diff --git a/containment/package/contents/code/HeuristicTools.js b/containment/package/contents/code/HeuristicTools.js index a79acca7..1a8df17c 100644 --- a/containment/package/contents/code/HeuristicTools.js +++ b/containment/package/contents/code/HeuristicTools.js @@ -1,200 +1,200 @@ /* * Copyright 2017-2018 Michail Vourlakos * * This file is part of Latte-Dock * * Latte-Dock 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. * * Latte-Dock 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 . */ //! FILLWIDTH/FILLHEIGHT COMPUTATIONS //! Computations in order to calculate correctly the sizes for applets //! that are requesting fillWidth or fillHeight //! initialize AppletItems flag "inFillCalculations" in orderf //! to inform them that new calculations are taking place function initLayoutForFillsCalculations(layout) { for(var i=0; i=0) && (maxSize !== Infinity)) { curApplet.sizeForFill = maxSize; // console.log("s3_1 "+ maxSize + " _ per applet:" + sizePerApplet); curApplet.inFillCalculations = false; availableSpace = Math.abs(availableSpace - maxSize); noOfApplets = noOfApplets - 1; sizePerApplet = noOfApplets > 1 ? Math.floor(availableSpace / noOfApplets) : availableSpace; // console.log(noOfApplets + " - " + sizePerApplet + " - " + availableSpace); } } return [availableSpace, sizePerApplet, noOfApplets]; } //! during step2/pass2 all the applets with fills //! that remained with no computations from pass1 //! are updated with the algorithm's proposed size function computeStep2ForLayout(layout, sizePerApplet) { for(var i=0; i 0 ? availableSpace / noA : 0 ; var noStart = startLayout.fillApplets; var noMain = mainLayout.fillApplets; var noEnd = endLayout.fillApplets; //! initialize the computations initLayoutForFillsCalculations(startLayout); initLayoutForFillsCalculations(mainLayout); initLayoutForFillsCalculations(endLayout); //console.log("s3..."); var res; //! first pass if (mainLayout.fillApplets > 0){ res = computeStep1ForLayout(mainLayout, availableSpace, sizePerAppletMain, noMain); sizePerAppletMain = res[1]; noMain = res[2]; var dif = (availableSpace - res[0]) / 2; availableSpaceStart = availableSpaceStart - dif; availableSpaceEnd = availableSpaceEnd - dif; } var sizePerAppletStart = startLayout.fillApplets > 0 ? availableSpaceStart / noStart : 0 ; var sizePerAppletEnd = endLayout.fillApplets > 0 ? availableSpaceEnd / noEnd : 0 ; if (startLayout.fillApplets > 0) { res = computeStep1ForLayout(startLayout, availableSpaceStart, sizePerAppletStart, noStart); availableSpaceStart = res[0]; sizePerAppletStart = res[1]; noStart = res[2]; } if (endLayout.fillApplets > 0) { res = computeStep1ForLayout(endLayout, availableSpaceEnd, sizePerAppletEnd, noEnd); availableSpaceEnd = res[0]; sizePerAppletEnd = res[1]; noEnd = res[2]; } //// //! second pass if (mainLayout.shownApplets > 0) { //var bSize = root.isHorizontal ? mainLayout.width : mainLayout.height; sizePerAppletMain = (availableSpaceStart + availableSpaceEnd) / (noStart + noMain + noEnd); computeStep2ForLayout(mainLayout, sizePerAppletMain); // var aSize = root.isHorizontal ? mainLayout.width : mainLayout.height; // availableSpaceStart = availableSpaceStart - aSize/2; // availableSpaceEnd = availableSpaceEnd - aSize/2; sizePerAppletStart = startLayout.fillApplets > 0 ? availableSpaceStart / noStart : 0 ; sizePerAppletEnd = endLayout.fillApplets > 0 ? availableSpaceEnd / noEnd : 0 ; } if (startLayout.fillApplets > 0) computeStep2ForLayout(startLayout, sizePerAppletStart); if (endLayout.fillApplets > 0) computeStep2ForLayout(endLayout, sizePerAppletEnd); } } } diff --git a/containment/package/contents/ui/DebugWindow.qml b/containment/package/contents/ui/DebugWindow.qml index 241b3748..e54ddcb0 100644 --- a/containment/package/contents/ui/DebugWindow.qml +++ b/containment/package/contents/ui/DebugWindow.qml @@ -1,756 +1,756 @@ /* * Copyright 2016 Smith AR * Michail Vourlakos * * This file is part of Latte-Dock * * Latte-Dock 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. * * Latte-Dock 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.1 import QtQuick.Window 2.2 import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.extras 2.0 as PlasmaExtras -import org.kde.latte 0.1 as Latte +import org.kde.latte 0.2 as Latte Window{ width: mainGrid.width + 10 height: Math.min(mainGrid.height+10, Screen.height-root.realSize) visible: true property string space:" : " PlasmaExtras.ScrollArea { id: scrollArea anchors.fill: parent verticalScrollBarPolicy: Qt.ScrollBarAsNeeded horizontalScrollBarPolicy: Qt.ScrollBarAlwaysOff flickableItem.flickableDirection: Flickable.VerticalFlick Grid{ id:mainGrid columns: 2 Text{ text: "Screen id"+space } Text{ text: dock && dock.positioner ? dock.positioner.currentScreenName : "___" } Text{ text: "Screen Geometry"+space } Text{ text: { if (dock && dock.screenGeometry){ return dock.screenGeometry.x+","+dock.screenGeometry.y+ " "+dock.screenGeometry.width+"x"+dock.screenGeometry.height; } else { return "_,_ _x_"; } } } Text{ text: "Window Geometry"+space } Text{ text: { if (dock) { return dock.x + "," + dock.y + " "+dock.width+ "x"+dock.height; } else { return "_,_ _x_"; } } } Text{ text: "On Primary"+space } Text{ text: { if (dock && dock.onPrimary) return "Yes"; else return "No"; } } Text{ text: " ----------- " } Text{ text: " ----------- " } Text{ text: "Contents Width"+space } Text{ text: layoutsContainer.contentsWidth } Text{ text: "Contents Height"+space } Text{ text: layoutsContainer.contentsHeight } Text{ text: "Max Length (user)"+space } Text{ text: plasmoid.configuration.maxLength +"%" } Text{ text: "Max Length (pixels)"+space } Text{ text: root.maxLength } Text{ text: "Offset (pixels)"+space } Text{ text: root.offset } Text{ text: "Mask"+space } Text{ text: { if (dock && dock.effects && dock.effects.mask) { return dock.effects.mask.x +", "+ dock.effects.mask.y+" "+dock.effects.mask.width+"x"+dock.effects.mask.height; } else { return "_,_ _x_"; } } } Text{ text: "Absolute Geometry"+space } Text{ text: { if (dock && dock.absoluteGeometry) { return dock.absoluteGeometry.x + ", " + dock.absoluteGeometry.y + " " + dock.absoluteGeometry.width + "x" + dock.absoluteGeometry.height; } else { return "_,_ _x_"; } } } Text{ text: "Local Geometry"+space } Text{ text: { if (dock && dock.localGeometry) { return dock.localGeometry.x + ", " + dock.localGeometry.y + " " + dock.localGeometry.width + "x" + dock.localGeometry.height; } else { return "_,_ _x_"; } } } Text{ text: "Draw Effects"+space } Text{ text: { if (dock && dock.effects && dock.effects.drawEffects) return "Yes"; else return "No"; } } Text{ text: "Effects Area"+space } Text{ text: { if (dock && dock.effects && dock.effects.rect) { return dock.effects.rect.x + ", " + dock.effects.rect.y + " " +dock.effects.rect.width + "x" + dock.effects.rect.height; } else { return "_,_ _x_"; } } } Text{ text: " ----------- " } Text{ text: " ----------- " } Text{ text: "Is Hidden (flag)"+space } Text{ text: { if (dock && dock.visibility && dock.visibility.isHidden) return "Yes"; else return "No"; } } Text{ text: "Actions Block Hiding "+space } Text{ text: root.actionsBlockHiding } Text{ text: "Contains Mouse (flag)"+space } Text{ text: { if (dock && dock.visibility && dock.visibility.containsMouse) return "Yes"; else return "No"; } } Text{ text: "Edit Mode"+space } Text{ text: { if (root.editMode) return "Yes"; else return "No"; } } Text{ text: " ----------- " } Text{ text: " ----------- " } Text{ text: "Location"+space } Text{ text: { switch(plasmoid.location){ case PlasmaCore.Types.LeftEdge: return "Left Edge"; break; case PlasmaCore.Types.RightEdge: return "Right Edge"; break; case PlasmaCore.Types.TopEdge: return "Top Edge"; break; case PlasmaCore.Types.BottomEdge: return "Bottom Edge"; break; } return " : " + plasmoid.location; } } Text{ text: "Alignment"+space } Text{ text: { switch(plasmoid.configuration.panelPosition){ - case Latte.Dock.Left: + case Latte.Types.Left: return "Left"; break; - case Latte.Dock.Right: + case Latte.Types.Right: return "Right"; break; - case Latte.Dock.Center: + case Latte.Types.Center: return "Center"; break; - case Latte.Dock.Top: + case Latte.Types.Top: return "Top"; break; - case Latte.Dock.Bottom: + case Latte.Types.Bottom: return "Bottom"; break; - case Latte.Dock.Justify: + case Latte.Types.Justify: return "Justify"; break; } return " : " + plasmoid.configuration.panelPosition; } } Text{ text: "Visibility"+space } Text{ text: { if (!dock || !dock.visibility) return ""; switch(dock.visibility.mode){ - case Latte.Dock.AlwaysVisible: + case Latte.Types.AlwaysVisible: return "Always Visible"; break; - case Latte.Dock.AutoHide: + case Latte.Types.AutoHide: return "Auto Hide"; break; - case Latte.Dock.DodgeActive: + case Latte.Types.DodgeActive: return "Dodge Active"; break; - case Latte.Dock.DodgeMaximized: + case Latte.Types.DodgeMaximized: return "Dodge Maximized"; break; - case Latte.Dock.DodgeAllWindows: + case Latte.Types.DodgeAllWindows: return "Dodge All Windows"; break; - case Latte.Dock.None: + case Latte.Types.None: return "None"; break; } return " : " + dock.visibility.mode; } } Text{ text: "Zoom Factor"+space } Text{ text: root.zoomFactor } Text{ text: " ----------- " } Text{ text: " ----------- " } Text{ text: "Icon Size (current)"+space } Text{ text: root.iconSize } Text{ text: "Icon Size (user)"+space } Text{ text: plasmoid.configuration.iconSize } Text{ text: "Icon Size (proportion)"+space } Text{ text: root.proportionIconSize } Text{ text: "Icon Size (auto decrease), Enabled"+space } Text{ text: root.autoDecreaseIconSize } Text{ text: "Icon Size (auto decrease)"+space } Text{ text: root.automaticIconSizeBasedSize } Text{ text: "Icon Margin (pixels)"+space } Text{ text: root.iconMargin } Text{ text: "Icon Margin (user set)"+space } Text{ text: plasmoid.configuration.iconMargin+"%" } Text{ text: "Thick Margin Base"+space } Text{ text: root.thickMarginBase } Text{ text: "Thick Margin High"+space } Text{ text: root.thickMarginHigh } Text{ text: " ----------- " } Text{ text: " ----------- " } Text{ text: "Show Panel Background (user)"+space } Text{ text: { if (plasmoid.configuration.useThemePanel) return "Yes"; else return "No"; } } Text{ text: "Force Transparent Panel (auto)"+space } Text{ text: { if (root.forceTransparentPanel) return "Yes"; else return "No"; } } Text{ text: "Panel Background Length"+space } Text{ text: root.realPanelLength } Text{ text: "Panel Background Thickness(user)"+space } Text{ text: plasmoid.configuration.panelSize + "%" } Text{ text: "Panel Background Thickness(automatic)"+space } Text{ text: root.realPanelSize } Text{ text: "Panel Transparency"+space } Text{ text: root.panelTransparency + "%" } Text{ text: "Panel Shadows Active"+space } Text{ text: { if (root.panelShadowsActive) return "Yes"; else return "No"; } } Text{ text: "Panel Background Shadow"+space } Text{ text: root.panelShadow } Text{ text: "Panel Background Margin"+space } Text{ text: root.panelMargin } Text{ text: " ----------- " } Text{ text: " ----------- " } Text{ text: "Mask - Normal Thickness"+space } Text{ text: visibilityManager.thicknessNormal } Text{ text: "Thickness Uses Panel Size"+space } Text{ text: visibilityManager.panelIsBiggerFromIconSize } Text{ text: "Behave As Plasma Panel"+space } Text{ text: { if (root.behaveAsPlasmaPanel) return "Yes"; else return "No"; } } Text{ text: "Draw Shadows (external)"+space } Text{ text: { if (root.drawShadowsExternal) return "Yes"; else return "No"; } } Text{ text: " ----------- " } Text{ text: " ----------- " } Text{ text: "Applet Hovered"+space } Text{ text: layoutsContainer.hoveredIndex } Text{ text: "Task Hovered"+space } Text{ text: root.latteAppletHoveredIndex } Text{ text: "In Normal State"+space } Text{ text: visibilityManager.normalState } Text{ text: "Animations Both Axis"+space } Text{ text: root.animationsNeedBothAxis } Text{ text: "Animations Only Length"+space } Text{ text: root.animationsNeedLength } Text{ text: "Animations Need Thickness"+space } Text{ text: root.animationsNeedThickness } Text{ text: " ----------- " } Text{ text: " ----------- " } Text{ text: "Start Layout Shown Applets"+space } Text{ text: layoutsContainer.startLayout.shownApplets } Text{ text: "Start Layout Applets (with fill)"+space } Text{ text: layoutsContainer.startLayout.fillApplets } Text{ text: "Start Layout Size (no fill applets)"+space } Text{ text: layoutsContainer.startLayout.sizeWithNoFillApplets+" px." } Text{ text: " ----------- " } Text{ text: " ----------- " } Text{ text: "Main Layout Shown Applets"+space } Text{ text: layoutsContainer.mainLayout.shownApplets } Text{ text: "Main Layout Applets (with fill)"+space } Text{ text: layoutsContainer.mainLayout.fillApplets } Text{ text: "Main Layout Size (no fill applets)"+space } Text{ text: layoutsContainer.mainLayout.sizeWithNoFillApplets+" px." } Text{ text: " ----------- " } Text{ text: " ----------- " } Text{ text: "End Layout Shown Applets"+space } Text{ text: layoutsContainer.endLayout.shownApplets } Text{ text: "End Layout Applets (with fill)"+space } Text{ text: layoutsContainer.endLayout.fillApplets } Text{ text: "End Layout Size (no fill applets)"+space } Text{ text: layoutsContainer.endLayout.sizeWithNoFillApplets+" px." } } } } diff --git a/containment/package/contents/ui/EditModeVisual.qml b/containment/package/contents/ui/EditModeVisual.qml index 810d9d5a..92f80264 100644 --- a/containment/package/contents/ui/EditModeVisual.qml +++ b/containment/package/contents/ui/EditModeVisual.qml @@ -1,359 +1,359 @@ /* * Copyright 2016 Smith AR * Michail Vourlakos * * This file is part of Latte-Dock * * Latte-Dock 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. * * Latte-Dock 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.1 import QtGraphicalEffects 1.0 import org.kde.plasma.plasmoid 2.0 import org.kde.plasma.core 2.0 as PlasmaCore -import org.kde.latte 0.1 as Latte +import org.kde.latte 0.2 as Latte Item{ id: editVisual width: root.isHorizontal ? (dock ? dock.width : root.width) : visibilityManager.thicknessNormalOriginal + theme.defaultFont.pixelSize height: root.isVertical ? (dock ? dock.height : root.height) : visibilityManager.thicknessNormalOriginal + theme.defaultFont.pixelSize opacity: 0 property int speed: Latte.WindowSystem.compositingActive ? root.durationTime*2.8*units.longDuration : 10 property int thickness: visibilityManager.thicknessNormalOriginalValue + root.editShadow property int rootThickness: visibilityManager.thicknessZoomOriginal + root.editShadow - theme.defaultFont.pixelSize property int editLength: root.isHorizontal ? (root.behaveAsPlasmaPanel ? root.width - root.maxIconSize/4 : root.width)://root.maxLength) : (root.behaveAsPlasmaPanel ? root.height - root.maxIconSize/4 : root.height) property real editStateOpacity: 0.95 //root.behaveAsPlasmaPanel ? 0.5 : 0.95// root.blurEnabled ? 0.8 : 0.9 property bool animationSent: false property bool farEdge: (plasmoid.location===PlasmaCore.Types.BottomEdge) || (plasmoid.location===PlasmaCore.Types.RightEdge) property bool editAnimationEnded: false property bool plasmaEditMode: plasmoid.userConfiguring property bool inEditMode: false property rect efGeometry property string layoutColor: root.dockManagedLayout ? root.dockManagedLayout.color : "blue" Item{ id: shadow width: root.isHorizontal ? imageTiler.width + 2*root.editShadow : root.editShadow height: root.isHorizontal ? root.editShadow : imageTiler.height + 2*root.editShadow clip: true visible: !editTransition.running EditShadow{ id: editShadow } states: [ ///topShadow State { name: "topShadow" when: (plasmoid.location === PlasmaCore.Types.BottomEdge) AnchorChanges { target: shadow anchors{ top:undefined; bottom:imageTiler.top; left:undefined; right:undefined; horizontalCenter:imageTiler.horizontalCenter; verticalCenter:undefined} } AnchorChanges { target: editShadow anchors{ top:parent.top; bottom:undefined; left:parent.left; right:undefined; horizontalCenter:parent.horizontalCenter; verticalCenter:parent.undefined} } PropertyChanges{ target: editShadow anchors{ leftMargin: 0; rightMargin:0; topMargin:root.editShadow; bottomMargin:0} } }, ///bottomShadow State { name: "bottomShadow" when: (plasmoid.location === PlasmaCore.Types.TopEdge) AnchorChanges { target: shadow anchors{ top:imageTiler.bottom; bottom:undefined; left:undefined; right:undefined; horizontalCenter:imageTiler.horizontalCenter; verticalCenter:undefined} } AnchorChanges { target: editShadow anchors{ top:undefined; bottom:parent.bottom; left:undefined; right:undefined; horizontalCenter:parent.horizontalCenter; verticalCenter:undefined} } PropertyChanges{ target: editShadow anchors{ leftMargin: 0; rightMargin:0; topMargin:0; bottomMargin:root.editShadow} } }, ///leftShadow State { name: "leftShadow" when: (plasmoid.location === PlasmaCore.Types.RightEdge) AnchorChanges { target: shadow anchors{ top:undefined; bottom:undefined; left:undefined; right:imageTiler.left; horizontalCenter:undefined; verticalCenter:imageTiler.verticalCenter} } AnchorChanges { target: editShadow anchors{ top:undefined; bottom:undefined; left:parent.left; right:undefined; horizontalCenter:undefined; verticalCenter:undefined} } PropertyChanges{ target: editShadow anchors{ leftMargin: root.editShadow; rightMargin:0; topMargin:0; bottomMargin:0} } }, ///rightShadow State { name: "rightShadow" when: (plasmoid.location === PlasmaCore.Types.LeftEdge) AnchorChanges { target: shadow anchors{ top:undefined; bottom:undefined; left:imageTiler.right; right:undefined; horizontalCenter:undefined; verticalCenter:imageTiler.verticalCenter} } AnchorChanges { target: editShadow anchors{ top:undefined; bottom:undefined; left:undefined; right:parent.right; horizontalCenter:undefined; verticalCenter:undefined} } PropertyChanges{ target: editShadow anchors{ leftMargin: 0; rightMargin:root.editShadow; topMargin:0; bottomMargin:0} } } ] } Image{ id: imageTiler anchors.centerIn: parent width: parent.width height: parent.height opacity: editVisual.editStateOpacity fillMode: Image.Tile source: hasBackground ? dock.managedLayout.background : "../icons/"+editVisual.layoutColor+"print.jpg" readonly property bool hasBackground: (dock && dock.managedLayout && dock.managedLayout.background.startsWith("/")) ? true : false } Connections{ target: plasmoid onLocationChanged: initializeEditPosition(); } onRootThicknessChanged: { initializeEditPosition(); } onThicknessChanged: { initializeEditPosition(); } onXChanged: updateEffectsArea(); onYChanged: updateEffectsArea(); onWidthChanged: { /*if (root.isHorizontal) { initializeEditPosition(); }*/ updateEffectsArea(); } onHeightChanged: { /* if (root.isVertical) { initializeEditPosition(); }*/ updateEffectsArea(); } function updateEffectsArea(){ if (!dock || state !== "edit" || !editAnimationEnded) return; var rootGeometry = mapToItem(root, 0, 0); efGeometry.x = rootGeometry.x; efGeometry.y = rootGeometry.y; efGeometry.width = width; efGeometry.height = height; dock.effects.rect = efGeometry; } function initializeNormalPosition() { if (plasmoid.location === PlasmaCore.Types.BottomEdge) { y = rootThickness; x = 0; } 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) { y = -editVisual.thickness; x = 0; } } function initializeEditPosition() { if (root.editMode) { if (plasmoid.location === PlasmaCore.Types.LeftEdge){ x = 0; y = 0; } else if (plasmoid.location === PlasmaCore.Types.TopEdge) { x = 0; y = 0; } else if (plasmoid.location === PlasmaCore.Types.BottomEdge) { x = 0; y = rootThickness - thickness; } else if (plasmoid.location === PlasmaCore.Types.RightEdge) { x = rootThickness - thickness; y = 0; } } } //////////// States //////////////////// states: [ State{ name: "*" when: !plasmaEditMode }, State{ name: "edit" when: plasmaEditMode } ] transitions: [ Transition{ id: editTransition from: "*" to: "edit" SequentialAnimation{ id:normalAnimationTransition ScriptAction{ script:{ editVisual.inEditMode = true; editVisual.opacity = 0 editVisual.editAnimationEnded = false; initializeNormalPosition(); if(!animationSent) { animationSent = true; root.slotAnimationsNeedLength(1); } } } ParallelAnimation{ PropertyAnimation { target: editVisual property: "opacity" to: 1 duration: editVisual.speed / 2 easing.type: Easing.OutQuad } PropertyAnimation { target: editVisual property: root.isHorizontal ? "y" : "x" to: editVisual.farEdge ? editVisual.rootThickness - editVisual.thickness : 0 duration: editVisual.speed easing.type: Easing.OutQuad } } ScriptAction{ script:{ editVisual.editAnimationEnded = true; updateEffectsArea(); updateAutomaticIconSize(); visibilityManager.updateMaskArea(); } } } }, Transition{ from: "edit" to: "*" SequentialAnimation{ ScriptAction{ script: { //! remove kwin effects when starting the animation dock.effects.rect = Qt.rect(-1, -1, 0, 0); } } ParallelAnimation{ PropertyAnimation { target: editVisual property: root.isHorizontal ? "y" : "x" to: editVisual.farEdge ? editVisual.rootThickness : -editVisual.thickness duration: editVisual.speed easing.type: Easing.InQuad } PropertyAnimation { target: editVisual property: "opacity" to: 0 duration: editVisual.speed easing.type: Easing.InQuad } } ScriptAction{ script:{ editVisual.inEditMode = false; editVisual.editAnimationEnded = false; if (editVisual.animationSent) { root.slotAnimationsNeedLength(-1); editVisual.animationSent = false; } if (visibilityManager.inTempHiding) { visibilityManager.sendHideDockDuringLocationChangeFinished(); } } } } } ] } diff --git a/containment/package/contents/ui/EditShadow.qml b/containment/package/contents/ui/EditShadow.qml index 2a48d140..9b9f99f9 100644 --- a/containment/package/contents/ui/EditShadow.qml +++ b/containment/package/contents/ui/EditShadow.qml @@ -1,40 +1,40 @@ /* * Copyright 2016 Smith AR * Michail Vourlakos * * This file is part of Latte-Dock * * Latte-Dock 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. * * Latte-Dock 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.1 import org.kde.plasma.core 2.0 as PlasmaCore import QtGraphicalEffects 1.0 -import org.kde.latte 0.1 as Latte +import org.kde.latte 0.2 as Latte Rectangle{ width: imageTiler.width height: imageTiler.height color: "white" layer.enabled: true layer.effect: DropShadow { radius: root.editShadow fast: true samples: 2 * radius color: "#040404" } } diff --git a/containment/package/contents/ui/LayoutsContainer.qml b/containment/package/contents/ui/LayoutsContainer.qml index 84b128e0..842a9bcc 100644 --- a/containment/package/contents/ui/LayoutsContainer.qml +++ b/containment/package/contents/ui/LayoutsContainer.qml @@ -1,700 +1,700 @@ /* * Copyright 2016 Smith AR * Michail Vourlakos * * This file is part of Latte-Dock * * Latte-Dock 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. * * Latte-Dock 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.1 import QtQuick.Layouts 1.1 import org.kde.plasma.plasmoid 2.0 import org.kde.plasma.core 2.0 as PlasmaCore -import org.kde.latte 0.1 as Latte +import org.kde.latte 0.2 as Latte import "../code/HeuristicTools.js" as HeuristicTools Item{ id: layoutsContainer readonly property bool isHidden: root.inStartup || (dock && dock.visibility && dock.visibility.isHidden) - readonly property bool useMaxLength: (plasmoid.configuration.panelPosition === Latte.Dock.Justify) + readonly property bool useMaxLength: (plasmoid.configuration.panelPosition === Latte.Types.Justify) && ((!root.editMode && !root.behaveAsPlasmaPanel ) || (behaveAsPlasmaPanel && root.editMode)) property int allCount: root.latteApplet ? _mainLayout.count-1+latteApplet.tasksCount : _mainLayout.count property int currentSpot: -1000 property int hoveredIndex: -1 readonly property int fillApplets: _startLayout.fillApplets + _mainLayout.fillApplets + _endLayout.fillApplets property Item startLayout : _startLayout property Item mainLayout: _mainLayout property Item endLayout: _endLayout Binding { target: layoutsContainer property: "x" value: { if ( dock && root.isHorizontal && useMaxLength ){ return ((dock.width/2) - (root.maxLength/2)); // + root.offset) } else { if ((visibilityManager.inSlidingIn || visibilityManager.inSlidingOut) && root.isVertical){ return; } if (layoutsContainer.isHidden && root.isVertical) { if (Latte.WindowSystem.compositingActive) { return visibilityManager.slidingOutToPos; } else { if ((plasmoid.location===PlasmaCore.Types.LeftEdge)||(plasmoid.location===PlasmaCore.Types.TopEdge)) { return visibilityManager.slidingOutToPos + 1; } else { return visibilityManager.slidingOutToPos - 1; } } } else { return 0; } } } } Binding{ target: layoutsContainer property: "y" value: { if ( dock && root.isVertical && useMaxLength ) { return ((dock.height/2) - (root.maxLength/2));// + root.offset); } else { if ((visibilityManager.inSlidingIn || visibilityManager.inSlidingOut) && root.isHorizontal){ return; } if (layoutsContainer.isHidden && root.isHorizontal) { if (Latte.WindowSystem.compositingActive) { return visibilityManager.slidingOutToPos; } else { if ((plasmoid.location===PlasmaCore.Types.LeftEdge)||(plasmoid.location===PlasmaCore.Types.TopEdge)) { return visibilityManager.slidingOutToPos + 1; } else { return visibilityManager.slidingOutToPos - 1; } } } else { return 0; } } } } width: root.isHorizontal && useMaxLength ? root.maxLength : parent.width height: root.isVertical && useMaxLength ? root.maxLength : parent.height z:10 property bool animationSent: false - property bool shouldCheckHalfs: (plasmoid.configuration.panelPosition === Latte.Dock.Justify) && (_mainLayout.children>1) + property bool shouldCheckHalfs: (plasmoid.configuration.panelPosition === Latte.Types.Justify) && (_mainLayout.children>1) property int contentsWidth: _startLayout.width + _mainLayout.width + _endLayout.width property int contentsHeight: _startLayout.height + _mainLayout.height + _endLayout.height onContentsWidthChanged: { if (root.isHorizontal){ var firstHalfExited = false; var secondHalfExited = false; if (shouldCheckHalfs){ firstHalfExited = ( (_startLayout.width + _mainLayout.width/2) >= root.maxLength/2 ); secondHalfExited = ( (_endLayout.width + _mainLayout.width/2) >= root.maxLength/2 ); } if (dock && ((contentsWidth >= root.maxLength) || firstHalfExited || secondHalfExited)) { updateAutomaticIconSize(); } if (!animationSent) { animationSent = true; slotAnimationsNeedLength(1); } layoutsContainer.updateSizeForAppletsInFill(); delayUpdateMaskArea.start(); } } onContentsHeightChanged: { if (root.isVertical){ var firstHalfExited = false; var secondHalfExited = false; if (shouldCheckHalfs){ firstHalfExited = ( (_startLayout.height + _mainLayout.height/2) >= root.maxLength/2 ); secondHalfExited = ( (_endLayout.height + _mainLayout.height/2) >= root.maxLength/2 ); } if (dock && ((contentsHeight >= root.maxLength) || firstHalfExited || secondHalfExited)) { updateAutomaticIconSize(); } if (!animationSent) { animationSent = true; slotAnimationsNeedLength(1); } layoutsContainer.updateSizeForAppletsInFill(); delayUpdateMaskArea.start(); } } onXChanged: root.updateEffectsArea(); onYChanged: root.updateEffectsArea(); Grid{ id:_startLayout columns: root.isVertical ? 1 : 0 columnSpacing: 0 flow: isHorizontal ? Grid.LeftToRight : Grid.TopToBottom rows: root.isHorizontal ? 1 : 0 rowSpacing: 0 Layout.preferredWidth: width Layout.preferredHeight: height property int beginIndex: 0 property int count: children.length //it is used in calculations for fillWidth,fillHeight applets property int sizeWithNoFillApplets: 0 Binding{ target: _startLayout property:"sizeWithNoFillApplets" when: _startLayout value: { if (!visibilityManager || !visibilityManager.normalState) return; var space = 0; for (var i=0; i<_startLayout.children.length; ++i){ if (_startLayout.children[i] && !_startLayout.children[i].needsFillSpace) { space = root.isHorizontal ? space + _startLayout.children[i].width : space + _startLayout.children[i].height; } } return space; } } property int shownApplets: { var res = 0; for (var i=0; i * Michail Vourlakos * * This file is part of Latte-Dock * * Latte-Dock 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. * * Latte-Dock 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.1 import QtQuick.Layouts 1.1 import QtQuick.Window 2.2 import org.kde.plasma.plasmoid 2.0 import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.components 2.0 as PlasmaComponents import org.kde.kquickcontrolsaddons 2.0 import "colorizer" as Colorizer -import org.kde.latte 0.1 as Latte +import org.kde.latte 0.2 as Latte Item{ id:barLine width: root.isHorizontal ? panelWidth : smallSize height: root.isVertical ? panelHeight : smallSize opacity: root.useThemePanel ? 1 : 0 property int animationTime: 6*root.durationTime*units.shortDuration property int lengthMargins: { return root.isVertical ? shadowsSvgItem.marginsHeight : shadowsSvgItem.marginsWidth } property int panelWidth: { if (root.behaveAsPlasmaPanel && !root.editMode) { return root.width; } else { - if ((root.panelAlignment === Latte.Dock.Justify) && root.isHorizontal) { + if ((root.panelAlignment === Latte.Types.Justify) && root.isHorizontal) { return root.maxLength; } else { return layoutsContainer.mainLayout.width + spacing; } } } property int panelHeight: { if (root.behaveAsPlasmaPanel && !root.editMode) { return root.height; } else { - if ((root.panelAlignment === Latte.Dock.Justify) && root.isVertical) { + if ((root.panelAlignment === Latte.Types.Justify) && root.isVertical) { return root.maxLength; } else { return layoutsContainer.mainLayout.height + spacing; } } } property int spacing: { if (!Latte.WindowSystem.compositingActive) { return 0; - } else if (root.panelAlignment === Latte.Dock.Justify && plasmoid.configuration.maxLength === 100) { + } else if (root.panelAlignment === Latte.Types.Justify && plasmoid.configuration.maxLength === 100) { return 0; - } else if (root.panelAlignment === Latte.Dock.Center || root.panelAlignment === Latte.Dock.Justify || root.offset!==0) { + } else if (root.panelAlignment === Latte.Types.Center || root.panelAlignment === Latte.Types.Justify || root.offset!==0) { return root.panelEdgeSpacing/2; } else { return root.panelEdgeSpacing/4; } } property int smallSize: Math.max(3.7*root.statesLineSize, 16) Behavior on opacity{ enabled: Latte.WindowSystem.compositingActive NumberAnimation { duration: barLine.animationTime } } Behavior on opacity{ enabled: !Latte.WindowSystem.compositingActive NumberAnimation { duration: 0 } } Binding { target: root property: "realPanelLength" value: root.isVertical ? barLine.height : barLine.width } Binding { target: root property: "totalPanelEdgeSpacing" value: spacing } onXChanged: solidBackground.updateEffectsArea(); onYChanged: solidBackground.updateEffectsArea(); /// plasmoid's default panel /* BorderImage{ anchors.fill:parent source: "../images/panel-west.png" border { left:8; right:8; top:8; bottom:8 } opacity: (!root.useThemePanel) ? 1 : 0 visible: (opacity == 0) ? false : true horizontalTileMode: BorderImage.Stretch verticalTileMode: BorderImage.Stretch Behavior on opacity{ NumberAnimation { duration: 200 } } }*/ /// the current theme's panel PlasmaCore.FrameSvgItem{ id: shadowsSvgItem width: root.isVertical ? panelSize + marginsWidth - (solidBackground.leftIncreaser + solidBackground.rightIncreaser) : Math.min(parent.width + marginsWidth, root.width - marginsWidth) height: root.isVertical ? Math.min(parent.height + marginsHeight, root.height - marginsHeight) : panelSize + marginsHeight - (solidBackground.topIncreaser + solidBackground.bottomIncreaser) imagePath: root.behaveAsPlasmaPanel || !Latte.WindowSystem.compositingActive || !root.panelShadowsActive || !themeHasShadow ? "" : "widgets/panel-background" prefix: root.behaveAsPlasmaPanel || !Latte.WindowSystem.compositingActive || !root.panelShadowsActive || !themeHasShadow ? "" : "shadow" visible: (opacity == 0) ? false : true opacity: { if (root.forceTransparentPanel || !root.useThemePanel) return 0; else return 1; } enabledBorders: dock && dock.effects ? dock.effects.enabledBorders : PlasmaCore.FrameSvg.NoBorder //! set true by default in order to avoid crash on startup because imagePath is set to "" readonly property bool themeHasShadow: themeExtended ? themeExtended.hasShadow : true Behavior on opacity { enabled: Latte.WindowSystem.compositingActive NumberAnimation { duration: barLine.animationTime } } Behavior on opacity{ enabled: !Latte.WindowSystem.compositingActive NumberAnimation { duration: 0 } } property int marginsWidth: { if (imagePath === "") { return 0; } else { - if (root.panelAlignment === Latte.Dock.Left && root.offset===0) + if (root.panelAlignment === Latte.Types.Left && root.offset===0) return margins.right; - else if (root.panelAlignment === Latte.Dock.Right && root.offset===0) + else if (root.panelAlignment === Latte.Types.Right && root.offset===0) return margins.left; else return margins.left+margins.right; } } property int marginsHeight: { if (imagePath === "") { return 0; } else { - if (root.panelAlignment === Latte.Dock.Top && root.offset===0) + if (root.panelAlignment === Latte.Types.Top && root.offset===0) return margins.bottom; - else if (root.panelAlignment === Latte.Dock.Bottom && root.offset===0) + else if (root.panelAlignment === Latte.Types.Bottom && root.offset===0) return margins.top; else return margins.top + margins.bottom; } } property int panelSize: automaticPanelSize property int automaticPanelSize: { if (root.behaveAsPlasmaPanel) { return root.statesLineSize + root.iconSize + root.thickMargin; } else { var icons = root.statesLineSize + root.iconSize + root.thickMargin + 1; var panels = root.themePanelSize + root.panelMargin; root.realPanelThickness = icons; if (icons > panels) { return panels; } else { return icons; } } } property int shadowsSize: 0 Binding{ target: shadowsSvgItem property: "shadowsSize" value:{ if (shadowsSvgItem && !root.behaveAsPlasmaPanel && root.useThemePanel && root.panelShadowsActive){ if (root.isVertical){ if (plasmoid.location === PlasmaCore.Types.LeftEdge) return shadowsSvgItem.margins.right; else if (plasmoid.location === PlasmaCore.Types.RightEdge) return shadowsSvgItem.margins.left; } else { if (plasmoid.location === PlasmaCore.Types.BottomEdge) return shadowsSvgItem.margins.top; else if (plasmoid.location === PlasmaCore.Types.TopEdge) return shadowsSvgItem.margins.bottom; } } else { return 0; } } } Behavior on opacity{ enabled: Latte.WindowSystem.compositingActive NumberAnimation { duration: barLine.animationTime } } Behavior on opacity{ enabled: !Latte.WindowSystem.compositingActive NumberAnimation { duration: 0 } } Binding { target: root property: "panelShadow" when: shadowsSvgItem value: shadowsSvgItem.shadowsSize } Binding { target: root property: "realPanelSize" when: shadowsSvgItem value: shadowsSvgItem.panelSize } Binding { target: root property: "panelMarginLength" when: shadowsSvgItem value: root.isVertical ? shadowsSvgItem.marginsHeight : shadowsSvgItem.marginsWidth } //! This is used to provide real solidness without any transparency from the plasma theme Rectangle{ id: solidBackgroundRectangle anchors.fill: solidBackground color: theme.backgroundColor opacity: behaveAsPlasmaPanel && solidBackground.forceSolidness && plasmoid.configuration.maxLength === 100 ? 1 : 0 Behavior on opacity{ enabled: Latte.WindowSystem.compositingActive NumberAnimation { duration: 2 * barLine.animationTime } } Behavior on opacity{ enabled: !Latte.WindowSystem.compositingActive NumberAnimation { duration: 0 } } } PlasmaCore.FrameSvgItem{ id: solidBackground anchors.leftMargin: Latte.WindowSystem.compositingActive ? shadowsSvgItem.margins.left - leftIncreaser : 0 anchors.rightMargin: Latte.WindowSystem.compositingActive ? shadowsSvgItem.margins.right - rightIncreaser : 0 anchors.topMargin: Latte.WindowSystem.compositingActive ? shadowsSvgItem.margins.top - topIncreaser : 0 anchors.bottomMargin: Latte.WindowSystem.compositingActive ? shadowsSvgItem.margins.bottom - bottomIncreaser : 0 anchors.fill:parent opacity: { if (forceSolidness) { return 1; } else if (!plasmoid.configuration.useThemePanel && plasmoid.configuration.solidBackgroundForMaximized) { return 0; } else { return plasmoid.configuration.panelTransparency / 100; } } readonly property bool forceSolidness: (root.solidPanel && !plasmoid.configuration.solidBackgroundForMaximized) || root.forceSolidPanel || !Latte.WindowSystem.compositingActive property rect efGeometry: Qt.rect(-1,-1,0,0) imagePath: root.solidPanel ? "opaque/dialogs/background" : "widgets/panel-background" onWidthChanged: updateEffectsArea(); onHeightChanged: updateEffectsArea(); Component.onCompleted: { root.updateEffectsArea.connect(updateEffectsArea); adjustPrefix(); } Component.onDestruction: { root.updateEffectsArea.disconnect(updateEffectsArea); } Binding{ target: root property: "currentPanelTransparency" value: solidBackground.opacity * 100 } Connections{ target: root onEditModeChanged: { if (!root.editMode){ solidBackground.updateEffectsArea(); } } onSolidPanelChanged: { adjustPrefix(); } } //! Fix for FrameSvgItem QML version not updating its margins after a theme change //! with this hack we enforce such update. I could use the repaintNeeded signal but //! it is called more often than the themeChanged one. Connections{ target: themeExtended onThemeChanged: { solidBackground.adjustPrefix(); plasmoid.configuration.panelShadows = !plasmoid.configuration.panelShadows; plasmoid.configuration.panelShadows = !plasmoid.configuration.panelShadows; updateEffectsArea(); } } Connections{ target: plasmoid onLocationChanged: solidBackground.adjustPrefix(); } function updateEffectsArea(){ if (!dock || root.editMode) return; var rootGeometry = mapToItem(root, 0, 0); efGeometry.x = rootGeometry.x; efGeometry.y = rootGeometry.y; efGeometry.width = width; efGeometry.height = height; dock.effects.rect = efGeometry; if (!Latte.WindowSystem.compositingActive) { visibilityManager.updateMaskArea(); } } //! the increases used when the user forces a solid background and the background //! must be increased in order to look ok in the corners property int rightIncreaser: { if (!(root.solidPanel && root.isVertical && plasmoid.location === PlasmaCore.Types.LeftEdge) || !Latte.WindowSystem.compositingActive) return 0; else return hiddenPanelBackground.margins.right; } property int leftIncreaser: { if (!(root.solidPanel && root.isVertical && plasmoid.location === PlasmaCore.Types.RightEdge) || !Latte.WindowSystem.compositingActive) return 0; else return hiddenPanelBackground.margins.left; } property int topIncreaser: { if (!(root.solidPanel && root.isVertical && plasmoid.location === PlasmaCore.Types.BottomEdge) || !Latte.WindowSystem.compositingActive) return 0; else return hiddenPanelBackground.margins.top; } property int bottomIncreaser: { if (!(root.solidPanel && root.isVertical && plasmoid.location === PlasmaCore.Types.TopEdge) || !Latte.WindowSystem.compositingActive) return 0; else return hiddenPanelBackground.margins.bottom; } Binding { target: root property: "panelMargin" value: { if (root.useThemePanel){ if (root.isVertical){ if (plasmoid.location === PlasmaCore.Types.LeftEdge) return solidBackground.margins.right; else if (plasmoid.location === PlasmaCore.Types.RightEdge) return solidBackground.margins.left; } else { if (plasmoid.location === PlasmaCore.Types.BottomEdge) return solidBackground.margins.top; else if (plasmoid.location === PlasmaCore.Types.TopEdge) return solidBackground.margins.bottom; } } } } onRepaintNeeded: { if (root.behaveAsPlasmaPanel) adjustPrefix(); } enabledBorders: dock && dock.effects ? dock.effects.enabledBorders : PlasmaCore.FrameSvg.NoBorder Behavior on opacity{ enabled: Latte.WindowSystem.compositingActive NumberAnimation { duration: barLine.animationTime } } Behavior on opacity{ enabled: !Latte.WindowSystem.compositingActive NumberAnimation { duration: 0 } } function adjustPrefix() { if (!plasmoid) { return ""; } var pre; switch (plasmoid.location) { case PlasmaCore.Types.LeftEdge: pre = "west"; break; case PlasmaCore.Types.TopEdge: pre = "north"; break; case PlasmaCore.Types.RightEdge: pre = "east"; break; case PlasmaCore.Types.BottomEdge: pre = "south"; break; default: prefix = ""; } prefix = [pre, ""]; } } Colorizer.CustomBackground { anchors.fill: solidBackground opacity: root.forceColorizeFromActiveWindowScheme ? solidBackground.opacity : 0 backgroundColor: root.forceColorizeFromActiveWindowScheme ? dock.visibility.touchingWindowScheme.backgroundColor : "transparent" roundness: { if (themeExtended) { switch(plasmoid.location) { case PlasmaCore.Types.BottomEdge: return themeExtended.bottomEdgeRoundness; case PlasmaCore.Types.LeftEdge: return themeExtended.leftEdgeRoundness; case PlasmaCore.Types.TopEdge: return themeExtended.topEdgeRoundness; case PlasmaCore.Types.RightEdge: return themeExtended.rightEdgeRoundness; default: return 0; } } return 0; } } PlasmaCore.FrameSvgItem{ id: hiddenPanelBackground imagePath: "widgets/panel-background" visible: false } } transitions: Transition { enabled: editModeVisual.plasmaEditMode AnchorAnimation { duration: 0.8 * root.animationTime easing.type: Easing.OutCubic } } //BEGIN states //user set Panel Positions //0-Center, 1-Left, 2-Right, 3-Top, 4-Bottom states: [ ///Left State { name: "leftCenterOrJustify" - when: (plasmoid.location === PlasmaCore.Types.LeftEdge)&&(root.panelAlignment === Latte.Dock.Center || root.panelAlignment === Latte.Dock.Justify) + when: (plasmoid.location === PlasmaCore.Types.LeftEdge)&&(root.panelAlignment === Latte.Types.Center || root.panelAlignment === Latte.Types.Justify) AnchorChanges { target: barLine anchors{ top:undefined; bottom:undefined; left:parent.left; right:undefined; horizontalCenter:undefined; verticalCenter:parent.verticalCenter} } AnchorChanges { target: shadowsSvgItem anchors{ top:undefined; bottom:undefined; left:parent.left; right:undefined; horizontalCenter:undefined; verticalCenter:parent.verticalCenter} } PropertyChanges{ target: barLine anchors.leftMargin: 0; anchors.rightMargin:0; anchors.topMargin:0; anchors.bottomMargin:0; - anchors.horizontalCenterOffset: 0; anchors.verticalCenterOffset: (root.panelAlignment === Latte.Dock.Center ? root.offset : 0); + anchors.horizontalCenterOffset: 0; anchors.verticalCenterOffset: (root.panelAlignment === Latte.Types.Center ? root.offset : 0); } }, ///Left State { name: "leftTop" - when: (plasmoid.location === PlasmaCore.Types.LeftEdge)&&(root.panelAlignment === Latte.Dock.Top) + when: (plasmoid.location === PlasmaCore.Types.LeftEdge)&&(root.panelAlignment === Latte.Types.Top) AnchorChanges { target: barLine anchors{ top:parent.top; bottom:undefined; left:parent.left; right:undefined; horizontalCenter:undefined; verticalCenter:undefined} } AnchorChanges { target: shadowsSvgItem anchors{ top:parent.top; bottom:undefined; left:parent.left; right:undefined; horizontalCenter:undefined; verticalCenter:undefined} } PropertyChanges{ target: barLine anchors.leftMargin: 0; anchors.rightMargin:0; anchors.topMargin:root.offset; anchors.bottomMargin:0; anchors.horizontalCenterOffset: 0; anchors.verticalCenterOffset: 0; } }, ///Left State { name: "leftBottom" - when: (plasmoid.location === PlasmaCore.Types.LeftEdge)&&(root.panelAlignment === Latte.Dock.Bottom) + when: (plasmoid.location === PlasmaCore.Types.LeftEdge)&&(root.panelAlignment === Latte.Types.Bottom) AnchorChanges { target: barLine anchors{ top:undefined; bottom:parent.bottom; left:parent.left; right:undefined; horizontalCenter:undefined; verticalCenter:undefined} } AnchorChanges { target: shadowsSvgItem anchors{ top:undefined; bottom:parent.bottom; left:parent.left; right:undefined; horizontalCenter:undefined; verticalCenter:undefined} } PropertyChanges{ target: barLine anchors.leftMargin: 0; anchors.rightMargin:0; anchors.topMargin:0; anchors.bottomMargin:root.offset; anchors.horizontalCenterOffset: 0; anchors.verticalCenterOffset: 0; } }, ///Right State { name: "rightCenterOrJustify" - when: (plasmoid.location === PlasmaCore.Types.RightEdge)&&(root.panelAlignment === Latte.Dock.Center || root.panelAlignment === Latte.Dock.Justify) + when: (plasmoid.location === PlasmaCore.Types.RightEdge)&&(root.panelAlignment === Latte.Types.Center || root.panelAlignment === Latte.Types.Justify) AnchorChanges { target: barLine anchors{ top:undefined; bottom:undefined; left:undefined; right:parent.right; horizontalCenter:undefined; verticalCenter:parent.verticalCenter} } AnchorChanges { target: shadowsSvgItem anchors{ top:undefined; bottom:undefined; left:undefined; right:parent.right; horizontalCenter:undefined; verticalCenter:parent.verticalCenter} } PropertyChanges{ target: barLine anchors.leftMargin: 0; anchors.rightMargin:0; anchors.topMargin:0; anchors.bottomMargin:0; - anchors.horizontalCenterOffset: 0; anchors.verticalCenterOffset: (root.panelAlignment === Latte.Dock.Center ? root.offset : 0); + anchors.horizontalCenterOffset: 0; anchors.verticalCenterOffset: (root.panelAlignment === Latte.Types.Center ? root.offset : 0); } }, State { name: "rightTop" - when: (plasmoid.location === PlasmaCore.Types.RightEdge)&&(root.panelAlignment === Latte.Dock.Top) + when: (plasmoid.location === PlasmaCore.Types.RightEdge)&&(root.panelAlignment === Latte.Types.Top) AnchorChanges { target: barLine anchors{ top:parent.top; bottom:undefined; left:undefined; right:parent.right; horizontalCenter:undefined; verticalCenter:undefined} } AnchorChanges { target: shadowsSvgItem anchors{ top:parent.top; bottom:undefined; left:undefined; right:parent.right; horizontalCenter:undefined; verticalCenter:undefined} } PropertyChanges{ target: barLine anchors.leftMargin: 0; anchors.rightMargin:0; anchors.topMargin:root.offset; anchors.bottomMargin:0; anchors.horizontalCenterOffset: 0; anchors.verticalCenterOffset: 0; } }, State { name: "rightBottom" - when: (plasmoid.location === PlasmaCore.Types.RightEdge)&&(root.panelAlignment === Latte.Dock.Bottom) + when: (plasmoid.location === PlasmaCore.Types.RightEdge)&&(root.panelAlignment === Latte.Types.Bottom) AnchorChanges { target: barLine anchors{ top:undefined; bottom:parent.bottom; left:undefined; right:parent.right; horizontalCenter:undefined; verticalCenter:undefined } } AnchorChanges { target: shadowsSvgItem anchors{ top:undefined; bottom:parent.bottom; left:undefined; right:parent.right; horizontalCenter:undefined; verticalCenter:undefined} } PropertyChanges{ target: barLine anchors.leftMargin: 0; anchors.rightMargin:0; anchors.topMargin:0; anchors.bottomMargin:root.offset; anchors.horizontalCenterOffset: 0; anchors.verticalCenterOffset: 0; } }, ///Bottom State { name: "bottomCenterOrJustify" - when: (plasmoid.location === PlasmaCore.Types.BottomEdge)&&(root.panelAlignment === Latte.Dock.Center || root.panelAlignment === Latte.Dock.Justify) + when: (plasmoid.location === PlasmaCore.Types.BottomEdge)&&(root.panelAlignment === Latte.Types.Center || root.panelAlignment === Latte.Types.Justify) AnchorChanges { target: barLine anchors{ top:undefined; bottom:parent.bottom; left:undefined; right:undefined; horizontalCenter:parent.horizontalCenter; verticalCenter:undefined} } AnchorChanges { target: shadowsSvgItem anchors{ top:undefined; bottom:parent.bottom; left:undefined; right:undefined; horizontalCenter:parent.horizontalCenter; verticalCenter:undefined} } PropertyChanges{ target: barLine anchors.leftMargin: 0; anchors.rightMargin:0; anchors.topMargin:0; anchors.bottomMargin:0; - anchors.horizontalCenterOffset: (root.panelAlignment === Latte.Dock.Center ? root.offset : 0); anchors.verticalCenterOffset: 0; + anchors.horizontalCenterOffset: (root.panelAlignment === Latte.Types.Center ? root.offset : 0); anchors.verticalCenterOffset: 0; } }, State { name: "bottomLeft" when: (plasmoid.location === PlasmaCore.Types.BottomEdge) - &&(((root.panelAlignment === Latte.Dock.Left)&&(Qt.application.layoutDirection !== Qt.RightToLeft)) - || ((root.panelAlignment === Latte.Dock.Right)&&(Qt.application.layoutDirection === Qt.RightToLeft))) + &&(((root.panelAlignment === Latte.Types.Left)&&(Qt.application.layoutDirection !== Qt.RightToLeft)) + || ((root.panelAlignment === Latte.Types.Right)&&(Qt.application.layoutDirection === Qt.RightToLeft))) AnchorChanges { target: barLine anchors{ top:undefined; bottom:parent.bottom; left:parent.left; right:undefined; horizontalCenter:undefined; verticalCenter:undefined} } AnchorChanges { target: shadowsSvgItem anchors{ top:undefined; bottom:parent.bottom; left:parent.left; right:undefined; horizontalCenter:undefined; verticalCenter:undefined} } PropertyChanges{ target: barLine anchors.leftMargin: root.offset; anchors.rightMargin:0; anchors.topMargin:0; anchors.bottomMargin:0; anchors.horizontalCenterOffset: 0; anchors.verticalCenterOffset: 0; } }, State { name: "bottomRight" when: (plasmoid.location === PlasmaCore.Types.BottomEdge) - &&(((root.panelAlignment === Latte.Dock.Right)&&(Qt.application.layoutDirection !== Qt.RightToLeft)) - ||((root.panelAlignment === Latte.Dock.Left)&&(Qt.application.layoutDirection === Qt.RightToLeft))) + &&(((root.panelAlignment === Latte.Types.Right)&&(Qt.application.layoutDirection !== Qt.RightToLeft)) + ||((root.panelAlignment === Latte.Types.Left)&&(Qt.application.layoutDirection === Qt.RightToLeft))) AnchorChanges { target: barLine anchors{ top:undefined; bottom:parent.bottom; left:undefined; right:parent.right; horizontalCenter:undefined; verticalCenter:undefined} } AnchorChanges { target: shadowsSvgItem anchors{ top:undefined; bottom:parent.bottom; left:undefined; right:parent.right; horizontalCenter:undefined; verticalCenter:undefined} } PropertyChanges{ target: barLine anchors.leftMargin: 0; anchors.rightMargin:root.offset; anchors.topMargin:0; anchors.bottomMargin:0; anchors.horizontalCenterOffset: 0; anchors.verticalCenterOffset: 0; } }, ///Top State { name: "topCenterOrJustify" - when: (plasmoid.location === PlasmaCore.Types.TopEdge)&&(root.panelAlignment === Latte.Dock.Center || root.panelAlignment === Latte.Dock.Justify) + when: (plasmoid.location === PlasmaCore.Types.TopEdge)&&(root.panelAlignment === Latte.Types.Center || root.panelAlignment === Latte.Types.Justify) AnchorChanges { target: barLine anchors{ top:parent.top; bottom:undefined; left:undefined; right:undefined; horizontalCenter:parent.horizontalCenter; verticalCenter:undefined} } AnchorChanges { target: shadowsSvgItem anchors{ top:parent.top; bottom:undefined; left:undefined; right:undefined; horizontalCenter:parent.horizontalCenter; verticalCenter:undefined} } PropertyChanges{ target: barLine anchors.leftMargin: 0; anchors.rightMargin:0; anchors.topMargin:0; anchors.bottomMargin:0; - anchors.horizontalCenterOffset: (root.panelAlignment === Latte.Dock.Center ? root.offset : 0); anchors.verticalCenterOffset: 0; + anchors.horizontalCenterOffset: (root.panelAlignment === Latte.Types.Center ? root.offset : 0); anchors.verticalCenterOffset: 0; } }, State { name: "topLeft" when: (plasmoid.location === PlasmaCore.Types.TopEdge) - &&(((root.panelAlignment === Latte.Dock.Left)&&(Qt.application.layoutDirection !== Qt.RightToLeft)) - || ((root.panelAlignment === Latte.Dock.Right)&&(Qt.application.layoutDirection === Qt.RightToLeft))) + &&(((root.panelAlignment === Latte.Types.Left)&&(Qt.application.layoutDirection !== Qt.RightToLeft)) + || ((root.panelAlignment === Latte.Types.Right)&&(Qt.application.layoutDirection === Qt.RightToLeft))) AnchorChanges { target: barLine anchors{ top:parent.top; bottom:undefined; left:parent.left; right:undefined; horizontalCenter:undefined; verticalCenter:undefined} } AnchorChanges { target: shadowsSvgItem anchors{ top:parent.top; bottom:undefined; left:parent.left; right:undefined; horizontalCenter:undefined; verticalCenter:undefined} } PropertyChanges{ target: barLine anchors.leftMargin: root.offset; anchors.rightMargin:0; anchors.topMargin:0; anchors.bottomMargin:0; anchors.horizontalCenterOffset: 0; anchors.verticalCenterOffset: 0; } }, State { name: "topRight" when: (plasmoid.location === PlasmaCore.Types.TopEdge) - &&(((root.panelAlignment === Latte.Dock.Right)&&(Qt.application.layoutDirection !== Qt.RightToLeft)) - ||((root.panelAlignment === Latte.Dock.Left)&&(Qt.application.layoutDirection === Qt.RightToLeft))) + &&(((root.panelAlignment === Latte.Types.Right)&&(Qt.application.layoutDirection !== Qt.RightToLeft)) + ||((root.panelAlignment === Latte.Types.Left)&&(Qt.application.layoutDirection === Qt.RightToLeft))) AnchorChanges { target: barLine anchors{ top:parent.top; bottom:undefined; left:undefined; right:parent.right; horizontalCenter:undefined; verticalCenter:undefined} } AnchorChanges { target: shadowsSvgItem anchors{ top:parent.top; bottom:undefined; left:undefined; right:parent.right; horizontalCenter:undefined; verticalCenter:undefined} } PropertyChanges{ target: barLine anchors.leftMargin: 0; anchors.rightMargin:root.offset; anchors.topMargin:0; anchors.bottomMargin:0; anchors.horizontalCenterOffset: 0; anchors.verticalCenterOffset: 0; } } ] //END states } diff --git a/containment/package/contents/ui/Ruler.qml b/containment/package/contents/ui/Ruler.qml index d2b59b36..6a2b89d3 100644 --- a/containment/package/contents/ui/Ruler.qml +++ b/containment/package/contents/ui/Ruler.qml @@ -1,369 +1,369 @@ /* * Copyright 2018 Michail Vourlakos * * This file is part of Latte-Dock * * Latte-Dock 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. * * Latte-Dock 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 QtQuick.Layouts 1.0 import QtGraphicalEffects 1.0 import org.kde.plasma.plasmoid 2.0 import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.components 2.0 as PlasmaComponents -import org.kde.latte 0.1 as Latte +import org.kde.latte 0.2 as Latte Item{ id: rulerItem width: root.isHorizontal ? root.maxLength : thickness height: root.isVertical ? root.maxLength : thickness opacity: root.editMode ? 1 : 0 property int rulerAnimationTime: 0.8 * root.animationTime readonly property bool containsMouse: rulerMouseArea.containsMouse readonly property int thickness: theme.defaultFont.pixelSize + rMargin readonly property string tooltip: i18nc("maximum length tooltip, %0% is maximum length percentage","You can use mouse wheel to change maximum length of %0%").arg(plasmoid.configuration.maxLength) x: { if (root.isHorizontal) { return xL; } else { if (plasmoid.location === PlasmaCore.Types.LeftEdge){ return editModeVisual.x + editModeVisual.width - theme.defaultFont.pixelSize; } else if (plasmoid.location === PlasmaCore.Types.RightEdge){ return editModeVisual.x; } } } y: { if (root.isVertical) { return yL; } else { if (plasmoid.location === PlasmaCore.Types.BottomEdge){ return editModeVisual.y; } else if (plasmoid.location === PlasmaCore.Types.TopEdge){ return editModeVisual.y + editModeVisual.height - theme.defaultFont.pixelSize; } } } property int length: root.maxLength property int rMargin: 3 property int xL: 0 property int yL: 0 Binding{ target: ruler property: "xL" value: { if (root.isHorizontal) { - if (plasmoid.configuration.panelPosition === Latte.Dock.Justify) { + if (plasmoid.configuration.panelPosition === Latte.Types.Justify) { return root.width/2 - rulerItem.length/2 + root.offset; - } else if (root.panelAlignment === Latte.Dock.Left) { + } else if (root.panelAlignment === Latte.Types.Left) { return root.offset; - } else if (root.panelAlignment === Latte.Dock.Center) { + } else if (root.panelAlignment === Latte.Types.Center) { return root.width/2 - rulerItem.length/2 + root.offset; - } else if (root.panelAlignment === Latte.Dock.Right) { + } else if (root.panelAlignment === Latte.Types.Right) { return root.width - rulerItem.length - root.offset; } } else { return ; } } } Binding{ target: ruler property: "yL" value: { if (root.isVertical) { - if (plasmoid.configuration.panelPosition === Latte.Dock.Justify) { + if (plasmoid.configuration.panelPosition === Latte.Types.Justify) { return root.height/2 - rulerItem.length/2 + root.offset; - } else if (root.panelAlignment === Latte.Dock.Top) { + } else if (root.panelAlignment === Latte.Types.Top) { return root.offset; - } else if (root.panelAlignment === Latte.Dock.Center) { + } else if (root.panelAlignment === Latte.Types.Center) { return root.height/2 - rulerItem.length/2 + root.offset; - } else if (root.panelAlignment === Latte.Dock.Bottom) { + } else if (root.panelAlignment === Latte.Types.Bottom) { return root.height - rulerItem.length - root.offset; } } else { return; } } } property int textShadow: { if (textColorIsDark) { return 1; } else { return 6; } } // formula for luminance according to: // https://www.w3.org/TR/2008/REC-WCAG20-20081211/#relativeluminancedef property real textColorRs: { var color = textColor.r; if (color <= 0.03928) { return color / 12.92; } else { return Math.pow( ((color + 0.055) / 1.055), 2.4 ); } } property real textColorGs: { var color = textColor.g; if (color <= 0.03928) { return color / 12.92; } else { return Math.pow( ((color + 0.055) / 1.055), 2.4 ); } } property real textColorBs: { var color = textColor.b; if (color <= 0.03928) { return color / 12.92; } else { return Math.pow( ((color + 0.055) / 1.055), 2.4 ); } } readonly property real textColorLuma: 0.2126*textColorRs + 0.7152*textColorGs + 0.0722*textColorBs readonly property bool textColorIsDark: textColorLuma < 0.6 readonly property color textColor: dock && dock.managedLayout ? dock.managedLayout.textColor : "#D7E3FF" Behavior on width { NumberAnimation { id: horizontalAnimation duration: rulerAnimationTime easing.type: Easing.OutCubic } } Behavior on height { NumberAnimation { id: verticalAnimation duration: rulerAnimationTime easing.type: Easing.OutCubic } } Behavior on x { enabled: root.isHorizontal && !offsetAnimation.running NumberAnimation { duration: rulerAnimationTime easing.type: Easing.OutCubic } } Behavior on y { enabled: root.isVertical && !offsetAnimation.running NumberAnimation { duration: rulerAnimationTime easing.type: Easing.OutCubic } } Grid{ id: rulerGrid width: root.isHorizontal ? parent.length : undefined height: root.isVertical ? parent.length : undefined rows: root.isHorizontal ? 1 : 0 columns: root.isVertical ? 1 : 0 spacing: 2 flow: root.isHorizontal ? GridLayout.TopToBottom : GridLayout.LeftToRight x: { if (plasmoid.location === PlasmaCore.Types.LeftEdge) { return -rMargin; } else if (plasmoid.location === PlasmaCore.Types.RightEdge) { return rMargin; } else { return 0; } } y: { if (plasmoid.location === PlasmaCore.Types.BottomEdge) { return rMargin; } else if (plasmoid.location === PlasmaCore.Types.TopEdge) { return -rMargin; } else { return 0; } } Behavior on width { NumberAnimation { duration: rulerAnimationTime easing.type: Easing.OutCubic } } Behavior on height { NumberAnimation { duration: rulerAnimationTime easing.type: Easing.OutCubic } } property int freeSpace: { if (root.isHorizontal) { return rulerItem.width - rulerGrid.spacing - 1 //((rulerGrid.children.length-2) * rulerGrid.spacing) - (startLine.width + startArrow.width + labelItem.width + endArrow.width + endArrow.width); } else { return rulerItem.height - rulerGrid.spacing - 1 //((rulerGrid.children.length-2) * rulerGrid.spacing) - (startLine.height + startArrow.height + labelItem.height + endArrow.height + endArrow.height); } } layer.enabled: true layer.effect: DropShadow{ radius: textShadow fast: true samples: 2 * radius color: root.appShadowColorSolid } Rectangle{ id: startLine width: root.isHorizontal ? 2 : theme.defaultFont.pixelSize height: root.isVertical ? 2 : theme.defaultFont.pixelSize color: textColor } Item{ id: startArrow width: root.isHorizontal ? 0.6 * theme.defaultFont.pixelSize : theme.defaultFont.pixelSize height: root.isVertical ? 0.6 * theme.defaultFont.pixelSize : theme.defaultFont.pixelSize clip:true Rectangle{ anchors.verticalCenter: root.isHorizontal ? parent.verticalCenter : parent.bottom anchors.horizontalCenter: root.isHorizontal ? parent.right : parent.horizontalCenter width: 0.75*theme.defaultFont.pixelSize height: width rotation: 45 color: textColor } } Item{ id: startSpacer width: root.isHorizontal ? rulerGrid.freeSpace / 2 : theme.defaultFont.pixelSize height: root.isVertical ? rulerGrid.freeSpace / 2 : theme.defaultFont.pixelSize Rectangle{ height: root.isHorizontal ? 2 : parent.height width: root.isVertical ? 2 : parent.width anchors.centerIn: parent color: textColor } } Item { id: labelItem width: root.isHorizontal ? labelMetricsRec.width : labelMetricsRec.height / 2 height: root.isVertical ? labelMetricsRec.width : labelMetricsRec.height / 2 PlasmaComponents.Label{ id: maxLengthLbl anchors.centerIn: parent text: i18n("Maximum Length") color: textColor transformOrigin: Item.Center rotation: { if (root.isHorizontal) { return 0; } else if (plasmoid.location === PlasmaCore.Types.LeftEdge){ return 90; } else if (plasmoid.location === PlasmaCore.Types.RightEdge){ return -90; } } Rectangle { id: labelMetricsRec anchors.fill: parent visible: false } } } Item{ id: endSpacer width: startSpacer.width height: startSpacer.height Rectangle{ height: root.isHorizontal ? 2 : parent.height width: root.isVertical ? 2 : parent.width anchors.centerIn: parent color: textColor } } Item{ id: endArrow width: root.isHorizontal ? 0.6 * theme.defaultFont.pixelSize : theme.defaultFont.pixelSize height: root.isVertical ? 0.6 * theme.defaultFont.pixelSize : theme.defaultFont.pixelSize clip:true Rectangle{ anchors.verticalCenter: root.isHorizontal ? parent.verticalCenter : parent.top anchors.horizontalCenter: root.isHorizontal ? parent.left : parent.horizontalCenter width: 0.75*theme.defaultFont.pixelSize height: width rotation: 45 color: textColor } } Rectangle{ id: endLine width: root.isHorizontal ? 2 : theme.defaultFont.pixelSize height: root.isVertical ? 2 : theme.defaultFont.pixelSize color: textColor } } // end of grid } diff --git a/containment/package/contents/ui/RulerMouseArea.qml b/containment/package/contents/ui/RulerMouseArea.qml index 9d59760c..852835d2 100644 --- a/containment/package/contents/ui/RulerMouseArea.qml +++ b/containment/package/contents/ui/RulerMouseArea.qml @@ -1,85 +1,85 @@ /* * Copyright 2018 Michail Vourlakos * * This file is part of Latte-Dock * * Latte-Dock 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. * * Latte-Dock 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.plasmoid 2.0 import org.kde.plasma.core 2.0 as PlasmaCore -import org.kde.latte 0.1 as Latte +import org.kde.latte 0.2 as Latte MouseArea{ enabled: root.editMode && !dock.visibility.isHidden cursorShape: { if (enabled) { return root.isHorizontal ? Qt.SizeHorCursor : Qt.SizeVerCursor } else { return Qt.ArrowCursor; } } hoverEnabled: enabled onWheel: { var angle = wheel.angleDelta.y / 8; if (angle > 12) { updateMaxLength(6); } else if (angle < -12) { updateMaxLength(-6); } } //! replica of updating maximum length from configuration tab function updateMaxLength(step) { var tempML = plasmoid.configuration.maxLength + step; var value = Math.max(Math.min(tempML,100),30); plasmoid.configuration.maxLength = value; var newTotal = Math.abs(plasmoid.configuration.offset) + value; //centered and justify alignments based on offset and get out of the screen in some cases - var centeredCheck = ((plasmoid.configuration.panelPosition === Latte.Dock.Center) - || (plasmoid.configuration.panelPosition === Latte.Dock.Justify)) + var centeredCheck = ((plasmoid.configuration.panelPosition === Latte.Types.Center) + || (plasmoid.configuration.panelPosition === Latte.Types.Justify)) && ((Math.abs(plasmoid.configuration.offset) + value/2) > 50); if (newTotal > 100 || centeredCheck) { - if ((plasmoid.configuration.panelPosition === Latte.Dock.Center) - || (plasmoid.configuration.panelPosition === Latte.Dock.Justify)) { + if ((plasmoid.configuration.panelPosition === Latte.Types.Center) + || (plasmoid.configuration.panelPosition === Latte.Types.Justify)) { var suggestedValue = (plasmoid.configuration.offset<0) ? Math.min(0, -(100-value)): Math.max(0, 100-value); if ((Math.abs(suggestedValue) + value/2) > 50) { if (suggestedValue < 0) { suggestedValue = - (50 - value/2); } else { suggestedValue = 50 - value/2; } } plasmoid.configuration.offset = suggestedValue; } else { plasmoid.configuration.offset = Math.max(0, 100-value); } } } } diff --git a/containment/package/contents/ui/VisibilityManager.qml b/containment/package/contents/ui/VisibilityManager.qml index 438d56c0..e648de2c 100644 --- a/containment/package/contents/ui/VisibilityManager.qml +++ b/containment/package/contents/ui/VisibilityManager.qml @@ -1,662 +1,662 @@ /* * Copyright 2016 Smith AR * Michail Vourlakos * * This file is part of Latte-Dock * * Latte-Dock 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. * * Latte-Dock 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.1 import QtQuick.Window 2.2 import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.plasmoid 2.0 -import org.kde.latte 0.1 as Latte +import org.kde.latte 0.2 as Latte Item{ id: manager anchors.fill: parent property QtObject window property bool debugMagager: Qt.application.arguments.indexOf("--mask") >= 0 property bool blockUpdateMask: false property bool inForceHiding: false //is used when the docks are forced in hiding e.g. when changing layouts property bool normalState : false // this is being set from updateMaskArea property bool previousNormalState : false // this is only for debugging purposes property bool panelIsBiggerFromIconSize: root.useThemePanel && (root.themePanelSize >= root.iconSize) 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)) ? -thicknessNormal : thicknessNormal; property int statesLineSizeOriginal: root.latteApplet ? Math.ceil( root.maxIconSize/13 ) : 0 property int thickReverseAndGlowExtraSize: (root.reverseLinesPosition && root.showGlow && !behaveAsPlasmaPanel) ? 2*statesLineSize : 0; property int thickReverseAndGlowExtraSizeOriginal: Math.ceil(2*root.maxIconSize/13 ) property int thicknessAutoHidden: Latte.WindowSystem.compositingActive ? 2 : 1 property int thicknessMid: root.statesLineSize + (1 + (0.65 * (root.zoomFactor-1)))*(root.iconSize+root.thickMargin + thickReverseAndGlowExtraSize) //needed in some animations property int thicknessNormal: Math.max(root.statesLineSize + root.iconSize + root.thickMargin + thickReverseAndGlowExtraSize +1, root.realPanelSize + root.panelShadow) property int thicknessZoom: root.statesLineSize + ((root.iconSize+root.thickMargin + thickReverseAndGlowExtraSize) * root.zoomFactor) + 2 //it is used to keep thickness solid e.g. when iconSize changes from auto functions property int thicknessMidOriginal: Math.max(thicknessNormalOriginal, statesLineSizeOriginal + thickReverseAndGlowExtraSizeOriginal + (1 + (0.65 * (root.zoomFactor-1)))*(root.maxIconSize+root.thickMarginOriginal)) //needed in some animations property int thicknessNormalOriginal: !root.behaveAsPlasmaPanel || root.editMode ? thicknessNormalOriginalValue : root.realPanelSize + root.panelShadow property int thicknessNormalOriginalValue: statesLineSizeOriginal + thickReverseAndGlowExtraSizeOriginal + root.maxIconSize + root.thickMarginOriginal + 1 property int thicknessZoomOriginal: Math.max(statesLineSizeOriginal + thickReverseAndGlowExtraSizeOriginal + ((root.maxIconSize+root.thickMarginOriginal) * root.zoomFactor) + 2, root.realPanelSize + root.panelShadow, thicknessEditMode) property int thicknessEditMode: thicknessNormalOriginalValue + theme.defaultFont.pixelSize + root.editShadow Binding{ target: dock property:"maxThickness" //! prevents updating window geometry during closing window in wayland and such fixes a crash when: dock && !inTempHiding && !inForceHiding value: thicknessZoomOriginal } Binding{ target: dock property:"normalThickness" when: dock value: thicknessNormalOriginal } Binding{ target: dock property: "behaveAsPlasmaPanel" when: dock value: root.editMode ? false : root.behaveAsPlasmaPanel } Binding{ target: dock property: "fontPixelSize" when: theme value: theme.defaultFont.pixelSize } Binding{ target: dock property:"inEditMode" when: dock value: root.editMode } Binding{ target: dock property: "maxLength" when: dock value: root.editMode ? 1 : plasmoid.configuration.maxLength/100 } Binding{ target: dock property: "offset" when: dock value: plasmoid.configuration.offset } Binding{ target: dock property: "alignment" when: dock value: root.panelAlignment } Binding{ target: dock && dock.effects ? dock.effects : null property: "backgroundOpacity" when: dock && dock.effects value: root.currentPanelTransparency } Binding{ target: dock && dock.effects ? dock.effects : null property: "colorizerEnabled" when: dock && dock.effects value: root.forceColorizer && plasmoid.configuration.solidBackgroundForMaximized } Binding{ target: dock && dock.effects ? dock.effects : null property: "drawEffects" when: dock && dock.effects value: Latte.WindowSystem.compositingActive && (((root.blurEnabled && root.useThemePanel) || (root.blurEnabled && root.forceSolidPanel && dock.visibility.existsWindowMaximized && Latte.WindowSystem.compositingActive)) && (!root.inStartup || inForceHiding || inTempHiding)) } Binding{ target: dock && dock.effects ? dock.effects : null property: "drawShadows" when: dock && dock.effects value: root.drawShadowsExternal && (!root.inStartup || inForceHiding || inTempHiding) } Binding{ target: dock && dock.effects ? dock.effects : null property:"innerShadow" when: dock && dock.effects value: { if (editModeVisual.editAnimationEnded && !root.behaveAsPlasmaPanel) { return root.editShadow; } else { return root.panelShadow; } } } Binding{ target: dock && dock.visibility ? dock.visibility : null property: "enabledDynamicBackground" when: dock && dock.visibility value: (root.backgroundOnlyOnMaximized || plasmoid.configuration.solidBackgroundForMaximized || root.disablePanelShadowMaximized) && Latte.WindowSystem.compositingActive } Connections{ target:root onPanelShadowChanged: updateMaskArea(); onPanelMarginChanged: updateMaskArea(); } Connections{ target: universalLayoutManager onCurrentLayoutIsSwitching: { if (Latte.WindowSystem.compositingActive && root.dockManagedLayout && root.dockManagedLayout.name === layoutName) { manager.inTempHiding = true; manager.inForceHiding = true; root.clearZoom(); manager.slotMustBeHide(); } } } onNormalStateChanged: { if (normalState) { root.updateAutomaticIconSize(); root.updateSizeForAppletsInFill(); } } onThicknessZoomOriginalChanged: { updateMaskArea(); } function slotContainsMouseChanged() { if(dock.visibility.containsMouse) { updateMaskArea(); } } function slotMustBeShown() { // console.log("show..."); if (!slidingAnimationAutoHiddenIn.running && !inTempHiding && !inForceHiding){ slidingAnimationAutoHiddenIn.init(); } } function slotMustBeHide() { //! prevent sliding-in on startup if the dodge modes have sent a hide signal if (inStartupTimer.running && root.inStartup) { root.inStartup = false; } // console.log("hide...."); if((!slidingAnimationAutoHiddenOut.running && !dock.visibility.blockHiding && !dock.visibility.containsMouse) || inForceHiding) { slidingAnimationAutoHiddenOut.init(); } } //! functions used for sliding out/in during location/screen changes function slotHideDockDuringLocationChange() { inTempHiding = true; blockUpdateMask = true; slotMustBeHide(); } function slotShowDockAfterLocationChange() { slidingAnimationAutoHiddenIn.init(); } function sendHideDockDuringLocationChangeFinished(){ blockUpdateMask = false; dock.positioner.hideDockDuringLocationChangeFinished(); } ///test maskArea function updateMaskArea() { if (!dock || blockUpdateMask) { return; } var localX = 0; var localY = 0; normalState = ((root.animationsNeedBothAxis === 0) && (root.animationsNeedLength === 0)) || (dock.visibility.isHidden && !dock.visibility.containsMouse && root.animationsNeedThickness == 0); // debug maskArea criteria if (debugMagager) { console.log(root.animationsNeedBothAxis + ", " + root.animationsNeedLength + ", " + root.animationsNeedThickness + ", " + dock.visibility.isHidden); if (previousNormalState !== normalState) { console.log("normal state changed to:" + normalState); previousNormalState = normalState; } } var tempLength = root.isHorizontal ? width : height; var tempThickness = root.isHorizontal ? height : width; var space = 0; if (Latte.WindowSystem.compositingActive) { if (root.useThemePanel){ space = root.totalPanelEdgeSpacing + root.panelMarginLength + 1; } else { space = root.totalPanelEdgeSpacing + 1; } } else { space = root.totalPanelEdgeSpacing + root.panelMarginLength; } if (Latte.WindowSystem.compositingActive) { if (normalState) { //console.log("entered normal state..."); //count panel length var noCompositingEdit = !Latte.WindowSystem.compositingActive && root.editMode; //used when !compositing and in editMode if (noCompositingEdit) { tempLength = root.isHorizontal ? root.width : root.height; } else { if(root.isHorizontal) { - tempLength = plasmoid.configuration.panelPosition === Latte.Dock.Justify ? + tempLength = plasmoid.configuration.panelPosition === Latte.Types.Justify ? layoutsContainer.width + space : layoutsContainer.mainLayout.width + space; } else { - tempLength = plasmoid.configuration.panelPosition === Latte.Dock.Justify ? + tempLength = plasmoid.configuration.panelPosition === Latte.Types.Justify ? layoutsContainer.height + space : layoutsContainer.mainLayout.height + space; } } tempThickness = thicknessNormal; if (root.animationsNeedThickness > 0) { tempThickness = Latte.WindowSystem.compositingActive ? thicknessZoom : thicknessNormal; } if (dock.visibility.isHidden && !slidingAnimationAutoHiddenOut.running ) { tempThickness = thicknessAutoHidden; } //configure x,y based on plasmoid position and root.panelAlignment(Alignment) if ((plasmoid.location === PlasmaCore.Types.BottomEdge) || (plasmoid.location === PlasmaCore.Types.TopEdge)) { if (plasmoid.location === PlasmaCore.Types.BottomEdge) { localY = dock.visibility.isHidden && dock.visibility.supportsKWinEdges ? dock.height + tempThickness : dock.height - tempThickness; } else if (plasmoid.location === PlasmaCore.Types.TopEdge) { localY = dock.visibility.isHidden && dock.visibility.supportsKWinEdges ? -tempThickness : 0; } if (noCompositingEdit) { localX = 0; - } else if (plasmoid.configuration.panelPosition === Latte.Dock.Justify) { + } else if (plasmoid.configuration.panelPosition === Latte.Types.Justify) { localX = (dock.width/2) - tempLength/2 + root.offset; - } else if (root.panelAlignment === Latte.Dock.Left) { + } else if (root.panelAlignment === Latte.Types.Left) { localX = root.offset; - } else if (root.panelAlignment === Latte.Dock.Center) { + } else if (root.panelAlignment === Latte.Types.Center) { localX = (dock.width/2) - tempLength/2 + root.offset; - } else if (root.panelAlignment === Latte.Dock.Right) { + } else if (root.panelAlignment === Latte.Types.Right) { localX = dock.width - layoutsContainer.mainLayout.width - space - root.offset; } } else if ((plasmoid.location === PlasmaCore.Types.LeftEdge) || (plasmoid.location === PlasmaCore.Types.RightEdge)){ if (plasmoid.location === PlasmaCore.Types.LeftEdge) { localX = dock.visibility.isHidden && dock.visibility.supportsKWinEdges ? -tempThickness : 0; } else if (plasmoid.location === PlasmaCore.Types.RightEdge) { localX = dock.visibility.isHidden && dock.visibility.supportsKWinEdges ? dock.width + tempThickness : dock.width - tempThickness; } if (noCompositingEdit) { localY = 0; - } else if (plasmoid.configuration.panelPosition === Latte.Dock.Justify) { + } else if (plasmoid.configuration.panelPosition === Latte.Types.Justify) { localY = (dock.height/2) - tempLength/2 + root.offset; - } else if (root.panelAlignment === Latte.Dock.Top) { + } else if (root.panelAlignment === Latte.Types.Top) { localY = root.offset; - } else if (root.panelAlignment === Latte.Dock.Center) { + } else if (root.panelAlignment === Latte.Types.Center) { localY = (dock.height/2) - tempLength/2 + root.offset; - } else if (root.panelAlignment === Latte.Dock.Bottom) { + } else if (root.panelAlignment === Latte.Types.Bottom) { localY = dock.height - layoutsContainer.mainLayout.height - space - root.offset; } } } else { if(root.isHorizontal) tempLength = Screen.width; //screenGeometry.width; else tempLength = Screen.height; //screenGeometry.height; //grow only on length and not thickness if(root.animationsNeedLength>0 && root.animationsNeedBothAxis === 0) { //this is used to fix a bug with shadow showing when the animation of edit mode //is triggered tempThickness = editModeVisual.editAnimationEnded ? thicknessNormalOriginal + theme.defaultFont.pixelSize + root.editShadow : thicknessNormalOriginal + theme.defaultFont.pixelSize if (dock.visibility.isHidden && !slidingAnimationAutoHiddenOut.running ) { tempThickness = thicknessAutoHidden; } else if (root.animationsNeedThickness > 0) { tempThickness = thicknessZoomOriginal; } } else{ //use all thickness space if (dock.visibility.isHidden && !slidingAnimationAutoHiddenOut.running ) { tempThickness = Latte.WindowSystem.compositingActive ? thicknessAutoHidden : thicknessNormalOriginal; } else { tempThickness = thicknessZoomOriginal; } } //configure the x,y position based on thickness if(plasmoid.location === PlasmaCore.Types.RightEdge) localX = Math.max(0,dock.width - tempThickness); else if(plasmoid.location === PlasmaCore.Types.BottomEdge) localY = Math.max(0,dock.height - tempThickness); } } // end of compositing calculations var maskArea = dock.effects.mask; if (Latte.WindowSystem.compositingActive) { var maskLength = maskArea.width; //in Horizontal if (root.isVertical) { maskLength = maskArea.height; } var maskThickness = maskArea.height; //in Horizontal if (root.isVertical) { maskThickness = maskArea.width; } } else { //! no compositing case if (!dock.visibility.isHidden || !dock.visibility.supportsKWinEdges) { localX = dock.effects.rect.x; localY = dock.effects.rect.y; } else { if (plasmoid.location === PlasmaCore.Types.BottomEdge) { localX = dock.effects.rect.x; localY = dock.effects.rect.y+dock.effects.rect.height+thicknessAutoHidden; } else if (plasmoid.location === PlasmaCore.Types.TopEdge) { localX = dock.effects.rect.x; localY = dock.effects.rect.y - thicknessAutoHidden; } else if (plasmoid.location === PlasmaCore.Types.LeftEdge) { localX = dock.effects.rect.x - thicknessAutoHidden; localY = dock.effects.rect.y; } else if (plasmoid.location === PlasmaCore.Types.RightEdge) { localX = dock.effects.rect.x + dock.effects.rect.width + 1; localY = dock.effects.rect.y; } } if (root.isHorizontal) { tempThickness = dock.effects.rect.height; tempLength = dock.effects.rect.width; } else { tempThickness = dock.effects.rect.width; tempLength = dock.effects.rect.height; } } // console.log("Not updating mask..."); if( maskArea.x !== localX || maskArea.y !== localY || maskLength !== tempLength || maskThickness !== tempThickness) { // console.log("Updating mask..."); var newMaskArea = Qt.rect(-1,-1,0,0); newMaskArea.x = localX; newMaskArea.y = localY; if (isHorizontal) { newMaskArea.width = tempLength; newMaskArea.height = tempThickness; } else { newMaskArea.width = tempThickness; newMaskArea.height = tempLength; } if (!Latte.WindowSystem.compositingActive) { dock.effects.mask = newMaskArea; } else { if (dock.behaveAsPlasmaPanel && !root.editMode) { dock.effects.mask = Qt.rect(0,0,root.width,root.height); } else { dock.effects.mask = newMaskArea; } } } //console.log("reached updating geometry ::: "+dock.maskArea); if(normalState){ var tempGeometry = Qt.rect(dock.effects.mask.x, dock.effects.mask.y, dock.effects.mask.width, dock.effects.mask.height); //the shadows size must be removed from the maskArea //before updating the localDockGeometry if ((!dock.behaveAsPlasmaPanel || root.editMode) && Latte.WindowSystem.compositingActive) { var fixedThickness = root.realPanelThickness; if (plasmoid.formFactor === PlasmaCore.Types.Vertical) { tempGeometry.width = fixedThickness; } else { tempGeometry.height = fixedThickness; } if (plasmoid.location === PlasmaCore.Types.BottomEdge) { tempGeometry.y = dock.height - fixedThickness; } else if (plasmoid.location === PlasmaCore.Types.RightEdge) { tempGeometry.x = dock.width - fixedThickness; } //set the boundaries for dock local geometry //qBound = qMax(min, qMin(value, max)). tempGeometry.x = Math.max(0, Math.min(tempGeometry.x, dock.width)); tempGeometry.y = Math.max(0, Math.min(tempGeometry.y, dock.height)); tempGeometry.width = Math.min(tempGeometry.width, dock.width); tempGeometry.height = Math.min(tempGeometry.height, dock.height); } //console.log("update geometry ::: "+tempGeometry); if (!Latte.WindowSystem.compositingActive) { dock.localGeometry = dock.effects.rect; } else { dock.localGeometry = tempGeometry; } } } Loader{ anchors.fill: parent active: root.debugMode sourceComponent: Item{ anchors.fill:parent Rectangle{ id: windowBackground anchors.fill: parent border.color: "red" border.width: 1 color: "transparent" } Rectangle{ x: dock ? dock.effects.mask.x : -1 y: dock ? dock.effects.mask.y : -1 height: dock ? dock.effects.mask.height : 0 width: dock ? dock.effects.mask.width : 0 border.color: "green" border.width: 1 color: "transparent" } } } /***Hiding/Showing Animations*****/ //////////////// Animations - Slide In - Out SequentialAnimation{ id: slidingAnimationAutoHiddenOut ScriptAction{ script: { root.isHalfShown = true; } } PropertyAnimation { target: layoutsContainer property: root.isVertical ? "x" : "y" to: { if (Latte.WindowSystem.compositingActive) { return slidingOutToPos; } else { if ((plasmoid.location===PlasmaCore.Types.LeftEdge)||(plasmoid.location===PlasmaCore.Types.TopEdge)) { return slidingOutToPos + 1; } else { return slidingOutToPos - 1; } } } duration: manager.animationSpeed easing.type: Easing.InQuad } ScriptAction{ script: { dock.visibility.isHidden = true; } } onStarted: { if (manager.debugMagager) { console.log("hiding animation started..."); } } onStopped: { dock.visibility.isHidden = true; if (manager.debugMagager) { console.log("hiding animation ended..."); } if (!manager.inTempHiding) { updateMaskArea(); } else if (plasmoid.configuration.durationTime === 0) { sendHideDockDuringLocationChangeFinished(); } } function init() { if (!dock.visibility.blockHiding) start(); } } SequentialAnimation{ id: slidingAnimationAutoHiddenIn PauseAnimation{ duration: manager.inTempHiding && root.durationTime>0 ? 500 : 0 } PropertyAnimation { target: layoutsContainer property: root.isVertical ? "x" : "y" to: 0 duration: manager.animationSpeed easing.type: Easing.OutQuad } ScriptAction{ script: { root.isHalfShown = false; root.inStartup = false; } } onStarted: { if (manager.debugMagager) { console.log("showing animation started..."); } } onStopped: { inSlidingIn = false; if (manager.inTempHiding) { manager.inTempHiding = false; updateAutomaticIconSize(); } manager.inTempHiding = false; updateAutomaticIconSize(); if (manager.debugMagager) { console.log("showing animation ended..."); } } function init() { // if (!dock.visibility.blockHiding) inSlidingIn = true; if (slidingAnimationAutoHiddenOut.running) { slidingAnimationAutoHiddenOut.stop(); } dock.visibility.isHidden = false; updateMaskArea(); start(); } } } diff --git a/containment/package/contents/ui/applet/ActiveIndicator.qml b/containment/package/contents/ui/applet/ActiveIndicator.qml index b75589de..25cd409c 100644 --- a/containment/package/contents/ui/applet/ActiveIndicator.qml +++ b/containment/package/contents/ui/applet/ActiveIndicator.qml @@ -1,240 +1,240 @@ /* * Copyright 2016 Smith AR * Michail Vourlakos * * This file is part of Latte-Dock * * Latte-Dock 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. * * Latte-Dock 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.0 import org.kde.plasma.plasmoid 2.0 import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.components 2.0 as PlasmaComponents -import org.kde.latte 0.1 as Latte +import org.kde.latte 0.2 as Latte Item{ id:glowFrame width: !root.isVertical ? parent.width : size height: root.isVertical ? parent.height : size property int size: mimicPlasmaPanel ? 4 : root.statesLineSize property bool mimicPlasmaPanel: !root.latteApplet && plasmoid.configuration.panelSize===100 ? !plasmoid.configuration.reverseLinesPosition : false /*Rectangle{ anchors.fill: parent border.width: 1 border.color: "yellow" color: "transparent" opacity:0.6 }*/ Latte.GlowPoint{ id:activePoint anchors.centerIn: parent basicColor: theme.buttonFocusColor roundCorners: true showGlow: root.showGlow glow3D: root.glow3D animation: Math.max(1.65*3*units.longDuration,root.durationTime*3*units.longDuration) location: plasmoid.location glowOpacity: root.glowOpacity contrastColor: root.appShadowColorSolid opacity:{ if ( (!vertical && width <= glowFrame.size && !isActive) || (vertical && height <= glowFrame.size && !isActive)) return 0; return 1; } property bool isActive: (container.isExpanded && !container.isSystray && applet.pluginName !== root.plasmoidName && applet.pluginName !== "org.kde.activeWindowControl" && applet.pluginName !== "org.kde.plasma.appmenu") property bool vertical: root.isVertical property int animationTime: root.durationTime * (1.2*units.longDuration) - property int stateWidth: root.activeIndicatorType === Latte.Dock.DotIndicator ? glowFrame.size : glowFrame.width - property int stateHeight: root.activeIndicatorType === Latte.Dock.DotIndicator ? glowFrame.size : glowFrame.height + property int stateWidth: root.activeIndicatorType === Latte.Types.DotIndicator ? glowFrame.size : glowFrame.width + property int stateHeight: root.activeIndicatorType === Latte.Types.DotIndicator ? glowFrame.size : glowFrame.height property real scaleFactor: wrapper.zoomScale function updateInitialSizes(){ if(glowFrame){ if(vertical) width = glowFrame.size; else height = glowFrame.size; if(vertical && isActive) height = stateHeight; else height = glowFrame.size; if(!vertical && isActive) width = stateWidth; else width = glowFrame.size; } } onIsActiveChanged: { // if(mainItemContainer.hasActive || windowsPreviewDlg.visible) activeAndReverseAnimation.start(); } onScaleFactorChanged: { - if ( root.activeIndicatorType === Latte.Dock.LineIndicator ) { + if ( root.activeIndicatorType === Latte.Types.LineIndicator ) { if(!activeAndReverseAnimation.running && !root.vertical && isActive){ width = stateWidth; } else if (!activeAndReverseAnimation.running && root.vertical && isActive){ height = stateHeight; } } } onStateWidthChanged:{ - if(!activeAndReverseAnimation.running && !vertical && isActive && root.activeIndicatorType === Latte.Dock.LineIndicator) + if(!activeAndReverseAnimation.running && !vertical && isActive && root.activeIndicatorType === Latte.Types.LineIndicator) width = stateWidth; } onStateHeightChanged:{ - if(!activeAndReverseAnimation.running && vertical && isActive && root.activeIndicatorType === Latte.Dock.LineIndicator) + if(!activeAndReverseAnimation.running && vertical && isActive && root.activeIndicatorType === Latte.Types.LineIndicator) height = stateHeight; } onVerticalChanged: updateInitialSizes(); Component.onCompleted: { updateInitialSizes(); root.onIconSizeChanged.connect(updateInitialSizes); } Component.onDestruction: { root.onIconSizeChanged.disconnect(updateInitialSizes); } NumberAnimation{ id: activeAndReverseAnimation target: activePoint property: root.isVertical ? "height" : "width" to: !activePoint.isActive ? (root.isVertical ? activePoint.stateHeight : activePoint.stateWidth) : glowFrame.size duration: activePoint.animationTime easing.type: Easing.InQuad onStopped: activePoint.updateInitialSizes() } } states: [ State { name: "leftLatte" when: ((plasmoid.location === PlasmaCore.Types.LeftEdge && !root.reverseLinesPosition) || (plasmoid.location === PlasmaCore.Types.RightEdge && root.reverseLinesPosition)) && !mimicPlasmaPanel AnchorChanges { target: glowFrame anchors{ verticalCenter:parent.verticalCenter; horizontalCenter:undefined; top:undefined; bottom:undefined; left:undefined; right:parent.left;} } }, State { name: "bottomLatte" when: ((plasmoid.location === PlasmaCore.Types.BottomEdge && !root.reverseLinesPosition) || (plasmoid.location === PlasmaCore.Types.TopEdge && root.reverseLinesPosition)) && !mimicPlasmaPanel AnchorChanges { target: glowFrame anchors{ verticalCenter:undefined; horizontalCenter:parent.horizontalCenter; top:parent.bottom; bottom:undefined; left:undefined; right:undefined;} } }, State { name: "topLatte" when: ((plasmoid.location === PlasmaCore.Types.TopEdge && !root.reverseLinesPosition) || (plasmoid.location === PlasmaCore.Types.BottomEdge && root.reverseLinesPosition)) && !mimicPlasmaPanel AnchorChanges { target: glowFrame anchors{ verticalCenter:undefined; horizontalCenter:parent.horizontalCenter; top:undefined; bottom:parent.top; left:undefined; right:undefined;} } }, State { name: "rightLatte" when: ((plasmoid.location === PlasmaCore.Types.RightEdge && !root.reverseLinesPosition) || (plasmoid.location === PlasmaCore.Types.LeftEdge && root.reverseLinesPosition)) && !mimicPlasmaPanel AnchorChanges { target: glowFrame anchors{ verticalCenter:parent.verticalCenter; horizontalCenter:undefined; top:undefined; bottom:undefined; left:parent.right; right:undefined;} } }, State { name: "topPlasma" when: plasmoid.location === PlasmaCore.Types.TopEdge && mimicPlasmaPanel AnchorChanges { target: glowFrame anchors{ verticalCenter:undefined; horizontalCenter:parent.horizontalCenter; top:undefined; bottom:parent.bottom; left:undefined; right:undefined;} } }, State { name: "bottomPlasma" when: plasmoid.location === PlasmaCore.Types.BottomEdge && mimicPlasmaPanel AnchorChanges { target: glowFrame anchors{ verticalCenter:undefined; horizontalCenter:parent.horizontalCenter; top:parent.top; bottom:undefined; left:undefined; right:undefined;} } }, State { name: "leftPlasma" when: plasmoid.location === PlasmaCore.Types.LeftEdge && mimicPlasmaPanel AnchorChanges { target: glowFrame anchors{ verticalCenter:undefined; horizontalCenter:parent.horizontalCenter; top:undefined; bottom:undefined; left:undefined; right:parent.right;} } }, State { name: "rightPlasma" when: plasmoid.location === PlasmaCore.Types.LeftEdge && mimicPlasmaPanel AnchorChanges { target: glowFrame anchors{ verticalCenter:undefined; horizontalCenter:parent.horizontalCenter; top:undefined; bottom:undefined; left:parent.left; right:undefined;} } } ] } diff --git a/containment/package/contents/ui/applet/AppletItem.qml b/containment/package/contents/ui/applet/AppletItem.qml index 72e458cf..06684b22 100644 --- a/containment/package/contents/ui/applet/AppletItem.qml +++ b/containment/package/contents/ui/applet/AppletItem.qml @@ -1,856 +1,856 @@ /* * Copyright 2016 Smith AR * Michail Vourlakos * * This file is part of Latte-Dock * * Latte-Dock 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. * * Latte-Dock 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.1 import QtQuick.Layouts 1.1 import QtGraphicalEffects 1.0 import org.kde.plasma.plasmoid 2.0 import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.components 2.0 as PlasmaComponents import org.kde.plasma.extras 2.0 as PlasmaExtras import org.kde.kquickcontrolsaddons 2.0 -import org.kde.latte 0.1 as Latte +import org.kde.latte 0.2 as Latte import "../colorizer" as Colorizer import "communicator" as Communicator Item { id: container visible: false width: isInternalViewSplitter && !root.editMode ? 0 : (root.isHorizontal ? computeWidth : computeWidth + shownAppletMargin) height: isInternalViewSplitter && !root.editMode ? 0 : (root.isVertical ? computeHeight : computeHeight + shownAppletMargin) property bool animationsEnabled: true property bool animationWasSent: false //protection flag for animation broadcasting property bool canBeHovered: true property bool canShowAppletNumberBadge: !isSeparator && !isHidden && !isLattePlasmoid && !isSpacer && !isInternalViewSplitter property bool inFillCalculations: false //temp record, is used in calculations for fillWidth,fillHeight applets property bool needsFillSpace: { //fill flag, it is used in calculations for fillWidth,fillHeight applets if (!applet || !applet.Layout || (applet && applet.pluginName === "org.kde.plasma.panelspacer")) return false; if (((root.isHorizontal && applet.Layout.fillWidth===true) || (root.isVertical && applet.Layout.fillHeight===true)) && (applet.status !== PlasmaCore.Types.HiddenStatus)) return true; else return false; } property bool showZoomed: false property bool lockZoom: false property bool isExpanded: applet && applet.status >= PlasmaCore.Types.NeedsAttentionStatus && applet.status !== PlasmaCore.Types.HiddenStatus property bool isHidden: applet && applet.status === PlasmaCore.Types.HiddenStatus ? true : false property bool isInternalViewSplitter: (internalSplitterId > 0) property bool isLattePlasmoid: latteApplet !== null property bool isZoomed: false property bool isSeparator: applet && applet.pluginName === "audoban.applet.separator" property bool isSpacer: latteSpacer !== null property bool isSystray: applet && (applet.pluginName === "org.kde.plasma.systemtray" || applet.pluginName === "org.nomad.systemtray" ) property bool firstChildOfStartLayout: (index === layoutsContainer.startLayout.beginIndex) property bool lastChildOfEndLayout: ((index === layoutsContainer.endLayout.beginIndex+layoutsContainer.endLayout.count-1)&&(layoutsContainer.endLayout.count>1)) //applet is in starting edge /*property bool startEdge: index < layoutsContainer.endLayout.beginIndex ? (index === 0)&&(layoutsContainer.mainLayout.count > 1) : (index === layoutsContainer.endLayout.beginIndex)&&(layoutsContainer.endLayout.count > 1)*/ property bool startEdge: (index === layoutsContainer.startLayout.beginIndex) || (index === layoutsContainer.mainLayout.beginIndex) || (index === layoutsContainer.endLayout.beginIndex) //applet is in ending edge - property bool endEdge: plasmoid.configuration.panelPosition !== Latte.Dock.Justify ? (index === layoutsContainer.mainLayout.beginIndex + layoutsContainer.mainLayout.count - 1)&&(layoutsContainer.mainLayout.count>1) : + property bool endEdge: plasmoid.configuration.panelPosition !== Latte.Types.Justify ? (index === layoutsContainer.mainLayout.beginIndex + layoutsContainer.mainLayout.count - 1)&&(layoutsContainer.mainLayout.count>1) : (((index === layoutsContainer.startLayout.beginIndex+layoutsContainer.startLayout.count-2)&&(layoutsContainer.startLayout.count>2)) ||((index === layoutsContainer.mainLayout.beginIndex+layoutsContainer.mainLayout.count-2)&&(layoutsContainer.mainLayout.count>2)) ||((index === layoutsContainer.endLayout.beginIndex+layoutsContainer.endLayout.count-1)&&(layoutsContainer.endLayout.count>1))) property int animationTime: root.durationTime* (1.2 *units.shortDuration) // 70 property int hoveredIndex: layoutsContainer.hoveredIndex property int index: -1 property int appletMargin: (applet && (applet.pluginName === root.plasmoidName)) || isInternalViewSplitter || root.reverseLinesPosition ? 0 : root.statesLineSize property int maxWidth: root.isHorizontal ? root.height : root.width property int maxHeight: root.isHorizontal ? root.height : root.width property int shownAppletMargin: isSystray ? 0 : appletMargin property int internalSplitterId: 0 property int previousIndex: -1 property int sizeForFill: -1 //it is used in calculations for fillWidth,fillHeight applets property int spacersMaxSize: Math.max(0,Math.ceil(0.5*root.iconSize) - root.iconMargin) property int status: applet ? applet.status : -1 property real computeWidth: root.isVertical ? wrapper.width : hiddenSpacerLeft.width+wrapper.width+hiddenSpacerRight.width property real computeHeight: root.isVertical ? hiddenSpacerLeft.height + wrapper.height + hiddenSpacerRight.height : wrapper.height property string title: isInternalViewSplitter ? "Now Dock Splitter" : "" property Item applet: null property Item latteApplet: applet && (applet.pluginName === root.plasmoidName) ? (applet.children[0] ? applet.children[0] : null) : null property Item latteSpacer: applet && (applet.pluginName === "org.kde.latte.spacer") ? (applet.children[0] ? applet.children[0] : null) : null property Item appletWrapper: applet && ((applet.pluginName === root.plasmoidName) || isSystray) ? wrapper : wrapper.wrapperContainer property Item tooltipVisualParent: titleTooltipParent property alias containsMouse: appletMouseArea.containsMouse property alias pressed: appletMouseArea.pressed /*onComputeHeightChanged: { if(index==0) console.log(computeHeight); }*/ /// BEGIN functions function activateAppletForNeutralAreas(mouse){ //if the event is at the active indicator or spacers area then try to expand the applet, //unfortunately for other applets there is no other way to activate them yet //for example the icon-only applets var choords = mapToItem(container.appletWrapper, mouse.x, mouse.y); if (choords.x<0 || choords.y<0 || choords.x>=container.appletWrapper.width || choords.y>=container.appletWrapper.height) { dock.toggleAppletExpanded(applet.id); } } function checkIndex(){ index = -1; for(var i=0; i root.iconSize) && root.isHorizontal) || (applet && (applet.Layout.minimumHeight > root.iconSize) && root.isVertical)) && (applet && applet.pluginName !== "org.kde.plasma.panelspacer" && (applet.pluginName !== "org.kde.latte.spacer")) && !communicator.canShowOverlaiedLatteIcon) || (isSystray) || (container.needsFillSpace) ) { canBeHovered = false; } else{ canBeHovered = true; } } //! pos in global root positioning function containsPos(pos) { var relPos = root.mapToItem(container,pos.x, pos.y); if (relPos.x>=0 && relPos.x<=width && relPos.y>=0 && relPos.y<=height) return true; return false; } ///END functions //BEGIN connections onAppletChanged: { if (!applet) { destroy(); } } onHoveredIndexChanged:{ if ( (Math.abs(hoveredIndex-index) > 1) && (hoveredIndex !== -1) ) { wrapper.zoomScale = 1; } if (Math.abs(hoveredIndex-index) >= 1) { hiddenSpacerLeft.nScale = 0; hiddenSpacerRight.nScale = 0; } } onIndexChanged: { if (container.latteApplet) { root.latteAppletPos = index; } if (isHidden) { parabolicManager.setHidden(previousIndex, index); } if (isSeparator) { parabolicManager.setSeparator(previousIndex, index); } if (index>-1) { previousIndex = index; } } onIsExpandedChanged: { if (isExpanded) { root.hideTooltipLabel(); } } onIsHiddenChanged: { if (isHidden) { parabolicManager.setHidden(-1, index); } else { parabolicManager.setHidden(index, -1); } } onIsSeparatorChanged: { if (isSeparator) { parabolicManager.setSeparator(-1, index); } else { parabolicManager.setSeparator(index, -1); } } onLatteAppletChanged: { if(container.latteApplet){ root.latteApplet = container.latteApplet; root.latteAppletContainer = container; root.latteAppletPos = index; container.latteApplet.latteDock = root; container.latteApplet.forceHidePanel = true; container.latteApplet.signalAnimationsNeedBothAxis.connect(slotAnimationsNeedBothAxis); container.latteApplet.signalAnimationsNeedLength.connect(slotAnimationsNeedLength); container.latteApplet.signalAnimationsNeedThickness.connect(slotAnimationsNeedThickness); container.latteApplet.signalActionsBlockHiding.connect(slotActionsBlockHiding); container.latteApplet.signalPreviewsShown.connect(slotPreviewsShown); container.latteApplet.clearZoomSignal.connect(titleTooltipDialog.hide); } } onLatteSpacerChanged: { if(container.latteSpacer){ latteSpacer.latteDock = root; //container.lockZoom = true; } } onNeedsFillSpaceChanged: checkCanBeHovered(); onShowZoomedChanged: { if(showZoomed){ //var newZ = container.maxHeight / root.iconSize; //wrapper.zoomScale = newZ; wrapper.zoomScale = 1; } else{ wrapper.zoomScale = 1; } } Component.onCompleted: { checkIndex(); root.updateIndexes.connect(checkIndex); root.clearZoomSignal.connect(clearZoom); } Component.onDestruction: { if (isSeparator){ parabolicManager.setSeparator(previousIndex, -1); } if (isHidden) parabolicManager.setHidden(previousIndex, -1); root.updateIndexes.disconnect(checkIndex); root.clearZoomSignal.disconnect(clearZoom); if (container.latteApplet) { container.latteApplet.signalAnimationsNeedBothAxis.disconnect(slotAnimationsNeedBothAxis); container.latteApplet.signalAnimationsNeedLength.disconnect(slotAnimationsNeedLength); container.latteApplet.signalAnimationsNeedThickness.disconnect(slotAnimationsNeedThickness); container.latteApplet.signalActionsBlockHiding.disconnect(slotActionsBlockHiding); container.latteApplet.signalPreviewsShown.disconnect(slotPreviewsShown); container.latteApplet.clearZoomSignal.disconnect(titleTooltipDialog.hide); } } Connections{ target: root /* onGlobalDirectRenderChanged:{ if (root.globalDirectRender && restoreAnimation.running) { // console.log("CLEAR APPLET SCALE !!!!"); //restoreAnimation.stop(); //wrapper.zoomScale = 1; } }*/ onLatteAppletHoveredIndexChanged: { if ( (root.zoomFactor>1) && (root.latteAppletHoveredIndex >= 0) ){ var distance = 2; //for Tasks plasmoid distance of 2 is not always safe there are //cases that needs to be 3, when an internal separator there is //between the hovered task and the current applet if (root.hasInternalSeparator) { if (index < root.latteAppletPos) { var firstTaskIndex = root.latteApplet.parabolicManager.availableHigherIndex(0); distance = firstTaskIndex+2; } else if (index > root.latteAppletPos) { var lastTaskIndex = root.latteApplet.parabolicManager.availableLowerIndex(root.tasksCount-1); distance = root.tasksCount-1-lastTaskIndex+2; } } if(Math.abs(index-root.latteAppletPos+root.latteAppletHoveredIndex)>=Math.max(2,distance)) { container.clearZoom(); } } } onSignalActivateEntryAtIndex: { if (parabolicManager.pseudoIndexBelongsToLatteApplet(entryIndex) && container.isLattePlasmoid) { latteApplet.activateTaskAtIndex(entryIndex - latteApplet.tasksNumbersBase); } else if (root.unifiedGlobalShortcuts && (entryIndex === parabolicManager.pseudoAppletIndex(container.index))) { dock.toggleAppletExpanded(applet.id); } } onSignalNewInstanceForEntryAtIndex: { if (parabolicManager.pseudoIndexBelongsToLatteApplet(entryIndex) && container.isLattePlasmoid) { latteApplet.newInstanceForTaskAtIndex(entryIndex - latteApplet.tasksNumbersBase); } else if (root.unifiedGlobalShortcuts && (entryIndex === parabolicManager.pseudoAppletIndex(container.index))) { dock.toggleAppletExpanded(applet.id); } } } Connections{ target: layoutsContainer onHoveredIndexChanged:{ //for applets it is safe to consider that a distance of 2 //is enough to clearZoom if ( (root.zoomFactor>1) && (layoutsContainer.hoveredIndex>=0) && (Math.abs(index-layoutsContainer.hoveredIndex)>=2)) container.clearZoom(); if ((restoreAnimation.running) && (layoutsContainer.hoveredIndex !== -1)) { restoreAnimation.stop(); } } } Connections{ target: root onLatteAppletHoveredIndexChanged: { if ((restoreAnimation.running) && (root.latteAppletHoveredIndex !== -1)) { restoreAnimation.stop(); } } } ///END connections //! It is used for any communication needed with the underlying applet Communicator.Engine{ id: communicator //set up the overlaied containers and properties for when a overlaiedIconItem must be presented to the user //because the plasma widgets specific implementation breaks the Latte experience onOverlayLatteIconIsActiveChanged:{ if (!overlayLatteIconIsActive && applet.opacity===0) { applet.opacity = 1; wrapper.disableScaleWidth = false; wrapper.disableScaleHeight = false; wrapper.updateLayoutWidth(); wrapper.updateLayoutHeight(); } else if (overlayLatteIconIsActive && applet.opacity>0) { applet.opacity = 0; if (applet.pluginName === "org.kde.plasma.folder") { applet.parent = wrapper.containerForOverlayIcon; applet.anchors.fill = wrapper.containerForOverlayIcon; } wrapper.disableScaleWidth = false; wrapper.disableScaleHeight = false; wrapper.updateLayoutWidth(); wrapper.updateLayoutHeight(); } } } /* Rectangle{ anchors.fill: parent color: "transparent" border.color: "green" border.width: 1 }*/ MouseArea{ id: appletMouseAreaBottom anchors.fill: parent propagateComposedEvents: true visible: (!appletMouseArea.visible || !appletMouseArea.enabled) && !root.editMode property bool pressed: false onPressed: { container.activateAppletForNeutralAreas(mouse); pressed = true; mouse.accepted = false; } onReleased: { pressed = false; mouse.accepted = false; } } //! Main Applet Shown Area Flow{ id: appletFlow width: container.computeWidth height: container.computeHeight opacity: appletColorizer.mustBeShown ? 0 : 1 anchors.rightMargin: (latteApplet || (showZoomed && root.editMode)) || (plasmoid.location !== PlasmaCore.Types.RightEdge) ? 0 : shownAppletMargin anchors.leftMargin: (latteApplet || (showZoomed && root.editMode)) || (plasmoid.location !== PlasmaCore.Types.LeftEdge) ? 0 : shownAppletMargin anchors.topMargin: (latteApplet || (showZoomed && root.editMode)) || (plasmoid.location !== PlasmaCore.Types.TopEdge)? 0 : shownAppletMargin anchors.bottomMargin: (latteApplet || (showZoomed && root.editMode)) || (plasmoid.location !== PlasmaCore.Types.BottomEdge) ? 0 : shownAppletMargin Behavior on opacity { NumberAnimation { duration: 0.8 * root.animationTime easing.type: Easing.OutCubic } } // a hidden spacer for the first element to add stability // IMPORTANT: hidden spacers must be tested on vertical !!! AppletHiddenSpacer{id: hiddenSpacerLeft} AppletItemWrapper{ id: wrapper TitleTooltipParent{ id: titleTooltipParent } } // a hidden spacer on the right for the last item to add stability AppletHiddenSpacer{id: hiddenSpacerRight; rightSpacer: true} }// Flow with hidden spacers inside //Busy Indicator PlasmaComponents.BusyIndicator { z: 1000 visible: applet && applet.busy running: visible anchors.centerIn: parent width: Math.min(parent.width, parent.height) height: width } //! The Launchers Area Indicator Rectangle{ anchors.fill: parent radius: root.iconSize/10 property color tempColor: "#aa222222" color: tempColor border.width: 1 border.color: "#ff656565" opacity: latteApplet && root.addLaunchersMessage ? 1 : 0 Behavior on opacity{ NumberAnimation { duration: 2*root.durationTime*container.animationTime } } PlasmaExtras.Heading { width: parent.width height: parent.height text: i18n("Launchers Area") horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter wrapMode: Text.WordWrap elide: Text.ElideRight fontSizeMode: Text.Fit color: colorizerManager.applyTheme.textColor rotation: { if (root.isHorizontal) return 0; else if (plasmoid.location === PlasmaCore.Types.LeftEdge) return -90; else if (plasmoid.location === PlasmaCore.Types.RightEdge) return 90; } } } //! The Applet Colorizer Colorizer.Applet { id: appletColorizer anchors.fill: parent opacity: mustBeShown ? 1 : 0 readonly property bool mustBeShown: colorizerManager.mustBeShown && !communicator.disableLatteSideColoring Behavior on opacity { NumberAnimation { duration: 1.2 * root.animationTime easing.type: Easing.OutCubic } } } MouseArea{ id: appletMouseArea anchors.fill: parent enabled: applet && !latteApplet && canBeHovered && !root.editMode && !lockZoom hoverEnabled: !root.editMode && (!latteApplet) ? true : false propagateComposedEvents: true //! a way must be found in order for this be enabled //! only to support springloading for plasma 5.10 //! also on this is based the tooltips behavior by enabling it //! plasma tooltips are disabled visible: applet && !container.latteApplet && !lockZoom && canBeHovered && !(container.isSeparator && !root.editMode) //&& (root.zoomFactor>1) property bool blockWheel: false property bool pressed: false onClicked: { pressed = false; mouse.accepted = false; } onEntered: { if (containsMouse && !container.lockZoom && container.canBeHovered){ root.stopCheckRestoreZoomTimer(); } if (restoreAnimation.running) { restoreAnimation.stop(); } root.showTooltipLabel(container, applet.title); //console.log("entered applet:" + layoutsContainer.hoveredIndex); if (layoutsContainer.hoveredIndex === -1 && root.latteAppletHoveredIndex===-1) { root.startDirectRenderDelayerDuringEntering(); } if (!(root.dockIsHidden || root.inSlidingIn || root.inSlidingOut)){ layoutsContainer.hoveredIndex = index; } if (lockZoom || !canBeHovered) { return; } if (root.isHalfShown || (root.latteApplet && (root.latteApplet.noTasksInAnimation>0 || root.latteApplet.contextMenu))) { return; } if (root.isHorizontal){ layoutsContainer.currentSpot = mouseX; wrapper.calculateScales(mouseX); } else{ layoutsContainer.currentSpot = mouseY; wrapper.calculateScales(mouseY); } } onExited:{ if (communicator.appletIconItemIsShown()) { communicator.setAppletIconItemActive(false); } root.hideTooltipLabel(); if (root.zoomFactor>1){ root.startCheckRestoreZoomTimer(); } } onPositionChanged: { // if(!pressed){ if (lockZoom || !canBeHovered) { mouse.accepted = false; return; } if (root.isHalfShown || (root.latteApplet && (root.latteApplet.noTasksInAnimation>0 || root.latteApplet.contextMenu))) { return; } if (layoutsContainer.hoveredIndex === -1 && root.latteAppletHoveredIndex===-1) { root.startDirectRenderDelayerDuringEntering(); } if (!(root.dockIsHidden || root.inSlidingIn || root.inSlidingOut)){ layoutsContainer.hoveredIndex = index; } if (!root.globalDirectRender && !root.directRenderDelayerIsRunning) { root.setGlobalDirectRender(true); } if( ((wrapper.zoomScale == 1 || wrapper.zoomScale === root.zoomFactor) && !root.globalDirectRender) || root.globalDirectRender) { if (root.isHorizontal){ var step = Math.abs(layoutsContainer.currentSpot-mouse.x); if (step >= root.animationStep){ layoutsContainer.currentSpot = mouse.x; wrapper.calculateScales(mouse.x); } } else{ var step = Math.abs(layoutsContainer.currentSpot-mouse.y); if (step >= root.animationStep){ layoutsContainer.currentSpot = mouse.y; wrapper.calculateScales(mouse.y); } } } mouse.accepted = false; } onPressed: { container.activateAppletForNeutralAreas(mouse); pressed = true; //! this is needed for some applets is order to be activated/deactivated correctly //! such case is the "Application Menu". (bug #928) mouse.accepted = false; } onReleased: { pressed = false; mouse.accepted = false; } onWheel: { if (isSeparator || !root.mouseWheelActions || blockWheel || (root.dockIsHidden || root.inSlidingIn || root.inSlidingOut)){ wheel.accepted = false; return; } var angle = wheel.angleDelta.y / 8; blockWheel = true; scrollDelayer.start(); if (angle > 12) { //positive direction if (!isExpanded) { dock.toggleAppletExpanded(applet.id); } } else if (angle < -12) { //negative direction if (isExpanded) { dock.toggleAppletExpanded(applet.id); } } } //! A timer is needed in order to handle also touchpads that probably //! send too many signals very fast. This way the signals per sec are limited. //! The user needs to have a steady normal scroll in order to not //! notice a annoying delay Timer{ id: scrollDelayer interval: 700 onTriggered: appletMouseArea.blockWheel = false; } } //BEGIN states states: [ State { name: "left" when: (plasmoid.location === PlasmaCore.Types.LeftEdge) AnchorChanges { target: appletFlow anchors{ top:undefined; bottom:undefined; left:parent.left; right:undefined;} } }, State { name: "right" when: (plasmoid.location === PlasmaCore.Types.RightEdge) AnchorChanges { target: appletFlow anchors{ top:undefined; bottom:undefined; left:undefined; right:parent.right;} } }, State { name: "bottom" when: (plasmoid.location === PlasmaCore.Types.BottomEdge) AnchorChanges { target: appletFlow anchors{ top:undefined; bottom:parent.bottom; left:undefined; right:undefined;} } }, State { name: "top" when: (plasmoid.location === PlasmaCore.Types.TopEdge) AnchorChanges { target: appletFlow anchors{ top:parent.top; bottom:undefined; left:undefined; right:undefined;} } } ] //END states //BEGIN animations ///////Restore Zoom Animation///// ParallelAnimation{ id: restoreAnimation PropertyAnimation { target: wrapper property: "zoomScale" to: 1 duration: 4 * container.animationTime easing.type: Easing.InCubic } PropertyAnimation { target: hiddenSpacerLeft property: "nScale" to: 0 duration: 4 * container.animationTime easing.type: Easing.InCubic } PropertyAnimation { target: hiddenSpacerRight property: "nScale" to: 0 duration: 4 * container.animationTime easing.type: Easing.InCubic } } /////Clicked Animation///// SequentialAnimation{ id: clickedAnimation alwaysRunToEnd: true running: (appletMouseArea.pressed || appletMouseAreaBottom.pressed) && (root.durationTime > 0) onStopped: { appletMouseArea.pressed = false; appletMouseAreaBottom.pressed = false; } ParallelAnimation{ PropertyAnimation { target: wrapper.clickedEffect property: "brightness" to: -0.35 duration: units.longDuration easing.type: Easing.OutQuad } } ParallelAnimation{ PropertyAnimation { target: wrapper.clickedEffect property: "brightness" to: 0 duration: units.longDuration easing.type: Easing.OutQuad } } } //END animations } diff --git a/containment/package/contents/ui/applet/AppletItemWrapper.qml b/containment/package/contents/ui/applet/AppletItemWrapper.qml index a78a7ee9..88942234 100644 --- a/containment/package/contents/ui/applet/AppletItemWrapper.qml +++ b/containment/package/contents/ui/applet/AppletItemWrapper.qml @@ -1,822 +1,822 @@ /* * Copyright 2016 Smith AR * Michail Vourlakos * * This file is part of Latte-Dock * * Latte-Dock 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. * * Latte-Dock 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.1 import QtQuick.Layouts 1.1 import QtGraphicalEffects 1.0 import org.kde.plasma.plasmoid 2.0 import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.components 2.0 as PlasmaComponents -import org.kde.latte 0.1 as Latte +import org.kde.latte 0.2 as Latte import "../../code/MathTools.js" as MathTools Item{ id: wrapper width: { if (container.isInternalViewSplitter && !root.editMode) return 0; if (container.isSeparator && !root.editMode) { if (!root.isVertical) return -1; else return root.iconSize; } //! width for applets that use fillWidth/fillHeight such plasma taskmanagers and AWC if (container.needsFillSpace && root.isHorizontal) { - if (root.panelAlignment !== Latte.Dock.Justify) { + if (root.panelAlignment !== Latte.Types.Justify) { var maximumValue = (applet.Layout.maximumWidth === Infinity) || applet.Layout.maximumWidth === -1 ? container.sizeForFill : Math.min(container.sizeForFill, applet.Layout.maximumWidth); var constrainedWidth = MathTools.bound(applet.Layout.minimumWidth, applet.Layout.preferredWidth, maximumValue); return root.editMode ? Math.max(constrainedWidth, root.iconSize) : constrainedWidth; } if(container.sizeForFill>-1){ return container.sizeForFill; } } if (container.latteApplet) { //! commented because it was breaking the context menu available area, I don't remember where //! we needed this... // if (container.showZoomed && root.isVertical) // return root.statesLineSize + root.thickMargin + root.iconSize + 1; //else return latteApplet.tasksWidth; } else { return scaledWidth; } } height: { if (container.isInternalViewSplitter && !root.editMode) return 0; if (container.isSeparator && !root.editMode) { if (root.isVertical) return -1; else return root.iconSize; } //! height for applets that use fillWidth/fillHeight such plasma taskmanagers and AWC if (container.needsFillSpace && root.isVertical) { - if (root.panelAlignment !== Latte.Dock.Justify) { + if (root.panelAlignment !== Latte.Types.Justify) { var maximumValue = (applet.Layout.maximumHeight === Infinity) || applet.Layout.maximumHeight === -1 ? container.sizeForFill : Math.min(container.sizeForFill, applet.Layout.maximumHeight); var constrainedHeight = MathTools.bound(applet.Layout.minimumHeight, applet.Layout.preferredHeight, maximumValue); return root.editMode ? Math.max(constrainedHeight, root.iconSize) : constrainedHeight; } if (container.sizeForFill>-1){ return container.sizeForFill; } } if (container.latteApplet) { //! commented because it was breaking the context menu available area, I don't remember where //! we needed this... //if (container.showZoomed && root.isHorizontal) // return root.statesLineSize + root.thickMargin + root.iconSize + 1; // else return latteApplet.tasksHeight; } else { return scaledHeight; } } //width: container.isInternalViewSplitter && !root.editMode ? 0 : Math.round( latteApplet ? ((container.showZoomed && root.isVertical) ? // scaledWidth : latteApplet.tasksWidth) : scaledWidth ) //height: container.isInternalViewSplitter&& !root.editMode ? 0 : Math.round( latteApplet ? ((container.showZoomed && root.isHorizontal) ? // scaledHeight : latteApplet.tasksHeight ): scaledHeight ) property bool disableScaleWidth: false property bool disableScaleHeight: false property bool editMode: root.editMode property int appletMinimumWidth: applet && applet.Layout ? applet.Layout.minimumWidth : -1 property int appletMinimumHeight: applet && applet.Layout ? applet.Layout.minimumHeight : -1 property int appletPreferredWidth: applet && applet.Layout ? applet.Layout.preferredWidth : -1 property int appletPreferredHeight: applet && applet.Layout ? applet.Layout.preferredHeight : -1 property int appletMaximumWidth: applet && applet.Layout ? applet.Layout.maximumWidth : -1 property int appletMaximumHeight: applet && applet.Layout ? applet.Layout.maximumHeight : -1 property int iconSize: root.iconSize property int marginWidth: root.isVertical ? (container.isSystray ? root.thickMarginBase : root.thickMargin ) : (root.inFullJustify && (container.firstChildOfStartLayout || container.lastChildOfEndLayout ) ? 0 : root.iconMargin) //Fitt's Law property int marginHeight: root.isHorizontal ? (container.isSystray ? root.thickMarginBase : root.thickMargin ) : (root.inFullJustify && (container.firstChildOfStartLayout || container.lastChildOfEndLayout ) ? 0 : root.iconMargin) //Fitt's Law property real scaledWidth: zoomScaleWidth * (layoutWidth + marginWidth) property real scaledHeight: zoomScaleHeight * (layoutHeight + marginHeight) property real zoomScaleWidth: disableScaleWidth ? 1 : zoomScale property real zoomScaleHeight: disableScaleHeight ? 1 : zoomScale property int layoutWidthResult: 0 property int layoutWidth property int layoutHeight // property int localMoreSpace: root.reverseLinesPosition ? root.statesLineSize + 2 : appletMargin property int localMoreSpace: appletMargin property int moreHeight: (container.isSystray || root.reverseLinesPosition) && root.isHorizontal ? localMoreSpace : 0 property int moreWidth: (container.isSystray || root.reverseLinesPosition) && root.isVertical ? localMoreSpace : 0 property real center:(width + hiddenSpacerLeft.separatorSpace + hiddenSpacerRight.separatorSpace) / 2 property real zoomScale: 1 property int index: container.index property Item wrapperContainer: _wrapperContainer property Item clickedEffect: _clickedEffect property Item containerForOverlayIcon: _containerForOverlayIcon // property int pHeight: applet ? applet.Layout.preferredHeight : -10 /*function debugLayouts(){ if(applet){ console.log("---------- "+ applet.pluginName +" ----------"); console.log("MinW "+applet.Layout.minimumWidth); console.log("PW "+applet.Layout.preferredWidth); console.log("MaxW "+applet.Layout.maximumWidth); console.log("FillW "+applet.Layout.fillWidth); console.log("-----"); console.log("MinH "+applet.Layout.minimumHeight); console.log("PH "+applet.Layout.preferredHeight); console.log("MaxH "+applet.Layout.maximumHeight); console.log("FillH "+applet.Layout.fillHeight); console.log("-----"); console.log("LayoutW: " + layoutWidth); console.log("LayoutH: " + layoutHeight); } } onLayoutWidthChanged: { debugLayouts(); } onLayoutHeightChanged: { debugLayouts(); }*/ onAppletMinimumWidthChanged: { if(zoomScale == 1) checkCanBeHovered(); updateLayoutWidth(); } onAppletMinimumHeightChanged: { if(zoomScale == 1) checkCanBeHovered(); updateLayoutHeight(); } onAppletPreferredWidthChanged: updateLayoutWidth(); onAppletPreferredHeightChanged: updateLayoutHeight(); onAppletMaximumWidthChanged: updateLayoutWidth(); onAppletMaximumHeightChanged: updateLayoutHeight(); onIconSizeChanged: { updateLayoutWidth(); updateLayoutHeight(); } onEditModeChanged: { updateLayoutWidth(); updateLayoutHeight(); } onZoomScaleChanged: { if ((zoomScale === root.zoomFactor) && !root.globalDirectRender) { root.setGlobalDirectRender(true); } if ((zoomScale > 1) && !container.isZoomed) { container.isZoomed = true; if (!root.editMode && !animationWasSent) { root.slotAnimationsNeedBothAxis(1); animationWasSent = true; } } else if ((zoomScale == 1) && container.isZoomed) { container.isZoomed = false; if (animationWasSent) { root.slotAnimationsNeedBothAxis(-1); animationWasSent = false; } } } Connections { target: root onIsVerticalChanged: { if (container.latteApplet) { return; } wrapper.disableScaleWidth = false; wrapper.disableScaleHeight = false; if (root.isVertical) { wrapper.updateLayoutHeight(); wrapper.updateLayoutWidth(); } else { wrapper.updateLayoutWidth(); wrapper.updateLayoutHeight(); } } } function updateLayoutHeight(){ if (container.needsFillSpace && root.isVertical) { layoutsContainer.updateSizeForAppletsInFill(); return; } if (isLattePlasmoid) { return; } else if (container.isInternalViewSplitter){ if(!root.editMode) layoutHeight = 0; else layoutHeight = root.iconSize + moreHeight + root.statesLineSize; } else if(applet && applet.pluginName === "org.kde.plasma.panelspacer"){ layoutHeight = root.iconSize + moreHeight; } else if(container.isSystray && root.isHorizontal){ layoutHeight = root.statesLineSize + root.iconSize; } else{ if(applet && (applet.Layout.minimumHeight > root.iconSize) && root.isVertical && !canBeHovered && !communicator.overlayLatteIconIsActive){ layoutHeight = applet.Layout.minimumHeight; } //it is used for plasmoids that need to scale only one axis... e.g. the Weather Plasmoid else if(applet && ( applet.Layout.maximumHeight < root.iconSize || applet.Layout.preferredHeight > root.iconSize || container.lockZoom) && root.isVertical && !disableScaleWidth && !communicator.overlayLatteIconIsActive) { if (!container.isSpacer) { disableScaleHeight = true; } //this way improves performance, probably because during animation the preferred sizes update a lot if((applet.Layout.maximumHeight < root.iconSize)){ layoutHeight = applet.Layout.maximumHeight; } else if (applet.Layout.minimumHeight > root.iconSize){ layoutHeight = applet.Layout.minimumHeight; } else if ((applet.Layout.preferredHeight > root.iconSize) || (container.lockZoom && applet.Layout.preferredHeight > 0 )){ layoutHeight = applet.Layout.preferredHeight; } else{ layoutHeight = root.iconSize + moreHeight; } } else { layoutHeight = root.iconSize + moreHeight; } } } function updateLayoutWidth(){ if (container.needsFillSpace && root.isHorizontal) { layoutsContainer.updateSizeForAppletsInFill(); return; } if (isLattePlasmoid) { return; } else if (container.isInternalViewSplitter){ if(!root.editMode) layoutWidth = 0; else layoutWidth = root.iconSize + moreWidth + root.statesLineSize; } else if(applet && applet.pluginName === "org.kde.plasma.panelspacer"){ layoutWidth = root.iconSize + moreWidth; } else if(container.isSystray && root.isVertical){ layoutWidth = root.statesLineSize + root.iconSize; } else{ if(applet && (applet.Layout.minimumWidth > root.iconSize) && root.isHorizontal && !canBeHovered && !communicator.overlayLatteIconIsActive){ layoutWidth = applet.Layout.minimumWidth; } //it is used for plasmoids that need to scale only one axis... e.g. the Weather Plasmoid else if(applet && ( applet.Layout.maximumWidth < root.iconSize || applet.Layout.preferredWidth > root.iconSize || container.lockZoom) && root.isHorizontal && !disableScaleHeight && !communicator.overlayLatteIconIsActive){ if (!container.isSpacer) { disableScaleWidth = true; } //this way improves performance, probably because during animation the preferred sizes update a lot if((applet.Layout.maximumWidth < root.iconSize)){ // return applet.Layout.maximumWidth; layoutWidth = applet.Layout.maximumWidth; } else if (applet.Layout.minimumWidth > root.iconSize){ layoutWidth = applet.Layout.minimumWidth; } else if ((applet.Layout.preferredWidth > root.iconSize) || (container.lockZoom && applet.Layout.preferredWidth > 0 )){ layoutWidth = applet.Layout.preferredWidth; } else{ layoutWidth = root.iconSize + moreWidth; } } else{ layoutWidth = root.iconSize + moreWidth; } } } Loader{ anchors.fill: parent - active: root.activeIndicator === Latte.Dock.AllIndicator - || (root.activeIndicator === Latte.Dock.InternalsIndicator && communicator.overlayLatteIconIsActive) + active: root.activeIndicator === Latte.Types.AllIndicator + || (root.activeIndicator === Latte.Types.InternalsIndicator && communicator.overlayLatteIconIsActive) sourceComponent: Item{ anchors.fill: parent ActiveIndicator{} } } Item{ id:_wrapperContainer width:{ if (container.needsFillSpace && (container.sizeForFill>-1) && root.isHorizontal){ return wrapper.width; } if (container.isInternalViewSplitter) return wrapper.layoutWidth; else return parent.zoomScaleWidth * wrapper.layoutWidth; } height:{ if (container.needsFillSpace && (container.sizeForFill>-1) && root.isVertical){ return wrapper.height; } if (container.isInternalViewSplitter) return wrapper.layoutHeight; else return parent.zoomScaleHeight * wrapper.layoutHeight; } //width: Math.round( container.isInternalViewSplitter ? wrapper.layoutWidth : parent.zoomScaleWidth * wrapper.layoutWidth ) //height: Math.round( container.isInternalViewSplitter ? wrapper.layoutHeight : parent.zoomScaleHeight * wrapper.layoutHeight ) anchors.rightMargin: plasmoid.location === PlasmaCore.Types.RightEdge ? lowThickUsed : 0 anchors.leftMargin: plasmoid.location === PlasmaCore.Types.LeftEdge ? lowThickUsed : 0 anchors.topMargin: plasmoid.location === PlasmaCore.Types.TopEdge ? lowThickUsed : 0 anchors.bottomMargin: plasmoid.location === PlasmaCore.Types.BottomEdge ? lowThickUsed : 0 opacity: appletShadow.active ? 0 : 1 property int lowThickUsed: root.thickMarginBase //BEGIN states states: [ State { name: "left" when: (plasmoid.location === PlasmaCore.Types.LeftEdge) AnchorChanges { target: _wrapperContainer anchors{ verticalCenter:wrapper.verticalCenter; horizontalCenter:undefined; top:undefined; bottom:undefined; left:parent.left; right:undefined;} } }, State { name: "right" when: (plasmoid.location === PlasmaCore.Types.RightEdge) AnchorChanges { target: _wrapperContainer anchors{ verticalCenter:wrapper.verticalCenter; horizontalCenter:undefined; top:undefined; bottom:undefined; left:undefined; right:parent.right;} } }, State { name: "bottom" when: (plasmoid.location === PlasmaCore.Types.BottomEdge) AnchorChanges { target: _wrapperContainer anchors{ verticalCenter:undefined; horizontalCenter:wrapper.horizontalCenter; top:undefined; bottom:parent.bottom; left:undefined; right:undefined;} } }, State { name: "top" when: (plasmoid.location === PlasmaCore.Types.TopEdge) AnchorChanges { target: _wrapperContainer anchors{ verticalCenter:undefined; horizontalCenter:wrapper.horizontalCenter; top:parent.top; bottom:undefined; left:undefined; right:undefined;} } } ] //END states ///Secret MouseArea to be used by the folder widget Loader{ anchors.fill: parent active: communicator.overlayLatteIconIsActive && applet.pluginName === "org.kde.plasma.folder" sourceComponent: MouseArea{ onClicked: dock.toggleAppletExpanded(applet.id); } } Item{ id: _containerForOverlayIcon anchors.centerIn: parent //we setup as maximum for hidden container of some applets that break //the Latte experience the size:96 or units.iconSizeHints.panel. //This is why after that size the folder widget changes //to fullRepresentation instead of compact one width: Math.min(maxSize, parent.width) height: width property int maxSize:{ if (Latte.WindowSystem.plasmaDesktopVersion === 0 || (Latte.WindowSystem.plasmaDesktopVersion < Latte.WindowSystem.makeVersion(5,12,80)) ) { return 96; } else { return units.iconSizeHints.panel; } } } Loader{ anchors.fill: parent active: communicator.overlayLatteIconIsActive sourceComponent: Latte.IconItem{ id: overlayIconItem anchors.fill: parent source: { if (communicator.appletIconItemIsShown()) return communicator.appletIconItem.source; else if (communicator.appletImageItemIsShown()) return communicator.appletImageItem.source; } usesPlasmaTheme: communicator.appletIconItemIsShown() ? communicator.appletIconItem.usesPlasmaTheme : false Loader{ anchors.centerIn: parent active: root.debugModeOverloadedIcons sourceComponent: Rectangle{ width: 30 height: 30 color: "green" opacity: 0.65 } } //ActiveIndicator{} } } } //spacer background Loader{ anchors.fill: _wrapperContainer active: applet && (applet.pluginName === "org.kde.plasma.panelspacer") && root.editMode sourceComponent: Rectangle{ anchors.fill: parent border.width: 1 border.color: theme.textColor color: "transparent" opacity: 0.7 radius: root.iconMargin Rectangle{ anchors.centerIn: parent color: parent.border.color width: parent.width - 1 height: parent.height - 1 opacity: 0.2 } } } Loader{ anchors.fill: _wrapperContainer active: container.isInternalViewSplitter && root.editMode rotation: root.isVertical ? 90 : 0 sourceComponent: PlasmaCore.SvgItem{ id:splitterImage anchors.fill: parent svg: PlasmaCore.Svg{ imagePath: root.universalSettings.splitterIconPath() } layer.enabled: true layer.effect: DropShadow { radius: root.appShadowSize fast: true samples: 2 * radius color: root.appShadowColor verticalOffset: 2 } Component.onCompleted: { if (root.isVertical) { wrapper.updateLayoutHeight(); wrapper.updateLayoutWidth(); } else { wrapper.updateLayoutWidth(); wrapper.updateLayoutHeight(); } } } } ///Shadow in applets Loader{ id: appletShadow anchors.fill: container.appletWrapper active: container.applet && !appletColorizer.mustBeShown && (((plasmoid.configuration.shadows === 1 /*Locked Applets*/ && (!container.canBeHovered || (container.lockZoom && (applet.pluginName !== root.plasmoidName))) ) || (plasmoid.configuration.shadows === 2 /*All Applets*/ && (applet.pluginName !== root.plasmoidName))) || (root.forceTransparentPanel && plasmoid.configuration.shadows>0 && applet.pluginName !== root.plasmoidName)) /*on forced transparent state*/ onActiveChanged: { if (active) { wrapperContainer.opacity = 0; } else { wrapperContainer.opacity = 1; } } sourceComponent: DropShadow{ anchors.fill: parent color: root.appShadowColor //"#ff080808" fast: true samples: 2 * radius source: communicator.overlayLatteIconIsActive ? _wrapperContainer : container.applet radius: shadowSize verticalOffset: forcedShadow ? 0 : 2 property int shadowSize : root.appShadowSize //Math.ceil(root.iconSize / 12) property bool forcedShadow: root.forceTransparentPanel && plasmoid.configuration.shadows>0 && applet.pluginName !== root.plasmoidName ? true : false } } BrightnessContrast{ id:hoveredImage anchors.fill: _wrapperContainer source: _wrapperContainer enabled: opacity != 0 ? true : false opacity: appletMouseArea.containsMouse ? 1 : 0 brightness: 0.25 contrast: 0.15 Behavior on opacity { NumberAnimation { duration: root.durationTime*units.longDuration } } } BrightnessContrast { id: _clickedEffect anchors.fill: _wrapperContainer source: _wrapperContainer visible: clickedAnimation.running } /// START Applets Number Loader{ id: appletNumberLoader anchors.fill: container.appletWrapper active: isValidDelayer > 0 asynchronous: true visible: badgeString!=="" property int fixedIndex: -1 property string badgeString: "" onActiveChanged: { if (active) { fixedIndex = parabolicManager.pseudoAppletIndex(index); } } Component.onCompleted: fixedIndex = parabolicManager.pseudoAppletIndex(index); property real isValidDelayer: container.canShowAppletNumberBadge && ((root.showAppletsNumbers && root.unifiedGlobalShortcuts) || (root.showMetaBadge && applet.id===applicationLauncherId)) ? 1 : 0 Behavior on isValidDelayer { NumberAnimation { duration: root.durationTime*units.longDuration } } Binding{ target: appletNumberLoader property:"badgeString" value: { //! don't change value on hiding/releasing if (!root.showMetaBadge && !root.showAppletsNumbers) { return; } if (root.showMetaBadge && applet && applet.id === applicationLauncherId) { return '\u2318'; } else if (appletNumberLoader.fixedIndex>=1 && appletNumberLoader.fixedIndex<20) { return root.badgesForActivate[appletNumberLoader.fixedIndex-1]; } else { return ""; } } } sourceComponent: Item{ Loader{ anchors.fill: appletNumber active: root.enableShadows sourceComponent: DropShadow{ color: root.appShadowColor fast: true samples: 2 * radius source: appletNumber radius: root.appShadowSize/2 verticalOffset: 2 } } Latte.BadgeText { id: appletNumber anchors.centerIn: parent minimumWidth: 0.4 * root.iconSize height: width border.color: root.minimizedDotColor proportion: 0 radiusPerCentage: 50 showNumber: false showText: true textValue: appletNumberLoader.badgeString } } } //END of Applets number /* onHeightChanged: { if ((index == 1)|| (index==3)){ console.log("H: "+index+" ("+zoomScale+"). "+currentLayout.children[1].height+" - "+currentLayout.children[3].height+" - "+(currentLayout.children[1].height+currentLayout.children[3].height)); } } onZoomScaleChanged:{ if ((index == 1)|| (index==3)){ console.log(index+" ("+zoomScale+"). "+currentLayout.children[1].height+" - "+currentLayout.children[3].height+" - "+(currentLayout.children[1].height+currentLayout.children[3].height)); } }*/ Loader{ anchors.fill: parent active: root.debugMode sourceComponent: Rectangle{ anchors.fill: parent color: "transparent" //! red visualizer, in debug mode for the applets that use fillWidth or fillHeight //! green, for the rest border.color: (container.needsFillSpace && (container.sizeForFill>-1) && root.isHorizontal) ? "red" : "green" border.width: 1 } } Behavior on zoomScale { enabled: !root.globalDirectRender NumberAnimation { duration: 3 * container.animationTime easing.type: Easing.OutCubic } } Behavior on zoomScale { enabled: root.globalDirectRender && !restoreAnimation.running NumberAnimation { duration: root.directRenderAnimationTime } } function calculateScales( currentMousePosition ){ if (root.editMode || root.zoomFactor===1 || root.durationTime===0) { return; } var distanceFromHovered = Math.abs(index - layoutsContainer.hoveredIndex); // A new algorithm tryig to make the zoom calculation only once // and at the same time fixing glitches if ((distanceFromHovered == 0)&& (currentMousePosition > 0) ){ //use the new parabolicManager in order to handle all parabolic effect messages var scales = parabolicManager.applyParabolicEffect(index, currentMousePosition, center); /*if (root.latteApplet && Math.abs(index - root.latteAppletPos) > 2){ root.latteApplet.clearZoom(); }*/ //Left hiddenSpacer if(container.startEdge){ hiddenSpacerLeft.nScale = scales.leftScale - 1; } //Right hiddenSpacer ///there is one more item in the currentLayout ???? if(container.endEdge){ hiddenSpacerRight.nScale = scales.rightScale - 1; } zoomScale = root.zoomFactor; } } //scale function signalUpdateScale(nIndex, nScale, step){ if(container && !container.containsMouse && (container.index === nIndex)){ if ( ((canBeHovered && !lockZoom ) || container.latteApplet) && (applet && applet.status !== PlasmaCore.Types.HiddenStatus) //&& (index != currentLayout.hoveredIndex) ){ if(!container.latteApplet){ if(nScale >= 0) zoomScale = nScale + step; else zoomScale = zoomScale + step; } } } } Component.onCompleted: { root.updateScale.connect(signalUpdateScale); } Component.onDestruction: { root.updateScale.disconnect(signalUpdateScale); } }// Main task area // id:wrapper diff --git a/containment/package/contents/ui/colorizer/CustomBackground.qml b/containment/package/contents/ui/colorizer/CustomBackground.qml index f0498fcb..d3a44872 100644 --- a/containment/package/contents/ui/colorizer/CustomBackground.qml +++ b/containment/package/contents/ui/colorizer/CustomBackground.qml @@ -1,201 +1,201 @@ /* * Copyright 2018 Michail Vourlakos * * This file is part of Latte-Dock * * Latte-Dock 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. * * Latte-Dock 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.plasmoid 2.0 import org.kde.plasma.core 2.0 as PlasmaCore -import org.kde.latte 0.1 as Latte +import org.kde.latte 0.2 as Latte Item{ id: main anchors.fill: parent clip: true property int roundness: 0 property color backgroundColor property bool topBorder: false property bool leftBorder: false property bool bottomBorder: false property bool rightBorder: false property int noOfBorders: { var i = 0; if (topBorder) { i = i + 1; } if (leftBorder) { i = i + 1; } if (rightBorder) { i = i + 1; } if (bottomBorder) { i = i + 1; } return i; } readonly property bool drawWithoutRoundness: noOfBorders === 1 || !Latte.WindowSystem.compositingActive Binding{ target: main property: "topBorder" when: dock value: { return ((dock && dock.effects && (dock.effects.enabledBorders & PlasmaCore.FrameSvg.TopBorder)) > 0); } } Binding{ target: main property: "leftBorder" when: dock value: { return ((dock && dock.effects && (dock.effects.enabledBorders & PlasmaCore.FrameSvg.LeftBorder)) > 0); } } Binding{ target: main property: "bottomBorder" when: dock value: { return ((dock && dock.effects && (dock.effects.enabledBorders & PlasmaCore.FrameSvg.BottomBorder)) > 0); } } Binding{ target: main property: "rightBorder" when: dock value: { return ((dock && dock.effects && (dock.effects.enabledBorders & PlasmaCore.FrameSvg.RightBorder)) > 0); } } Rectangle{ id: painter anchors.verticalCenter: parent.verticalCenter anchors.horizontalCenter: parent.horizontalCenter width: { if (plasmoid.formFactor === PlasmaCore.Types.Horizontal) { if (drawWithoutRoundness || noOfBorders === 3) { return parent.width; } else if (noOfBorders === 2) { return parent.width + roundness; } } else if (plasmoid.formFactor === PlasmaCore.Types.Vertical) { if (drawWithoutRoundness) { return parent.width; } else if (noOfBorders === 2 || noOfBorders === 3) { return parent.width + roundness; } } } height: { if (plasmoid.formFactor === PlasmaCore.Types.Horizontal) { if (drawWithoutRoundness) { return parent.height; } else if (noOfBorders === 2 || noOfBorders === 3) { return parent.height + roundness; } } else if (plasmoid.formFactor === PlasmaCore.Types.Vertical) { if (drawWithoutRoundness || noOfBorders === 3) { return parent.height; } else if (noOfBorders === 2) { return parent.height + roundness; } } } radius: drawWithoutRoundness ? 0 : roundness color: parent.backgroundColor border.width: 0; border.color: "transparent" readonly property int centerStep: roundness / 2 states: [ State { name: "horizontal" when: (plasmoid.formFactor === PlasmaCore.Types.Horizontal) PropertyChanges{ target: painter anchors.horizontalCenterOffset: { if (drawWithoutRoundness || noOfBorders === 3) { return 0; } else if (noOfBorders === 2) { if (leftBorder) { return centerStep; } else if (rightBorder) { return -centerStep; } } return 0; } anchors.verticalCenterOffset: { if (drawWithoutRoundness) { return 0; } else { //top edge and bottom edge return plasmoid.location === PlasmaCore.Types.TopEdge ? -centerStep : centerStep; } } } }, State { name: "vertical" when: (plasmoid.formFactor === PlasmaCore.Types.Vertical) PropertyChanges{ target: painter anchors.verticalCenterOffset: { if (drawWithoutRoundness || noOfBorders === 3) { return 0; } else if (noOfBorders === 2) { if (bottomBorder) { return -centerStep; } else if (topBorder) { return centerStep; } } } anchors.horizontalCenterOffset: { if (drawWithoutRoundness) { return 0; } else { //left edge and right edge return plasmoid.location === PlasmaCore.Types.LeftEdge ? -centerStep : centerStep; } } } } ] } } diff --git a/containment/package/contents/ui/colorizer/Manager.qml b/containment/package/contents/ui/colorizer/Manager.qml index add99ac2..5f414d81 100644 --- a/containment/package/contents/ui/colorizer/Manager.qml +++ b/containment/package/contents/ui/colorizer/Manager.qml @@ -1,92 +1,92 @@ /* * Copyright 2018 Michail Vourlakos * * This file is part of Latte-Dock * * Latte-Dock 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. * * Latte-Dock 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.plasmoid 2.0 import org.kde.plasma.core 2.0 as PlasmaCore -import org.kde.latte 0.1 as Latte +import org.kde.latte 0.2 as Latte import "../../code/ColorizerTools.js" as ColorizerTools Loader{ id: manager active: forceColorizer || forceSolidnessAndColorize readonly property bool forceSolidness: (root.solidPanel && !plasmoid.configuration.solidBackgroundForMaximized) || root.forceSolidPanel || !Latte.WindowSystem.compositingActive readonly property bool forceSolidnessAndColorize: forceSolidness && forceColorizeFromActiveWindowScheme readonly property real themeBackgroundColorLuma: ColorizerTools.colorLuminas(theme.backgroundColor) readonly property real themeTextColorLuma: ColorizerTools.colorLuminas(theme.textColor) readonly property color minimizedDotColor: themeTextColorLuma > 0.6 ? Qt.darker(theme.textColor, 1.7) : Qt.lighter(theme.textColor, 7) property bool mustBeShown: active && (!forceSolidPanel || forceSolidnessAndColorize) //! when forceSemiTransparentPanel is enabled because of snapped or maximized etc. windows //! then the colorizer could be enabled for low panel transparency levels (<40%) && (!userShowPanelBackground || !forceSemiTransparentPanel || (forceSemiTransparentPanel && root.panelTransparency<40)) && !maximizedWindowTitleBarBehavesAsPanelBackground && (plasmoid.configuration.solidBackgroundForMaximized || plasmoid.configuration.backgroundOnlyOnMaximized) && !root.editMode && Latte.WindowSystem.compositingActive property real currentBackgroundLuminas: item ? item.currentBackgroundLuminas : -1000 property QtObject applyTheme: { if (forceSolidnessAndColorize && dock.visibility.touchingWindowScheme) { return dock.visibility.touchingWindowScheme; } if (themeExtended) { if (currentBackgroundLuminas > 0.5) { return themeExtended.lightTheme; } else { return themeExtended.darkTheme; } } return theme; } property color applyColor: applyTheme.textColor //! new TEMPORARY options to pass palette to applets //! UNTIL Latte produces two different color schemes files (LIGHT / DARK) //! to be passed to applets etc... readonly property color backgroundColor: applyTheme.backgroundColor readonly property color textColor: applyTheme.textColor readonly property color inactiveBackgroundColor: applyTheme === theme ? theme.backgroundColor : applyTheme.inactiveBackgroundColor readonly property color inactiveTextColor: applyTheme === theme ? theme.textColor : applyTheme.inactiveTextColor readonly property color highlightColor: theme.highlightColor readonly property color highlightedTextColor: theme.highlightedTextColor readonly property color positiveTextColor: applyTheme.positiveTextColor readonly property color neutralTextColor: applyTheme.neutralTextColor readonly property color negativeTextColor: applyTheme.negativeTextColor readonly property color buttonTextColor: theme.buttonTextColor readonly property color buttonBackgroundColor: theme.buttonBackgroundColor readonly property color buttonHoverColor: theme.buttonHoverColor readonly property color buttonFocusColor: theme.buttonFocusColor readonly property string scheme: themeExtended ? applyTheme.schemeFile : "kdeglobals" sourceComponent: BackgroundTracker{} } diff --git a/containment/package/contents/ui/main.qml b/containment/package/contents/ui/main.qml index 1a9ea9d1..0ec1a75a 100644 --- a/containment/package/contents/ui/main.qml +++ b/containment/package/contents/ui/main.qml @@ -1,1814 +1,1814 @@ /* * Copyright 2016 Smith AR * Michail Vourlakos * * This file is part of Latte-Dock * * Latte-Dock 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. * * Latte-Dock 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.1 import QtQuick.Layouts 1.1 import QtQuick.Window 2.2 import QtGraphicalEffects 1.0 import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.components 2.0 as PlasmaComponents import org.kde.kquickcontrolsaddons 2.0 import org.kde.draganddrop 2.0 as DragDrop import org.kde.plasma.plasmoid 2.0 -import org.kde.latte 0.1 as Latte +import org.kde.latte 0.2 as Latte import "applet" as Applet import "colorizer" as Colorizer import "../code/LayoutManager.js" as LayoutManager DragDrop.DropArea { id: root objectName: "dockLayoutView" LayoutMirroring.enabled: Qt.application.layoutDirection === Qt.RightToLeft && !root.isVertical LayoutMirroring.childrenInherit: true //// BEGIN SIGNALS signal clearZoomSignal(); signal separatorsUpdated(); signal signalActivateEntryAtIndex(int entryIndex); signal signalNewInstanceForEntryAtIndex(int entryIndex); signal updateEffectsArea(); signal updateIndexes(); signal updateScale(int delegateIndex, real newScale, real step); //// END SIGNALS ////BEGIN properties property bool debugMode: Qt.application.arguments.indexOf("--graphics")>=0 property bool debugModeSpacers: Qt.application.arguments.indexOf("--spacers")>=0 property bool debugModeTimers: Qt.application.arguments.indexOf("--timers")>=0 property bool debugModeWindow: Qt.application.arguments.indexOf("--with-window")>=0 property bool debugModeOverloadedIcons: Qt.application.arguments.indexOf("--overloaded-icons")>=0 property bool globalDirectRender: false //it is used as a globalDirectRender for all elements in the dock property int directRenderAnimationTime: 0 property bool addLaunchersMessage: false property bool addLaunchersInTaskManager: plasmoid.configuration.addLaunchersInTaskManager // when there are only plasma style task managers the automatic icon size algorithm should better be disabled property bool autoDecreaseIconSize: plasmoid.configuration.autoDecreaseIconSize && !containsOnlyPlasmaTasks && layoutsContainer.fillApplets<=0 property bool backgroundOnlyOnMaximized: plasmoid.configuration.backgroundOnlyOnMaximized property bool behaveAsPlasmaPanel: { if (!dock || !dock.visibility) return false; return (visibilityManager.panelIsBiggerFromIconSize && (zoomFactor === 1.0) - && (dock.visibility.mode === Latte.Dock.AlwaysVisible || dock.visibility.mode === Latte.Dock.WindowsGoBelow) - && (plasmoid.configuration.panelPosition === Latte.Dock.Justify) && !(root.solidPanel && panelShadowsActive)); + && (dock.visibility.mode === Latte.Types.AlwaysVisible || dock.visibility.mode === Latte.Types.WindowsGoBelow) + && (plasmoid.configuration.panelPosition === Latte.Types.Justify) && !(root.solidPanel && panelShadowsActive)); } property bool blurEnabled: plasmoid.configuration.blurEnabled && !root.forceTransparentPanel || (hasExpandedApplet && zoomFactor===1 && plasmoid.configuration.panelSize===100) property bool confirmedDragEntered: false property bool containsOnlyPlasmaTasks: false //this is flag to indicate when from tasks only a plasma based one is found property bool dockContainsMouse: dock && dock.visibility ? dock.visibility.containsMouse : false property bool disablePanelShadowMaximized: plasmoid.configuration.disablePanelShadowForMaximized && Latte.WindowSystem.compositingActive property bool drawShadowsExternal: panelShadowsActive && behaveAsPlasmaPanel && !visibilityManager.inTempHiding property bool editMode: editModeVisual.inEditMode property bool windowIsTouching: dock && dock.visibility && (dock.visibility.existsWindowMaximized || dock.visibility.existsWindowSnapped || hasExpandedApplet) property bool forceSemiTransparentPanel: ((!plasmoid.configuration.solidBackgroundForMaximized && plasmoid.configuration.backgroundOnlyOnMaximized && windowIsTouching) || (plasmoid.configuration.solidBackgroundForMaximized && !plasmoid.configuration.backgroundOnlyOnMaximized && !windowIsTouching)) && Latte.WindowSystem.compositingActive property bool forceSolidPanel: plasmoid.configuration.solidBackgroundForMaximized && dock && dock.visibility && Latte.WindowSystem.compositingActive &&(dock.visibility.existsWindowMaximized || dock.visibility.existsWindowSnapped || hasExpandedApplet || showAppletsNumbers || showMetaBadge) property bool forceTransparentPanel: root.backgroundOnlyOnMaximized && dock && dock.visibility && !(dock.visibility.existsWindowMaximized || dock.visibility.existsWindowSnapped) && Latte.WindowSystem.compositingActive && !(hasExpandedApplet && zoomFactor===1 && plasmoid.configuration.panelSize===100) property bool forceColorizer: Latte.WindowSystem.compositingActive && plasmoid.configuration.colorizeTransparentPanels property bool forceColorizeFromActiveWindowScheme: plasmoid.configuration.colorizeFromActiveWindowScheme && !editMode && (dock && dock.visibility && dock.visibility.touchingWindowScheme && (dock.visibility.existsWindowMaximized || dock.visibility.existsWindowSnapped) && !hasExpandedApplet) property bool maximizedWindowTitleBarBehavesAsPanelBackground: dock && dock.visibility && (!plasmoid.configuration.solidBackgroundForMaximized && plasmoid.configuration.backgroundOnlyOnMaximized) - && (dock.visibility.mode === Latte.Dock.WindowsGoBelow) + && (dock.visibility.mode === Latte.Types.WindowsGoBelow) && (plasmoid.location === PlasmaCore.Types.TopEdge) && (!useThemePanel || panelTransparency<40) && dock.visibility.existsWindowMaximized readonly property bool hasExpandedApplet: plasmoid.applets.some(function (item) { return (item.status >= PlasmaCore.Types.NeedsAttentionStatus && item.status !== PlasmaCore.Types.HiddenStatus && item.pluginName !== root.plasmoidName && item.pluginName !== "org.kde.activeWindowControl"); }) readonly property bool hasUserSpecifiedBackground: (dock && dock.managedLayout && dock.managedLayout.background.startsWith("/")) ? true : false property bool dockIsShownCompletely: !(dockIsHidden || inSlidingIn || inSlidingOut) && !root.editMode property bool immutable: plasmoid.immutable property bool indicateAudioStreams: plasmoid.configuration.indicateAudioStreams - property bool inFullJustify: (plasmoid.configuration.panelPosition === Latte.Dock.Justify) && (plasmoid.configuration.maxLength===100) + property bool inFullJustify: (plasmoid.configuration.panelPosition === Latte.Types.Justify) && (plasmoid.configuration.maxLength===100) property bool inSlidingIn: visibilityManager ? visibilityManager.inSlidingIn : false property bool inSlidingOut: visibilityManager ? visibilityManager.inSlidingOut : false property bool inStartup: true property bool isHalfShown: false //is used to disable the zoom hovering effect at sliding in-out the dock property bool isHorizontal: plasmoid.formFactor === PlasmaCore.Types.Horizontal property bool isReady: !(dockIsHidden || inSlidingIn || inSlidingOut) property bool isVertical: !isHorizontal property bool isHovered: latteApplet ? ((latteAppletHoveredIndex !== -1) && (layoutsContainer.hoveredIndex !== -1)) //|| wholeArea.containsMouse : (layoutsContainer.hoveredIndex !== -1) //|| wholeArea.containsMouse property bool mouseWheelActions: plasmoid.configuration.mouseWheelActions property bool normalState : false property bool onlyAddingStarup: true //is used for the initialization phase in startup where there arent removals, this variable provides a way to grow icon size property bool shrinkThickMargins: plasmoid.configuration.shrinkThickMargins property bool showAppletsNumbers: false property bool showMetaBadge: false property int applicationLauncherId: -1 property bool solidPanel: Latte.WindowSystem.compositingActive ? plasmoid.configuration.solidPanel : true //FIXME: possibly this is going to be the default behavior, this user choice //has been dropped from the Dock Configuration Window //property bool smallAutomaticIconJumps: plasmoid.configuration.smallAutomaticIconJumps property bool smallAutomaticIconJumps: true property bool userShowPanelBackground: Latte.WindowSystem.compositingActive ? plasmoid.configuration.useThemePanel : true property bool useThemePanel: noApplets === 0 || !Latte.WindowSystem.compositingActive ? true : (plasmoid.configuration.useThemePanel || plasmoid.configuration.solidBackgroundForMaximized) property alias hoveredIndex: layoutsContainer.hoveredIndex property alias directRenderDelayerIsRunning: directRenderDelayerForEnteringTimer.running property int activeIndicator: plasmoid.configuration.activeIndicator property int actionsBlockHiding: 0 //actions that block hiding property int animationsNeedBothAxis:0 //animations need space in both axes, e.g zooming a task property int animationsNeedLength: 0 // animations need length, e.g. adding a task property int animationsNeedThickness: 0 // animations need thickness, e.g. bouncing animation property int animationTime: durationTime*2.8*units.longDuration property int automaticIconSizeBasedSize: -1 //it is not set, this is the defautl //what is the highest icon size based on what icon size is used, screen calculated or user specified property int maxIconSize: proportionIconSize!==-1 ? proportionIconSize : plasmoid.configuration.iconSize property int iconSize: automaticIconSizeBasedSize > 0 && autoDecreaseIconSize ? Math.min(automaticIconSizeBasedSize, root.maxIconSize) : root.maxIconSize property int proportionIconSize: { //icon size based on screen height if ((plasmoid.configuration.proportionIconSize===-1) || !dock) return -1; return Math.max(16,Math.round(dock.screenGeometry.height * plasmoid.configuration.proportionIconSize/100/8)*8); } property int iconStep: 8 property int latteAppletPos: -1 property int maxLength: { if (root.isHorizontal) { return behaveAsPlasmaPanel ? width : width * (plasmoid.configuration.maxLength/100) } else { return behaveAsPlasmaPanel ? height : height * (plasmoid.configuration.maxLength/100) } } property int middleClickAction: plasmoid.configuration.middleClickAction property int modifier: plasmoid.configuration.modifier property int modifierClickAction: plasmoid.configuration.modifierClickAction property int modifierClick: plasmoid.configuration.modifierClick property int panelEdgeSpacing: Math.max(panelBoxBackground.lengthMargins, 1.5*appShadowSize) property int panelTransparency: plasmoid.configuration.panelTransparency //user set property int currentPanelTransparency: 0 //application override property bool panelShadowsActive: { if (!userShowPanelBackground) { return false; } if (( (plasmoid.configuration.panelShadows && !root.backgroundOnlyOnMaximized) || (plasmoid.configuration.panelShadows && root.backgroundOnlyOnMaximized && !root.forceTransparentPanel)) && !(disablePanelShadowMaximized && dock.visibility.existsWindowMaximized)) { return true; } if (hasExpandedApplet && zoomFactor===1 && plasmoid.configuration.panelSize===100 && !(root.solidPanel && !plasmoid.configuration.panelShadows) ) { return true; } return false; } property int appShadowOpacity: (plasmoid.configuration.shadowOpacity/100) * 255 property int appShadowSize: enableShadows ? (0.4*root.iconSize) * (plasmoid.configuration.shadowSize/100) : 0 property int appShadowSizeOriginal: enableShadows ? (0.4*maxIconSize) * (plasmoid.configuration.shadowSize/100) : 0 property string appShadowColor: "#" + decimalToHex(appShadowOpacity) + plasmoid.configuration.shadowColor property string appShadowColorSolid: "#" + plasmoid.configuration.shadowColor property int totalPanelEdgeSpacing: 0 //this is set by PanelBox //FIXME: this is not needed any more probably property int previousAllTasks: -1 //is used to forbit updateAutomaticIconSize when hovering property int offset: { /*if (behaveAsPlasmaPanel) { return 0; }*/ if (root.isHorizontal) { return width * (plasmoid.configuration.offset/100); } else { height * (plasmoid.configuration.offset/100) } } //center the layout correctly when the user uses an offset - property int offsetFixed: (offset===0 || panelAlignment === Latte.Dock.Center || plasmoid.configuration.panelPosition === Latte.Dock.Justify)? + property int offsetFixed: (offset===0 || panelAlignment === Latte.Types.Center || plasmoid.configuration.panelPosition === Latte.Types.Justify)? offset : offset+panelMarginLength/2+totalPanelEdgeSpacing/2 property int realSize: iconSize + iconMargin property int realPanelSize: 0 property int realPanelLength: 0 property int realPanelThickness: 0 //this is set by the PanelBox property int panelMargin: 0 property int panelMarginLength: 0 property int panelShadow: 0 //shadowsSize property int editShadow: { if (!Latte.WindowSystem.compositingActive) { return 0; } else if (dock && dock.screenGeometry) { return (dock.screenGeometry.height/90); } else { return 7; } } property int themePanelSize: { //root.statesLineSize + root.iconSize + root.iconMargin + 1 var panelBase = root.statesLineSize + root.panelMargin; var margin = latteApplet ? thickMargin : 0; var maxPanelSize = (root.statesLineSize + iconSize + margin + 1) - panelBase; var percentage = Latte.WindowSystem.compositingActive ? plasmoid.configuration.panelSize/100 : 1; return Math.max(panelBase, panelBase + percentage*maxPanelSize); } //decouple iconMargin which now is used only for length calculations with thickMargins //which are used for thickness calculations property int thickMarginBase: { if (shrinkThickMargins) { return 0; } else { return Math.ceil(0.06 * iconSize); } } property int thickMarginHigh: { var minimum = 2; if (shrinkThickMargins) { if (behaveAsPlasmaPanel){ return (reverseLinesPosition ? Math.max(root.statesLineSize/2, 1) : minimum); } else { return Math.max(minimum, 0.5 * appShadowSize); } } else { if (behaveAsPlasmaPanel) { return (reverseLinesPosition ? Math.max(root.statesLineSize, 4) : 4); } else { return Math.max( Math.ceil(0.06 * iconSize), 0.5 * appShadowSize); } } } property int thickMargin: thickMarginBase + thickMarginHigh //it is used in order to not break the calculations for the thickness placement //especially in automatic icon sizes calculations property int thickMarginOriginal: Math.ceil(0.06 * maxIconSize + Math.max( Math.ceil(0.06 * maxIconSize), 0.5 * appShadowSizeOriginal)) //! iconMargin from configuration is a percentage. The calculation provides a length //! for that value between 0.04 - 0.5 of iconSize, this way 100% iconMargin means //! equal to the iconSize property int iconMargin: Math.ceil( ((0.5 * (plasmoid.configuration.iconMargin))/100) * iconSize) - property int statesLineSize: (latteApplet && !(root.showWindowsOnlyFromLaunchers && root.activeIndicator === Latte.Dock.NoneIndicator)) - || (activeIndicator !== Latte.Dock.NoneIndicator) ? Math.ceil( root.iconSize/13 ) : 0 + property int statesLineSize: (latteApplet && !(root.showWindowsOnlyFromLaunchers && root.activeIndicator === Latte.Types.NoneIndicator)) + || (activeIndicator !== Latte.Types.NoneIndicator) ? Math.ceil( root.iconSize/13 ) : 0 ///FIXME: I can't remember why this is needed, maybe for the anchorings!!! In order for the Double Layout to not mess the anchorings... - //property int layoutsContainer.mainLayoutPosition: !plasmoid.immutable ? Latte.Dock.Center : (root.isVertical ? Latte.Dock.Top : Latte.Dock.Left) - //property int panelAlignment: plasmoid.configuration.panelPosition !== Latte.Dock.Justify ? plasmoid.configuration.panelPosition : layoutsContainer.mainLayoutPosition + //property int layoutsContainer.mainLayoutPosition: !plasmoid.immutable ? Latte.Types.Center : (root.isVertical ? Latte.Types.Top : Latte.Types.Left) + //property int panelAlignment: plasmoid.configuration.panelPosition !== Latte.Types.Justify ? plasmoid.configuration.panelPosition : layoutsContainer.mainLayoutPosition property int panelAlignment: !root.editMode ? plasmoid.configuration.panelPosition : - ( plasmoid.configuration.panelPosition === Latte.Dock.Justify ? - Latte.Dock.Center : plasmoid.configuration.panelPosition ) + ( plasmoid.configuration.panelPosition === Latte.Types.Justify ? + Latte.Types.Center : plasmoid.configuration.panelPosition ) property real zoomFactor: (Latte.WindowSystem.compositingActive && durationTime>0) ? ( 1 + (plasmoid.configuration.zoomLevel / 20) ) : 1 readonly property string plasmoidName: "org.kde.latte.plasmoid" property var badgesForActivate: { if (!universalSettings) { return ['1','2','3','4','5','6','7','8','9','0', 'z', 'x', 'c', 'v', 'b', 'n', 'm', ',', '.']; } return universalSettings.badgesForActivate; } property var iconsArray: [16, 22, 32, 48, 64, 96, 128, 256] property var layoutManager: LayoutManager property Item dragOverlay property Item toolBox property Item latteAppletContainer property Item latteApplet property Item parabolicManager: _parabolicManager property QtObject dock: null property QtObject themeExtended: null property QtObject universalSettings: null property QtObject universalLayoutManager: null property QtObject dockManagedLayout: dock && dock.managedLayout ? dock.managedLayout : null // TO BE DELETED, if not needed: property int counter:0; ///BEGIN properties provided to Latte Plasmoid //shadows for applets, it should be removed as the appleitems don't need it any more property bool enableShadows: plasmoid.configuration.shadows || (root.forceTransparentPanel && plasmoid.configuration.shadows>0) property bool dockIsHidden: dock ? dock.visibility.isHidden : true property bool groupTasksByDefault: plasmoid.configuration.groupTasksByDefault property bool dotsOnActive: plasmoid.configuration.dotsOnActive property bool highlightWindows: plasmoid.configuration.highlightWindows property bool reverseLinesPosition: !latteApplet && plasmoid.configuration.panelSize===100 ? !plasmoid.configuration.reverseLinesPosition : plasmoid.configuration.reverseLinesPosition property bool showGlow: plasmoid.configuration.showGlow property bool glow3D: plasmoid.configuration.glow3D property bool showToolTips: plasmoid.configuration.showToolTips property bool showWindowActions: plasmoid.configuration.showWindowActions property bool showWindowsOnlyFromLaunchers: plasmoid.configuration.showWindowsOnlyFromLaunchers property bool showOnlyCurrentScreen: plasmoid.configuration.showOnlyCurrentScreen property bool showOnlyCurrentDesktop: plasmoid.configuration.showOnlyCurrentDesktop property bool showOnlyCurrentActivity: plasmoid.configuration.showOnlyCurrentActivity property bool smartLaunchersEnabled: plasmoid.configuration.smartLaunchersEnabled property bool threeColorsWindows: plasmoid.configuration.threeColorsWindows property bool titleTooltips: plasmoid.configuration.titleTooltips property bool unifiedGlobalShortcuts: plasmoid.configuration.unifiedGlobalShortcuts readonly property bool hasInternalSeparator: latteApplet ? latteApplet.hasInternalSeparator : false property int activeIndicatorType: plasmoid.configuration.activeIndicatorType property int animationStep: { - if (!universalSettings || universalSettings.mouseSensitivity === Latte.Dock.HighSensitivity) { + if (!universalSettings || universalSettings.mouseSensitivity === Latte.Types.HighSensitivity) { return 1; - } else if (universalSettings.mouseSensitivity === Latte.Dock.MediumSensitivity) { + } else if (universalSettings.mouseSensitivity === Latte.Types.MediumSensitivity) { return Math.max(3, root.iconSize / 18); - } else if (universalSettings.mouseSensitivity === Latte.Dock.LowSensitivity) { + } else if (universalSettings.mouseSensitivity === Latte.Types.LowSensitivity) { return Math.max(5, root.iconSize / 10); } } property int glowOption: plasmoid.configuration.glowOption property real glowOpacity: plasmoid.configuration.glowOpacity/100 property int latteAppletHoveredIndex: latteApplet ? latteApplet.hoveredIndex : -1 property int launchersGroup: plasmoid.configuration.launchersGroup property int tasksCount: latteApplet ? latteApplet.tasksCount : 0 property real durationTime: { if ((dock && dock.effects && dock.effects.animationsBlocked) || !Latte.WindowSystem.compositingActive) { return 0; } if (plasmoid.configuration.durationTime === 0 || plasmoid.configuration.durationTime === 2 ) return plasmoid.configuration.durationTime; if (plasmoid.configuration.durationTime === 1) return 1.65; else if (plasmoid.configuration.durationTime === 3) return 2.35; return 2; } property rect screenGeometry: dock ? dock.screenGeometry : plasmoid.screenGeometry readonly property color minimizedDotColor: colorizerManager.minimizedDotColor ///END properties from latteApplet /* Layout.preferredWidth: plasmoid.immutable ? - (plasmoid.configuration.panelPosition === Latte.Dock.Justify ? + (plasmoid.configuration.panelPosition === Latte.Types.Justify ? layoutsContainer.width + 0.5*iconMargin : layoutsContainer.mainLayout.width + iconMargin) : Screen.width //on unlocked state use the maximum Layout.preferredHeight: plasmoid.immutable ? - (plasmoid.configuration.panelPosition === Latte.Dock.Justify ? + (plasmoid.configuration.panelPosition === Latte.Types.Justify ? layoutsContainer.height + 0.5*iconMargin : layoutsContainer.mainLayout.height + iconMargin) : Screen.height //on unlocked state use the maximum*/ Plasmoid.backgroundHints: PlasmaCore.Types.NoBackground //// BEGIN properties in functions property int noApplets: { var count1 = 0; var count2 = 0; count1 = layoutsContainer.mainLayout.children.length; var tempLength = layoutsContainer.mainLayout.children.length; for (var i=tempLength-1; i>=0; --i) { var applet = layoutsContainer.mainLayout.children[i]; if (applet && (applet === dndSpacer || applet === lastSpacer || applet.isInternalViewSplitter)) count1--; } count2 = layoutsContainer.endLayout.children.length; tempLength = layoutsContainer.endLayout.children.length; for (var i=tempLength-1; i>=0; --i) { var applet = layoutsContainer.endLayout.children[i]; if (applet && (applet === dndSpacer || applet === lastSpacer || applet.isInternalViewSplitter)) count2--; } return (count1 + count2); } ///The index of user's current icon size property int currentIconIndex:{ for(var i=iconsArray.length-1; i>=0; --i){ if(iconsArray[i] === iconSize){ return i; } } return 3; } //// END properties in functions ////////////////END properties //// BEGIN OF Behaviors Behavior on iconMargin { NumberAnimation { duration: 0.8 * root.animationTime easing.type: Easing.OutCubic } } Behavior on iconSize { enabled: !(root.editMode && root.behaveAsPlasmaPanel) NumberAnimation { duration: 0.8 * root.animationTime onRunningChanged: { if (!running) { delayUpdateMaskArea.start(); } } } } Behavior on offset { enabled: editModeVisual.plasmaEditMode NumberAnimation { id: offsetAnimation duration: 0.8 * root.animationTime easing.type: Easing.OutCubic } } //// END OF Behaviors //////////////START OF CONNECTIONS onContainsOnlyPlasmaTasksChanged: updateAutomaticIconSize(); onEditModeChanged: { if (editMode) { visibilityManager.updateMaskArea(); updateAutomaticIconSize(); clearZoom(); } else { updateAutomaticIconSize(); layoutsContainer.updateSizeForAppletsInFill(); } updateLayouts(); //! This is used in case the dndspacer has been left behind //! e.g. the user drops a folder and a context menu is appearing //! but the user decides to not make a choice for the applet type if (dndSpacer.parent !== root) { dndSpacer.parent = root; } } onDockChanged: { if (dock) { dock.onAddInternalViewSplitter.connect(addInternalViewSplitters); dock.onRemoveInternalViewSplitter.connect(removeInternalViewSplitters); dock.onXChanged.connect(visibilityManager.updateMaskArea); dock.onYChanged.connect(visibilityManager.updateMaskArea); dock.onWidthChanged.connect(visibilityManager.updateMaskArea); dock.onHeightChanged.connect(visibilityManager.updateMaskArea); dock.positioner.hideDockDuringLocationChangeStarted.connect(visibilityManager.slotHideDockDuringLocationChange); dock.positioner.showDockAfterLocationChangeFinished.connect(visibilityManager.slotShowDockAfterLocationChange); dock.positioner.hideDockDuringScreenChangeStarted.connect(visibilityManager.slotHideDockDuringLocationChange); dock.positioner.showDockAfterScreenChangeFinished.connect(visibilityManager.slotShowDockAfterLocationChange); dock.positioner.hideDockDuringMovingToLayoutStarted.connect(visibilityManager.slotHideDockDuringLocationChange); dock.positioner.showDockAfterMovingToLayoutFinished.connect(visibilityManager.slotShowDockAfterLocationChange); dock.visibility.onContainsMouseChanged.connect(visibilityManager.slotContainsMouseChanged); dock.visibility.onMustBeHide.connect(visibilityManager.slotMustBeHide); dock.visibility.onMustBeShown.connect(visibilityManager.slotMustBeShown); updateContainsOnlyPlasmaTasks(); } } onDockContainsMouseChanged: { if (!dockContainsMouse) { initializeHoveredIndexes(); } } onDragEnter: { if (plasmoid.immutable || dockIsHidden || visibilityManager.inSlidingIn || visibilityManager.inSlidingOut) { event.ignore(); return; } if (event.mimeData.formats.indexOf("application/x-orgkdeplasmataskmanager_taskbuttonitem") >= 0) { return; } if (latteApplet) { if (latteApplet.launchersDrop(event)) { root.addLaunchersMessage = true; if (root.addLaunchersInTaskManager) { return; } } else if (dock.mimeContainsPlasmoid(event.mimeData, "audoban.applet.separator") && root.latteAppletContainer.containsPos(event)) { confirmedDragEntered = true dndSpacer.opacity = 0; dndSpacer.parent = root; return; } } if (!confirmedDragEntered) { confirmedDragEntered = true; slotAnimationsNeedLength(1); } if (!latteApplet || (latteApplet && !dock.mimeContainsPlasmoid(event.mimeData, "org.kde.latte.plasmoid"))) { LayoutManager.insertAtCoordinates2(dndSpacer, event.x, event.y) dndSpacer.opacity = 1; } } onDragMove: { if (event.mimeData.formats.indexOf("application/x-orgkdeplasmataskmanager_taskbuttonitem") >= 0 || dockIsHidden || visibilityManager.inSlidingIn || visibilityManager.inSlidingOut) { return; } if (latteApplet) { if (latteApplet.launchersDrop(event)) { root.addLaunchersMessage = true; if (root.addLaunchersInTaskManager) { return; } } else if (dock.mimeContainsPlasmoid(event.mimeData, "audoban.applet.separator") && root.latteAppletContainer.containsPos(event)) { confirmedDragEntered = true dndSpacer.opacity = 0; dndSpacer.parent = root; return; } } if (!latteApplet || (latteApplet && !dock.mimeContainsPlasmoid(event.mimeData, "org.kde.latte.plasmoid"))) { LayoutManager.insertAtCoordinates2(dndSpacer, event.x, event.y) dndSpacer.opacity = 1; } } onDragLeave: { if (confirmedDragEntered) { slotAnimationsNeedLength(-1); confirmedDragEntered = false; } root.addLaunchersMessage = false; dndSpacer.opacity = 0; dndSpacer.parent = root; } onDrop: { if (dockIsHidden || visibilityManager.inSlidingIn || visibilityManager.inSlidingOut) { return; } if (event.mimeData.formats.indexOf("application/x-orgkdeplasmataskmanager_taskbuttonitem") < 0) { if (latteApplet && latteApplet.launchersDrop(event) && root.addLaunchersInTaskManager) { latteApplet.launchersDropped(event.mimeData.urls); } else if (!latteApplet || (latteApplet && !dock.mimeContainsPlasmoid(event.mimeData, "org.kde.latte.plasmoid"))) { plasmoid.processMimeData(event.mimeData, event.x, event.y); event.accept(event.proposedAction); } } if (confirmedDragEntered) { slotAnimationsNeedLength(-1); confirmedDragEntered = false; } root.addLaunchersMessage = false; dndSpacer.opacity = 0; //! this line is very important because it positions correctly the new applets //dndSpacer.parent = root; } onMaxLengthChanged: { layoutsContainer.updateSizeForAppletsInFill(); if (root.editMode) { updateAutomaticIconSize(); } } onToolBoxChanged: { if (toolBox) { toolBox.visible = false; } } property bool automaticSizeAnimation: false; onAutomaticIconSizeBasedSizeChanged: { if (!automaticSizeAnimation) { automaticSizeAnimation = true; slotAnimationsNeedBothAxis(1); } } onIconSizeChanged: { if (((iconSize === automaticIconSizeBasedSize) || (iconSize === root.maxIconSize)) && automaticSizeAnimation){ slotAnimationsNeedBothAxis(-1); automaticSizeAnimation=false; } } onIsReadyChanged: { if (isReady && !titleTooltipDialog.visible && titleTooltipDialog.activeItemHovered){ titleTooltipDialog.show(titleTooltipDialog.activeItem, titleTooltipDialog.activeItemText); } } onIsVerticalChanged: { if (isVertical) { - if (plasmoid.configuration.panelPosition === Latte.Dock.Left) - plasmoid.configuration.panelPosition = Latte.Dock.Top; - else if (plasmoid.configuration.panelPosition === Latte.Dock.Right) - plasmoid.configuration.panelPosition = Latte.Dock.Bottom; + if (plasmoid.configuration.panelPosition === Latte.Types.Left) + plasmoid.configuration.panelPosition = Latte.Types.Top; + else if (plasmoid.configuration.panelPosition === Latte.Types.Right) + plasmoid.configuration.panelPosition = Latte.Types.Bottom; } else { - if (plasmoid.configuration.panelPosition === Latte.Dock.Top) - plasmoid.configuration.panelPosition = Latte.Dock.Left; - else if (plasmoid.configuration.panelPosition === Latte.Dock.Bottom) - plasmoid.configuration.panelPosition = Latte.Dock.Right; + if (plasmoid.configuration.panelPosition === Latte.Types.Top) + plasmoid.configuration.panelPosition = Latte.Types.Left; + else if (plasmoid.configuration.panelPosition === Latte.Types.Bottom) + plasmoid.configuration.panelPosition = Latte.Types.Right; } } onProportionIconSizeChanged: { if (proportionIconSize!==-1) updateAutomaticIconSize(); } // onIconSizeChanged: console.log("Icon Size Changed:"+iconSize); Component.onCompleted: { // currentLayout.isLayoutHorizontal = isHorizontal LayoutManager.plasmoid = plasmoid; LayoutManager.root = root; LayoutManager.layout = layoutsContainer.mainLayout; LayoutManager.layoutS = layoutsContainer.startLayout; layoutManager.layoutE = layoutsContainer.endLayout; LayoutManager.lastSpacer = lastSpacer; LayoutManager.restore(); plasmoid.action("configure").visible = !plasmoid.immutable; plasmoid.action("configure").enabled = !plasmoid.immutable; inStartupTimer.start(); } Component.onDestruction: { console.debug("Destroying Latte Dock Containment ui..."); if (dock) { dock.onAddInternalViewSplitter.disconnect(addInternalViewSplitters); dock.onRemoveInternalViewSplitter.disconnect(removeInternalViewSplitters); dock.onXChanged.disconnect(visibilityManager.updateMaskArea); dock.onYChanged.disconnect(visibilityManager.updateMaskArea); dock.onWidthChanged.disconnect(visibilityManager.updateMaskArea); dock.onHeightChanged.disconnect(visibilityManager.updateMaskArea); dock.positioner.hideDockDuringLocationChangeStarted.disconnect(visibilityManager.slotHideDockDuringLocationChange); dock.positioner.showDockAfterLocationChangeFinished.disconnect(visibilityManager.slotShowDockAfterLocationChange); dock.positioner.hideDockDuringScreenChangeStarted.disconnect(visibilityManager.slotHideDockDuringLocationChange); dock.positioner.showDockAfterScreenChangeFinished.disconnect(visibilityManager.slotShowDockAfterLocationChange); dock.positioner.hideDockDuringMovingToLayoutStarted.disconnect(visibilityManager.slotHideDockDuringLocationChange); dock.positioner.showDockAfterMovingToLayoutFinished.disconnect(visibilityManager.slotShowDockAfterLocationChange); if (dock.visibility) { dock.visibility.onContainsMouseChanged.disconnect(visibilityManager.slotContainsMouseChanged); dock.visibility.onMustBeHide.disconnect(visibilityManager.slotMustBeHide); dock.visibility.onMustBeShown.disconnect(visibilityManager.slotMustBeShown); } } } Containment.onAppletAdded: { addApplet(applet, x, y); LayoutManager.save(); updateIndexes(); } Containment.onAppletRemoved: { LayoutManager.removeApplet(applet); var flexibleFound = false; for (var i = 0; i < layoutsContainer.mainLayout.children.length; ++i) { var applet = layoutsContainer.mainLayout.children[i].applet; if (applet && ((root.isHorizontal && applet.Layout.fillWidth) || (!root.isHorizontal && applet.Layout.fillHeight)) && applet.visible) { flexibleFound = true; break } } if (!flexibleFound) { lastSpacer.parent = layoutsContainer.mainLayout; } LayoutManager.save(); updateIndexes(); updateContainsOnlyPlasmaTasks(); } Plasmoid.onUserConfiguringChanged: { if (plasmoid.immutable) { if (dragOverlay) { dragOverlay.destroy(); } return; } // console.debug("user configuring", plasmoid.userConfiguring) if (plasmoid.userConfiguring) { dock.setBlockHiding(true); // console.log("applets------"); for (var i = 0; i < plasmoid.applets.length; ++i) { // console.log("applet:"+i); plasmoid.applets[i].expanded = false; } if (!dragOverlay) { var component = Qt.createComponent("ConfigOverlay.qml"); if (component.status == Component.Ready) { dragOverlay = component.createObject(root); } else { console.log("Could not create ConfigOverlay"); console.log(component.errorString()); } component.destroy(); } else { dragOverlay.visible = true; } } else { dock.setBlockHiding(false); if (dock.visibility.isHidden) { dock.visibility.mustBeShown(); } if (dragOverlay) { dragOverlay.visible = false; dragOverlay.destroy(); } } } Plasmoid.onImmutableChanged: { plasmoid.action("configure").visible = !plasmoid.immutable; plasmoid.action("configure").enabled = !plasmoid.immutable; ///Set Preferred Sizes/// ///Notice: they are set here because if they are set with a binding ///they break the !immutable experience, the dock becomes too small ///to add applets if (plasmoid.immutable) { if(root.isHorizontal) { - root.Layout.preferredWidth = (plasmoid.configuration.panelPosition === Latte.Dock.Justify ? + root.Layout.preferredWidth = (plasmoid.configuration.panelPosition === Latte.Types.Justify ? layoutsContainer.width + 0.5*iconMargin : layoutsContainer.mainLayout.width + iconMargin); } else { - root.Layout.preferredHeight = (plasmoid.configuration.panelPosition === Latte.Dock.Justify ? + root.Layout.preferredHeight = (plasmoid.configuration.panelPosition === Latte.Types.Justify ? layoutsContainer.height + 0.5*iconMargin : layoutsContainer.mainLayout.height + iconMargin); } } else { if (root.isHorizontal) { root.Layout.preferredWidth = Screen.width; } else { root.Layout.preferredHeight = Screen.height; } } visibilityManager.updateMaskArea(); } //////////////END OF CONNECTIONS //////////////START OF FUNCTIONS function addApplet(applet, x, y) { var container = appletContainerComponent.createObject(dndSpacer.parent) container.applet = applet; applet.parent = container.appletWrapper; applet.anchors.fill = container.appletWrapper; applet.visible = true; // don't show applet if it choses to be hidden but still make it // accessible in the panelcontroller container.visible = Qt.binding(function() { return applet.status !== PlasmaCore.Types.HiddenStatus || (!plasmoid.immutable && plasmoid.userConfiguring) }) addContainerInLayout(container, applet, x, y); updateContainsOnlyPlasmaTasks(); } function addContainerInLayout(container, applet, x, y){ // Is there a DND placeholder? Replace it! if ( (dndSpacer.parent === layoutsContainer.mainLayout) || (dndSpacer.parent === layoutsContainer.startLayout) || (dndSpacer.parent===layoutsContainer.endLayout)) { LayoutManager.insertBeforeForLayout(dndSpacer.parent, dndSpacer, container); dndSpacer.parent = root; return; // If the provided position is valid, use it. } else if (x >= 0 && y >= 0) { var index = LayoutManager.insertAtCoordinates2(container, x , y); // Fall through to determining an appropriate insert position. } else { var before = null; container.animationsEnabled = false; if (lastSpacer.parent === layoutsContainer.mainLayout) { before = lastSpacer; } // Insert icons to the left of whatever is at the center (usually a Task Manager), // if it exists. // FIXME TODO: This is a real-world fix to produce a sensible initial position for // launcher icons added by launcher menu applets. The basic approach has been used // since Plasma 1. However, "add launcher to X" is a generic-enough concept and // frequent-enough occurrence that we'd like to abstract it further in the future // and get rid of the ugliness of parties external to the containment adding applets // of a specific type, and the containment caring about the applet type. In a better // system the containment would be informed of requested launchers, and determine by // itself what it wants to do with that information. if (applet.pluginName == "org.kde.plasma.icon") { var middle = layoutsContainer.mainLayout.childAt(root.width / 2, root.height / 2); if (middle) { before = middle; } // Otherwise if lastSpacer is here, enqueue before it. } if (before) { LayoutManager.insertBefore(before, container); // Fall through to adding at the end. } else { container.parent = layoutsContainer.mainLayout; } } //Important, removes the first children of the layoutsContainer.mainLayout after the first //applet has been added lastSpacer.parent = root; updateIndexes(); } function addInternalViewSplitters(){ addInternalViewSplitter(-1); addInternalViewSplitter(-1); } function addInternalViewSplitter(pos){ var splittersCount = internalViewSplittersCount(); if(splittersCount<2){ var container = appletContainerComponent.createObject(root); container.internalSplitterId = splittersCount+1; container.visible = true; if(pos>=0 ){ layoutManager.insertAtIndex(container, pos); } else { layoutManager.insertAtIndex(container, Math.floor(layoutsContainer.mainLayout.count / 2)); } layoutManager.save(); } } //! it is used in order to check the right click position //! the only way to take into account the visual appearance //! of the applet (including its spacers) function appletContainsPos(appletId, pos){ for (var i = 0; i < layoutsContainer.startLayout.children.length; ++i) { var child = layoutsContainer.startLayout.children[i]; if (child && child.applet && child.applet.id === appletId && child.containsPos(pos)) return true; } for (var i = 0; i < layoutsContainer.mainLayout.children.length; ++i) { var child = layoutsContainer.mainLayout.children[i]; if (child && child.applet && child.applet.id === appletId && child.containsPos(pos)) return true; } for (var i = 0; i < layoutsContainer.endLayout.children.length; ++i) { var child = layoutsContainer.endLayout.children[i]; if (child && child.applet && child.applet.id === appletId && child.containsPos(pos)) return true; } return false; } function checkLastSpacer() { lastSpacer.parent = root var expands = false; if (isHorizontal) { for (var container in layoutsContainer.mainLayout.children) { var item = layoutsContainer.mainLayout.children[container]; if (item.Layout && item.Layout.fillWidth) { expands = true; } } } else { for (var container in layoutsContainer.mainLayout.children) { var item = layoutsContainer.mainLayout.children[container]; if (item.Layout && item.Layout.fillHeight) { expands = true; } } } if (!expands) { lastSpacer.parent = layoutsContainer.mainLayout } } function clearZoom(){ if (latteApplet){ latteApplet.clearZoom(); } root.clearZoomSignal(); } function containmentActions(){ return dock.containmentActions(); } function decimalToHex(d, padding) { var hex = Number(d).toString(16); padding = typeof (padding) === "undefined" || padding === null ? padding = 2 : padding; while (hex.length < padding) { hex = "0" + hex; } return hex; } function disableDirectRender(){ // root.globalDirectRender = false; } function internalViewSplittersCount(){ var splitters = 0; for (var container in layoutsContainer.startLayout.children) { var item = layoutsContainer.startLayout.children[container]; if(item && item.isInternalViewSplitter) { splitters++; } } for (var container in layoutsContainer.mainLayout.children) { var item = layoutsContainer.mainLayout.children[container]; if(item && item.isInternalViewSplitter) { splitters++; } } for (var container in layoutsContainer.endLayout.children) { var item = layoutsContainer.endLayout.children[container]; if(item && item.isInternalViewSplitter) { splitters++; } } return splitters; } function initializeHoveredIndexes() { layoutsContainer.hoveredIndex = -1; layoutsContainer.currentSpot = -1000; if (latteApplet) { latteApplet.initializeHoveredIndex(); } } function mouseInCanBeHoveredApplet(){ if (latteApplet && latteApplet.containsMouse()) return true; var applets = layoutsContainer.startLayout.children; for(var i=0; i=0; --i){ if(iconsArray[i] === size){ return true; } } return false; } function slotAnimationsNeedBothAxis(step) { if (step === 0) { return; } animationsNeedBothAxis = Math.max(animationsNeedBothAxis + step, 0); visibilityManager.updateMaskArea(); } function slotAnimationsNeedLength(step) { if (step === 0) { return; } animationsNeedLength = Math.max(animationsNeedLength + step, 0); //when need length animations are ended it would be a good idea //to update the tasks geometries in the plasmoid if(animationsNeedLength === 0 && latteApplet) { latteApplet.publishTasksGeometries(); } visibilityManager.updateMaskArea(); } function slotAnimationsNeedThickness(step) { if (step === 0) { return; } animationsNeedThickness = Math.max(animationsNeedThickness + step, 0); visibilityManager.updateMaskArea(); } //this is used when dragging a task in order to not hide the dock //and also by the menu appearing from tasks for the same reason function slotActionsBlockHiding(step) { //if (root.editMode) { // return; // } if ((step === 0) || (!dock)) { return; } actionsBlockHiding = Math.max(actionsBlockHiding + step, 0); if (actionsBlockHiding > 0){ dock.setBlockHiding(true); } else { if (!root.editMode) dock.setBlockHiding(false); } } function slotPreviewsShown(){ if (dock) { dock.deactivateApplets(); } } function startCheckRestoreZoomTimer(){ checkRestoreZoom.start(); } function stopCheckRestoreZoomTimer(){ checkRestoreZoom.stop(); } function startDirectRenderDelayerDuringEntering(){ directRenderDelayerForEnteringTimer.start(); } function setGlobalDirectRender(value) { if (latteApplet && latteApplet.waitingLaunchers.length > 0) return; if (value === true) { if (mouseInCanBeHoveredApplet()) { root.globalDirectRender = true; } else { // console.log("direct render true ignored..."); } } else { root.globalDirectRender = false; } } function updateAutomaticIconSize() { if ( !blockAutomaticUpdateIconSize.running && !visibilityManager.inTempHiding && ((visibilityManager.normalState || root.editMode) && (root.autoDecreaseIconSize || (!root.autoDecreaseIconSize && root.iconSize!=root.maxIconSize))) && (iconSize===root.maxIconSize || iconSize === automaticIconSizeBasedSize) ) { blockAutomaticUpdateIconSize.start(); var layoutLength; var maxLength = root.maxLength; //console.log("------Entered check-----"); //console.log("max length: "+ maxLength); if (root.isVertical) { - layoutLength = (plasmoid.configuration.panelPosition === Latte.Dock.Justify) ? + layoutLength = (plasmoid.configuration.panelPosition === Latte.Types.Justify) ? layoutsContainer.startLayout.height+layoutsContainer.mainLayout.height+layoutsContainer.endLayout.height : layoutsContainer.mainLayout.height } else { - layoutLength = (plasmoid.configuration.panelPosition === Latte.Dock.Justify) ? + layoutLength = (plasmoid.configuration.panelPosition === Latte.Types.Justify) ? layoutsContainer.startLayout.width+layoutsContainer.mainLayout.width+layoutsContainer.endLayout.width : layoutsContainer.mainLayout.width } var toShrinkLimit = maxLength-((root.zoomFactor-1)*(iconSize+2*iconMargin)); var toGrowLimit = maxLength-1.5*((root.zoomFactor-1)*(iconSize+2*iconMargin)); var newIconSizeFound = false; if (layoutLength > toShrinkLimit) { //must shrink // console.log("step3"); var nextIconSize = root.maxIconSize; do { nextIconSize = nextIconSize - iconStep; var factor = nextIconSize / iconSize; var nextLength = factor * layoutLength; } while ( (nextLength>toShrinkLimit) && (nextIconSize !== 16)); automaticIconSizeBasedSize = nextIconSize; newIconSizeFound = true; console.log("Step 3 - found:"+automaticIconSizeBasedSize); } else if ((layoutLength 0) { if (foundGoodSize === root.maxIconSize) { automaticIconSizeBasedSize = -1; } else { automaticIconSizeBasedSize = foundGoodSize; } newIconSizeFound = true // console.log("Step 4 - found:"+automaticIconSizeBasedSize); } else { // console.log("Step 4 - did not found..."); } } } } function updateContainsOnlyPlasmaTasks() { if (dock) { root.containsOnlyPlasmaTasks = (dock.tasksPresent() && !dock.latteTasksPresent()); } else { root.containsOnlyPlasmaTasks = false; } } function updateSizeForAppletsInFill() { layoutsContainer.updateSizeForAppletsInFill(); } function updateLayouts(){ if(!root.editMode){ // console.log("update layout - internal view splitters count:"+internalViewSplittersCount()); if (internalViewSplittersCount() === 2) { var splitter = -1; var splitter2 = -1; var totalChildren = layoutsContainer.mainLayout.children.length; for (var i=0; i=0 && splitter2 === -1) { splitter2 = i; } } // console.log("update layouts 1:"+splitter + " - "+splitter2); for (var i=0; i<=splitter; ++i){ var item = layoutsContainer.mainLayout.children[0]; item.parent = layoutsContainer.startLayout; } splitter2 = splitter2 - splitter - 1; // console.log("update layouts 2:"+splitter + " - "+splitter2); totalChildren = layoutsContainer.mainLayout.children.length; for (var i=splitter2+1; i=0; --i) { var item1 = layoutsContainer.mainLayout.children[0]; item1.parent = layoutsContainer.startLayout; } var totalChildren2 = layoutsContainer.endLayout.children.length; for (var i=totalChildren2-1; i>=0; --i) { var item2 = layoutsContainer.endLayout.children[0]; item2.parent = layoutsContainer.startLayout; } var totalChildrenL = layoutsContainer.startLayout.children.length; for (var i=totalChildrenL-1; i>=0; --i) { var itemL = layoutsContainer.startLayout.children[0]; itemL.parent = layoutsContainer.mainLayout; } } } updateIndexes(); } //END functions ////BEGIN interfaces Connections { target: Latte.WindowSystem onCompositingActiveChanged: { visibilityManager.updateMaskArea(); } } Connections { target: dock onWidthChanged:{ if (root.isHorizontal && proportionIconSize!==-1) updateAutomaticIconSize(); } onHeightChanged:{ if (root.isVertical && proportionIconSize!==-1) updateAutomaticIconSize(); } onContextMenuIsShownChanged: { if (!dock.contextMenuIsShown) { checkRestoreZoom.start(); } else { root.setGlobalDirectRender(false); } } } Connections{ target: dock && dock.visibility ? dock.visibility : root ignoreUnknownSignals : true onContainsMouseChanged: { if (mouseInHoverableArea()) { stopCheckRestoreZoomTimer(); } else { startCheckRestoreZoomTimer(); } } } Connections{ target: layoutsContainer onHoveredIndexChanged: { if (latteApplet && layoutsContainer.hoveredIndex>-1){ latteApplet.setHoveredIndex(-1); } if (latteApplet && latteApplet.windowPreviewIsShown && layoutsContainer.hoveredIndex>-1) { latteApplet.hidePreview(); } } } ////END interfaces /////BEGIN: Title Tooltip/////////// PlasmaCore.Dialog{ id: titleTooltipDialog type: PlasmaCore.Dialog.Tooltip flags: Qt.WindowStaysOnTopHint | Qt.WindowDoesNotAcceptFocus | Qt.ToolTip location: plasmoid.location mainItem: RowLayout{ Layout.fillWidth: true Layout.fillHeight: true PlasmaComponents.Label{ id:titleLbl Layout.leftMargin: 4 Layout.rightMargin: 4 Layout.topMargin: 2 Layout.bottomMargin: 2 text: titleTooltipDialog.title } } visible: false property string title: "" property bool activeItemHovered: false property Item activeItem: null property Item activeItemTooltipParent: null property string activeItemText: "" Component.onCompleted: { root.clearZoomSignal.connect(titleTooltipDialog.hide); } Component.onDestruction: { root.clearZoomSignal.disconnect(titleTooltipDialog.hide); } function hide(debug){ if (!root.titleTooltips) return; activeItemHovered = false; hideTitleTooltipTimer.start(); } function show(taskItem, text){ if (!root.titleTooltips || (latteApplet && latteApplet.contextMenu)){ return; } activeItemHovered = true; if (activeItem !== taskItem) { activeItem = taskItem; activeItemTooltipParent = taskItem.tooltipVisualParent; activeItemText = text; } if (isReady) { showTitleTooltipTimer.start(); } } function update() { activeItemHovered = true title = activeItemText; visualParent = activeItemTooltipParent; if (latteApplet && latteApplet.windowPreviewIsShown) { latteApplet.hidePreview(); } visible = true; } } Timer { id: showTitleTooltipTimer interval: 100 onTriggered: { if (dock && dock.visibility && dock.visibility.containsMouse) { titleTooltipDialog.update(); } if (titleTooltipDialog.visible) { titleTooltipCheckerToNotShowTimer.start(); } if (root.debugModeTimers) { console.log("containment timer: showTitleTooltipTimer called..."); } } } Timer { id: hideTitleTooltipTimer interval: 200 onTriggered: { if (!titleTooltipDialog.activeItemHovered) { titleTooltipDialog.visible = false; } if (root.debugModeTimers) { console.log("containment timer: hideTitleTooltipTimer called..."); } } } //! Timer to fix #811, rare cases that both a window preview and context menu are //! shown Timer { id: titleTooltipCheckerToNotShowTimer interval: 250 onTriggered: { if (titleTooltipDialog.visible && latteApplet && (latteApplet.contextMenu || latteApplet.windowPreviewIsShown)) { titleTooltipDialog.visible = false; } } } /////END: Title Tooltip/////////// ///////////////BEGIN components Component { id: appletContainerComponent Applet.AppletItem{} } ParabolicManager{ id: _parabolicManager } ///////////////END components PlasmaCore.ColorScope{ id: colorScopePalette } ///////////////BEGIN UI elements //it is used to check if the mouse is outside the layoutsContainer borders, //so in that case the onLeave event behavior should be trigerred RootMouseArea{ id: rootMouseArea } Loader{ active: root.debugModeWindow sourceComponent: DebugWindow{} } //! Load a sepia background in order to avoid black background Loader{ anchors.fill: parent active: !Latte.WindowSystem.compositingActive sourceComponent: Image{ anchors.fill: parent fillMode: Image.Tile source: root.hasUserSpecifiedBackground ? dock.managedLayout.background : "../icons/wheatprint.jpg" } } EditModeVisual{ id:editModeVisual // z: root.behaveAsPlasmaPanel ? 1 : 0 } Ruler{id: ruler} RulerMouseArea{ id: rulerMouseArea anchors.fill: ruler z:1100 } Item{ id: panelBox anchors.fill:layoutsContainer // z: root.behaveAsPlasmaPanel ? 0 : 1 PanelBox{ id: panelBoxBackground } } Item { id: lastSpacer parent: layoutsContainer.mainLayout Layout.fillWidth: true Layout.fillHeight: true z:10 Rectangle{ anchors.fill: parent color: "transparent" border.color: "yellow" border.width: 1 } } Item { id: dndSpacer property int normalSize: root.statesLineSize + root.iconSize + root.thickMargin - 1 //visibilityManager.statesLineSizeOriginal + root.maxIconSize + visibilityManager.iconMarginOriginal - 1 width: normalSize height: normalSize Layout.preferredWidth: width Layout.preferredHeight: height opacity: 0 z:10 AddWidgetVisual{} } Loader{ anchors.fill: parent active: root.debugMode z:10 sourceComponent: Item{ Rectangle{ anchors.fill: parent color: "yellow" opacity: 0.30 } } } VisibilityManager{ id: visibilityManager } LayoutsContainer { id: layoutsContainer } Colorizer.Manager { id: colorizerManager } ///////////////END UI elements ///////////////BEGIN TIMER elements //Timer to check if the mouse is still outside the dock in order to restore zooms to 1.0 Timer{ id:checkRestoreZoom interval: 90 onTriggered: { if (latteApplet && (latteApplet.previewContainsMouse() || latteApplet.contextMenu)) return; if (dock.contextMenuIsShown) return; if (!mouseInHoverableArea()) { setGlobalDirectRender(false); root.initializeHoveredIndexes(); root.clearZoom(); } if (root.debugModeTimers) { console.log("containment timer: checkRestoreZoom called..."); } } } //! Delayer in order to not activate directRendering when the mouse //! enters until the timer has ended. This way we make sure that the //! zoom-in animations will have ended. Timer{ id:directRenderDelayerForEnteringTimer interval: 3.2 * root.durationTime * units.shortDuration } //this is a delayer to update mask area, it is used in cases //that animations can not catch up with animations signals //e.g. the automaicIconSize case Timer{ id:delayUpdateMaskArea repeat:false; interval:300; onTriggered: { if (layoutsContainer.animationSent) { root.slotAnimationsNeedLength(-1); layoutsContainer.animationSent = false; } visibilityManager.updateMaskArea(); if (root.debugModeTimers) { console.log("containment timer: delayUpdateMaskArea called..."); } } } // This function is very costly! This timer makes sure that it can be called // only once every 1sec. Timer{ id:blockAutomaticUpdateIconSize interval: 1000 repeat: false onTriggered: root.updateAutomaticIconSize(); } //! It is used in order to slide-in the dock on startup Timer{ id: inStartupTimer interval: 1500 repeat: false onTriggered: { if (inStartup) { visibilityManager.slotMustBeShown(); } } } ///////////////END TIMER elements } diff --git a/plasmoid/package/contents/ui/ContextMenu.qml b/plasmoid/package/contents/ui/ContextMenu.qml index 744d8c85..743d7036 100644 --- a/plasmoid/package/contents/ui/ContextMenu.qml +++ b/plasmoid/package/contents/ui/ContextMenu.qml @@ -1,908 +1,908 @@ /* * Copyright 2016 Smith AR * Michail Vourlakos * * This file is part of Latte-Dock * * Latte-Dock 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. * * Latte-Dock 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.0 import org.kde.plasma.plasmoid 2.0 import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.components 2.0 as PlasmaComponents import org.kde.activities 0.1 as Activities import org.kde.taskmanager 0.1 as TaskManager -import org.kde.latte 0.1 as Latte +import org.kde.latte 0.2 as Latte import "../code/activitiesTools.js" as ActivitiesTools PlasmaComponents.ContextMenu { id: menu property bool changingLayout: false property QtObject mpris2Source property QtObject backend property var modelIndex readonly property var atm: TaskManager.AbstractTasksModel placement: { if (plasmoid.location == PlasmaCore.Types.LeftEdge) { return PlasmaCore.Types.RightPosedTopAlignedPopup; } else if (plasmoid.location == PlasmaCore.Types.TopEdge) { return PlasmaCore.Types.BottomPosedLeftAlignedPopup; } else { return PlasmaCore.Types.TopPosedLeftAlignedPopup; } } minimumWidth: visualParent ? visualParent.width : 1 property bool isOnAllActivitiesLauncher: true property bool showAllPlaces: false property int activitiesCount: 0 onStatusChanged: { if (visualParent && get(atm.LauncherUrlWithoutIcon) != null && status == PlasmaComponents.DialogStatus.Open) { launcherToggleAction.checked = (tasksModel.launcherPosition(get(atm.LauncherUrlWithoutIcon)) != -1); activitiesDesktopsMenu.refresh(); } else if (status == PlasmaComponents.DialogStatus.Closed) { root.startCheckRestoreZoomTimer(100); root.contextMenu = null; menu.destroy(); backend.ungrabMouse(visualParent); } } function get(modelProp) { return tasksModel.data(modelIndex, modelProp) } function show() { //trying to use the dragging mechanism in order to not hide the dock root.disableRestoreZoom = true; root.signalActionsBlockHiding(1); //root.signalDraggingState(true); loadDynamicLaunchActions(visualParent.m.LauncherUrlWithoutIcon); // backend.ungrabMouse(visualParent); openRelative(); if (Latte.WindowSystem.isPlatformWayland){ //!Hiding previews under wayland it needs a delay otherwise it creates crashes windowsPreviewCheckerToNotShowTimer.start(); } else { windowsPreviewDlg.hide("9.4"); } icList.directRender = false; if (root.latteDock){ root.latteDock.hideTooltipLabel(); root.latteDock.globalDirectRender = false; } } function newMenuItem(parent) { return Qt.createQmlObject( "import org.kde.plasma.components 2.0 as PlasmaComponents;" + "PlasmaComponents.MenuItem {}", parent); } function newSeparator(parent) { return Qt.createQmlObject( "import org.kde.plasma.components 2.0 as PlasmaComponents;" + "PlasmaComponents.MenuItem { separator: true }", parent); } function loadDynamicLaunchActions(launcherUrl) { var lists = []; //From Plasma 5.10 and frameworks 5.34, places are also supported if (Latte.WindowSystem.frameworksVersion >= 336384 && (typeof backend.placesActions === "function")) { lists = [ backend.jumpListActions(launcherUrl, menu), backend.placesActions(launcherUrl, showAllPlaces, menu), backend.recentDocumentActions(launcherUrl, menu) ] } else { lists = [ backend.jumpListActions(launcherUrl, menu), backend.recentDocumentActions(launcherUrl, menu) ]; } lists.forEach(function (list) { for (var i = 0; i < list.length; ++i) { var item = newMenuItem(menu); item.action = list[i]; menu.addMenuItem(item, virtualDesktopsMenuItem); } if (list.length > 0) { menu.addMenuItem(newSeparator(menu), virtualDesktopsMenuItem); } }); // Add Media Player control actions var sourceName = mpris2Source.sourceNameForLauncherUrl(launcherUrl, get(atm.AppPid)); if (sourceName && !(get(atm.LegacyWinIdList) != undefined && get(atm.LegacyWinIdList).length > 1)) { var playerData = mpris2Source.data[sourceName] if (playerData.CanControl) { var menuItem = menu.newMenuItem(menu); menuItem.text = i18nc("Play previous track", "Previous Track"); menuItem.icon = "media-skip-backward"; menuItem.enabled = Qt.binding(function() { return playerData.CanGoPrevious; }); menuItem.clicked.connect(function() { mpris2Source.goPrevious(sourceName); }); menu.addMenuItem(menuItem, virtualDesktopsMenuItem); menuItem = menu.newMenuItem(menu); // PlasmaCore Menu doesn't actually handle icons or labels changing at runtime... menuItem.text = Qt.binding(function() { return playerData.PlaybackStatus === "Playing" ? i18nc("Pause playback", "Pause") : i18nc("Start playback", "Play"); }); menuItem.icon = Qt.binding(function() { return playerData.PlaybackStatus === "Playing" ? "media-playback-pause" : "media-playback-start"; }); menuItem.enabled = Qt.binding(function() { return playerData.PlaybackStatus === "Playing" ? playerData.CanPause : playerData.CanPlay; }); menuItem.clicked.connect(function() { mpris2Source.playPause(sourceName); }); menu.addMenuItem(menuItem, virtualDesktopsMenuItem); menuItem = menu.newMenuItem(menu); menuItem.text = i18nc("Play next track", "Next Track"); menuItem.icon = "media-skip-forward"; menuItem.enabled = Qt.binding(function() { return playerData.CanGoNext; }); menuItem.clicked.connect(function() { mpris2Source.goNext(sourceName); }); menu.addMenuItem(menuItem, virtualDesktopsMenuItem); menuItem = menu.newMenuItem(menu); menuItem.text = i18nc("Stop playback", "Stop"); menuItem.icon = "media-playback-stop"; menuItem.clicked.connect(function() { mpris2Source.stop(sourceName); }); menu.addMenuItem(menuItem, virtualDesktopsMenuItem); // Technically media controls and audio streams are separate but for the user they're // semantically related, don't add a separator inbetween. if (!menu.visualParent.hasAudioStream) { menu.addMenuItem(newSeparator(menu), virtualDesktopsMenuItem); } // If we don't have a window associated with the player but we can quit // it through MPRIS we'll offer a "Quit" option instead of "Close" if (!closeWindowItem.visible && playerData.CanQuit) { menuItem = menu.newMenuItem(menu); menuItem.text = i18nc("Quit media player app", "Quit"); menuItem.icon = "application-exit"; menuItem.visible = Qt.binding(function() { return !closeWindowItem.visible; }); menuItem.clicked.connect(function() { mpris2Source.quit(sourceName); }); menu.addMenuItem(menuItem); } // If we don't have a window associated with the player but we can raise // it through MPRIS we'll offer a "Restore" option if (!startNewInstanceItem.visible && playerData.CanRaise) { menuItem = menu.newMenuItem(menu); menuItem.text = i18nc("Open or bring to the front window of media player app", "Restore"); menuItem.icon = playerData["Desktop Icon Name"]; menuItem.visible = Qt.binding(function() { return !startNewInstanceItem.visible; }); menuItem.clicked.connect(function() { mpris2Source.raise(sourceName); }); menu.addMenuItem(menuItem, startNewInstanceItem); } } } // We allow mute/unmute whenever an application has a stream, regardless of whether it // is actually playing sound. // This way you can unmute, e.g. a telephony app, even after the conversation has ended, // so you still have it ringing later on. if (menu.visualParent.hasAudioStream) { var muteItem = menu.newMenuItem(menu); muteItem.checkable = true; muteItem.checked = Qt.binding(function() { return menu.visualParent && menu.visualParent.muted; }); muteItem.clicked.connect(function() { menu.visualParent.toggleMuted(); }); muteItem.text = i18n("Mute"); muteItem.icon = "audio-volume-muted"; menu.addMenuItem(muteItem, virtualDesktopsMenuItem); menu.addMenuItem(newSeparator(menu), virtualDesktopsMenuItem); } } ///REMOVE function updateOnAllActivitiesLauncher(){ //isOnAllActivitiesLauncher = ActivitiesTools.isOnAllActivities(visualParent.m.LauncherUrlWithoutIcon); } Component.onCompleted: { ActivitiesTools.launchersOnActivities = root.launchersOnActivities ActivitiesTools.currentActivity = activityInfo.currentActivity; ActivitiesTools.plasmoid = plasmoid; //From Plasma 5.10 and frameworks 5.34 jumpLists and //places are supported if (Latte.WindowSystem.frameworksVersion >= 336384) { // Cannot have "Connections" as child of PlasmaCoponents.ContextMenu. backend.showAllPlaces.connect(function() { visualParent.showContextMenu({showAllPlaces: true}); }); } // updateOnAllActivitiesLauncher(); } Component.onDestruction: { if (!changingLayout) { root.contextMenu = null; backend.ungrabMouse(visualParent); root.signalActionsBlockHiding(-1); //root.signalDraggingState(false); root.disableRestoreZoom = false; root.startCheckRestoreZoomTimer(100); } } /// Sub Items PlasmaComponents.MenuItem { id: virtualDesktopsMenuItem visible: virtualDesktopInfo.numberOfDesktops > 1 && (visualParent && visualParent.m.IsLauncher !== true && visualParent.m.IsStartup !== true && visualParent.m.IsVirtualDesktopChangeable === true) enabled: visible text: i18n("Move To Desktop") Connections { target: virtualDesktopInfo onNumberOfDesktopsChanged: virtualDesktopsMenu.refresh() onDesktopNamesChanged: virtualDesktopsMenu.refresh() } PlasmaComponents.ContextMenu { id: virtualDesktopsMenu visualParent: virtualDesktopsMenuItem.action function refresh() { clearMenuItems(); if (virtualDesktopInfo.numberOfDesktops <= 1) { return; } var menuItem = menu.newMenuItem(virtualDesktopsMenu); menuItem.text = i18n("Move To Current Desktop"); menuItem.enabled = Qt.binding(function() { return menu.visualParent && menu.visualParent.m.VirtualDesktop != virtualDesktopInfo.currentDesktop; }); menuItem.clicked.connect(function() { tasksModel.requestVirtualDesktop(menu.modelIndex, 0); }); menuItem = menu.newMenuItem(virtualDesktopsMenu); menuItem.text = i18n("All Desktops"); menuItem.checkable = true; menuItem.checked = Qt.binding(function() { return menu.visualParent && menu.visualParent.m.IsOnAllVirtualDesktops === true; }); menuItem.clicked.connect(function() { tasksModel.requestVirtualDesktop(menu.modelIndex, 0); }); backend.setActionGroup(menuItem.action); menu.newSeparator(virtualDesktopsMenu); for (var i = 0; i < virtualDesktopInfo.desktopNames.length; ++i) { menuItem = menu.newMenuItem(virtualDesktopsMenu); //menuItem.text = i18nc("1 = number of desktop, 2 = desktop name", "%1 Desktop %2", i + 1, virtualDesktopInfo.desktopNames[i]); menuItem.text = (i + 1) + ". " + virtualDesktopInfo.desktopNames[i]; menuItem.checkable = true; menuItem.checked = Qt.binding((function(i) { return function() { return menu.visualParent && menu.visualParent.m.VirtualDesktop == (i + 1) }; })(i)); menuItem.clicked.connect((function(i) { return function() { return tasksModel.requestVirtualDesktop(menu.modelIndex, i + 1); }; })(i)); backend.setActionGroup(menuItem.action); } menu.newSeparator(virtualDesktopsMenu); menuItem = menu.newMenuItem(virtualDesktopsMenu); menuItem.text = i18n("New Desktop"); menuItem.clicked.connect(function() { tasksModel.requestVirtualDesktop(menu.modelIndex, virtualDesktopInfo.numberOfDesktops + 1) }); } Component.onCompleted: refresh() } } PlasmaComponents.MenuItem { id: activitiesDesktopsMenuItem visible: activityInfo.numberOfRunningActivities > 1 && (visualParent && !visualParent.m.IsLauncher && !visualParent.m.IsStartup) && !root.disableAllWindowsFunctionality enabled: visible text: i18n("Move To &Activity") Connections { target: activityInfo onNumberOfRunningActivitiesChanged: activitiesDesktopsMenu.refresh() } PlasmaComponents.ContextMenu { id: activitiesDesktopsMenu visualParent: activitiesDesktopsMenuItem.action function refresh() { clearMenuItems(); if (activityInfo.numberOfRunningActivities <= 1) { return; } var menuItem = menu.newMenuItem(activitiesDesktopsMenu); menuItem.text = i18n("Add To Current Activity"); menuItem.enabled = Qt.binding(function() { return menu.visualParent && menu.visualParent.m.Activities.length > 0 && menu.visualParent.m.Activities.indexOf(activityInfo.currentActivity) < 0; }); menuItem.clicked.connect(function() { tasksModel.requestActivities(menu.modelIndex, menu.visualParent.m.Activities.concat(activityInfo.currentActivity)); }); menuItem = menu.newMenuItem(activitiesDesktopsMenu); menuItem.text = i18n("All Activities"); menuItem.checkable = true; menuItem.checked = Qt.binding(function() { return menu.visualParent && menu.visualParent.m.Activities.length === 0; }); menuItem.clicked.connect(function() { var checked = menuItem.checked; var newActivities = menu.visualParent.m.Activities; var size = newActivities.length; newActivities = undefined; // will cast to an empty QStringList i.e all activities if (size === 0) { newActivities = new Array(activityInfo.currentActivity); } tasksModel.requestActivities(menu.modelIndex, newActivities); }); menu.newSeparator(activitiesDesktopsMenu); var runningActivities = activityInfo.runningActivities(); for (var i = 0; i < runningActivities.length; ++i) { var activityId = runningActivities[i]; menuItem = menu.newMenuItem(activitiesDesktopsMenu); menuItem.text = activityInfo.activityName(runningActivities[i]); menuItem.checkable = true; menuItem.checked = Qt.binding( (function(activityId) { return function() { return menu.visualParent && menu.visualParent.m.Activities.indexOf(activityId) >= 0; }; })(activityId)); menuItem.clicked.connect((function(activityId) { return function () { var checked = menuItem.checked; var newActivities = menu.visualParent.m.Activities; var index = newActivities.indexOf(activityId) if (index < 0) { newActivities = newActivities.concat(activityId); } else { //newActivities = newActivities.splice(index, 1); //this does not work!!! newActivities.splice(index, 1); } return tasksModel.requestActivities(menu.modelIndex, newActivities); }; })(activityId)); } menu.newSeparator(activitiesDesktopsMenu); } Component.onCompleted: refresh() } } PlasmaComponents.MenuItem { visible: (visualParent && visualParent.m.IsLauncher !== true && visualParent.m.IsStartup !== true && root.showWindowActions && !root.disableAllWindowsFunctionality) enabled: visualParent && visualParent.m.IsMinimizable === true checkable: true checked: visualParent && visualParent.m.IsMinimized === true text: i18n("Minimize") onClicked: tasksModel.requestToggleMinimized(menu.modelIndex) } PlasmaComponents.MenuItem { visible: (visualParent && visualParent.m.IsLauncher !== true && visualParent.m.IsStartup !== true && root.showWindowActions && !root.disableAllWindowsFunctionality) enabled: visualParent && visualParent.m.IsMaximizable === true checkable: true checked: visualParent && visualParent.m.IsMaximized === true text: i18n("Maximize") onClicked: tasksModel.requestToggleMaximized(menu.modelIndex) } PlasmaComponents.MenuItem { id: moreActionsMenuItem visible: (visualParent && visualParent.m.IsLauncher !== true && visualParent.m.IsStartup !== true && root.showWindowActions && !root.disableAllWindowsFunctionality) enabled: visible text: i18n("More Actions") PlasmaComponents.ContextMenu { visualParent: moreActionsMenuItem.action PlasmaComponents.MenuItem { enabled: menu.visualParent && menu.visualParent.m.IsMovable === true text: i18n("Move") icon: "transform-move" onClicked: tasksModel.requestMove(menu.modelIndex) } PlasmaComponents.MenuItem { enabled: menu.visualParent && menu.visualParent.m.IsResizable === true text: i18n("Resize") onClicked: tasksModel.requestResize(menu.modelIndex) } PlasmaComponents.MenuItem { checkable: true checked: menu.visualParent && menu.visualParent.m.IsKeepAbove === true text: i18n("Keep Above Others") icon: "go-up" onClicked: tasksModel.requestToggleKeepAbove(menu.modelIndex) } PlasmaComponents.MenuItem { checkable: true checked: menu.visualParent && menu.visualParent.m.IsKeepBelow === true text: i18n("Keep Below Others") icon: "go-down" onClicked: tasksModel.requestToggleKeepBelow(menu.modelIndex) } PlasmaComponents.MenuItem { enabled: menu.visualParent && menu.visualParent.m.IsFullScreenable === true checkable: true checked: menu.visualParent && menu.visualParent.m.IsFullScreen === true text: i18n("Fullscreen") icon: "view-fullscreen" onClicked: tasksModel.requestToggleFullScreen(menu.modelIndex) } PlasmaComponents.MenuItem { enabled: menu.visualParent && menu.visualParent.m.IsShadeable === true checkable: true checked: menu.visualParent && menu.visualParent.m.IsShaded === true text: i18n("Shade") onClicked: tasksModel.requestToggleShaded(menu.modelIndex) } PlasmaComponents.MenuItem { separator: true } PlasmaComponents.MenuItem { visible: (plasmoid.configuration.groupingStrategy != 0) && menu.visualParent.m.IsWindow === true checkable: true checked: menu.visualParent && menu.visualParent.m.IsGroupable === true text: i18n("Allow this program to be grouped") onClicked: tasksModel.requestToggleGrouping(menu.modelIndex) } } } PlasmaComponents.MenuItem { id: startNewInstanceItem visible: (visualParent && visualParent.m.IsLauncher !== true && visualParent.m.IsStartup !== true) enabled: visualParent && visualParent.m.LauncherUrlWithoutIcon != null text: i18n("Start New Instance") icon: "system-run" onClicked: tasksModel.requestNewInstance(menu.modelIndex) } PlasmaComponents.MenuItem { separator: true visible: (visualParent && visualParent.m.IsLauncher !== true && visualParent.m.IsStartup !== true && root.showWindowActions) } //// NEW Launchers Mechanism PlasmaComponents.MenuItem { id: launcherToggleAction visible: visualParent && get(atm.IsLauncher) !== true && get(atm.IsStartup) !== true && (activityInfo.numberOfRunningActivities < 2) //&& plasmoid.immutability !== PlasmaCore.Types.SystemImmutable enabled: visualParent && get(atm.LauncherUrlWithoutIcon) !== "" checkable: true text: i18nc("Toggle action for showing a launcher button while the application is not running", "&Pin") onClicked: { if (tasksModel.launcherPosition(get(atm.LauncherUrlWithoutIcon)) != -1) { var launcher = get(atm.LauncherUrl); - if (latteDock && latteDock.launchersGroup >= Latte.Dock.LayoutLaunchers) { + if (latteDock && latteDock.launchersGroup >= Latte.Types.LayoutLaunchers) { latteDock.universalLayoutManager.launchersSignals.removeLauncher(root.managedLayoutName, latteDock.launchersGroup, launcher); } else { root.launcherForRemoval = launcher; tasksModel.requestRemoveLauncher(launcher); root.launchersUpdatedFor(launcher); } } else { var launcher = get(atm.LauncherUrl); - if (latteDock && latteDock.launchersGroup >= Latte.Dock.LayoutLaunchers) { + if (latteDock && latteDock.launchersGroup >= Latte.Types.LayoutLaunchers) { latteDock.universalLayoutManager.launchersSignals.addLauncher(root.managedLayoutName, latteDock.launchersGroup, launcher); } else { tasksModel.requestAddLauncher(launcher); root.launchersUpdatedFor(launcher); } } } } PlasmaComponents.MenuItem { id: showLauncherInActivitiesItem text: i18n("&Pin") visible: visualParent && (!visualParent.isSeparator || (visualParent.isSeparator && root.editMode)) // && get(atm.IsLauncher) !== true && get(atm.IsStartup) !== true && plasmoid.immutability !== PlasmaCore.Types.SystemImmutable && (activityInfo.numberOfRunningActivities >= 2) Connections { target: activityInfo onNumberOfRunningActivitiesChanged: activitiesDesktopsMenu.refresh() } PlasmaComponents.ContextMenu { id: activitiesLaunchersMenu visualParent: showLauncherInActivitiesItem.action function refresh() { clearMenuItems(); if (menu.visualParent === null) return; var createNewItem = function(id, title, url, activities) { var result = menu.newMenuItem(activitiesLaunchersMenu); result.text = title; result.visible = true; result.checkable = true; result.checked = activities.some(function(activity) { return activity === id }); result.clicked.connect( function() { if (result.checked) { - if (latteDock && latteDock.launchersGroup >= Latte.Dock.LayoutLaunchers) { + if (latteDock && latteDock.launchersGroup >= Latte.Types.LayoutLaunchers) { latteDock.universalLayoutManager.launchersSignals.addLauncherToActivity(root.managedLayoutName, latteDock.launchersGroup, url, id); } else { if (id !== tasksModel.activity && (activities[0] === "00000000-0000-0000-0000-000000000000")) { root.launcherForRemoval = url; } tasksModel.requestAddLauncherToActivity(url, id); root.launchersUpdatedFor(url); } } else { - if (latteDock && latteDock.launchersGroup >= Latte.Dock.LayoutLaunchers) { + if (latteDock && latteDock.launchersGroup >= Latte.Types.LayoutLaunchers) { latteDock.universalLayoutManager.launchersSignals.removeLauncherFromActivity(root.managedLayoutName, latteDock.launchersGroup, url, id); } else { if (id === tasksModel.activity) { root.launcherForRemoval = url; } tasksModel.requestRemoveLauncherFromActivity(url, id); root.launchersUpdatedFor(url); } } } ); return result; } if (menu.visualParent === null) return; var url = menu.get(atm.LauncherUrlWithoutIcon); var activities = tasksModel.launcherActivities(url); var NULL_UUID = "00000000-0000-0000-0000-000000000000"; createNewItem(NULL_UUID, i18n("On All Activities"), url, activities); if (activityInfo.numberOfRunningActivities <= 1) { return; } createNewItem(activityInfo.currentActivity, i18n("On The Current Activity"), url, activities); menu.newSeparator(activitiesLaunchersMenu); var runningActivities = activityInfo.runningActivities(); runningActivities.forEach(function(id) { createNewItem(id, activityInfo.activityName(id), url, activities); }); } Component.onCompleted: { menu.onVisualParentChanged.connect(refresh); refresh(); } } } PlasmaComponents.MenuItem { visible: (visualParent && !visualParent.isSeparator && get(atm.IsLauncher) === true) && plasmoid.immutability !== PlasmaCore.Types.SystemImmutable text: i18nc("Remove launcher button for application shown while it is not running", "Unpin") onClicked: { var launcher = get(atm.LauncherUrlWithoutIcon); - if (latteDock && latteDock.launchersGroup >= Latte.Dock.LayoutLaunchers) { + if (latteDock && latteDock.launchersGroup >= Latte.Types.LayoutLaunchers) { latteDock.universalLayoutManager.launchersSignals.removeLauncher(root.managedLayoutName, latteDock.launchersGroup, launcher); } else { root.launcherForRemoval = launcher tasksModel.requestRemoveLauncher(launcher); root.launchersUpdatedFor(launcher); } } } //////END OF NEW ARCHITECTURE PlasmaComponents.MenuItem { separator: true } PlasmaComponents.MenuItem { id: addInternalSeparatorItem visible: root.editMode icon: "add" text: i18n("Add Separator") onClicked: { var pos=visualParent.itemIndex; root.addInternalSeparatorAtPos(pos); } } PlasmaComponents.MenuItem { id: removeInternalSeparatorItem visible: root.editMode && visualParent.isSeparator icon: "remove" text: i18n("Remove Separator") enabled: parabolicManager.hasInternalSeparator onClicked: { //root.removeLastSeparator(); var launcher = get(atm.LauncherUrlWithoutIcon); - if (latteDock && latteDock.launchersGroup >= Latte.Dock.LayoutLaunchers) { + if (latteDock && latteDock.launchersGroup >= Latte.Types.LayoutLaunchers) { latteDock.universalLayoutManager.launchersSignals.removeLauncher(root.managedLayoutName, latteDock.launchersGroup, launcher); } else { root.launcherForRemoval = launcher; tasksModel.requestRemoveLauncher(launcher); root.launchersUpdatedFor(launcher); } } } PlasmaComponents.MenuItem { separator: true visible: root.editMode } PlasmaComponents.MenuItem { id: layoutsMenuItem action: latteDock ? latteDock.containmentActions()[1] : plasmoid.action("configure") enabled: visible visible: latteDock && latteDock.universalLayoutManager.menuLayouts.length>1 } PlasmaComponents.MenuItem { id: alternativesMenuItem visible: root.editMode && !visualParent.isSeparator text: plasmoid.action("alternatives").text icon: plasmoid.action("alternatives").icon onClicked: plasmoid.action("alternatives").trigger(); } PlasmaComponents.MenuItem { id: addWidgets action: latteDock ? latteDock.containmentActions()[2] : plasmoid.action("configure"); visible: latteDock } PlasmaComponents.MenuItem { id: configureItem action: latteDock ? latteDock.containmentActions()[3] : plasmoid.action("configure") } //! BEGIN: Plasmoid actions when it isnt inside a Latte dock PlasmaComponents.MenuItem { id: removePlasmoid visible: !latteDock && !plasmoid.immutable text: plasmoid.action("remove").text icon: plasmoid.action("remove").icon onClicked: plasmoid.action("remove").trigger(); } PlasmaComponents.MenuItem { id: configurePlasmoid visible: !latteDock && !plasmoid.immutable text: plasmoid.action("configure").text icon: plasmoid.action("configure").icon onClicked: plasmoid.action("configure").trigger(); } //! END: Plasmoid actions when it isnt inside a Latte dock PlasmaComponents.MenuItem { separator: true visible: closeWindowItem.visible } //!move window Close button at the very bottom in order to not alter users workflow //!comparing with the design decisions of other taskmanagers PlasmaComponents.MenuItem { id: closeWindowItem visible: (visualParent && visualParent.m.IsLauncher !== true && visualParent.m.IsStartup !== true) enabled: visualParent && visualParent.m.IsClosable === true text: i18n("Close") icon: "window-close" onClicked: { if (root.zoomFactor>1) { delayWindowRemovalTimer.modelIndex = menu.modelIndex; delayWindowRemovalTimer.start(); } else { tasksModel.requestClose(menu.modelIndex); } } } } diff --git a/plasmoid/package/contents/ui/MouseHandler.qml b/plasmoid/package/contents/ui/MouseHandler.qml index 9ea76918..aa82254a 100644 --- a/plasmoid/package/contents/ui/MouseHandler.qml +++ b/plasmoid/package/contents/ui/MouseHandler.qml @@ -1,260 +1,260 @@ /* * Copyright 2016 Smith AR * Michail Vourlakos * * This file is part of Latte-Dock * * Latte-Dock 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. * * Latte-Dock 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.0 import org.kde.plasma.plasmoid 2.0 import org.kde.draganddrop 2.0 import org.kde.taskmanager 0.1 as TaskManager -import org.kde.latte 0.1 as Latte +import org.kde.latte 0.2 as Latte import "../code/tools.js" as TaskTools Item { // signal urlDropped(url url) signal urlsDropped(var urls) property Item target property Item ignoredItem property bool moved: false property alias hoveredItem: dropHandler.hoveredItem property alias onlyLaunchers: dropHandler.onlyLaunchers Timer { id: ignoreItemTimer repeat: false interval: 200 onTriggered: { ignoredItem = null; } } Connections { target: root onDragSourceChanged: { if (!dragSource) { ignoredItem = null; ignoreItemTimer.stop(); } } } DropArea { id: dropHandler anchors.fill: parent preventStealing: true; property int droppedPosition: -1; property bool onlyLaunchers: false; property bool droppingSeparator: false; property Item hoveredItem function isDroppingSeparator(event) { return ((event.mimeData.formats.indexOf("text/x-plasmoidservicename") === 0) && (String(event.mimeData.getDataAsByteArray("text/x-plasmoidservicename")) === "audoban.applet.separator")); } onDragEnter:{ if(root.dragSource == null){ onlyLaunchers = false; droppingSeparator = false; root.dropNewLauncher = false; var createLaunchers = false; if (event.mimeData.hasUrls || (event.mimeData.formats.indexOf("text/x-plasmoidservicename") !== 0)) { root.dropNewLauncher = true; if (event.mimeData.hasUrls){ createLaunchers = event.mimeData.urls.every(function (item) { return backend.isApplication(item) }); } } else if (isDroppingSeparator(event)) { droppingSeparator = true; root.dropNewLauncher = true; return; } else { event.ignore(); } if (createLaunchers) { onlyLaunchers = true; } } } onDragMove: { /* if(root.dragSource == null){ root.dropNewLauncher = true; } */ if (target.animating) { return; } var above = target.childAtPos(event.x, event.y); // If we're mixing launcher tasks with other tasks and are moving // a (small) launcher task across a non-launcher task, don't allow // the latter to be the move target twice in a row for a while, as // it will naturally be moved underneath the cursor as result of the // initial move, due to being far larger than the launcher delegate. // TODO: This restriction (minus the timer, which improves things) // has been proven out in the EITM fork, but could be improved later // by tracking the cursor movement vector and allowing the drag if // the movement direction has reversed, etablishing user intent to // move back. if (root.dragSource == null && ignoredItem == above) return; if (root.dragSource != null && root.dragSource.m.IsLauncher === true && above != null && above.m != null && above.m.IsLauncher !== true && above == ignoredItem) { return; } else { //ignoredItem = null; } //at some point it was needed the following && above != ignoredItem //but know not... strange... && above != ignoredItem //I use the ignoredItem in order to reduce the move calls as much //as possible if (tasksModel.sortMode == TaskManager.TasksModel.SortManual && root.dragSource && ignoredItem == null) { var insertAt = TaskTools.insertIndexAt(above, event.x, event.y); if (root.dragSource != above && root.dragSource.itemIndex != insertAt) { // console.log(root.dragSource.itemIndex + " - "+insertAt); root.dragSource.z = 100; ignoredItem = above; var pos = root.dragSource.itemIndex; tasksModel.move(pos, insertAt); //! disable syncing for moving launchers action in favor of validatorOrder launchersSignal - /* if (latteDock && latteDock.launchersGroup >= Latte.Dock.LayoutLaunchers) { + /* if (latteDock && latteDock.launchersGroup >= Latte.Types.LayoutLaunchers) { latteDock.universalLayoutManager.launchersSignals.moveTask(root.managedLayoutName, plasmoid.id, latteDock.launchersGroup, pos, insertAt); }*/ root.separatorsUpdated(); ignoreItemTimer.restart(); } } else if (!root.dragSource && above && hoveredItem != above) { hoveredItem = above; if (!onlyLaunchers) { //! it is needed when dropping a url on a launcher in order to not break parabolic effect root.setHoveredIndex(hoveredItem.itemIndex); } //root.dropNewLauncher = true; activationTimer.restart(); } else if (!above) { //root.dropNewLauncher = true; hoveredItem = null; root.setHoveredIndex(-1); activationTimer.stop(); } if (hoveredItem && windowsPreviewDlg.visible && toolTipDelegate.rootIndex !== hoveredItem.modelIndex() ) { windowsPreviewDlg.hide(6); } } onDragLeave: { hoveredItem = null; root.setHoveredIndex(-1); root.dropNewLauncher = false; onlyLaunchers = false; root.separatorsUpdated(); activationTimer.stop(); } onDrop: { // Reject internal drops. root.dropNewLauncher = false; onlyLaunchers = false; root.separatorsUpdated(); if (event.mimeData.formats.indexOf("application/x-orgkdeplasmataskmanager_taskbuttonitem") >= 0) { return; } if (droppingSeparator) { droppingSeparator = false; if (hoveredItem && hoveredItem.itemIndex >=0){ root.addInternalSeparatorAtPos(hoveredItem.itemIndex); } else { root.addInternalSeparatorAtPos(0); } return; } if (event.mimeData.hasUrls) { parent.urlsDropped(event.mimeData.urls); } } Timer { id: activationTimer interval: 250 repeat: false onTriggered: { if (dropHandler.onlyLaunchers || !root.dropNewLauncher || dropHandler.droppingSeparator) { return; } if (parent.hoveredItem.m.IsGroupParent === true) { root.showPreviewForTasks(parent.hoveredItem); // groupDialog.visualParent = parent.hoveredItem; // groupDialog.visible = true; } else if (parent.hoveredItem.m.IsLauncher !== true) { if(windowsPreviewDlg.visible && toolTipDelegate.currentItem !==parent.hoveredItem.itemIndex ) { windowsPreviewDlg.hide(5); toolTipDelegate.currentItem=-1; } tasksModel.requestActivate(parent.hoveredItem.modelIndex()); } } } } /* MouseArea { id: wheelHandler anchors.fill: parent property int wheelDelta: 0; enabled: plasmoid.configuration.wheelEnabled onWheel: wheelDelta = TaskTools.wheelActivateNextPrevTask(wheelDelta, wheel.angleDelta.y); } */ } diff --git a/plasmoid/package/contents/ui/ParabolicManager.qml b/plasmoid/package/contents/ui/ParabolicManager.qml index ec58d9d3..4636a703 100644 --- a/plasmoid/package/contents/ui/ParabolicManager.qml +++ b/plasmoid/package/contents/ui/ParabolicManager.qml @@ -1,555 +1,555 @@ /* * Copyright 2016 Smith AR * Michail Vourlakos * * This file is part of Latte-Dock * * Latte-Dock 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. * * Latte-Dock 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.0 import org.kde.plasma.plasmoid 2.0 -import org.kde.latte 0.1 as Latte +import org.kde.latte 0.2 as Latte // holds all the logic around parabolic effect signals into one place. // ParabolicManager is responsible for triggering all the messages to tasks // that are neighbour to the hovered task. This will help a lot to catch cases // such as separators and proper clearing zoom. Item { id: parManager property bool hasInternalSeparator: false property int firstRealTaskIndex: -1 property int lastRealTaskIndex: -1 property int countRealTasks: -1 //tasks that change state (launcher,startup,window) and //at the next state must look the same //(id, mScale) property variant frozenTasks: [] //new launchers in order to be moved in correct place //(launcher, pos) property variant launchersToBeMoved: [] Connections{ target: root onTasksCountChanged: parManager.updateTasksEdgesIndexes(); onHiddenTasksUpdated: parManager.updateTasksEdgesIndexes(); } Component.onCompleted: { updateHasInternalSeparator(); updateTasksEdgesIndexes(); root.separatorsUpdated.connect(updateHasInternalSeparator); } Component.onDestruction: { root.separatorsUpdated.disconnect(updateHasInternalSeparator); } function updateTasksEdgesIndexes() { var newFirstTask = firstRealTask(); var newLastTask = lastRealTask(); if (newFirstTask !== firstRealTaskIndex || newLastTask !== lastRealTaskIndex ){ firstRealTaskIndex = newFirstTask; lastRealTaskIndex = newLastTask; root.separatorsUpdated(); } countRealTasks = realTasks(); } function updateHasInternalSeparator() { var count = icList.contentItem.children.length; for (var i=0; i=0 && index<=root.tasksCount-1) || (!root.latteDock)){ root.updateScale(index, zScale, zStep); return -1; } else{ var appletId = latteDock.latteAppletPos; if (index<0) appletId = latteDock.parabolicManager.availableLowerId(latteDock.latteAppletPos + index); else if (index>root.tasksCount-1){ var step=index-root.tasksCount+1; appletId = latteDock.parabolicManager.availableHigherId(latteDock.latteAppletPos + step); } latteDock.updateScale(appletId, zScale, zStep); return appletId; } } function applyParabolicEffect(index, currentMousePosition, center) { var rDistance = Math.abs(currentMousePosition - center); //check if the mouse goes right or down according to the center var positiveDirection = ((currentMousePosition - center) >= 0 ); if (Qt.application.layoutDirection === Qt.RightToLeft && !root.vertical) { positiveDirection = !positiveDirection; } var minimumZoom = 1; //finding the zoom center e.g. for zoom:1.7, calculates 0.35 var zoomCenter = ((root.zoomFactor + minimumZoom)/2) - 1; //computes the in the scale e.g. 0...0.35 according to the mouse distance //0.35 on the edge and 0 in the center var firstComputation = (rDistance / center) * (zoomCenter-minimumZoom+1); //calculates the scaling for the neighbour tasks var bigNeighbourZoom = Math.min(1 + zoomCenter + firstComputation, root.zoomFactor); var smallNeighbourZoom = Math.max(1 + zoomCenter - firstComputation, minimumZoom); //bigNeighbourZoom = Number(bigNeighbourZoom.toFixed(4)); //smallNeighbourZoom = Number(smallNeighbourZoom.toFixed(4)); var leftScale; var rightScale; if(positiveDirection === true){ rightScale = bigNeighbourZoom; leftScale = smallNeighbourZoom; } else { rightScale = smallNeighbourZoom; leftScale = bigNeighbourZoom; } // console.debug(leftScale + " " + rightScale + " " + index); //first applets accessed var gPAppletId = -1; var lPAppletId = -1; //secondary applets accessed to restore zoom var gAppletId = -1; var lAppletId = -1; var gStep = 1; var lStep = 1; //console.log("--- task style 2..."); var aGId1 = availableHigherIndex(index+1); var aLId1 = availableLowerIndex(index-1); gPAppletId = updateIdSendScale(aGId1, rightScale, 0); lPAppletId = updateIdSendScale(aLId1, leftScale, 0); // console.log("index:"+index + " lattePos:"+latteDock.latteAppletPos); // console.log("gApp:"+gPAppletId+" lApp:"+lPAppletId+ " aG1:"+aGId1+" aLId1:"+aLId1); gStep = aGId1 - index; lStep = index - aLId1; if (latteDock) { if (gPAppletId > -1) gStep = Math.abs(gPAppletId - latteDock.latteAppletPos + (root.tasksCount-1-index)); if (lPAppletId > -1) lStep = Math.abs(lPAppletId - latteDock.latteAppletPos - index); } //console.log("gs:"+gStep+" ls:"+lStep); gAppletId = updateIdSendScale(index+gStep+1, 1, 0); lAppletId = updateIdSendScale(index-lStep-1, 1, 0); //console.log(" cgApp:"+gAppletId+" clApp:"+lAppletId); clearTasksGreaterThan(aGId1+1); clearTasksLowerThan(aLId1-1); if (latteDock){ if (gAppletId > -1) latteDock.parabolicManager.clearAppletsGreaterThan(gAppletId); else latteDock.parabolicManager.clearAppletsGreaterThan(latteDock.latteAppletPos); if (lAppletId > -1) latteDock.parabolicManager.clearAppletsLowerThan(lAppletId); else latteDock.parabolicManager.clearAppletsLowerThan(latteDock.latteAppletPos-1); } return {leftScale:leftScale, rightScale:rightScale}; } function clearTasksGreaterThan(index) { if (index0 && root.tasksCount>2) { for(var i=0; i-1 && (hovered === index || hovered === availableLowerIndex(index-1) || hovered === availableHigherIndex(index+1) )) { return true; } return false; } //! Frozen Tasks functions function getFrozenTask(identifier) { for(var i=0; i -1) { frozenTasks.splice(taskIndex, 1); } } function setFrozenTask(identifier, scale) { var frozenTaskExists = false; console.log("SET FROZEN :: "+identifier+" - "+scale); var frozenTask = getFrozenTask(identifier); if (frozenTask) { frozenTask.mScale = scale; } else { frozenTasks.push({id: identifier, mScale: scale}); } } function availableLowerIndex(from) { var next = from; while (next>=0 && (taskIsSeparator(next) || (root.showWindowsOnlyFromLaunchers && taskIsForcedHidden(next))) ) next = next - 1; return next; } function availableHigherIndex(from) { var next = from; while (next<=root.tasksCount-1 && (taskIsSeparator(next) || (root.showWindowsOnlyFromLaunchers && taskIsForcedHidden(next))) ) { next = next + 1; } return next; } function isSeparator(launcher){ return (launcher.indexOf("latte-separator")!==-1 && launcher.indexOf(".desktop")!==1); } function taskIsSeparator(taskIndex){ var task = icList.childAtIndex(taskIndex); return (task && !task.isForcedHidden && task.isSeparator); } function taskIsForcedHidden(taskIndex) { var task = icList.childAtIndex(taskIndex); //!tasks that become hidden there is a chance to have index===-1 and to not be //!able to be tracked down return ((!task && (taskIndex>=0 && taskIndex=0); } //! the real index task after we take into account the separators before it //! for example the first task if there is a separator before it is 1, it isnt 0 function realTaskIndex(pseudoIndex) { if (hasInternalSeparator) { var steps = pseudoIndex + 1; var pos = 0; while (steps > 0) { if (!taskIsSeparator(pos)) { steps = steps - 1; } if (steps > 0) pos = pos + 1; } return pos; } else { return pseudoIndex; } } //! the pseudo index task after we take into account the separators before it //! for example the third task if there is a separator before it is 1, it isnt 2 function pseudoTaskIndex(realIndex) { var pseudoIndex = realIndex; if (hasInternalSeparator) { for (var i=0; i