From e16e15db09d89a997db73e313b966f95e6c59f56 Mon Sep 17 00:00:00 2001 From: saturneric Date: Fri, 22 Nov 2024 23:06:30 +0100 Subject: feat: rewrite core init processes and add env option --- src/ui/UserInterfaceUtils.cpp | 76 ++++++++++++++++++++++--------------------- 1 file changed, 39 insertions(+), 37 deletions(-) (limited to 'src/ui/UserInterfaceUtils.cpp') diff --git a/src/ui/UserInterfaceUtils.cpp b/src/ui/UserInterfaceUtils.cpp index ba3c323b..5c07e009 100644 --- a/src/ui/UserInterfaceUtils.cpp +++ b/src/ui/UserInterfaceUtils.cpp @@ -182,43 +182,45 @@ CommonUtils::CommonUtils() : QWidget(nullptr) { &UISignalStation::SignalRestartApplication, this, &CommonUtils::SlotRestartApplication); - connect(this, &CommonUtils::SignalBadGnupgEnv, this, - [=](const QString &reason) { - QMessageBox msg_box; - msg_box.setText(tr("GnuPG Context Loading Failed")); - msg_box.setInformativeText( - tr("Gnupg(gpg) is not installed correctly, please follow " - "this " - "notes in FAQ to install Gnupg and then open " - "GpgFrontend.
" - "Or, you can open GnuPG Controller to set a " - "custom GnuPG which GpgFrontend should use. Then, " - "GpgFrontend will restart.

" - "Breif Reason: %1") - .arg(reason)); - msg_box.setStandardButtons(QMessageBox::Open | QMessageBox::Cancel); - msg_box.setDefaultButton(QMessageBox::Save); - int ret = msg_box.exec(); - - switch (ret) { - case QMessageBox::Open: - (new GnuPGControllerDialog(this))->exec(); - // restart application when loop start - application_need_to_restart_at_once_ = true; - // restart application, core and ui - emit SignalRestartApplication(kDeepRestartCode); - break; - case QMessageBox::Cancel: - // close application - emit SignalRestartApplication(0); - break; - default: - // close application - emit SignalRestartApplication(0); - break; - } - }); + connect( + this, &CommonUtils::SignalBadGnupgEnv, this, [=](const QString &reason) { + QMessageBox msg_box; + msg_box.setText(tr("Failed to Load GnuPG Context")); + msg_box.setInformativeText( + tr("It seems that GnuPG (gpg) is not properly installed. " + "Please refer to the FAQ for " + "instructions on fixing the installation. After resolving the " + "issue, " + "relaunch GpgFrontend.

" + "Alternatively, you can open the GnuPG Controller to configure " + "a custom GnuPG installation for GpgFrontend to use. Once set, " + "GpgFrontend will restart automatically.

" + "Details: %1") + .arg(reason)); + msg_box.setStandardButtons(QMessageBox::Retry | QMessageBox::Cancel); + msg_box.setDefaultButton(QMessageBox::Retry); + int ret = msg_box.exec(); + + switch (ret) { + case QMessageBox::Retry: + (new GnuPGControllerDialog(this))->exec(); + // Mark application for immediate restart + application_need_to_restart_at_once_ = true; + // Trigger application restart with deep restart code + emit SignalRestartApplication(kDeepRestartCode); + break; + case QMessageBox::Cancel: + // Close application + emit SignalRestartApplication(0); + break; + default: + // Default action: close application + emit SignalRestartApplication(0); + break; + } + }); } void CommonUtils::WaitForOpera(QWidget *parent, -- cgit v1.2.3