mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-08-06 01:06:31 +08:00
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:
@@ -772,8 +772,6 @@ add_library(gui SHARED
|
||||
showhidebar.cpp
|
||||
showhidebar.h
|
||||
showhidebar.ui
|
||||
singleapplicationui.cpp
|
||||
singleapplicationui.h
|
||||
splashscreen.cpp
|
||||
splashscreen.h
|
||||
stylesheetutility.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);
|
||||
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
#include <QScopedPointer>
|
||||
|
||||
#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
|
||||
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user