~neon/plasmate/frameworks

« back to all changes in this revision

Viewing changes to themeexplorer/package/contents/ui/delegates/analog_meter.qml

  • Committer: Marco Martin
  • Date: 2015-03-04 17:45:32 UTC
  • Revision ID: git-v1:f684d78bd5880dfd090b809e5cf952ee9b80576f
add analog meter

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *   Copyright 2012 Viranch Mehta <viranch.mehta@gmail.com>
 
3
 *   Copyright 2012 Marco Martin <mart@kde.org>
 
4
 *   Copyright 2013 David Edmundson <davidedmundson@kde.org>
 
5
 *
 
6
 *   This program is free software; you can redistribute it and/or modify
 
7
 *   it under the terms of the GNU Library General Public License as
 
8
 *   published by the Free Software Foundation; either version 2 or
 
9
 *   (at your option) any later version.
 
10
 *
 
11
 *   This program is distributed in the hope that it will be useful,
 
12
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
 *   GNU Library General Public License for more details
 
15
 *
 
16
 *   You should have received a copy of the GNU Library General Public
 
17
 *   License along with this program; if not, write to the
 
18
 *   Free Software Foundation, Inc.,
 
19
 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
20
 */
 
21
 
 
22
import QtQuick 2.0
 
23
import org.kde.plasma.calendar 2.0 as PlasmaCalendar
 
24
import QtQuick.Layouts 1.1
 
25
 
 
26
import org.kde.plasma.core 2.0 as PlasmaCore
 
27
 
 
28
Item {
 
29
 
 
30
    property int value: 30
 
31
 
 
32
    PlasmaCore.Svg {
 
33
        id: meterSvg
 
34
        imagePath: "widgets/analog_meter"
 
35
    }
 
36
 
 
37
    PlasmaCore.SvgItem {
 
38
        id: face
 
39
        anchors.centerIn: parent
 
40
        width: Math.min(parent.width, parent.height)
 
41
        height: width / (naturalSize.width / naturalSize.height)
 
42
        svg: meterSvg
 
43
        elementId: "background"
 
44
    }
 
45
 
 
46
    PlasmaCore.SvgItem {
 
47
        id: centerScrew
 
48
        svg: meterSvg
 
49
        elementId: "rotatecenter"
 
50
        rotation: value + 90
 
51
 
 
52
        x: face.x + meterSvg.elementRect("rotatecenter").x * svgScale
 
53
        y: face.y + meterSvg.elementRect("rotatecenter").y * svgScale
 
54
 
 
55
        property real svgScale: face.width / face.naturalSize.width
 
56
        width: naturalSize.width * svgScale
 
57
        height: naturalSize.height * svgScale
 
58
 
 
59
        PlasmaCore.SvgItem {
 
60
            svg: meterSvg
 
61
 
 
62
            anchors.horizontalCenter: parent.horizontalCenter
 
63
            y: x
 
64
            elementId: "pointer-shadow"
 
65
            width: naturalSize.width * centerScrew.svgScale
 
66
            height: naturalSize.height * centerScrew.svgScale
 
67
        }
 
68
        PlasmaCore.SvgItem {
 
69
            id: hand
 
70
            svg: meterSvg
 
71
            elementId: "pointer"
 
72
            anchors.horizontalCenter: parent.horizontalCenter
 
73
            y: x
 
74
 
 
75
            width: naturalSize.width * centerScrew.svgScale
 
76
            height: naturalSize.height * centerScrew.svgScale
 
77
        }
 
78
    }
 
79
 
 
80
}