File indexing completed on 2024-04-28 16:53:05

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 "systemmonitor.h"
0016 
0017 /**
0018  * Wraps Config in an API similar to Qt.labs.settings
0019  *
0020  * This object should be used from QML. Any custom properties declared on the
0021  * QML instance will be forwarded from and to the KConfig based configuration
0022  * class.
0023  */
0024 class Configuration : public QObject, public QQmlParserStatus
0025 {
0026     Q_OBJECT
0027     Q_INTERFACES(QQmlParserStatus)
0028 
0029 public:
0030     explicit Configuration(QObject *parent = nullptr);
0031 
0032     Q_SLOT void propertyChanged();
0033 
0034     Q_SIGNAL void configurationLoaded();
0035 
0036     void classBegin() override;
0037     void componentComplete() override;
0038 
0039     static SystemMonitorConfiguration *globalConfig();
0040 
0041 private:
0042     std::unique_ptr<QTimer> m_saveTimer;
0043 };