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>(); auto settings = IoC<FortSettings>();
if (settings->isService()) { if (settings->isService()) {
IoC<ServiceManager>()->restart(); IoC<ServiceManager>()->processRestartRequired();
} else { } else {
auto windowManager = IoC<WindowManager>(); IoC<WindowManager>()->processRestartRequired();
windowManager->showConfirmBox(
[=] { windowManager->restart(); }, tr("Restart Now?"), tr("Restart Required"));
} }
} }

View File

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

View File

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

View File

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

View File

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