mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-01-24 13:41:33 -05:00
Regain focus after native file dialogs have been closed.
For some reason this happens on Mac OS X. We work around it by calling activateWindow(). Closes #39
This commit is contained in:
parent
c0e91e4f16
commit
5786d0c279
@ -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;
|
||||
|
@ -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<Database*, DatabaseManagerStruct> m_dbList;
|
||||
};
|
||||
|
@ -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());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user