From 0db7b29a2d2802b80d722928ca90515aa5bd4711 Mon Sep 17 00:00:00 2001 From: Michail Vourlakos Date: Sat, 18 Apr 2020 19:24:21 +0300 Subject: [PATCH] Abilities:move iconSize to containmentAbility --- .../package/contents/code/LayoutManager.js | 3 +- .../contents/ui/AutomaticItemSizer.qml | 29 +++++---- .../package/contents/ui/DebugWindow.qml | 4 +- containment/package/contents/ui/PanelBox.qml | 4 +- .../package/contents/ui/VisibilityManager.qml | 24 +++---- .../package/contents/ui/abilities/Ability.qml | 24 +++++++ .../contents/ui/abilities/Containment.qml | 28 ++++++++ .../ui/abilities/ContainmentPrivate.qml | 51 +++++++++++++++ .../package/contents/ui/applet/AppletItem.qml | 18 ++--- .../contents/ui/applet/ItemWrapper.qml | 60 ++++++++--------- .../contents/ui/applet/ShortcutBadge.qml | 6 +- .../contents/ui/applet/TitleTooltipParent.qml | 2 +- .../ui/applet/communicator/LatteBridge.qml | 4 +- .../contents/ui/applet/indicator/Bridge.qml | 4 +- .../contents/ui/applet/indicator/Loader.qml | 4 +- .../package/contents/ui/editmode/Visual.qml | 4 +- .../ui/layouts/EnvironmentActions.qml | 2 +- .../contents/ui/layouts/indicator/Bridge.qml | 4 +- containment/package/contents/ui/main.qml | 65 +++++++------------ 19 files changed, 218 insertions(+), 122 deletions(-) create mode 100644 containment/package/contents/ui/abilities/Ability.qml create mode 100644 containment/package/contents/ui/abilities/Containment.qml create mode 100644 containment/package/contents/ui/abilities/ContainmentPrivate.qml diff --git a/containment/package/contents/code/LayoutManager.js b/containment/package/contents/code/LayoutManager.js index 7b4d11aef..80e5d39df 100644 --- a/containment/package/contents/code/LayoutManager.js +++ b/containment/package/contents/code/LayoutManager.js @@ -22,6 +22,7 @@ var layout; var layoutS; var layoutE; var root; +var containmentAb; var plasmoid; var lastSpacer; @@ -449,7 +450,7 @@ function insertAtLayoutCoordinates(tLayout, item, x, y) { if (!child) { // check if dragging takes place after the end of the layout - var neededSpace = 1.5 * (root.iconSize + root.lengthMargin); + var neededSpace = 1.5 * (containmentAb.iconSize + root.lengthMargin); if ( (((root.isVertical && (y - neededSpace) <= tLayout.height) && y>=0) ||(root.isHorizontal && (x - neededSpace) <= tLayout.width) && x>=0) && tLayout.children.length>0 ){ diff --git a/containment/package/contents/ui/AutomaticItemSizer.qml b/containment/package/contents/ui/AutomaticItemSizer.qml index bac1d3f51..0a98ed028 100644 --- a/containment/package/contents/ui/AutomaticItemSizer.qml +++ b/containment/package/contents/ui/AutomaticItemSizer.qml @@ -63,14 +63,19 @@ Item { sizer.updateAutomaticIconSize(); } } + } + + Connections { + target: containmentAb + onProportionIconSizeChanged: { - if (root.proportionIconSize!==-1) { + if (containmentAb.proportionIconSize!==-1) { sizer.updateAutomaticIconSize(); } } onIconSizeChanged: { - if (((root.iconSize === sizer.automaticIconSizeBasedSize) || (root.iconSize === root.maxIconSize)) && sizer.automaticSizeAnimation){ + if (((containmentAb.iconSize === sizer.automaticIconSizeBasedSize) || (containmentAb.iconSize === containmentAb.maxIconSize)) && sizer.automaticSizeAnimation){ root.slotAnimationsNeedBothAxis(-1); sizer.automaticSizeAnimation=false; } @@ -80,13 +85,13 @@ Item { Connections { target: latteView onWidthChanged:{ - if (root.isHorizontal && root.proportionIconSize!==-1) { + if (root.isHorizontal && containmentAb.proportionIconSize!==-1) { sizer.updateAutomaticIconSize(); } } onHeightChanged:{ - if (root.isVertical && root.proportionIconSize!==-1) { + if (root.isVertical && containmentAb.proportionIconSize!==-1) { sizer.updateAutomaticIconSize(); } } @@ -133,8 +138,8 @@ Item { function updateAutomaticIconSize() { if ( !doubleCallAutomaticUpdateIconSize.running && !visibilityManager.inTempHiding && ((visibilityManager.normalState || root.editMode) - && (sizer.isActive || (!sizer.isActive && root.iconSize!==root.maxIconSize))) - && (root.iconSize===root.maxIconSize || root.iconSize === sizer.automaticIconSizeBasedSize) ) { + && (sizer.isActive || (!sizer.isActive && containmentAb.iconSize!==root.maxIconSize))) + && (containmentAb.iconSize===containmentAb.maxIconSize || containmentAb.iconSize === sizer.automaticIconSizeBasedSize) ) { //!doubler timer if (!doubleCallAutomaticUpdateIconSize.secondTimeCallApplied) { @@ -157,7 +162,7 @@ Item { layoutsContainer.startLayout.width+layoutsContainer.mainLayout.width+layoutsContainer.endLayout.width : layoutsContainer.mainLayout.width } - var itemLength = root.iconSize + lengthMargins; + var itemLength = containmentAb.iconSize + lengthMargins; var toShrinkLimit = maxLength - (root.zoomFactor * itemLength); //! to grow limit must be a little less than the shrink one in order to be more robust and @@ -170,11 +175,11 @@ Item { var newIconSizeFound = false; if (layoutLength > toShrinkLimit) { //must shrink // console.log("step3"); - var nextIconSize = root.maxIconSize; + var nextIconSize = containmentAb.maxIconSize; do { nextIconSize = nextIconSize - automaticStep; - var factor = nextIconSize / root.iconSize; + var factor = nextIconSize / containmentAb.iconSize; var nextLength = factor * layoutLength; } while ( (nextLength>toShrinkLimit) && (nextIconSize !== 16)); @@ -188,7 +193,7 @@ Item { addPrediction(intLength, intNextLength); // console.log("Step 3 - found:"+automaticIconSizeBasedSize); } else if ((layoutLength 0 && !producesEndlessLoop(intLength2, intNextLength2)) { - if (foundGoodSize === root.maxIconSize) { + if (foundGoodSize === containmentAb.maxIconSize) { automaticIconSizeBasedSize = -1; } else { automaticIconSizeBasedSize = foundGoodSize; diff --git a/containment/package/contents/ui/DebugWindow.qml b/containment/package/contents/ui/DebugWindow.qml index 3a40f6686..bbdde9751 100644 --- a/containment/package/contents/ui/DebugWindow.qml +++ b/containment/package/contents/ui/DebugWindow.qml @@ -412,7 +412,7 @@ Window{ } Text{ - text: root.iconSize + text: containmentAb.iconSize } Text{ @@ -428,7 +428,7 @@ Window{ } Text{ - text: root.proportionIconSize + text: containmentAb.proportionIconSize } Text{ diff --git a/containment/package/contents/ui/PanelBox.qml b/containment/package/contents/ui/PanelBox.qml index 0973381e4..d77e868d6 100644 --- a/containment/package/contents/ui/PanelBox.qml +++ b/containment/package/contents/ui/PanelBox.qml @@ -228,9 +228,9 @@ Item{ property int panelSize: automaticPanelSize property int automaticPanelSize: { if (root.behaveAsPlasmaPanel) { - return root.iconSize + root.thickMargins;// + 2; + return containmentAb.iconSize + root.thickMargins;// + 2; } else { - var icons = root.iconSize + root.thickMargins;// + 2; + var icons = containmentAb.iconSize + root.thickMargins;// + 2; var panelt = root.themePanelThickness;// + 2; root.realPanelThickness = icons + root.localScreenEdgeMargin; diff --git a/containment/package/contents/ui/VisibilityManager.qml b/containment/package/contents/ui/VisibilityManager.qml index 738b905c8..f8ad5ca96 100644 --- a/containment/package/contents/ui/VisibilityManager.qml +++ b/containment/package/contents/ui/VisibilityManager.qml @@ -40,7 +40,7 @@ Item{ 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.themePanelThickness >= (root.iconSize + root.thickMargin)) + property bool panelIsBiggerFromIconSize: root.useThemePanel && (root.themePanelThickness >= (containmentAb.iconSize + root.thickMargin)) property bool maskIsFloating: !root.behaveAsPlasmaPanel && !root.editMode @@ -72,25 +72,25 @@ Item{ } property int thicknessAutoHidden: LatteCore.WindowSystem.compositingActive ? 2 : 1 - property int thicknessMid: root.screenEdgeMargin + (1 + (0.65 * (root.maxZoomFactor-1)))*(root.iconSize+root.thickMargins+extraThickMask) //needed in some animations - property int thicknessNormal: root.screenEdgeMargin + Math.max(root.iconSize + root.thickMargins + extraThickMask + 1, root.realPanelSize + root.panelShadow) + property int thicknessMid: root.screenEdgeMargin + (1 + (0.65 * (root.maxZoomFactor-1)))*(containmentAb.iconSize+root.thickMargins+extraThickMask) //needed in some animations + property int thicknessNormal: root.screenEdgeMargin + Math.max(containmentAb.iconSize + root.thickMargins + extraThickMask + 1, root.realPanelSize + root.panelShadow) - property int thicknessZoom: root.screenEdgeMargin + ((root.iconSize+root.thickMargins+extraThickMask) * root.maxZoomFactor) + 2 + property int thicknessZoom: root.screenEdgeMargin + ((containmentAb.iconSize+root.thickMargins+extraThickMask) * root.maxZoomFactor) + 2 //it is used to keep thickness solid e.g. when iconSize changes from auto functions - property int thicknessMidOriginal: root.screenEdgeMargin + Math.max(thicknessNormalOriginal,extraThickMask + (1 + (0.65 * (root.maxZoomFactor-1)))*(root.maxIconSize+root.maxThickMargin)) //needed in some animations - property int thicknessNormalOriginal: root.screenEdgeMargin + root.maxIconSize + (root.maxThickMargin * 2) //this way we always have the same thickness published at all states + property int thicknessMidOriginal: root.screenEdgeMargin + Math.max(thicknessNormalOriginal,extraThickMask + (1 + (0.65 * (root.maxZoomFactor-1)))*(containmentAb.maxIconSize+root.maxThickMargin)) //needed in some animations + property int thicknessNormalOriginal: root.screenEdgeMargin + containmentAb.maxIconSize + (root.maxThickMargin * 2) //this way we always have the same thickness published at all states /*property int thicknessNormalOriginal: !root.behaveAsPlasmaPanel || root.editMode ? thicknessNormalOriginalValue : root.realPanelSize + root.panelShadow*/ - property int thicknessNormalOriginalValue: root.screenEdgeMargin + root.maxIconSize + (root.maxThickMargin * 2) + extraThickMask + 1 - property int thicknessZoomOriginal:root.screenEdgeMargin + Math.max( ((root.maxIconSize+(root.maxThickMargin * 2)) * root.maxZoomFactor) + extraThickMask + 2, + property int thicknessNormalOriginalValue: root.screenEdgeMargin + containmentAb.maxIconSize + (root.maxThickMargin * 2) + extraThickMask + 1 + property int thicknessZoomOriginal:root.screenEdgeMargin + Math.max( ((containmentAb.maxIconSize+(root.maxThickMargin * 2)) * root.maxZoomFactor) + extraThickMask + 2, root.realPanelSize + root.panelShadow, (LatteCore.WindowSystem.compositingActive ? thicknessEditMode + root.editShadow : thicknessEditMode)) //! is used from Panel in edit mode in order to provide correct masking property int thicknessEditMode: thicknessNormalOriginalValue + editModeVisual.settingsThickness //! when Latte behaves as Plasma panel - property int thicknessAsPanel: root.iconSize + root.thickMargins + property int thicknessAsPanel: containmentAb.iconSize + root.thickMargins //! is used to increase the mask thickness readonly property int marginBetweenContentsAndRuler: root.editMode ? 10 : 0 @@ -128,7 +128,7 @@ Item{ value: root.behaveAsPlasmaPanel && !root.editMode ? thicknessAsPanel : thicknessZoomOriginal } - property bool validIconSize: (root.iconSize===root.maxIconSize || root.iconSize === automaticItemSizer.automaticIconSizeBasedSize) + property bool validIconSize: (containmentAb.iconSize===containmentAb.maxIconSize || containmentAb.iconSize === automaticItemSizer.automaticIconSizeBasedSize) property bool inPublishingState: validIconSize && !inSlidingIn && !inSlidingOut && !inTempHiding && !inForceHiding Binding{ @@ -735,7 +735,7 @@ Item{ } } - var validIconSize = (root.iconSize===root.maxIconSize || root.iconSize === automaticItemSizer.automaticIconSizeBasedSize); + var validIconSize = (containmentAb.iconSize===containmentAb.maxIconSize || containmentAb.iconSize === automaticItemSizer.automaticIconSizeBasedSize); //console.log("reached updating geometry ::: "+dock.maskArea); @@ -748,7 +748,7 @@ Item{ //the shadows size must be removed from the maskArea //before updating the localDockGeometry if (!latteView.behaveAsPlasmaPanel || root.editMode) { - var cleanThickness = root.iconSize + root.thickMargins; + var cleanThickness = containmentAb.iconSize + root.thickMargins; var edgeMargin = root.screenEdgeMargin; if (plasmoid.location === PlasmaCore.Types.TopEdge) { diff --git a/containment/package/contents/ui/abilities/Ability.qml b/containment/package/contents/ui/abilities/Ability.qml new file mode 100644 index 000000000..3d889bb05 --- /dev/null +++ b/containment/package/contents/ui/abilities/Ability.qml @@ -0,0 +1,24 @@ +/* +* Copyright 2020 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 + +Item { + property QtObject publicApi: Item{} +} diff --git a/containment/package/contents/ui/abilities/Containment.qml b/containment/package/contents/ui/abilities/Containment.qml new file mode 100644 index 000000000..c5e36415a --- /dev/null +++ b/containment/package/contents/ui/abilities/Containment.qml @@ -0,0 +1,28 @@ +/* +* Copyright 2020 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 + +ContainmentPrivate { + id: apis + + publicApi: Item { + readonly property alias iconSize: apis.iconSize + } +} diff --git a/containment/package/contents/ui/abilities/ContainmentPrivate.qml b/containment/package/contents/ui/abilities/ContainmentPrivate.qml new file mode 100644 index 000000000..87953cae6 --- /dev/null +++ b/containment/package/contents/ui/abilities/ContainmentPrivate.qml @@ -0,0 +1,51 @@ +/* +* Copyright 2020 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 + +Ability { + property int iconSize: autoItemSizerAb.automaticIconSizeBasedSize > 0 && autoItemSizerAb.isActive ? + Math.min(autoItemSizerAb.automaticIconSizeBasedSize, maxIconSize) : + maxIconSize + + //what is the highest icon size based on what icon size is used, screen calculated or user specified + readonly property int maxIconSize: proportionIconSize!==-1 ? proportionIconSize : plasmoid.configuration.iconSize + + readonly property int proportionIconSize: { //icon size based on screen height + if ((plasmoid.configuration.proportionIconSize===-1) || !latteView) + return -1; + + return Math.max(16,Math.round(latteView.screenGeometry.height * plasmoid.configuration.proportionIconSize/100/8)*8); + } + + //! Behaviors + Behavior on iconSize { + enabled: !(root.editMode && root.behaveAsPlasmaPanel) + NumberAnimation { + duration: 0.8 * root.animationTime + + onRunningChanged: { + if (!running) { + delayUpdateMaskArea.start(); + } + } + } + } +} diff --git a/containment/package/contents/ui/applet/AppletItem.qml b/containment/package/contents/ui/applet/AppletItem.qml index 6f3a90bc7..f36843d81 100644 --- a/containment/package/contents/ui/applet/AppletItem.qml +++ b/containment/package/contents/ui/applet/AppletItem.qml @@ -163,14 +163,14 @@ Item { 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.55 * root.iconSize) - root.lengthMargins) + property int spacersMaxSize: Math.max(0,Math.ceil(0.55 * containmentAb.iconSize) - root.lengthMargins) property int status: applet ? applet.status : -1 //! local margins readonly property bool parabolicEffectMarginsEnabled: root.zoomFactor>1 && !originalAppletBehavior property int lengthAppletIntMargin: root.lengthAppletIntMarginFactor === -1 || parabolicEffectMarginsEnabled ? - root.lengthIntMargin : root.lengthAppletIntMarginFactor * root.iconSize + root.lengthIntMargin : root.lengthAppletIntMarginFactor * containmentAb.iconSize property int lengthAppletFullMargin: lengthAppletIntMargin + root.lengthExtMargin property int lengthAppletFullMargins: 2 * lengthAppletFullMargin @@ -398,8 +398,8 @@ Item { return; } - var maxSize = root.iconSize + root.thickMargins; - var maxForMinimumSize = root.iconSize + root.thickMargins; + var maxSize = containmentAb.iconSize + root.thickMargins; + var maxForMinimumSize = containmentAb.iconSize + root.thickMargins; if ( isSystray || appletItem.needsFillSpace @@ -838,7 +838,7 @@ Item { width: { if (root.isHorizontal) { - return root.iconSize * wrapper.zoomScale + return containmentAb.iconSize * wrapper.zoomScale } else { return badgeThickness; } @@ -848,17 +848,17 @@ Item { if (root.isHorizontal) { return badgeThickness; } else { - return root.iconSize * wrapper.zoomScale + return containmentAb.iconSize * wrapper.zoomScale } } readonly property int badgeThickness: { if (plasmoid.location === PlasmaCore.Types.BottomEdge || plasmoid.location === PlasmaCore.Types.RightEdge) { - return ((root.iconSize + root.thickMargin) * wrapper.zoomScale) + root.localScreenEdgeMargin; + return ((containmentAb.iconSize + root.thickMargin) * wrapper.zoomScale) + root.localScreenEdgeMargin; } - return ((root.iconSize + root.thickMargin) * wrapper.zoomScale); + return ((containmentAb.iconSize + root.thickMargin) * wrapper.zoomScale); } ShortcutBadge{ @@ -917,7 +917,7 @@ Item { // width: root.isHorizontal ? parent.width : parent.width - root.localScreenEdgeMargin // height: root.isHorizontal ? parent.height - root.localScreenEdgeMargin : parent.height - radius: root.iconSize/10 + radius: containmentAb.iconSize/10 opacity: root.addLaunchersMessage ? 1 : 0 backgroundOpacity: 0.75 duration: root.durationTime diff --git a/containment/package/contents/ui/applet/ItemWrapper.qml b/containment/package/contents/ui/applet/ItemWrapper.qml index 4a963b883..24702e89d 100644 --- a/containment/package/contents/ui/applet/ItemWrapper.qml +++ b/containment/package/contents/ui/applet/ItemWrapper.qml @@ -50,7 +50,7 @@ Item{ var constrainedWidth = MathTools.bound(applet.Layout.minimumWidth, applet.Layout.preferredWidth, maximumValue); - return root.inConfigureAppletsMode ? Math.max(constrainedWidth, root.iconSize) : constrainedWidth; + return root.inConfigureAppletsMode ? Math.max(constrainedWidth, containmentAb.iconSize) : constrainedWidth; } if(appletItem.sizeForFill>-1){ @@ -62,7 +62,7 @@ Item{ return latteApplet.tasksWidth; } else { if (root.isHorizontal && root.inConfigureAppletsMode) { - return Math.max(Math.min(root.iconSize, root.minAppletLengthInConfigure), scaledWidth); + return Math.max(Math.min(containmentAb.iconSize, root.minAppletLengthInConfigure), scaledWidth); } return root.isVertical ? scaledWidth + root.localScreenEdgeMargin : scaledWidth; @@ -85,7 +85,7 @@ Item{ var constrainedHeight = MathTools.bound(applet.Layout.minimumHeight, applet.Layout.preferredHeight, maximumValue); - return root.inConfigureAppletsMode ? Math.max(constrainedHeight, root.iconSize) : constrainedHeight; + return root.inConfigureAppletsMode ? Math.max(constrainedHeight, containmentAb.iconSize) : constrainedHeight; } if (appletItem.sizeForFill>-1){ @@ -97,7 +97,7 @@ Item{ return latteApplet.tasksHeight; } else { if (root.isVertical && root.inConfigureAppletsMode) { - return Math.max(Math.min(root.iconSize, root.minAppletLengthInConfigure), scaledHeight); + return Math.max(Math.min(containmentAb.iconSize, root.minAppletLengthInConfigure), scaledHeight); } return root.isHorizontal ? scaledHeight + root.localScreenEdgeMargin : scaledHeight; @@ -124,7 +124,7 @@ Item{ 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 iconSize: containmentAb.iconSize property int marginWidth: root.isVertical ? root.thickMargins : @@ -188,11 +188,11 @@ Item{ console.log("Real Wrapper Height: "+wrapper.height); console.log("-----"); console.log("Can be hovered: " + canBeHovered); - console.log("Icon size: " + root.iconSize); + console.log("Icon size: " + containmentAb.iconSize); console.log("Thick Margins: " + root.thickMargins); console.log("Intern. Margins: " + (root.lengthIntMargin * 2)); console.log("Intern. Margins: " + (root.lengthExtMargin * 2)); - console.log("Max hovered criteria: " + (root.iconSize + thickMargins)); + console.log("Max hovered criteria: " + (containmentAb.iconSize + thickMargins)); console.log("-----"); console.log("LayoutW: " + layoutWidth); console.log("LayoutH: " + layoutHeight); @@ -314,39 +314,39 @@ Item{ if(!root.inConfigureAppletsMode) { layoutHeight = 0; } else { - layoutHeight = (root.isHorizontal ? root.iconSize : Math.min(root.iconSize, root.maxJustifySplitterSize)); + layoutHeight = (root.isHorizontal ? containmentAb.iconSize : Math.min(containmentAb.iconSize, root.maxJustifySplitterSize)); } } else if(appletItem.isSystray && root.isHorizontal){ - layoutHeight = root.iconSize; + layoutHeight = containmentAb.iconSize; } else{ - if(applet && (applet.Layout.minimumHeight > root.iconSize) && root.isVertical && !canBeHovered && !communicator.overlayLatteIconIsActive){ + if(applet && (applet.Layout.minimumHeight > containmentAb.iconSize) && root.isVertical && !canBeHovered && !communicator.overlayLatteIconIsActive){ blockParabolicEffect = true; 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 + && ( applet.Layout.maximumHeight < containmentAb.iconSize + || applet.Layout.preferredHeight > containmentAb.iconSize || appletItem.originalAppletBehavior) && root.isVertical && !disableScaleWidth && !communicator.overlayLatteIconIsActive) { //this way improves performance, probably because during animation the preferred sizes update a lot - if((applet.Layout.maximumHeight < root.iconSize)){ + if((applet.Layout.maximumHeight < containmentAb.iconSize)){ layoutHeight = applet.Layout.maximumHeight; - } else if (applet.Layout.minimumHeight > root.iconSize){ + } else if (applet.Layout.minimumHeight > containmentAb.iconSize){ blockParabolicEffect = true; layoutHeight = applet.Layout.minimumHeight; - } else if ((applet.Layout.preferredHeight > root.iconSize) + } else if ((applet.Layout.preferredHeight > containmentAb.iconSize) || (appletItem.originalAppletBehavior && applet.Layout.preferredHeight > 0 )){ blockParabolicEffect = true; layoutHeight = applet.Layout.preferredHeight; } else{ - layoutHeight = root.iconSize; + layoutHeight = containmentAb.iconSize; } } else { - layoutHeight = root.iconSize; + layoutHeight = containmentAb.iconSize; } } @@ -375,41 +375,41 @@ Item{ if(!root.inConfigureAppletsMode) { layoutWidth = 0; } else { - layoutWidth = (root.isVertical ? root.iconSize : Math.min(root.iconSize, root.maxJustifySplitterSize)); + layoutWidth = (root.isVertical ? containmentAb.iconSize : Math.min(containmentAb.iconSize, root.maxJustifySplitterSize)); } } else if(appletItem.isSystray && root.isVertical){ - layoutWidth = root.iconSize; + layoutWidth = containmentAb.iconSize; } else{ - if(applet && (applet.Layout.minimumWidth > root.iconSize) && root.isHorizontal && !canBeHovered && !communicator.overlayLatteIconIsActive){ + if(applet && (applet.Layout.minimumWidth > containmentAb.iconSize) && root.isHorizontal && !canBeHovered && !communicator.overlayLatteIconIsActive){ blockParabolicEffect = true; 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 + && ( applet.Layout.maximumWidth < containmentAb.iconSize + || applet.Layout.preferredWidth > containmentAb.iconSize || appletItem.originalAppletBehavior) && root.isHorizontal && !disableScaleHeight && !communicator.overlayLatteIconIsActive){ //this way improves performance, probably because during animation the preferred sizes update a lot - if((applet.Layout.maximumWidth < root.iconSize)){ + if((applet.Layout.maximumWidth < containmentAb.iconSize)){ // return applet.Layout.maximumWidth; layoutWidth = applet.Layout.maximumWidth; - } else if (applet.Layout.minimumWidth > root.iconSize){ + } else if (applet.Layout.minimumWidth > containmentAb.iconSize){ blockParabolicEffect = true; layoutWidth = applet.Layout.minimumWidth; - } else if ((applet.Layout.preferredWidth > root.iconSize) + } else if ((applet.Layout.preferredWidth > containmentAb.iconSize) || (appletItem.originalAppletBehavior && applet.Layout.preferredWidth > 0 )){ blockParabolicEffect = true; layoutWidth = applet.Layout.preferredWidth; } else{ - layoutWidth = root.iconSize; + layoutWidth = containmentAb.iconSize; } } else{ - layoutWidth = root.iconSize; + layoutWidth = containmentAb.iconSize; } } @@ -434,7 +434,7 @@ Item{ return wrapper.layoutWidth; } else { if (plasmoid.formFactor === PlasmaCore.Types.Vertical) { - var wrapperContainerThickness = parent.zoomScaleWidth * (root.iconSize + root.thickMargins); + var wrapperContainerThickness = parent.zoomScaleWidth * (containmentAb.iconSize + root.thickMargins); return appletItem.supportsScreenEdgeMargin ? wrapperContainerThickness + root.localScreenEdgeMargin : wrapperContainerThickness; } else { return parent.zoomScaleWidth * wrapper.layoutWidth; @@ -451,7 +451,7 @@ Item{ return wrapper.layoutHeight; } else { if (plasmoid.formFactor === PlasmaCore.Types.Horizontal) { - var wrapperContainerThickness = parent.zoomScaleHeight * (root.iconSize + root.thickMargins); + var wrapperContainerThickness = parent.zoomScaleHeight * (containmentAb.iconSize + root.thickMargins); return appletItem.supportsScreenEdgeMargin ? wrapperContainerThickness + root.localScreenEdgeMargin : wrapperContainerThickness; } else { return parent.zoomScaleHeight * wrapper.layoutHeight; @@ -612,7 +612,7 @@ Item{ PlasmaCore.SvgItem{ id:splitterImage anchors.centerIn: parent - width: Math.min(root.maxJustifySplitterSize, root.iconSize) + width: Math.min(root.maxJustifySplitterSize, containmentAb.iconSize) height: width rotation: root.isVertical ? 90 : 0 diff --git a/containment/package/contents/ui/applet/ShortcutBadge.qml b/containment/package/contents/ui/applet/ShortcutBadge.qml index 7d969f03d..d4beaca23 100644 --- a/containment/package/contents/ui/applet/ShortcutBadge.qml +++ b/containment/package/contents/ui/applet/ShortcutBadge.qml @@ -102,13 +102,13 @@ Loader{ // when iconSize < 48, height is always = 24, height / iconSize > 50% // we prefer center aligned badges to top-left aligned ones - property bool centerInParent: root.iconSize < 48 + property bool centerInParent: containmentAb.iconSize < 48 anchors.left: centerInParent? undefined : parent.left anchors.top: centerInParent? undefined : parent.top anchors.centerIn: centerInParent? parent : undefined - minimumWidth: 0.4 * (wrapper.zoomScale * root.iconSize) - height: Math.max(24, 0.4 * (wrapper.zoomScale * root.iconSize)) + minimumWidth: 0.4 * (wrapper.zoomScale * containmentAb.iconSize) + height: Math.max(24, 0.4 * (wrapper.zoomScale * containmentAb.iconSize)) borderColor: colorizerManager.originalLightTextColor proportion: 0 diff --git a/containment/package/contents/ui/applet/TitleTooltipParent.qml b/containment/package/contents/ui/applet/TitleTooltipParent.qml index 8ea3399c1..3a43b2345 100644 --- a/containment/package/contents/ui/applet/TitleTooltipParent.qml +++ b/containment/package/contents/ui/applet/TitleTooltipParent.qml @@ -31,7 +31,7 @@ Item{ property int size: 1 property int thickness: Math.min(Math.max(minimumThickness, preferredThickness), maximumThickness) property int minimumThickness: 0 - readonly property int preferredThickness: (root.zoomFactor * (root.iconSize + root.thickMargins)) + root.localScreenEdgeMargin + readonly property int preferredThickness: (root.zoomFactor * (containmentAb.iconSize + root.thickMargins)) + root.localScreenEdgeMargin property int maximumThickness: 9999 //border.width: 1 diff --git a/containment/package/contents/ui/applet/communicator/LatteBridge.qml b/containment/package/contents/ui/applet/communicator/LatteBridge.qml index a0cf7a181..ee4c2ec35 100644 --- a/containment/package/contents/ui/applet/communicator/LatteBridge.qml +++ b/containment/package/contents/ui/applet/communicator/LatteBridge.qml @@ -86,7 +86,7 @@ Item{ // USE CASE: it can be used from applets that want their size to be always // relevant to the view icon size // @since: 0.9 - readonly property int iconSize: root.iconSize + readonly property int iconSize: containmentAb.iconSize // NAME: screenEdgeMargin // USAGE: read-only @@ -113,6 +113,8 @@ Item{ readonly property QtObject windowsTracker: mainCommunicator.windowsTrackingEnabled && latteView && latteView.windowsTracker ? latteView.windowsTracker : null + readonly property Item containment: containmentAb + property Item actions: Actions{} Connections { diff --git a/containment/package/contents/ui/applet/indicator/Bridge.qml b/containment/package/contents/ui/applet/indicator/Bridge.qml index b6f4d80ac..d306d25d9 100644 --- a/containment/package/contents/ui/applet/indicator/Bridge.qml +++ b/containment/package/contents/ui/applet/indicator/Bridge.qml @@ -58,8 +58,8 @@ Item{ readonly property int windowsCount: 0 readonly property int windowsMinimizedCount: 0 - readonly property int currentIconSize: root.iconSize - readonly property int maxIconSize: root.maxIconSize + readonly property int currentIconSize: containmentAb.iconSize + readonly property int maxIconSize: containmentAb.maxIconSize readonly property real scaleFactor: appletIsValid ? appletItem.wrapperAlias.zoomScale : 1 readonly property real panelOpacity: root.currentPanelOpacity readonly property color shadowColor: root.appShadowColorSolid diff --git a/containment/package/contents/ui/applet/indicator/Loader.qml b/containment/package/contents/ui/applet/indicator/Loader.qml index 2a727c6a7..0745b197c 100644 --- a/containment/package/contents/ui/applet/indicator/Loader.qml +++ b/containment/package/contents/ui/applet/indicator/Loader.qml @@ -68,8 +68,8 @@ Loader { readonly property bool locked: appletItem.lockZoom || root.zoomFactor === 1 - property real visualLockedWidth: root.iconSize + appletItem.internalWidthMargins - property real visualLockedHeight: root.iconSize + appletItem.internalHeightMargins + property real visualLockedWidth: containmentAb.iconSize + appletItem.internalWidthMargins + property real visualLockedHeight: containmentAb.iconSize + appletItem.internalHeightMargins //! Communications !// diff --git a/containment/package/contents/ui/editmode/Visual.qml b/containment/package/contents/ui/editmode/Visual.qml index bf840a6d4..f98099b64 100644 --- a/containment/package/contents/ui/editmode/Visual.qml +++ b/containment/package/contents/ui/editmode/Visual.qml @@ -45,8 +45,8 @@ Item{ property int speed: LatteCore.WindowSystem.compositingActive ? root.appliedDurationTime*3.6*root.longDuration : 10 property int thickness: visibilityManager.thicknessEditMode + root.editShadow property int rootThickness: visibilityManager.thicknessZoomOriginal + root.editShadow //- visibilityManager.thicknessEditMode - 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 int editLength: root.isHorizontal ? (root.behaveAsPlasmaPanel ? root.width - containmentAb.maxIconSize/4 : root.width)://root.maxLength) : + (root.behaveAsPlasmaPanel ? root.height - containmentAb.maxIconSize/4 : root.height) property bool animationSent: false property bool farEdge: (plasmoid.location===PlasmaCore.Types.BottomEdge) || (plasmoid.location===PlasmaCore.Types.RightEdge) diff --git a/containment/package/contents/ui/layouts/EnvironmentActions.qml b/containment/package/contents/ui/layouts/EnvironmentActions.qml index 16bca3c17..b6150be41 100644 --- a/containment/package/contents/ui/layouts/EnvironmentActions.qml +++ b/containment/package/contents/ui/layouts/EnvironmentActions.qml @@ -43,7 +43,7 @@ Loader { acceptedButtons: Qt.LeftButton | Qt.MidButton - readonly property int localThickness: (root.isHovered ? (root.iconSize + root.thickMargins)*root.zoomFactor : (root.iconSize + root.thickMargins)) + readonly property int localThickness: (root.isHovered ? (containmentAb.iconSize + root.thickMargins)*root.zoomFactor : (containmentAb.iconSize + root.thickMargins)) readonly property int length: { if (screenEdgeMarginEnabled && plasmoid.configuration.fittsLawIsRequested) { return root.isHorizontal ? root.width : root.height; diff --git a/containment/package/contents/ui/layouts/indicator/Bridge.qml b/containment/package/contents/ui/layouts/indicator/Bridge.qml index 68d426b37..b44ec535b 100644 --- a/containment/package/contents/ui/layouts/indicator/Bridge.qml +++ b/containment/package/contents/ui/layouts/indicator/Bridge.qml @@ -52,8 +52,8 @@ Item{ readonly property int windowsCount: 0 readonly property int windowsMinimizedCount: 0 - readonly property int currentIconSize: root.iconSize - readonly property int maxIconSize: root.maxIconSize + readonly property int currentIconSize: containmentAb.iconSize + readonly property int maxIconSize: containmentAb.maxIconSize readonly property real scaleFactor: 1 readonly property real panelOpacity: root.currentPanelOpacity readonly property color shadowColor: root.appShadowColorSolid diff --git a/containment/package/contents/ui/main.qml b/containment/package/contents/ui/main.qml index 6f5e84d94..3be7f3220 100644 --- a/containment/package/contents/ui/main.qml +++ b/containment/package/contents/ui/main.qml @@ -32,6 +32,7 @@ import org.kde.latte 0.2 as Latte import org.kde.latte.core 0.2 as LatteCore import org.kde.latte.components 1.0 as LatteComponents +import "abilities" as Ability import "applet" as Applet import "colorizer" as Colorizer import "editmode" as EditMode @@ -260,19 +261,6 @@ Item { readonly property int minAppletLengthInConfigure: 64 readonly property int maxJustifySplitterSize: 96 - //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: automaticItemSizer.automaticIconSizeBasedSize > 0 && automaticItemSizer.isActive ? - Math.min(automaticItemSizer.automaticIconSizeBasedSize, root.maxIconSize) : - root.maxIconSize - - property int proportionIconSize: { //icon size based on screen height - if ((plasmoid.configuration.proportionIconSize===-1) || !latteView) - return -1; - - return Math.max(16,Math.round(latteView.screenGeometry.height * plasmoid.configuration.proportionIconSize/100/8)*8); - } - property int latteAppletPos: -1 property int minLengthPerCentage: plasmoid.configuration.minLength property int maxLengthPerCentage: hideLengthScreenGaps ? 100 : plasmoid.configuration.maxLength @@ -339,8 +327,8 @@ Item { } property int appShadowOpacity: (plasmoid.configuration.shadowOpacity/100) * 255 - property int appShadowSize: enableShadows ? (0.5*root.iconSize) * (plasmoid.configuration.shadowSize/100) : 0 - property int appShadowSizeOriginal: enableShadows ? (0.5*maxIconSize) * (plasmoid.configuration.shadowSize/100) : 0 + property int appShadowSize: enableShadows ? (0.5*containmentAb.iconSize) * (plasmoid.configuration.shadowSize/100) : 0 + property int appShadowSizeOriginal: enableShadows ? (0.5*containmentAb.maxIconSize) * (plasmoid.configuration.shadowSize/100) : 0 property string appChosenShadowColor: { if (plasmoid.configuration.shadowColorType === Latte.Types.ThemeColorShadow) { @@ -395,13 +383,13 @@ Item { property int themePanelThickness: { var panelBase = root.panelThickMarginHigh + root.panelThickMarginBase; var margin = shrinkThickMargins ? 0 : thickMargins + localScreenEdgeMargin; - var maxPanelSize = (iconSize + margin) - panelBase; + var maxPanelSize = (containmentAb.iconSize + margin) - panelBase; var percentage = LatteCore.WindowSystem.compositingActive ? plasmoid.configuration.panelSize/100 : 1; return Math.max(panelBase, panelBase + percentage*maxPanelSize); } - property int lengthIntMargin: lengthIntMarginFactor * root.iconSize - property int lengthExtMargin: lengthExtMarginFactor * root.iconSize + property int lengthIntMargin: lengthIntMarginFactor * containmentAb.iconSize + property int lengthExtMargin: lengthExtMarginFactor * containmentAb.iconSize property real lengthIntMarginFactor: indicators.isEnabled ? indicators.padding : 0 property real lengthExtMarginFactor: plasmoid.configuration.lengthExtMargin / 100 @@ -415,7 +403,7 @@ Item { //0.075 old statesLineSize and 0.06 old default thickMargin return Math.max(indicators.info.minThicknessPadding, plasmoid.configuration.thickMargin / 100) } - property int thickMargin: thickMarginFactor * root.iconSize + property int thickMargin: thickMarginFactor * containmentAb.iconSize property bool screenEdgeMarginEnabled: plasmoid.configuration.screenEdgeMargin >= 0 && !plasmoid.configuration.shrinkThickMargins property int screenEdgeMargin: { @@ -438,7 +426,7 @@ Item { //it is used in order to not break the calculations for the thickness placement //especially in automatic icon sizes calculations - property int maxThickMargin: thickMarginFactor * maxIconSize + property int maxThickMargin: thickMarginFactor * containmentAb.maxIconSize property int lengthMargin: lengthIntMargin + lengthExtMargin property int lengthMargins: 2 * lengthMargin @@ -474,6 +462,9 @@ Item { property Item toolBox property Item latteAppletContainer property Item latteApplet + + readonly property Item autoItemSizerAb: automaticItemSizer + readonly property Item containmentAb: _containmentAb readonly property Item indicatorsManager: indicators readonly property Item parabolicManager: _parabolicManager readonly property Item maskManager: visibilityManager @@ -515,9 +506,9 @@ Item { if (!universalSettings || universalSettings.mouseSensitivity === Latte.Types.HighSensitivity) { return 1; } else if (universalSettings.mouseSensitivity === Latte.Types.MediumSensitivity) { - return Math.max(3, root.iconSize / 18); + return Math.max(3, containmentAb.iconSize / 18); } else if (universalSettings.mouseSensitivity === Latte.Types.LowSensitivity) { - return Math.max(5, root.iconSize / 10); + return Math.max(5, containmentAb.iconSize / 10); } } @@ -602,7 +593,7 @@ Item { ///The index of user's current icon size property int currentIconIndex:{ for(var i=iconsArray.length-1; i>=0; --i){ - if(iconsArray[i] === iconSize){ + if(iconsArray[i] === containmentAb.iconSize){ return i; } } @@ -645,19 +636,6 @@ Item { } } - Behavior on iconSize { - enabled: !(root.editMode && root.behaveAsPlasmaPanel) - NumberAnimation { - duration: 0.8 * root.animationTime - - onRunningChanged: { - if (!running) { - delayUpdateMaskArea.start(); - } - } - } - } - Behavior on offset { enabled: editModeVisual.editAnimationInFullThickness NumberAnimation { @@ -782,12 +760,11 @@ Item { } } - // onIconSizeChanged: console.log("Icon Size Changed:"+iconSize); - Component.onCompleted: { // currentLayout.isLayoutHorizontal = isHorizontal LayoutManager.plasmoid = plasmoid; LayoutManager.root = root; + LayoutManager.containmentAb = containmentAb; LayoutManager.layout = layoutsContainer.mainLayout; LayoutManager.layoutS = layoutsContainer.startLayout; LayoutManager.layoutE = layoutsContainer.endLayout; @@ -1766,8 +1743,8 @@ Item { width: root.isHorizontal ? length : thickness height: root.isHorizontal ? thickness : length - readonly property int length: root.iconSize + root.lengthMargins - readonly property int thickness: root.iconSize + root.thickMargins + root.localScreenEdgeMargin + readonly property int length: containmentAb.iconSize + root.lengthMargins + readonly property int thickness: containmentAb.iconSize + root.thickMargins + root.localScreenEdgeMargin Layout.preferredWidth: width Layout.preferredHeight: height @@ -1846,6 +1823,14 @@ Item { ///////////////END UI elements + ///////////////BEGIN ABILITIES + + Ability.Containment{ + id: _containmentAb + } + + ///////////////END ABILITIES + ///////////////BEGIN TIMER elements