GrantleeTheme

colorscheme.cpp
1 /*
2  * SPDX-FileCopyrightText: 2019 Volker Krause <[email protected]>
3  *
4  * SPDX-License-Identifier: LGPL-2.1-or-later
5  */
6 
7 #include "colorscheme.h"
8 #include <QObject>
9 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
10 #include <grantlee/metatype.h>
11 #else
12 #include <KTextTemplate/metatype.h>
13 #endif
14 
15 #include <KColorScheme>
16 
17 #define PROP_IMPL(PROP, METHOD) \
18  if (QString::compare(property, QLatin1String(#PROP), Qt::CaseInsensitive) == 0) { \
19  return object.METHOD(KColorScheme::PROP).color(); \
20  }
21 #define BACKGROUND_PROP(PROP) PROP_IMPL(PROP, background)
22 #define FOREGROUND_PROP(PROP) PROP_IMPL(PROP, foreground)
23 #define DECORATION_PROP(PROP) PROP_IMPL(PROP, decoration)
24 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
25 GRANTLEE_BEGIN_LOOKUP(KColorScheme)
26 #else
27 KTEXTTEMPLATE_BEGIN_LOOKUP(KColorScheme)
28 #endif
29 BACKGROUND_PROP(NormalBackground)
30 BACKGROUND_PROP(AlternateBackground)
31 BACKGROUND_PROP(ActiveBackground)
32 BACKGROUND_PROP(LinkBackground)
33 BACKGROUND_PROP(VisitedBackground)
34 BACKGROUND_PROP(NegativeBackground)
35 BACKGROUND_PROP(NeutralBackground)
36 BACKGROUND_PROP(PositiveBackground)
37 
38 FOREGROUND_PROP(NormalText)
39 FOREGROUND_PROP(InactiveText)
40 FOREGROUND_PROP(ActiveText)
41 FOREGROUND_PROP(LinkText)
42 FOREGROUND_PROP(VisitedText)
43 FOREGROUND_PROP(NegativeText)
44 FOREGROUND_PROP(NeutralText)
45 FOREGROUND_PROP(PositiveText)
46 
47 DECORATION_PROP(FocusColor)
48 DECORATION_PROP(HoverColor)
49 
50 return {};
51 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
52 GRANTLEE_END_LOOKUP
53 #else
54 KTEXTTEMPLATE_END_LOOKUP
55 #endif
56 
57 void ColorScheme::registerMetaType()
58 {
59 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
60  Grantlee::registerMetaType<KColorScheme>();
61 #else
62  KTextTemplate::registerMetaType<KColorScheme>();
63 #endif
64 }
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Wed Sep 28 2022 04:06:59 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.