Commit 6bdc8428 authored by DonLakeFlyer's avatar DonLakeFlyer

Use FocusScope in all the right places

parent 4d9627f8
...@@ -41,9 +41,17 @@ Rectangle { ...@@ -41,9 +41,17 @@ Rectangle {
colorGroupEnabled: enabled colorGroupEnabled: enabled
} }
MouseArea { FocusScope {
id: currentItemScope
anchors.fill: parent anchors.fill: parent
onClicked: _root.clicked()
MouseArea {
anchors.fill: parent
onClicked: {
currentItemScope.focus = true
_root.clicked()
}
}
} }
QGCLabel { QGCLabel {
...@@ -72,7 +80,10 @@ Rectangle { ...@@ -72,7 +80,10 @@ Rectangle {
QGCMouseArea { QGCMouseArea {
fillItem: hamburger fillItem: hamburger
visible: hamburger.visible visible: hamburger.visible
onClicked: hamburgerMenu.popup() onClicked: {
currentItemScope.focus = true
hamburgerMenu.popup()
}
Menu { Menu {
id: hamburgerMenu id: hamburgerMenu
......
...@@ -6,12 +6,11 @@ import QtGraphicalEffects 1.0 ...@@ -6,12 +6,11 @@ import QtGraphicalEffects 1.0
import QGroundControl.ScreenTools 1.0 import QGroundControl.ScreenTools 1.0
import QGroundControl.Palette 1.0 import QGroundControl.Palette 1.0
QGCMouseArea { FocusScope {
id: _root id: _root
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
height: column.height height: column.height
onClicked: checked = !checked
property alias text: label.text property alias text: label.text
property bool checked: true property bool checked: true
...@@ -27,38 +26,47 @@ QGCMouseArea { ...@@ -27,38 +26,47 @@ QGCMouseArea {
QGCPalette { id: qgcPal; colorGroupEnabled: true } QGCPalette { id: qgcPal; colorGroupEnabled: true }
ColumnLayout { QGCMouseArea {
id: column anchors.fill: parent
anchors.left: parent.left
anchors.right: parent.right
Item { onClicked: {
height: _sectionSpacer _root.focus = true
width: 1 checked = !checked
visible: showSpacer
} }
QGCLabel { ColumnLayout {
id: label id: column
Layout.fillWidth: true anchors.left: parent.left
anchors.right: parent.right
QGCColoredImage { Item {
id: image height: _sectionSpacer
width: label.height / 2 width: 1
height: width visible: showSpacer
anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter
source: "/qmlimages/arrow-down.png"
color: qgcPal.text
visible: !_root.checked
} }
}
Rectangle { QGCLabel {
anchors.left: parent.left id: label
anchors.right: parent.right Layout.fillWidth: true
height: 1
color: qgcPal.text QGCColoredImage {
id: image
width: label.height / 2
height: width
anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter
source: "/qmlimages/arrow-down.png"
color: qgcPal.text
visible: !_root.checked
}
}
Rectangle {
anchors.left: parent.left
anchors.right: parent.right
height: 1
color: qgcPal.text
}
} }
} }
} }
...@@ -68,7 +68,10 @@ Button { ...@@ -68,7 +68,10 @@ Button {
} }
} }
onClicked: popup.toggleShow() onClicked: {
combo.focus = true
popup.toggleShow()
}
Component.onCompleted: { Component.onCompleted: {
if (currentIndex === -1) { if (currentIndex === -1) {
......
...@@ -163,71 +163,77 @@ Rectangle { ...@@ -163,71 +163,77 @@ Rectangle {
visible: index == 0 ? _showOptionalElements : true visible: index == 0 ? _showOptionalElements : true
} }
Rectangle { FocusScope {
id: scope
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
height: width height: width
color: checked ? _repeaterPal.buttonHighlight : _repeaterPal.button
QGCColoredImage {
id: button
anchors.fill: parent
source: _source
sourceSize.height: parent.height
fillMode: Image.PreserveAspectFit
mipmap: true
smooth: true
color: checked ? _repeaterPal.buttonHighlightText : _repeaterPal.buttonText
RotationAnimation on rotation {
id: imageRotation
loops: Animation.Infinite
from: 0
to: 360
duration: 500
running: false
}
NumberAnimation on opacity { Rectangle {
id: opacityAnimation anchors.fill: parent
running: false color: checked ? _repeaterPal.buttonHighlight : _repeaterPal.button
from: 0
to: 1.0 QGCColoredImage {
loops: Animation.Infinite id: button
duration: 2000 anchors.fill: parent
source: _source
sourceSize.height: parent.height
fillMode: Image.PreserveAspectFit
mipmap: true
smooth: true
color: checked ? _repeaterPal.buttonHighlightText : _repeaterPal.buttonText
RotationAnimation on rotation {
id: imageRotation
loops: Animation.Infinite
from: 0
to: 360
duration: 500
running: false
}
NumberAnimation on opacity {
id: opacityAnimation
running: false
from: 0
to: 1.0
loops: Animation.Infinite
duration: 2000
}
} }
}
QGCMouseArea { QGCMouseArea {
// Size of mouse area is expanded to make touch easier // Size of mouse area is expanded to make touch easier
anchors.leftMargin: -buttonStripColumn.anchors.margins anchors.leftMargin: -buttonStripColumn.anchors.margins
anchors.rightMargin: -buttonStripColumn.anchors.margins anchors.rightMargin: -buttonStripColumn.anchors.margins
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
anchors.top: parent.top anchors.top: parent.top
height: parent.height + (_showOptionalElements? buttonLabel.height + buttonColumn.spacing : 0) height: parent.height + (_showOptionalElements? buttonLabel.height + buttonColumn.spacing : 0)
visible: _buttonEnabled visible: _buttonEnabled
preventStealing: true preventStealing: true
onClicked: { onClicked: {
if (modelData.dropPanelComponent === undefined) { scope.focus = true
dropPanel.hide() if (modelData.dropPanelComponent === undefined) {
if (modelData.toggle === true) { dropPanel.hide()
checked = !checked if (modelData.toggle === true) {
} else { checked = !checked
// dropPanel.hide above will close panel, but we need to do this to clear toggles } else {
uncheckAll() // dropPanel.hide above will close panel, but we need to do this to clear toggles
} uncheckAll()
_root.clicked(index, checked) }
} else { _root.clicked(index, checked)
if (checked) {
dropPanel.hide() // hide affects checked, so this needs to be duplicated inside not outside if
} else { } else {
dropPanel.hide() // hide affects checked, so this needs to be duplicated inside not outside if if (checked) {
uncheckAll() dropPanel.hide() // hide affects checked, so this needs to be duplicated inside not outside if
checked = true } else {
var panelEdgeTopPoint = mapToItem(_root, width, 0) dropPanel.hide() // hide affects checked, so this needs to be duplicated inside not outside if
dropPanel.show(panelEdgeTopPoint, height, modelData.dropPanelComponent) uncheckAll()
checked = true
var panelEdgeTopPoint = mapToItem(_root, width, 0)
dropPanel.show(panelEdgeTopPoint, height, modelData.dropPanelComponent)
}
} }
} }
} }
......
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