on xenial help sign in
Move Tooltip in a different component.
cca10e3Andrea Azzarone
qml/Launcher/LauncherPanel.qml+61−86
@@ -67,6 +67,13 @@ Rectangle {
67 quickList.focus = true;
67 quickList.focus = true;
68 }
68 }
69
69
70+ MouseArea {
71+ id: mouseEventEater
72+ anchors.fill: parent
73+ acceptedButtons: Qt.AllButtons
74+ onWheel: wheel.accepted = true;
75+ }
76+
70 Column {
77 Column {
71 id: mainColumn
78 id: mainColumn
72 anchors {
79 anchors {
@@ -824,24 +831,12 @@ Rectangle {
824 }
831 }
825 }
832 }
826
833
827− UbuntuShape {
834+ Tooltip {
828 id: tooltipShape
835 id: tooltipShape
829 objectName: "tooltipShape"
836 objectName: "tooltipShape"
830
837
838+ visible: tooltipShownState.active
831 rotation: root.rotation
839 rotation: root.rotation
832− aspect: UbuntuShape.Flat
833− color: theme.palette.normal.background
834− opacity: tooltipShownState.active ? 0.95 : 0
835− visible: opacity > 0
836−
837− Behavior on opacity {
838− UbuntuNumberAnimation {
839− duration: UbuntuAnimation.BriskDuration
840− }
841− }
842−
843− width: tooltipLabel.implicitWidth + units.gu(4)
844− height: tooltipLabel.implicitHeight + units.gu(2)
845 y: itemCenter - (height / 2)
840 y: itemCenter - (height / 2)
846
841
847 anchors {
842 anchors {
@@ -850,29 +845,9 @@ Rectangle {
850 margins: units.gu(1)
845 margins: units.gu(1)
851 }
846 }
852
847
853− Image {
854− anchors {
855− right: parent.left
856− rightMargin: -units.dp(4)
857− verticalCenter: parent.verticalCenter
858− }
859− height: units.gu(1)
860− width: units.gu(2)
861− source: "graphics/quicklist_tooltip.png"
862− rotation: 90
863− }
864−
865− Label {
866− id: tooltipLabel
867− anchors.centerIn: parent
868− verticalAlignment: Label.AlignVCenter
869− color: theme.palette.normal.backgroundText
870− anchors.margins: units.gu(10)
871−
872− Binding on text {
848+ Binding on text {
873− when: !!tooltipShape.hoveredItem
849+ when: !!tooltipShape.hoveredItem
874− value: !!tooltipShape.hoveredItem ? tooltipShape.hoveredItem.name : ""
850+ value: !!tooltipShape.hoveredItem ? tooltipShape.hoveredItem.name : ""
875− }
876 }
851 }
877
852
878 property var hoveredItem: dndArea.containsMouse ? launcherListView.itemAt(dndArea.mouseX, dndArea.mouseY + launcherListView.realContentY) : null
853 property var hoveredItem: dndArea.containsMouse ? launcherListView.itemAt(dndArea.mouseX, dndArea.mouseY + launcherListView.realContentY) : null
@@ -882,69 +857,69 @@ Rectangle {
882 when: !!tooltipShape.hoveredItem
857 when: !!tooltipShape.hoveredItem
883 value: !!tooltipShape.hoveredItem ? root.mapFromItem(tooltipShape.hoveredItem, 0, 0).y + (tooltipShape.hoveredItem.height / 2) + tooltipShape.hoveredItem.offset : 0
858 value: !!tooltipShape.hoveredItem ? root.mapFromItem(tooltipShape.hoveredItem, 0, 0).y + (tooltipShape.hoveredItem.height / 2) + tooltipShape.hoveredItem.offset : 0
884 }
859 }
860+ }
885
861
886− DSM.StateMachine {
862+ DSM.StateMachine {
887− id: tooltipStateMachine
863+ id: tooltipStateMachine
888− initialState: tooltipHiddenState
864+ initialState: tooltipHiddenState
889− running: true
865+ running: true
890
866
891− DSM.State {
867+ DSM.State {
892− id: tooltipHiddenState
868+ id: tooltipHiddenState
893
869
894− DSM.SignalTransition {
870+ DSM.SignalTransition {
895− targetState: tooltipShownState
871+ targetState: tooltipShownState
896− signal: tooltipShape.hoveredItemChanged
872+ signal: tooltipShape.hoveredItemChanged
897− // !dndArea.pressed allows us to filter out touch input events
873+ // !dndArea.pressed allows us to filter out touch input events
898− guard: tooltipShape.hoveredItem != null && !dndArea.pressed && !root.moving
874+ guard: tooltipShape.hoveredItem != null && !dndArea.pressed && !root.moving
899− }
900 }
875 }
876+ }
901
877
902− DSM.State {
878+ DSM.State {
903− id: tooltipShownState
879+ id: tooltipShownState
904
880
905− DSM.SignalTransition {
881+ DSM.SignalTransition {
906− targetState: tooltipHiddenState
882+ targetState: tooltipHiddenState
907− signal: tooltipShape.hoveredItemChanged
883+ signal: tooltipShape.hoveredItemChanged
908− guard: tooltipShape.hoveredItem == null
884+ guard: tooltipShape.hoveredItem == null
909− }
885+ }
910
886
911− DSM.SignalTransition {
887+ DSM.SignalTransition {
912− targetState: tooltipHiddenState
888+ targetState: tooltipHiddenState
913− signal: dndArea.exited
889+ signal: dndArea.exited
914− }
890+ }
915
891
916− DSM.SignalTransition {
892+ DSM.SignalTransition {
917− targetState: tooltipDismissedState
893+ targetState: tooltipDismissedState
918− signal: dndArea.onPressed
894+ signal: dndArea.onPressed
919− }
895+ }
920
896
921− DSM.SignalTransition {
897+ DSM.SignalTransition {
922− targetState: tooltipDismissedState
898+ targetState: tooltipDismissedState
923− signal: quickList.stateChanged
899+ signal: quickList.stateChanged
924− guard: quickList.state === "open"
900+ guard: quickList.state === "open"
925− }
901+ }
926
902
927− DSM.SignalTransition {
903+ DSM.SignalTransition {
928− targetState: tooltipDismissedState
904+ targetState: tooltipDismissedState
929− signal: root.movingChanged
905+ signal: root.movingChanged
930− guard: root.moving
906+ guard: root.moving
931− }
932 }
907 }
908+ }
933
909
934− DSM.State {
910+ DSM.State {
935− id: tooltipDismissedState
911+ id: tooltipDismissedState
936
912
937− DSM.SignalTransition {
913+ DSM.SignalTransition {
938− targetState: tooltipHiddenState
914+ targetState: tooltipHiddenState
939− signal: dndArea.positionChanged
915+ signal: dndArea.positionChanged
940− guard: quickList.state != "open" && !dndArea.pressed && !dndArea.moving
916+ guard: quickList.state != "open" && !dndArea.pressed && !dndArea.moving
941− }
917+ }
942
918
943− DSM.SignalTransition {
919+ DSM.SignalTransition {
944− targetState: tooltipHiddenState
920+ targetState: tooltipHiddenState
945− signal: dndArea.exited
921+ signal: dndArea.exited
946− guard: quickList.state != "open"
922+ guard: quickList.state != "open"
947− }
948 }
923 }
949 }
924 }
950 }
925 }
qml/Launcher/Tooltip.qmlnew file+72
@@ -0,0 +1,72 @@
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 Ubuntu.Components 1.3
19+
20+UbuntuShape {
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 UbuntuAnimation.SlowDuration.
25+ property alias delay: delayTimer.interval
26+
27+ // This property holds the text shown on the tool tip.
28+ property alias text: label.text
29+
30+ aspect: UbuntuShape.Flat
31+ color: theme.palette.normal.background
32+ width: label.implicitWidth + units.gu(4)
33+ height: label.implicitHeight + units.gu(2)
34+
35+ Behavior on opacity {
36+ UbuntuNumberAnimation {
37+ duration: UbuntuAnimation.BriskDuration
38+ }
39+ }
40+
41+ Binding on opacity {
42+ when: !visible
43+ value: 0
44+ }
45+
46+ Timer {
47+ id: delayTimer
48+ running: root.visible
49+ triggeredOnStart: true
50+ interval: UbuntuAnimation.SlowDuration
51+ onTriggered: root.opacity = (running ? .0 : .95)
52+ }
53+
54+ Image {
55+ anchors {
56+ right: parent.left
57+ rightMargin: -units.dp(4)
58+ verticalCenter: parent.verticalCenter
59+ }
60+ height: units.gu(1)
61+ width: units.gu(2)
62+ source: "graphics/quicklist_tooltip.png"
63+ rotation: 90
64+ }
65+
66+ Label {
67+ id: label
68+ anchors.centerIn: parent
69+ verticalAlignment: Label.AlignVCenter
70+ color: theme.palette.normal.backgroundText
71+ }
72+}