Lomiri
Loading...
Searching...
No Matches
Tooltip.qml
1/*
2 * Copyright (C) 2016 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
17import QtQuick 2.12
18import QtGraphicalEffects 1.12
19import Lomiri.Components 1.3
20
21LomiriShape {
22 id: root
23
24 // This property holds the delay (milliseconds) after which the tool tip is shown.
25 // A tooltip with a negative delay is shown immediately. The default value is 500 ms.
26 property int delay: 500
27
28 // This property holds the text shown on the tool tip.
29 property alias text: label.text
30
31 readonly property bool lightMode: true
32
33 aspect: LomiriShape.Flat
34 color: theme.palette.normal.background
35 width: label.implicitWidth + units.gu(4)
36 height: label.implicitHeight + units.gu(2)
37 opacity: 0
38
39 Image {
40 id: arrow
41 anchors {
42 right: parent.left
43 rightMargin: -units.dp(4)
44 verticalCenter: parent.verticalCenter
45 }
46 source: "graphics/quicklist_tooltip.png"
47 rotation: 90
48 visible: !root.lightMode
49 }
50
51 ColorOverlay {
52 anchors.fill: arrow
53 source: arrow
54 color: root.color
55 rotation: arrow.rotation
56 visible: root.lightMode
57 }
58
59 Label {
60 id: label
61 anchors.centerIn: parent
62 color: theme.palette.normal.backgroundText
63 }
64
65 states: [
66 State {
67 name: "visible"
68 when: root.visible
69 PropertyChanges {
70 target: root
71 opacity: 0.95
72 }
73 }
74 ]
75
76 transitions: [
77 Transition {
78 from: ""; to: "visible"
79 SequentialAnimation {
80 PauseAnimation { duration: root.delay }
81 LomiriNumberAnimation { target: root; property: "opacity"; duration: LomiriAnimation.BriskDuration }
82 }
83 }
84 ]
85}