diff --git a/components/mobileshell/CMakeLists.txt b/components/mobileshell/CMakeLists.txt index c5f7dc6c..350b256a 100644 --- a/components/mobileshell/CMakeLists.txt +++ b/components/mobileshell/CMakeLists.txt @@ -8,11 +8,13 @@ qt_add_dbus_interfaces(DBUS_SRCS dbus/org.kde.KWin.ScreenShot2.xml set(mobileshellplugin_SRCS mobileshellplugin.cpp shellutil.cpp - quicksettingsmodel.cpp mobileshellsettings.cpp vkbdinterface.cpp displaysmodel.cpp + quicksettings/quicksetting.cpp + quicksettings/quicksettingsmodel.cpp + notifications/notificationthumbnailer.cpp notifications/notificationfilemenu.cpp diff --git a/components/mobileshell/mobileshellplugin.cpp b/components/mobileshell/mobileshellplugin.cpp index 8c3c2ddf..f336dbf4 100644 --- a/components/mobileshell/mobileshellplugin.cpp +++ b/components/mobileshell/mobileshellplugin.cpp @@ -13,7 +13,8 @@ #include "mobileshellsettings.h" #include "notifications/notificationfilemenu.h" #include "notifications/notificationthumbnailer.h" -#include "quicksettingsmodel.h" +#include "quicksettings/quicksetting.h" +#include "quicksettings/quicksettingsmodel.h" #include "shellutil.h" #include "virtualkeyboardinterface.h" #include "vkbdinterface.h" diff --git a/components/mobileshell/quicksettings/quicksetting.cpp b/components/mobileshell/quicksettings/quicksetting.cpp new file mode 100644 index 00000000..4a8f125f --- /dev/null +++ b/components/mobileshell/quicksettings/quicksetting.cpp @@ -0,0 +1,62 @@ +/* + * SPDX-FileCopyrightText: 2021 Aleix Pol Gonzalez + * + * SPDX-License-Identifier: LGPL-2.0-or-later + */ + +#include "quicksetting.h" + +QuickSetting::QuickSetting(QObject *parent) + : QObject(parent) +{ +} + +void QuickSetting::setEnabled(bool enabled) +{ + if (m_enabled == enabled) + return; + + m_enabled = enabled; + Q_EMIT enabledChanged(enabled); +} + +void QuickSetting::setSettingsCommand(const QString &settingsCommand) +{ + if (m_settingsCommand == settingsCommand) + return; + + m_settingsCommand = settingsCommand; + Q_EMIT settingsCommandChanged(settingsCommand); +} + +void QuickSetting::setIconName(const QString &iconName) +{ + if (m_iconName == iconName) + return; + + m_iconName = iconName; + Q_EMIT iconNameChanged(iconName); +} + +void QuickSetting::setText(const QString &text) +{ + if (m_text == text) + return; + + m_text = text; + Q_EMIT textChanged(text); +} + +void QuickSetting::setStatus(const QString &status) +{ + if (m_status == status) + return; + + m_status = status; + Q_EMIT statusChanged(status); +} + +QQmlListProperty QuickSetting::children() +{ + return QQmlListProperty(this, &m_children); +} diff --git a/components/mobileshell/quicksettingsmodel.h b/components/mobileshell/quicksettings/quicksetting.h similarity index 68% rename from components/mobileshell/quicksettingsmodel.h rename to components/mobileshell/quicksettings/quicksetting.h index ae5a2052..e6c0ae65 100644 --- a/components/mobileshell/quicksettingsmodel.h +++ b/components/mobileshell/quicksettings/quicksetting.h @@ -4,8 +4,7 @@ * SPDX-License-Identifier: LGPL-2.0-or-later */ -#ifndef QUICKSETTINGSMODEL_H -#define QUICKSETTINGSMODEL_H +#pragma once #include "qqml.h" #include @@ -68,34 +67,3 @@ private: QString m_settingsCommand; QList m_children; }; - -class QuickSettingsModel : public QAbstractListModel, public QQmlParserStatus -{ - Q_OBJECT - Q_INTERFACES(QQmlParserStatus) - Q_PROPERTY(QQmlListProperty children READ children NOTIFY childrenChanged) - Q_CLASSINFO("DefaultProperty", "children") - QML_ELEMENT - -public: - QuickSettingsModel(QObject *parent = nullptr); - - QVariant data(const QModelIndex &index, int role) const override; - int rowCount(const QModelIndex &parent) const override; - QHash roleNames() const override; - - QQmlListProperty children(); - - void classBegin() override; - void componentComplete() override; - Q_SCRIPTABLE void include(QuickSetting *item); - -Q_SIGNALS: - void childrenChanged(); - -private: - QList m_children; - QList m_external; -}; - -#endif // QUICKSETTINGSMODEL_H diff --git a/components/mobileshell/quicksettingsmodel.cpp b/components/mobileshell/quicksettings/quicksettingsmodel.cpp similarity index 69% rename from components/mobileshell/quicksettingsmodel.cpp rename to components/mobileshell/quicksettings/quicksettingsmodel.cpp index d07bff48..239bab7f 100644 --- a/components/mobileshell/quicksettingsmodel.cpp +++ b/components/mobileshell/quicksettings/quicksettingsmodel.cpp @@ -80,63 +80,6 @@ void QuickSettingsModel::componentComplete() { } -//////////////////////// - -QuickSetting::QuickSetting(QObject *parent) - : QObject(parent) -{ -} - -void QuickSetting::setEnabled(bool enabled) -{ - if (m_enabled == enabled) - return; - - m_enabled = enabled; - Q_EMIT enabledChanged(enabled); -} - -void QuickSetting::setSettingsCommand(const QString &settingsCommand) -{ - if (m_settingsCommand == settingsCommand) - return; - - m_settingsCommand = settingsCommand; - Q_EMIT settingsCommandChanged(settingsCommand); -} - -void QuickSetting::setIconName(const QString &iconName) -{ - if (m_iconName == iconName) - return; - - m_iconName = iconName; - Q_EMIT iconNameChanged(iconName); -} - -void QuickSetting::setText(const QString &text) -{ - if (m_text == text) - return; - - m_text = text; - Q_EMIT textChanged(text); -} - -void QuickSetting::setStatus(const QString &status) -{ - if (m_status == status) - return; - - m_status = status; - Q_EMIT statusChanged(status); -} - -QQmlListProperty QuickSetting::children() -{ - return QQmlListProperty(this, &m_children); -} - void QuickSettingsModel::include(QuickSetting *item) { const int c = m_children.count() + m_external.count(); diff --git a/components/mobileshell/quicksettings/quicksettingsmodel.h b/components/mobileshell/quicksettings/quicksettingsmodel.h new file mode 100644 index 00000000..c4297202 --- /dev/null +++ b/components/mobileshell/quicksettings/quicksettingsmodel.h @@ -0,0 +1,45 @@ +/* + * SPDX-FileCopyrightText: 2021 Aleix Pol Gonzalez + * + * SPDX-License-Identifier: LGPL-2.0-or-later + */ + +#ifndef QUICKSETTINGSMODEL_H +#define QUICKSETTINGSMODEL_H + +#include "qqml.h" +#include "quicksetting.h" + +#include +#include + +class QuickSettingsModel : public QAbstractListModel, public QQmlParserStatus +{ + Q_OBJECT + Q_INTERFACES(QQmlParserStatus) + Q_PROPERTY(QQmlListProperty children READ children NOTIFY childrenChanged) + Q_CLASSINFO("DefaultProperty", "children") + QML_ELEMENT + +public: + QuickSettingsModel(QObject *parent = nullptr); + + QVariant data(const QModelIndex &index, int role) const override; + int rowCount(const QModelIndex &parent) const override; + QHash roleNames() const override; + + QQmlListProperty children(); + + void classBegin() override; + void componentComplete() override; + Q_SCRIPTABLE void include(QuickSetting *item); + +Q_SIGNALS: + void childrenChanged(); + +private: + QList m_children; + QList m_external; +}; + +#endif // QUICKSETTINGSMODEL_H