summaryrefslogtreecommitdiffstats
path: root/src/gui/widgets/qmainwindowlayout.cpp
diff options
context:
space:
mode:
authorThierry Bastian <thierry.bastian@nokia.com>2009-07-08 14:34:55 (GMT)
committerThierry Bastian <thierry.bastian@nokia.com>2009-07-08 14:47:58 (GMT)
commitc2f2b6509fcd91617ae3eb860d6d3f947c5ea443 (patch)
treed0a50618d1f937cc3655ba92f699cf928dbbe96e /src/gui/widgets/qmainwindowlayout.cpp
parentc02a9925f10fbf1a4883983f35c735666862a3f6 (diff)
downloadQt-c2f2b6509fcd91617ae3eb860d6d3f947c5ea443.zip
Qt-c2f2b6509fcd91617ae3eb860d6d3f947c5ea443.tar.gz
Qt-c2f2b6509fcd91617ae3eb860d6d3f947c5ea443.tar.bz2
QMainWindow: fix the use of animation and improve code quality
Diffstat (limited to 'src/gui/widgets/qmainwindowlayout.cpp')
-rw-r--r--src/gui/widgets/qmainwindowlayout.cpp33
1 files changed, 17 insertions, 16 deletions
diff --git a/src/gui/widgets/qmainwindowlayout.cpp b/src/gui/widgets/qmainwindowlayout.cpp
index 8fb7c4f..aba9120 100644
--- a/src/gui/widgets/qmainwindowlayout.cpp
+++ b/src/gui/widgets/qmainwindowlayout.cpp
@@ -1527,24 +1527,20 @@ bool QMainWindowLayout::plug(QLayoutItem *widgetItem)
layoutState.remove(previousPath);
pluggingWidget = widget;
- if (dockOptions & QMainWindow::AnimatedDocks) {
- QRect globalRect = currentGapRect;
- globalRect.moveTopLeft(parentWidget()->mapToGlobal(globalRect.topLeft()));
+ QRect globalRect = currentGapRect;
+ globalRect.moveTopLeft(parentWidget()->mapToGlobal(globalRect.topLeft()));
#ifndef QT_NO_DOCKWIDGET
- if (qobject_cast<QDockWidget*>(widget) != 0) {
- QDockWidgetLayout *layout = qobject_cast<QDockWidgetLayout*>(widget->layout());
- if (layout->nativeWindowDeco()) {
- globalRect.adjust(0, layout->titleHeight(), 0, 0);
- } else {
- int fw = widget->style()->pixelMetric(QStyle::PM_DockWidgetFrameWidth, 0, widget);
- globalRect.adjust(-fw, -fw, fw, fw);
- }
+ if (qobject_cast<QDockWidget*>(widget) != 0) {
+ QDockWidgetLayout *layout = qobject_cast<QDockWidgetLayout*>(widget->layout());
+ if (layout->nativeWindowDeco()) {
+ globalRect.adjust(0, layout->titleHeight(), 0, 0);
+ } else {
+ int fw = widget->style()->pixelMetric(QStyle::PM_DockWidgetFrameWidth, 0, widget);
+ globalRect.adjust(-fw, -fw, fw, fw);
}
-#endif
- widgetAnimator.animate(widget, globalRect, true);
- } else {
- animationFinished(widget);
}
+#endif
+ widgetAnimator.animate(widget, globalRect, dockOptions & QMainWindow::AnimatedDocks);
return true;
}
@@ -1576,9 +1572,11 @@ void QMainWindowLayout::animationFinished(QWidget *widget)
tb->d_func()->plug(currentGapRect);
#endif
- applyState(layoutState, false);
#ifndef QT_NO_DOCKWIDGET
#ifndef QT_NO_TABBAR
+ //it is important to set the current tab before applying the layout
+ //so that applyState will not try to counter the result of the animation
+ //by putting the item in negative space
if (qobject_cast<QDockWidget*>(widget) != 0) {
// info() might return null if the widget is destroyed while
// animating but before the animationFinished signal is received.
@@ -1587,6 +1585,9 @@ void QMainWindowLayout::animationFinished(QWidget *widget)
}
#endif
#endif
+
+ applyState(layoutState, false);
+
savedState.clear();
currentGapPos.clear();
pluggingWidget = 0;