KSyntaxHighlighting

theme.cpp
1 /*
2  Copyright (C) 2016 Volker Krause <[email protected]>
3 
4  Permission is hereby granted, free of charge, to any person obtaining
5  a copy of this software and associated documentation files (the
6  "Software"), to deal in the Software without restriction, including
7  without limitation the rights to use, copy, modify, merge, publish,
8  distribute, sublicense, and/or sell copies of the Software, and to
9  permit persons to whom the Software is furnished to do so, subject to
10  the following conditions:
11 
12  The above copyright notice and this permission notice shall be included
13  in all copies or substantial portions of the Software.
14 
15  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
19  CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
20  TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
21  SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 */
23 
24 #include "theme.h"
25 #include "themedata_p.h"
26 
27 #include <QCoreApplication>
28 
29 using namespace KSyntaxHighlighting;
30 
32 {
33 }
34 
35 Theme::Theme(const Theme &copy)
36 {
37  m_data = copy.m_data;
38 }
39 
40 Theme::Theme(ThemeData *data)
41  : m_data(data)
42 {
43 }
44 
46 {
47 }
48 
50 {
51  m_data = other.m_data;
52  return *this;
53 }
54 
55 bool Theme::isValid() const
56 {
57  return m_data.data();
58 }
59 
61 {
62  return m_data ? m_data->name() : QString();
63 }
64 
66 {
67  return m_data ? QCoreApplication::instance()->translate("Theme", m_data->name().toUtf8().constData()) : QString();
68 }
69 
70 bool Theme::isReadOnly() const
71 {
72  return m_data ? m_data->isReadOnly() : false;
73 }
74 
76 {
77  return m_data ? m_data->filePath() : QString();
78 }
79 
80 QRgb Theme::textColor(TextStyle style) const
81 {
82  return m_data ? m_data->textColor(style) : 0;
83 }
84 
86 {
87  return m_data ? m_data->selectedTextColor(style) : 0;
88 }
89 
91 {
92  return m_data ? m_data->backgroundColor(style) : 0;
93 }
94 
96 {
97  return m_data ? m_data->selectedBackgroundColor(style) : 0;
98 }
99 
100 bool Theme::isBold(TextStyle style) const
101 {
102  return m_data ? m_data->isBold(style) : false;
103 }
104 
105 bool Theme::isItalic(TextStyle style) const
106 {
107  return m_data ? m_data->isItalic(style) : false;
108 }
109 
110 bool Theme::isUnderline(TextStyle style) const
111 {
112  return m_data ? m_data->isUnderline(style) : false;
113 }
114 
116 {
117  return m_data ? m_data->isStrikeThrough(style) : false;
118 }
119 
121 {
122  return m_data ? m_data->editorColor(role) : 0;
123 }
QRgb editorColor(EditorColorRole role) const
Returns the editor color for the requested role.
Definition: theme.cpp:120
bool isUnderline(TextStyle style) const
Returns whether the given style should be shown underlined.
Definition: theme.cpp:110
bool isItalic(TextStyle style) const
Returns whether the given style should be shown in italic.
Definition: theme.cpp:105
const T * constData() const const
QString filePath() const
Returns the full path and file name to this Theme.
Definition: theme.cpp:75
QString translate(const char *context, const char *sourceText, const char *disambiguation, int n)
EditorColorRole
Editor color roles, used to paint line numbers, editor background etc.
Definition: theme.h:178
~Theme()
Destructor.
Definition: theme.cpp:45
QRgb selectedTextColor(TextStyle style) const
Returns the selected text color to be used for style.
Definition: theme.cpp:85
QRgb backgroundColor(TextStyle style) const
Returns the background color to be used for style.
Definition: theme.cpp:90
Syntax highlighting engine for Kate syntax definitions.
bool isValid() const
Returns true if this is a valid Theme.
Definition: theme.cpp:55
QCoreApplication * instance()
bool isReadOnly() const
Returns true if this Theme is read-only.
Definition: theme.cpp:70
Color theme definition used for highlighting.
Definition: theme.h:81
QString name() const
Returns the unique name of this Theme.
Definition: theme.cpp:60
TextStyle
Default styles that can be referenced from syntax definition XML files.
Definition: theme.h:95
Theme & operator=(const Theme &other)
Assignment operator, sharing the Theme data with other.
Definition: theme.cpp:49
QRgb selectedBackgroundColor(TextStyle style) const
Returns the background color to be used for selected text for style.
Definition: theme.cpp:95
bool isBold(TextStyle style) const
Returns whether the given style should be shown in bold.
Definition: theme.cpp:100
Theme()
Default constructor, creating an invalid Theme, see isValid().
Definition: theme.cpp:31
QRgb textColor(TextStyle style) const
Returns the text color to be used for style.
Definition: theme.cpp:80
bool isStrikeThrough(TextStyle style) const
Returns whether the given style should be shown struck through.
Definition: theme.cpp:115
QString translatedName() const
Returns the translated name of this Theme.
Definition: theme.cpp:65
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Aug 10 2020 23:03:13 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.