diff options
author | Bradley T. Hughes <bradley.hughes@nokia.com> | 2009-10-30 13:39:48 (GMT) |
---|---|---|
committer | Bradley T. Hughes <bradley.hughes@nokia.com> | 2009-10-30 13:39:48 (GMT) |
commit | 6a907f37d698eadc9cc35712b9cda48ba19e634d (patch) | |
tree | d1df866f6a19901f5fe0431e5609cfc2d02484a9 /src/gui/widgets | |
parent | 8097fa53b5e0e6228bd5737de6de8cd77c04dddf (diff) | |
parent | 8c4edbd04f350294462fd689748de2dd7cc84d47 (diff) | |
download | Qt-6a907f37d698eadc9cc35712b9cda48ba19e634d.zip Qt-6a907f37d698eadc9cc35712b9cda48ba19e634d.tar.gz Qt-6a907f37d698eadc9cc35712b9cda48ba19e634d.tar.bz2 |
Merge commit '8c4edbd04f350294462fd689748de2dd7cc84d47' into 4.6-upstream
Diffstat (limited to 'src/gui/widgets')
-rw-r--r-- | src/gui/widgets/qtabbar.cpp | 19 | ||||
-rw-r--r-- | src/gui/widgets/qtabbar_p.h | 10 | ||||
-rw-r--r-- | src/gui/widgets/qtabwidget.cpp | 16 |
3 files changed, 39 insertions, 6 deletions
diff --git a/src/gui/widgets/qtabbar.cpp b/src/gui/widgets/qtabbar.cpp index 6c9761c..3935c55 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) { @@ -1798,6 +1812,7 @@ void QTabBarPrivate::setupMovableTab() QPixmap grabImage(grabRect.size()); grabImage.fill(Qt::transparent); QStylePainter p(&grabImage, q); + p.initFrom(q); QStyleOptionTabV3 tab; q->initStyleOption(&tab, pressedIndex); @@ -1865,7 +1880,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) { diff --git a/src/gui/widgets/qtabwidget.cpp b/src/gui/widgets/qtabwidget.cpp index 9aeb033..d22bd54 100644 --- a/src/gui/widgets/qtabwidget.cpp +++ b/src/gui/widgets/qtabwidget.cpp @@ -313,7 +313,16 @@ void QTabWidget::initStyleOption(QStyleOptionTabWidgetFrame *option) const : QTabBar::TriangularEast; break; } + option->tabBarSize = t; + + if (QStyleOptionTabWidgetFrameV2 *tabframe = qstyleoption_cast<QStyleOptionTabWidgetFrameV2*>(option)) { + QRect tbRect = tabBar()->geometry(); + QRect selectedTabRect = tabBar()->tabRect(tabBar()->currentIndex()); + tabframe->tabBarRect = tbRect; + selectedTabRect.moveTopLeft(selectedTabRect.topLeft() + tbRect.topLeft()); + tabframe->selectedTabRect = selectedTabRect; + } } /*! @@ -756,7 +765,7 @@ void QTabWidget::setUpLayout(bool onlyCheck) if (onlyCheck && !d->dirty) return; // nothing to do - QStyleOptionTabWidgetFrame option; + QStyleOptionTabWidgetFrameV2 option; initStyleOption(&option); // this must be done immediately, because QWidgetItem relies on it (even if !isVisible()) @@ -1167,8 +1176,8 @@ void QTabWidget::tabRemoved(int index) void QTabWidget::paintEvent(QPaintEvent *) { Q_D(QTabWidget); - QStylePainter p(this); if (documentMode()) { + QStylePainter p(this, tabBar()); if (QWidget *w = cornerWidget(Qt::TopLeftCorner)) { QStyleOptionTabBarBaseV2 opt; QTabBarPrivate::initStyleBaseOption(&opt, tabBar(), w->size()); @@ -1185,8 +1194,9 @@ void QTabWidget::paintEvent(QPaintEvent *) } return; } + QStylePainter p(this); - QStyleOptionTabWidgetFrame opt; + QStyleOptionTabWidgetFrameV2 opt; initStyleOption(&opt); opt.rect = d->panelRect; p.drawPrimitive(QStyle::PE_FrameTabWidget, opt); |