Changeset View
Changeset View
Standalone View
Standalone View
source/qml/components/slider/SliderBasic.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: 128 | ||||
31 | id: root | ||||
32 | | ||||
33 | GridLayout { | ||||
34 | columns: 3 | ||||
35 | columnSpacing: Kirigami.Units.largeSpacing | ||||
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: "Select screen size:" | ||||
45 | } | ||||
46 | | ||||
47 | ColumnLayout { | ||||
48 | spacing: Kirigami.Units.largeSpacing | ||||
49 | Item { | ||||
50 | width: 200 | ||||
51 | height: Kirigami.Units.largeSpacing * 3 | ||||
52 | Slider { | ||||
53 | id: sld1 | ||||
54 | width: 200 | ||||
55 | value: 1 | ||||
56 | maximumValue: 5 | ||||
57 | minimumValue: 0 | ||||
58 | tickmarksEnabled: true | ||||
59 | style: Styles.SliderStyle { | ||||
60 | tickmarks: Repeater { | ||||
61 | id: repeater | ||||
62 | model: [0,1,2,3,4,5] | ||||
63 | Rectangle { | ||||
64 | color: "#777" | ||||
65 | width: 1 ; | ||||
66 | height: index == 0 || index == 5 ? Kirigami.Units.largeSpacing : Kirigami.Units.smallSpacing | ||||
67 | y: repeater.height | ||||
68 | x: styleData.handleWidth / 2 + index * ((repeater.width - styleData.handleWidth) / (repeater.count-1)) | ||||
69 | } | ||||
70 | } | ||||
71 | } | ||||
72 | } | ||||
73 | } | ||||
74 | Item { | ||||
75 | width: 200 | ||||
76 | height: units.largeSpacing | ||||
77 | Label { | ||||
78 | text: "640x480" | ||||
79 | } | ||||
80 | Label { | ||||
81 | text: "5120×2880" | ||||
82 | anchors.right: parent.right | ||||
83 | } | ||||
84 | } | ||||
85 | } | ||||
86 | | ||||
87 | Label { | ||||
88 | id: lbl2 | ||||
89 | text: "1024x768" | ||||
90 | Layout.alignment: Qt.AlignTop | ||||
91 | height: units.largeSpacing | ||||
92 | } | ||||
93 | } | ||||
94 | | ||||
95 | HIG.Raster { | ||||
96 | z: 1 | ||||
97 | } | ||||
98 | | ||||
99 | // HACK coordinates are only final after a small delay | ||||
100 | Timer { | ||||
101 | interval: 1000 | ||||
102 | repeat: false | ||||
103 | running: true | ||||
104 | onTriggered: { | ||||
105 | var a = new A.An(lbl1); | ||||
106 | a.draw({ | ||||
107 | outline: {label: false}, | ||||
108 | ruler: {offset: lbl1.mapToItem(root, 0, 0).y + lbl1.height, horizontal: true}, | ||||
109 | brace: {to: new A.An(sld1), text: "8px", center: false} | ||||
110 | }); | ||||
111 | | ||||
112 | a = new A.An(sld1); | ||||
113 | a.draw({ | ||||
114 | outline: {label: false}, | ||||
115 | ruler: [ | ||||
116 | {}, | ||||
117 | {offset: sld1.mapToItem(root, 0, 0).x + sld1.width} | ||||
118 | ], | ||||
119 | brace: {to: new A.An(lbl2), text: "8px", center: false} | ||||
120 | }); | ||||
121 | a = new A.An(lbl2); | ||||
122 | a.draw({ | ||||
123 | outline: {label: false} | ||||
124 | }); | ||||
125 | } | ||||
126 | } | ||||
127 | } |