mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-10-01 01:26:01 -04:00
Added a new DatabaseWidget modal state.
Commit d8857bf4
attempted to fix currentMode() while the DB had not
yet been opened. However, the fix meant that the title bar always
displayed the state as being "locked". This change works around the
issue by introducing a new modal state for when the DB is not yet
open.
This commit is contained in:
parent
fae4f69b8c
commit
a627870bbb
@ -229,7 +229,8 @@ void DatabaseTabWidget::checkReloadDatabases()
|
|||||||
|
|
||||||
ReloadBehavior reloadBehavior = ReloadBehavior(config()->get("ReloadBehavior").toInt());
|
ReloadBehavior reloadBehavior = ReloadBehavior(config()->get("ReloadBehavior").toInt());
|
||||||
if ( (reloadBehavior == AlwaysAsk)
|
if ( (reloadBehavior == AlwaysAsk)
|
||||||
|| (reloadBehavior == ReloadUnmodified && mode == DatabaseWidget::EditMode)
|
|| (reloadBehavior == ReloadUnmodified && (mode == DatabaseWidget::EditMode
|
||||||
|
|| mode == DatabaseWidget::OpenMode))
|
||||||
|| (reloadBehavior == ReloadUnmodified && dbStruct.modified)) {
|
|| (reloadBehavior == ReloadUnmodified && dbStruct.modified)) {
|
||||||
int res = QMessageBox::warning(this, fi.exists() ? tr("Database file changed") : tr("Database file removed"),
|
int res = QMessageBox::warning(this, fi.exists() ? tr("Database file changed") : tr("Database file removed"),
|
||||||
tr("Do you want to discard your changes and reload?"),
|
tr("Do you want to discard your changes and reload?"),
|
||||||
@ -296,7 +297,8 @@ bool DatabaseTabWidget::closeDatabase(Database* db)
|
|||||||
if (dbName.right(1) == "*") {
|
if (dbName.right(1) == "*") {
|
||||||
dbName.chop(1);
|
dbName.chop(1);
|
||||||
}
|
}
|
||||||
if (dbStruct.dbWidget->currentMode() == DatabaseWidget::EditMode && db->hasKey()) {
|
if ((dbStruct.dbWidget->currentMode() == DatabaseWidget::EditMode ||
|
||||||
|
dbStruct.dbWidget->currentMode() == DatabaseWidget::OpenMode) && db->hasKey()) {
|
||||||
QMessageBox::StandardButton result =
|
QMessageBox::StandardButton result =
|
||||||
MessageBox::question(
|
MessageBox::question(
|
||||||
this, tr("Close?"),
|
this, tr("Close?"),
|
||||||
@ -631,7 +633,9 @@ bool DatabaseTabWidget::hasLockableDatabases()
|
|||||||
i.next();
|
i.next();
|
||||||
DatabaseWidget::Mode mode = i.value().dbWidget->currentMode();
|
DatabaseWidget::Mode mode = i.value().dbWidget->currentMode();
|
||||||
|
|
||||||
if ((mode == DatabaseWidget::ViewMode || mode == DatabaseWidget::EditMode)
|
if ((mode == DatabaseWidget::ViewMode ||
|
||||||
|
mode == DatabaseWidget::EditMode ||
|
||||||
|
mode == DatabaseWidget::OpenMode)
|
||||||
&& i.value().dbWidget->dbHasKey()) {
|
&& i.value().dbWidget->dbHasKey()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -647,7 +651,9 @@ void DatabaseTabWidget::lockDatabases()
|
|||||||
i.next();
|
i.next();
|
||||||
DatabaseWidget::Mode mode = i.value().dbWidget->currentMode();
|
DatabaseWidget::Mode mode = i.value().dbWidget->currentMode();
|
||||||
|
|
||||||
if ((mode == DatabaseWidget::ViewMode || mode == DatabaseWidget::EditMode)
|
if ((mode == DatabaseWidget::ViewMode ||
|
||||||
|
mode == DatabaseWidget::EditMode ||
|
||||||
|
mode == DatabaseWidget::OpenMode)
|
||||||
&& i.value().dbWidget->dbHasKey()) {
|
&& i.value().dbWidget->dbHasKey()) {
|
||||||
i.value().dbWidget->lock();
|
i.value().dbWidget->lock();
|
||||||
updateTabName(i.key());
|
updateTabName(i.key());
|
||||||
|
@ -173,10 +173,12 @@ DatabaseWidget::Mode DatabaseWidget::currentMode()
|
|||||||
else if (currentWidget() == m_mainWidget) {
|
else if (currentWidget() == m_mainWidget) {
|
||||||
return DatabaseWidget::ViewMode;
|
return DatabaseWidget::ViewMode;
|
||||||
}
|
}
|
||||||
else if (currentWidget() == m_unlockDatabaseWidget ||
|
else if (currentWidget() == m_unlockDatabaseWidget) {
|
||||||
currentWidget() == m_databaseOpenWidget) {
|
|
||||||
return DatabaseWidget::LockedMode;
|
return DatabaseWidget::LockedMode;
|
||||||
}
|
}
|
||||||
|
else if (currentWidget() == m_databaseOpenWidget) {
|
||||||
|
return DatabaseWidget::OpenMode;
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
return DatabaseWidget::EditMode;
|
return DatabaseWidget::EditMode;
|
||||||
}
|
}
|
||||||
|
@ -55,6 +55,7 @@ public:
|
|||||||
None,
|
None,
|
||||||
ViewMode,
|
ViewMode,
|
||||||
EditMode,
|
EditMode,
|
||||||
|
OpenMode,
|
||||||
LockedMode
|
LockedMode
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -394,6 +394,7 @@ void MainWindow::setMenuActionState(DatabaseWidget::Mode mode)
|
|||||||
}
|
}
|
||||||
case DatabaseWidget::EditMode:
|
case DatabaseWidget::EditMode:
|
||||||
case DatabaseWidget::LockedMode:
|
case DatabaseWidget::LockedMode:
|
||||||
|
case DatabaseWidget::OpenMode:
|
||||||
Q_FOREACH (QAction* action, m_ui->menuEntries->actions()) {
|
Q_FOREACH (QAction* action, m_ui->menuEntries->actions()) {
|
||||||
action->setEnabled(false);
|
action->setEnabled(false);
|
||||||
}
|
}
|
||||||
|
@ -76,6 +76,7 @@ bool Service::isDatabaseOpened() const
|
|||||||
switch(dbWidget->currentMode()) {
|
switch(dbWidget->currentMode()) {
|
||||||
case DatabaseWidget::None:
|
case DatabaseWidget::None:
|
||||||
case DatabaseWidget::LockedMode:
|
case DatabaseWidget::LockedMode:
|
||||||
|
case DatabaseWidget::OpenMode:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DatabaseWidget::ViewMode:
|
case DatabaseWidget::ViewMode:
|
||||||
@ -93,6 +94,7 @@ bool Service::openDatabase()
|
|||||||
switch(dbWidget->currentMode()) {
|
switch(dbWidget->currentMode()) {
|
||||||
case DatabaseWidget::None:
|
case DatabaseWidget::None:
|
||||||
case DatabaseWidget::LockedMode:
|
case DatabaseWidget::LockedMode:
|
||||||
|
case DatabaseWidget::OpenMode:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DatabaseWidget::ViewMode:
|
case DatabaseWidget::ViewMode:
|
||||||
|
Loading…
Reference in New Issue
Block a user