Added ability to override foreground color for date service messages.

This commit is contained in:
23rd 2021-05-31 20:18:56 +03:00 committed by John Preston
parent 7ee35bc80c
commit 2cd8b00610
2 changed files with 19 additions and 11 deletions

View file

@ -216,7 +216,8 @@ void paintPreparedDate(
int dateTextWidth, int dateTextWidth,
int y, int y,
int w, int w,
const style::color &bg) { const style::color &bg,
const style::color &fg) {
int left = st::msgServiceMargin.left(); int left = st::msgServiceMargin.left();
int maxwidth = w; int maxwidth = w;
if (Core::App().settings().chatWide()) { if (Core::App().settings().chatWide()) {
@ -237,7 +238,7 @@ void paintPreparedDate(
bg); bg);
p.setFont(st::msgServiceFont); p.setFont(st::msgServiceFont);
p.setPen(st::msgServiceFg); p.setPen(fg);
p.drawText(left + st::msgServicePadding.left(), y + st::msgServiceMargin.top() + st::msgServicePadding.top() + st::msgServiceFont->ascent, dateText); p.drawText(left + st::msgServicePadding.left(), y + st::msgServiceMargin.top() + st::msgServicePadding.top() + st::msgServiceFont->ascent, dateText);
} }
@ -261,10 +262,11 @@ void ServiceMessagePainter::paintDate(
const QDateTime &date, const QDateTime &date,
int y, int y,
int w, int w,
const style::color &bg) { const style::color &bg,
const style::color &fg) {
const auto dateText = langDayOfMonthFull(date.date()); const auto dateText = langDayOfMonthFull(date.date());
const auto dateTextWidth = st::msgServiceFont->width(dateText); const auto dateTextWidth = st::msgServiceFont->width(dateText);
paintPreparedDate(p, dateText, dateTextWidth, y, w, bg); paintPreparedDate(p, dateText, dateTextWidth, y, w, bg, fg);
} }
void ServiceMessagePainter::paintDate( void ServiceMessagePainter::paintDate(
@ -272,14 +274,16 @@ void ServiceMessagePainter::paintDate(
const QString &dateText, const QString &dateText,
int y, int y,
int w, int w,
const style::color &bg) { const style::color &bg,
const style::color &fg) {
paintPreparedDate( paintPreparedDate(
p, p,
dateText, dateText,
st::msgServiceFont->width(dateText), st::msgServiceFont->width(dateText),
y, y,
w, w,
bg); bg,
fg);
} }
void ServiceMessagePainter::paintDate( void ServiceMessagePainter::paintDate(
@ -288,8 +292,9 @@ void ServiceMessagePainter::paintDate(
int dateTextWidth, int dateTextWidth,
int y, int y,
int w, int w,
const style::color &bg) { const style::color &bg,
paintPreparedDate(p, dateText, dateTextWidth, y, w, bg); const style::color &fg) {
paintPreparedDate(p, dateText, dateTextWidth, y, w, bg, fg);
} }
void ServiceMessagePainter::paintBubble( void ServiceMessagePainter::paintBubble(

View file

@ -68,20 +68,23 @@ public:
const QDateTime &date, const QDateTime &date,
int y, int y,
int w, int w,
const style::color &bg = st::msgServiceBg); const style::color &bg = st::msgServiceBg,
const style::color &fg = st::msgServiceFg);
static void paintDate( static void paintDate(
Painter &p, Painter &p,
const QString &dateText, const QString &dateText,
int y, int y,
int w, int w,
const style::color &bg = st::msgServiceBg); const style::color &bg = st::msgServiceBg,
const style::color &fg = st::msgServiceFg);
static void paintDate( static void paintDate(
Painter &p, Painter &p,
const QString &dateText, const QString &dateText,
int dateTextWidth, int dateTextWidth,
int y, int y,
int w, int w,
const style::color &bg = st::msgServiceBg); const style::color &bg = st::msgServiceBg,
const style::color &fg = st::msgServiceFg);
static void paintBubble( static void paintBubble(
Painter &p, Painter &p,