KSyntaxHighlighting

theme.cpp
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
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("Theme", m_data->name().toUtf8().constData()) : QString();
50}
51
53{
54 return m_data->isReadOnly();
55}
56
58{
59 return m_data->filePath();
60}
61
62QRgb 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
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
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}
106
107#include "moc_theme.cpp"
Color theme definition used for highlighting.
Definition theme.h:65
bool isValid() const
Returns true if this is a valid Theme.
Definition theme.cpp:37
bool isStrikeThrough(TextStyle style) const
Returns whether the given style should be shown struck through.
Definition theme.cpp:97
QRgb textColor(TextStyle style) const
Returns the text color to be used for style.
Definition theme.cpp:62
QString filePath() const
Returns the full path and file name to this Theme.
Definition theme.cpp:57
bool isBold(TextStyle style) const
Returns whether the given style should be shown in bold.
Definition theme.cpp:82
Theme()
Default constructor, creating an invalid Theme, see isValid().
Definition theme.cpp:21
bool isReadOnly() const
Returns true if this Theme is read-only.
Definition theme.cpp:52
QRgb selectedTextColor(TextStyle style) const
Returns the selected text color to be used for style.
Definition theme.cpp:67
QRgb selectedBackgroundColor(TextStyle style) const
Returns the background color to be used for selected text for style.
Definition theme.cpp:77
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:158
Theme & operator=(const Theme &other)
Assignment operator, sharing the Theme data with other.
TextStyle
Default styles that can be referenced from syntax definition XML files.
Definition theme.h:75
bool isItalic(TextStyle style) const
Returns whether the given style should be shown in italic.
Definition theme.cpp:87
QRgb backgroundColor(TextStyle style) const
Returns the background color to be used for style.
Definition theme.cpp:72
QRgb editorColor(EditorColorRole role) const
Returns the editor color for the requested role.
Definition theme.cpp:102
Syntax highlighting engine for Kate syntax definitions.
QCoreApplication * instance()
QString translate(const char *context, const char *sourceText, const char *disambiguation, int n)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:17:13 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.