diff options
author | Prasanth Ullattil <prasanth.ulattil@nokia.com> | 2009-10-27 09:56:39 (GMT) |
---|---|---|
committer | Prasanth Ullattil <prasanth.ulattil@nokia.com> | 2009-10-27 09:56:39 (GMT) |
commit | 3bc088fad760bd50eec05b323a056641247a9a59 (patch) | |
tree | 7e8ea3eba5d282891a013c6a14c3ac19aa650427 /src/gui/widgets | |
parent | 5393f71b9ac66395258713d1703e5c7f23aba206 (diff) | |
download | Qt-3bc088fad760bd50eec05b323a056641247a9a59.zip Qt-3bc088fad760bd50eec05b323a056641247a9a59.tar.gz Qt-3bc088fad760bd50eec05b323a056641247a9a59.tar.bz2 |
QTabbar is not behaving (painting) like native ones on Mac.
When a tab is clicked and mouse is moved outside that tab, it should
be drawn as normal (not in sunken state).
Reviewed-by: MortenS
Diffstat (limited to 'src/gui/widgets')
-rw-r--r-- | src/gui/widgets/qtabbar.cpp | 18 | ||||
-rw-r--r-- | src/gui/widgets/qtabbar_p.h | 10 |
2 files changed, 25 insertions, 3 deletions
diff --git a/src/gui/widgets/qtabbar.cpp b/src/gui/widgets/qtabbar.cpp index 6c9761c..4dffbdc 100644 --- a/src/gui/widgets/qtabbar.cpp +++ b/src/gui/widgets/qtabbar.cpp @@ -1694,6 +1694,9 @@ void QTabBar::mousePressEvent(QMouseEvent *event) d->moveTabFinished(d->pressedIndex); d->pressedIndex = d->indexAtPos(event->pos()); +#ifdef Q_WS_MAC + d->previousPressedIndex = d->pressedIndex; +#endif if (d->validIndex(d->pressedIndex)) { QStyleOptionTabBarBaseV2 optTabBase; optTabBase.init(this); @@ -1774,6 +1777,17 @@ void QTabBar::mouseMoveEvent(QMouseEvent *event) update(); } +#ifdef Q_WS_MAC + } else if (!d->documentMode && event->buttons() == Qt::LeftButton && d->previousPressedIndex != -1) { + int newPressedIndex = d->indexAtPos(event->pos()); + if (d->pressedIndex == -1 && d->previousPressedIndex == newPressedIndex) { + d->pressedIndex = d->previousPressedIndex; + update(tabRect(d->pressedIndex)); + } else if(d->pressedIndex != newPressedIndex) { + d->pressedIndex = -1; + update(tabRect(d->previousPressedIndex)); + } +#endif } if (event->buttons() != Qt::LeftButton) { @@ -1865,7 +1879,9 @@ void QTabBar::mouseReleaseEvent(QMouseEvent *event) event->ignore(); return; } - +#ifdef Q_WS_MAC + d->previousPressedIndex = -1; +#endif if (d->movable && d->dragInProgress && d->validIndex(d->pressedIndex)) { int length = d->tabList[d->pressedIndex].dragOffset; int width = verticalTabs(d->shape) diff --git a/src/gui/widgets/qtabbar_p.h b/src/gui/widgets/qtabbar_p.h index 494a340..9f3285b 100644 --- a/src/gui/widgets/qtabbar_p.h +++ b/src/gui/widgets/qtabbar_p.h @@ -77,7 +77,11 @@ public: :currentIndex(-1), pressedIndex(-1), shape(QTabBar::RoundedNorth), layoutDirty(false), drawBase(true), scrollOffset(0), expanding(true), closeButtonOnTabs(false), selectionBehaviorOnRemove(QTabBar::SelectRightTab), paintWithOffsets(true), movable(false), - dragInProgress(false), documentMode(false), movingTab(0) {} + dragInProgress(false), documentMode(false), movingTab(0) +#ifdef Q_WS_MAC + , previousPressedIndex(-1) +#endif + {} int currentIndex; int pressedIndex; @@ -195,7 +199,9 @@ public: bool documentMode; QWidget *movingTab; - +#ifdef Q_WS_MAC + int previousPressedIndex; +#endif // shared by tabwidget and qtabbar static void initStyleBaseOption(QStyleOptionTabBarBaseV2 *optTabBase, QTabBar *tabbar, QSize size) { |