summaryrefslogtreecommitdiffstats
path: root/QtLauncher/settingsmanager.h
blob: f65a707c222bfd19e553b58359dec6fcaceaa50e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// Copyright (C) 2023 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only

#ifndef SETTINGSMANAGER_H
#define SETTINGSMANAGER_H

#include "qqmlintegration.h"
#include <QObject>
#include <QSettings>

class SettingsManager : public QObject
{
    Q_OBJECT
    Q_PROPERTY(bool gridSelected READ gridSelected WRITE setGridSelected NOTIFY gridSelectedChanged)
    Q_PROPERTY (bool mouseSelected READ mouseSelected WRITE setMouseSelected NOTIFY mouseSelectedChanged)

    QML_ELEMENT
    QML_SINGLETON
public:
    explicit SettingsManager(QObject *parent = nullptr);
    ~SettingsManager();

    bool gridSelected();
    void setGridSelected(bool enabled);
    bool mouseSelected();
    void setMouseSelected(bool enabled);

    Q_INVOKABLE QVariant getValue(const QString& key, const QVariant &defaultValue);
    Q_INVOKABLE void setValue(const QString& key, const QVariant &value);

signals:
    void gridSelectedChanged(bool enabled);
    void mouseSelectedChanged(bool enabled);

private:
    QSettings m_settings;
};

#endif // SETTINGSMANAGER_H