mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
fix(chat): cleanup chat css base style
fix chat area's inner stylesheet note: the base font is never a bold font (respects html tags: e.g. <b>bold text</b>) fix block colors: * action -> blue * alert -> red * quote -> green
This commit is contained in:
parent
464daebdd7
commit
989b15e656
|
@ -61,6 +61,9 @@ ChatMessage::Ptr ChatMessage::createChatMessage(const QString &sender, const QSt
|
||||||
|
|
||||||
switch(type)
|
switch(type)
|
||||||
{
|
{
|
||||||
|
case NORMAL:
|
||||||
|
text = wrapDiv(text, "msg");
|
||||||
|
break;
|
||||||
case ACTION:
|
case ACTION:
|
||||||
senderText = "*";
|
senderText = "*";
|
||||||
text = wrapDiv(QString("%1 %2").arg(sender.toHtmlEscaped(), text), "action");
|
text = wrapDiv(QString("%1 %2").arg(sender.toHtmlEscaped(), text), "action");
|
||||||
|
@ -69,8 +72,6 @@ ChatMessage::Ptr ChatMessage::createChatMessage(const QString &sender, const QSt
|
||||||
case ALERT:
|
case ALERT:
|
||||||
text = wrapDiv(text, "alert");
|
text = wrapDiv(text, "alert");
|
||||||
break;
|
break;
|
||||||
default:
|
|
||||||
text = wrapDiv(text, "msg");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Note: Eliding cannot be enabled for RichText items. (QTBUG-17207)
|
// Note: Eliding cannot be enabled for RichText items. (QTBUG-17207)
|
||||||
|
|
|
@ -31,13 +31,13 @@
|
||||||
#include <QDesktopServices>
|
#include <QDesktopServices>
|
||||||
#include <QTextFragment>
|
#include <QTextFragment>
|
||||||
|
|
||||||
|
#include "src/widget/style.h"
|
||||||
|
|
||||||
Text::Text(const QString& txt, const QFont& font, bool enableElide, const QString &rwText, const QColor c)
|
Text::Text(const QString& txt, const QFont& font, bool enableElide, const QString &rwText, const QColor c)
|
||||||
: rawText(rwText)
|
: rawText(rwText)
|
||||||
, elide(enableElide)
|
, elide(enableElide)
|
||||||
, defFont(font)
|
, defFont(font)
|
||||||
, defStyleSheet(QString::fromUtf8("body{font: '%1' %2px %3;}")
|
, defStyleSheet(Style::getStylesheet(QStringLiteral(":/ui/chatArea/innerStyle.css"), font))
|
||||||
.arg(font.family()).arg(font.pixelSize())
|
|
||||||
.arg(font.bold() ? "bold" : QString()))
|
|
||||||
, color(c)
|
, color(c)
|
||||||
{
|
{
|
||||||
setText(txt);
|
setText(txt);
|
||||||
|
|
|
@ -29,9 +29,6 @@
|
||||||
CustomTextDocument::CustomTextDocument(QObject *parent)
|
CustomTextDocument::CustomTextDocument(QObject *parent)
|
||||||
: QTextDocument(parent)
|
: QTextDocument(parent)
|
||||||
{
|
{
|
||||||
static QString css = Style::getStylesheet(":ui/chatArea/innerStyle.css");
|
|
||||||
|
|
||||||
setDefaultStyleSheet(css);
|
|
||||||
setUndoRedoEnabled(false);
|
setUndoRedoEnabled(false);
|
||||||
setUseDesignMetrics(false);
|
setUseDesignMetrics(false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,7 +78,7 @@ QStringList Style::getThemeColorNames()
|
||||||
|
|
||||||
QList<QColor> Style::themeColorColors = {QColor(), QColor("#004aa4"), QColor("#97ba00"), QColor("#c23716"), QColor("#4617b5")};
|
QList<QColor> Style::themeColorColors = {QColor(), QColor("#004aa4"), QColor("#97ba00"), QColor("#c23716"), QColor("#4617b5")};
|
||||||
|
|
||||||
QString Style::getStylesheet(const QString &filename)
|
QString Style::getStylesheet(const QString &filename, const QFont& baseFont)
|
||||||
{
|
{
|
||||||
QFile file(filename);
|
QFile file(filename);
|
||||||
if (!file.open(QFile::ReadOnly | QFile::Text))
|
if (!file.open(QFile::ReadOnly | QFile::Text))
|
||||||
|
@ -87,7 +87,7 @@ QString Style::getStylesheet(const QString &filename)
|
||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
return resolve(file.readAll());
|
return resolve(file.readAll(), baseFont);
|
||||||
}
|
}
|
||||||
|
|
||||||
QColor Style::getColor(Style::ColorPalette entry)
|
QColor Style::getColor(Style::ColorPalette entry)
|
||||||
|
@ -115,7 +115,7 @@ QFont Style::getFont(Style::Font font)
|
||||||
return fonts[font];
|
return fonts[font];
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Style::resolve(QString qss)
|
QString Style::resolve(QString qss, const QFont& baseFont)
|
||||||
{
|
{
|
||||||
if (dict.isEmpty())
|
if (dict.isEmpty())
|
||||||
{
|
{
|
||||||
|
@ -137,13 +137,15 @@ QString Style::resolve(QString qss)
|
||||||
{"@themeLight", Style::getColor(Style::ThemeLight).name()},
|
{"@themeLight", Style::getColor(Style::ThemeLight).name()},
|
||||||
|
|
||||||
// fonts
|
// fonts
|
||||||
|
{"@baseFont", QString::fromUtf8("'%1' %2px")
|
||||||
|
.arg(baseFont.family()).arg(QFontInfo(baseFont).pixelSize())},
|
||||||
{"@extraBig", qssifyFont(Style::getFont(Style::ExtraBig))},
|
{"@extraBig", qssifyFont(Style::getFont(Style::ExtraBig))},
|
||||||
{"@big", qssifyFont(Style::getFont(Style::Big))},
|
{"@big", qssifyFont(Style::getFont(Style::Big))},
|
||||||
{"@bigBold", qssifyFont(Style::getFont(Style::BigBold))},
|
{"@bigBold", qssifyFont(Style::getFont(Style::BigBold))},
|
||||||
{"@medium", qssifyFont(Style::getFont(Style::Medium))},
|
{"@medium", qssifyFont(Style::getFont(Style::Medium))},
|
||||||
{"@mediumBold", qssifyFont(Style::getFont(Style::MediumBold))},
|
{"@mediumBold", qssifyFont(Style::getFont(Style::MediumBold))},
|
||||||
{"@small", qssifyFont(Style::getFont(Style::Small))},
|
{"@small", qssifyFont(Style::getFont(Style::Small))},
|
||||||
{"@smallLight", qssifyFont(Style::getFont(Style::SmallLight))},
|
{"@smallLight", qssifyFont(Style::getFont(Style::SmallLight))}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -59,10 +59,10 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
static QStringList getThemeColorNames();
|
static QStringList getThemeColorNames();
|
||||||
static QString getStylesheet(const QString& filename);
|
static QString getStylesheet(const QString& filename, const QFont& baseFont = QFont());
|
||||||
static QColor getColor(ColorPalette entry);
|
static QColor getColor(ColorPalette entry);
|
||||||
static QFont getFont(Font font);
|
static QFont getFont(Font font);
|
||||||
static QString resolve(QString qss);
|
static QString resolve(QString qss, const QFont& baseFont = QFont());
|
||||||
static void repolish(QWidget* w);
|
static void repolish(QWidget* w);
|
||||||
static void setThemeColor(int color);
|
static void setThemeColor(int color);
|
||||||
static void setThemeColor(const QColor &color); ///< Pass an invalid QColor to reset to defaults
|
static void setThemeColor(const QColor &color); ///< Pass an invalid QColor to reset to defaults
|
||||||
|
|
|
@ -1,37 +1,31 @@
|
||||||
|
body {
|
||||||
|
font: @baseFont;
|
||||||
|
}
|
||||||
|
|
||||||
p {
|
p {
|
||||||
white-space: pre-wrap;
|
white-space: pre-wrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
p.msg {
|
.action {
|
||||||
color: @black;
|
|
||||||
font: @big;
|
|
||||||
}
|
|
||||||
|
|
||||||
p.action {
|
|
||||||
color: #1818FF;
|
color: #1818FF;
|
||||||
font: @big;
|
|
||||||
font-style: italic;
|
font-style: italic;
|
||||||
}
|
}
|
||||||
|
|
||||||
p.typing {
|
.typing {
|
||||||
color: @mediumGreyLight;
|
color: @mediumGreyLight;
|
||||||
font: @big;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
span.quote {
|
.quote {
|
||||||
color: #279419;
|
color: #279419;
|
||||||
}
|
}
|
||||||
|
|
||||||
p.alert {
|
.alert {
|
||||||
margin-left: 0px;
|
margin-left: 0px;
|
||||||
margin-right: 0px;
|
margin-right: 0px;
|
||||||
color: @black;
|
|
||||||
background-color: @orange;
|
background-color: @orange;
|
||||||
font: @big;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
p.alert_name {
|
.alert_name {
|
||||||
color: @black;
|
|
||||||
background-color: @orange;
|
background-color: @orange;
|
||||||
font: @bigBold;
|
font: @bigBold;
|
||||||
}
|
}
|
||||||
|
@ -39,4 +33,3 @@ p.alert_name {
|
||||||
a {
|
a {
|
||||||
color: blue;
|
color: blue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user