Warning, /plasma/latte-dock/containment/package/contents/ui/applet/IndicatorLevel.qml is written in an unsupported language. File is not indexed.

0001 /*
0002     SPDX-FileCopyrightText: 2019 Michail Vourlakos <mvourlakos@gmail.com>
0003     SPDX-License-Identifier: GPL-2.0-or-later
0004 */
0005 
0006 import QtQuick 2.7
0007 
0008 import org.kde.plasma.core 2.0 as PlasmaCore
0009 
0010 import org.kde.latte.abilities.items 0.1 as AbilityItem
0011 
0012 AbilityItem.IndicatorLevel {
0013     id: indicatorLevel
0014     anchors.bottom: (plasmoid.location === PlasmaCore.Types.BottomEdge) ? parent.bottom : undefined
0015     anchors.top: (plasmoid.location === PlasmaCore.Types.TopEdge) ? parent.top : undefined
0016     anchors.left: (plasmoid.location === PlasmaCore.Types.LeftEdge) ? parent.left : undefined
0017     anchors.right: (plasmoid.location === PlasmaCore.Types.RightEdge) ? parent.right : undefined
0018 
0019     anchors.horizontalCenter: root.isHorizontal ? parent.horizontalCenter : undefined
0020     anchors.verticalCenter: root.isVertical ? parent.verticalCenter : undefined
0021 
0022     width: {
0023         if (root.isHorizontal) {
0024             if (appletItem.parabolicEffectIsSupported) {
0025                 return appletItem.wrapper.zoomScale * visualLockedWidth;
0026             }
0027 
0028             return appletWrapper.width + appletItem.internalWidthMargins;
0029         } else {
0030             return appletItem.wrapper.width;
0031         }
0032     }
0033 
0034     height: {
0035         if (root.isVertical) {
0036             if (appletItem.parabolicEffectIsSupported) {
0037                 return appletItem.wrapper.zoomScale * visualLockedHeight;
0038             }
0039 
0040             return appletWrapper.height + appletItem.internalHeightMargins;
0041         } else {
0042             return appletItem.wrapper.height;
0043         }
0044     }
0045 
0046     level.isDrawn: !appletItem.isSeparator
0047                    && !appletItem.isMarginsAreaSeparator
0048                    && !appletItem.isHidden
0049                    && !(appletItem.isAutoFillApplet && !communicator.indexerIsSupported) //! simple Plasma AutoFill applets
0050                    && !communicator.indexerIsSupported
0051                    && level.indicator.host.isEnabled
0052                    && (appletItem.communicator.requires.activeIndicatorEnabled
0053                        || (!appletItem.communicator.requires.activeIndicatorEnabled && appletItem.debug.graphicsEnabled /*debug paddings*/)
0054                        && level.indicator.host.info.enabledForApplets)
0055 
0056     readonly property bool locked: appletItem.lockZoom || appletItem.parabolic.factor.zoom === 1
0057 
0058     //! Qt.min() is used to make sure that indicators always take into account the current applet length provided
0059     //! and as such always look centered even when applet are aligned to length screen edge
0060     property real visualLockedWidth: Math.min(appletItem.metrics.iconSize, appletWrapper.width) + appletItem.internalWidthMargins
0061     property real visualLockedHeight: Math.min(appletItem.metrics.iconSize, appletWrapper.height) + appletItem.internalHeightMargins
0062 
0063     Connections {
0064         target: appletItem
0065         enabled: indicatorLevel.level.indicator.host.isEnabled && indicatorLevel.level.indicator.host.info.needsMouseEventCoordinates
0066         onMousePressed: {
0067             var fixedPos = indicatorLevel.mapFromItem(appletItem, x, y);
0068             indicatorLevel.level.mousePressed(Math.round(fixedPos.x), Math.round(fixedPos.y), button);
0069         }
0070 
0071         onMouseReleased: {
0072             var fixedPos = indicatorLevel.mapFromItem(appletItem, x, y);
0073             indicatorLevel.level.mouseReleased(Math.round(fixedPos.x), Math.round(fixedPos.y), button);
0074         }
0075     }
0076 }