summaryrefslogtreecommitdiffstats
path: root/src/gui/widgets/qpushbutton.cpp
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2010-05-20 16:12:25 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2010-05-20 16:12:25 (GMT)
commit372af5d18bb85c41ce336f2bbf72b44646d8a79f (patch)
tree06c487f426fee92cf01eb8c1601ce44f99ee79ba /src/gui/widgets/qpushbutton.cpp
parentdfc61f6b59886f7d223722bf149342cdd46581a8 (diff)
parent83245ed872b6265d872a8ab0235c9dbd1f2daf4b (diff)
downloadQt-372af5d18bb85c41ce336f2bbf72b44646d8a79f.zip
Qt-372af5d18bb85c41ce336f2bbf72b44646d8a79f.tar.gz
Qt-372af5d18bb85c41ce336f2bbf72b44646d8a79f.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-1 into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-1: Removed a change from the 4.7.0 change log. Improve look and feel of itemviews on mac doc: Fixed many broken links. doc: Fixed many broken links. update 4.7.0 changes QPushButton's click area exceeds the button area by far on Mac OS X QApplication::closeAllWindows() should ignore windows being closed Examples: Fix compilation with namespace. Use QApplication::arguments() to check for command line args Added support for .rc files on VS2010. Doc: Updating CSS and JS Docs: added an intro for qml, Quick for Beginners. Fix crash on exit in native wifi plugin on Vista+ when run in debugger.
Diffstat (limited to 'src/gui/widgets/qpushbutton.cpp')
-rw-r--r--src/gui/widgets/qpushbutton.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/gui/widgets/qpushbutton.cpp b/src/gui/widgets/qpushbutton.cpp
index 1a9adcc..7b8c0db 100644
--- a/src/gui/widgets/qpushbutton.cpp
+++ b/src/gui/widgets/qpushbutton.cpp
@@ -58,6 +58,9 @@
#include "qdebug.h"
#include "qlayoutitem.h"
#include "qdialogbuttonbox.h"
+#ifdef Q_WS_MAC
+#include "qmacstyle_mac.h"
+#endif // Q_WS_MAC
#ifndef QT_NO_ACCESSIBILITY
#include "qaccessible.h"
@@ -679,6 +682,37 @@ bool QPushButton::event(QEvent *e)
return QAbstractButton::event(e);
}
+#ifdef Q_WS_MAC
+/*! \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))
+ 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);
+ // In OSX buttons are round, which causes the hit method to be special.
+ // We cannot simply relay on detecting if something is inside the rect or not,
+ // we need to check if it is inside the "rounded area" or not. A point might
+ // be inside the rect but not inside the rounded area.
+ // Notice this method is only reimplemented for OSX.
+ return nonConst->hitButton(pos);
+}
+
+bool QPushButtonPrivate::hitButton(const QPoint &pos)
+{
+ Q_Q(QPushButton);
+ QRect roundedRect(q->rect().left() + QMacStyle::PushButtonLeftOffset,
+ q->rect().top() + QMacStyle::PushButtonContentPadding,
+ q->rect().width() - QMacStyle::PushButtonRightOffset,
+ q->rect().height() - QMacStyle::PushButtonBottomOffset);
+ return roundedRect.contains(pos);
+}
+#endif // Q_WS_MAC
+
#ifdef QT3_SUPPORT
/*!
Use one of the constructors that doesn't take the \a name