summaryrefslogtreecommitdiffstats
path: root/src/widgets
diff options
context:
space:
mode:
authorGabriel de Dietrich <gabriel.dedietrich@digia.com>2014-04-29 19:29:59 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-05-02 17:36:45 +0200
commita006ede6e785b288d6955490217a6da46e62a7b5 (patch)
treeefd479209deb19cede99d03606c18a08206b015d /src/widgets
parent721543e46484524f509e21e6bfe483e5b57bc4be (diff)
Mac style: Get proper ThemeButtonKind for QDateTimeEdit
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 <jake.petroules@petroules.com> Reviewed-by: J-P Nurmi <jpnurmi@digia.com> Reviewed-by: Morten Johan Sørvig <morten.sorvig@digia.com>
Diffstat (limited to 'src/widgets')
-rw-r--r--src/widgets/styles/qmacstyle_mac.mm30
1 files changed, 24 insertions, 6 deletions
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<const QDateTimeEdit *>(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