mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-09-22 22:04:48 -04:00
Option to automatically reopen databases which were last opened.
This commit is contained in:
parent
7ff475977e
commit
850c7c7ecf
6 changed files with 47 additions and 21 deletions
|
@ -88,6 +88,7 @@ void Config::init(const QString& fileName)
|
||||||
m_settings.reset(new QSettings(fileName, QSettings::IniFormat));
|
m_settings.reset(new QSettings(fileName, QSettings::IniFormat));
|
||||||
|
|
||||||
m_defaults.insert("RememberLastDatabases", true);
|
m_defaults.insert("RememberLastDatabases", true);
|
||||||
|
m_defaults.insert("AutoReopenLastDatabases", true);
|
||||||
m_defaults.insert("ModifiedOnExpandedStateChanges", true);
|
m_defaults.insert("ModifiedOnExpandedStateChanges", true);
|
||||||
m_defaults.insert("AutoSaveAfterEveryChange", false);
|
m_defaults.insert("AutoSaveAfterEveryChange", false);
|
||||||
m_defaults.insert("AutoSaveOnExit", false);
|
m_defaults.insert("AutoSaveOnExit", false);
|
||||||
|
|
|
@ -66,16 +66,7 @@ DatabaseTabWidget::~DatabaseTabWidget()
|
||||||
|
|
||||||
void DatabaseTabWidget::toggleTabbar()
|
void DatabaseTabWidget::toggleTabbar()
|
||||||
{
|
{
|
||||||
if (count() > 1) {
|
tabBar()->setVisible(count() > 1);
|
||||||
if (!tabBar()->isVisible()) {
|
|
||||||
tabBar()->show();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (tabBar()->isVisible()) {
|
|
||||||
tabBar()->hide();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DatabaseTabWidget::newDatabase()
|
void DatabaseTabWidget::newDatabase()
|
||||||
|
@ -148,7 +139,7 @@ void DatabaseTabWidget::openDatabase(const QString& fileName, const QString& pw,
|
||||||
|
|
||||||
insertDatabase(db, dbStruct);
|
insertDatabase(db, dbStruct);
|
||||||
|
|
||||||
updateLastDatabases(dbStruct.filePath);
|
updateRecentDatabases(dbStruct.filePath);
|
||||||
|
|
||||||
if (!pw.isNull() || !keyFile.isEmpty()) {
|
if (!pw.isNull() || !keyFile.isEmpty()) {
|
||||||
dbStruct.dbWidget->switchToOpenDatabase(dbStruct.filePath, pw, keyFile);
|
dbStruct.dbWidget->switchToOpenDatabase(dbStruct.filePath, pw, keyFile);
|
||||||
|
@ -235,8 +226,25 @@ void DatabaseTabWidget::deleteDatabase(Database* db)
|
||||||
delete db;
|
delete db;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DatabaseTabWidget::reopenLastDatabases()
|
||||||
|
{
|
||||||
|
if (config()->get("AutoReopenLastDatabases", false).toBool()) {
|
||||||
|
int index = count();
|
||||||
|
Q_FOREACH (const QString & database, config()->get("LastOpenDatabases", QVariant()).toStringList())
|
||||||
|
openDatabase(database);
|
||||||
|
setCurrentIndex(index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool DatabaseTabWidget::closeAllDatabases()
|
bool DatabaseTabWidget::closeAllDatabases()
|
||||||
{
|
{
|
||||||
|
QStringList reloadDatabases;
|
||||||
|
if (config()->get("AutoReopenLastDatabases", false).toBool()) {
|
||||||
|
for (int i = 0; i < count(); i ++)
|
||||||
|
reloadDatabases << indexDatabaseManagerStruct(i).filePath;
|
||||||
|
}
|
||||||
|
config()->set("LastOpenDatabases", reloadDatabases);
|
||||||
|
|
||||||
while (!m_dbList.isEmpty()) {
|
while (!m_dbList.isEmpty()) {
|
||||||
if (!closeDatabase()) {
|
if (!closeDatabase()) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -299,7 +307,7 @@ void DatabaseTabWidget::saveDatabaseAs(Database* db)
|
||||||
dbStruct.fileName = fileInfo.fileName();
|
dbStruct.fileName = fileInfo.fileName();
|
||||||
dbStruct.dbWidget->updateFilename(dbStruct.filePath);
|
dbStruct.dbWidget->updateFilename(dbStruct.filePath);
|
||||||
updateTabName(db);
|
updateTabName(db);
|
||||||
updateLastDatabases(dbStruct.filePath);
|
updateRecentDatabases(dbStruct.filePath);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
QMessageBox::critical(this, tr("Error"), tr("Writing the database failed.") + "\n\n"
|
QMessageBox::critical(this, tr("Error"), tr("Writing the database failed.") + "\n\n"
|
||||||
|
@ -545,7 +553,7 @@ void DatabaseTabWidget::modified()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DatabaseTabWidget::updateLastDatabases(const QString& filename)
|
void DatabaseTabWidget::updateRecentDatabases(const QString& filename)
|
||||||
{
|
{
|
||||||
if (!config()->get("RememberLastDatabases").toBool()) {
|
if (!config()->get("RememberLastDatabases").toBool()) {
|
||||||
config()->set("LastDatabases", QVariant());
|
config()->set("LastDatabases", QVariant());
|
||||||
|
|
|
@ -65,6 +65,7 @@ public Q_SLOTS:
|
||||||
void saveDatabaseAs(int index = -1);
|
void saveDatabaseAs(int index = -1);
|
||||||
bool closeDatabase(int index = -1);
|
bool closeDatabase(int index = -1);
|
||||||
void closeDatabaseFromSender();
|
void closeDatabaseFromSender();
|
||||||
|
void reopenLastDatabases();
|
||||||
bool closeAllDatabases();
|
bool closeAllDatabases();
|
||||||
void changeMasterKey();
|
void changeMasterKey();
|
||||||
void changeDatabaseSettings();
|
void changeDatabaseSettings();
|
||||||
|
@ -93,7 +94,7 @@ private:
|
||||||
DatabaseManagerStruct indexDatabaseManagerStruct(int index);
|
DatabaseManagerStruct indexDatabaseManagerStruct(int index);
|
||||||
Database* databaseFromDatabaseWidget(DatabaseWidget* dbWidget);
|
Database* databaseFromDatabaseWidget(DatabaseWidget* dbWidget);
|
||||||
void insertDatabase(Database* db, const DatabaseManagerStruct& dbStruct);
|
void insertDatabase(Database* db, const DatabaseManagerStruct& dbStruct);
|
||||||
void updateLastDatabases(const QString& filename);
|
void updateRecentDatabases(const QString& filename);
|
||||||
void connectDatabase(Database* newDb, Database* oldDb = Q_NULLPTR);
|
void connectDatabase(Database* newDb, Database* oldDb = Q_NULLPTR);
|
||||||
|
|
||||||
KeePass2Writer m_writer;
|
KeePass2Writer m_writer;
|
||||||
|
|
|
@ -227,6 +227,8 @@ MainWindow::MainWindow()
|
||||||
|
|
||||||
m_actionMultiplexer.connect(m_ui->actionSearch, SIGNAL(triggered()),
|
m_actionMultiplexer.connect(m_ui->actionSearch, SIGNAL(triggered()),
|
||||||
SLOT(toggleSearch()));
|
SLOT(toggleSearch()));
|
||||||
|
|
||||||
|
m_ui->tabWidget->reopenLastDatabases();
|
||||||
}
|
}
|
||||||
|
|
||||||
MainWindow::~MainWindow()
|
MainWindow::~MainWindow()
|
||||||
|
|
|
@ -63,8 +63,12 @@ SettingsWidget::SettingsWidget(QWidget* parent)
|
||||||
connect(m_generalUi->autoSaveAfterEveryChangeCheckBox, SIGNAL(toggled(bool)),
|
connect(m_generalUi->autoSaveAfterEveryChangeCheckBox, SIGNAL(toggled(bool)),
|
||||||
this, SLOT(enableAutoSaveOnExit(bool)));
|
this, SLOT(enableAutoSaveOnExit(bool)));
|
||||||
|
|
||||||
|
connect(m_generalUi->rememberLastDatabasesCheckBox, SIGNAL(toggled(bool)),
|
||||||
|
m_generalUi->autoReopenLastDatabases, SLOT(setEnabled(bool)));
|
||||||
|
|
||||||
connect(m_secUi->clearClipboardCheckBox, SIGNAL(toggled(bool)),
|
connect(m_secUi->clearClipboardCheckBox, SIGNAL(toggled(bool)),
|
||||||
m_secUi->clearClipboardSpinBox, SLOT(setEnabled(bool)));
|
m_secUi->clearClipboardSpinBox, SLOT(setEnabled(bool)));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SettingsWidget::~SettingsWidget()
|
SettingsWidget::~SettingsWidget()
|
||||||
|
@ -82,6 +86,7 @@ void SettingsWidget::addSettingsPage(ISettingsPage *page)
|
||||||
void SettingsWidget::loadSettings()
|
void SettingsWidget::loadSettings()
|
||||||
{
|
{
|
||||||
m_generalUi->rememberLastDatabasesCheckBox->setChecked(config()->get("RememberLastDatabases").toBool());
|
m_generalUi->rememberLastDatabasesCheckBox->setChecked(config()->get("RememberLastDatabases").toBool());
|
||||||
|
m_generalUi->autoReopenLastDatabases->setChecked(config()->get("AutoReopenLastDatabases").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());
|
||||||
|
@ -104,6 +109,8 @@ 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("AutoReopenLastDatabases", m_generalUi->rememberLastDatabasesCheckBox->isChecked()
|
||||||
|
&& m_generalUi->autoReopenLastDatabases->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());
|
||||||
|
|
|
@ -7,21 +7,21 @@
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>456</width>
|
<width>456</width>
|
||||||
<height>146</height>
|
<height>172</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QFormLayout" name="formLayout">
|
<layout class="QFormLayout" name="formLayout">
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<widget class="QCheckBox" name="rememberLastDatabasesCheckBox">
|
<widget class="QCheckBox" name="rememberLastDatabasesCheckBox">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Remember last databases</string>
|
<string>Remember recent databases</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="checked">
|
<property name="checked">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</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="autoReopenLastDatabases">
|
||||||
|
<property name="text">
|
||||||
|
<string>Automatically reopen last databases</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<customwidgets>
|
<customwidgets>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue