diff --git a/src/gui/DatabaseTabWidget.cpp b/src/gui/DatabaseTabWidget.cpp index 16030ff9c..6a8b0118a 100644 --- a/src/gui/DatabaseTabWidget.cpp +++ b/src/gui/DatabaseTabWidget.cpp @@ -45,7 +45,6 @@ const int DatabaseTabWidget::LastDatabasesCount = 5; DatabaseTabWidget::DatabaseTabWidget(QWidget* parent) : QTabWidget(parent) - , m_window(parent->window()) { DragTabBar* tabBar = new DragTabBar(this); tabBar->setDrawBase(false); @@ -94,7 +93,7 @@ void DatabaseTabWidget::newDatabase() void DatabaseTabWidget::openDatabase() { QString filter = QString("%1 (*.kdbx);;%2 (*)").arg(tr("KeePass 2 Database"), tr("All files")); - QString fileName = fileDialog()->getOpenFileName(m_window, tr("Open database"), QString(), + QString fileName = fileDialog()->getOpenFileName(this, tr("Open database"), QString(), filter); if (!fileName.isEmpty()) { openDatabase(fileName); @@ -287,7 +286,7 @@ void DatabaseTabWidget::saveDatabaseAs(Database* db) if (dbStruct.saveToFilename) { oldFileName = dbStruct.filePath; } - QString fileName = fileDialog()->getSaveFileName(m_window, tr("Save database as"), + QString fileName = fileDialog()->getSaveFileName(this, tr("Save database as"), oldFileName, tr("KeePass 2 Database").append(" (*.kdbx)")); if (!fileName.isEmpty()) { bool result = false; diff --git a/src/gui/DatabaseTabWidget.h b/src/gui/DatabaseTabWidget.h index eba810449..37aea0fb2 100644 --- a/src/gui/DatabaseTabWidget.h +++ b/src/gui/DatabaseTabWidget.h @@ -48,7 +48,7 @@ class DatabaseTabWidget : public QTabWidget Q_OBJECT public: - explicit DatabaseTabWidget(QWidget* parent); + explicit DatabaseTabWidget(QWidget* parent = Q_NULLPTR); ~DatabaseTabWidget(); void openDatabase(const QString& fileName, const QString& pw = QString(), const QString& keyFile = QString()); @@ -107,7 +107,6 @@ private: void updateLastDatabases(const QString& filename); void connectDatabase(Database* newDb, Database* oldDb = Q_NULLPTR); - QWidget* const m_window; KeePass2Writer m_writer; QHash m_dbList; }; diff --git a/src/gui/FileDialog.cpp b/src/gui/FileDialog.cpp index 1d24fc9f0..25b508e50 100644 --- a/src/gui/FileDialog.cpp +++ b/src/gui/FileDialog.cpp @@ -38,6 +38,11 @@ QString FileDialog::getOpenFileName(QWidget* parent, const QString& caption, QSt QString result = QFileDialog::getOpenFileName(parent, caption, dir, filter, selectedFilter, options); + // on Mac OS X the focus is lost after closing the native dialog + if (parent) { + parent->activateWindow(); + } + if (!result.isEmpty()) { config()->set("LastDir", QFileInfo(result).absolutePath()); } @@ -63,6 +68,11 @@ QString FileDialog::getSaveFileName(QWidget* parent, const QString& caption, QSt QString result = QFileDialog::getSaveFileName(parent, caption, dir, filter, selectedFilter, options); + // on Mac OS X the focus is lost after closing the native dialog + if (parent) { + parent->activateWindow(); + } + if (!result.isEmpty()) { config()->set("LastDir", QFileInfo(result).absolutePath()); }