Warning, /frameworks/qqc2-desktop-style/org.kde.desktop/private/DefaultSliderHandle.qml is written in an unsupported language. File is not indexed.

0001 /*
0002     SPDX-FileCopyrightText: 2023 ivan tkachenko <me@ratijas.tk>
0003 
0004     SPDX-License-Identifier: LGPL-3.0-only OR GPL-2.0-or-later
0005 */
0006 
0007 import QtQuick
0008 import QtQuick.Templates as T
0009 import org.kde.qqc2desktopstyle.private as StylePrivate
0010 
0011 Item {
0012     id: handle
0013 
0014     required property T.Slider control
0015 
0016     readonly property StylePrivate.StyleItem styleItem: {
0017         const item = control.background;
0018         return (item instanceof StylePrivate.StyleItem) ? item : null;
0019     }
0020 
0021     // It won't keep track of an actual position, but QtQuick.Templates code
0022     // only accounts for handle size and does not care for x/y anyway.
0023     property size size
0024 
0025     function updateHandleSize() {
0026         if (styleItem) {
0027             const rect = styleItem.subControlRect("handle");
0028             size = Qt.size(rect.width, rect.height);
0029         }
0030     }
0031 
0032     x: control.leftPadding + Math.round(control.horizontal ? control.visualPosition * (control.availableWidth - width) : (control.availableWidth - width) / 2)
0033     y: control.topPadding + Math.round(control.horizontal ? (control.availableHeight - height) / 2 : control.visualPosition * (control.availableHeight - height))
0034 
0035     implicitWidth: size.width
0036     implicitHeight: size.height
0037 
0038     Connections {
0039         target: handle.styleItem
0040 
0041         function onStyleNameChanged() {
0042             handle.updateHandleSize();
0043         }
0044     }
0045 
0046     Component.onCompleted: {
0047         updateHandleSize();
0048     }
0049 }