on xenial help sign in
Move Tooltip in a different component.
commitcca10e3efae7b85804f41efda69443c4f8ba82c6 authorAndrea Azzarone <azzaronea@gmail.com> dateTue 18 Oct 2016, 09:55 (10 years ago) parenta046475
2 files changed+133−86
qml/Launcher/LauncherPanel.qml+61−86 qml/Launcher/Tooltip.qml+72
qml/Launcher/LauncherPanel.qml+61−86
@@ -67,6 +67,13 @@ Rectangle {
6767 quickList.focus = true;
6868 }
6969
70+ MouseArea {
71+ id: mouseEventEater
72+ anchors.fill: parent
73+ acceptedButtons: Qt.AllButtons
74+ onWheel: wheel.accepted = true;
75+ }
76+
7077 Column {
7178 id: mainColumn
7279 anchors {
@@ -824,24 +831,12 @@ Rectangle {
824831 }
825832 }
826833
827− UbuntuShape {
834+ Tooltip {
828835 id: tooltipShape
829836 objectName: "tooltipShape"
830837
838+ visible: tooltipShownState.active
831839 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)
845840 y: itemCenter - (height / 2)
846841
847842 anchors {
@@ -850,29 +845,9 @@ Rectangle {
850845 margins: units.gu(1)
851846 }
852847
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 {
873− when: !!tooltipShape.hoveredItem
874− value: !!tooltipShape.hoveredItem ? tooltipShape.hoveredItem.name : ""
875− }
848+ Binding on text {
849+ when: !!tooltipShape.hoveredItem
850+ value: !!tooltipShape.hoveredItem ? tooltipShape.hoveredItem.name : ""
876851 }
877852
878853 property var hoveredItem: dndArea.containsMouse ? launcherListView.itemAt(dndArea.mouseX, dndArea.mouseY + launcherListView.realContentY) : null
@@ -882,69 +857,69 @@ Rectangle {
882857 when: !!tooltipShape.hoveredItem
883858 value: !!tooltipShape.hoveredItem ? root.mapFromItem(tooltipShape.hoveredItem, 0, 0).y + (tooltipShape.hoveredItem.height / 2) + tooltipShape.hoveredItem.offset : 0
884859 }
860+ }
885861
886− DSM.StateMachine {
887− id: tooltipStateMachine
888− initialState: tooltipHiddenState
889− running: true
862+ DSM.StateMachine {
863+ id: tooltipStateMachine
864+ initialState: tooltipHiddenState
865+ running: true
890866
891− DSM.State {
892− id: tooltipHiddenState
867+ DSM.State {
868+ id: tooltipHiddenState
893869
894− DSM.SignalTransition {
895− targetState: tooltipShownState
896− signal: tooltipShape.hoveredItemChanged
897− // !dndArea.pressed allows us to filter out touch input events
898− guard: tooltipShape.hoveredItem != null && !dndArea.pressed && !root.moving
899− }
870+ DSM.SignalTransition {
871+ targetState: tooltipShownState
872+ signal: tooltipShape.hoveredItemChanged
873+ // !dndArea.pressed allows us to filter out touch input events
874+ guard: tooltipShape.hoveredItem != null && !dndArea.pressed && !root.moving
900875 }
876+ }
901877
902− DSM.State {
903− id: tooltipShownState
878+ DSM.State {
879+ id: tooltipShownState
904880
905− DSM.SignalTransition {
906− targetState: tooltipHiddenState
907− signal: tooltipShape.hoveredItemChanged
908− guard: tooltipShape.hoveredItem == null
909− }
881+ DSM.SignalTransition {
882+ targetState: tooltipHiddenState
883+ signal: tooltipShape.hoveredItemChanged
884+ guard: tooltipShape.hoveredItem == null
885+ }
910886
911− DSM.SignalTransition {
912− targetState: tooltipHiddenState
913− signal: dndArea.exited
914− }
887+ DSM.SignalTransition {
888+ targetState: tooltipHiddenState
889+ signal: dndArea.exited
890+ }
915891
916− DSM.SignalTransition {
917− targetState: tooltipDismissedState
918− signal: dndArea.onPressed
919− }
892+ DSM.SignalTransition {
893+ targetState: tooltipDismissedState
894+ signal: dndArea.onPressed
895+ }
920896
921− DSM.SignalTransition {
922− targetState: tooltipDismissedState
923− signal: quickList.stateChanged
924− guard: quickList.state === "open"
925− }
897+ DSM.SignalTransition {
898+ targetState: tooltipDismissedState
899+ signal: quickList.stateChanged
900+ guard: quickList.state === "open"
901+ }
926902
927− DSM.SignalTransition {
928− targetState: tooltipDismissedState
929− signal: root.movingChanged
930− guard: root.moving
931− }
903+ DSM.SignalTransition {
904+ targetState: tooltipDismissedState
905+ signal: root.movingChanged
906+ guard: root.moving
932907 }
908+ }
933909
934− DSM.State {
935− id: tooltipDismissedState
910+ DSM.State {
911+ id: tooltipDismissedState
936912
937− DSM.SignalTransition {
938− targetState: tooltipHiddenState
939− signal: dndArea.positionChanged
940− guard: quickList.state != "open" && !dndArea.pressed && !dndArea.moving
941− }
913+ DSM.SignalTransition {
914+ targetState: tooltipHiddenState
915+ signal: dndArea.positionChanged
916+ guard: quickList.state != "open" && !dndArea.pressed && !dndArea.moving
917+ }
942918
943− DSM.SignalTransition {
944− targetState: tooltipHiddenState
945− signal: dndArea.exited
946− guard: quickList.state != "open"
947− }
919+ DSM.SignalTransition {
920+ targetState: tooltipHiddenState
921+ signal: dndArea.exited
922+ guard: quickList.state != "open"
948923 }
949924 }
950925 }
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+}