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

source code of syntax-highlighting/src/lib/theme.cpp