diff options
author | Norwegian Rock Cat <qt-info@nokia.com> | 2009-07-13 11:37:23 (GMT) |
---|---|---|
committer | Norwegian Rock Cat <qt-info@nokia.com> | 2009-07-13 11:43:52 (GMT) |
commit | 3af223d89836fbde213aa2f54d775c9cd840f693 (patch) | |
tree | 1debdf8b0beb05187110dfa35e01d207e589ba10 | |
parent | 821c7c1486beb6d5e65bd3ac8ba74752fec37fe8 (diff) | |
download | Qt-3af223d89836fbde213aa2f54d775c9cd840f693.zip Qt-3af223d89836fbde213aa2f54d775c9cd840f693.tar.gz Qt-3af223d89836fbde213aa2f54d775c9cd840f693.tar.bz2 |
Fix font propagation issues with QComboBox and the popup menu.
This has always been a bit bumpy, the problem is that the popup normally
has its own styling from the desktop, plus it's its own top-level and
that is normally a boundary for propagation. Of course, people are
surprised by this (especially when it works for editable). So, we need
to be a bit better propagating the info. Also the QStyleOptionMenuItem
has the correct font, but if it's set on a window, by the time it
reaches the popup, its resolve mask is very weak, so it will fail to
resolve at all. Setting the point size allows the font to have a bit of
strength.
Task-number: 257486
Reviewed-by: Jens Bache-Wiig
-rw-r--r-- | src/gui/styles/qcleanlooksstyle.cpp | 6 | ||||
-rw-r--r-- | src/gui/styles/qmacstyle_mac.mm | 8 | ||||
-rw-r--r-- | src/gui/widgets/qcombobox.cpp | 6 |
3 files changed, 16 insertions, 4 deletions
diff --git a/src/gui/styles/qcleanlooksstyle.cpp b/src/gui/styles/qcleanlooksstyle.cpp index 3855ba7..01f19c6 100644 --- a/src/gui/styles/qcleanlooksstyle.cpp +++ b/src/gui/styles/qcleanlooksstyle.cpp @@ -2042,6 +2042,12 @@ void QCleanlooksStyle::drawControl(ControlElement element, const QStyleOption *o s = s.left(t); } QFont font = menuitem->font; + // font may not have any "hard" flags set. We override + // the point size so that when it is resolved against the device, this font will win. + // This is mainly to handle cases where someone sets the font on the window + // and then the combo inherits it and passes it onward. At that point the resolve mask + // is very, very weak. This makes it stonger. + font.setPointSizeF(menuItem->font.pointSizeF()); if (menuitem->menuItemType == QStyleOptionMenuItem::DefaultItem) font.setBold(true); diff --git a/src/gui/styles/qmacstyle_mac.mm b/src/gui/styles/qmacstyle_mac.mm index b20db5b..c08009b 100644 --- a/src/gui/styles/qmacstyle_mac.mm +++ b/src/gui/styles/qmacstyle_mac.mm @@ -3991,8 +3991,12 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter const int xm = macItemFrame + maxpmw + macItemHMargin; QFont myFont = mi->font; - if (mi->state & QStyle::State_Mini) - myFont.setPointSize(mi->font.pointSize()); + // myFont may not have any "hard" flags set. We override + // the point size so that when it is resolved against the device, this font will win. + // This is mainly to handle cases where someone sets the font on the window + // and then the combo inherits it and passes it onward. At that point the resolve mask + // is very, very weak. This makes it stonger. + myFont.setPointSizeF(mi->font.pointSizeF()); p->setFont(myFont); p->drawText(xpos, yPos, contentRect.width() - xm - tabwidth + 1, contentRect.height(), text_flags ^ Qt::AlignRight, s); diff --git a/src/gui/widgets/qcombobox.cpp b/src/gui/widgets/qcombobox.cpp index 1ca878d..097f3d0 100644 --- a/src/gui/widgets/qcombobox.cpp +++ b/src/gui/widgets/qcombobox.cpp @@ -148,8 +148,10 @@ QStyleOptionMenuItem QComboMenuDelegate::getStyleOption(const QStyleOptionViewIt menuOption.rect = option.rect; // Make sure fonts set on the combo box also overrides the font for the popup menu. - if (mCombo->testAttribute(Qt::WA_SetFont) || mCombo->testAttribute(Qt::WA_MacSmallSize) - || mCombo->testAttribute(Qt::WA_MacMiniSize)) + if (mCombo->testAttribute(Qt::WA_SetFont) + || mCombo->testAttribute(Qt::WA_MacSmallSize) + || mCombo->testAttribute(Qt::WA_MacMiniSize) + || mCombo->font() != qt_app_fonts_hash()->value("QComboBox", QFont())) menuOption.font = mCombo->font(); else menuOption.font = qt_app_fonts_hash()->value("QComboMenuItem", mCombo->font()); |