summaryrefslogtreecommitdiffstats
path: root/tradeshow/iot-sensortag/resources
diff options
context:
space:
mode:
authorKari Hautamäki <kari.hautamaki@qt.io>2017-02-09 16:43:22 +0200
committerTitta Heikkala <titta.heikkala@qt.io>2017-02-10 05:41:22 +0000
commit3bfd8426a8e5bb84516101b14398a0bc34f7ef71 (patch)
tree5703f2d43d7088cefc06bf60523980419fbf6113 /tradeshow/iot-sensortag/resources
parenta3447ec9896902354d89284cafba1e1dbac17774 (diff)
iot-sensortag: Hide menus by clicking outside
Add a fullscreen MouseArea that is used to close a menu when clicked outside of the menu Change-Id: I1479519f6f14be56c12445b92b0c05d519dc7f01 Reviewed-by: Titta Heikkala <titta.heikkala@qt.io>
Diffstat (limited to 'tradeshow/iot-sensortag/resources')
-rw-r--r--tradeshow/iot-sensortag/resources/base/TopToolbar.qml39
1 files changed, 34 insertions, 5 deletions
diff --git a/tradeshow/iot-sensortag/resources/base/TopToolbar.qml b/tradeshow/iot-sensortag/resources/base/TopToolbar.qml
index af6aba2..85dcb69 100644
--- a/tradeshow/iot-sensortag/resources/base/TopToolbar.qml
+++ b/tradeshow/iot-sensortag/resources/base/TopToolbar.qml
@@ -58,21 +58,24 @@ Item {
width: implicitWidth
CloudSettings {
- id: cloudSettins
+ id: cloudSettings
+
x: cloudItem.x
- y: parent.height
+ y: topToolbar.height
visible: false
}
SensorSettings {
id: sensorList
+
x: sensorItem.x
- y: parent.height
+ y: topToolbar.height
visible: false
}
Item {
id: cloudItem
+
height: topToolbar.height
anchors.top: parent.top
anchors.left: parent.left
@@ -102,7 +105,7 @@ Item {
MouseArea {
anchors.fill: parent
- onClicked: cloudSettins.visible = !cloudSettins.visible
+ onClicked: clickBait.activate(cloudSettings)
}
}
@@ -143,7 +146,7 @@ Item {
MouseArea {
anchors.fill: parent
- onClicked: sensorList.visible = !sensorList.visible
+ onClicked: clickBait.activate(sensorList)
}
}
@@ -192,4 +195,30 @@ Item {
anchors.bottomMargin: -18
source: pathPrefix + "Toolbar/topbar_all.png"
}
+
+ MouseArea {
+ id: clickBait
+
+ property var menu
+
+ function activate(menuItem) {
+ menu = menuItem;
+ menuItem.visible = true;
+ menuItem.parent = clickBait;
+ }
+
+ function deactivate() {
+ menu.parent = topToolbar;
+ menu.visible = false;
+ menu = null;
+ }
+
+ width: main.width
+ height: main.height
+ enabled: menu ? true : false
+ onClicked: {
+ if (!childAt(mouseX, mouseY))
+ deactivate();
+ }
+ }
}