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)
|
||||
{
|
||||
case NORMAL:
|
||||
text = wrapDiv(text, "msg");
|
||||
break;
|
||||
case ACTION:
|
||||
senderText = "*";
|
||||
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:
|
||||
text = wrapDiv(text, "alert");
|
||||
break;
|
||||
default:
|
||||
text = wrapDiv(text, "msg");
|
||||
}
|
||||
|
||||
// Note: Eliding cannot be enabled for RichText items. (QTBUG-17207)
|
||||
|
|
|
@ -31,13 +31,13 @@
|
|||
#include <QDesktopServices>
|
||||
#include <QTextFragment>
|
||||
|
||||
#include "src/widget/style.h"
|
||||
|
||||
Text::Text(const QString& txt, const QFont& font, bool enableElide, const QString &rwText, const QColor c)
|
||||
: rawText(rwText)
|
||||
, elide(enableElide)
|
||||
, defFont(font)
|
||||
, defStyleSheet(QString::fromUtf8("body{font: '%1' %2px %3;}")
|
||||
.arg(font.family()).arg(font.pixelSize())
|
||||
.arg(font.bold() ? "bold" : QString()))
|
||||
, defStyleSheet(Style::getStylesheet(QStringLiteral(":/ui/chatArea/innerStyle.css"), font))
|
||||
, color(c)
|
||||
{
|
||||
setText(txt);
|
||||
|
|
|
@ -29,9 +29,6 @@
|
|||
CustomTextDocument::CustomTextDocument(QObject *parent)
|
||||
: QTextDocument(parent)
|
||||
{
|
||||
static QString css = Style::getStylesheet(":ui/chatArea/innerStyle.css");
|
||||
|
||||
setDefaultStyleSheet(css);
|
||||
setUndoRedoEnabled(false);
|
||||
setUseDesignMetrics(false);
|
||||
}
|
||||
|
|
|
@ -78,7 +78,7 @@ QStringList Style::getThemeColorNames()
|
|||
|
||||
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);
|
||||
if (!file.open(QFile::ReadOnly | QFile::Text))
|
||||
|
@ -87,7 +87,7 @@ QString Style::getStylesheet(const QString &filename)
|
|||
return QString();
|
||||
}
|
||||
|
||||
return resolve(file.readAll());
|
||||
return resolve(file.readAll(), baseFont);
|
||||
}
|
||||
|
||||
QColor Style::getColor(Style::ColorPalette entry)
|
||||
|
@ -115,7 +115,7 @@ QFont Style::getFont(Style::Font font)
|
|||
return fonts[font];
|
||||
}
|
||||
|
||||
QString Style::resolve(QString qss)
|
||||
QString Style::resolve(QString qss, const QFont& baseFont)
|
||||
{
|
||||
if (dict.isEmpty())
|
||||
{
|
||||
|
@ -137,13 +137,15 @@ QString Style::resolve(QString qss)
|
|||
{"@themeLight", Style::getColor(Style::ThemeLight).name()},
|
||||
|
||||
// fonts
|
||||
{"@baseFont", QString::fromUtf8("'%1' %2px")
|
||||
.arg(baseFont.family()).arg(QFontInfo(baseFont).pixelSize())},
|
||||
{"@extraBig", qssifyFont(Style::getFont(Style::ExtraBig))},
|
||||
{"@big", qssifyFont(Style::getFont(Style::Big))},
|
||||
{"@bigBold", qssifyFont(Style::getFont(Style::BigBold))},
|
||||
{"@medium", qssifyFont(Style::getFont(Style::Medium))},
|
||||
{"@mediumBold", qssifyFont(Style::getFont(Style::MediumBold))},
|
||||
{"@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 QString getStylesheet(const QString& filename);
|
||||
static QString getStylesheet(const QString& filename, const QFont& baseFont = QFont());
|
||||
static QColor getColor(ColorPalette entry);
|
||||
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 setThemeColor(int color);
|
||||
static void setThemeColor(const QColor &color); ///< Pass an invalid QColor to reset to defaults
|
||||
|
|
|
@ -1,42 +1,35 @@
|
|||
body {
|
||||
font: @baseFont;
|
||||
}
|
||||
|
||||
p {
|
||||
white-space: pre-wrap;
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
|
||||
p.msg {
|
||||
color: @black;
|
||||
font: @big;
|
||||
.action {
|
||||
color: #1818FF;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
p.action {
|
||||
color: #1818FF;
|
||||
font: @big;
|
||||
font-style: italic;
|
||||
.typing {
|
||||
color: @mediumGreyLight;
|
||||
}
|
||||
|
||||
p.typing {
|
||||
color: @mediumGreyLight;
|
||||
font: @big;
|
||||
.quote {
|
||||
color: #279419;
|
||||
}
|
||||
|
||||
span.quote {
|
||||
color: #279419;
|
||||
.alert {
|
||||
margin-left: 0px;
|
||||
margin-right: 0px;
|
||||
background-color: @orange;
|
||||
}
|
||||
|
||||
p.alert {
|
||||
margin-left: 0px;
|
||||
margin-right: 0px;
|
||||
color: @black;
|
||||
background-color: @orange;
|
||||
font: @big;
|
||||
}
|
||||
|
||||
p.alert_name {
|
||||
color: @black;
|
||||
background-color: @orange;
|
||||
font: @bigBold;
|
||||
.alert_name {
|
||||
background-color: @orange;
|
||||
font: @bigBold;
|
||||
}
|
||||
|
||||
a {
|
||||
color: blue;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user