DolphinQt: Adjust panel-specific colors and syntax highlighting for dark theme.

This commit is contained in:
Admiral H. Curtiss 2023-08-01 20:47:17 +02:00 committed by Nayla Hanegan
parent 887b07af71
commit 521d6e93c7
No known key found for this signature in database
GPG key ID: 3075216CED0DB01D
8 changed files with 97 additions and 28 deletions

View file

@ -3,6 +3,11 @@
#include "DolphinQt/Config/GameConfigHighlighter.h"
#include <QBrush>
#include <QColor>
#include "DolphinQt/Settings.h"
struct HighlightingRule
{
QRegularExpression pattern;
@ -13,22 +18,36 @@ GameConfigHighlighter::~GameConfigHighlighter() = default;
GameConfigHighlighter::GameConfigHighlighter(QTextDocument* parent) : QSyntaxHighlighter(parent)
{
const bool is_dark_theme = Settings::Instance().IsThemeDark();
QTextCharFormat equal_format;
equal_format.setForeground(Qt::red);
if (is_dark_theme)
equal_format.setForeground(QBrush{QColor(255, 96, 96)});
else
equal_format.setForeground(Qt::red);
QTextCharFormat section_format;
section_format.setFontWeight(QFont::Bold);
QTextCharFormat comment_format;
comment_format.setForeground(Qt::darkGreen);
if (is_dark_theme)
comment_format.setForeground(QBrush{QColor(0, 220, 0)});
else
comment_format.setForeground(Qt::darkGreen);
comment_format.setFontItalic(true);
QTextCharFormat const_format;
const_format.setFontWeight(QFont::Bold);
const_format.setForeground(Qt::blue);
if (is_dark_theme)
const_format.setForeground(QBrush{QColor(132, 132, 255)});
else
const_format.setForeground(Qt::blue);
QTextCharFormat num_format;
num_format.setForeground(Qt::darkBlue);
if (is_dark_theme)
num_format.setForeground(QBrush{QColor(66, 138, 255)});
else
num_format.setForeground(Qt::darkBlue);
m_rules.emplace_back(HighlightingRule{QRegularExpression(QStringLiteral("=")), equal_format});
m_rules.emplace_back(

View file

@ -6,6 +6,8 @@
#include <optional>
#include <thread>
#include <QBrush>
#include <QColor>
#include <QComboBox>
#include <QDialogButtonBox>
#include <QHeaderView>
@ -38,7 +40,6 @@
namespace
{
// TODO: Make sure these functions return colors that will be visible in the current theme.
QTextCharFormat GetSpecialCharFormat()
{
QTextCharFormat format;
@ -49,7 +50,10 @@ QTextCharFormat GetSpecialCharFormat()
QTextCharFormat GetLiteralCharFormat()
{
QTextCharFormat format;
format.setForeground(QBrush{Qt::darkMagenta});
if (Settings::Instance().IsThemeDark())
format.setForeground(QBrush{QColor(171, 132, 219)});
else
format.setForeground(QBrush{Qt::darkMagenta});
return format;
}
@ -57,35 +61,50 @@ QTextCharFormat GetInvalidCharFormat()
{
QTextCharFormat format;
format.setUnderlineStyle(QTextCharFormat::WaveUnderline);
format.setUnderlineColor(Qt::darkRed);
if (Settings::Instance().IsThemeDark())
format.setUnderlineColor(QColor(255, 69, 0));
else
format.setUnderlineColor(Qt::darkRed);
return format;
}
QTextCharFormat GetControlCharFormat()
{
QTextCharFormat format;
format.setForeground(QBrush{Qt::darkGreen});
if (Settings::Instance().IsThemeDark())
format.setForeground(QBrush{QColor(0, 220, 0)});
else
format.setForeground(QBrush{Qt::darkGreen});
return format;
}
QTextCharFormat GetVariableCharFormat()
{
QTextCharFormat format;
format.setForeground(QBrush{Qt::darkYellow});
if (Settings::Instance().IsThemeDark())
format.setForeground(QBrush{QColor(226, 226, 0)});
else
format.setForeground(QBrush{Qt::darkYellow});
return format;
}
QTextCharFormat GetBarewordCharFormat()
{
QTextCharFormat format;
format.setForeground(QBrush{Qt::darkBlue});
if (Settings::Instance().IsThemeDark())
format.setForeground(QBrush{QColor(66, 138, 255)});
else
format.setForeground(QBrush{Qt::darkBlue});
return format;
}
QTextCharFormat GetCommentCharFormat()
{
QTextCharFormat format;
format.setForeground(QBrush{Qt::darkGray});
if (Settings::Instance().IsThemeDark())
format.setForeground(QBrush{QColor(176, 176, 176)});
else
format.setForeground(QBrush{Qt::darkGray});
return format;
}
} // namespace