From 472f69da4ca0fe65f39db839f929b1ea56314142 Mon Sep 17 00:00:00 2001 From: Lars Toenning Date: Mon, 24 Mar 2025 14:23:53 +0100 Subject: [PATCH] refactor: Remove singleapplicationui class This only protected the UI settings but it likely required for many other settings as well, if done propertly. Do reduce complexity => remove for now --- src/gui/CMakeLists.txt | 2 -- src/gui/components/settingsguicomponent.cpp | 3 +- src/gui/components/settingsguicomponent.h | 3 +- src/gui/singleapplicationui.cpp | 29 ----------------- src/gui/singleapplicationui.h | 36 --------------------- 5 files changed, 2 insertions(+), 71 deletions(-) delete mode 100644 src/gui/singleapplicationui.cpp delete mode 100644 src/gui/singleapplicationui.h diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt index f2c730c33..61fc8c38f 100644 --- a/src/gui/CMakeLists.txt +++ b/src/gui/CMakeLists.txt @@ -772,8 +772,6 @@ add_library(gui SHARED showhidebar.cpp showhidebar.h showhidebar.ui - singleapplicationui.cpp - singleapplicationui.h splashscreen.cpp splashscreen.h stylesheetutility.cpp diff --git a/src/gui/components/settingsguicomponent.cpp b/src/gui/components/settingsguicomponent.cpp index d76470840..0eef9bb7b 100644 --- a/src/gui/components/settingsguicomponent.cpp +++ b/src/gui/components/settingsguicomponent.cpp @@ -21,8 +21,7 @@ using namespace swift::core::context; namespace swift::gui::components { - CSettingsGuiComponent::CSettingsGuiComponent(QWidget *parent) - : QFrame(parent), swift::gui::CSingleApplicationUi(this), ui(new Ui::CSettingsGuiComponent) + CSettingsGuiComponent::CSettingsGuiComponent(QWidget *parent) : QFrame(parent), ui(new Ui::CSettingsGuiComponent) { ui->setupUi(this); diff --git a/src/gui/components/settingsguicomponent.h b/src/gui/components/settingsguicomponent.h index e90a7be84..68eaa1685 100644 --- a/src/gui/components/settingsguicomponent.h +++ b/src/gui/components/settingsguicomponent.h @@ -10,7 +10,6 @@ #include #include "gui/settings/guisettings.h" -#include "gui/singleapplicationui.h" namespace Ui { @@ -21,7 +20,7 @@ namespace swift::gui::components /*! * General GUI settings */ - class CSettingsGuiComponent : public QFrame, public swift::gui::CSingleApplicationUi + class CSettingsGuiComponent : public QFrame { Q_OBJECT diff --git a/src/gui/singleapplicationui.cpp b/src/gui/singleapplicationui.cpp deleted file mode 100644 index b79c8663f..000000000 --- a/src/gui/singleapplicationui.cpp +++ /dev/null @@ -1,29 +0,0 @@ -// SPDX-FileCopyrightText: Copyright (C) 2017 swift Project Community / Contributors -// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1 - -#include "singleapplicationui.h" - -#include - -#include "gui/guiapplication.h" - -using namespace swift::misc; - -namespace swift::gui -{ - CSingleApplicationUi::CSingleApplicationUi(QWidget *ui) : m_ui(ui) - { - QObject::connect(&m_timer, &QTimer::timeout, [=] { this->evaluate(); }); - m_timer.setInterval(5000); - m_timer.start(); - } - - void CSingleApplicationUi::evaluate() - { - if (!sGui) { return; } - if (!m_ui) { return; } - const CApplicationInfoList apps = sGui->getRunningApplications(); - const bool enable = apps.size() < 2; - m_ui->setEnabled(enable); - } -} // namespace swift::gui diff --git a/src/gui/singleapplicationui.h b/src/gui/singleapplicationui.h deleted file mode 100644 index 39adffaf5..000000000 --- a/src/gui/singleapplicationui.h +++ /dev/null @@ -1,36 +0,0 @@ -// SPDX-FileCopyrightText: Copyright (C) 2017 swift Project Community / Contributors -// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1 - -//! \file - -#ifndef SWIFT_GUI_SINGLEAPPLICATIONUI_H -#define SWIFT_GUI_SINGLEAPPLICATIONUI_H - -#include - -class QWidget; - -namespace swift::gui -{ - /*! - * Enable / disable UI depending on how many swift applications are running - */ - class CSingleApplicationUi - { - public: - //! Constructor - CSingleApplicationUi(QWidget *ui); - - //! Set UI widget - void setWidget(QWidget *ui) { m_ui = ui; } - - private: - //! Evaluate if - void evaluate(); - - QTimer m_timer; - QWidget *m_ui = nullptr; //!< enabled/disabled UI - }; -} // namespace swift::gui - -#endif // SWIFT_GUI_SINGLEAPPLICATIONUI_H