From 10e5a305bbcfbcf8df0ed62b7f11902317a6d4b4 Mon Sep 17 00:00:00 2001 From: sithlord48 Date: Wed, 19 Feb 2025 19:51:22 -0500 Subject: [PATCH] refactor: remove redundant client / server staus labels, the status label provides this info already --- src/apps/deskflow-gui/CMakeLists.txt | 4 -- src/apps/deskflow-gui/MainWindow.cpp | 2 - src/apps/deskflow-gui/MainWindow.ui | 34 +------------- .../deskflow-gui/widgets/ClientStateLabel.cpp | 25 ----------- .../deskflow-gui/widgets/ClientStateLabel.h | 20 --------- .../deskflow-gui/widgets/ServerStateLabel.cpp | 45 ------------------- .../deskflow-gui/widgets/ServerStateLabel.h | 26 ----------- 7 files changed, 1 insertion(+), 155 deletions(-) delete mode 100644 src/apps/deskflow-gui/widgets/ClientStateLabel.cpp delete mode 100644 src/apps/deskflow-gui/widgets/ClientStateLabel.h delete mode 100644 src/apps/deskflow-gui/widgets/ServerStateLabel.cpp delete mode 100644 src/apps/deskflow-gui/widgets/ServerStateLabel.h diff --git a/src/apps/deskflow-gui/CMakeLists.txt b/src/apps/deskflow-gui/CMakeLists.txt index 90afe726d..7723d0668 100644 --- a/src/apps/deskflow-gui/CMakeLists.txt +++ b/src/apps/deskflow-gui/CMakeLists.txt @@ -94,8 +94,6 @@ add_executable(${target} WIN32 MACOSX_BUNDLE dialogs/SettingsDialog.cpp dialogs/SettingsDialog.h dialogs/SettingsDialog.ui - widgets/ClientStateLabel.cpp - widgets/ClientStateLabel.h widgets/FingerprintPreview.h widgets/FingerprintPreview.cpp widgets/KeySequenceWidget.cpp @@ -104,8 +102,6 @@ add_executable(${target} WIN32 MACOSX_BUNDLE widgets/NewScreenWidget.cpp widgets/ScreenSetupView.cpp widgets/ScreenSetupView.h - widgets/ServerStateLabel.cpp - widgets/ServerStateLabel.h widgets/TrashScreenWidget.cpp widgets/TrashScreenWidget.h ) diff --git a/src/apps/deskflow-gui/MainWindow.cpp b/src/apps/deskflow-gui/MainWindow.cpp index fd65dc280..7c50b7ace 100644 --- a/src/apps/deskflow-gui/MainWindow.cpp +++ b/src/apps/deskflow-gui/MainWindow.cpp @@ -733,10 +733,8 @@ void MainWindow::checkConnected(const QString &line) { if (ui->rbModeServer->isChecked()) { m_serverConnection.handleLogLine(line); - ui->labelServerState->updateServerState(line); } else { m_clientConnection.handleLogLine(line); - ui->m_pLabelClientState->updateClientState(line); } } diff --git a/src/apps/deskflow-gui/MainWindow.ui b/src/apps/deskflow-gui/MainWindow.ui index 1ebfcc662..174c1a6b2 100644 --- a/src/apps/deskflow-gui/MainWindow.ui +++ b/src/apps/deskflow-gui/MainWindow.ui @@ -7,7 +7,7 @@ 0 0 883 - 650 + 583 @@ -219,16 +219,6 @@ - - - - No clients connected - - - 20 - - - @@ -383,16 +373,6 @@ - - - - Connected to server - - - 20 - - - @@ -512,18 +492,6 @@ - - - deskflow::gui::widgets::ServerStateLabel - QLabel -
widgets/ServerStateLabel.h
-
- - deskflow::gui::widgets::ClientStateLabel - QLabel -
widgets/ClientStateLabel.h
-
-
rbModeServer lineClientIp diff --git a/src/apps/deskflow-gui/widgets/ClientStateLabel.cpp b/src/apps/deskflow-gui/widgets/ClientStateLabel.cpp deleted file mode 100644 index fe9944072..000000000 --- a/src/apps/deskflow-gui/widgets/ClientStateLabel.cpp +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Deskflow -- mouse and keyboard sharing utility - * SPDX-FileCopyrightText: (C) 2021 Symless Ltd. - * SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception - */ - -#include "ClientStateLabel.h" - -namespace deskflow::gui::widgets { - -ClientStateLabel::ClientStateLabel(QWidget *parent) : QLabel(parent) -{ - hide(); -} - -void ClientStateLabel::updateClientState(const QString &line) -{ - if (line.contains("connected to server")) { - show(); - } else if (line.contains("disconnected from server") || line.contains("process exited")) { - hide(); - } -} - -} // namespace deskflow::gui::widgets diff --git a/src/apps/deskflow-gui/widgets/ClientStateLabel.h b/src/apps/deskflow-gui/widgets/ClientStateLabel.h deleted file mode 100644 index ab3a0a0e3..000000000 --- a/src/apps/deskflow-gui/widgets/ClientStateLabel.h +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Deskflow -- mouse and keyboard sharing utility - * SPDX-FileCopyrightText: (C) 2021 Symless Ltd. - * SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception - */ - -#pragma once - -#include - -namespace deskflow::gui::widgets { - -class ClientStateLabel : public QLabel -{ -public: - explicit ClientStateLabel(QWidget *parent = nullptr); - void updateClientState(const QString &line); -}; - -} // namespace deskflow::gui::widgets diff --git a/src/apps/deskflow-gui/widgets/ServerStateLabel.cpp b/src/apps/deskflow-gui/widgets/ServerStateLabel.cpp deleted file mode 100644 index e06949ada..000000000 --- a/src/apps/deskflow-gui/widgets/ServerStateLabel.cpp +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Deskflow -- mouse and keyboard sharing utility - * SPDX-FileCopyrightText: (C) 2021 Symless Ltd. - * SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception - */ - -#include "ServerStateLabel.h" - -#include "gui/core/ServerMessage.h" - -using namespace deskflow::gui; - -namespace deskflow::gui::widgets { - -ServerStateLabel::ServerStateLabel(QWidget *parent) : QLabel(parent) -{ -} - -void ServerStateLabel::updateServerState(const QString &line) -{ - ServerMessage message(line); - - if (message.isExitMessage()) { - m_clients.clear(); - } else if (message.isConnectedMessage()) { - m_clients.append(message.getClientName()); - } else if (message.isDisconnectedMessage()) { - m_clients.removeAll(message.getClientName()); - } - - if (m_clients.isEmpty()) { - setText(tr("No clients connected")); - } else { - // unfortunately, we can't rely on the clients list because we don't always - // catch the connect/disconnect messages. so clients tend to get stuck in - // the list even though they're offline. - // in order to properly show a list of clients, we would need the core to - // print a list of connected clients on every connect/disconnect event, - // which could be a bit noisy in the logs (perhaps an ipc message would be - // needed). - setText(tr("Client(s) are connected")); - } -} - -} // namespace deskflow::gui::widgets diff --git a/src/apps/deskflow-gui/widgets/ServerStateLabel.h b/src/apps/deskflow-gui/widgets/ServerStateLabel.h deleted file mode 100644 index 67e32839f..000000000 --- a/src/apps/deskflow-gui/widgets/ServerStateLabel.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Deskflow -- mouse and keyboard sharing utility - * SPDX-FileCopyrightText: (C) 2021 Symless Ltd. - * SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception - */ - -#pragma once - -#include -#include - -namespace deskflow::gui::widgets { - -class ServerStateLabel : public QLabel -{ -public: - explicit ServerStateLabel(QWidget *parent = nullptr); - void updateServerState(const QString &line); - -private: - QStringList m_clients; - - void updateState(); -}; - -} // namespace deskflow::gui::widgets