Debian Codegraph @

qml/components/ZoomControl.qml

raw
1 /*
2 * Copyright 2014 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17 import QtQuick 2.12
18 import Lomiri.Components 1.3
19
20 Item {
21 id: zoomControl
22 property alias minimumValue: slider.minimumValue
23 property alias maximumValue: slider.maximumValue
24 property alias value: slider.value
25
26 function show() {
27 zoomAutoHide.restart();
28 shown = true;
29 }
30
31 property bool shown: false
32 visible: opacity != 0.0
33 opacity: shown ? 1.0 : 0.0
34 layer.enabled: fadeAnimation.running
35 Behavior on opacity { LomiriNumberAnimation {id: fadeAnimation} }
36
37 Timer {
38 id: zoomAutoHide
39 interval: 2000
40 onTriggered: {
41 zoomControl.shown = false;
42 }
43 }
44
45 implicitHeight: slider.height
46
47 Image {
48 id: minusIcon
49 anchors {
50 left: parent.left
51 verticalCenter: parent.verticalCenter
52 }
53 source: "../../assets/zoom_minus.png"
54 asynchronous: true
55 cache: false
56 }
57
58 Slider {
59 id: slider
60 style: ThinSliderStyle {}
61 anchors {
62 left: minusIcon.right
63 right: plusIcon.left
64 }
65
66 live: true
67 minimumValue: 0.0 // No zoom => 0.0 zoom factor
68 value: minimumValue
69 }
70
71 Image {
72 id: plusIcon
73 anchors {
74 right: parent.right
75 verticalCenter: parent.verticalCenter
76 }
77 source: "../../assets/zoom_plus.png"
78 asynchronous: true
79 cache: false
80 }
81 }
82