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