1 | /* |
---|---|
2 | SPDX-FileCopyrightText: 2016 Volker Krause <vkrause@kde.org> |
3 | SPDX-FileCopyrightText: 2022 Jonathan Poelen <jonathan.poelen@gmail.com> |
4 | |
5 | SPDX-License-Identifier: MIT |
6 | */ |
7 | |
8 | #include "theme.h" |
9 | #include "themedata_p.h" |
10 | |
11 | #include <QCoreApplication> |
12 | |
13 | using namespace KSyntaxHighlighting; |
14 | |
15 | static QExplicitlySharedDataPointer<ThemeData> &sharedDefaultThemeData() |
16 | { |
17 | static QExplicitlySharedDataPointer<ThemeData> data(new ThemeData); |
18 | return data; |
19 | } |
20 | |
21 | Theme::Theme() |
22 | : m_data(sharedDefaultThemeData()) |
23 | { |
24 | } |
25 | |
26 | Theme::Theme(const Theme ©) = default; |
27 | |
28 | Theme::Theme(ThemeData *data) |
29 | : m_data(data) |
30 | { |
31 | } |
32 | |
33 | Theme::~Theme() = default; |
34 | |
35 | Theme &Theme::operator=(const Theme &other) = default; |
36 | |
37 | bool Theme::isValid() const |
38 | { |
39 | return m_data.data() != sharedDefaultThemeData().data(); |
40 | } |
41 | |
42 | QString Theme::name() const |
43 | { |
44 | return m_data->name(); |
45 | } |
46 | |
47 | QString Theme::translatedName() const |
48 | { |
49 | return isValid() ? QCoreApplication::instance()->translate(context: "Theme", key: m_data->name().toUtf8().constData()) : QString(); |
50 | } |
51 | |
52 | bool Theme::isReadOnly() const |
53 | { |
54 | return m_data->isReadOnly(); |
55 | } |
56 | |
57 | QString Theme::filePath() const |
58 | { |
59 | return m_data->filePath(); |
60 | } |
61 | |
62 | QRgb Theme::textColor(TextStyle style) const |
63 | { |
64 | return m_data->textColor(style); |
65 | } |
66 | |
67 | QRgb Theme::selectedTextColor(TextStyle style) const |
68 | { |
69 | return m_data->selectedTextColor(style); |
70 | } |
71 | |
72 | QRgb Theme::backgroundColor(TextStyle style) const |
73 | { |
74 | return m_data->backgroundColor(style); |
75 | } |
76 | |
77 | QRgb Theme::selectedBackgroundColor(TextStyle style) const |
78 | { |
79 | return m_data->selectedBackgroundColor(style); |
80 | } |
81 | |
82 | bool Theme::isBold(TextStyle style) const |
83 | { |
84 | return m_data->isBold(style); |
85 | } |
86 | |
87 | bool Theme::isItalic(TextStyle style) const |
88 | { |
89 | return m_data->isItalic(style); |
90 | } |
91 | |
92 | bool Theme::isUnderline(TextStyle style) const |
93 | { |
94 | return m_data->isUnderline(style); |
95 | } |
96 | |
97 | bool Theme::isStrikeThrough(TextStyle style) const |
98 | { |
99 | return m_data->isStrikeThrough(style); |
100 | } |
101 | |
102 | QRgb Theme::editorColor(EditorColorRole role) const |
103 | { |
104 | return m_data->editorColor(role); |
105 | } |
106 | |
107 | #include "moc_theme.cpp" |
108 |