Warning, /plasma/latte-dock/declarativeimports/components/Slider.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 import QtQuick.Templates 2.0 as T
0008 import org.kde.plasma.core 2.0 as PlasmaCore
0009 import "private" as Private
0010 
0011 T.Slider {
0012     id: control
0013 
0014     implicitWidth: Math.max(background ? background.implicitWidth : 0,
0015         Math.max(handle ? handle.implicitWidth : 0,
0016                  handle ? handle.implicitWidth : 0) + leftPadding + rightPadding)
0017     implicitHeight: Math.max(background ? background.implicitHeight : 0,
0018         Math.max(handle ? handle.implicitHeight : 0,
0019                  handle ? handle.implicitHeight : 0) + topPadding + bottomPadding)
0020 
0021     //padding: 3*units.smallSpacing //5//units.gridUnit
0022     topPadding: 3*units.smallSpacing
0023     bottomPadding: 3*units.smallSpacing
0024     leftPadding: units.smallSpacing
0025     rightPadding: units.smallSpacing
0026 
0027     snapMode: T.Slider.SnapOnRelease
0028 
0029     readonly property bool minimumInternalValueIsSet: (minimumInternalValue!==from && minimumInternalValue !== -10000)
0030     property int minimumInternalValue: -10000
0031 
0032     PlasmaCore.Svg {
0033         id: grooveSvg
0034         imagePath: "widgets/slider"
0035         colorGroup: PlasmaCore.ColorScope.colorGroup
0036     }
0037 
0038     PlasmaCore.FrameSvgItem {
0039         id: minimumValueGroove
0040         imagePath: "widgets/slider"
0041         prefix: "groove-highlight"
0042         x: limitedX - width/2
0043         y: parent.height/2 - height/2
0044         width: parent.height * 0.6
0045         height: 2
0046         rotation: 90
0047         visible: minimumInternalValueIsSet
0048 
0049         readonly property int limitedX: limitedPer * parent.width
0050         readonly property real limitedPer: ((minimumInternalValue-from)/(to-from))
0051 
0052         opacity: {
0053             if (control.enabled && minimumInternalValueIsSet && value < minimumInternalValue) {
0054                 return 0.3
0055             }
0056 
0057             if (control.enabled) {
0058                 return 1;
0059             }
0060 
0061             return 0.4;
0062         }
0063     }
0064 
0065     handle: Item {
0066         property bool horizontal: control.orientation === Qt.Horizontal
0067         x: leftFixedPadding + (horizontal ? control.visualPosition * (control.availableWidth - width / 2) : (control.availableWidth - width) / 2)
0068         y: topFixedPadding + (horizontal ? (control.availableHeight - height) / 2 : control.visualPosition * (control.availableHeight - height / 2))
0069 
0070         width: firstHandle.naturalSize.width
0071         height: firstHandle.naturalSize.height
0072 
0073         property int leftFixedPadding: horizontal && control.visualPosition === 0 ? 0 : control.leftPadding
0074         property int topFixedPadding: !horizontal && control.visualPosition === 0 ? 0 : control.topPadding
0075 
0076         Private.RoundShadow {
0077             anchors.fill: parent
0078             imagePath: "widgets/slider"
0079             focusElement: parent.horizontal ? "horizontal-slider-focus" : "vertical-slider-focus"
0080             hoverElement: parent.horizontal ? "horizontal-slider-hover" : "vertical-slider-hover"
0081             shadowElement: parent.horizontal ? "horizontal-slider-shadow" : "vertical-slider-shadow"
0082             state: control.activeFocus ? "focus" : (control.hovered ? "hover" : "shadow")
0083         }
0084         PlasmaCore.SvgItem {
0085             id: firstHandle
0086             anchors.fill: parent
0087             svg: grooveSvg
0088             elementId: parent.horizontal ? "horizontal-slider-handle" : "vertical-slider-handle"
0089         }
0090     }
0091 
0092     background: PlasmaCore.FrameSvgItem {
0093         imagePath: "widgets/slider"
0094         prefix: "groove"
0095         readonly property bool horizontal: control.orientation === Qt.Horizontal
0096         implicitWidth: horizontal ? units.gridUnit * 8 : margins.left + margins.right
0097         implicitHeight: horizontal ? margins.top + margins.bottom : units.gridUnit * 8
0098         width: horizontal ? control.availableWidth : implicitWidth
0099         height: horizontal ? implicitHeight : control.availableHeight
0100         anchors.centerIn: parent
0101         scale: horizontal && control.mirrored ? -1 : 1
0102 
0103         PlasmaCore.FrameSvgItem {
0104             id: grooveHighlight
0105             imagePath: "widgets/slider"
0106             prefix: "groove-highlight"
0107             x: parent.horizontal ? 0 : (parent.width - width) / 2
0108             y: parent.horizontal ? (parent.height - height) / 2 : control.visualPosition * parent.height
0109             width: parent.horizontal ? control.position * parent.width + invisibleSpacer : parent.width
0110             height: parent.horizontal ? parent.height : control.position * parent.height + invisibleSpacer
0111             opacity: {
0112                 if (control.enabled && minimumInternalValueIsSet && value < minimumInternalValue) {
0113                     return 0.3
0114                 }
0115 
0116                 if (control.enabled) {
0117                     return 1;
0118                 }
0119 
0120                 return 0.4;
0121             }
0122 
0123             property int invisibleSpacer: control.position === 0 ? 4 : 0
0124         }
0125     }
0126 }