File indexing completed on 2024-04-28 05:34:23
0001 /* 0002 * SPDX-FileCopyrightText: 2019 Arjen Hiemstra <ahiemstra@heimr.nl> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0005 */ 0006 0007 #pragma once 0008 0009 #include <memory> 0010 0011 #include <QObject> 0012 #include <QQmlParserStatus> 0013 #include <QTimer> 0014 0015 #include <qqmlregistration.h> 0016 0017 #include "systemmonitor.h" 0018 0019 /** 0020 * Wraps Config in an API similar to Qt.labs.settings 0021 * 0022 * This object should be used from QML. Any custom properties declared on the 0023 * QML instance will be forwarded from and to the KConfig based configuration 0024 * class. 0025 */ 0026 class Configuration : public QObject, public QQmlParserStatus 0027 { 0028 Q_OBJECT 0029 Q_INTERFACES(QQmlParserStatus) 0030 QML_ELEMENT 0031 0032 public: 0033 explicit Configuration(QObject *parent = nullptr); 0034 0035 Q_SLOT void propertyChanged(); 0036 0037 Q_SIGNAL void configurationLoaded(); 0038 0039 void classBegin() override; 0040 void componentComplete() override; 0041 0042 static SystemMonitorConfiguration *globalConfig(); 0043 0044 private: 0045 std::unique_ptr<QTimer> m_saveTimer; 0046 };