UI: Options: Confirm "Import Backup" to restart

This commit is contained in:
Nodir Temirkhodjaev 2023-12-25 17:58:07 +03:00
parent 263755f4bb
commit 960b9d07c9
3 changed files with 11 additions and 1 deletions

View File

@ -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();

View File

@ -48,6 +48,7 @@ public slots:
void exportBackup();
void importBackup();
void confirmImportBackup();
void closeWindow();

View File

@ -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);