UI: Refactor restart requesting

This commit is contained in:
Nodir Temirkhodjaev 2024-01-11 17:43:25 +03:00
parent 4878582b61
commit 26b67801c2
5 changed files with 12 additions and 7 deletions

View File

@ -425,12 +425,9 @@ void FortManager::processRestartRequired()
auto settings = IoC<FortSettings>();
if (settings->isService()) {
IoC<ServiceManager>()->restart();
IoC<ServiceManager>()->processRestartRequired();
} else {
auto windowManager = IoC<WindowManager>();
windowManager->showConfirmBox(
[=] { windowManager->restart(); }, tr("Restart Now?"), tr("Restart Required"));
IoC<WindowManager>()->processRestartRequired();
}
}

View File

@ -129,9 +129,11 @@ void ServiceManager::processControl(quint32 code, quint32 eventType)
reportStatus(state);
}
void ServiceManager::restart()
void ServiceManager::processRestartRequired()
{
qCDebug(LC) << "Quit due required restart";
QCoreApplication::quit();
reportStatus(SERVICE_STOP_PENDING);
}

View File

@ -30,7 +30,7 @@ public:
void processControl(quint32 code, quint32 eventType) override;
void restart();
void processRestartRequired();
signals:
void pauseRequested();

View File

@ -501,6 +501,11 @@ void WindowManager::restart()
QCoreApplication::quit();
}
void WindowManager::processRestartRequired()
{
showConfirmBox([&] { restart(); }, tr("Restart Now?"), tr("Restart Required"));
}
bool WindowManager::checkWindowPassword(WindowCode code)
{
return (WindowPasswordProtected & code) == 0 || checkPassword();

View File

@ -105,6 +105,7 @@ public slots:
void quit();
void restart();
void processRestartRequired();
bool checkWindowPassword(WindowCode code);
bool checkPassword();