From 60be2fb6a13315f074c3c0b7793c38632f291e8b Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Tue, 28 Feb 2017 16:03:30 +0100 Subject: QMainWindow: move the separator handling in another class MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit So it will be re-used by QDockWidgetGroupWindow The Layout template argument can be the QMainWindowLayout, or the QDockWidgetGroupLayout. They have a function dockAreaLayoutInfo which return a QDockAreaLayout* or a QDockAreaLayoutInfo*, respectively. These two class have the same interface as far as QMainWindowLayoutSeparatorHelper is concerned. (QDockAreaLayout forward most of its call to the relevant QDockAreaLayoutInfo) The code is mostly moved without modification, but there is a change in startSeparatorMove, because we don't have access to the layoutState to set the fallbackToSizeHints variable, so instead, we do that from QMainWindowLayout::hover. Change-Id: Ic5fa3ee2def3d0155195f751d4770b207732139f Reviewed-by: Sérgio Martins --- src/widgets/widgets/qmainwindowlayout.cpp | 58 +------------------------------ 1 file changed, 1 insertion(+), 57 deletions(-) (limited to 'src/widgets/widgets/qmainwindowlayout.cpp') diff --git a/src/widgets/widgets/qmainwindowlayout.cpp b/src/widgets/widgets/qmainwindowlayout.cpp index 98421588a7..30217733cf 100644 --- a/src/widgets/widgets/qmainwindowlayout.cpp +++ b/src/widgets/widgets/qmainwindowlayout.cpp @@ -1689,39 +1689,6 @@ void QMainWindowLayout::tabMoved(int from, int to) } #endif // QT_NO_TABBAR -bool QMainWindowLayout::startSeparatorMove(const QPoint &pos) -{ - movingSeparator = layoutState.dockAreaLayout.findSeparator(pos); - - if (movingSeparator.isEmpty()) - return false; - - layoutState.dockAreaLayout.fallbackToSizeHints = false; - - savedState = layoutState; - movingSeparatorPos = movingSeparatorOrigin = pos; - - return true; -} - -bool QMainWindowLayout::separatorMove(const QPoint &pos) -{ - if (movingSeparator.isEmpty()) - return false; - movingSeparatorPos = pos; - separatorMoveTimer.start(0, this); - return true; -} - -bool QMainWindowLayout::endSeparatorMove(const QPoint&) -{ - if (movingSeparator.isEmpty()) - return false; - movingSeparator.clear(); - savedState.clear(); - return true; -} - void QMainWindowLayout::raise(QDockWidget *widget) { #ifndef QT_NO_TABBAR @@ -2424,6 +2391,7 @@ void QMainWindowLayout::hover(QLayoutItem *widgetItem, const QPoint &mousePos) } } setCurrentHoveredFloat(nullptr); + layoutState.dockAreaLayout.fallbackToSizeHints = false; #endif //QT_NO_DOCKWIDGET QPoint pos = parentWidget()->mapFromGlobal(mousePos); @@ -2575,30 +2543,6 @@ bool QMainWindowLayout::restoreState(QDataStream &stream) return true; } -void QMainWindowLayout::timerEvent(QTimerEvent *e) -{ -#ifndef QT_NO_DOCKWIDGET - if (e->timerId() == separatorMoveTimer.timerId()) { - //let's move the separators - separatorMoveTimer.stop(); - if (movingSeparator.isEmpty()) - return; - if (movingSeparatorOrigin == movingSeparatorPos) - return; - - //when moving the separator, we need to update the previous position - parentWidget()->update(layoutState.dockAreaLayout.separatorRegion()); - - layoutState = savedState; - layoutState.dockAreaLayout.separatorMove(movingSeparator, movingSeparatorOrigin, - movingSeparatorPos); - movingSeparatorPos = movingSeparatorOrigin; - } -#endif - QLayout::timerEvent(e); -} - - QT_END_NAMESPACE #include "moc_qmainwindowlayout_p.cpp" -- cgit v1.2.3