summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Moe Gustavsen <richard.gustavsen@nokia.com>2010-08-03 12:22:40 (GMT)
committerRichard Moe Gustavsen <richard.gustavsen@nokia.com>2010-08-04 07:38:36 (GMT)
commitb0965cd049997283976c132fceb9727b6582ca49 (patch)
treeb2524df6e9bb6cd0d1b5e58d3c026f9417cced3b
parent0b736b21b5acd2cd412f70b7aa5902e0aa091dfc (diff)
downloadQt-b0965cd049997283976c132fceb9727b6582ca49.zip
Qt-b0965cd049997283976c132fceb9727b6582ca49.tar.gz
Qt-b0965cd049997283976c132fceb9727b6582ca49.tar.bz2
Mac: fix regression from 65a673f that makes some buttons unclickable
If a button has a small gemoetry, the mac style will reender it as flat. Change 65a673f did not take this logic into account when massaging the hit rect of the button. This patch will. Task-number: QTBUG-10401 Reviewed-by: cduclos
-rw-r--r--src/gui/styles/qmacstyle_mac.h4
-rw-r--r--src/gui/styles/qmacstyle_mac.mm10
-rw-r--r--src/gui/styles/qmacstyle_mac_p.h2
-rw-r--r--src/gui/widgets/qpushbutton.cpp8
4 files changed, 20 insertions, 4 deletions
diff --git a/src/gui/styles/qmacstyle_mac.h b/src/gui/styles/qmacstyle_mac.h
index bcebb1d..d5fcdae 100644
--- a/src/gui/styles/qmacstyle_mac.h
+++ b/src/gui/styles/qmacstyle_mac.h
@@ -60,6 +60,8 @@ class QPalette;
#define Q_GUI_EXPORT_STYLE_MAC Q_GUI_EXPORT
#endif
+class QPushButton;
+class QStyleOptionButton;
class QMacStylePrivate;
class Q_GUI_EXPORT_STYLE_MAC QMacStyle : public QWindowsStyle
{
@@ -133,6 +135,8 @@ private:
Q_DISABLE_COPY(QMacStyle)
QMacStylePrivate *d;
+
+ friend bool qt_mac_buttonIsRenderedFlat(const QPushButton *pushButton, const QStyleOptionButton *option);
};
#endif // Q_WS_MAC
diff --git a/src/gui/styles/qmacstyle_mac.mm b/src/gui/styles/qmacstyle_mac.mm
index d18383c..ae90d26 100644
--- a/src/gui/styles/qmacstyle_mac.mm
+++ b/src/gui/styles/qmacstyle_mac.mm
@@ -1059,6 +1059,16 @@ void QMacStylePrivate::initHIThemePushButton(const QStyleOptionButton *btn,
}
}
+bool qt_mac_buttonIsRenderedFlat(const QPushButton *pushButton, const QStyleOptionButton *option)
+{
+ QMacStyle *macStyle = qobject_cast<QMacStyle *>(pushButton->style());
+ if (!macStyle)
+ return false;
+ HIThemeButtonDrawInfo bdi;
+ macStyle->d->initHIThemePushButton(option, pushButton, kThemeStateActive, &bdi);
+ return bdi.kind == kThemeBevelButton;
+}
+
/**
Creates a HIThemeButtonDrawInfo structure that specifies the correct button
kind and other details to use for drawing the given combobox. Which button
diff --git a/src/gui/styles/qmacstyle_mac_p.h b/src/gui/styles/qmacstyle_mac_p.h
index 5a0ba4c..f9b9d30 100644
--- a/src/gui/styles/qmacstyle_mac_p.h
+++ b/src/gui/styles/qmacstyle_mac_p.h
@@ -150,6 +150,8 @@ enum QAquaWidgetSize { QAquaSizeLarge = 0, QAquaSizeSmall = 1, QAquaSizeMini = 2
return sizes[controlSize]; \
} while (0)
+bool qt_mac_buttonIsRenderedFlat(const QPushButton *pushButton, const QStyleOptionButton *option);
+
class QMacStylePrivate : public QObject
{
Q_OBJECT
diff --git a/src/gui/widgets/qpushbutton.cpp b/src/gui/widgets/qpushbutton.cpp
index 8a18ed0..237c266 100644
--- a/src/gui/widgets/qpushbutton.cpp
+++ b/src/gui/widgets/qpushbutton.cpp
@@ -687,11 +687,11 @@ bool QPushButton::event(QEvent *e)
/*! \reimp */
bool QPushButton::hitButton(const QPoint &pos) const
{
- // This is only required if we are using the native style, so check that first.
- QMacStyle *macStyle = qobject_cast<QMacStyle *>(style());
- // If this is a flat button we just bail out.
- if(isFlat() || (0 == macStyle))
+ QStyleOptionButton opt;
+ initStyleOption(&opt);
+ if (qt_mac_buttonIsRenderedFlat(this, &opt))
return QAbstractButton::hitButton(pos);
+
// Now that we know we are using the native style, let's proceed.
Q_D(const QPushButton);
QPushButtonPrivate *nonConst = const_cast<QPushButtonPrivate *>(d);