qt: Fix font family updates (#3746)

* qt: Update the application font if the font family gets changed

* qt: Make sure recent transactions have the correct font family

Introduced because QListView is ignored in GUIUtil::updateFonts, so its base font family doesn't change, hence the recent transactions don't adjust because the painter's font doesn't change.

* Store initial font size
This commit is contained in:
xdustinface 2020-09-29 02:08:39 +02:00
parent cf2da32ffe
commit 69b77765ba
2 changed files with 4 additions and 6 deletions

View File

@ -1296,6 +1296,7 @@ QString fontFamilyToString(FontFamily family)
void setFontFamily(FontFamily family)
{
fontFamily = family;
setApplicationFont();
updateFonts();
}

View File

@ -52,7 +52,7 @@ public:
QRect rectBottomHalf(mainRect.left() + xspace, mainRect.top() + ypad + halfheight + 5, mainRect.width() - xspace, halfheight);
QRect rectBounding;
QColor colorForeground;
QFont fontInitial = painter->font();
qreal initialFontSize = painter->font().pointSizeF();
// Grab model indexes for desired data from TransactionTableModel
QModelIndex indexDate = index.sibling(index.row(), TransactionTableModel::Date);
@ -61,9 +61,7 @@ public:
// Draw first line (with slightly bigger font than the second line will get)
// Content: Date/Time, Optional IS indicator, Amount
QFont font = fontInitial;
font.setPointSizeF(GUIUtil::getScaledFontSize(font.pointSizeF() * 1.17));
painter->setFont(font);
painter->setFont(GUIUtil::getFont(GUIUtil::FontWeight::Normal, false, GUIUtil::getScaledFontSize(initialFontSize * 1.17)));
// Date/Time
colorForeground = qvariant_cast<QColor>(indexDate.data(Qt::ForegroundRole));
QString strDate = indexDate.data(Qt::DisplayRole).toString();
@ -83,8 +81,7 @@ public:
// Draw second line (with the initial font)
// Content: Address/label, Optional Watchonly indicator
fontInitial.setPointSizeF(GUIUtil::getScaledFontSize(fontInitial.pointSizeF()));
painter->setFont(fontInitial);
painter->setFont(GUIUtil::getFont(GUIUtil::FontWeight::Normal, false, GUIUtil::getScaledFontSize(initialFontSize)));
// Address/Label
colorForeground = qvariant_cast<QColor>(indexAddress.data(Qt::ForegroundRole));
QString address = indexAddress.data(Qt::DisplayRole).toString();