kdelibs/kdeui
Dominik Haumann
dhdev at gmx.de
Thu Mar 3 19:47:46 CET 2005
CVS commit by dhaumann:
fix: keep the right size when redock undocked widgets.
Tested with: mainly k3b and some other apps.
Now I can drag/drop/undock/dock widgets and the size is always correct.
PS: There is a huge bug with highResolution, which has effects here. I
have fixed that locally here as well. So very probably a patch follows :)
CCMAIL:kmdi-devel at kde.org
M +44 -7 kdockwidget.cpp 1.170
--- kdelibs/kdeui/kdockwidget.cpp #1.169:1.170
@@ -2022,15 +2022,52 @@ void KDockManager::drop()
}
else {
+ // curPos is the current target DockPosition.
+ // currentDragWidget->prevSideDockPosBeforeDrag is where the dockwidget comes from.
+ // currentDragWidget->formerDockPos is the position *before* the dockwidget was in
+ // position currentDragWidget->prevSideDockPosBeforeDrag.
int splitPos = currentDragWidget->d->splitPosInPercent;
- // do we have to calculate 100%-splitPosInPercent?
- if( (curPos != currentDragWidget->prevSideDockPosBeforeDrag) && (curPos != KDockWidget::DockCenter) && (curPos != KDockWidget::DockDesktop)) {
- switch( currentDragWidget->prevSideDockPosBeforeDrag) {
- case KDockWidget::DockLeft: if(curPos != KDockWidget::DockTop) splitPos = 100-splitPos; break;
- case KDockWidget::DockRight: if(curPos != KDockWidget::DockBottom) splitPos = 100-splitPos; break;
- case KDockWidget::DockTop: if(curPos != KDockWidget::DockLeft) splitPos = 100-splitPos; break;
- case KDockWidget::DockBottom: if(curPos != KDockWidget::DockRight) splitPos = 100-splitPos; break;
+ KDockWidget::DockPosition previousPosition = currentDragWidget->prevSideDockPosBeforeDrag;
+
+// kdDebug() << splitPos << endl;
+// kdDebug() << "curPos: " << curPos << endl;
+// kdDebug() << "formerDockPos: " << currentDragWidget->formerDockPos<< endl;
+// kdDebug() << "prevSideDockPosBeforeDrag: " << currentDragWidget->prevSideDockPosBeforeDrag<< endl;
+
+ // Now we *need* to "invert" the procentual value, if the dockwidget moves from top/left
+ // to bottom/right or vice versa. This keeps the dockwidget's size on its new position.
+ // A special case is, when the dock position was DockNone, then we have to look for the
+ // formerDockPos to get things right.
+ if( (curPos != previousPosition)
+ && (curPos != KDockWidget::DockCenter) && (curPos != KDockWidget::DockDesktop)) {
+
+ if (previousPosition == KDockWidget::DockNone)
+ previousPosition = currentDragWidget->formerDockPos;
+
+ switch( previousPosition ) {
+ case KDockWidget::DockLeft:
+ if(curPos != KDockWidget::DockTop && curPos != KDockWidget::DockLeft)
+ splitPos = 100 - splitPos;
+ break;
+
+ case KDockWidget::DockRight:
+ if(curPos != KDockWidget::DockBottom && curPos != KDockWidget::DockRight)
+ splitPos = 100 - splitPos;
+ break;
+
+ case KDockWidget::DockTop:
+ if(curPos != KDockWidget::DockLeft && curPos != KDockWidget::DockTop )
+ splitPos = 100 - splitPos;
+ break;
+
+ case KDockWidget::DockBottom:
+ if(curPos != KDockWidget::DockRight && curPos != KDockWidget::DockBottom )
+ splitPos = 100 - splitPos;
+ break;
+
default: break;
}
}
+ // set new prevSideDockPosBeforeDrag
+ currentDragWidget->prevSideDockPosBeforeDrag = curPos;
currentDragWidget->manualDock( currentMoveWidget, curPos , splitPos, QCursor::pos() - d->dragOffset );
currentDragWidget->makeDockVisible();
More information about the Kmdi-devel
mailing list