mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-12-25 15:29:44 -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
@ -112,6 +112,10 @@ namespace Bootstrap
|
||||
mainWindow.openDatabase(filename);
|
||||
}
|
||||
}
|
||||
auto lastActiveFile = config()->get("LastActiveDatabase").toString();
|
||||
if (!lastActiveFile.isEmpty()) {
|
||||
mainWindow.openDatabase(lastActiveFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -81,7 +81,8 @@ ApplicationSettingsWidget::ApplicationSettingsWidget(QWidget* parent)
|
||||
// clang-format off
|
||||
connect(m_generalUi->autoSaveAfterEveryChangeCheckBox, SIGNAL(toggled(bool)), SLOT(autoSaveToggled(bool)));
|
||||
connect(m_generalUi->systrayShowCheckBox, SIGNAL(toggled(bool)), SLOT(systrayToggled(bool)));
|
||||
connect(m_generalUi->toolbarHideCheckBox, SIGNAL(toggled(bool)), SLOT(enableToolbarSettings(bool)));
|
||||
connect(m_generalUi->toolbarHideCheckBox, SIGNAL(toggled(bool)), SLOT(toolbarSettingsToggled(bool)));
|
||||
connect(m_generalUi->rememberLastDatabasesCheckBox, SIGNAL(toggled(bool)), SLOT(rememberDatabasesToggled(bool)));
|
||||
|
||||
connect(m_secUi->clearClipboardCheckBox, SIGNAL(toggled(bool)),
|
||||
m_secUi->clearClipboardSpinBox, SLOT(setEnabled(bool)));
|
||||
@ -294,11 +295,13 @@ void ApplicationSettingsWidget::saveSettings()
|
||||
|
||||
// Security: clear storage if related settings are disabled
|
||||
if (!config()->get("RememberLastDatabases").toBool()) {
|
||||
config()->set("LastDatabases", QVariant());
|
||||
config()->set("LastDatabases", {});
|
||||
config()->set("OpenPreviousDatabasesOnStartup", {});
|
||||
config()->set("LastActiveDatabase", {});
|
||||
}
|
||||
|
||||
if (!config()->get("RememberLastKeyFiles").toBool()) {
|
||||
config()->set("LastKeyFiles", QVariant());
|
||||
config()->set("LastKeyFiles", {});
|
||||
config()->set("LastDir", "");
|
||||
}
|
||||
|
||||
@ -330,9 +333,20 @@ void ApplicationSettingsWidget::systrayToggled(bool checked)
|
||||
m_generalUi->systrayMinimizeToTrayCheckBox->setEnabled(checked);
|
||||
}
|
||||
|
||||
void ApplicationSettingsWidget::enableToolbarSettings(bool checked)
|
||||
void ApplicationSettingsWidget::toolbarSettingsToggled(bool checked)
|
||||
{
|
||||
m_generalUi->toolbarMovableCheckBox->setEnabled(!checked);
|
||||
m_generalUi->toolButtonStyleComboBox->setEnabled(!checked);
|
||||
m_generalUi->toolButtonStyleLabel->setEnabled(!checked);
|
||||
}
|
||||
|
||||
void ApplicationSettingsWidget::rememberDatabasesToggled(bool checked)
|
||||
{
|
||||
if (!checked) {
|
||||
m_generalUi->rememberLastKeyFilesCheckBox->setChecked(false);
|
||||
m_generalUi->openPreviousDatabasesOnStartupCheckBox->setChecked(false);
|
||||
}
|
||||
|
||||
m_generalUi->rememberLastKeyFilesCheckBox->setEnabled(checked);
|
||||
m_generalUi->openPreviousDatabasesOnStartupCheckBox->setEnabled(checked);
|
||||
}
|
||||
|
@ -55,7 +55,8 @@ private slots:
|
||||
void reject();
|
||||
void autoSaveToggled(bool checked);
|
||||
void systrayToggled(bool checked);
|
||||
void enableToolbarSettings(bool checked);
|
||||
void toolbarSettingsToggled(bool checked);
|
||||
void rememberDatabasesToggled(bool checked);
|
||||
|
||||
private:
|
||||
QWidget* const m_secWidget;
|
||||
|
@ -49,33 +49,6 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="rememberLastDatabasesCheckBox">
|
||||
<property name="text">
|
||||
<string>Remember last databases</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="rememberLastKeyFilesCheckBox">
|
||||
<property name="text">
|
||||
<string>Remember last key files and security dongles</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="openPreviousDatabasesOnStartupCheckBox">
|
||||
<property name="text">
|
||||
<string>Load previous databases on startup</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="systrayMinimizeOnStartup">
|
||||
<property name="text">
|
||||
@ -83,6 +56,88 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="rememberLastDatabasesCheckBox">
|
||||
<property name="text">
|
||||
<string>Remember previously used databases</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="rememberDbSubLayout_2">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetMaximumSize</enum>
|
||||
</property>
|
||||
<item>
|
||||
<spacer name="toolbarMovableSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="openPreviousDatabasesOnStartupCheckBox">
|
||||
<property name="text">
|
||||
<string>Load previously open databases on startup</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="rememberDbSubLayout">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetMaximumSize</enum>
|
||||
</property>
|
||||
<item>
|
||||
<spacer name="toolbarMovableSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="rememberLastKeyFilesCheckBox">
|
||||
<property name="text">
|
||||
<string>Remember database key files and security dongles</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkForUpdatesOnStartupCheckBox">
|
||||
<property name="text">
|
||||
@ -218,7 +273,7 @@
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<width>20</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
@ -245,7 +300,7 @@
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="toolButtonStyleLayout">
|
||||
<property name="spacing">
|
||||
<number>15</number>
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<spacer name="toolButtonStyleSpacer">
|
||||
@ -257,7 +312,7 @@
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<width>20</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
@ -274,8 +329,11 @@
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">margin-right: 5px</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Button style</string>
|
||||
<string>Button style:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -326,7 +384,7 @@
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<width>20</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
@ -377,7 +435,7 @@
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<width>20</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
@ -407,7 +465,7 @@
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="languageLabelLayout_2">
|
||||
<property name="spacing">
|
||||
<number>15</number>
|
||||
<number>8</number>
|
||||
</property>
|
||||
<item alignment="Qt::AlignRight">
|
||||
<widget class="QLabel" name="languageLabel_2">
|
||||
@ -418,7 +476,7 @@
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Language</string>
|
||||
<string>Language:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -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;
|
||||
|
@ -105,7 +105,6 @@ private slots:
|
||||
void updateCopyAttributesMenu();
|
||||
void showEntryContextMenu(const QPoint& globalPos);
|
||||
void showGroupContextMenu(const QPoint& globalPos);
|
||||
void rememberOpenDatabases(const QString& filePath);
|
||||
void applySettingsChanges();
|
||||
void trayIconTriggered(QSystemTrayIcon::ActivationReason reason);
|
||||
void lockDatabasesAfterInactivity();
|
||||
@ -137,7 +136,6 @@ private:
|
||||
QAction* m_searchWidgetAction;
|
||||
QActionGroup* m_lastDatabasesActions;
|
||||
QActionGroup* m_copyAdditionalAttributeActions;
|
||||
QStringList m_openDatabases;
|
||||
InactivityTimer* m_inactivityTimer;
|
||||
InactivityTimer* m_touchIDinactivityTimer;
|
||||
int m_countDefaultAttributes;
|
||||
|
Loading…
Reference in New Issue
Block a user