File indexing completed on 2024-09-08 05:00:58
0001 // SPDX-FileCopyrightText: 2022 Devin Lin <devin@kde.org> 0002 // SPDX-License-Identifier: LGPL-2.0-or-later 0003 0004 #pragma once 0005 0006 #include "qqml.h" 0007 #include "quicksetting.h" 0008 #include "quicksettingsconfig.h" 0009 #include "savedquicksettingsmodel.h" 0010 0011 #include <KPackage/Package> 0012 #include <KPluginMetaData> 0013 0014 #include <QAbstractListModel> 0015 #include <QQmlListProperty> 0016 #include <QTimer> 0017 0018 /** 0019 * @short A model that reads quick settings configurations 0020 * from the config and presents models to display them. 0021 * 0022 * @author Devin Lin <devin@kde.org> 0023 **/ 0024 class SavedQuickSettings : public QObject 0025 { 0026 Q_OBJECT 0027 QML_ELEMENT 0028 0029 Q_PROPERTY(SavedQuickSettingsModel *enabledModel READ enabledQuickSettingsModel CONSTANT) 0030 Q_PROPERTY(SavedQuickSettingsModel *disabledModel READ disabledQuickSettingsModel CONSTANT) 0031 0032 public: 0033 SavedQuickSettings(QObject *parent = nullptr); 0034 ~SavedQuickSettings(); 0035 0036 SavedQuickSettingsModel *enabledQuickSettingsModel() const; 0037 SavedQuickSettingsModel *disabledQuickSettingsModel() const; 0038 0039 Q_INVOKABLE void enableQS(int index); 0040 Q_INVOKABLE void disableQS(int index); 0041 0042 private: 0043 void refreshModel(); 0044 void saveModel(); 0045 0046 QuickSettingsConfig *m_settings; 0047 QList<KPluginMetaData> m_validPackages; 0048 QList<KPluginMetaData> m_enabledPackages; 0049 QList<KPluginMetaData> m_disabledPackages; 0050 0051 SavedQuickSettingsModel *m_enabledQSModel; 0052 SavedQuickSettingsModel *m_disabledQSModel; 0053 0054 QTimer *m_updateTimer; 0055 QTimer *m_saveTimer; 0056 };