Fix annoyances with access control dialog

* Don't send database locked/unlocked messages when "search in all databases" is enabled
* After access control dialog closes, only hide main window on macOS, and then only if previously hidden.
This commit is contained in:
varjolintu 2020-04-24 18:38:33 +03:00 committed by Jonathan White
parent 45848c3f61
commit 48bf4fb85d
2 changed files with 18 additions and 4 deletions

View File

@ -755,9 +755,12 @@ QList<Entry*> BrowserService::confirmEntries(QList<Entry*>& pwEntriesToConfirm,
}
m_dialogActive = true;
bool wasAppActive = qApp->activeWindow() == getMainWindow()->window();
BrowserAccessControlDialog accessControlDialog;
connect(m_currentDatabaseWidget, SIGNAL(databaseLocked()), &accessControlDialog, SLOT(reject()));
connect(this, SIGNAL(activeDatabaseChanged()), &accessControlDialog, SLOT(reject()));
connect(&accessControlDialog, &BrowserAccessControlDialog::disableAccess, [&](QTableWidgetItem* item) {
auto entry = pwEntriesToConfirm[item->row()];
BrowserEntryConfig config;
@ -795,8 +798,18 @@ QList<Entry*> BrowserService::confirmEntries(QList<Entry*>& pwEntriesToConfirm,
}
}
#ifdef Q_OS_MAC
// Re-hide the application if it wasn't visible before
// only affects macOS because dialogs force the main window to show
if (!wasAppActive) {
hideWindow();
}
#else
Q_UNUSED(wasAppActive);
#endif
m_dialogActive = false;
hideWindow();
return allowedEntries;
}
@ -1238,14 +1251,16 @@ void BrowserService::databaseUnlocked(DatabaseWidget* dbWidget)
void BrowserService::activeDatabaseChanged(DatabaseWidget* dbWidget)
{
m_currentDatabaseWidget = dbWidget;
if (dbWidget) {
// Only emit these signals when we are not searching in all databases
if (dbWidget && !browserSettings()->searchInAllDatabases()) {
if (dbWidget->isLocked()) {
databaseLocked(dbWidget);
} else {
databaseUnlocked(dbWidget);
}
}
m_currentDatabaseWidget = dbWidget;
}
void BrowserService::processClientMessage(const QJsonObject& message)

View File

@ -34,7 +34,6 @@ enum
max_length = 16 * 1024
};
class DatabaseTabWidget;
class DatabaseWidget;
class BrowserHost;
class BrowserAction;