mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-08-01 19:16:16 -04:00
parent
ba3baf3595
commit
f0985ff9d9
5 changed files with 22 additions and 0 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("OpenPreviousDatabasesOnStartup", 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);
|
||||||
|
|
|
@ -226,6 +226,9 @@ bool DatabaseTabWidget::closeDatabase(Database* db)
|
||||||
void DatabaseTabWidget::deleteDatabase(Database* db)
|
void DatabaseTabWidget::deleteDatabase(Database* db)
|
||||||
{
|
{
|
||||||
const DatabaseManagerStruct dbStruct = m_dbList.value(db);
|
const DatabaseManagerStruct dbStruct = m_dbList.value(db);
|
||||||
|
bool emitDatabaseWithFileClosed = dbStruct.saveToFilename;
|
||||||
|
QString filePath = dbStruct.filePath;
|
||||||
|
|
||||||
int index = databaseIndex(db);
|
int index = databaseIndex(db);
|
||||||
|
|
||||||
removeTab(index);
|
removeTab(index);
|
||||||
|
@ -233,6 +236,10 @@ void DatabaseTabWidget::deleteDatabase(Database* db)
|
||||||
m_dbList.remove(db);
|
m_dbList.remove(db);
|
||||||
delete dbStruct.dbWidget;
|
delete dbStruct.dbWidget;
|
||||||
delete db;
|
delete db;
|
||||||
|
|
||||||
|
if (emitDatabaseWithFileClosed) {
|
||||||
|
Q_EMIT databaseWithFileClosed(filePath);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DatabaseTabWidget::closeAllDatabases()
|
bool DatabaseTabWidget::closeAllDatabases()
|
||||||
|
|
|
@ -74,6 +74,7 @@ public Q_SLOTS:
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void tabNameChanged();
|
void tabNameChanged();
|
||||||
|
void databaseWithFileClosed(QString filePath);
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void updateTabName(Database* db);
|
void updateTabName(Database* db);
|
||||||
|
|
|
@ -397,12 +397,18 @@ void MainWindow::databaseTabChanged(int tabIndex)
|
||||||
|
|
||||||
void MainWindow::closeEvent(QCloseEvent* event)
|
void MainWindow::closeEvent(QCloseEvent* event)
|
||||||
{
|
{
|
||||||
|
openDatabases.clear();
|
||||||
|
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()) {
|
||||||
|
config()->set("OpenDatabasesOnExit", openDatabases);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::showEntryContextMenu(const QPoint& globalPos)
|
void MainWindow::showEntryContextMenu(const QPoint& globalPos)
|
||||||
|
@ -429,3 +435,8 @@ void MainWindow::setShortcut(QAction* action, QKeySequence::StandardKey standard
|
||||||
action->setShortcut(QKeySequence(fallback));
|
action->setShortcut(QKeySequence(fallback));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::rememberOpenDatabases(QString filePath)
|
||||||
|
{
|
||||||
|
openDatabases.append(filePath);
|
||||||
|
}
|
||||||
|
|
|
@ -57,6 +57,7 @@ private Q_SLOTS:
|
||||||
void showEntryContextMenu(const QPoint& globalPos);
|
void showEntryContextMenu(const QPoint& globalPos);
|
||||||
void showGroupContextMenu(const QPoint& globalPos);
|
void showGroupContextMenu(const QPoint& globalPos);
|
||||||
void saveToolbarState(bool value);
|
void saveToolbarState(bool value);
|
||||||
|
void rememberOpenDatabases(QString filePath);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static void setShortcut(QAction* action, QKeySequence::StandardKey standard, int fallback = 0);
|
static void setShortcut(QAction* action, QKeySequence::StandardKey standard, int fallback = 0);
|
||||||
|
@ -68,6 +69,7 @@ private:
|
||||||
QAction* m_clearHistoryAction;
|
QAction* m_clearHistoryAction;
|
||||||
QActionGroup* m_lastDatabasesActions;
|
QActionGroup* m_lastDatabasesActions;
|
||||||
QActionGroup* m_copyAdditionalAttributeActions;
|
QActionGroup* m_copyAdditionalAttributeActions;
|
||||||
|
QStringList openDatabases;
|
||||||
|
|
||||||
Q_DISABLE_COPY(MainWindow)
|
Q_DISABLE_COPY(MainWindow)
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue