Changeset View
Changeset View
Standalone View
Standalone View
source/qml/components/slider/SliderVolume.qml
- This file was added.
1 | /* | ||||
---|---|---|---|---|---|
2 | * Copyright 2018 Fabian Riethmayer | ||||
3 | * | ||||
4 | * This program is free software; you can redistribute it and/or modify | ||||
5 | * it under the terms of the GNU Library General Public License as | ||||
6 | * published by the Free Software Foundation; either version 2, or | ||||
7 | * (at your option) any later version. | ||||
8 | * | ||||
9 | * This program is distributed in the hope that it will be useful, | ||||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
12 | * GNU Library General Public License for more details | ||||
13 | * | ||||
14 | * You should have received a copy of the GNU Library General Public | ||||
15 | * License along with this program; if not, write to the | ||||
16 | * Free Software Foundation, Inc., | ||||
17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||||
18 | */ | ||||
19 | | ||||
20 | import QtQuick 2.6 | ||||
21 | import QtQuick.Controls 1.4 | ||||
22 | import QtQuick.Layouts 1.2 | ||||
23 | import org.kde.kirigami 2.4 as Kirigami | ||||
24 | import QtQuick.Controls.Styles.Plasma 2.0 as Styles | ||||
25 | import "../../lib" as HIG | ||||
26 | import "../../lib/annotate.js" as A | ||||
27 | | ||||
28 | Rectangle { | ||||
29 | width: 480 | ||||
30 | height: 100 | ||||
31 | id: root | ||||
32 | | ||||
33 | GridLayout { | ||||
34 | columns: 3 | ||||
35 | columnSpacing: Kirigami.Units.largeSpacing * 2 | ||||
36 | x: 20 | ||||
37 | y: 32 | ||||
38 | width: 280 | ||||
39 | | ||||
40 | Label { | ||||
41 | id: lbl1 | ||||
42 | width: 60 | ||||
43 | Layout.alignment: Qt.AlignLeft | Qt.AlignTop | ||||
44 | text: "Volume" | ||||
45 | } | ||||
46 | | ||||
47 | ColumnLayout { | ||||
48 | spacing: Kirigami.Units.largeSpacing * 2 | ||||
49 | Item { | ||||
50 | width: 200 | ||||
51 | height: Kirigami.Units.largeSpacing | ||||
52 | Slider { | ||||
53 | id: sld1 | ||||
54 | width: 200 | ||||
55 | value: 1 | ||||
56 | maximumValue: 4 | ||||
57 | minimumValue: 0 | ||||
58 | stepSize: 0.5 | ||||
59 | tickmarksEnabled: true | ||||
60 | } | ||||
61 | } | ||||
62 | } | ||||
63 | | ||||
64 | Label { | ||||
65 | id: lbl2 | ||||
66 | text: "20%" | ||||
67 | Layout.alignment: Qt.AlignTop | ||||
68 | height: units.largeSpacing | ||||
69 | } | ||||
70 | } | ||||
71 | | ||||
72 | HIG.Raster { | ||||
73 | z: 1 | ||||
74 | } | ||||
75 | | ||||
76 | // HACK coordinates are only final after a small delay | ||||
77 | Timer { | ||||
78 | interval: 1000 | ||||
79 | repeat: false | ||||
80 | running: true | ||||
81 | onTriggered: { | ||||
82 | var a = new A.An(lbl1); | ||||
83 | a.draw({ | ||||
84 | outline: {label: false}, | ||||
85 | ruler: {offset: lbl1.mapToItem(root, 0, 0).y + lbl1.height, horizontal: true}, | ||||
86 | brace: {to: new A.An(sld1), text: "8px", center: false} | ||||
87 | }); | ||||
88 | | ||||
89 | a = new A.An(sld1); | ||||
90 | a.draw({ | ||||
91 | outline: {label: false}, | ||||
92 | ruler: [ | ||||
93 | {}, | ||||
94 | {offset: sld1.mapToItem(root, 0, 0).x + sld1.width} | ||||
95 | ], | ||||
96 | brace: {to: new A.An(lbl2), text: "8px", center: false} | ||||
97 | }); | ||||
98 | a = new A.An(lbl2); | ||||
99 | a.draw({ | ||||
100 | outline: {label: false} | ||||
101 | }); | ||||
102 | } | ||||
103 | } | ||||
104 | } |