mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-17 10:55:32 +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.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
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
||||||
|
|
||||||
|
|||||||
@@ -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