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.15
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 aspect: LomiriShape.Flat
32 color: theme.palette.normal.background
33 width: label.implicitWidth + units.gu(4)
34 height: label.implicitHeight + units.gu(2)
35 opacity: 0
36
37 Image {
38 id: arrow
39 anchors {
40 right: parent.left
41 rightMargin: -units.dp(4)
42 verticalCenter: parent.verticalCenter
43 }
44 source: "graphics/quicklist_tooltip.png"
45 rotation: 90
46 visible: theme.palette.normal.background.hslLightness < 0.5
47 }
48
49 ColorOverlay {
50 anchors.fill: arrow
51 source: arrow
52 color: root.color
53 rotation: arrow.rotation
54 visible: theme.palette.normal.background.hslLightness >= 0.5
55 }
56
57 Label {
58 id: label
59 anchors.centerIn: parent
60 color: theme.palette.normal.backgroundText
61 }
62
63 states: [
64 State {
65 name: "visible"
66 when: root.visible
67 PropertyChanges {
68 target: root
69 opacity: 0.95
70 }
71 }
72 ]
73
74 transitions: [
75 Transition {
76 from: ""; to: "visible"
77 SequentialAnimation {
78 PauseAnimation { duration: root.delay }
79 LomiriNumberAnimation { target: root; property: "opacity"; duration: LomiriAnimation.BriskDuration }
80 }
81 }
82 ]
83}