Changeset View
Changeset View
Standalone View
Standalone View
src/kthemesettings_p.h
- This file was added.
1 | /* This file is part of the KDE libraries | ||||
---|---|---|---|---|---|
2 | * | ||||
3 | * Copyright (c) 2018 René J.V. Bertin <rjvbertin@gmail.com> | ||||
4 | * | ||||
5 | * This library is free software; you can redistribute it and/or | ||||
6 | * modify it under the terms of the GNU Lesser General Public | ||||
7 | * License as published by the Free Software Foundation; either | ||||
8 | * version 2.1 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 | * Lesser General Public License for more details. | ||||
14 | * | ||||
15 | * You should have received a copy of the GNU Lesser General Public | ||||
16 | * License along with this library; if not, write to the Free Software | ||||
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA | ||||
18 | * 02110-1301 USA | ||||
19 | */ | ||||
20 | | ||||
21 | #ifndef KTHEMESETTINGS_P_H | ||||
22 | #define KTHEMESETTINGS_P_H | ||||
23 | | ||||
24 | #include <QStringList> | ||||
25 | #include <QStandardPaths> | ||||
26 | #include <QSettings> | ||||
27 | #include <QColor> | ||||
28 | | ||||
29 | /** | ||||
30 | * @class KThemeSettings | ||||
31 | * | ||||
32 | * @short A basic interface to read the custom or global theme settings | ||||
33 | * | ||||
34 | * KThemeSettings is wrapper around QSettings that provides an elementary | ||||
35 | * alternative for KColorScheme because that class is not accessible in | ||||
36 | * other Tier 1 frameworks. | ||||
37 | * | ||||
38 | * It allows to obtain RGB specifications from current theme's, either a | ||||
39 | * custom theme if the application set one, or from the user-defined default | ||||
40 | * theme (as set in the kdeglobals settings store). | ||||
41 | * | ||||
42 | * This class is not exported because any external code desiring to use it | ||||
43 | * can and should use KConfig, KColorScheme and KColorSchemeManager instead. | ||||
44 | * | ||||
45 | */ | ||||
46 | class KThemeSettings | ||||
47 | { | ||||
48 | public: | ||||
49 | /** | ||||
50 | * Construct a KThemeSettings object | ||||
51 | * | ||||
52 | * @p initialGroup : the initial group to activate. This is a convenience | ||||
53 | * option for quick lookups: setting this to a non-empty string will cause | ||||
54 | * subsequent lookups to fail (return the fallback value) if the settings | ||||
55 | * store does not contain the group. | ||||
56 | * | ||||
57 | */ | ||||
58 | KThemeSettings(const QString &initialGroup = QString()); | ||||
59 | | ||||
60 | virtual ~KThemeSettings(); | ||||
61 | | ||||
62 | /** | ||||
63 | * exposes QSettings::contains(@p key) | ||||
64 | */ | ||||
65 | bool contains(const QString &key); | ||||
66 | | ||||
67 | /** | ||||
68 | * exposes QSettings::childGroups() | ||||
69 | */ | ||||
70 | QStringList childGroups(); | ||||
71 | | ||||
72 | /** | ||||
73 | * exposes QSettings::beginGroup(@p group) | ||||
74 | */ | ||||
75 | void beginGroup(const QString &group); | ||||
76 | | ||||
77 | /** | ||||
78 | * exposes QSettings::endGroup() | ||||
79 | */ | ||||
80 | void endGroup(); | ||||
81 | | ||||
82 | /** | ||||
83 | * read and return the RGB definition for @p key, or @p defaultValue on failure. | ||||
84 | */ | ||||
85 | QColor readRGB(const QString &key, QColor defaultValue = QColor()); | ||||
86 | | ||||
87 | private: | ||||
88 | QSettings *m_settings = nullptr; | ||||
89 | }; | ||||
90 | | ||||
91 | #endif |