diff --git a/src/gui/DatabaseTabWidget.cpp b/src/gui/DatabaseTabWidget.cpp index 5c364f3c9..545a2bd82 100644 --- a/src/gui/DatabaseTabWidget.cpp +++ b/src/gui/DatabaseTabWidget.cpp @@ -229,7 +229,8 @@ void DatabaseTabWidget::checkReloadDatabases() ReloadBehavior reloadBehavior = ReloadBehavior(config()->get("ReloadBehavior").toInt()); if ( (reloadBehavior == AlwaysAsk) - || (reloadBehavior == ReloadUnmodified && mode == DatabaseWidget::EditMode) + || (reloadBehavior == ReloadUnmodified && (mode == DatabaseWidget::EditMode + || mode == DatabaseWidget::OpenMode)) || (reloadBehavior == ReloadUnmodified && dbStruct.modified)) { 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?"), @@ -296,7 +297,8 @@ bool DatabaseTabWidget::closeDatabase(Database* db) if (dbName.right(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 = MessageBox::question( this, tr("Close?"), @@ -631,7 +633,9 @@ bool DatabaseTabWidget::hasLockableDatabases() i.next(); 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()) { return true; } @@ -647,7 +651,9 @@ void DatabaseTabWidget::lockDatabases() i.next(); 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->lock(); updateTabName(i.key()); diff --git a/src/gui/DatabaseWidget.cpp b/src/gui/DatabaseWidget.cpp index 9ddbddd7e..5202611a0 100644 --- a/src/gui/DatabaseWidget.cpp +++ b/src/gui/DatabaseWidget.cpp @@ -173,10 +173,12 @@ DatabaseWidget::Mode DatabaseWidget::currentMode() else if (currentWidget() == m_mainWidget) { return DatabaseWidget::ViewMode; } - else if (currentWidget() == m_unlockDatabaseWidget || - currentWidget() == m_databaseOpenWidget) { + else if (currentWidget() == m_unlockDatabaseWidget) { return DatabaseWidget::LockedMode; } + else if (currentWidget() == m_databaseOpenWidget) { + return DatabaseWidget::OpenMode; + } else { return DatabaseWidget::EditMode; } diff --git a/src/gui/DatabaseWidget.h b/src/gui/DatabaseWidget.h index 894d9811c..a6b06348c 100644 --- a/src/gui/DatabaseWidget.h +++ b/src/gui/DatabaseWidget.h @@ -55,6 +55,7 @@ public: None, ViewMode, EditMode, + OpenMode, LockedMode }; diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index 7c11d5b13..aa7330950 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -394,6 +394,7 @@ void MainWindow::setMenuActionState(DatabaseWidget::Mode mode) } case DatabaseWidget::EditMode: case DatabaseWidget::LockedMode: + case DatabaseWidget::OpenMode: Q_FOREACH (QAction* action, m_ui->menuEntries->actions()) { action->setEnabled(false); } diff --git a/src/http/Service.cpp b/src/http/Service.cpp index eea204df8..7de986df6 100644 --- a/src/http/Service.cpp +++ b/src/http/Service.cpp @@ -76,6 +76,7 @@ bool Service::isDatabaseOpened() const switch(dbWidget->currentMode()) { case DatabaseWidget::None: case DatabaseWidget::LockedMode: + case DatabaseWidget::OpenMode: break; case DatabaseWidget::ViewMode: @@ -93,6 +94,7 @@ bool Service::openDatabase() switch(dbWidget->currentMode()) { case DatabaseWidget::None: case DatabaseWidget::LockedMode: + case DatabaseWidget::OpenMode: break; case DatabaseWidget::ViewMode: