Changeset View
Changeset View
Standalone View
Standalone View
kcms/feedback/feedback.h
- This file was added.
1 | /* | ||||
---|---|---|---|---|---|
2 | * Copyright (C) 2019 David Edmundson <davidedmundson@kde.org> | ||||
3 | * Copyright (C) 2019 Aleix Pol Gonzalez <aleixpol@kde.org> | ||||
4 | * | ||||
5 | * This library is free software; you can redistribute it and/or | ||||
6 | * modify it under the terms of the GNU Library General Public | ||||
7 | * License as published by the Free Software Foundation; either | ||||
8 | * version 2 of the License, or (at your option) any later version. | ||||
9 | * | ||||
10 | * This library is distributed in the hope that it will be useful, | ||||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||||
13 | * Library General Public License for more details. | ||||
14 | * | ||||
15 | * You should have received a copy of the GNU Library General Public License | ||||
16 | * along with this library; see the file COPYING.LIB. If not, write to | ||||
17 | * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||||
18 | * Boston, MA 02110-1301, USA. | ||||
19 | */ | ||||
20 | | ||||
21 | #pragma once | ||||
22 | | ||||
23 | #include <KQuickAddons/ConfigModule> | ||||
24 | | ||||
25 | #include <KSharedConfig> | ||||
26 | | ||||
27 | class Feedback : public KQuickAddons::ConfigModule | ||||
28 | { | ||||
29 | Q_OBJECT | ||||
30 | | ||||
31 | Q_PROPERTY(bool feedbackEnabled READ feedbackEnabled WRITE setFeedbackEnabled NOTIFY feedbackEnabledChanged) | ||||
32 | Q_PROPERTY(int plasmaFeedbackLevel READ plasmaFeedbackLevel WRITE setPlasmaFeedbackLevel NOTIFY plasmaFeedbackLevelChanged) | ||||
33 | | ||||
34 | public: | ||||
35 | explicit Feedback(QObject* parent = nullptr, const QVariantList &list = QVariantList()); | ||||
36 | ~Feedback() override; | ||||
37 | | ||||
38 | bool feedbackEnabled() const { return m_feedbackEnabled; } | ||||
39 | int plasmaFeedbackLevel() const { return m_plasmaFeedbackLevel; } | ||||
40 | | ||||
41 | void setFeedbackEnabled(bool feedbackEnabled) { | ||||
42 | if (feedbackEnabled != m_feedbackEnabled) { | ||||
43 | m_feedbackEnabled = feedbackEnabled; | ||||
44 | Q_EMIT feedbackEnabledChanged(feedbackEnabled); | ||||
45 | } | ||||
46 | } | ||||
47 | | ||||
48 | void setPlasmaFeedbackLevel(int plasmaFeedbackLevel) { | ||||
49 | if (plasmaFeedbackLevel != m_plasmaFeedbackLevel) { | ||||
50 | m_plasmaFeedbackLevel = plasmaFeedbackLevel; | ||||
51 | Q_EMIT plasmaFeedbackLevelChanged(plasmaFeedbackLevel); | ||||
52 | } | ||||
53 | } | ||||
54 | | ||||
55 | public Q_SLOTS: | ||||
56 | void load() override; | ||||
57 | void save() override; | ||||
58 | void defaults() override; | ||||
59 | | ||||
60 | Q_SIGNALS: | ||||
61 | void feedbackEnabledChanged(bool feedbackEnabled) const; | ||||
62 | void plasmaFeedbackLevelChanged(bool plasmaFeedbackLevel); | ||||
63 | | ||||
64 | private: | ||||
65 | KSharedConfig::Ptr m_globalConfig; | ||||
66 | KSharedConfig::Ptr m_plasmaConfig; | ||||
67 | bool m_feedbackEnabled = false; | ||||
68 | int m_plasmaFeedbackLevel = 0; | ||||
69 | }; |