Skip to content

Commit

Permalink
Fix annoyances with access control dialog
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
varjolintu authored and droidmonkey committed May 16, 2020
1 parent 45848c3 commit fc0c063
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
21 changes: 18 additions & 3 deletions src/browser/BrowserService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -755,9 +755,12 @@ QList<Entry*> BrowserService::confirmEntries(QList<Entry*>& pwEntriesToConfirm,
}

m_dialogActive = true;
bool applicationVisible = getMainWindow()->isVisible();
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;
Expand Down Expand Up @@ -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 (!applicationVisible) {
hideWindow();
}
#else
Q_UNUSED(applicationVisible);
#endif

m_dialogActive = false;
hideWindow();

return allowedEntries;
}

Expand Down Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion src/browser/BrowserService.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ enum
max_length = 16 * 1024
};

class DatabaseTabWidget;
class DatabaseWidget;
class BrowserHost;
class BrowserAction;
Expand Down

0 comments on commit fc0c063

Please sign in to comment.