aboutsummaryrefslogtreecommitdiffstats
path: root/src/libs/3rdparty/syntax-highlighting/src/lib/theme.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/libs/3rdparty/syntax-highlighting/src/lib/theme.cpp')
-rw-r--r--src/libs/3rdparty/syntax-highlighting/src/lib/theme.cpp77
1 files changed, 30 insertions, 47 deletions
diff --git a/src/libs/3rdparty/syntax-highlighting/src/lib/theme.cpp b/src/libs/3rdparty/syntax-highlighting/src/lib/theme.cpp
index 57f62ef6ab..c54bb38b18 100644
--- a/src/libs/3rdparty/syntax-highlighting/src/lib/theme.cpp
+++ b/src/libs/3rdparty/syntax-highlighting/src/lib/theme.cpp
@@ -1,24 +1,8 @@
/*
- Copyright (C) 2016 Volker Krause <vkrause@kde.org>
-
- Permission is hereby granted, free of charge, to any person obtaining
- a copy of this software and associated documentation files (the
- "Software"), to deal in the Software without restriction, including
- without limitation the rights to use, copy, modify, merge, publish,
- distribute, sublicense, and/or sell copies of the Software, and to
- permit persons to whom the Software is furnished to do so, subject to
- the following conditions:
-
- The above copyright notice and this permission notice shall be included
- in all copies or substantial portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ SPDX-FileCopyrightText: 2016 Volker Krause <vkrause@kde.org>
+ SPDX-FileCopyrightText: 2022 Jonathan Poelen <jonathan.poelen@gmail.com>
+
+ SPDX-License-Identifier: MIT
*/
#include "theme.h"
@@ -28,97 +12,96 @@
using namespace KSyntaxHighlighting;
-Theme::Theme()
+static QExplicitlySharedDataPointer<ThemeData> &sharedDefaultThemeData()
{
+ static QExplicitlySharedDataPointer<ThemeData> data(new ThemeData);
+ return data;
}
-Theme::Theme(const Theme &copy)
+Theme::Theme()
+ : m_data(sharedDefaultThemeData())
{
- m_data = copy.m_data;
}
-Theme::Theme(ThemeData* data)
+Theme::Theme(const Theme &copy) = default;
+
+Theme::Theme(ThemeData *data)
: m_data(data)
{
}
-Theme::~Theme()
-{
-}
+Theme::~Theme() = default;
-Theme &Theme::operator=(const Theme &other)
-{
- m_data = other.m_data;
- return *this;
-}
+Theme &Theme::operator=(const Theme &other) = default;
bool Theme::isValid() const
{
- return m_data.data();
+ return m_data.data() != sharedDefaultThemeData().data();
}
QString Theme::name() const
{
- return m_data ? m_data->name() : QString();
+ return m_data->name();
}
QString Theme::translatedName() const
{
- return m_data ? QCoreApplication::instance()->translate("Theme", m_data->name().toUtf8().constData())
- : QString();
+ return isValid() ? QCoreApplication::instance()->translate("Theme", m_data->name().toUtf8().constData()) : QString();
}
bool Theme::isReadOnly() const
{
- return m_data ? m_data->isReadOnly() : false;
+ return m_data->isReadOnly();
}
QString Theme::filePath() const
{
- return m_data ? m_data->filePath() : QString();
+ return m_data->filePath();
}
QRgb Theme::textColor(TextStyle style) const
{
- return m_data ? m_data->textColor(style) : 0;
+ return m_data->textColor(style);
}
QRgb Theme::selectedTextColor(TextStyle style) const
{
- return m_data ? m_data->selectedTextColor(style) : 0;
+ return m_data->selectedTextColor(style);
}
QRgb Theme::backgroundColor(TextStyle style) const
{
- return m_data ? m_data->backgroundColor(style) : 0;
+ return m_data->backgroundColor(style);
}
QRgb Theme::selectedBackgroundColor(TextStyle style) const
{
- return m_data ? m_data->selectedBackgroundColor(style) : 0;
+ return m_data->selectedBackgroundColor(style);
}
bool Theme::isBold(TextStyle style) const
{
- return m_data ? m_data->isBold(style) : false;
+ return m_data->isBold(style);
}
bool Theme::isItalic(TextStyle style) const
{
- return m_data ? m_data->isItalic(style) : false;
+ return m_data->isItalic(style);
}
bool Theme::isUnderline(TextStyle style) const
{
- return m_data ? m_data->isUnderline(style) : false;
+ return m_data->isUnderline(style);
}
bool Theme::isStrikeThrough(TextStyle style) const
{
- return m_data ? m_data->isStrikeThrough(style) : false;
+ return m_data->isStrikeThrough(style);
}
QRgb Theme::editorColor(EditorColorRole role) const
{
- return m_data ? m_data->editorColor(role) : 0;
+ return m_data->editorColor(role);
}
+
+#include "moc_theme.cpp"