diff --git a/plasmoid/package/contents/ui/main.qml b/plasmoid/package/contents/ui/main.qml index 9576ffa3f..987c5efe5 100644 --- a/plasmoid/package/contents/ui/main.qml +++ b/plasmoid/package/contents/ui/main.qml @@ -214,7 +214,8 @@ Item { property int tasksHeight: mouseHandler.height property int tasksWidth: mouseHandler.width - property int userPanelPosition: latteView ? latteView.panelAlignment : plasmoid.configuration.plasmoidPosition + //updated from Binding + property int userPanelPosition readonly property real currentPanelOpacity: latteView ? latteView.currentPanelTransparency / 100 : 1 @@ -363,6 +364,36 @@ Item { source: "indicators/Manager.qml" } + Binding { + target: root + property: "userPanelPosition" + value: { + if (latteView) { + if (latteView.panelUserSetAlignment === -1) { + return; + } + + if (inConfigureAppletsMode) { + return Latte.Types.Center; + } else if (latteView.panelUserSetAlignment === Latte.Types.Justify) { + if (latteView.latteAppletPos>=0 && latteView.latteAppletPos<100) { + return plasmoid.formFactor === PlasmaCore.Types.Horizontal ? Latte.Types.Left : Latte.Types.Top; + } else if (latteView.latteAppletPos>=100 && latteView.latteAppletPos<200) { + return Latte.Types.Center; + } else if (latteView.latteAppletPos>=200) { + return plasmoid.formFactor === PlasmaCore.Types.Horizontal ? Latte.Types.Right : Latte.Types.Bottom; + } + + return Latte.Types.Center; + } + + return latteView.panelUserSetAlignment; + } + + return plasmoid.configuration.plasmoidPosition; + } + } + ///// function initializeHoveredIndex() { @@ -1067,7 +1098,7 @@ Item { width: ( icList.orientation === Qt.Horizontal ) ? icList.width + spacing : smallSize height: ( icList.orientation === Qt.Vertical ) ? icList.height + spacing : smallSize - property int spacing: root.iconSize / 2 + property int spacing: latteView ? 0 : root.iconSize / 2 property int smallSize: Math.max(0.10 * root.iconSize, 16) Behavior on opacity{ @@ -1207,6 +1238,13 @@ Item { } } + /* Rectangle { + anchors.fill: scrollableList + color: "transparent" + border.width: 1 + border.color: "blue" + } */ + TasksLayout.ScrollableList { id: scrollableList width: !root.vertical ? Math.min(root.width, icList.width) : thickness @@ -1214,9 +1252,6 @@ Item { contentWidth: icList.width contentHeight: icList.height - readonly property bool centered: userPanelPosition === Latte.Types.Center - readonly property bool reversed: Qt.application.layoutDirection === Qt.RightToLeft - property int thickness: !thickAnimated ? root.thickMargins + root.iconSize : (root.thickMargins + root.iconSize) * root.zoomFactor readonly property bool thickAnimated: latteView && (latteView.animationsNeedBothAxis>0 || latteView.animationsNeedThickness>0) @@ -1231,15 +1266,8 @@ Item { } } - Rectangle { + TasksLayout.ScrollPositioner { id: listViewBase - x: !root.vertical ? icList.width / 2 : 0 - y: !root.vertical ? 0 : icList.height / 2 - width: !root.vertical ? 1 : scrollableList.width - height: !root.vertical ? scrollableList.height : 1 - color: "transparent" - border.width: 1 - border.color: "transparent"//"purple" ListView { id:icList @@ -1308,7 +1336,7 @@ Item { return undefined; } } - } + } // ScrollPositioner } // ScrollableList TasksLayout.ScrollEdgeShadows { @@ -1316,7 +1344,9 @@ Item { width: !root.vertical ? scrollableList.width : thickness height: !root.vertical ? thickness : scrollableList.height visible: scrollableList.contentsExceed - } + + flickable: scrollableList + } // ScrollEdgeShadows Task.VisualAddItem{ id: newDroppedLauncherVisual @@ -2017,11 +2047,11 @@ Item { //user set Panel Positions // 0-Center, 1-Left, 2-Right, 3-Top, 4-Bottom states: [ - ///Bottom Edge State { name: "bottomCenter" - when: (root.position === PlasmaCore.Types.BottomPosition && userPanelPosition===Latte.Types.Center) + when: ((plasmoid.location===PlasmaCore.Types.BottomEdge || plasmoid.location===PlasmaCore.Types.Floating) + && root.userPanelPosition===Latte.Types.Center) AnchorChanges { target: barLine @@ -2034,7 +2064,8 @@ Item { }, State { name: "bottomLeft" - when: (root.position === PlasmaCore.Types.BottomPosition && userPanelPosition===Latte.Types.Left) + when: ((plasmoid.location===PlasmaCore.Types.BottomEdge || plasmoid.location===PlasmaCore.Types.Floating) + && root.userPanelPosition===Latte.Types.Left) AnchorChanges { target: barLine @@ -2047,7 +2078,8 @@ Item { }, State { name: "bottomRight" - when: (root.position === PlasmaCore.Types.BottomPosition && userPanelPosition===Latte.Types.Right) + when: ((plasmoid.location===PlasmaCore.Types.BottomEdge || plasmoid.location===PlasmaCore.Types.Floating) + && root.userPanelPosition===Latte.Types.Right) AnchorChanges { target: barLine @@ -2061,7 +2093,7 @@ Item { ///Top Edge State { name: "topCenter" - when: (root.position === PlasmaCore.Types.TopPosition && userPanelPosition===Latte.Types.Center) + when: (plasmoid.location===PlasmaCore.Types.TopEdge && root.userPanelPosition===Latte.Types.Center) AnchorChanges { target: barLine @@ -2074,7 +2106,7 @@ Item { }, State { name: "topLeft" - when: (root.position === PlasmaCore.Types.TopPosition && userPanelPosition===Latte.Types.Left) + when: (plasmoid.location===PlasmaCore.Types.TopEdge && root.userPanelPosition===Latte.Types.Left) AnchorChanges { target: barLine @@ -2087,7 +2119,7 @@ Item { }, State { name: "topRight" - when: (root.position === PlasmaCore.Types.TopPosition && userPanelPosition===Latte.Types.Right) + when: (plasmoid.location===PlasmaCore.Types.TopEdge && root.userPanelPosition===Latte.Types.Right) AnchorChanges { target: barLine @@ -2101,7 +2133,7 @@ Item { ////Left Edge State { name: "leftCenter" - when: (root.position === PlasmaCore.Types.LeftPosition && userPanelPosition===Latte.Types.Center) + when: (plasmoid.location===PlasmaCore.Types.LeftEdge && root.userPanelPosition===Latte.Types.Center) AnchorChanges { target: barLine @@ -2114,7 +2146,7 @@ Item { }, State { name: "leftTop" - when: (root.position === PlasmaCore.Types.LeftPosition && userPanelPosition===Latte.Types.Top) + when: (plasmoid.location===PlasmaCore.Types.LeftEdge && root.userPanelPosition===Latte.Types.Top) AnchorChanges { target: barLine @@ -2127,7 +2159,7 @@ Item { }, State { name: "leftBottom" - when: (root.position === PlasmaCore.Types.LeftPosition && userPanelPosition===Latte.Types.Bottom) + when: (plasmoid.location===PlasmaCore.Types.LeftEdge && root.userPanelPosition===Latte.Types.Bottom) AnchorChanges { target: barLine @@ -2141,7 +2173,7 @@ Item { ///Right Edge State { name: "rightCenter" - when: (root.position === PlasmaCore.Types.RightPosition && userPanelPosition===Latte.Types.Center) + when: (plasmoid.location===PlasmaCore.Types.RightEdge && root.userPanelPosition===Latte.Types.Center) AnchorChanges { target: barLine @@ -2154,7 +2186,7 @@ Item { }, State { name: "rightTop" - when: (root.position === PlasmaCore.Types.RightPosition && userPanelPosition===Latte.Types.Top) + when: (plasmoid.location===PlasmaCore.Types.RightEdge && root.userPanelPosition===Latte.Types.Top) AnchorChanges { target: barLine @@ -2167,7 +2199,7 @@ Item { }, State { name: "rightBottom" - when: (root.position === PlasmaCore.Types.RightPosition && userPanelPosition===Latte.Types.Bottom) + when: (plasmoid.location===PlasmaCore.Types.RightEdge && root.userPanelPosition===Latte.Types.Bottom) AnchorChanges { target: barLine diff --git a/plasmoid/package/contents/ui/taskslayout/ScrollEdgeShadows.qml b/plasmoid/package/contents/ui/taskslayout/ScrollEdgeShadows.qml index 99b21efe6..9cad6017a 100644 --- a/plasmoid/package/contents/ui/taskslayout/ScrollEdgeShadows.qml +++ b/plasmoid/package/contents/ui/taskslayout/ScrollEdgeShadows.qml @@ -30,6 +30,8 @@ Item { readonly property int thickness: latteView ? latteView.realPanelSize : root.iconSize + root.thickMargins readonly property color appliedColor: root.appShadowColorSolid + property Item flickable + LinearGradient { id: firstGradient width: !root.vertical ? gradientLength : shadowsContainer.thickness @@ -74,8 +76,8 @@ Item { } AnchorChanges { target: shadowsContainer - anchors{ top:undefined; bottom:parent.bottom; left:undefined; right:undefined; - horizontalCenter:parent.horizontalCenter; verticalCenter:undefined} + anchors{ top:undefined; bottom:flickable.bottom; left:undefined; right:undefined; + horizontalCenter:flickable.horizontalCenter; verticalCenter:undefined} } }, State { @@ -94,8 +96,8 @@ Item { } AnchorChanges { target: shadowsContainer - anchors{ top:parent.top; bottom:undefined; left:undefined; right:undefined; - horizontalCenter:parent.horizontalCenter; verticalCenter:undefined} + anchors{ top:flickable.top; bottom:undefined; left:undefined; right:undefined; + horizontalCenter:flickable.horizontalCenter; verticalCenter:undefined} } }, State { @@ -114,8 +116,8 @@ Item { } AnchorChanges { target: shadowsContainer - anchors{ top:undefined; bottom:undefined; left:parent.left; right:undefined; - horizontalCenter:undefined; verticalCenter:parent.verticalCenter} + anchors{ top:undefined; bottom:undefined; left:flickable.left; right:undefined; + horizontalCenter:undefined; verticalCenter:flickable.verticalCenter} } }, State { @@ -134,8 +136,8 @@ Item { } AnchorChanges { target: shadowsContainer - anchors{ top:undefined; bottom:undefined; left:undefined; right:parent.right; - horizontalCenter:undefined; verticalCenter:parent.verticalCenter} + anchors{ top:undefined; bottom:undefined; left:undefined; right:flickable.right; + horizontalCenter:undefined; verticalCenter:flickable.verticalCenter} } } ] diff --git a/plasmoid/package/contents/ui/taskslayout/ScrollPositioner.qml b/plasmoid/package/contents/ui/taskslayout/ScrollPositioner.qml new file mode 100644 index 000000000..987f94956 --- /dev/null +++ b/plasmoid/package/contents/ui/taskslayout/ScrollPositioner.qml @@ -0,0 +1,60 @@ +/* + * Copyright 2019 Michail Vourlakos + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +import QtQuick 2.7 + +import org.kde.plasma.core 2.0 as PlasmaCore + +import org.kde.latte 0.2 as Latte + +Rectangle { + id: listViewBase + x: { + if (!root.vertical) { + if (root.userPanelPosition === Latte.Types.Center) { + return icList.width / 2; + } else if (root.userPanelPosition === Latte.Types.Left){ + return 0; + } else if (root.userPanelPosition === Latte.Types.Right){ + return icList.width; + } + } else { + return 0; + } + } + + y: { + if (!root.vertical) { + return 0; + } else { + if (root.userPanelPosition === Latte.Types.Center) { + return icList.height / 2; + } else if (root.userPanelPosition === Latte.Types.Top){ + return 0; + } else if (root.userPanelPosition === Latte.Types.Bottom){ + return icList.height; + } + } + } + + width: !root.vertical ? 1 : scrollableList.width + height: !root.vertical ? scrollableList.height : 1 + + color: "transparent" + border.width: 1 + border.color: "transparent" //"purple" +} diff --git a/plasmoid/package/contents/ui/taskslayout/ScrollableList.qml b/plasmoid/package/contents/ui/taskslayout/ScrollableList.qml index 4409541b8..8728c433a 100644 --- a/plasmoid/package/contents/ui/taskslayout/ScrollableList.qml +++ b/plasmoid/package/contents/ui/taskslayout/ScrollableList.qml @@ -31,6 +31,9 @@ Flickable{ property int offset: 0 + readonly property bool centered: userPanelPosition === Latte.Types.Center + readonly property bool reversed: Qt.application.layoutDirection === Qt.RightToLeft + readonly property bool contentsExceed: !root.vertical ? Math.floor(contentWidth) > width : Math.floor(contentHeight) > height readonly property int contentsExtraSpace: { if (contentsExceed) { @@ -53,26 +56,26 @@ Flickable{ readonly property int alignment: { if (plasmoid.location === PlasmaCore.Types.LeftEdge) { if (centered) return Latte.Types.LeftEdgeCenterAlign; - if (root.panelAlignment === Latte.Types.Top) return Latte.Types.LeftEdgeTopAlign; - if (root.panelAlignment === Latte.Types.Bottom) return Latte.Types.LeftEdgeBottomAlign; + if (userPanelPosition === Latte.Types.Top) return Latte.Types.LeftEdgeTopAlign; + if (userPanelPosition === Latte.Types.Bottom) return Latte.Types.LeftEdgeBottomAlign; } if (plasmoid.location === PlasmaCore.Types.RightEdge) { if (centered) return Latte.Types.RightEdgeCenterAlign; - if (root.panelAlignment === Latte.Types.Top) return Latte.Types.RightEdgeTopAlign; - if (root.panelAlignment === Latte.Types.Bottom) return Latte.Types.RightEdgeBottomAlign; + if (userPanelPosition === Latte.Types.Top) return Latte.Types.RightEdgeTopAlign; + if (userPanelPosition === Latte.Types.Bottom) return Latte.Types.RightEdgeBottomAlign; } if (plasmoid.location === PlasmaCore.Types.BottomEdge) { if (centered) return Latte.Types.BottomEdgeCenterAlign; - if ((root.panelAlignment === Latte.Types.Left && !reversed) - || (root.panelAlignment === Latte.Types.Right && reversed)) { + if ((userPanelPosition === Latte.Types.Left && !reversed) + || (userPanelPosition === Latte.Types.Right && reversed)) { return Latte.Types.BottomEdgeLeftAlign; } - if ((root.panelAlignment === Latte.Types.Right && !reversed) - || (root.panelAlignment === Latte.Types.Left && reversed)) { + if ((userPanelPosition === Latte.Types.Right && !reversed) + || (userPanelPosition === Latte.Types.Left && reversed)) { return Latte.Types.BottomEdgeRightAlign; } } @@ -80,13 +83,13 @@ Flickable{ if (plasmoid.location === PlasmaCore.Types.TopEdge) { if (centered) return Latte.Types.TopEdgeCenterAlign; - if ((root.panelAlignment === Latte.Types.Left && !reversed) - || (root.panelAlignment === Latte.Types.Right && reversed)) { + if ((userPanelPosition === Latte.Types.Left && !reversed) + || (userPanelPosition === Latte.Types.Right && reversed)) { return Latte.Types.TopEdgeLeftAlign; } - if ((root.panelAlignment === Latte.Types.Right && !reversed) - || (root.panelAlignment === Latte.Types.Left && reversed)) { + if ((userPanelPosition === Latte.Types.Right && !reversed) + || (userPanelPosition === Latte.Types.Left && reversed)) { return Latte.Types.TopEdgeRightAlign; } } @@ -94,7 +97,6 @@ Flickable{ return Latte.Types.BottomEdgeCenterAlign; } - function increasePos() { if (!root.vertical) { contentX = Math.min(scrollLastPos, contentX + scrollStep);