diff options
Diffstat (limited to 'src/ui')
-rw-r--r-- | src/ui/GpgFrontendUIInit.cpp | 8 | ||||
-rw-r--r-- | src/ui/UserInterfaceUtils.cpp | 76 |
2 files changed, 47 insertions, 37 deletions
diff --git a/src/ui/GpgFrontendUIInit.cpp b/src/ui/GpgFrontendUIInit.cpp index 9cca46c2..e93a8e3c 100644 --- a/src/ui/GpgFrontendUIInit.cpp +++ b/src/ui/GpgFrontendUIInit.cpp @@ -72,6 +72,14 @@ void WaitEnvCheckingProcess() { waiting_dialog->deleteLater(); }); + QApplication::connect(CoreSignalStation::GetInstance(), + &CoreSignalStation::SignalBadGnupgEnv, waiting_dialog, + [=]() { + LOG_D() << "ui caught signal: core loading failed"; + waiting_dialog->finished(0); + waiting_dialog->deleteLater(); + }); + // new local event looper QEventLoop looper; QApplication::connect(CoreSignalStation::GetInstance(), 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 " - "<a href='https://www.gpgfrontend.bktus.com/#/" - "faq?id=how-to-deal-with-39env-loading-failed39'>this " - "notes</a> in FAQ to install Gnupg and then open " - "GpgFrontend. <br />" - "Or, you can open GnuPG Controller to set a " - "custom GnuPG which GpgFrontend should use. Then, " - "GpgFrontend will restart. <br /><br />" - "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 <a " + "href='https://www.gpgfrontend.bktus.com/overview/faq/" + "#troubleshooting-gnupg-installation-issues'>FAQ</a> for " + "instructions on fixing the installation. After resolving the " + "issue, " + "relaunch GpgFrontend.<br /><br />" + "Alternatively, you can open the GnuPG Controller to configure " + "a custom GnuPG installation for GpgFrontend to use. Once set, " + "GpgFrontend will restart automatically.<br /><br />" + "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, |