diff options
author | saturneric <[email protected]> | 2025-02-04 15:17:16 +0000 |
---|---|---|
committer | saturneric <[email protected]> | 2025-02-04 15:17:16 +0000 |
commit | 4050dd0db4ff31c3de1a966ceade1c20540c63b5 (patch) | |
tree | ff948010519560a382545768cbb8b7b4ec9a580e /src | |
parent | Merge branch 'develop' (diff) | |
download | GpgFrontend-4050dd0db4ff31c3de1a966ceade1c20540c63b5.tar.gz GpgFrontend-4050dd0db4ff31c3de1a966ceade1c20540c63b5.zip |
fix: solve discovered issues before release v2.1.7
Diffstat (limited to 'src')
-rw-r--r-- | src/core/GpgCoreInit.cpp | 4 | ||||
-rw-r--r-- | src/core/function/gpg/GpgCommandExecutor.cpp | 2 | ||||
-rw-r--r-- | src/core/function/gpg/GpgContext.cpp | 3 | ||||
-rw-r--r-- | src/ui/dialog/Wizard.cpp | 72 | ||||
-rw-r--r-- | src/ui/dialog/Wizard.h | 32 | ||||
-rw-r--r-- | src/ui/main_window/MainWindow.cpp | 65 | ||||
-rw-r--r-- | src/ui/main_window/MainWindow.h | 7 | ||||
-rw-r--r-- | src/ui/main_window/MainWindowSlotUI.cpp | 1 |
8 files changed, 57 insertions, 129 deletions
diff --git a/src/core/GpgCoreInit.cpp b/src/core/GpgCoreInit.cpp index 5018b8e4..e12c71f1 100644 --- a/src/core/GpgCoreInit.cpp +++ b/src/core/GpgCoreInit.cpp @@ -81,7 +81,7 @@ auto GetDefaultKeyDatabasePath(const QString& gpgconf_path) -> QString { QFileInfo info(gpgconf_path); if (!info.exists() || !info.isFile()) return {}; - auto* p = new QProcess(QCoreApplication::instance()); + auto* p = new QProcess(); p->setProgram(info.absoluteFilePath()); p->setArguments({"--list-dirs", "homedir"}); p->start(); @@ -275,7 +275,7 @@ auto RefreshGpgMEBackendEngine(const QString& gpgconf_path, auto GetComponentPathsByGpgConf(const QString& gpgconf_install_fs_path) -> bool { - auto* process = new QProcess(QCoreApplication::instance()); + auto* process = new QProcess(); process->setProgram(gpgconf_install_fs_path); process->setArguments({"--check-programs"}); process->start(); diff --git a/src/core/function/gpg/GpgCommandExecutor.cpp b/src/core/function/gpg/GpgCommandExecutor.cpp index b244dfa4..a4ab8990 100644 --- a/src/core/function/gpg/GpgCommandExecutor.cpp +++ b/src/core/function/gpg/GpgCommandExecutor.cpp @@ -149,7 +149,7 @@ void GpgCommandExecutor::ExecuteSync(ExecuteContext context) { Thread::Task *task = BuildTaskFromExecCtx(context); QPointer<Thread::Task> p_t = task; - auto *looper = new QEventLoop(QCoreApplication::instance()); + auto *looper = new QEventLoop(); QObject::connect(task, &Thread::Task::SignalTaskEnd, looper, &QEventLoop::quit); diff --git a/src/core/function/gpg/GpgContext.cpp b/src/core/function/gpg/GpgContext.cpp index 002c0488..e93544ba 100644 --- a/src/core/function/gpg/GpgContext.cpp +++ b/src/core/function/gpg/GpgContext.cpp @@ -211,8 +211,7 @@ class GpgContext::Impl { auto set_ctx_openpgp_engine_info(gpgme_ctx_t ctx) -> bool { const auto app_path = Module::RetrieveRTValueTypedOrDefault<>( - "core", QString("gpgme.ctx.app_path").arg(parent_->GetChannel()), - QString{}); + "core", QString("gpgme.ctx.app_path"), QString{}); QString database_path; // set custom gpg key db path diff --git a/src/ui/dialog/Wizard.cpp b/src/ui/dialog/Wizard.cpp index 8e77dada..a126d995 100644 --- a/src/ui/dialog/Wizard.cpp +++ b/src/ui/dialog/Wizard.cpp @@ -30,14 +30,12 @@ #include "core/function/GlobalSettingStation.h" #include "ui/GpgFrontendUI.h" -#include "ui/dialog/key_generate/KeyGenerateDialog.h" namespace GpgFrontend::UI { Wizard::Wizard(QWidget* parent) : QWizard(parent) { setPage(kPAGE_INTRO, new IntroPage(this)); setPage(kPAGE_CHOOSE, new ChoosePage(this)); - setPage(kPAGE_GEN_KEY, new KeyGenPage(this)); setPage(kPAGE_CONCLUSION, new ConclusionPage(this)); #ifndef Q_WS_MAC setWizardStyle(ModernStyle); @@ -54,16 +52,10 @@ Wizard::Wizard(QWidget* parent) : QWizard(parent) { } void Wizard::slot_wizard_accepted() { - // Don't show is mapped to show -> negation - try { - auto settings = GetSettings(); - settings.setValue("wizard/show_wizard", false); - } catch (...) { - FLOG_W("setting operation error"); - } - if (field("openHelp").toBool()) { - emit SignalOpenHelp("docu.html#content"); - } + auto settings = GetSettings(); + settings.setValue("wizard/show_wizard", !field("showWizard").toBool()); + settings.setValue("network/prohibit_update_checking", + !field("checkUpdate").toBool()); } IntroPage::IntroPage(QWidget* parent) : QWizardPage(parent) { @@ -100,7 +92,7 @@ IntroPage::IntroPage(QWidget* parent) : QWizardPage(parent) { setLayout(layout); } -int IntroPage::nextId() const { return Wizard::kPAGE_CHOOSE; } +auto IntroPage::nextId() const -> int { return Wizard::kPAGE_CHOOSE; } ChoosePage::ChoosePage(QWidget* parent) : QWizardPage(parent) { setTitle(tr("Choose your action...")); @@ -148,7 +140,7 @@ ChoosePage::ChoosePage(QWidget* parent) : QWizardPage(parent) { next_page_ = Wizard::kPAGE_CONCLUSION; } -int ChoosePage::nextId() const { return next_page_; } +auto ChoosePage::nextId() const -> int { return next_page_; } void ChoosePage::slot_jump_page(const QString& page) { QMetaObject const qmo = Wizard::staticMetaObject; @@ -159,53 +151,13 @@ void ChoosePage::slot_jump_page(const QString& page) { wizard()->next(); } -KeyGenPage::KeyGenPage(QWidget* parent) : QWizardPage(parent) { - setTitle(tr("Create a keypair...")); - setSubTitle(tr("...for decrypting and signing messages")); - auto* top_label = new QLabel( - tr("You should create a new keypair." - "The pair consists of a public and a private key.<br>" - "Other users can use the public key to encrypt messages for you " - "and verify messages signed by you." - "You can use the private key to decrypt and sign messages.<br>" - "For more information have a look at the offline tutorial (which then " - "is shown in the main window):")); - top_label->setWordWrap(true); - auto* link_label = new QLabel( - "<a href=" - "docu_keygen.html#content" - ">" + - tr("Offline tutorial") + "</a>"); - - auto* create_key_button_box = new QWidget(this); - auto* create_key_button_box_layout = new QHBoxLayout(create_key_button_box); - auto* create_key_button = new QPushButton(tr("Create New Key")); - create_key_button_box_layout->addWidget(create_key_button); - create_key_button_box_layout->addStretch(1); - auto* layout = new QVBoxLayout(); - layout->addWidget(top_label); - layout->addWidget(link_label); - layout->addWidget(create_key_button_box); - connect(create_key_button, &QPushButton::clicked, this, - &KeyGenPage::slot_generate_key_dialog); - - setLayout(layout); -} - -int KeyGenPage::nextId() const { return Wizard::kPAGE_CONCLUSION; } - -void KeyGenPage::slot_generate_key_dialog() { - (new KeyGenerateDialog(kGpgFrontendDefaultChannel, this))->show(); - wizard()->next(); -} - ConclusionPage::ConclusionPage(QWidget* parent) : QWizardPage(parent) { setTitle(tr("Ready.")); setSubTitle(tr("Have fun with GpgFrontend!")); auto* bottom_label = new QLabel( tr("You are ready to use GpgFrontend now.<br><br>") + - "<a href=\"https://gpgfrontend.bktus.com/guides/understand-interface\">" + + "<a href=\"https://gpgfrontend.bktus.com/guides/fundamental-concepts\">" + tr("The Online Document") + "</a>" + tr(" will get you started with GpgFrontend. Anytime you encounter " "problems, please try to find help from the documentation") + @@ -223,17 +175,21 @@ ConclusionPage::ConclusionPage(QWidget* parent) : QWizardPage(parent) { new QCheckBox(tr("Don't show the wizard again.")); dont_show_wizard_checkbox_->setChecked(true); + check_updates_checkbox_ = + new QCheckBox(tr("Check for updates at each startup.")); + check_updates_checkbox_->setChecked(true); + registerField("showWizard", dont_show_wizard_checkbox_); - // registerField("openHelp", openHelpCheckBox); + registerField("checkUpdate", check_updates_checkbox_); auto* layout = new QVBoxLayout; layout->addWidget(bottom_label); - // layout->addWidget(openHelpCheckBox); layout->addWidget(dont_show_wizard_checkbox_); + layout->addWidget(check_updates_checkbox_); setLayout(layout); setVisible(true); } -int ConclusionPage::nextId() const { return -1; } +auto ConclusionPage::nextId() const -> int { return -1; } } // namespace GpgFrontend::UI diff --git a/src/ui/dialog/Wizard.h b/src/ui/dialog/Wizard.h index 91a5f846..780cd0ad 100644 --- a/src/ui/dialog/Wizard.h +++ b/src/ui/dialog/Wizard.h @@ -130,37 +130,6 @@ class ChoosePage : public QWizardPage { * @brief * */ -class KeyGenPage : public QWizardPage { - Q_OBJECT - - public: - /** - * @brief Construct a new Key Gen Page object - * - * @param parent - */ - explicit KeyGenPage(QWidget* parent = nullptr); - - /** - * @brief - * - * @return int - */ - [[nodiscard]] int nextId() const override; - - private slots: - - /** - * @brief - * - */ - void slot_generate_key_dialog(); -}; - -/** - * @brief - * - */ class ConclusionPage : public QWizardPage { Q_OBJECT @@ -181,6 +150,7 @@ class ConclusionPage : public QWizardPage { private: QCheckBox* dont_show_wizard_checkbox_; ///< + QCheckBox* check_updates_checkbox_; ///< QCheckBox* open_help_check_box_; ///< }; diff --git a/src/ui/main_window/MainWindow.cpp b/src/ui/main_window/MainWindow.cpp index d0f9b7db..698cd535 100644 --- a/src/ui/main_window/MainWindow.cpp +++ b/src/ui/main_window/MainWindow.cpp @@ -132,46 +132,21 @@ void MainWindow::Init() noexcept { info_board_->AssociateTabWidget(edit_->TabWidget()); - // loading process is done - emit SignalLoaded(); - Module::TriggerEvent("APPLICATION_LOADED"); - - // check version information - auto settings = GetSettings(); - - // ask if user wants to check update when the app boot - if (!settings.contains("network/prohibit_update_checking")) { - QMessageBox::StandardButton reply; - reply = QMessageBox::question( - this, tr("Update Check"), - tr("Do you want to check for updates at each startup?"), - QMessageBox::Yes | QMessageBox::No); - - auto prohibit_update_checking = (reply == QMessageBox::No); - settings.setValue("network/prohibit_update_checking", - prohibit_update_checking); - } - - auto prohibit_update_checking = - settings.value("network/prohibit_update_checking", false).toBool(); - if (!prohibit_update_checking) { - Module::ListenRTPublishEvent( - this, kVersionCheckingModuleID, "version.loading_done", - [=](Module::Namespace, Module::Key, int, std::any) { - FLOG_D( - "version-checking version.loading_done changed, calling slot " - "version upgrade"); - this->slot_version_upgrade_notify(); - }); - Module::TriggerEvent("CHECK_APPLICATION_VERSION"); - } + // check update if needed + check_update_at_startup(); // recover unsaved page from cache if it exists recover_editor_unsaved_pages_from_cache(); // check if need to open wizard window - auto show_wizard = settings.value("wizard/show_wizard", true).toBool(); - if (show_wizard) slot_start_wizard(); + if (GetSettings().value("wizard/show_wizard", true).toBool()) { + slot_start_wizard(); + } + + // loading process is done + emit SignalLoaded(); + Module::TriggerEvent("APPLICATION_LOADED"); + } catch (...) { LOG_W() << tr("Critical error occur while loading GpgFrontend."); QMessageBox::critical( @@ -309,4 +284,24 @@ auto MainWindow::create_action(const QString& id, const QString& name, return action; } +void MainWindow::check_update_at_startup() { + // check version information + auto settings = GetSettings(); + if (!settings.contains("network/prohibit_update_checking")) return; + + auto prohibit_update_checking = + settings.value("network/prohibit_update_checking", false).toBool(); + if (!prohibit_update_checking) { + Module::ListenRTPublishEvent( + this, kVersionCheckingModuleID, "version.loading_done", + [=](const Module::Namespace&, const Module::Key&, int, + const std::any&) { + FLOG_D( + "version-checking version.loading_done changed, calling slot " + "version upgrade"); + this->slot_version_upgrade_notify(); + }); + Module::TriggerEvent("CHECK_APPLICATION_VERSION"); + } +} } // namespace GpgFrontend::UI diff --git a/src/ui/main_window/MainWindow.h b/src/ui/main_window/MainWindow.h index 165deee5..9e5a289c 100644 --- a/src/ui/main_window/MainWindow.h +++ b/src/ui/main_window/MainWindow.h @@ -661,6 +661,13 @@ class MainWindow : public GeneralMainWindow { auto sign_operation_key_validate( const QSharedPointer<GpgOperaContextBasement>& contexts) -> bool; + /** + * @brief + * + * @return auto + */ + void check_update_at_startup(); + TextEdit* edit_{}; ///< Tabwidget holding the edit-windows QMenu* file_menu_{}; ///< Submenu for file-operations QMenu* edit_menu_{}; ///< Submenu for text-operations diff --git a/src/ui/main_window/MainWindowSlotUI.cpp b/src/ui/main_window/MainWindowSlotUI.cpp index fd5c0d8f..248e6488 100644 --- a/src/ui/main_window/MainWindowSlotUI.cpp +++ b/src/ui/main_window/MainWindowSlotUI.cpp @@ -29,6 +29,7 @@ #include "MainWindow.h" #include "core/GpgConstants.h" #include "core/function/CacheManager.h" +#include "core/function/GlobalSettingStation.h" #include "core/function/gpg/GpgAdvancedOperator.h" #include "core/model/SettingsObject.h" #include "ui/UserInterfaceUtils.h" |