Commit a5d3df39 authored by DonLakeFlyer's avatar DonLakeFlyer Committed by Don Gagne

Use FocusScope in all the right places

parent bc171f06
......@@ -45,9 +45,17 @@ Rectangle {
colorGroupEnabled: enabled
}
MouseArea {
FocusScope {
id: currentItemScope
anchors.fill: parent
onClicked: _root.clicked()
MouseArea {
anchors.fill: parent
onClicked: {
currentItemScope.focus = true
_root.clicked()
}
}
}
QGCLabel {
......@@ -76,7 +84,14 @@ Rectangle {
QGCMouseArea {
fillItem: hamburger
visible: hamburger.visible
onClicked: _waypointsOnlyMode ? waypointsOnlyMenu.popup() : normalMenu.popup()
onClicked: {
currentItemScope.focus = true
if (_waypointsOnlyMode) {
waypointsOnlyMenu.popup()
} else {
normalMenu.popup()
}
}
Menu {
id: normalMenu
......
......@@ -6,12 +6,11 @@ import QtGraphicalEffects 1.0
import QGroundControl.ScreenTools 1.0
import QGroundControl.Palette 1.0
QGCMouseArea {
FocusScope {
id: _root
anchors.left: parent.left
anchors.right: parent.right
height: column.height
onClicked: checked = !checked
property alias text: label.text
property bool checked: true
......@@ -27,38 +26,47 @@ QGCMouseArea {
QGCPalette { id: qgcPal; colorGroupEnabled: true }
ColumnLayout {
id: column
anchors.left: parent.left
anchors.right: parent.right
QGCMouseArea {
anchors.fill: parent
Item {
height: _sectionSpacer
width: 1
visible: showSpacer
onClicked: {
_root.focus = true
checked = !checked
}
QGCLabel {
id: label
Layout.fillWidth: true
ColumnLayout {
id: column
anchors.left: parent.left
anchors.right: parent.right
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
Item {
height: _sectionSpacer
width: 1
visible: showSpacer
}
}
Rectangle {
anchors.left: parent.left
anchors.right: parent.right
height: 1
color: qgcPal.text
QGCLabel {
id: label
Layout.fillWidth: true
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 {
}
}
onClicked: popup.toggleShow()
onClicked: {
combo.focus = true
popup.toggleShow()
}
Component.onCompleted: {
if (currentIndex === -1) {
......
......@@ -163,71 +163,77 @@ Rectangle {
visible: index == 0 ? _showOptionalElements : true
}
Rectangle {
FocusScope {
id: scope
anchors.left: parent.left
anchors.right: parent.right
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 {
id: opacityAnimation
running: false
from: 0
to: 1.0
loops: Animation.Infinite
duration: 2000
Rectangle {
anchors.fill: parent
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 {
id: opacityAnimation
running: false
from: 0
to: 1.0
loops: Animation.Infinite
duration: 2000
}
}
}
QGCMouseArea {
// Size of mouse area is expanded to make touch easier
anchors.leftMargin: -buttonStripColumn.anchors.margins
anchors.rightMargin: -buttonStripColumn.anchors.margins
anchors.left: parent.left
anchors.right: parent.right
anchors.top: parent.top
height: parent.height + (_showOptionalElements? buttonLabel.height + buttonColumn.spacing : 0)
visible: _buttonEnabled
preventStealing: true
onClicked: {
if (modelData.dropPanelComponent === undefined) {
dropPanel.hide()
if (modelData.toggle === true) {
checked = !checked
} else {
// dropPanel.hide above will close panel, but we need to do this to clear toggles
uncheckAll()
}
_root.clicked(index, checked)
} else {
if (checked) {
dropPanel.hide() // hide affects checked, so this needs to be duplicated inside not outside if
QGCMouseArea {
// Size of mouse area is expanded to make touch easier
anchors.leftMargin: -buttonStripColumn.anchors.margins
anchors.rightMargin: -buttonStripColumn.anchors.margins
anchors.left: parent.left
anchors.right: parent.right
anchors.top: parent.top
height: parent.height + (_showOptionalElements? buttonLabel.height + buttonColumn.spacing : 0)
visible: _buttonEnabled
preventStealing: true
onClicked: {
scope.focus = true
if (modelData.dropPanelComponent === undefined) {
dropPanel.hide()
if (modelData.toggle === true) {
checked = !checked
} else {
// dropPanel.hide above will close panel, but we need to do this to clear toggles
uncheckAll()
}
_root.clicked(index, checked)
} else {
dropPanel.hide() // hide affects checked, so this needs to be duplicated inside not outside if
uncheckAll()
checked = true
var panelEdgeTopPoint = mapToItem(_root, width, 0)
dropPanel.show(panelEdgeTopPoint, height, modelData.dropPanelComponent)
if (checked) {
dropPanel.hide() // hide affects checked, so this needs to be duplicated inside not outside if
} else {
dropPanel.hide() // hide affects checked, so this needs to be duplicated inside not outside if
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