mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-05-08 01:25:00 -04:00
Add settings option to control if previous databases are opened on startup.
Closes #36
This commit is contained in:
parent
6f92188323
commit
bbf183bef7
4 changed files with 24 additions and 9 deletions
|
@ -398,15 +398,21 @@ void MainWindow::databaseTabChanged(int tabIndex)
|
||||||
void MainWindow::closeEvent(QCloseEvent* event)
|
void MainWindow::closeEvent(QCloseEvent* event)
|
||||||
{
|
{
|
||||||
openDatabases.clear();
|
openDatabases.clear();
|
||||||
connect(m_ui->tabWidget, SIGNAL(databaseWithFileClosed(QString)), this, SLOT(rememberOpenDatabases(QString)));
|
bool openPreviousDatabasesOnStartup = config()->get("OpenPreviousDatabasesOnStartup").toBool();
|
||||||
|
|
||||||
|
if (openPreviousDatabasesOnStartup) {
|
||||||
|
connect(m_ui->tabWidget, SIGNAL(databaseWithFileClosed(QString)), this, SLOT(rememberOpenDatabases(QString)));
|
||||||
|
}
|
||||||
|
|
||||||
if (!m_ui->tabWidget->closeAllDatabases()) {
|
if (!m_ui->tabWidget->closeAllDatabases()) {
|
||||||
event->ignore();
|
event->ignore();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
event->accept();
|
event->accept();
|
||||||
}
|
}
|
||||||
disconnect(m_ui->tabWidget, SIGNAL(databaseWithFileClosed(QString)), this, SLOT(rememberOpenDatabases(QString)));
|
|
||||||
if (config()->get("OpenPreviousDatabasesOnStartup").toBool()) {
|
if (openPreviousDatabasesOnStartup) {
|
||||||
|
disconnect(m_ui->tabWidget, SIGNAL(databaseWithFileClosed(QString)), this, SLOT(rememberOpenDatabases(QString)));
|
||||||
config()->set("OpenDatabasesOnExit", openDatabases);
|
config()->set("OpenDatabasesOnExit", openDatabases);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,6 +53,7 @@ SettingsWidget::~SettingsWidget()
|
||||||
void SettingsWidget::loadSettings()
|
void SettingsWidget::loadSettings()
|
||||||
{
|
{
|
||||||
m_generalUi->rememberLastDatabasesCheckBox->setChecked(config()->get("RememberLastDatabases").toBool());
|
m_generalUi->rememberLastDatabasesCheckBox->setChecked(config()->get("RememberLastDatabases").toBool());
|
||||||
|
m_generalUi->openPreviousDatabasesOnStartupCheckBox->setChecked(config()->get("OpenPreviousDatabasesOnStartup").toBool());
|
||||||
m_generalUi->modifiedExpandedChangedCheckBox->setChecked(config()->get("ModifiedOnExpandedStateChanges").toBool());
|
m_generalUi->modifiedExpandedChangedCheckBox->setChecked(config()->get("ModifiedOnExpandedStateChanges").toBool());
|
||||||
m_generalUi->autoSaveAfterEveryChangeCheckBox->setChecked(config()->get("AutoSaveAfterEveryChange").toBool());
|
m_generalUi->autoSaveAfterEveryChangeCheckBox->setChecked(config()->get("AutoSaveAfterEveryChange").toBool());
|
||||||
m_generalUi->autoSaveOnExitCheckBox->setChecked(config()->get("AutoSaveOnExit").toBool());
|
m_generalUi->autoSaveOnExitCheckBox->setChecked(config()->get("AutoSaveOnExit").toBool());
|
||||||
|
@ -72,6 +73,7 @@ void SettingsWidget::loadSettings()
|
||||||
void SettingsWidget::saveSettings()
|
void SettingsWidget::saveSettings()
|
||||||
{
|
{
|
||||||
config()->set("RememberLastDatabases", m_generalUi->rememberLastDatabasesCheckBox->isChecked());
|
config()->set("RememberLastDatabases", m_generalUi->rememberLastDatabasesCheckBox->isChecked());
|
||||||
|
config()->set("OpenPreviousDatabasesOnStartup", m_generalUi->openPreviousDatabasesOnStartupCheckBox->isChecked());
|
||||||
config()->set("ModifiedOnExpandedStateChanges", m_generalUi->modifiedExpandedChangedCheckBox->isChecked());
|
config()->set("ModifiedOnExpandedStateChanges", m_generalUi->modifiedExpandedChangedCheckBox->isChecked());
|
||||||
config()->set("AutoSaveAfterEveryChange", m_generalUi->autoSaveAfterEveryChangeCheckBox->isChecked());
|
config()->set("AutoSaveAfterEveryChange", m_generalUi->autoSaveAfterEveryChangeCheckBox->isChecked());
|
||||||
config()->set("AutoSaveOnExit", m_generalUi->autoSaveOnExitCheckBox->isChecked());
|
config()->set("AutoSaveOnExit", m_generalUi->autoSaveOnExitCheckBox->isChecked());
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="0">
|
<item row="2" column="0">
|
||||||
<widget class="QCheckBox" name="modifiedExpandedChangedCheckBox">
|
<widget class="QCheckBox" name="modifiedExpandedChangedCheckBox">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Mark as modified on expanded state changes</string>
|
<string>Mark as modified on expanded state changes</string>
|
||||||
|
@ -31,30 +31,37 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="0">
|
<item row="4" column="0">
|
||||||
<widget class="QCheckBox" name="autoSaveAfterEveryChangeCheckBox">
|
<widget class="QCheckBox" name="autoSaveAfterEveryChangeCheckBox">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Automatically save after every change</string>
|
<string>Automatically save after every change</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0">
|
<item row="3" column="0">
|
||||||
<widget class="QCheckBox" name="autoSaveOnExitCheckBox">
|
<widget class="QCheckBox" name="autoSaveOnExitCheckBox">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Automatically save on exit</string>
|
<string>Automatically save on exit</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="4" column="0">
|
<item row="5" column="0">
|
||||||
<widget class="QLabel" name="label">
|
<widget class="QLabel" name="label">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Global Auto-Type shortcut</string>
|
<string>Global Auto-Type shortcut</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="4" column="1">
|
<item row="5" column="1">
|
||||||
<widget class="ShortcutWidget" name="autoTypeShortcutWidget"/>
|
<widget class="ShortcutWidget" name="autoTypeShortcutWidget"/>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QCheckBox" name="openPreviousDatabasesOnStartupCheckBox">
|
||||||
|
<property name="text">
|
||||||
|
<string>Open previous databases on startup</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<customwidgets>
|
<customwidgets>
|
||||||
|
|
|
@ -62,7 +62,7 @@ int main(int argc, char** argv)
|
||||||
QStringList filenames = config()->get("OpenDatabasesOnExit").toStringList();
|
QStringList filenames = config()->get("OpenDatabasesOnExit").toStringList();
|
||||||
Q_FOREACH (const QString& filename, filenames) {
|
Q_FOREACH (const QString& filename, filenames) {
|
||||||
if (!filename.isEmpty() && QFile::exists(filename)) {
|
if (!filename.isEmpty() && QFile::exists(filename)) {
|
||||||
mainWindow.openDatabase(filename, argumentMap.value("password"), QString());
|
mainWindow.openDatabase(filename, QString(), QString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue