Warning, /plasma/plasma-workspace/applets/analog-clock/contents/ui/Hand.qml is written in an unsupported language. File is not indexed.

0001 /*
0002     SPDX-FileCopyrightText: 2012 Viranch Mehta <viranch.mehta@gmail.com>
0003     SPDX-FileCopyrightText: 2012 Marco Martin <mart@kde.org>
0004     SPDX-FileCopyrightText: 2013 David Edmundson <davidedmundson@kde.org>
0005 
0006     SPDX-License-Identifier: LGPL-2.0-or-later
0007 */
0008 
0009 import QtQuick 2.0
0010 
0011 import org.kde.ksvg 1.0 as KSvg
0012 import org.kde.kirigami 2.20 as Kirigami
0013 
0014 KSvg.SvgItem {
0015     id: handRoot
0016 
0017     property alias rotation: rotation.angle
0018     property double svgScale
0019     property double horizontalRotationOffset: 0
0020     property double verticalRotationOffset: 0
0021     property string rotationCenterHintId
0022     readonly property double horizontalRotationCenter: {
0023         if (svg.hasElement(rotationCenterHintId)) {
0024             var hintedCenterRect = svg.elementRect(rotationCenterHintId),
0025                 handRect = svg.elementRect(elementId),
0026                 hintedX = hintedCenterRect.x - handRect.x + hintedCenterRect.width/2;
0027             return Math.round(hintedX * svgScale) + Math.round(hintedX * svgScale) % 2;
0028         }
0029         return width/2;
0030     }
0031     readonly property double verticalRotationCenter: {
0032         if (svg.hasElement(rotationCenterHintId)) {
0033             var hintedCenterRect = svg.elementRect(rotationCenterHintId),
0034                 handRect = svg.elementRect(elementId),
0035                 hintedY = hintedCenterRect.y - handRect.y + hintedCenterRect.height/2;
0036             return Math.round(hintedY * svgScale) + width % 2;
0037         }
0038         return width/2;
0039     }
0040 
0041     width: Math.round(naturalSize.width * svgScale) + Math.round(naturalSize.width * svgScale) % 2
0042     height: Math.round(naturalSize.height * svgScale) + width % 2
0043     anchors {
0044         top: clock.verticalCenter
0045         topMargin: -verticalRotationCenter + verticalRotationOffset
0046         left: clock.horizontalCenter
0047         leftMargin: -horizontalRotationCenter + horizontalRotationOffset
0048     }
0049 
0050     svg: clockSvg
0051     transform: Rotation {
0052         id: rotation
0053         angle: 0
0054         origin {
0055             x: handRoot.horizontalRotationCenter
0056             y: handRoot.verticalRotationCenter
0057         }
0058         Behavior on angle {
0059             RotationAnimation {
0060                 id: anim
0061                 duration: Kirigami.Units.longDuration
0062                 direction: RotationAnimation.Clockwise
0063                 easing.type: Easing.OutElastic
0064                 easing.overshoot: 0.5
0065             }
0066         }
0067     }
0068 }