KSyntaxHighlighting

theme.cpp
1 /*
2  SPDX-FileCopyrightText: 2016 Volker Krause <[email protected]>
3  SPDX-FileCopyrightText: 2022 Jonathan Poelen <[email protected]>
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 
22  : m_data(sharedDefaultThemeData())
23 {
24 }
25 
26 Theme::Theme(const Theme &copy) = 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("Theme", m_data->name().toUtf8().constData()) : QString();
50 }
51 
52 bool Theme::isReadOnly() const
53 {
54  return m_data->isReadOnly();
55 }
56 
58 {
59  return m_data->filePath();
60 }
61 
62 QRgb Theme::textColor(TextStyle style) const
63 {
64  return m_data->textColor(style);
65 }
66 
68 {
69  return m_data->selectedTextColor(style);
70 }
71 
73 {
74  return m_data->backgroundColor(style);
75 }
76 
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 
98 {
99  return m_data->isStrikeThrough(style);
100 }
101 
103 {
104  return m_data->editorColor(role);
105 }
QString filePath() const
Returns the full path and file name to this Theme.
Definition: theme.cpp:57
QString translate(const char *context, const char *sourceText, const char *disambiguation, int n)
Theme & operator=(const Theme &other)
Assignment operator, sharing the Theme data with other.
bool isValid() const
Returns true if this is a valid Theme.
Definition: theme.cpp:37
TextStyle
Default styles that can be referenced from syntax definition XML files.
Definition: theme.h:80
Theme()
Default constructor, creating an invalid Theme, see isValid().
Definition: theme.cpp:21
QRgb editorColor(EditorColorRole role) const
Returns the editor color for the requested role.
Definition: theme.cpp:102
QRgb backgroundColor(TextStyle style) const
Returns the background color to be used for style.
Definition: theme.cpp:72
bool isItalic(TextStyle style) const
Returns whether the given style should be shown in italic.
Definition: theme.cpp:87
bool isStrikeThrough(TextStyle style) const
Returns whether the given style should be shown struck through.
Definition: theme.cpp:97
QCoreApplication * instance()
bool isBold(TextStyle style) const
Returns whether the given style should be shown in bold.
Definition: theme.cpp:82
QRgb selectedBackgroundColor(TextStyle style) const
Returns the background color to be used for selected text for style.
Definition: theme.cpp:77
QRgb selectedTextColor(TextStyle style) const
Returns the selected text color to be used for style.
Definition: theme.cpp:67
bool isUnderline(TextStyle style) const
Returns whether the given style should be shown underlined.
Definition: theme.cpp:92
EditorColorRole
Editor color roles, used to paint line numbers, editor background etc.
Definition: theme.h:163
bool isReadOnly() const
Returns true if this Theme is read-only.
Definition: theme.cpp:52
const T * constData() const const
QRgb textColor(TextStyle style) const
Returns the text color to be used for style.
Definition: theme.cpp:62
Color theme definition used for highlighting.
Definition: theme.h:64
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Sun Mar 26 2023 04:09:17 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.