From ddecf63b0cb5e4f69c165356d207d977a1629811 Mon Sep 17 00:00:00 2001 From: Michail Vourlakos Date: Sun, 29 Jan 2017 09:55:58 +0200 Subject: [PATCH] fix issues with new maxLength --- containment/contents/ui/EditModeVisual.qml | 55 ++++++++++++++++++---- containment/contents/ui/PanelBox.qml | 4 +- containment/contents/ui/main.qml | 2 +- 3 files changed, 50 insertions(+), 11 deletions(-) diff --git a/containment/contents/ui/EditModeVisual.qml b/containment/contents/ui/EditModeVisual.qml index 62245c8d2..e77c0893d 100644 --- a/containment/contents/ui/EditModeVisual.qml +++ b/containment/contents/ui/EditModeVisual.qml @@ -23,6 +23,8 @@ import QtQuick 2.1 import org.kde.plasma.core 2.0 as PlasmaCore import QtGraphicalEffects 1.0 +import org.kde.latte 0.1 as Latte + Image{ id: editVisual width: root.isHorizontal ? root.maxLength : visibilityManager.thicknessNormalOriginalValue @@ -67,6 +69,7 @@ Image{ Connections{ target: root onIconSizeChanged: initializeEditPosition(); + onPanelAlignmentChanged: initializeEditPosition(); } onRootThicknessChanged: { @@ -95,34 +98,70 @@ Image{ function initializeNormalPosition() { if (plasmoid.location === PlasmaCore.Types.BottomEdge) { - x = root.width/2 - root.maxLength/2; y = rootThickness; } else if (plasmoid.location === PlasmaCore.Types.RightEdge) { x = rootThickness; - y = 0; } else if (plasmoid.location === PlasmaCore.Types.LeftEdge) { x = -editVisual.thickness; - y = 0; } else if (plasmoid.location === PlasmaCore.Types.TopEdge) { - x = root.width/2 - root.maxLength/2; y = -editVisual.thickness; } + + if (root.isHorizontal) { + if (plasmoid.configuration.panelPosition === Latte.Dock.Justify) { + x = root.width/2 - root.maxLength/2; + } else if (root.panelAlignment === Latte.Dock.Left) { + x = 0; + } else if (root.panelAlignment === Latte.Dock.Center) { + x = root.width/2 - root.maxLength/2; + } else if (root.panelAlignment === Latte.Dock.Right) { + x = root.width - root.maxLength; + } + } else if (root.isVertical) { + if (plasmoid.configuration.panelPosition === Latte.Dock.Justify) { + y = root.height/2 - root.maxLength/2; + } else if (root.panelAlignment === Latte.Dock.Top) { + y = 0; + } else if (root.panelAlignment === Latte.Dock.Center) { + y = root.height/2 - root.maxLength/2; + } else if (root.panelAlignment === Latte.Dock.Bottom) { + y = root.height - root.maxLength; + } + } } function initializeEditPosition() { if (root.editMode) { if (plasmoid.location === PlasmaCore.Types.LeftEdge){ x = 0; - y = root.height/2 - editVisual.height/2; } else if (plasmoid.location === PlasmaCore.Types.TopEdge) { - x = root.width/2 - editVisual.width/2; y = 0; } else if (plasmoid.location === PlasmaCore.Types.BottomEdge) { - x = root.width/2 - editVisual.width/2; y = rootThickness - thickness + shadowSize; } else if (plasmoid.location === PlasmaCore.Types.RightEdge) { x = rootThickness - thickness + shadowSize; - y = root.height/2 - editVisual.height/2; + } + + if (root.isHorizontal) { + if (plasmoid.configuration.panelPosition === Latte.Dock.Justify) { + x = root.width/2 - editVisual.width/2; + } else if (root.panelAlignment === Latte.Dock.Left) { + x = 0; + } else if (root.panelAlignment === Latte.Dock.Center) { + x = root.width/2 - editVisual.width/2; + } else if (root.panelAlignment === Latte.Dock.Right) { + x = root.width - editVisual.width; + } + } else if (root.isVertical) { + if (plasmoid.configuration.panelPosition === Latte.Dock.Justify) { + y = root.height/2 - editVisual.height/2; + } else if (root.panelAlignment === Latte.Dock.Top) { + y = 0; + } else if (root.panelAlignment === Latte.Dock.Center) { + y = root.height/2 - editVisual.height/2; + } else if (root.panelAlignment === Latte.Dock.Bottom) { + y = root.height - editVisual.height; + } } } } diff --git a/containment/contents/ui/PanelBox.qml b/containment/contents/ui/PanelBox.qml index bed864979..87e125ed3 100644 --- a/containment/contents/ui/PanelBox.qml +++ b/containment/contents/ui/PanelBox.qml @@ -37,9 +37,9 @@ Item{ // parent: root z:0 - property int panelWidth: secondLayout.count > 0 && root.isHorizontal && !root.editMode ? + property int panelWidth: (root.panelAlignment === Latte.Dock.Justify) && root.isHorizontal && !root.editMode ? layoutsContainer.width + 2*spacing : mainLayout.width + spacing - property int panelHeight: secondLayout.count > 0 && root.isVertical && !root.editMode ? + property int panelHeight: (root.panelAlignment === Latte.Dock.Justify) && root.isVertical && !root.editMode ? layoutsContainer.height + 2*spacing : mainLayout.height + spacing width: root.isHorizontal ? panelWidth : smallSize diff --git a/containment/contents/ui/main.qml b/containment/contents/ui/main.qml index 53059ad3a..4ecf6867d 100644 --- a/containment/contents/ui/main.qml +++ b/containment/contents/ui/main.qml @@ -49,7 +49,7 @@ DragDrop.DropArea { property bool editMode: plasmoid.userConfiguring property bool immutable: plasmoid.immutable property bool inStartup: true - property bool isHorizontal: plasmoid.formFactor == PlasmaCore.Types.Horizontal + property bool isHorizontal: plasmoid.formFactor === PlasmaCore.Types.Horizontal property bool isVertical: !isHorizontal property bool isHovered: nowDock ? ((nowDockHoveredIndex !== -1) && (layoutsContainer.hoveredIndex !== -1)) //|| wholeArea.containsMouse : (layoutsContainer.hoveredIndex !== -1) //|| wholeArea.containsMouse