From 0985a557a97d474b29f36a4a44168c61c3f7ddb5 Mon Sep 17 00:00:00 2001 From: xdustinface Date: Tue, 29 Sep 2020 02:03:57 +0200 Subject: [PATCH 1/3] qt: Update the application font if the font family gets changed --- src/qt/guiutil.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/qt/guiutil.cpp b/src/qt/guiutil.cpp index 8569712e2478c..ca10a73b073ef 100644 --- a/src/qt/guiutil.cpp +++ b/src/qt/guiutil.cpp @@ -1267,6 +1267,7 @@ QString fontFamilyToString(FontFamily family) void setFontFamily(FontFamily family) { fontFamily = family; + setApplicationFont(); updateFonts(); } From 824281e8b30fc2b4e5583b3270632f57d3584071 Mon Sep 17 00:00:00 2001 From: xdustinface Date: Tue, 29 Sep 2020 02:32:36 +0200 Subject: [PATCH 2/3] 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. --- src/qt/overviewpage.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/qt/overviewpage.cpp b/src/qt/overviewpage.cpp index 3ed36782d4302..adb35b216bcbd 100644 --- a/src/qt/overviewpage.cpp +++ b/src/qt/overviewpage.cpp @@ -52,7 +52,6 @@ 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(); // Grab model indexes for desired data from TransactionTableModel QModelIndex indexDate = index.sibling(index.row(), TransactionTableModel::Date); @@ -61,9 +60,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(painter->font().pointSizeF() * 1.17))); // Date/Time colorForeground = qvariant_cast(indexDate.data(Qt::ForegroundRole)); QString strDate = indexDate.data(Qt::DisplayRole).toString(); @@ -83,8 +80,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(painter->font().pointSizeF()))); // Address/Label colorForeground = qvariant_cast(indexAddress.data(Qt::ForegroundRole)); QString address = indexAddress.data(Qt::DisplayRole).toString(); From 43eeca1383edfa07a4e945bd09a747d266ac0f49 Mon Sep 17 00:00:00 2001 From: UdjinM6 Date: Tue, 29 Sep 2020 03:48:22 +0300 Subject: [PATCH 3/3] Store initial font size --- src/qt/overviewpage.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/qt/overviewpage.cpp b/src/qt/overviewpage.cpp index adb35b216bcbd..f1ef8b128028f 100644 --- a/src/qt/overviewpage.cpp +++ b/src/qt/overviewpage.cpp @@ -52,6 +52,7 @@ class TxViewDelegate : public QAbstractItemDelegate QRect rectBottomHalf(mainRect.left() + xspace, mainRect.top() + ypad + halfheight + 5, mainRect.width() - xspace, halfheight); QRect rectBounding; QColor colorForeground; + qreal initialFontSize = painter->font().pointSizeF(); // Grab model indexes for desired data from TransactionTableModel QModelIndex indexDate = index.sibling(index.row(), TransactionTableModel::Date); @@ -60,7 +61,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 - painter->setFont(GUIUtil::getFont(GUIUtil::FontWeight::Normal, false, GUIUtil::getScaledFontSize(painter->font().pointSizeF() * 1.17))); + painter->setFont(GUIUtil::getFont(GUIUtil::FontWeight::Normal, false, GUIUtil::getScaledFontSize(initialFontSize * 1.17))); // Date/Time colorForeground = qvariant_cast(indexDate.data(Qt::ForegroundRole)); QString strDate = indexDate.data(Qt::DisplayRole).toString(); @@ -80,7 +81,7 @@ class TxViewDelegate : public QAbstractItemDelegate // Draw second line (with the initial font) // Content: Address/label, Optional Watchonly indicator - painter->setFont(GUIUtil::getFont(GUIUtil::FontWeight::Normal, false, GUIUtil::getScaledFontSize(painter->font().pointSizeF()))); + painter->setFont(GUIUtil::getFont(GUIUtil::FontWeight::Normal, false, GUIUtil::getScaledFontSize(initialFontSize))); // Address/Label colorForeground = qvariant_cast(indexAddress.data(Qt::ForegroundRole)); QString address = indexAddress.data(Qt::DisplayRole).toString();