From 79fdf3a1f64f96be5f3f55c8e33557d5f9a908e1 Mon Sep 17 00:00:00 2001 From: sithlord48 Date: Sat, 21 Feb 2026 23:23:21 -0500 Subject: [PATCH] refactor: mv CoreProcess::ConnectionState -> common/Enums deskflow::core::ConnectionState --- src/lib/common/Enums.h | 12 ++++++++++++ src/lib/gui/MainWindow.cpp | 7 +++---- src/lib/gui/MainWindow.h | 3 ++- src/lib/gui/core/CoreProcess.h | 12 +++--------- 4 files changed, 20 insertions(+), 14 deletions(-) diff --git a/src/lib/common/Enums.h b/src/lib/common/Enums.h index 362ecb614..f77bd67eb 100644 --- a/src/lib/common/Enums.h +++ b/src/lib/common/Enums.h @@ -21,3 +21,15 @@ enum class ErrorType : uint8_t }; Q_ENUM_NS(ErrorType) } // namespace deskflow::client + +namespace deskflow::core { +Q_NAMESPACE +enum class ConnectionState +{ + Disconnected, + Connecting, + Connected, + Listening +}; +Q_ENUM_NS(ConnectionState) +} // namespace deskflow::core diff --git a/src/lib/gui/MainWindow.cpp b/src/lib/gui/MainWindow.cpp index e5e6f56ec..8413930e2 100644 --- a/src/lib/gui/MainWindow.cpp +++ b/src/lib/gui/MainWindow.cpp @@ -54,7 +54,6 @@ using namespace deskflow::gui; -using CoreConnectionState = CoreProcess::ConnectionState; using CoreProcessState = CoreProcess::ProcessState; MainWindow::MainWindow() @@ -931,7 +930,7 @@ void MainWindow::updateStatus() case Started: { updateNetworkInfo(); switch (connection) { - using enum CoreConnectionState; + using enum ConnectionState; case Listening: { if (isServer) { @@ -1007,7 +1006,7 @@ void MainWindow::coreProcessStateChanged(CoreProcessState state) updateModeControlLabels(); } -void MainWindow::coreConnectionStateChanged(CoreConnectionState state) +void MainWindow::coreConnectionStateChanged(ConnectionState state) { qDebug() << "core connection state changed: " << static_cast(state); @@ -1016,7 +1015,7 @@ void MainWindow::coreConnectionStateChanged(CoreConnectionState state) // always assume connection is not secure when connection changes // to anything except connected. the only way the padlock shows is // when the correct TLS version string is detected. - if (state != CoreConnectionState::Connected) { + if (state != ConnectionState::Connected) { secureSocket(false); } else if (isVisible()) { showFirstConnectedMessage(); diff --git a/src/lib/gui/MainWindow.h b/src/lib/gui/MainWindow.h index 8327de8c8..91e87e310 100644 --- a/src/lib/gui/MainWindow.h +++ b/src/lib/gui/MainWindow.h @@ -59,6 +59,7 @@ class DaemonIpcClient; class MainWindow : public QMainWindow { + using ConnectionState = deskflow::core::ConnectionState; using CoreMode = Settings::CoreMode; using CoreProcess = deskflow::gui::CoreProcess; using NetworkMonitor = deskflow::gui::NetworkMonitor; @@ -104,7 +105,7 @@ private: void settingsChanged(const QString &key = QString()); void serverConfigSaving(); void coreProcessError(CoreProcess::Error error); - void coreConnectionStateChanged(CoreProcess::ConnectionState state); + void coreConnectionStateChanged(ConnectionState state); void coreProcessStateChanged(CoreProcess::ProcessState state); void versionCheckerUpdateFound(const QString &version); void trayIconActivated(QSystemTrayIcon::ActivationReason reason); diff --git a/src/lib/gui/core/CoreProcess.h b/src/lib/gui/core/CoreProcess.h index 9d3308501..c05eae3ef 100644 --- a/src/lib/gui/core/CoreProcess.h +++ b/src/lib/gui/core/CoreProcess.h @@ -7,6 +7,7 @@ #pragma once +#include "common/Enums.h" #include "common/Settings.h" #include "gui/FileTail.h" #include "gui/config/IServerConfig.h" @@ -24,6 +25,7 @@ class DaemonIpcClient; class CoreProcess : public QObject { + using ConnectionState = deskflow::core::ConnectionState; using ProcessMode = Settings::ProcessMode; using IServerConfig = deskflow::gui::IServerConfig; @@ -45,14 +47,6 @@ public: }; Q_ENUM(ProcessState) - enum class ConnectionState - { - Disconnected, - Connecting, - Connected, - Listening - }; - explicit CoreProcess(const IServerConfig &serverConfig); void start(std::optional processMode = std::nullopt); @@ -98,7 +92,7 @@ public: Q_SIGNALS: void error(deskflow::gui::CoreProcess::Error error); void logLine(const QString &line); - void connectionStateChanged(deskflow::gui::CoreProcess::ConnectionState state); + void connectionStateChanged(deskflow::core::ConnectionState state); void processStateChanged(deskflow::gui::CoreProcess::ProcessState state); void secureSocket(bool enabled); void daemonIpcClientConnectionFailed();