Warning, /plasma/latte-dock/shell/package/contents/configuration/CanvasConfiguration.qml is written in an unsupported language. File is not indexed.

0001 /*
0002     SPDX-FileCopyrightText: 2020 Michail Vourlakos <mvourlakos@gmail.com>
0003     SPDX-License-Identifier: GPL-2.0-or-later
0004 */
0005 
0006 import QtQuick 2.8
0007 import QtGraphicalEffects 1.0
0008 
0009 import org.kde.plasma.core 2.0 as PlasmaCore
0010 import org.kde.plasma.components 2.0 as PlasmaComponents
0011 
0012 import org.kde.latte.private.app 0.1 as LatteApp
0013 import org.kde.latte.core 0.2 as LatteCore
0014 import org.kde.latte.private.containment 0.1 as LatteContainment
0015 
0016 import "canvas" as CanvasComponent
0017 
0018 Loader {
0019     active: plasmoid && plasmoid.configuration && latteView
0020 
0021     sourceComponent: Item{
0022         id: root
0023         readonly property bool isVertical: plasmoid.formFactor === PlasmaCore.Types.Vertical
0024         readonly property bool isHorizontal: !isVertical
0025 
0026         property int animationSpeed: LatteCore.WindowSystem.compositingActive ? 500 : 0
0027         property int panelAlignment: plasmoid.configuration.alignment
0028 
0029         readonly property real appliedOpacity: imageTiler.opacity
0030         readonly property real maxOpacity: universalSettings.inConfigureAppletsMode || !LatteCore.WindowSystem.compositingActive ?
0031                                                1 : plasmoid.configuration.editBackgroundOpacity
0032 
0033         property real offset: {
0034             if (root.isHorizontal) {
0035                 return width * (plasmoid.configuration.offset/100);
0036             } else {
0037                 return height * (plasmoid.configuration.offset/100)
0038             }
0039         }
0040 
0041         property string appChosenShadowColor: {
0042             if (plasmoid.configuration.shadowColorType === LatteContainment.Types.ThemeColorShadow) {
0043                 var strC = String(theme.textColor);
0044                 return strC.indexOf("#") === 0 ? strC.substr(1) : strC;
0045             } else if (plasmoid.configuration.shadowColorType === LatteContainment.Types.UserColorShadow) {
0046                 return plasmoid.configuration.shadowColor;
0047             }
0048 
0049             // default shadow color
0050             return "080808";
0051         }
0052 
0053         property string appShadowColorSolid: "#" + appChosenShadowColor
0054 
0055         //// BEGIN OF Behaviors
0056         Behavior on offset {
0057             NumberAnimation {
0058                 id: offsetAnimation
0059                 duration: animationSpeed
0060                 easing.type: Easing.OutCubic
0061             }
0062         }
0063         //// END OF Behaviors
0064 
0065         Item {
0066             id: graphicsSystem
0067             readonly property bool isAccelerated: (GraphicsInfo.api !== GraphicsInfo.Software)
0068                                                   && (GraphicsInfo.api !== GraphicsInfo.Unknown)
0069         }
0070 
0071         Image{
0072             id: imageTiler
0073             anchors.fill: parent
0074             opacity: root.maxOpacity
0075             fillMode: Image.Tile
0076             source: latteView.layout ? latteView.layout.background : "../images/canvas/blueprint.jpg"
0077 
0078             Behavior on opacity {
0079                 NumberAnimation {
0080                     duration: 0.8 * root.animationSpeed
0081                     easing.type: Easing.OutCubic
0082                 }
0083             }
0084         }
0085 
0086         LatteApp.ContextMenuLayer {
0087             id: contextMenuLayer
0088             anchors.fill: parent
0089             view: latteView
0090         }
0091 
0092         MouseArea {
0093             id: editBackMouseArea
0094             anchors.fill: imageTiler
0095             visible: !universalSettings.inConfigureAppletsMode
0096             hoverEnabled: true
0097 
0098             property bool wheelIsBlocked: false;
0099             readonly property double opacityStep: 0.1
0100             readonly property string tooltip: i18nc("opacity for background under edit mode, %1 is opacity percentage",
0101                                                     "You can use mouse wheel to change background opacity of %1%",Math.round(plasmoid.configuration.editBackgroundOpacity * 100))
0102 
0103             onWheel: {
0104                 processWheel(wheel);
0105             }
0106 
0107 
0108             function processWheel(wheel) {
0109                 if (wheelIsBlocked) {
0110                     return;
0111                 }
0112 
0113                 wheelIsBlocked = true;
0114                 scrollDelayer.start();
0115 
0116                 var angle = wheel.angleDelta.y / 8;
0117 
0118                 if (angle > 10) {
0119                     plasmoid.configuration.editBackgroundOpacity = Math.min(100, plasmoid.configuration.editBackgroundOpacity + opacityStep)
0120                 } else if (angle < -10) {
0121                     plasmoid.configuration.editBackgroundOpacity = Math.max(0, plasmoid.configuration.editBackgroundOpacity - opacityStep)
0122                 }
0123             }
0124 
0125             //! A timer is needed in order to handle also touchpads that probably
0126             //! send too many signals very fast. This way the signals per sec are limited.
0127             //! The user needs to have a steady normal scroll in order to not
0128             //! notice a annoying delay
0129             Timer{
0130                 id: scrollDelayer
0131 
0132                 interval: 80
0133                 onTriggered: editBackMouseArea.wheelIsBlocked = false;
0134             }
0135         }
0136 
0137         PlasmaComponents.Button {
0138             anchors.fill: editBackMouseArea
0139             opacity: 0
0140             tooltip: editBackMouseArea.tooltip
0141         }
0142 
0143         //! Settings Overlay
0144         CanvasComponent.SettingsOverlay {
0145             id: settingsOverlay
0146             anchors.fill: parent
0147         }
0148     }
0149 }