Skip to content

Commit

Permalink
Fix font weight on Qt6 (#1124)
Browse files Browse the repository at this point in the history
Qt6 has different weight mapping from Qt5. It scales from 1 to 1000.
https://doc.qt.io/qt-6/qfont.html#Weight-enum
  • Loading branch information
pastalian authored Aug 17, 2024
1 parent 543dfcd commit 296748c
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/gui/shellwidget/shellwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@
#include "compat_shellwidget.h"
#include "helpers.h"

#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
constexpr int c_qtWeightMin{ 0 };
constexpr int c_qtWeightMax{ 99 };
#else
constexpr int c_qtWeightMin{ 1 };
constexpr int c_qtWeightMax{ 1000 };
#endif

ShellWidget::ShellWidget(QWidget* parent)
: QWidget(parent)
{
Expand Down Expand Up @@ -1042,7 +1050,7 @@ QVariant ShellWidget::TryGetQFontFromDescription(const QString& fdesc) const noe
weight = QFont::DemiBold;
} else if (attr.length() > 0 && attr.at(0) == 'w') {
weight = rightString(attr, attr.length() - 1).toInt();
if (weight < 0 || weight > 99) {
if (weight < c_qtWeightMin || weight > c_qtWeightMax) {
return QStringLiteral("Invalid font weight");
}
} else if (attr == "i") {
Expand Down

0 comments on commit 296748c

Please sign in to comment.