From f5db9ce63d4a6a560bc920135df9a976b1bb147e Mon Sep 17 00:00:00 2001 From: Michail Vourlakos Date: Fri, 8 May 2020 23:02:43 +0300 Subject: [PATCH] fix Justify alignment applets placement inConfigure --applets are now always take into account the splitters placement and the splitters try to be always in the center. This is much more predictable and understanble from the user --- .../contents/ui/editmode/ConfigOverlay.qml | 2 +- containment/package/contents/ui/main.qml | 70 ++++++++++++++++--- 2 files changed, 61 insertions(+), 11 deletions(-) diff --git a/containment/package/contents/ui/editmode/ConfigOverlay.qml b/containment/package/contents/ui/editmode/ConfigOverlay.qml index 0a3e0a512..e85220954 100644 --- a/containment/package/contents/ui/editmode/ConfigOverlay.qml +++ b/containment/package/contents/ui/editmode/ConfigOverlay.qml @@ -237,7 +237,7 @@ MouseArea { // handle.width = currentApplet.width; // handle.height = currentApplet.height; root.layoutManagerSave(); - root.layoutManagerMoveAppletsOutOfMainLayoutToLayouts(); + root.layoutManagerMoveAppletsBasedOnJustifyAlignment(); layoutsContainer.updateSizeForAppletsInFill(); } diff --git a/containment/package/contents/ui/main.qml b/containment/package/contents/ui/main.qml index 713e15d34..907a8c1e3 100644 --- a/containment/package/contents/ui/main.qml +++ b/containment/package/contents/ui/main.qml @@ -1108,12 +1108,57 @@ Item { layoutsContainer.updateSizeForAppletsInFill(); } - function layoutManagerMoveAppletsOutOfMainLayoutToLayouts() { + function layoutManagerMoveAppletsBasedOnJustifyAlignment() { if (plasmoid.configuration.alignment !== 10) { return; } animations.appletsInParentChange = true; + + var splitter = -1; + var startChildrenLength = layoutsContainer.startLayout.children.length; + + //! Check if there is a splitter inside start layout after the user was dragging its applets + for (var i=0; i=0) { + for (var i=startChildrenLength-1; i>=splitter; --i){ + var item = layoutsContainer.startLayout.children[i]; + LayoutManager.insertAtIndex(layoutsContainer.mainLayout, item, 0); + } + } + + var splitter2 = -1; + var endChildrenLength = layoutsContainer.endLayout.children.length; + + //! Check if there is a splitter inside endlayout after the user was dragging its applets + for (var i=0; i=0) { + for (var i=0; i<=splitter2; ++i){ + var item = layoutsContainer.endLayout.children[0]; + item.parent = layoutsContainer.mainLayout; + } + } + + //! Validate applets positioning and move applets out of splitters to start/endlayouts accordingly splitMainLayoutToLayouts(); + animations.appletsInParentChange = false; } @@ -1137,19 +1182,24 @@ Item { } // console.log("update layouts 1:"+splitter + " - "+splitter2); - for (var i=0; i 0) { + for (var i=0; i 0) { + splitter2 = splitter2 - splitter; + // console.log("update layouts 2:"+splitter + " - "+splitter2); - totalChildren = layoutsContainer.mainLayout.children.length; + totalChildren = layoutsContainer.mainLayout.children.length; - for (var i=totalChildren-1; i>=splitter2+1; --i){ - var item = layoutsContainer.mainLayout.children[i]; - LayoutManager.insertAtIndex(layoutsContainer.endLayout, item, 0); + for (var i=totalChildren-1; i>=splitter2+1; --i){ + var item = layoutsContainer.mainLayout.children[i]; + LayoutManager.insertAtIndex(layoutsContainer.endLayout, item, 0); + } } animations.appletsInParentChange = false;