From c791135160f50f6790d9b7a186ee57be7fb95ae2 Mon Sep 17 00:00:00 2001 From: sithlord48 Date: Sat, 21 Feb 2026 23:34:23 -0500 Subject: [PATCH] refactor: move CoreProcess::ProcessState => common/Enums deskflow::core::ProcessState --- src/lib/common/Enums.h | 11 +++++++++++ src/lib/gui/MainWindow.cpp | 15 ++++++--------- src/lib/gui/MainWindow.h | 3 ++- src/lib/gui/core/CoreProcess.h | 12 ++---------- 4 files changed, 21 insertions(+), 20 deletions(-) diff --git a/src/lib/common/Enums.h b/src/lib/common/Enums.h index f77bd67eb..b9af3c698 100644 --- a/src/lib/common/Enums.h +++ b/src/lib/common/Enums.h @@ -24,6 +24,17 @@ Q_ENUM_NS(ErrorType) namespace deskflow::core { Q_NAMESPACE + +enum class ProcessState +{ + Starting, + Started, + Stopping, + Stopped, + RetryPending +}; +Q_ENUM_NS(ProcessState) + enum class ConnectionState { Disconnected, diff --git a/src/lib/gui/MainWindow.cpp b/src/lib/gui/MainWindow.cpp index 8413930e2..2061a663c 100644 --- a/src/lib/gui/MainWindow.cpp +++ b/src/lib/gui/MainWindow.cpp @@ -54,8 +54,6 @@ using namespace deskflow::gui; -using CoreProcessState = CoreProcess::ProcessState; - MainWindow::MainWindow() : ui{std::make_unique()}, m_coreProcess(m_serverConfig), @@ -908,7 +906,7 @@ void MainWindow::updateStatus() updateSecurityIcon(false); switch (process) { - using enum CoreProcessState; + using enum ProcessState; case Starting: setStatus(tr("%1 is starting...").arg(kAppName)); @@ -962,11 +960,11 @@ void MainWindow::updateStatus() } } -void MainWindow::coreProcessStateChanged(CoreProcessState state) +void MainWindow::coreProcessStateChanged(ProcessState state) { + using enum ProcessState; updateStatus(); - - if (state == CoreProcessState::Started) { + if (state == Started) { qDebug() << "recording that core has started"; Settings::setValue(Settings::Gui::AutoStartCore, true); if (m_coreProcess.mode() == CoreMode::Server && @@ -977,8 +975,7 @@ void MainWindow::coreProcessStateChanged(CoreProcessState state) } } - if (state == CoreProcessState::Started || state == CoreProcessState::Starting || - state == CoreProcessState::RetryPending) { + if (state == Started || state == Starting || state == RetryPending) { disconnect(ui->btnToggleCore, &QPushButton::clicked, m_actionStartCore, &QAction::trigger); connect(ui->btnToggleCore, &QPushButton::clicked, m_actionStopCore, &QAction::trigger, Qt::UniqueConnection); @@ -987,7 +984,7 @@ void MainWindow::coreProcessStateChanged(CoreProcessState state) m_actionRestartCore->setVisible(true); m_actionStopCore->setEnabled(true); - if (state == CoreProcessState::Starting) { + if (state == Starting) { if (deskflow::platform::isWayland()) { m_waylandWarnings.showOnce(this); } diff --git a/src/lib/gui/MainWindow.h b/src/lib/gui/MainWindow.h index 91e87e310..084572b9a 100644 --- a/src/lib/gui/MainWindow.h +++ b/src/lib/gui/MainWindow.h @@ -63,6 +63,7 @@ class MainWindow : public QMainWindow using CoreMode = Settings::CoreMode; using CoreProcess = deskflow::gui::CoreProcess; using NetworkMonitor = deskflow::gui::NetworkMonitor; + using ProcessState = deskflow::core::ProcessState; Q_OBJECT @@ -106,7 +107,7 @@ private: void serverConfigSaving(); void coreProcessError(CoreProcess::Error error); void coreConnectionStateChanged(ConnectionState state); - void coreProcessStateChanged(CoreProcess::ProcessState state); + void coreProcessStateChanged(ProcessState state); void versionCheckerUpdateFound(const QString &version); void trayIconActivated(QSystemTrayIcon::ActivationReason reason); void serverConnectionConfigureClient(const QString &clientName); diff --git a/src/lib/gui/core/CoreProcess.h b/src/lib/gui/core/CoreProcess.h index c05eae3ef..3c4268084 100644 --- a/src/lib/gui/core/CoreProcess.h +++ b/src/lib/gui/core/CoreProcess.h @@ -27,6 +27,7 @@ class CoreProcess : public QObject { using ConnectionState = deskflow::core::ConnectionState; using ProcessMode = Settings::ProcessMode; + using ProcessState = deskflow::core::ProcessState; using IServerConfig = deskflow::gui::IServerConfig; Q_OBJECT @@ -37,15 +38,6 @@ public: AddressMissing, StartFailed }; - enum class ProcessState - { - Starting, - Started, - Stopping, - Stopped, - RetryPending - }; - Q_ENUM(ProcessState) explicit CoreProcess(const IServerConfig &serverConfig); @@ -93,7 +85,7 @@ Q_SIGNALS: void error(deskflow::gui::CoreProcess::Error error); void logLine(const QString &line); void connectionStateChanged(deskflow::core::ConnectionState state); - void processStateChanged(deskflow::gui::CoreProcess::ProcessState state); + void processStateChanged(deskflow::core::ProcessState state); void secureSocket(bool enabled); void daemonIpcClientConnectionFailed();