From 1d8eea28bb935789862329ad035364a9c38536e0 Mon Sep 17 00:00:00 2001 From: Michail Vourlakos Date: Sun, 10 Dec 2017 19:54:13 +0200 Subject: [PATCH] slidingIn/Out during locationChange signal --- app/dockview.cpp | 57 +++++++++++++++++++ app/dockview.h | 18 ++++++ .../package/contents/ui/EditModeVisual.qml | 12 ++-- .../package/contents/ui/VisibilityManager.qml | 29 +++++++++- containment/package/contents/ui/main.qml | 15 ++++- .../contents/configuration/BehaviorConfig.qml | 8 ++- 6 files changed, 127 insertions(+), 12 deletions(-) diff --git a/app/dockview.cpp b/app/dockview.cpp index fddfbaa7a..3c8a725a8 100644 --- a/app/dockview.cpp +++ b/app/dockview.cpp @@ -209,6 +209,10 @@ void DockView::init() connect(this, SIGNAL(normalThicknessChanged()), corona(), SIGNAL(availableScreenRectChanged())); connect(this, SIGNAL(shadowChanged()), corona(), SIGNAL(availableScreenRectChanged())); + + initSignalingForLocationChangeSliding(); + + ///!!!!! rootContext()->setContextProperty(QStringLiteral("dock"), this); auto *dockCorona = qobject_cast(this->corona()); @@ -229,6 +233,37 @@ void DockView::init() qDebug() << "SOURCE:" << source(); } +void DockView::initSignalingForLocationChangeSliding() +{ + connect(this, &DockView::hideDockDuringLocationChangeSignal, this, [&]() { + setBlockHiding(false); + + if (m_configView) { + auto configDialog = qobject_cast(m_configView); + + if (configDialog) { + configDialog->hideConfigWindow(); + } + } + }); + + connect(this, &DockView::hideDockDuringLocationChangeFinished, this, [&]() { + setBlockAnimations(true); + setLocation(m_goToLocation); + }); + + connect(this, &DockView::dockLocationChanged, this, [&]() { + if (blockAnimations()) { + QTimer::singleShot(100, [this]() { + setBlockAnimations(false); + emit showDockAfterLocationChangeSignal(); + showSettingsWindow(); + }); + } + }); +} + + void DockView::availableScreenRectChanged() { if (m_inDelete) @@ -1045,6 +1080,21 @@ void DockView::setAlignment(int alignment) emit alignmentChanged(); } +bool DockView::blockAnimations() const +{ + return m_blockAnimations; +} + +void DockView::setBlockAnimations(bool block) +{ + if (m_blockAnimations == block) { + return; + } + + m_blockAnimations = block; + emit blockAnimationsChanged(); +} + QRect DockView::maskArea() const { return m_maskArea; @@ -1172,6 +1222,13 @@ void DockView::setShadow(int shadow) emit shadowChanged(); } +void DockView::hideDockDuringLocationChange(int goToLocation) +{ + m_goToLocation = static_cast(goToLocation); + emit hideDockDuringLocationChangeSignal(); +} + + void DockView::setBlockHiding(bool block) { if (!block) { diff --git a/app/dockview.h b/app/dockview.h index 6999971da..11b8cfc08 100644 --- a/app/dockview.h +++ b/app/dockview.h @@ -54,6 +54,7 @@ class DockView : public PlasmaQuick::ContainmentView { Q_OBJECT Q_PROPERTY(bool alternativesIsShown READ alternativesIsShown NOTIFY alternativesIsShownChanged) Q_PROPERTY(bool behaveAsPlasmaPanel READ behaveAsPlasmaPanel WRITE setBehaveAsPlasmaPanel NOTIFY behaveAsPlasmaPanelChanged) + Q_PROPERTY(bool blockAnimations READ blockAnimations WRITE setBlockAnimations NOTIFY blockAnimationsChanged) Q_PROPERTY(bool contextMenuIsShown READ contextMenuIsShown NOTIFY contextMenuIsShownChanged) Q_PROPERTY(bool dockWinBehavior READ dockWinBehavior WRITE setDockWinBehavior NOTIFY dockWinBehaviorChanged) Q_PROPERTY(bool drawShadows READ drawShadows WRITE setDrawShadows NOTIFY drawShadowsChanged) @@ -112,6 +113,9 @@ public: bool behaveAsPlasmaPanel() const; void setBehaveAsPlasmaPanel(bool behavior); + bool blockAnimations() const; + void setBlockAnimations(bool block); + bool contextMenuIsShown() const; bool dockWinBehavior() const; @@ -184,6 +188,8 @@ public slots: Q_INVOKABLE void toggleAppletExpanded(const int id); Q_INVOKABLE void updateEnabledBorders(); + Q_INVOKABLE void hideDockDuringLocationChange(int goToLocation); + Q_INVOKABLE int docksWithTasks(); Q_INVOKABLE bool mimeContainsPlasmoid(QMimeData *mimeData, QString name); @@ -208,9 +214,17 @@ signals: void removeInternalViewSplitter(); void eventTriggered(QEvent *ev); + //! these two signals are used from config ui and containment ui + //! in order to orchestrate an animated hiding/showing of dock + //! during changing location + void hideDockDuringLocationChangeSignal(); + void hideDockDuringLocationChangeFinished(); + void showDockAfterLocationChangeSignal(); + void alternativesIsShownChanged(); void alignmentChanged(); void behaveAsPlasmaPanelChanged(); + void blockAnimationsChanged(); void contextMenuIsShownChanged(); void currentScreenChanged(); void dockLocationChanged(); @@ -252,6 +266,7 @@ private slots: private: void addAppletActions(QMenu *desktopMenu, Plasma::Applet *applet, QEvent *event); void addContainmentActions(QMenu *desktopMenu, QEvent *event); + void initSignalingForLocationChangeSliding(); void setupWaylandIntegration(); void updatePosition(QRect availableScreenRect = QRect()); void updateFormFactor(); @@ -264,6 +279,7 @@ private: bool m_alternativesIsShown{false}; bool m_behaveAsPlasmaPanel{false}; + bool m_blockAnimations{false}; bool m_forceDrawCenteredBorders{false}; bool m_dockWinBehavior{true}; bool m_drawShadows{true}; @@ -294,6 +310,8 @@ private: QTimer m_screenSyncTimer; + Plasma::Types::Location m_goToLocation; + Plasma::Theme m_theme; //only for the mask on disabled compositing, not to actually paint Plasma::FrameSvg *m_background{nullptr}; diff --git a/containment/package/contents/ui/EditModeVisual.qml b/containment/package/contents/ui/EditModeVisual.qml index 020dae3ee..e80b1c5f7 100644 --- a/containment/package/contents/ui/EditModeVisual.qml +++ b/containment/package/contents/ui/EditModeVisual.qml @@ -34,11 +34,11 @@ Image{ source: "../icons/"+layoutColor+"print.jpg" opacity: 0 - property int speed: root.durationTime*4*units.longDuration + property int speed: root.durationTime*3*units.longDuration property int thickness: visibilityManager.thicknessNormalOriginal + root.editShadow property int rootThickness: visibilityManager.thicknessZoomOriginal + root.editShadow property int editLength: root.isHorizontal ? (root.behaveAsPlasmaPanel ? root.width - root.maxIconSize/4 : root.maxLength) : - (root.behaveAsPlasmaPanel ? root.height - root.maxIconSize/4 : root.maxLength) + (root.behaveAsPlasmaPanel ? root.height - root.maxIconSize/4 : root.maxLength) property bool animationSent: false property bool farEdge: (plasmoid.location===PlasmaCore.Types.BottomEdge) || (plasmoid.location===PlasmaCore.Types.RightEdge) @@ -247,7 +247,7 @@ Image{ property: root.isHorizontal ? "y" : "x" to: editVisual.farEdge ? editVisual.rootThickness - editVisual.thickness : 0 duration: editVisual.speed - easing.type: Easing.OutBounce + easing.type: Easing.OutQuad } @@ -272,7 +272,7 @@ Image{ property: root.isHorizontal ? "y" : "x" to: editVisual.farEdge ? editVisual.rootThickness : -editVisual.thickness duration: editVisual.speed - easing.type: Easing.OutBounce + easing.type: Easing.OutQuad } PropertyAnimation { target: editVisual @@ -290,6 +290,10 @@ Image{ root.slotAnimationsNeedLength(-1); editVisual.animationSent = false; } + + if (visibilityManager.inTempHiding) { + visibilityManager.sendHideDockDuringLocationChangeFinished(); + } } } } diff --git a/containment/package/contents/ui/VisibilityManager.qml b/containment/package/contents/ui/VisibilityManager.qml index 055df5826..e343b6d5d 100644 --- a/containment/package/contents/ui/VisibilityManager.qml +++ b/containment/package/contents/ui/VisibilityManager.qml @@ -35,6 +35,7 @@ Item{ property bool debugMagager: Qt.application.arguments.indexOf("--mask") >= 0 + property bool blockUpdateMask: false property bool inStartup: root.inStartup property bool normalState : false // this is being set from updateMaskArea property bool previousNormalState : false // this is only for debugging purposes @@ -43,6 +44,7 @@ Item{ property int animationSpeed: Latte.WindowSystem.compositingActive ? root.durationTime * 1.2 * units.longDuration : 0 property bool inSlidingIn: false //necessary because of its init structure property alias inSlidingOut: slidingAnimationAutoHiddenOut.running + property bool inTempHiding: false property int length: root.isVertical ? Screen.height : Screen.width //screenGeometry.height : screenGeometry.width property int slidingOutToPos: ((plasmoid.location===PlasmaCore.Types.LeftEdge)||(plasmoid.location===PlasmaCore.Types.TopEdge)) ? @@ -165,7 +167,7 @@ Item{ function slotMustBeShown() { // console.log("show..."); - if (!slidingAnimationAutoHiddenIn.running){ + if (!slidingAnimationAutoHiddenIn.running && !inTempHiding){ slidingAnimationAutoHiddenIn.init(); } } @@ -178,9 +180,24 @@ Item{ } } + function slotHideDockDuringLocationChange() { + inTempHiding = true; + blockUpdateMask = true; + slotMustBeHide(); + } + + function slotShowDockAfterLocationChange() { + slidingAnimationAutoHiddenIn.init(); + } + + function sendHideDockDuringLocationChangeFinished(){ + blockUpdateMask = false; + dock.hideDockDuringLocationChangeFinished(); + } + ///test maskArea function updateMaskArea() { - if (!dock) { + if (!dock || blockUpdateMask) { return; } @@ -460,7 +477,11 @@ Item{ console.log("hiding animation ended..."); } - updateMaskArea(); + if (!manager.inTempHiding) { + updateMaskArea(); + } else if (plasmoid.configuration.durationTime === 0) { + sendHideDockDuringLocationChangeFinished(); + } } function init() { @@ -494,6 +515,8 @@ Item{ onStopped: { inSlidingIn = false; + manager.inTempHiding = false; + if (manager.debugMagager) { console.log("showing animation ended..."); } diff --git a/containment/package/contents/ui/main.qml b/containment/package/contents/ui/main.qml index 03b6fa101..13e2d8819 100644 --- a/containment/package/contents/ui/main.qml +++ b/containment/package/contents/ui/main.qml @@ -81,7 +81,7 @@ DragDrop.DropArea { property bool dockContainsMouse: dock && dock.visibility ? dock.visibility.containsMouse : false property bool disablePanelShadowMaximized: plasmoid.configuration.disablePanelShadowForMaximized - property bool drawShadowsExternal: panelShadowsActive && behaveAsPlasmaPanel + property bool drawShadowsExternal: panelShadowsActive && behaveAsPlasmaPanel && !visibilityManager.inTempHiding property bool editMode: plasmoid.userConfiguring property bool forceSolidPanel: plasmoid.configuration.solidBackgroundForMaximized && windowsModel.hasMaximizedWindow property bool forceTransparentPanel: root.backgroundOnlyOnMaximized && !windowsModel.hasMaximizedWindow && Latte.WindowSystem.compositingActive @@ -275,6 +275,10 @@ DragDrop.DropArea { property int tasksCount: latteApplet ? latteApplet.tasksCount : 0 property real durationTime: { + if (dock && dock.blockAnimations) { + return 0; + } + if (plasmoid.configuration.durationTime === 0 || plasmoid.configuration.durationTime === 2 ) return plasmoid.configuration.durationTime; @@ -389,6 +393,9 @@ DragDrop.DropArea { dock.onWidthChanged.connect(visibilityManager.updateMaskArea); dock.onHeightChanged.connect(visibilityManager.updateMaskArea); + dock.hideDockDuringLocationChangeSignal.connect(visibilityManager.slotHideDockDuringLocationChange); + dock.showDockAfterLocationChangeSignal.connect(visibilityManager.slotShowDockAfterLocationChange); + dock.visibility.onContainsMouseChanged.connect(visibilityManager.slotContainsMouseChanged); dock.visibility.onMustBeHide.connect(visibilityManager.slotMustBeHide); dock.visibility.onMustBeShown.connect(visibilityManager.slotMustBeShown); @@ -555,6 +562,8 @@ DragDrop.DropArea { dock.onYChanged.disconnect(visibilityManager.updateMaskArea); dock.onWidthChanged.disconnect(visibilityManager.updateMaskArea); dock.onHeightChanged.disconnect(visibilityManager.updateMaskArea); + dock.hideDockDuringLocationChangeSignal.disconnect(visibilityManager.slotHideDockDuringLocationChange); + dock.showDockAfterLocationChangeSignal.disconnect(visibilityManager.slotShowDockAfterLocationChange); if (dock.visibility) { dock.visibility.onContainsMouseChanged.disconnect(visibilityManager.slotContainsMouseChanged); @@ -1025,7 +1034,7 @@ DragDrop.DropArea { } function updateAutomaticIconSize() { - if ((visibilityManager.normalState && !root.editMode + if ((visibilityManager.normalState && !root.editMode && !visibilityManager.inTempHiding && (root.autoDecreaseIconSize || (!root.autoDecreaseIconSize && root.iconSize!=root.maxIconSize))) && (iconSize===root.maxIconSize || iconSize === automaticIconSizeBasedSize) ) { var layoutLength; @@ -1191,6 +1200,8 @@ DragDrop.DropArea { root.globalDirectRender = false; } } + + onDockLocationChanged:setGlobalDirectRender(false); } Connections{ diff --git a/shell/package/contents/configuration/BehaviorConfig.qml b/shell/package/contents/configuration/BehaviorConfig.qml index f6ebc9360..a036c3571 100644 --- a/shell/package/contents/configuration/BehaviorConfig.qml +++ b/shell/package/contents/configuration/BehaviorConfig.qml @@ -247,11 +247,13 @@ PlasmaComponents.Page { ExclusiveGroup { id: locationGroup + property bool inStartup: true + onCurrentChanged: { - if (current.checked) { - dock.location = current.edge - locationLayout.lockReservedEdges() + if (current.checked && !inStartup) { + dock.hideDockDuringLocationChange(current.edge); } + inStartup = false; } }