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