2021-07-14 13:39:43 +00:00
|
|
|
/*
|
|
|
|
|
* SPDX-FileCopyrightText: 2021 Aleix Pol Gonzalez <aleixpol@kde.org>
|
|
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: LGPL-2.0-or-later
|
|
|
|
|
*/
|
|
|
|
|
|
2022-03-11 04:52:53 +00:00
|
|
|
#pragma once
|
2021-07-14 13:39:43 +00:00
|
|
|
|
|
|
|
|
#include "qqml.h"
|
|
|
|
|
#include <QAbstractListModel>
|
|
|
|
|
#include <QQmlListProperty>
|
|
|
|
|
|
2022-03-13 20:27:14 +00:00
|
|
|
#include "mobileshell_export.h"
|
|
|
|
|
|
|
|
|
|
namespace MobileShell
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
class MOBILESHELL_EXPORT QuickSetting : public QObject
|
2021-07-14 13:39:43 +00:00
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
Q_PROPERTY(QString text READ text WRITE setText REQUIRED NOTIFY textChanged)
|
2022-03-13 21:47:42 +00:00
|
|
|
Q_PROPERTY(QString status READ status WRITE setStatus NOTIFY statusChanged) // if no status is explicitly set, On/Off is used by default
|
2021-07-14 13:39:43 +00:00
|
|
|
Q_PROPERTY(QString icon READ iconName WRITE setIconName REQUIRED NOTIFY iconNameChanged)
|
|
|
|
|
Q_PROPERTY(QString settingsCommand READ settingsCommand WRITE setSettingsCommand NOTIFY settingsCommandChanged)
|
|
|
|
|
Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged)
|
|
|
|
|
Q_PROPERTY(QQmlListProperty<QObject> children READ children CONSTANT)
|
|
|
|
|
Q_CLASSINFO("DefaultProperty", "children")
|
|
|
|
|
QML_NAMED_ELEMENT("QuickSetting")
|
|
|
|
|
public:
|
|
|
|
|
QuickSetting(QObject *parent = nullptr);
|
|
|
|
|
|
|
|
|
|
QString text() const
|
|
|
|
|
{
|
|
|
|
|
return m_text;
|
|
|
|
|
}
|
2021-12-22 23:29:00 +00:00
|
|
|
QString status() const
|
|
|
|
|
{
|
|
|
|
|
return m_status;
|
|
|
|
|
}
|
2021-07-14 13:39:43 +00:00
|
|
|
QString iconName() const
|
|
|
|
|
{
|
|
|
|
|
return m_iconName;
|
|
|
|
|
}
|
|
|
|
|
QString settingsCommand() const
|
|
|
|
|
{
|
|
|
|
|
return m_settingsCommand;
|
|
|
|
|
}
|
|
|
|
|
bool isEnabled() const
|
|
|
|
|
{
|
|
|
|
|
return m_enabled;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void setText(const QString &text);
|
2021-12-22 23:29:00 +00:00
|
|
|
void setStatus(const QString &status);
|
2021-07-14 13:39:43 +00:00
|
|
|
void setIconName(const QString &iconName);
|
|
|
|
|
void setSettingsCommand(const QString &settingsCommand);
|
|
|
|
|
void setEnabled(bool enabled);
|
|
|
|
|
QQmlListProperty<QObject> children();
|
|
|
|
|
|
|
|
|
|
Q_SIGNALS:
|
|
|
|
|
void enabledChanged(bool enabled);
|
|
|
|
|
void textChanged(const QString &text);
|
2021-12-22 23:29:00 +00:00
|
|
|
void statusChanged(const QString &text);
|
2021-07-14 13:39:43 +00:00
|
|
|
void iconNameChanged(const QString &icon);
|
|
|
|
|
void settingsCommandChanged(const QString &settingsCommand);
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
bool m_enabled = true;
|
|
|
|
|
QString m_text;
|
2021-12-22 23:29:00 +00:00
|
|
|
QString m_status;
|
2021-07-14 13:39:43 +00:00
|
|
|
QString m_iconName;
|
|
|
|
|
QString m_settingsCommand;
|
|
|
|
|
QList<QObject *> m_children;
|
|
|
|
|
};
|
2022-03-13 20:27:14 +00:00
|
|
|
|
|
|
|
|
} // namespace MobileShell
|