mirror of https://github.com/qTox/qTox
refactor: move palette colors in ini files
parent
87d6883a0f
commit
5bc27b08bc
4
res.qrc
4
res.qrc
|
@ -44,6 +44,7 @@
|
|||
<file>img/taskbar/light/taskbar_offline.svg</file>
|
||||
<file>img/taskbar/light/taskbar_event.svg</file>
|
||||
<file>img/transfer.svg</file>
|
||||
<file>themes/dark/palette.ini</file>
|
||||
<file>themes/dark/fileTransferWidget/fileDone.svg</file>
|
||||
<file>themes/dark/centralWidget/centralWidget.css</file>
|
||||
<file>themes/dark/chatArea/chatArea.css</file>
|
||||
|
@ -108,7 +109,8 @@
|
|||
<file>themes/dark/loginScreen/loginScreen.css</file>
|
||||
<file>themes/dark/contentDialog/contentDialog.css</file>
|
||||
<file>themes/dark/tooliconsZone/tooliconsZone.css</file>
|
||||
<file>themes/default/fileTransferWidget/fileDone.svg</file>
|
||||
<file>themes/default/palette.ini</file>
|
||||
<file>themes/default/fileTransferWidget/fileDone.svg</file>
|
||||
<file>themes/default/centralWidget/centralWidget.css</file>
|
||||
<file>themes/default/chatArea/chatArea.css</file>
|
||||
<file>themes/default/chatArea/chatHead.css</file>
|
||||
|
|
|
@ -66,8 +66,7 @@ ChatLog::ChatLog(QWidget* parent)
|
|||
setDragMode(QGraphicsView::NoDrag);
|
||||
setViewportUpdateMode(MinimalViewportUpdate);
|
||||
setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
// setBackgroundBrush(QBrush(Qt::white, Qt::SolidPattern)); // NOTE: default
|
||||
setBackgroundBrush(QBrush(Style::getColor(Style::White), Qt::SolidPattern)); // NOTE: dark
|
||||
setBackgroundBrush(QBrush(Style::getColor(Style::White), Qt::SolidPattern));
|
||||
|
||||
// The selection rect for multi-line selection
|
||||
selGraphItem = scene->addRect(0, 0, 0, 0, selectionRectColor.darker(120), selectionRectColor);
|
||||
|
|
|
@ -50,9 +50,7 @@ ChatMessage::Ptr ChatMessage::createChatMessage(const QString& sender, const QSt
|
|||
QString text = rawMessage.toHtmlEscaped();
|
||||
QString senderText = sender;
|
||||
|
||||
const QColor actionColor =
|
||||
// QColor("#1818FF"); // has to match the color in innerStyle.css (div.action) // NOTE: Default
|
||||
QColor("#546eff"); // NOTE: Dark
|
||||
const QColor actionColor = Style::getColor(Style::Action);
|
||||
|
||||
// smileys
|
||||
if (Settings::getInstance().getUseEmoticons())
|
||||
|
@ -89,8 +87,7 @@ ChatMessage::Ptr ChatMessage::createChatMessage(const QString& sender, const QSt
|
|||
if (isMe)
|
||||
authorFont.setBold(true);
|
||||
|
||||
// QColor color = QColor(0, 0, 0); // NOTE: Default
|
||||
QColor color = QColor("#c3c3c3"); // NOTE: Dark
|
||||
QColor color = Style::getColor(Style::Black);
|
||||
QColor authorColor;
|
||||
|
||||
if (colorizeName && Settings::getInstance().getEnableGroupChatsColor())
|
||||
|
|
|
@ -31,8 +31,6 @@
|
|||
#include <QTextBlock>
|
||||
#include <QTextFragment>
|
||||
|
||||
#include "src/widget/style.h"
|
||||
|
||||
static const QString COLOR_HIGHLIGHT = QStringLiteral("#ff7626");
|
||||
|
||||
Text::Text(const QString& txt, const QFont& font, bool enableElide, const QString& rwText,
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#define TEXT_H
|
||||
|
||||
#include "../chatlinecontent.h"
|
||||
#include "src/widget/style.h"
|
||||
|
||||
#include <QFont>
|
||||
|
||||
|
@ -32,8 +33,7 @@ class Text : public ChatLineContent
|
|||
|
||||
public:
|
||||
Text(const QString& txt = "", const QFont& font = QFont(), bool enableElide = false,
|
||||
// const QString& rawText = QString(), const QColor c = Qt::black); // NOTE: Default
|
||||
const QString& rawText = QString(), const QColor c = QColor("#c3c3c3")); // NOTE: Dark
|
||||
const QString& rawText = QString(), const QColor c = Style::getColor(Style::Black));
|
||||
virtual ~Text();
|
||||
|
||||
void setText(const QString& txt);
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include <QMap>
|
||||
#include <QPainter>
|
||||
#include <QRegularExpression>
|
||||
#include <QSettings>
|
||||
#include <QStandardPaths>
|
||||
#include <QStringBuilder>
|
||||
#include <QStyle>
|
||||
|
@ -81,25 +82,7 @@ QString qssifyFont(QFont font)
|
|||
return QString("%1 %2px \"%3\"").arg(font.weight() * 8).arg(font.pixelSize()).arg(font.family());
|
||||
}
|
||||
|
||||
// colors as defined in
|
||||
// https://github.com/ItsDuke/Tox-UI/blob/master/UI%20GUIDELINES.md
|
||||
//static QColor palette[] = { // NOTE: Default
|
||||
// QColor("#6bc260"), QColor("#cebf44"), QColor("#c84e4e"), QColor("#000000"), QColor("#1c1c1c"),
|
||||
// QColor("#414141"), QColor("#414141").lighter(120), QColor("#d1d1d1"), QColor("#ffffff"),
|
||||
// QColor("#ff7700"),
|
||||
|
||||
// // Theme colors
|
||||
// QColor("#1c1c1c"), QColor("#2a2a2a"), QColor("#414141"), QColor("#4e4e4e"),
|
||||
//};
|
||||
|
||||
static QColor palette[] = { // NOTE: Dark
|
||||
QColor("#6bc260"), QColor("#cebf44"), QColor("#c84e4e"), QColor("#000000"), QColor("#c3c3c3"),
|
||||
QColor("#d1d1d1"), QColor("#100f0f").lighter(120), QColor("#d1d1d1"), QColor("#201f1f"),
|
||||
QColor("#ff7700"),
|
||||
|
||||
// Theme colors
|
||||
QColor("#1c1c1c"), QColor("#2a2a2a"), QColor("#100f0f"), QColor("#201f1f"),
|
||||
};
|
||||
static QMap<Style::ColorPalette, QColor> palette;
|
||||
|
||||
static QMap<QString, QString> dict;
|
||||
|
||||
|
@ -134,6 +117,22 @@ QString Style::getThemeFolder()
|
|||
QList<QColor> Style::themeColorColors = {QColor(), QColor("#004aa4"), QColor("#97ba00"),
|
||||
QColor("#c23716"), QColor("#4617b5")};
|
||||
|
||||
QMap<Style::ColorPalette, QString> Style::aliasColors = {{Green, "green"},
|
||||
{Yellow, "yellow"},
|
||||
{Red, "red"},
|
||||
{Black,"black"},
|
||||
{DarkGrey, "darkGrey"},
|
||||
{MediumGrey,"mediumGrey"},
|
||||
{MediumGreyLight, "mediumGreyLight"},
|
||||
{LightGrey, "lightGrey"},
|
||||
{White, "white"},
|
||||
{Orange, "orange"},
|
||||
{ThemeDark, "themeDark"},
|
||||
{ThemeMediumDark, "themeMediumDark"},
|
||||
{ThemeMedium, "themeMedium"},
|
||||
{ThemeLight, "themeLight"},
|
||||
{Action, "action"}};
|
||||
|
||||
// stylesheet filename, font -> stylesheet
|
||||
// QString implicit sharing deduplicates stylesheets rather than constructing a new one each time
|
||||
std::map<std::pair<const QString, const QFont>, const QString> Style::stylesheetsCache;
|
||||
|
@ -230,12 +229,16 @@ const QString Style::resolve(const QString& filename, const QFont& baseFont)
|
|||
}
|
||||
}
|
||||
|
||||
if (palette.isEmpty()) {
|
||||
initPalette();
|
||||
}
|
||||
|
||||
if (dict.isEmpty()) {
|
||||
dict = {// colors
|
||||
{"@green", Style::getColor(Style::Green).name()},
|
||||
{"@yellow", Style::getColor(Style::Yellow).name()},
|
||||
{"@red", Style::getColor(Style::Red).name()},
|
||||
{"@black", Style::getColor(Style::Black).name()},
|
||||
{"@black", Style::getColor(Style::Black).name()}, // NOTE: (Dark) rename to textColor
|
||||
{"@darkGrey", Style::getColor(Style::DarkGrey).name()},
|
||||
{"@mediumGrey", Style::getColor(Style::MediumGrey).name()},
|
||||
{"@mediumGreyLight", Style::getColor(Style::MediumGreyLight).name()},
|
||||
|
@ -246,6 +249,7 @@ const QString Style::resolve(const QString& filename, const QFont& baseFont)
|
|||
{"@themeMediumDark", Style::getColor(Style::ThemeMediumDark).name()},
|
||||
{"@themeMedium", Style::getColor(Style::ThemeMedium).name()},
|
||||
{"@themeLight", Style::getColor(Style::ThemeLight).name()},
|
||||
{"@action", Style::getColor(Style::Action).name()},
|
||||
|
||||
// fonts
|
||||
{"@baseFont",
|
||||
|
@ -325,12 +329,10 @@ void Style::setThemeColor(const QColor& color)
|
|||
{
|
||||
if (!color.isValid()) {
|
||||
// Reset to default
|
||||
palette[ThemeDark] = QColor("#1c1c1c");
|
||||
palette[ThemeMediumDark] = QColor("#2a2a2a");
|
||||
// palette[ThemeMedium] = QColor("#414141"); // NOTE: Default
|
||||
palette[ThemeMedium] = QColor("#100f0f"); // NOTE: Dark
|
||||
// palette[ThemeLight] = QColor("#4e4e4e"); // MOTE: Default
|
||||
palette[ThemeLight] = QColor("#201f1f"); // MOTE: Dark
|
||||
palette[ThemeDark] = getColor(ThemeDark);
|
||||
palette[ThemeMediumDark] = getColor(ThemeMediumDark);
|
||||
palette[ThemeMedium] = getColor(ThemeMedium);
|
||||
palette[ThemeLight] = getColor(ThemeLight);
|
||||
} else {
|
||||
palette[ThemeDark] = color.darker(155);
|
||||
palette[ThemeMediumDark] = color.darker(135);
|
||||
|
@ -361,3 +363,19 @@ QPixmap Style::scaleSvgImage(const QString& path, uint32_t width, uint32_t heigh
|
|||
render.render(&painter, pixmap.rect());
|
||||
return pixmap;
|
||||
}
|
||||
|
||||
void Style::initPalette()
|
||||
{
|
||||
QSettings settings(BuiltinThemePath % "palette.ini", QSettings::IniFormat);
|
||||
|
||||
auto keys = aliasColors.keys();
|
||||
|
||||
settings.beginGroup("colors");
|
||||
|
||||
for (auto k : keys) {
|
||||
palette[k] = QColor(settings.value(aliasColors[k], "#000").toString());
|
||||
}
|
||||
|
||||
settings.endGroup();
|
||||
|
||||
}
|
||||
|
|
|
@ -45,6 +45,7 @@ public:
|
|||
ThemeMediumDark,
|
||||
ThemeMedium,
|
||||
ThemeLight,
|
||||
Action
|
||||
};
|
||||
|
||||
enum Font
|
||||
|
@ -71,6 +72,7 @@ public:
|
|||
static void setThemeColor(const QColor& color);
|
||||
static void applyTheme();
|
||||
static QPixmap scaleSvgImage(const QString& path, uint32_t width, uint32_t height);
|
||||
static void initPalette();
|
||||
|
||||
signals:
|
||||
void themeChanged();
|
||||
|
@ -81,6 +83,7 @@ private:
|
|||
private:
|
||||
static QList<QColor> themeColorColors;
|
||||
static std::map<std::pair<const QString, const QFont>, const QString> stylesheetsCache;
|
||||
static QMap<ColorPalette, QString> aliasColors;
|
||||
};
|
||||
|
||||
#endif // STYLE_H
|
||||
|
|
|
@ -7,7 +7,7 @@ p {
|
|||
}
|
||||
|
||||
.action {
|
||||
color: #546eff;
|
||||
color: @action;
|
||||
font-style: italic;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
[colors]
|
||||
green="#6bc260"
|
||||
yellow="#cebf44"
|
||||
red="#c84e4e"
|
||||
black="#c3c3c3"
|
||||
darkGrey="#c3c3c3"
|
||||
mediumGrey="#d1d1d1"
|
||||
mediumGreyLight="#131212"
|
||||
lightGrey="#d1d1d1"
|
||||
white="#201f1f"
|
||||
orange="#ff7700"
|
||||
themeDark="#1c1c1c"
|
||||
themeMediumDark="#2a2a2a"
|
||||
themeMedium="#100f0f"
|
||||
themeLight="#201f1f"
|
||||
action="#546eff"
|
|
@ -7,7 +7,7 @@ p {
|
|||
}
|
||||
|
||||
.action {
|
||||
color: #1818FF;
|
||||
color: @action;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
[colors]
|
||||
green="#6bc260"
|
||||
yellow="#cebf44"
|
||||
red="#c84e4e"
|
||||
black="#000000"
|
||||
darkGrey="#1c1c1c"
|
||||
mediumGrey="#414141"
|
||||
mediumGreyLight="#4e4e4e"
|
||||
lightGrey="#d1d1d1"
|
||||
white="#ffffff"
|
||||
orange="#ff7700"
|
||||
themeDark="#1c1c1c"
|
||||
themeMediumDark="#2a2a2a"
|
||||
themeMedium="#414141"
|
||||
themeLight="#4e4e4e"
|
||||
action="#1818FF"
|
Loading…
Reference in New Issue