mirror of
https://github.com/tnodir/fort
synced 2024-11-15 10:05:08 +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);
|
auto box = new QMessageBox(ba.icon, ba.title, ba.text, ba.buttons, parent);
|
||||||
box->setAttribute(Qt::WA_DeleteOnClose);
|
box->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
|
box->setInformativeText(ba.info);
|
||||||
setupModalDialog(box);
|
setupModalDialog(box);
|
||||||
return box;
|
return box;
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@ struct MessageBoxArg
|
|||||||
QMessageBox::StandardButtons buttons;
|
QMessageBox::StandardButtons buttons;
|
||||||
const QString text;
|
const QString text;
|
||||||
const QString title;
|
const QString title;
|
||||||
|
const QString info;
|
||||||
};
|
};
|
||||||
|
|
||||||
class DialogUtil
|
class DialogUtil
|
||||||
|
@ -188,13 +188,10 @@ void OptionsController::importBackup()
|
|||||||
|
|
||||||
const QString inPath = FileUtil::pathSlash(path);
|
const QString inPath = FileUtil::pathSlash(path);
|
||||||
|
|
||||||
if (confManager()->importBackup(inPath)) {
|
const bool ok = confManager()->importBackup(inPath);
|
||||||
windowManager()->showInfoDialog(tr("Backup Imported Successfully"));
|
|
||||||
} else {
|
|
||||||
windowManager()->showErrorBox(tr("Cannot Import Backup"));
|
|
||||||
}
|
|
||||||
|
|
||||||
windowManager()->restart();
|
windowManager()->processRestartRequired(
|
||||||
|
ok ? tr("Backup Imported Successfully") : tr("Cannot Import Backup"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void OptionsController::confirmImportBackup()
|
void OptionsController::confirmImportBackup()
|
||||||
|
@ -501,9 +501,9 @@ void WindowManager::restart()
|
|||||||
QCoreApplication::quit();
|
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)
|
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,
|
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(
|
showQuestionBox(
|
||||||
[=](bool confirmed) {
|
[=](bool confirmed) {
|
||||||
@ -559,11 +559,11 @@ void WindowManager::showConfirmBox(const std::function<void()> &onConfirmed, con
|
|||||||
onConfirmed();
|
onConfirmed();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
text, title, parent);
|
text, title, info, parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowManager::showQuestionBox(const std::function<void(bool confirmed)> &onFinished,
|
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(
|
auto box = DialogUtil::createMessageBox(
|
||||||
{
|
{
|
||||||
@ -571,6 +571,7 @@ void WindowManager::showQuestionBox(const std::function<void(bool confirmed)> &o
|
|||||||
.buttons = QMessageBox::Yes | QMessageBox::No,
|
.buttons = QMessageBox::Yes | QMessageBox::No,
|
||||||
.text = text,
|
.text = text,
|
||||||
.title = title,
|
.title = title,
|
||||||
|
.info = info,
|
||||||
},
|
},
|
||||||
parent);
|
parent);
|
||||||
|
|
||||||
|
@ -105,7 +105,7 @@ public slots:
|
|||||||
|
|
||||||
void quit();
|
void quit();
|
||||||
void restart();
|
void restart();
|
||||||
void processRestartRequired();
|
void processRestartRequired(const QString &info = {});
|
||||||
|
|
||||||
bool checkWindowPassword(WindowCode code);
|
bool checkWindowPassword(WindowCode code);
|
||||||
bool checkPassword();
|
bool checkPassword();
|
||||||
@ -115,9 +115,11 @@ public slots:
|
|||||||
virtual void showInfoBox(
|
virtual void showInfoBox(
|
||||||
const QString &text, const QString &title = QString(), QWidget *parent = nullptr);
|
const QString &text, const QString &title = QString(), QWidget *parent = nullptr);
|
||||||
void showConfirmBox(const std::function<void()> &onConfirmed, const QString &text,
|
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,
|
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(
|
static void showErrorDialog(
|
||||||
const QString &text, const QString &title = QString(), QWidget *parent = nullptr);
|
const QString &text, const QString &title = QString(), QWidget *parent = nullptr);
|
||||||
|
Loading…
Reference in New Issue
Block a user