Skip to content

Commit

Permalink
qt: Fix font family updates (dashpay#3746)
Browse files Browse the repository at this point in the history
* 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

Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
  • Loading branch information
2 people authored and gades committed Mar 10, 2022
1 parent 5929f31 commit c5cb4f6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/qt/guiutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1274,6 +1274,7 @@ QString fontFamilyToString(FontFamily family)
void setFontFamily(FontFamily family)
{
fontFamily = family;
setApplicationFont();
updateFonts();
}

Expand Down
9 changes: 3 additions & 6 deletions src/qt/overviewpage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class TxViewDelegate : public QAbstractItemDelegate
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);
Expand All @@ -63,9 +63,7 @@ class TxViewDelegate : public QAbstractItemDelegate

// 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();
Expand All @@ -85,8 +83,7 @@ class TxViewDelegate : public QAbstractItemDelegate

// 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();
Expand Down

0 comments on commit c5cb4f6

Please sign in to comment.