diff --git a/src/lib/gui/MainWindow.cpp b/src/lib/gui/MainWindow.cpp index 7c510d628..7dd810a36 100644 --- a/src/lib/gui/MainWindow.cpp +++ b/src/lib/gui/MainWindow.cpp @@ -289,6 +289,7 @@ void MainWindow::connectSlots() connect(&m_coreProcess, &CoreProcess::processStateChanged, this, &MainWindow::coreProcessStateChanged); connect(&m_coreProcess, &CoreProcess::connectionStateChanged, this, &MainWindow::coreConnectionStateChanged); connect(&m_coreProcess, &CoreProcess::secureSocket, this, &MainWindow::secureSocket); + connect(&m_coreProcess, &CoreProcess::daemonIpcClientConnectFailed, this, &MainWindow::daemonIpcClientConnectFailed); connect(m_actionAbout, &QAction::triggered, this, &MainWindow::openAboutDialog); connect(m_actionClearSettings, &QAction::triggered, this, &MainWindow::clearSettings); @@ -365,6 +366,21 @@ void MainWindow::firstShown() // hacky and fragile, so maybe there's a better approach. const auto kCriticalDialogDelay = 100; QTimer::singleShot(kCriticalDialogDelay, this, &messages::raiseCriticalDialog); + + if (!Settings::value(Settings::Gui::AutoUpdateCheck).isValid()) { + showAndActivate(); + Settings::setValue(Settings::Gui::AutoUpdateCheck, messages::showUpdateCheckOption(this)); + } + + if (Settings::value(Settings::Gui::AutoUpdateCheck).toBool()) { + m_versionChecker.checkLatest(); + } else { + qDebug() << "update check disabled"; + } + + if (Settings::value(Settings::Core::StartedBefore).toBool()) { + m_coreProcess.start(); + } } void MainWindow::settingsChanged(const QString &key) @@ -603,24 +619,6 @@ void MainWindow::serverConnectionConfigureClient(const QString &clientName) void MainWindow::open() { - - if (!Settings::value(Settings::Gui::AutoUpdateCheck).isValid()) { - showAndActivate(); - Settings::setValue(Settings::Gui::AutoUpdateCheck, messages::showUpdateCheckOption(this)); - } - - if (Settings::value(Settings::Gui::AutoUpdateCheck).toBool()) { - m_versionChecker.checkLatest(); - } else { - qDebug() << "update check disabled"; - } - - m_coreProcess.applyLogLevel(); - - if (Settings::value(Settings::Core::StartedBefore).toBool()) { - m_coreProcess.start(); - } - Settings::value(Settings::Gui::Autohide).toBool() ? hide() : showAndActivate(); } @@ -1137,3 +1135,10 @@ bool MainWindow::regenerateLocalFingerprints() updateLocalFingerprint(); return true; } + +void MainWindow::daemonIpcClientConnectFailed() +{ + if (deskflow::gui::messages::showDaemonOffline(this)) { + m_coreProcess.retryDaemon(); + } +} diff --git a/src/lib/gui/MainWindow.h b/src/lib/gui/MainWindow.h index ab828e5be..61b66f6af 100644 --- a/src/lib/gui/MainWindow.h +++ b/src/lib/gui/MainWindow.h @@ -158,6 +158,7 @@ private: void showAndActivate(); void showHostNameEditor(); void setHostName(); + void daemonIpcClientConnectFailed(); /** * @brief trustedFingerprintDb get the fingerprintDb for the trusted clients or trusted servers. diff --git a/src/lib/gui/Messages.cpp b/src/lib/gui/Messages.cpp index e55b6e944..32ad9c028 100644 --- a/src/lib/gui/Messages.cpp +++ b/src/lib/gui/Messages.cpp @@ -309,4 +309,35 @@ bool showUpdateCheckOption(QWidget *parent) return message.clickedButton() == checkButton; } +bool showDaemonOffline(QWidget *parent) +{ + QMessageBox message(parent); + message.setIcon(QMessageBox::Warning); + message.setWindowTitle(QObject::tr("Background service offline")); + + message.addButton(QObject::tr("Retry"), QMessageBox::AcceptRole); + const auto ignore = message.addButton(QObject::tr("Ignore"), QMessageBox::RejectRole); + const auto disable = message.addButton(QObject::tr("Disable"), QMessageBox::NoRole); + + message.setText(QString( + "
There was a problem finding the %1 background service (daemon).
" + "The background service makes %1 work with UAC prompts and the login screen.
" + "If don't want to use the background service and intentionally stopped it, " + "you can prevent it's use by disabling this feature.
" + "If you did not stop the background service intentionally, there may be a problem with it. " + "Please retry or try restarting the %1 service from the Windows services program.
" + ) + .arg(kAppName)); + message.exec(); + + if (message.clickedButton() == ignore) { + return false; + } else if (message.clickedButton() == disable) { + Settings::setValue(Settings::Core::ProcessMode, Settings::ProcessMode::Desktop); + return false; + } + + return true; +} + } // namespace deskflow::gui::messages diff --git a/src/lib/gui/Messages.h b/src/lib/gui/Messages.h index 1f1eb8df1..f035e2092 100644 --- a/src/lib/gui/Messages.h +++ b/src/lib/gui/Messages.h @@ -49,4 +49,6 @@ void showWaylandLibraryError(QWidget *parent); bool showUpdateCheckOption(QWidget *parent); +bool showDaemonOffline(QWidget *parent); + } // namespace deskflow::gui::messages diff --git a/src/lib/gui/core/CoreProcess.cpp b/src/lib/gui/core/CoreProcess.cpp index 63acf8cb2..cf0e221d5 100644 --- a/src/lib/gui/core/CoreProcess.cpp +++ b/src/lib/gui/core/CoreProcess.cpp @@ -140,6 +140,7 @@ CoreProcess::CoreProcess(const IServerConfig &serverConfig, std::shared_ptr