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
This commit is contained in:
Lars Toenning
2025-03-24 14:23:53 +01:00
parent 509d34ed37
commit 472f69da4c
5 changed files with 2 additions and 71 deletions

View File

@@ -772,8 +772,6 @@ add_library(gui SHARED
showhidebar.cpp showhidebar.cpp
showhidebar.h showhidebar.h
showhidebar.ui showhidebar.ui
singleapplicationui.cpp
singleapplicationui.h
splashscreen.cpp splashscreen.cpp
splashscreen.h splashscreen.h
stylesheetutility.cpp stylesheetutility.cpp

View File

@@ -21,8 +21,7 @@ using namespace swift::core::context;
namespace swift::gui::components namespace swift::gui::components
{ {
CSettingsGuiComponent::CSettingsGuiComponent(QWidget *parent) CSettingsGuiComponent::CSettingsGuiComponent(QWidget *parent) : QFrame(parent), ui(new Ui::CSettingsGuiComponent)
: QFrame(parent), swift::gui::CSingleApplicationUi(this), ui(new Ui::CSettingsGuiComponent)
{ {
ui->setupUi(this); ui->setupUi(this);

View File

@@ -10,7 +10,6 @@
#include <QScopedPointer> #include <QScopedPointer>
#include "gui/settings/guisettings.h" #include "gui/settings/guisettings.h"
#include "gui/singleapplicationui.h"
namespace Ui namespace Ui
{ {
@@ -21,7 +20,7 @@ namespace swift::gui::components
/*! /*!
* General GUI settings * General GUI settings
*/ */
class CSettingsGuiComponent : public QFrame, public swift::gui::CSingleApplicationUi class CSettingsGuiComponent : public QFrame
{ {
Q_OBJECT Q_OBJECT

View File

@@ -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 <QWidget>
#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

View File

@@ -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 <QTimer>
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