diff --git a/src/ui/form/dialog/dialogutil.cpp b/src/ui/form/dialog/dialogutil.cpp index 8f4fbb89..0b2f8e8c 100644 --- a/src/ui/form/dialog/dialogutil.cpp +++ b/src/ui/form/dialog/dialogutil.cpp @@ -42,6 +42,7 @@ QMessageBox *DialogUtil::createMessageBox(const MessageBoxArg &ba, QWidget *pare { auto box = new QMessageBox(ba.icon, ba.title, ba.text, ba.buttons, parent); box->setAttribute(Qt::WA_DeleteOnClose); + box->setInformativeText(ba.info); setupModalDialog(box); return box; } diff --git a/src/ui/form/dialog/dialogutil.h b/src/ui/form/dialog/dialogutil.h index 1234e487..f3d1eb7d 100644 --- a/src/ui/form/dialog/dialogutil.h +++ b/src/ui/form/dialog/dialogutil.h @@ -11,6 +11,7 @@ struct MessageBoxArg QMessageBox::StandardButtons buttons; const QString text; const QString title; + const QString info; }; class DialogUtil diff --git a/src/ui/form/opt/optionscontroller.cpp b/src/ui/form/opt/optionscontroller.cpp index c82533f7..fd6cd2c5 100644 --- a/src/ui/form/opt/optionscontroller.cpp +++ b/src/ui/form/opt/optionscontroller.cpp @@ -188,13 +188,10 @@ void OptionsController::importBackup() const QString inPath = FileUtil::pathSlash(path); - if (confManager()->importBackup(inPath)) { - windowManager()->showInfoDialog(tr("Backup Imported Successfully")); - } else { - windowManager()->showErrorBox(tr("Cannot Import Backup")); - } + const bool ok = confManager()->importBackup(inPath); - windowManager()->restart(); + windowManager()->processRestartRequired( + ok ? tr("Backup Imported Successfully") : tr("Cannot Import Backup")); } void OptionsController::confirmImportBackup() diff --git a/src/ui/manager/windowmanager.cpp b/src/ui/manager/windowmanager.cpp index 9b5905af..61717dcb 100644 --- a/src/ui/manager/windowmanager.cpp +++ b/src/ui/manager/windowmanager.cpp @@ -501,9 +501,9 @@ void WindowManager::restart() QCoreApplication::quit(); } -void WindowManager::processRestartRequired() +void WindowManager::processRestartRequired(const QString &info) { - showConfirmBox([&] { restart(); }, tr("Restart Now?"), tr("Restart Required")); + showConfirmBox([&] { restart(); }, tr("Restart Now?"), tr("Restart Required"), info); } bool WindowManager::checkWindowPassword(WindowCode code) @@ -551,7 +551,7 @@ void WindowManager::showInfoBox(const QString &text, const QString &title, QWidg } void WindowManager::showConfirmBox(const std::function &onConfirmed, const QString &text, - const QString &title, QWidget *parent) + const QString &title, const QString &info, QWidget *parent) { showQuestionBox( [=](bool confirmed) { @@ -559,11 +559,11 @@ void WindowManager::showConfirmBox(const std::function &onConfirmed, con onConfirmed(); } }, - text, title, parent); + text, title, info, parent); } void WindowManager::showQuestionBox(const std::function &onFinished, - const QString &text, const QString &title, QWidget *parent) + const QString &text, const QString &title, const QString &info, QWidget *parent) { auto box = DialogUtil::createMessageBox( { @@ -571,6 +571,7 @@ void WindowManager::showQuestionBox(const std::function &o .buttons = QMessageBox::Yes | QMessageBox::No, .text = text, .title = title, + .info = info, }, parent); diff --git a/src/ui/manager/windowmanager.h b/src/ui/manager/windowmanager.h index 5bdf45f2..5f4332c9 100644 --- a/src/ui/manager/windowmanager.h +++ b/src/ui/manager/windowmanager.h @@ -105,7 +105,7 @@ public slots: void quit(); void restart(); - void processRestartRequired(); + void processRestartRequired(const QString &info = {}); bool checkWindowPassword(WindowCode code); bool checkPassword(); @@ -115,9 +115,11 @@ public slots: virtual void showInfoBox( const QString &text, const QString &title = QString(), QWidget *parent = nullptr); void showConfirmBox(const std::function &onConfirmed, const QString &text, - const QString &title = QString(), QWidget *parent = nullptr); + const QString &title = QString(), const QString &info = QString(), + QWidget *parent = nullptr); void showQuestionBox(const std::function &onFinished, const QString &text, - const QString &title = QString(), QWidget *parent = nullptr); + const QString &title = QString(), const QString &info = QString(), + QWidget *parent = nullptr); static void showErrorDialog( const QString &text, const QString &title = QString(), QWidget *parent = nullptr);