diff options
author | saturneric <[email protected]> | 2024-05-03 18:17:25 +0000 |
---|---|---|
committer | saturneric <[email protected]> | 2024-05-03 18:17:25 +0000 |
commit | 1d9cffa54afdca117a43465fb350ee548ec2e41f (patch) | |
tree | 4facf6641e312b39d19c1388c87eb702ea720ace | |
parent | Merge remote-tracking branch 'origin/main' into develop (diff) | |
download | GpgFrontend-1d9cffa54afdca117a43465fb350ee548ec2e41f.tar.gz GpgFrontend-1d9cffa54afdca117a43465fb350ee548ec2e41f.zip |
fix: discard changes but text still remains
-rw-r--r-- | src/module/sdk/GFSDKBuildInfo.h | 2 | ||||
-rw-r--r-- | src/ui/dialog/controller/GnuPGControllerDialog.cpp | 4 | ||||
-rw-r--r-- | src/ui/dialog/controller/GnuPGControllerDialog.h | 2 | ||||
-rw-r--r-- | src/ui/dialog/help/AboutDialog.cpp | 2 | ||||
-rw-r--r-- | src/ui/dialog/settings/SettingsDialog.cpp | 14 | ||||
-rw-r--r-- | src/ui/dialog/settings/SettingsDialog.h | 6 | ||||
-rw-r--r-- | src/ui/main_window/MainWindow.cpp | 3 | ||||
-rw-r--r-- | src/ui/main_window/MainWindow.h | 7 | ||||
-rw-r--r-- | src/ui/main_window/MainWindowSlotUI.cpp | 14 | ||||
-rw-r--r-- | src/ui/widgets/TextEdit.cpp | 8 |
10 files changed, 28 insertions, 34 deletions
diff --git a/src/module/sdk/GFSDKBuildInfo.h b/src/module/sdk/GFSDKBuildInfo.h index aea49f03..a64d95c5 100644 --- a/src/module/sdk/GFSDKBuildInfo.h +++ b/src/module/sdk/GFSDKBuildInfo.h @@ -30,7 +30,7 @@ #define GF_SDK_VERSION_MAJOR "2" #define GF_SDK_VERSION_MINOR "1" -#define GF_SDK_VERSION_PATCH "2" +#define GF_SDK_VERSION_PATCH "3" #define GF_SDK_VERSION_STR \ GF_SDK_VERSION_MAJOR "." GF_SDK_VERSION_MINOR "." GF_SDK_VERSION_PATCH diff --git a/src/ui/dialog/controller/GnuPGControllerDialog.cpp b/src/ui/dialog/controller/GnuPGControllerDialog.cpp index b35d2a7d..1874e255 100644 --- a/src/ui/dialog/controller/GnuPGControllerDialog.cpp +++ b/src/ui/dialog/controller/GnuPGControllerDialog.cpp @@ -347,12 +347,12 @@ void GnuPGControllerDialog::apply_settings() { } auto GnuPGControllerDialog::get_restart_needed() const -> int { - return this->restart_needed_; + return this->restart_mode_; } void GnuPGControllerDialog::slot_set_restart_needed(int mode) { GF_UI_LOG_INFO("announce restart needed, mode: {}", mode); - this->restart_needed_ = mode; + this->restart_mode_ = mode; } auto GnuPGControllerDialog::check_custom_gnupg_path(QString path) -> bool { diff --git a/src/ui/dialog/controller/GnuPGControllerDialog.h b/src/ui/dialog/controller/GnuPGControllerDialog.h index 6e8ef797..e8a4b83c 100644 --- a/src/ui/dialog/controller/GnuPGControllerDialog.h +++ b/src/ui/dialog/controller/GnuPGControllerDialog.h @@ -83,7 +83,7 @@ class GnuPGControllerDialog : public GeneralDialog { private: std::shared_ptr<Ui_GnuPGControllerDialog> ui_; ///< - int restart_needed_{0}; ///< + int restart_mode_{0}; ///< QString custom_key_database_path_; QString custom_gnupg_path_; diff --git a/src/ui/dialog/help/AboutDialog.cpp b/src/ui/dialog/help/AboutDialog.cpp index ddc17fe7..0735ddba 100644 --- a/src/ui/dialog/help/AboutDialog.cpp +++ b/src/ui/dialog/help/AboutDialog.cpp @@ -97,7 +97,7 @@ InfoTab::InfoTab(QWidget* parent) : QWidget(parent) { auto text = "<center><h2>" + qApp->applicationName() + "</h2></center>" + - "<center><b>" + qApp->applicationVersion() + "</b></center>" + + "<center><b>" + "v" + qApp->applicationVersion() + "</b></center>" + "<center>" + GetProjectBuildGitVersion() + "</center>" + "<br><center>" + tr("GpgFrontend is an easy-to-use, compact, cross-platform, " "and installation-free GnuPG Frontend." diff --git a/src/ui/dialog/settings/SettingsDialog.cpp b/src/ui/dialog/settings/SettingsDialog.cpp index 3cf6b5ed..70b8c7b0 100644 --- a/src/ui/dialog/settings/SettingsDialog.cpp +++ b/src/ui/dialog/settings/SettingsDialog.cpp @@ -95,14 +95,14 @@ SettingsDialog::SettingsDialog(QWidget* parent) } void SettingsDialog::slot_declare_a_restart() { - if (restart_needed_ < kRestartCode) { - this->restart_needed_ = kRestartCode; + if (restart_mode_ < kRestartCode) { + this->restart_mode_ = kRestartCode; } } void SettingsDialog::slot_declare_a_deep_restart() { - if (restart_needed_ < kDeepRestartCode) { - this->restart_needed_ = kDeepRestartCode; + if (restart_mode_ < kDeepRestartCode) { + this->restart_mode_ = kDeepRestartCode; } } @@ -112,9 +112,9 @@ void SettingsDialog::SlotAccept() { key_server_tab_->ApplySettings(); network_tab_->ApplySettings(); - GF_UI_LOG_DEBUG("ui restart status: {}", restart_needed_); - if (restart_needed_ != kNonRestartCode) { - emit SignalRestartNeeded(restart_needed_); + GF_UI_LOG_DEBUG("ui restart status: {}", restart_mode_); + if (restart_mode_ != kNonRestartCode) { + emit SignalRestartNeeded(restart_mode_); } close(); } diff --git a/src/ui/dialog/settings/SettingsDialog.h b/src/ui/dialog/settings/SettingsDialog.h index 3839f094..f74b2cc0 100644 --- a/src/ui/dialog/settings/SettingsDialog.h +++ b/src/ui/dialog/settings/SettingsDialog.h @@ -82,9 +82,9 @@ class SettingsDialog : public GeneralDialog { void SignalRestartNeeded(int); private: - QTabWidget* tab_widget_; ///< - QDialogButtonBox* button_box_; ///< - int restart_needed_{kNonRestartCode}; ///< + QTabWidget* tab_widget_; ///< + QDialogButtonBox* button_box_; ///< + int restart_mode_{kNonRestartCode}; ///< private slots: diff --git a/src/ui/main_window/MainWindow.cpp b/src/ui/main_window/MainWindow.cpp index d7cc9754..c50cfc5e 100644 --- a/src/ui/main_window/MainWindow.cpp +++ b/src/ui/main_window/MainWindow.cpp @@ -245,9 +245,6 @@ void MainWindow::closeEvent(QCloseEvent *event) { CacheManager::GetInstance().SaveDurableCache( "editor_unsaved_pages", QJsonDocument(QJsonArray()), true); - // clear password from memory - // GpgContext::GetInstance().clearPasswordCache(); - // call parent GeneralMainWindow::closeEvent(event); } diff --git a/src/ui/main_window/MainWindow.h b/src/ui/main_window/MainWindow.h index 197fb04c..f53a4a03 100644 --- a/src/ui/main_window/MainWindow.h +++ b/src/ui/main_window/MainWindow.h @@ -421,11 +421,6 @@ class MainWindow : public GeneralMainWindow { */ void recover_editor_unsaved_pages_from_cache(); - /** - * @brief return true, if restart is needed - */ - [[nodiscard]] int get_restart_needed() const; - TextEdit* edit_{}; ///< Tabwidget holding the edit-windows QMenu* file_menu_{}; ///< Submenu for file-operations QMenu* edit_menu_{}; ///< Submenu for text-operations @@ -523,7 +518,7 @@ class MainWindow : public GeneralMainWindow { InfoBoardWidget* info_board_{}; ///< bool attachment_dock_created_{}; ///< - int restart_needed_{0}; ///< + int restart_mode_{0}; ///< bool prohibit_update_checking_ = false; ///< }; diff --git a/src/ui/main_window/MainWindowSlotUI.cpp b/src/ui/main_window/MainWindowSlotUI.cpp index 897c1950..39ceedc6 100644 --- a/src/ui/main_window/MainWindowSlotUI.cpp +++ b/src/ui/main_window/MainWindowSlotUI.cpp @@ -28,6 +28,7 @@ #include "MainWindow.h" #include "core/GpgConstants.h" +#include "core/function/CacheManager.h" #include "core/model/GpgPassphraseContext.h" #include "core/model/SettingsObject.h" #include "ui/UserInterfaceUtils.h" @@ -121,10 +122,13 @@ void MainWindow::slot_open_settings_dialog() { import_button_->setIconSize( QSize(appearance.tool_bar_icon_width, appearance.tool_bar_icon_height)); - // restart mainwindow if necessary - if (get_restart_needed() != 0) { + // restart main window if necessary + if (restart_mode_ != kNonRestartCode) { if (edit_->MaybeSaveAnyTab()) { - emit SignalRestartApplication(get_restart_needed()); + // clear cache of unsaved page + CacheManager::GetInstance().SaveDurableCache( + "editor_unsaved_pages", QJsonDocument(QJsonArray()), true); + emit SignalRestartApplication(restart_mode_); } } }); @@ -180,11 +184,9 @@ void MainWindow::slot_cut_pgp_header() { void MainWindow::SlotSetRestartNeeded(int mode) { GF_UI_LOG_DEBUG("restart mode: {}", mode); - this->restart_needed_ = mode; + this->restart_mode_ = mode; } -int MainWindow::get_restart_needed() const { return this->restart_needed_; } - void MainWindow::SlotUpdateCryptoMenuStatus(unsigned int type) { MainWindow::CryptoMenu::OperationType opera_type = type; GF_UI_LOG_DEBUG("update crypto menu status, type: {}", opera_type); diff --git a/src/ui/widgets/TextEdit.cpp b/src/ui/widgets/TextEdit.cpp index 25fce9b8..a0dba5f5 100644 --- a/src/ui/widgets/TextEdit.cpp +++ b/src/ui/widgets/TextEdit.cpp @@ -261,7 +261,7 @@ void TextEdit::slot_remove_tab(int index) { * * If it returns false, the close event should be aborted. */ -bool TextEdit::maybe_save_current_tab(bool askToSave) { +auto TextEdit::maybe_save_current_tab(bool askToSave) -> bool { PlainTextEditorPage* page = SlotCurPageTextEdit(); // if this page is no textedit, there should be nothing to save if (page == nullptr) { @@ -304,8 +304,8 @@ bool TextEdit::maybe_save_current_tab(bool askToSave) { } auto TextEdit::MaybeSaveAnyTab() -> bool { - // get a list of all unsaved documents and their tabids - QHash<int, QString> unsaved_docs = this->UnsavedDocuments(); + // get a list of all unsaved documents and their tab ids + QHash<int, QString> const unsaved_docs = this->UnsavedDocuments(); /* * no unsaved documents, so app can be closed @@ -318,7 +318,7 @@ auto TextEdit::MaybeSaveAnyTab() -> bool { * and show normal unsaved doc dialog */ if (unsaved_docs.size() == 1) { - int modified_tab = unsaved_docs.keys().at(0); + int const modified_tab = unsaved_docs.keys().at(0); tab_widget_->setCurrentIndex(modified_tab); return maybe_save_current_tab(true); } |