Warning, /plasma/latte-dock/declarativeimports/components/Slider.qml is written in an unsupported language. File is not indexed.
0001 /* 0002 * Copyright 2019 Michail Vourlakos <mvourlakos@gmail.com> 0003 * 0004 * This file is part of Latte-Dock 0005 * 0006 * Latte-Dock is free software; you can redistribute it and/or 0007 * modify it under the terms of the GNU General Public License as 0008 * published by the Free Software Foundation; either version 2 of 0009 * the License, or (at your option) any later version. 0010 * 0011 * Latte-Dock is distributed in the hope that it will be useful, 0012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0014 * GNU General Public License for more details. 0015 * 0016 * You should have received a copy of the GNU General Public License 0017 * along with this program. If not, see <http://www.gnu.org/licenses/>. 0018 */ 0019 0020 import QtQuick 2.7 0021 import QtQuick.Templates 2.0 as T 0022 import org.kde.plasma.core 2.0 as PlasmaCore 0023 import "private" as Private 0024 0025 T.Slider { 0026 id: control 0027 0028 implicitWidth: Math.max(background ? background.implicitWidth : 0, 0029 Math.max(handle ? handle.implicitWidth : 0, 0030 handle ? handle.implicitWidth : 0) + leftPadding + rightPadding) 0031 implicitHeight: Math.max(background ? background.implicitHeight : 0, 0032 Math.max(handle ? handle.implicitHeight : 0, 0033 handle ? handle.implicitHeight : 0) + topPadding + bottomPadding) 0034 0035 //padding: 3*units.smallSpacing //5//units.gridUnit 0036 topPadding: 3*units.smallSpacing 0037 bottomPadding: 3*units.smallSpacing 0038 leftPadding: units.smallSpacing 0039 rightPadding: units.smallSpacing 0040 0041 snapMode: T.Slider.SnapOnRelease 0042 0043 readonly property bool minimumInternalValueIsSet: (minimumInternalValue!==from && minimumInternalValue !== -10000) 0044 property int minimumInternalValue: -10000 0045 0046 PlasmaCore.Svg { 0047 id: grooveSvg 0048 imagePath: "widgets/slider" 0049 colorGroup: PlasmaCore.ColorScope.colorGroup 0050 } 0051 0052 PlasmaCore.FrameSvgItem { 0053 id: minimumValueGroove 0054 imagePath: "widgets/slider" 0055 prefix: "groove-highlight" 0056 x: limitedX - width/2 0057 y: parent.height/2 - height/2 0058 width: parent.height * 0.6 0059 height: 2 0060 rotation: 90 0061 visible: minimumInternalValueIsSet 0062 0063 readonly property int limitedX: limitedPer * parent.width 0064 readonly property real limitedPer: ((minimumInternalValue-from)/(to-from)) 0065 0066 opacity: { 0067 if (control.enabled && minimumInternalValueIsSet && value < minimumInternalValue) { 0068 return 0.3 0069 } 0070 0071 if (control.enabled) { 0072 return 1; 0073 } 0074 0075 return 0.4; 0076 } 0077 } 0078 0079 handle: Item { 0080 property bool horizontal: control.orientation === Qt.Horizontal 0081 x: leftFixedPadding + (horizontal ? control.visualPosition * (control.availableWidth - width / 2) : (control.availableWidth - width) / 2) 0082 y: topFixedPadding + (horizontal ? (control.availableHeight - height) / 2 : control.visualPosition * (control.availableHeight - height / 2)) 0083 0084 width: firstHandle.naturalSize.width 0085 height: firstHandle.naturalSize.height 0086 0087 property int leftFixedPadding: horizontal && control.visualPosition === 0 ? 0 : control.leftPadding 0088 property int topFixedPadding: !horizontal && control.visualPosition === 0 ? 0 : control.topPadding 0089 0090 Private.RoundShadow { 0091 anchors.fill: parent 0092 imagePath: "widgets/slider" 0093 focusElement: parent.horizontal ? "horizontal-slider-focus" : "vertical-slider-focus" 0094 hoverElement: parent.horizontal ? "horizontal-slider-hover" : "vertical-slider-hover" 0095 shadowElement: parent.horizontal ? "horizontal-slider-shadow" : "vertical-slider-shadow" 0096 state: control.activeFocus ? "focus" : (control.hovered ? "hover" : "shadow") 0097 } 0098 PlasmaCore.SvgItem { 0099 id: firstHandle 0100 anchors.fill: parent 0101 svg: grooveSvg 0102 elementId: parent.horizontal ? "horizontal-slider-handle" : "vertical-slider-handle" 0103 } 0104 } 0105 0106 background: PlasmaCore.FrameSvgItem { 0107 imagePath: "widgets/slider" 0108 prefix: "groove" 0109 readonly property bool horizontal: control.orientation === Qt.Horizontal 0110 implicitWidth: horizontal ? units.gridUnit * 8 : margins.left + margins.right 0111 implicitHeight: horizontal ? margins.top + margins.bottom : units.gridUnit * 8 0112 width: horizontal ? control.availableWidth : implicitWidth 0113 height: horizontal ? implicitHeight : control.availableHeight 0114 anchors.centerIn: parent 0115 scale: horizontal && control.mirrored ? -1 : 1 0116 0117 PlasmaCore.FrameSvgItem { 0118 id: grooveHighlight 0119 imagePath: "widgets/slider" 0120 prefix: "groove-highlight" 0121 x: parent.horizontal ? 0 : (parent.width - width) / 2 0122 y: parent.horizontal ? (parent.height - height) / 2 : control.visualPosition * parent.height 0123 width: parent.horizontal ? control.position * parent.width + invisibleSpacer : parent.width 0124 height: parent.horizontal ? parent.height : control.position * parent.height + invisibleSpacer 0125 opacity: { 0126 if (control.enabled && minimumInternalValueIsSet && value < minimumInternalValue) { 0127 return 0.3 0128 } 0129 0130 if (control.enabled) { 0131 return 1; 0132 } 0133 0134 return 0.4; 0135 } 0136 0137 property int invisibleSpacer: control.position === 0 ? 4 : 0 0138 } 0139 } 0140 }