mirror of
https://github.com/tnodir/fort
synced 2024-11-15 09:25:40 +00:00
UI: Options: Improve backup import result dialog
This commit is contained in:
parent
b03f2f95fa
commit
3c9e5b17ac
@ -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;
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ struct MessageBoxArg
|
||||
QMessageBox::StandardButtons buttons;
|
||||
const QString text;
|
||||
const QString title;
|
||||
const QString info;
|
||||
};
|
||||
|
||||
class DialogUtil
|
||||
|
@ -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()
|
||||
|
@ -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<void()> &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<void()> &onConfirmed, con
|
||||
onConfirmed();
|
||||
}
|
||||
},
|
||||
text, title, parent);
|
||||
text, title, info, parent);
|
||||
}
|
||||
|
||||
void WindowManager::showQuestionBox(const std::function<void(bool confirmed)> &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<void(bool confirmed)> &o
|
||||
.buttons = QMessageBox::Yes | QMessageBox::No,
|
||||
.text = text,
|
||||
.title = title,
|
||||
.info = info,
|
||||
},
|
||||
parent);
|
||||
|
||||
|
@ -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<void()> &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<void(bool confirmed)> &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);
|
||||
|
Loading…
Reference in New Issue
Block a user