Commit ba6522b4 authored by Gus Grubba's avatar Gus Grubba

Fix multiple selected state for offline maps buttons.

parent bc0afbca
...@@ -20,6 +20,8 @@ Rectangle { ...@@ -20,6 +20,8 @@ Rectangle {
border.width: _showBorder ? 1: 0 border.width: _showBorder ? 1: 0
border.color: qgcPal.buttonText border.color: qgcPal.buttonText
property var tileSet: null
property var currentSet: null
property bool checked: false property bool checked: false
property bool complete: false property bool complete: false
property alias text: nameLabel.text property alias text: nameLabel.text
...@@ -37,6 +39,19 @@ Rectangle { ...@@ -37,6 +39,19 @@ Rectangle {
signal clicked() signal clicked()
property ExclusiveGroup exclusiveGroup: null
onExclusiveGroupChanged: {
if (exclusiveGroup) {
checked = false
exclusiveGroup.bindCheckable(mapButton)
}
}
onCheckedChanged: {
if(checked) {
currentSet = tileSet
}
}
QGCPalette { id: qgcPal; colorGroupEnabled: enabled } QGCPalette { id: qgcPal; colorGroupEnabled: enabled }
Row { Row {
...@@ -85,26 +100,53 @@ Rectangle { ...@@ -85,26 +100,53 @@ Rectangle {
MouseArea { MouseArea {
anchors.fill: parent anchors.fill: parent
hoverEnabled: true hoverEnabled: !ScreenTools.isMobile
onMouseXChanged: { onMouseXChanged: {
if(!ScreenTools.isMobile) {
_lastGlobalMouseX = ScreenTools.mouseX() _lastGlobalMouseX = ScreenTools.mouseX()
_lastGlobalMouseY = ScreenTools.mouseY() _lastGlobalMouseY = ScreenTools.mouseY()
} }
}
onMouseYChanged: { onMouseYChanged: {
if(!ScreenTools.isMobile) {
_lastGlobalMouseX = ScreenTools.mouseX() _lastGlobalMouseX = ScreenTools.mouseX()
_lastGlobalMouseY = ScreenTools.mouseY() _lastGlobalMouseY = ScreenTools.mouseY()
} }
onEntered: { _hovered = true; _forceHoverOff = false; hoverTimer.start() } }
onExited: { _hovered = false; _forceHoverOff = false; hoverTimer.stop() } onEntered: {
onPressed: { _pressed = true; } if(!ScreenTools.isMobile) {
onReleased: { _pressed = false; } _hovered = true
onClicked: mapButton.clicked() _forceHoverOff = false
hoverTimer.start()
}
}
onExited: {
if(!ScreenTools.isMobile) {
_hovered = false
_forceHoverOff = false
hoverTimer.stop()
}
}
onPressed: {
if(!ScreenTools.isMobile) {
_pressed = true
}
}
onReleased: {
if(!ScreenTools.isMobile) {
_pressed = false
}
}
onClicked: {
checked = true
mapButton.clicked()
}
} }
Timer { Timer {
id: hoverTimer id: hoverTimer
interval: 250 interval: 250
repeat: true repeat: !ScreenTools.isMobile
onTriggered: { onTriggered: {
if (_lastGlobalMouseX !== ScreenTools.mouseX() || _lastGlobalMouseY !== ScreenTools.mouseY()) { if (_lastGlobalMouseX !== ScreenTools.mouseX() || _lastGlobalMouseY !== ScreenTools.mouseY()) {
_forceHoverOff = true _forceHoverOff = true
......
...@@ -918,11 +918,14 @@ QGCView { ...@@ -918,11 +918,14 @@ QGCView {
width: Math.min(_tileSetList.width, (ScreenTools.defaultFontPixelWidth * 50).toFixed(0)) width: Math.min(_tileSetList.width, (ScreenTools.defaultFontPixelWidth * 50).toFixed(0))
spacing: ScreenTools.defaultFontPixelHeight * 0.5 spacing: ScreenTools.defaultFontPixelHeight * 0.5
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
ExclusiveGroup { id: selectionGroup }
OfflineMapButton { OfflineMapButton {
id: firstButton id: firstButton
text: qsTr("Add New Set") text: qsTr("Add New Set")
width: _cacheList.width width: _cacheList.width
height: ScreenTools.defaultFontPixelHeight * 2 height: ScreenTools.defaultFontPixelHeight * (ScreenTools.isMobile ? 3 : 2)
currentSet: _currentSelection
exclusiveGroup: selectionGroup
onClicked: { onClicked: {
offlineMapView._currentSelection = null offlineMapView._currentSelection = null
addNewSet() addNewSet()
...@@ -936,7 +939,10 @@ QGCView { ...@@ -936,7 +939,10 @@ QGCView {
tiles: object.totalTileCount tiles: object.totalTileCount
complete: object.complete complete: object.complete
width: firstButton.width width: firstButton.width
height: ScreenTools.defaultFontPixelHeight * 2 height: ScreenTools.defaultFontPixelHeight * (ScreenTools.isMobile ? 3 : 2)
exclusiveGroup: selectionGroup
currentSet: _currentSelection
tileSet: object
onClicked: { onClicked: {
offlineMapView._currentSelection = object offlineMapView._currentSelection = object
showInfo() showInfo()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment