From 960b9d07c94b4b965b10bd95feb32e6ff9ded0d1 Mon Sep 17 00:00:00 2001 From: Nodir Temirkhodjaev Date: Mon, 25 Dec 2023 17:58:07 +0300 Subject: [PATCH] UI: Options: Confirm "Import Backup" to restart --- src/ui/form/opt/optionscontroller.cpp | 9 +++++++++ src/ui/form/opt/optionscontroller.h | 1 + src/ui/form/opt/pages/optmainpage.cpp | 2 +- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/ui/form/opt/optionscontroller.cpp b/src/ui/form/opt/optionscontroller.cpp index 2f2bed2b..21fab18b 100644 --- a/src/ui/form/opt/optionscontroller.cpp +++ b/src/ui/form/opt/optionscontroller.cpp @@ -177,11 +177,20 @@ void OptionsController::importBackup() if (confManager()->importBackup(path)) { windowManager()->showInfoDialog(tr("Backup Imported Successfully")); + windowManager()->restart(); } else { windowManager()->showErrorBox(tr("Cannot Import Backup")); } } +void OptionsController::confirmImportBackup() +{ + windowManager()->showConfirmBox([&] { importBackup(); }, + tr("Program will be restarted after successful import. Continue?\n\n" + "Make sure that you have a fresh backup."), + tr("Import Backup")); +} + void OptionsController::closeWindow() { windowManager()->closeOptionsWindow(); diff --git a/src/ui/form/opt/optionscontroller.h b/src/ui/form/opt/optionscontroller.h index 975ac8ed..77843b78 100644 --- a/src/ui/form/opt/optionscontroller.h +++ b/src/ui/form/opt/optionscontroller.h @@ -48,6 +48,7 @@ public slots: void exportBackup(); void importBackup(); + void confirmImportBackup(); void closeWindow(); diff --git a/src/ui/form/opt/pages/optmainpage.cpp b/src/ui/form/opt/pages/optmainpage.cpp index f51e8fc4..c0b8e9be 100644 --- a/src/ui/form/opt/pages/optmainpage.cpp +++ b/src/ui/form/opt/pages/optmainpage.cpp @@ -130,7 +130,7 @@ void OptMainPage::setupBackup() m_actImport = backupMenu->addAction(IconCache::icon(":/icons/folder.png"), QString()); connect(m_actExport, &QAction::triggered, ctrl(), &OptionsController::exportBackup); - connect(m_actImport, &QAction::triggered, ctrl(), &OptionsController::importBackup); + connect(m_actImport, &QAction::triggered, ctrl(), &OptionsController::confirmImportBackup); m_btBackup = new QPushButton(); m_btBackup->setMenu(backupMenu);