From a006ede6e785b288d6955490217a6da46e62a7b5 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Tue, 29 Apr 2014 19:29:59 +0200 Subject: Mac style: Get proper ThemeButtonKind for QDateTimeEdit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When it gets 'calendarPopup' set, that is. The reason lies, indirectly, in the extra margins we add to QComboBoxes and other QPushButtons in the Mac style. However, these extra margins do not apply to spinboxes, which is what QDateTimeEdit is. In particular, this causes Designer to show QDateTimeEdit at the wrong size when it's not in a layout. Task-number: QTBUG-38615 Change-Id: I3dd52e10db8c8970a6dc40b39fbe29dd86167daa Reviewed-by: Jake Petroules Reviewed-by: J-P Nurmi Reviewed-by: Morten Johan Sørvig --- src/widgets/styles/qmacstyle_mac.mm | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/styles/qmacstyle_mac.mm b/src/widgets/styles/qmacstyle_mac.mm index d35dd16f85..42262e66a9 100644 --- a/src/widgets/styles/qmacstyle_mac.mm +++ b/src/widgets/styles/qmacstyle_mac.mm @@ -1345,12 +1345,30 @@ void QMacStylePrivate::initComboboxBdi(const QStyleOptionComboBox *combo, HIThem // an extra check here before using the mini and small buttons. int h = combo->rect.size().height(); if (combo->editable){ - if (h < 21) - bdi->kind = kThemeComboBoxMini; - else if (h < 26) - bdi->kind = kThemeComboBoxSmall; - else - bdi->kind = kThemeComboBox; + if (qobject_cast(widget)) { + // Except when, you know, we get a QDateTimeEdit with calendarPopup + // enabled. And then things get weird, basically because it's a + // transvestite spinbox with editable combobox tendencies. Meaning + // that it wants to look a combobox, except that it isn't one, so it + // doesn't get all those extra free margins around. (Don't know whose + // idea those margins were, but now it looks like we're stuck with + // them forever). So anyway, the height threshold should be smaller + // in this case, or the style gets confused when it needs to render + // or return any subcontrol size of the poor thing. + if (h < 9) + bdi->kind = kThemeComboBoxMini; + else if (h < 22) + bdi->kind = kThemeComboBoxSmall; + else + bdi->kind = kThemeComboBox; + } else { + if (h < 21) + bdi->kind = kThemeComboBoxMini; + else if (h < 26) + bdi->kind = kThemeComboBoxSmall; + else + bdi->kind = kThemeComboBox; + } } else { // Even if we specify that we want the kThemePopupButton, Carbon // will use the kThemePopupButtonSmall if the size matches. So we -- cgit v1.2.3