mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-11-21 07:20:28 -05:00
Fix saving order of open databases
* Order of previously open databases are preserved when closing the application * The active database on closing remains active after startup * Nested open previous databases and remember key files under the remember previously open databases setting * Fix #1675
This commit is contained in:
parent
28a3824d2d
commit
72f0e9ba77
6 changed files with 135 additions and 62 deletions
|
|
@ -903,24 +903,27 @@ void MainWindow::saveWindowInformation()
|
|||
|
||||
bool MainWindow::saveLastDatabases()
|
||||
{
|
||||
bool accept;
|
||||
m_openDatabases.clear();
|
||||
bool openPreviousDatabasesOnStartup = config()->get("OpenPreviousDatabasesOnStartup").toBool();
|
||||
if (config()->get("OpenPreviousDatabasesOnStartup").toBool()) {
|
||||
auto currentDbWidget = m_ui->tabWidget->currentDatabaseWidget();
|
||||
if (currentDbWidget) {
|
||||
config()->set("LastActiveDatabase", currentDbWidget->database()->filePath());
|
||||
} else {
|
||||
config()->set("LastActiveDatabase", {});
|
||||
}
|
||||
|
||||
if (openPreviousDatabasesOnStartup) {
|
||||
connect(
|
||||
m_ui->tabWidget, SIGNAL(databaseClosed(const QString&)), this, SLOT(rememberOpenDatabases(const QString&)));
|
||||
QStringList openDatabases;
|
||||
for (int i=0; i < m_ui->tabWidget->count(); ++i) {
|
||||
auto dbWidget = m_ui->tabWidget->databaseWidgetFromIndex(i);
|
||||
openDatabases.append(dbWidget->database()->filePath());
|
||||
}
|
||||
|
||||
config()->set("LastOpenedDatabases", openDatabases);
|
||||
} else {
|
||||
config()->set("LastActiveDatabase", {});
|
||||
config()->set("LastOpenedDatabases", {});
|
||||
}
|
||||
|
||||
accept = m_ui->tabWidget->closeAllDatabaseTabs();
|
||||
|
||||
if (openPreviousDatabasesOnStartup) {
|
||||
disconnect(
|
||||
m_ui->tabWidget, SIGNAL(databaseClosed(const QString&)), this, SLOT(rememberOpenDatabases(const QString&)));
|
||||
config()->set("LastOpenedDatabases", m_openDatabases);
|
||||
}
|
||||
|
||||
return accept;
|
||||
return m_ui->tabWidget->closeAllDatabaseTabs();
|
||||
}
|
||||
|
||||
void MainWindow::updateTrayIcon()
|
||||
|
|
@ -985,11 +988,6 @@ void MainWindow::setShortcut(QAction* action, QKeySequence::StandardKey standard
|
|||
}
|
||||
}
|
||||
|
||||
void MainWindow::rememberOpenDatabases(const QString& filePath)
|
||||
{
|
||||
m_openDatabases.prepend(filePath);
|
||||
}
|
||||
|
||||
void MainWindow::applySettingsChanges()
|
||||
{
|
||||
int timeout = config()->get("security/lockdatabaseidlesec").toInt() * 1000;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue