File indexing completed on 2024-05-12 04:02:20

0001 /*
0002     SPDX-FileCopyrightText: 2016 Volker Krause <vkrause@kde.org>
0003     SPDX-FileCopyrightText: 2022 Jonathan Poelen <jonathan.poelen@gmail.com>
0004 
0005     SPDX-License-Identifier: MIT
0006 */
0007 
0008 #include "theme.h"
0009 #include "themedata_p.h"
0010 
0011 #include <QCoreApplication>
0012 
0013 using namespace KSyntaxHighlighting;
0014 
0015 static QExplicitlySharedDataPointer<ThemeData> &sharedDefaultThemeData()
0016 {
0017     static QExplicitlySharedDataPointer<ThemeData> data(new ThemeData);
0018     return data;
0019 }
0020 
0021 Theme::Theme()
0022     : m_data(sharedDefaultThemeData())
0023 {
0024 }
0025 
0026 Theme::Theme(const Theme &copy) = default;
0027 
0028 Theme::Theme(ThemeData *data)
0029     : m_data(data)
0030 {
0031 }
0032 
0033 Theme::~Theme() = default;
0034 
0035 Theme &Theme::operator=(const Theme &other) = default;
0036 
0037 bool Theme::isValid() const
0038 {
0039     return m_data.data() != sharedDefaultThemeData().data();
0040 }
0041 
0042 QString Theme::name() const
0043 {
0044     return m_data->name();
0045 }
0046 
0047 QString Theme::translatedName() const
0048 {
0049     return isValid() ? QCoreApplication::instance()->translate("Theme", m_data->name().toUtf8().constData()) : QString();
0050 }
0051 
0052 bool Theme::isReadOnly() const
0053 {
0054     return m_data->isReadOnly();
0055 }
0056 
0057 QString Theme::filePath() const
0058 {
0059     return m_data->filePath();
0060 }
0061 
0062 QRgb Theme::textColor(TextStyle style) const
0063 {
0064     return m_data->textColor(style);
0065 }
0066 
0067 QRgb Theme::selectedTextColor(TextStyle style) const
0068 {
0069     return m_data->selectedTextColor(style);
0070 }
0071 
0072 QRgb Theme::backgroundColor(TextStyle style) const
0073 {
0074     return m_data->backgroundColor(style);
0075 }
0076 
0077 QRgb Theme::selectedBackgroundColor(TextStyle style) const
0078 {
0079     return m_data->selectedBackgroundColor(style);
0080 }
0081 
0082 bool Theme::isBold(TextStyle style) const
0083 {
0084     return m_data->isBold(style);
0085 }
0086 
0087 bool Theme::isItalic(TextStyle style) const
0088 {
0089     return m_data->isItalic(style);
0090 }
0091 
0092 bool Theme::isUnderline(TextStyle style) const
0093 {
0094     return m_data->isUnderline(style);
0095 }
0096 
0097 bool Theme::isStrikeThrough(TextStyle style) const
0098 {
0099     return m_data->isStrikeThrough(style);
0100 }
0101 
0102 QRgb Theme::editorColor(EditorColorRole role) const
0103 {
0104     return m_data->editorColor(role);
0105 }
0106 
0107 #include "moc_theme.cpp"