From 81335bc92f3d98f45087a39020485ee34df079ba Mon Sep 17 00:00:00 2001 From: Michail Vourlakos Date: Thu, 20 Dec 2018 19:40:05 +0200 Subject: [PATCH] improve LayoutManager qml references --- .../package/contents/ui/ConfigOverlay.qml | 12 ++++----- .../package/contents/ui/EditModeVisual.qml | 2 +- .../package/contents/ui/VisibilityManager.qml | 2 +- containment/package/contents/ui/main.qml | 27 ++++++++++++++----- 4 files changed, 29 insertions(+), 14 deletions(-) diff --git a/containment/package/contents/ui/ConfigOverlay.qml b/containment/package/contents/ui/ConfigOverlay.qml index ce2cfc9b1..9247c9235 100644 --- a/containment/package/contents/ui/ConfigOverlay.qml +++ b/containment/package/contents/ui/ConfigOverlay.qml @@ -96,9 +96,9 @@ MouseArea { if ((plasmoid.formFactor === PlasmaCore.Types.Vertical && posInItem.y < item.height/2) || (plasmoid.formFactor !== PlasmaCore.Types.Vertical && posInItem.x < item.width/2)) { - root.layoutManager.insertBefore(item, placeHolder); + root.layoutManagerInsertBefore(item, placeHolder); } else { - root.layoutManager.insertAfter(item, placeHolder); + root.layoutManagerInsertAfter(item, placeHolder); } } @@ -198,7 +198,7 @@ MouseArea { placeHolder.height = currentApplet.height; handle.width = currentApplet.width; handle.height = currentApplet.height; - root.layoutManager.insertBefore(currentApplet, placeHolder); + root.layoutManagerInsertBefore(currentApplet, placeHolder); currentApplet.parent = root; currentApplet.x = lastX-appletX; currentApplet.y = lastY-appletY; @@ -221,7 +221,7 @@ MouseArea { configurationArea.isResizingLeft = false; configurationArea.isResizingRight = false; - root.layoutManager.insertBefore(placeHolder, currentApplet); + root.layoutManagerInsertBefore(placeHolder, currentApplet); placeHolder.parent = configurationArea; currentApplet.z = 1; @@ -231,7 +231,7 @@ MouseArea { handle.y = relevantLayout.y + currentApplet.y; // handle.width = currentApplet.width; // handle.height = currentApplet.height; - root.layoutManager.save(); + root.layoutManagerSave(); } onWheel: { @@ -489,7 +489,7 @@ MouseArea { onCheckedChanged: { currentApplet.lockZoom = checked; - root.layoutManager.saveLocks(); + root.layoutManagerSaveLocks(); } } diff --git a/containment/package/contents/ui/EditModeVisual.qml b/containment/package/contents/ui/EditModeVisual.qml index 6afb884af..bf5f08cc6 100644 --- a/containment/package/contents/ui/EditModeVisual.qml +++ b/containment/package/contents/ui/EditModeVisual.qml @@ -51,7 +51,7 @@ Item{ property rect efGeometry - property string layoutColor: root.latteViewManagedLayout ? root.latteViewManagedLayout.color : "blue" + property string layoutColor: latteView && latteView.managedLayout ? latteView.managedLayout.color : "blue" Item{ diff --git a/containment/package/contents/ui/VisibilityManager.qml b/containment/package/contents/ui/VisibilityManager.qml index 504409f51..0b152a49b 100644 --- a/containment/package/contents/ui/VisibilityManager.qml +++ b/containment/package/contents/ui/VisibilityManager.qml @@ -193,7 +193,7 @@ Item{ Connections{ target: universalLayoutManager onCurrentLayoutIsSwitching: { - if (Latte.WindowSystem.compositingActive && root.latteViewManagedLayout && root.latteViewManagedLayout.name === layoutName) { + if (Latte.WindowSystem.compositingActive && latteView && latteView.managedLayout && latteView.managedLayout.name === layoutName) { manager.inTempHiding = true; manager.inForceHiding = true; root.clearZoom(); diff --git a/containment/package/contents/ui/main.qml b/containment/package/contents/ui/main.qml index b007fd702..795e9c45a 100644 --- a/containment/package/contents/ui/main.qml +++ b/containment/package/contents/ui/main.qml @@ -338,7 +338,6 @@ DragDrop.DropArea { } property var iconsArray: [16, 22, 32, 48, 64, 96, 128, 256] - property var layoutManager: LayoutManager property Item dragOverlay property Item toolBox @@ -717,7 +716,7 @@ DragDrop.DropArea { LayoutManager.root = root; LayoutManager.layout = layoutsContainer.mainLayout; LayoutManager.layoutS = layoutsContainer.startLayout; - layoutManager.layoutE = layoutsContainer.endLayout; + LayoutManager.layoutE = layoutsContainer.endLayout; LayoutManager.lastSpacer = lastSpacer; LayoutManager.restore(); plasmoid.action("configure").visible = !plasmoid.immutable; @@ -947,12 +946,12 @@ DragDrop.DropArea { container.visible = true; if(pos>=0 ){ - layoutManager.insertAtIndex(container, pos); + LayoutManager.insertAtIndex(container, pos); } else { - layoutManager.insertAtIndex(container, Math.floor(layoutsContainer.mainLayout.count / 2)); + LayoutManager.insertAtIndex(container, Math.floor(layoutsContainer.mainLayout.count / 2)); } - layoutManager.save(); + LayoutManager.save(); } } @@ -1071,6 +1070,22 @@ DragDrop.DropArea { } } + function layoutManagerInsertBefore(place, item) { + LayoutManager.insertBefore(place, item); + } + + function layoutManagerInsertAfter(place, item) { + LayoutManager.insertAfter(place, item); + } + + function layoutManagerSave() { + LayoutManager.save(); + } + + function layoutManagerSaveLocks() { + LayoutManager.saveLocks(); + } + function mouseInCanBeHoveredApplet(){ if (latteApplet && latteApplet.containsMouse()) return true; @@ -1120,7 +1135,7 @@ DragDrop.DropArea { item.destroy(); } - layoutManager.save(); + LayoutManager.save(); } function setHoveredIndex(ind) {