diff options
author | Olivier Goffart <ogoffart@woboq.com> | 2017-02-28 16:03:30 +0100 |
---|---|---|
committer | Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com> | 2017-04-13 17:44:33 +0000 |
commit | 60be2fb6a13315f074c3c0b7793c38632f291e8b (patch) | |
tree | 08abce1c5f4240205776e00936df8160d90af8d8 /src/widgets/widgets/qmainwindowlayout.cpp | |
parent | 46458ce3ef4aeb01fef97348dcd317f0edd7e5fb (diff) |
QMainWindow: move the separator handling in another class
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 <sergio.martins@kdab.com>
Diffstat (limited to 'src/widgets/widgets/qmainwindowlayout.cpp')
-rw-r--r-- | src/widgets/widgets/qmainwindowlayout.cpp | 58 |
1 files changed, 1 insertions, 57 deletions
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" |