From cb69a9c7c634bb931d2c60799ef73fdddce3a09f Mon Sep 17 00:00:00 2001 From: Michail Vourlakos Date: Thu, 4 Jan 2018 21:27:55 +0200 Subject: [PATCH] slide out/in also in user screen change --- app/dockconfigview.cpp | 2 +- app/dockview.cpp | 59 +++++++++++++++---- app/dockview.h | 4 +- .../package/contents/ui/VisibilityManager.qml | 1 + containment/package/contents/ui/main.qml | 5 ++ 5 files changed, 59 insertions(+), 12 deletions(-) diff --git a/app/dockconfigview.cpp b/app/dockconfigview.cpp index f2ce28cad..141f25867 100644 --- a/app/dockconfigview.cpp +++ b/app/dockconfigview.cpp @@ -57,7 +57,7 @@ DockConfigView::DockConfigView(Plasma::Containment *containment, DockView *dockV m_screenSyncTimer.setSingleShot(true); m_screenSyncTimer.setInterval(100); - connections << connect(dockView, SIGNAL(screenChanged(QScreen *)), &m_screenSyncTimer, SLOT(start())); + connections << connect(&m_screenSyncTimer, &QTimer::timeout, this, [this]() { setScreen(m_dockView->screen()); setFlags(wFlags()); diff --git a/app/dockview.cpp b/app/dockview.cpp index fde92ae4a..c8989448d 100644 --- a/app/dockview.cpp +++ b/app/dockview.cpp @@ -190,7 +190,7 @@ void DockView::init() connect(this, &DockView::alignmentChanged, this, &DockView::updateEnabledBorders); connect(this, &DockView::dockWinBehaviorChanged, this, &DockView::saveConfig); connect(this, &DockView::onPrimaryChanged, this, &DockView::saveConfig); - connect(this, &DockView::onPrimaryChanged, this, &DockView::reconsiderScreen); + connect(this, &DockView::locationChanged, this, [&]() { updateFormFactor(); syncGeometry(); @@ -248,13 +248,9 @@ void DockView::initSignalingForLocationChangeSliding() } }); - connect(this, &DockView::hideDockDuringLocationChangeFinished, this, [&]() { - setBlockAnimations(true); - setLocation(m_goToLocation); - }); - - connect(this, &DockView::dockLocationChanged, this, [&]() { - if (blockAnimations()) { + connect(this, &DockView::locationChanged, this, [&]() { + if (m_goToLocation != Plasma::Types::Floating) { + m_goToLocation = Plasma::Types::Floating; QTimer::singleShot(100, [this]() { setBlockAnimations(false); emit showDockAfterLocationChangeFinished(); @@ -262,8 +258,44 @@ void DockView::initSignalingForLocationChangeSliding() }); } }); -} + //! signals to handle the sliding-in/out during screen changes + connect(this, &DockView::hideDockDuringScreenChangeStarted, this, [&]() { + setBlockHiding(false); + + if (m_configView) { + auto configDialog = qobject_cast(m_configView); + + if (configDialog) { + configDialog->hideConfigWindow(); + } + } + }); + + connect(this, &DockView::currentScreenChanged, this, [&]() { + if (m_goToScreen) { + m_goToScreen = nullptr; + QTimer::singleShot(100, [this]() { + setBlockAnimations(false); + emit showDockAfterScreenChangeFinished(); + showSettingsWindow(); + }); + } + }); + + //! ---- both cases ---- !// + //! this is used for both location and screen change cases, this signal + //! is send when the sliding-out animation has finished + connect(this, &DockView::hideDockDuringLocationChangeFinished, this, [&]() { + setBlockAnimations(true); + + if (m_goToLocation != Plasma::Types::Floating) { + setLocation(m_goToLocation); + } else if (m_goToScreen) { + setScreenToFollow(m_goToScreen); + } + }); +} void DockView::availableScreenRectChanged() { @@ -327,7 +359,13 @@ bool DockView::setCurrentScreen(const QString id) if (!freeEdges.contains(location())) { return false; } else { - setScreenToFollow(nextScreen); + m_goToScreen = nextScreen; + + //! asynchronous call in order to not crash from configwindow + //! deletion from sliding out animation + QTimer::singleShot(100, [this]() { + emit hideDockDuringScreenChangeStarted(); + }); } } } @@ -365,6 +403,7 @@ void DockView::setScreenToFollow(QScreen *screen, bool updateScreenId) syncGeometry(); updateAbsDockGeometry(true); emit screenGeometryChanged(); + emit currentScreenChanged(); } //! the main function which decides if this dock is at the diff --git a/app/dockview.h b/app/dockview.h index 0cf404dc2..e5b5a4178 100644 --- a/app/dockview.h +++ b/app/dockview.h @@ -313,7 +313,9 @@ private: QTimer m_screenSyncTimer; - Plasma::Types::Location m_goToLocation; + //!used at sliding out/in animation + Plasma::Types::Location m_goToLocation{Plasma::Types::Floating}; + QScreen *m_goToScreen{nullptr}; Plasma::Theme m_theme; //only for the mask on disabled compositing, not to actually paint diff --git a/containment/package/contents/ui/VisibilityManager.qml b/containment/package/contents/ui/VisibilityManager.qml index 48a4bef9f..dc1dad74c 100644 --- a/containment/package/contents/ui/VisibilityManager.qml +++ b/containment/package/contents/ui/VisibilityManager.qml @@ -200,6 +200,7 @@ Item{ } } + //! functions used for sliding out/in during location/screen changes function slotHideDockDuringLocationChange() { inTempHiding = true; blockUpdateMask = true; diff --git a/containment/package/contents/ui/main.qml b/containment/package/contents/ui/main.qml index e8e98ad54..f26be1607 100644 --- a/containment/package/contents/ui/main.qml +++ b/containment/package/contents/ui/main.qml @@ -399,6 +399,8 @@ DragDrop.DropArea { dock.hideDockDuringLocationChangeStarted.connect(visibilityManager.slotHideDockDuringLocationChange); dock.showDockAfterLocationChangeFinished.connect(visibilityManager.slotShowDockAfterLocationChange); + dock.hideDockDuringScreenChangeStarted.connect(visibilityManager.slotHideDockDuringLocationChange); + dock.showDockAfterScreenChangeFinished.connect(visibilityManager.slotShowDockAfterLocationChange); dock.visibility.onContainsMouseChanged.connect(visibilityManager.slotContainsMouseChanged); dock.visibility.onMustBeHide.connect(visibilityManager.slotMustBeHide); @@ -566,8 +568,11 @@ DragDrop.DropArea { dock.onYChanged.disconnect(visibilityManager.updateMaskArea); dock.onWidthChanged.disconnect(visibilityManager.updateMaskArea); dock.onHeightChanged.disconnect(visibilityManager.updateMaskArea); + dock.hideDockDuringLocationChangeStarted.disconnect(visibilityManager.slotHideDockDuringLocationChange); dock.showDockAfterLocationChangeFinished.disconnect(visibilityManager.slotShowDockAfterLocationChange); + dock.hideDockDuringScreenChangeStarted.disconnect(visibilityManager.slotHideDockDuringLocationChange); + dock.showDockAfterScreenChangeFinished.disconnect(visibilityManager.slotShowDockAfterLocationChange); if (dock.visibility) { dock.visibility.onContainsMouseChanged.disconnect(visibilityManager.slotContainsMouseChanged);