diff options
-rw-r--r-- | src/core/GpgConstants.h | 4 | ||||
-rw-r--r-- | src/core/GpgContext.cpp | 13 | ||||
-rw-r--r-- | src/core/GpgCoreInit.cpp | 50 | ||||
-rw-r--r-- | src/core/GpgCoreInit.h | 12 | ||||
-rw-r--r-- | src/core/GpgFunctionObject.cpp | 8 | ||||
-rw-r--r-- | src/core/GpgFunctionObject.h | 10 | ||||
-rw-r--r-- | src/core/function/GlobalSettingStation.cpp | 1 | ||||
-rw-r--r-- | src/core/function/GlobalSettingStation.h | 5 | ||||
-rw-r--r-- | src/main.cpp | 61 | ||||
-rw-r--r-- | src/ui/dialog/settings/SettingsDialog.cpp | 30 | ||||
-rw-r--r-- | src/ui/dialog/settings/SettingsDialog.h | 8 | ||||
-rw-r--r-- | src/ui/dialog/settings/SettingsGeneral.cpp | 110 | ||||
-rw-r--r-- | src/ui/dialog/settings/SettingsGeneral.h | 19 | ||||
-rw-r--r-- | src/ui/main_window/MainWindow.cpp | 6 | ||||
-rw-r--r-- | src/ui/main_window/MainWindow.h | 8 | ||||
-rw-r--r-- | src/ui/main_window/MainWindowSlotUI.cpp | 10 |
16 files changed, 292 insertions, 63 deletions
diff --git a/src/core/GpgConstants.h b/src/core/GpgConstants.h index 06f8e20d..a8a87835 100644 --- a/src/core/GpgConstants.h +++ b/src/core/GpgConstants.h @@ -31,10 +31,10 @@ #include "GpgFrontendCore.h" -const int RESTART_CODE = 1000; ///< +const int RESTART_CODE = 1000; ///< only refresh ui +const int DEEP_RESTART_CODE = 1001; // refresh core and ui namespace GpgFrontend { - using ByteArray = std::string; ///< using ByteArrayPtr = std::unique_ptr<ByteArray>; ///< using StdBypeArrayPtr = std::unique_ptr<ByteArray>; ///< diff --git a/src/core/GpgContext.cpp b/src/core/GpgContext.cpp index 28857d32..7ebd9fa9 100644 --- a/src/core/GpgContext.cpp +++ b/src/core/GpgContext.cpp @@ -102,6 +102,9 @@ GpgContext::GpgContext(const GpgContextInitArgs &args) : args_(args) { find_openpgp = true; info_.AppPath = engine_info->file_name; info_.GnupgVersion = engine_info->version; + info_.DatabasePath = std::string(engine_info->home_dir == nullptr + ? "default" + : engine_info->home_dir); break; case GPGME_PROTOCOL_CMS: find_cms = true; @@ -128,6 +131,16 @@ GpgContext::GpgContext(const GpgContextInitArgs &args) : args_(args) { engine_info = engine_info->next; } + // set custom key db path + if (!args.db_path.empty()) { + info_.DatabasePath = args.db_path; + auto err = gpgme_ctx_set_engine_info(_ctx_ref.get(), GPGME_PROTOCOL_OpenPGP, + info_.AppPath.c_str(), + info_.DatabasePath.c_str()); + LOG(INFO) << "ctx set custom key db path:" << info_.DatabasePath; + assert(check_gpg_error_2_err_code(err) == GPG_ERR_NO_ERROR); + } + // conditional check if ((info_.GnupgVersion >= "2.0.0" && find_gpgconf && find_openpgp && find_cms) || diff --git a/src/core/GpgCoreInit.cpp b/src/core/GpgCoreInit.cpp index f1664b2a..9ccc693d 100644 --- a/src/core/GpgCoreInit.cpp +++ b/src/core/GpgCoreInit.cpp @@ -77,23 +77,69 @@ void InitLoggingSystem() { LOG(INFO) << _("log file path") << logfile_path; } +void ResetGpgFrontendCore() { reset_gpgfrontend_core(); } + void init_gpgfrontend_core() { + // read from settings file + + bool use_custom_key_database_path = false; + try { + auto& settings = + GpgFrontend::GlobalSettingStation::GetInstance().GetUISettings(); + use_custom_key_database_path = + settings.lookup("general.use_custom_key_database_path"); + } catch (...) { + LOG(ERROR) << _("Setting Operation Error") + << _("use_custom_key_database_path"); + } + + LOG(INFO) << "core loaded if use custom key databse path: " + << use_custom_key_database_path; + + std::string custom_key_database_path; + try { + auto& settings = + GpgFrontend::GlobalSettingStation::GetInstance().GetUISettings(); + custom_key_database_path = static_cast<std::string>( + settings.lookup("general.custom_key_database_path")); + + } catch (...) { + LOG(ERROR) << _("Setting Operation Error") << _("custom_key_database_path"); + } + + LOG(INFO) << "core loaded custom key databse path: " + << custom_key_database_path; + // init default channel GpgFrontend::GpgContext::CreateInstance( - GPGFRONTEND_DEFAULT_CHANNEL, [&]() -> std::unique_ptr<ChannelObject> { + GPGFRONTEND_DEFAULT_CHANNEL, [=]() -> std::unique_ptr<ChannelObject> { GpgFrontend::GpgContextInitArgs args; + + // set key database path + if (use_custom_key_database_path && !custom_key_database_path.empty()) { + args.db_path = custom_key_database_path; + } + return std::unique_ptr<ChannelObject>(new GpgContext(args)); }); // init non-ascii channel GpgFrontend::GpgContext::CreateInstance( - GPGFRONTEND_NON_ASCII_CHANNEL, [&]() -> std::unique_ptr<ChannelObject> { + GPGFRONTEND_NON_ASCII_CHANNEL, [=]() -> std::unique_ptr<ChannelObject> { GpgFrontend::GpgContextInitArgs args; args.ascii = false; + + // set key database path + if (use_custom_key_database_path && !custom_key_database_path.empty()) { + args.db_path = custom_key_database_path; + } + return std::unique_ptr<ChannelObject>(new GpgContext(args)); }); } +void reset_gpgfrontend_core() { SingletonStorageCollection::GetInstance(true); } + void new_default_settings_channel(int channel) { GpgFrontend::GpgContext::CreateInstance( channel, [&]() -> std::unique_ptr<ChannelObject> { diff --git a/src/core/GpgCoreInit.h b/src/core/GpgCoreInit.h index 150e85e9..77942b56 100644 --- a/src/core/GpgCoreInit.h +++ b/src/core/GpgCoreInit.h @@ -43,11 +43,23 @@ void GPGFRONTEND_CORE_EXPORT InitLoggingSystem(); * @brief * */ +void GPGFRONTEND_CORE_EXPORT ResetGpgFrontendCore(); + +/** + * @brief + * + */ void init_gpgfrontend_core(); /** * @brief * + */ +void reset_gpgfrontend_core(); + +/** + * @brief + * * @param channel */ void new_default_settings_channel( diff --git a/src/core/GpgFunctionObject.cpp b/src/core/GpgFunctionObject.cpp index 1289d72f..6ff83d72 100644 --- a/src/core/GpgFunctionObject.cpp +++ b/src/core/GpgFunctionObject.cpp @@ -122,11 +122,15 @@ GpgFrontend::SingletonStorageCollection::GetSingletonStorage( } GpgFrontend::SingletonStorageCollection* -GpgFrontend::SingletonStorageCollection::GetInstance() { +GpgFrontend::SingletonStorageCollection::GetInstance( + bool force_refresh = false) { static SingletonStorageCollection* instance = nullptr; - if (instance == nullptr) { + + if (force_refresh || instance == nullptr) { instance = new SingletonStorageCollection(); + LOG(INFO) << "new single storage collection created: " << instance; } + return instance; } diff --git a/src/core/GpgFunctionObject.h b/src/core/GpgFunctionObject.h index de27ea42..56d0ab22 100644 --- a/src/core/GpgFunctionObject.h +++ b/src/core/GpgFunctionObject.h @@ -125,7 +125,7 @@ class GPGFRONTEND_CORE_EXPORT SingletonStorageCollection { * * @return SingletonStorageCollection* */ - static SingletonStorageCollection* GetInstance(); + static SingletonStorageCollection* GetInstance(bool force_refresh); /** * @brief Get the Singleton Storage object @@ -173,7 +173,7 @@ class SingletonFunctionObject : public ChannelObject { "T not derived from SingletonFunctionObject<T>"); auto p_storage = - SingletonStorageCollection::GetInstance()->GetSingletonStorage( + SingletonStorageCollection::GetInstance(false)->GetSingletonStorage( typeid(T)); auto* _p_pbj = (T*)(p_storage->FindObjectInChannel(channel)); @@ -200,7 +200,7 @@ class SingletonFunctionObject : public ChannelObject { "T not derived from SingletonFunctionObject<T>"); auto p_storage = - SingletonStorageCollection::GetInstance()->GetSingletonStorage( + SingletonStorageCollection::GetInstance(false)->GetSingletonStorage( typeid(T)); auto _p_pbj = (T*)(p_storage->FindObjectInChannel(channel)); @@ -219,7 +219,7 @@ class SingletonFunctionObject : public ChannelObject { * @return T& */ static void ReleaseChannel(int channel) { - SingletonStorageCollection::GetInstance() + SingletonStorageCollection::GetInstance(false) ->GetSingletonStorage(typeid(T)) ->ReleaseChannel(channel); } @@ -244,7 +244,7 @@ class SingletonFunctionObject : public ChannelObject { * @return std::vector<int> */ static std::vector<int> GetAllChannelId() { - return SingletonStorageCollection::GetInstance() + return SingletonStorageCollection::GetInstance(false) ->GetSingletonStorage(typeid(T)) ->GetAllChannelId(); } diff --git a/src/core/function/GlobalSettingStation.cpp b/src/core/function/GlobalSettingStation.cpp index db8d1bc3..7231ac9e 100644 --- a/src/core/function/GlobalSettingStation.cpp +++ b/src/core/function/GlobalSettingStation.cpp @@ -55,6 +55,7 @@ GpgFrontend::GlobalSettingStation::GlobalSettingStation(int channel) noexcept LOG(INFO) << _("App Data Path") << app_data_path_; LOG(INFO) << _("App Log Path") << app_log_path_; LOG(INFO) << _("App Locale Path") << app_locale_path_; + LOG(INFO) << _("App Conf Path") << ui_config_path_; if (!is_directory(app_configure_path_)) create_directory(app_configure_path_); diff --git a/src/core/function/GlobalSettingStation.h b/src/core/function/GlobalSettingStation.h index 58282466..8811623f 100644 --- a/src/core/function/GlobalSettingStation.h +++ b/src/core/function/GlobalSettingStation.h @@ -173,10 +173,9 @@ class GPGFRONTEND_CORE_EXPORT GlobalSettingStation QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) .toStdString(); ///< Program Configure Location std::filesystem::path ui_config_dir_path_ = - app_configure_path_ / - "UserInterface"; ///< Configure File Directory Location + app_configure_path_ / "conf"; ///< Configure File Directory Location std::filesystem::path ui_config_path_ = - ui_config_dir_path_ / "ui.cfg"; ///< UI Configure File Location + ui_config_dir_path_ / "main.cfg"; ///< Main Configure File Location libconfig::Config ui_cfg_; ///< UI Configure File diff --git a/src/main.cpp b/src/main.cpp index 14563880..5f2ba02e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -34,6 +34,7 @@ #include <csignal> #include <cstddef> +#include "core/GpgConstants.h" #include "core/GpgCoreInit.h" #include "ui/GpgFrontendApplication.h" #include "ui/GpgFrontendUIInit.h" @@ -110,38 +111,40 @@ int main(int argc, char* argv[]) { int return_from_event_loop_code; do { + do { #ifndef WINDOWS - int r = sigsetjmp(recover_env, 1); + int r = sigsetjmp(recover_env, 1); #else - int r = setjmp(recover_env); + int r = setjmp(recover_env); #endif - if (!r) { - // init ui library - GpgFrontend::UI::InitGpgFrontendUI(app); - - // create main window - return_from_event_loop_code = GpgFrontend::UI::RunGpgFrontendUI(app); - } else { - LOG(ERROR) << "recover from a crash"; - // when signal is caught, restart the main window - auto* message_box = new QMessageBox( - QMessageBox::Critical, _("A serious error has occurred"), - _("Oh no! GpgFrontend caught a serious error in the software, so " - "it needs to be restarted. If the problem recurs, please " - "manually terminate the program and report the problem to the " - "developer."), - QMessageBox::Ok, nullptr); - message_box->exec(); - return_from_event_loop_code = CRASH_CODE; - } - - if (return_from_event_loop_code == CRASH_CODE) { - app = GpgFrontend::UI::GpgFrontendApplication::GetInstance(argc, argv, - true); - } - - LOG(INFO) << "loop refresh"; - } while (return_from_event_loop_code == RESTART_CODE || + if (!r) { + // init ui library + GpgFrontend::UI::InitGpgFrontendUI(app); + + // create main window + return_from_event_loop_code = GpgFrontend::UI::RunGpgFrontendUI(app); + } else { + LOG(ERROR) << "recover from a crash"; + // when signal is caught, restart the main window + auto* message_box = new QMessageBox( + QMessageBox::Critical, _("A serious error has occurred"), + _("Oh no! GpgFrontend caught a serious error in the software, so " + "it needs to be restarted. If the problem recurs, please " + "manually terminate the program and report the problem to the " + "developer."), + QMessageBox::Ok, nullptr); + message_box->exec(); + return_from_event_loop_code = CRASH_CODE; + } + + LOG(INFO) << "loop refresh"; + } while (return_from_event_loop_code == RESTART_CODE); + + // reset core + GpgFrontend::ResetGpgFrontendCore(); + + // deep restart mode + } while (return_from_event_loop_code == DEEP_RESTART_CODE || return_from_event_loop_code == CRASH_CODE); // exit the program diff --git a/src/ui/dialog/settings/SettingsDialog.cpp b/src/ui/dialog/settings/SettingsDialog.cpp index e2677a0f..6737a512 100644 --- a/src/ui/dialog/settings/SettingsDialog.cpp +++ b/src/ui/dialog/settings/SettingsDialog.cpp @@ -33,6 +33,7 @@ #include "SettingsGeneral.h" #include "SettingsKeyServer.h" #include "SettingsNetwork.h" +#include "core/GpgConstants.h" #include "core/function/GlobalSettingStation.h" #include "ui/main_window/MainWindow.h" @@ -74,9 +75,24 @@ SettingsDialog::SettingsDialog(QWidget* parent) setLayout(mainLayout); // slots for handling the restart needed member - this->slot_set_restart_needed(false); + this->slot_set_restart_needed(0); + + // restart ui connect(general_tab_, &GeneralTab::SignalRestartNeeded, this, - &SettingsDialog::slot_set_restart_needed); + [=](bool needed) { + if (needed && restart_needed_ < RESTART_CODE) { + this->restart_needed_ = RESTART_CODE; + } + }); + + // restart core and ui + connect(general_tab_, &GeneralTab::SignalDeepRestartNeeded, this, + [=](bool needed) { + if (needed && restart_needed_ < DEEP_RESTART_CODE) + this->restart_needed_ = DEEP_RESTART_CODE; + }); + + // announce main window connect(this, &SettingsDialog::SignalRestartNeeded, qobject_cast<MainWindow*>(parent), &MainWindow::SlotSetRestartNeeded); @@ -85,12 +101,10 @@ SettingsDialog::SettingsDialog(QWidget* parent) this->show(); } -bool SettingsDialog::get_restart_needed() const { - return this->restart_needed_; -} +int SettingsDialog::get_restart_needed() const { return this->restart_needed_; } -void SettingsDialog::slot_set_restart_needed(bool needed) { - this->restart_needed_ = needed; +void SettingsDialog::slot_set_restart_needed(int mode) { + this->restart_needed_ = mode; } void SettingsDialog::SlotAccept() { @@ -108,7 +122,7 @@ void SettingsDialog::SlotAccept() { LOG(INFO) << "restart needed" << get_restart_needed(); if (get_restart_needed()) { - emit SignalRestartNeeded(true); + emit SignalRestartNeeded(get_restart_needed()); } close(); } diff --git a/src/ui/dialog/settings/SettingsDialog.h b/src/ui/dialog/settings/SettingsDialog.h index 172370d0..d28013f4 100644 --- a/src/ui/dialog/settings/SettingsDialog.h +++ b/src/ui/dialog/settings/SettingsDialog.h @@ -82,12 +82,12 @@ class SettingsDialog : public GeneralDialog { * * @param needed */ - void SignalRestartNeeded(bool needed); + void SignalRestartNeeded(int); private: QTabWidget* tab_widget_; ///< QDialogButtonBox* button_box_; ///< - bool restart_needed_{}; ///< + int restart_needed_{0}; ///< /** * @brief Get the Restart Needed object @@ -95,7 +95,7 @@ class SettingsDialog : public GeneralDialog { * @return true * @return false */ - bool get_restart_needed() const; + int get_restart_needed() const; private slots: @@ -104,7 +104,7 @@ class SettingsDialog : public GeneralDialog { * * @param needed */ - void slot_set_restart_needed(bool needed); + void slot_set_restart_needed(int); }; } // namespace GpgFrontend::UI diff --git a/src/ui/dialog/settings/SettingsGeneral.cpp b/src/ui/dialog/settings/SettingsGeneral.cpp index 3c7bca32..680ed014 100644 --- a/src/ui/dialog/settings/SettingsGeneral.cpp +++ b/src/ui/dialog/settings/SettingsGeneral.cpp @@ -28,6 +28,8 @@ #include "SettingsGeneral.h" +#include "core/GpgContext.h" + #ifdef MULTI_LANG_SUPPORT #include "SettingsDialog.h" #endif @@ -70,6 +72,51 @@ GeneralTab::GeneralTab(QWidget* parent) this, &GeneralTab::slot_language_changed); #endif + connect(ui_->keyDatabseUseCustomCheckBox, &QCheckBox::stateChanged, this, + [=](int state) { + ui_->customKeyDatabasePathSelectButton->setDisabled( + state != Qt::CheckState::Checked); + // announce the restart + this->slot_key_databse_path_changed(); + }); + + connect(ui_->keyDatabseUseCustomCheckBox, &QCheckBox::stateChanged, this, + &GeneralTab::slot_update_custom_key_database_path_label); + + connect( + ui_->customKeyDatabasePathSelectButton, &QPushButton::clicked, this, + [=]() { + QString selected_custom_key_database_path = + QFileDialog::getExistingDirectory( + this, _("Open Directory"), {}, + QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks); + + LOG(INFO) << "key databse path selected" + << selected_custom_key_database_path.toStdString(); + + if (!selected_custom_key_database_path.isEmpty()) { + auto& settings = GlobalSettingStation::GetInstance().GetUISettings(); + auto& general = settings["general"]; + + // update settings + if (!general.exists("custom_key_database_path")) + general.add("custom_key_database_path", + libconfig::Setting::TypeString) = + selected_custom_key_database_path.toStdString(); + else { + general["custom_key_database_path"] = + selected_custom_key_database_path.toStdString(); + } + + // announce the restart + this->slot_key_databse_path_changed(); + + // update ui + this->slot_update_custom_key_database_path_label( + this->ui_->keyDatabseUseCustomCheckBox->checkState()); + } + }); + SetSettings(); } @@ -132,6 +179,19 @@ void GeneralTab::SetSettings() { } catch (...) { LOG(ERROR) << _("Setting Operation Error") << _("non_ascii_when_export"); } + + try { + bool use_custom_key_database_path = + settings.lookup("general.use_custom_key_database_path"); + if (use_custom_key_database_path) + ui_->keyDatabseUseCustomCheckBox->setCheckState(Qt::Checked); + } catch (...) { + LOG(ERROR) << _("Setting Operation Error") + << _("use_custom_key_database_path"); + } + + this->slot_update_custom_key_database_path_label( + ui_->keyDatabseUseCustomCheckBox->checkState()); } /*********************************** @@ -187,10 +247,60 @@ void GeneralTab::ApplySettings() { general["confirm_import_keys"] = ui_->importConfirmationCheckBox->isChecked(); } + + if (!general.exists("use_custom_key_database_path")) + general.add("use_custom_key_database_path", + libconfig::Setting::TypeBoolean) = + ui_->keyDatabseUseCustomCheckBox->isChecked(); + else { + general["use_custom_key_database_path"] = + ui_->keyDatabseUseCustomCheckBox->isChecked(); + } } #ifdef MULTI_LANG_SUPPORT void GeneralTab::slot_language_changed() { emit SignalRestartNeeded(true); } #endif +void GeneralTab::slot_update_custom_key_database_path_label(int state) { + if (state != Qt::CheckState::Checked) { + ui_->currentKeyDatabasePathLabel->setText(QString::fromStdString( + GpgContext::GetInstance().GetInfo().DatabasePath)); + + // hide label (not necessary to show the default path) + this->ui_->currentKeyDatabasePathLabel->setHidden(true); + } else { + // read from settings file + std::string custom_key_database_path; + try { + auto& settings = + GpgFrontend::GlobalSettingStation::GetInstance().GetUISettings(); + custom_key_database_path = static_cast<std::string>( + settings.lookup("general.custom_key_database_path")); + + } catch (...) { + LOG(ERROR) << _("Setting Operation Error") + << _("custom_key_database_path"); + } + + LOG(INFO) << "selected_custom_key_database_path from settings" + << custom_key_database_path; + + // set label value + if (!custom_key_database_path.empty()) { + ui_->currentKeyDatabasePathLabel->setText( + QString::fromStdString(custom_key_database_path)); + } else { + ui_->currentKeyDatabasePathLabel->setText( + _("None custom key database path.")); + } + + this->ui_->currentKeyDatabasePathLabel->setHidden(false); + } +} + +void GeneralTab::slot_key_databse_path_changed() { + emit SignalDeepRestartNeeded(true); +} + } // namespace GpgFrontend::UI diff --git a/src/ui/dialog/settings/SettingsGeneral.h b/src/ui/dialog/settings/SettingsGeneral.h index b3e7d904..4543df7d 100644 --- a/src/ui/dialog/settings/SettingsGeneral.h +++ b/src/ui/dialog/settings/SettingsGeneral.h @@ -72,6 +72,13 @@ class GeneralTab : public QWidget { */ void SignalRestartNeeded(bool needed); + /** + * @brief + * + * @param needed + */ + void SignalDeepRestartNeeded(bool needed); + private: std::shared_ptr<Ui_GeneralSettings> ui_; ///< @@ -92,6 +99,18 @@ class GeneralTab : public QWidget { */ void slot_language_changed(); + /** + * @brief + * + */ + void slot_update_custom_key_database_path_label(int state); + + /** + * @brief + * + */ + void slot_key_databse_path_changed(); + #endif }; } // namespace GpgFrontend::UI diff --git a/src/ui/main_window/MainWindow.cpp b/src/ui/main_window/MainWindow.cpp index e3e4c0ab..b0273d86 100644 --- a/src/ui/main_window/MainWindow.cpp +++ b/src/ui/main_window/MainWindow.cpp @@ -62,12 +62,18 @@ void MainWindow::Init() noexcept { /* Variable containing if restart is needed */ this->SlotSetRestartNeeded(false); + // init menu bar + this->setMenuBar(new QMenuBar()); + create_actions(); create_menus(); create_tool_bars(); create_status_bar(); create_dock_windows(); + // show menu bar + this->menuBar()->show(); + connect(edit_->tab_widget_, &QTabWidget::currentChanged, this, &MainWindow::slot_disable_tab_actions); connect(SignalStation::GetInstance(), diff --git a/src/ui/main_window/MainWindow.h b/src/ui/main_window/MainWindow.h index b31e2fcb..2e24cecd 100644 --- a/src/ui/main_window/MainWindow.h +++ b/src/ui/main_window/MainWindow.h @@ -148,7 +148,7 @@ class MainWindow : public GeneralMainWindow { * @details get value of member restartNeeded to needed. * @param needed true, if application has to be restarted */ - void SlotSetRestartNeeded(bool needed); + void SlotSetRestartNeeded(int); private slots: @@ -322,7 +322,7 @@ class MainWindow : public GeneralMainWindow { /** * @brief return true, if restart is needed */ - [[nodiscard]] bool get_restart_needed() const; + [[nodiscard]] int get_restart_needed() const; TextEdit* edit_{}; ///< Tabwidget holding the edit-windows QMenu* file_menu_{}; ///< Submenu for file-operations @@ -387,7 +387,7 @@ class MainWindow : public GeneralMainWindow { QAction* about_act_{}; ///< Action to open about dialog QAction* check_update_act_{}; ///< Action to open about dialog QAction* translate_act_{}; ///< Action to open about dialog - QAction* gnupg_act_{}; ///< Action to open about dialog + QAction* gnupg_act_{}; ///< Action to open about dialog QAction* open_settings_act_{}; ///< Action to open settings dialog QAction* show_key_details_act_{}; ///< Action to open key-details dialog QAction* start_wizard_act_{}; ///< Action to open the wizard @@ -403,7 +403,7 @@ class MainWindow : public GeneralMainWindow { InfoBoardWidget* info_board_{}; ///< bool attachment_dock_created_{}; ///< - bool restart_needed_{}; ///< + int restart_needed_{0}; ///< bool prohibit_update_checking_ = false; ///< }; diff --git a/src/ui/main_window/MainWindowSlotUI.cpp b/src/ui/main_window/MainWindowSlotUI.cpp index 9061349e..8961a33f 100644 --- a/src/ui/main_window/MainWindowSlotUI.cpp +++ b/src/ui/main_window/MainWindowSlotUI.cpp @@ -27,6 +27,7 @@ */ #include "MainWindow.h" +#include "core/GpgConstants.h" #include "core/function/GlobalSettingStation.h" #include "ui/UserInterfaceUtils.h" #include "ui/struct/SettingsObject.h" @@ -128,7 +129,7 @@ void MainWindow::slot_open_settings_dialog() { if (get_restart_needed()) { if (edit_->MaybeSaveAnyTab()) { save_settings(); - qApp->exit(RESTART_CODE); + qApp->exit(get_restart_needed()); } } }); @@ -182,11 +183,12 @@ void MainWindow::slot_cut_pgp_header() { edit_->SlotFillTextEditWithText(content.trimmed()); } -void MainWindow::SlotSetRestartNeeded(bool needed) { - this->restart_needed_ = needed; +void MainWindow::SlotSetRestartNeeded(int mode) { + LOG(INFO) << "restart mode" << mode; + this->restart_needed_ = mode; } -bool MainWindow::get_restart_needed() const { return this->restart_needed_; } +int MainWindow::get_restart_needed() const { return this->restart_needed_; } void MainWindow::SetCryptoMenuStatus( MainWindow::CryptoMenu::OperationType type) { |