diff --git a/src/AutoPilotPlugins/APM/APMSafetyComponentSub.qml b/src/AutoPilotPlugins/APM/APMSafetyComponentSub.qml index bcddbf03c7530dc3cdf30d7dc644b38c05f5796b..6a926d5239b23fee3e8184165ae35450d17207ab 100644 --- a/src/AutoPilotPlugins/APM/APMSafetyComponentSub.qml +++ b/src/AutoPilotPlugins/APM/APMSafetyComponentSub.qml @@ -61,8 +61,6 @@ SetupPage { property real _margins: ScreenTools.defaultFontPixelHeight property bool _showIcon: !ScreenTools.isTinyScreen - ExclusiveGroup { id: fenceActionRadioGroup } - Column { spacing: _margins / 2 diff --git a/src/AutoPilotPlugins/APM/APMTuningComponentCopter.qml b/src/AutoPilotPlugins/APM/APMTuningComponentCopter.qml index 37c5abd221b8233810a62cf0c5e25dcac96ad054..6a3ed808371060075c1f955f6bd5b02f4b1b7478 100644 --- a/src/AutoPilotPlugins/APM/APMTuningComponentCopter.qml +++ b/src/AutoPilotPlugins/APM/APMTuningComponentCopter.qml @@ -59,10 +59,6 @@ SetupPage { property bool _loadComplete: false - ExclusiveGroup { id: fenceActionRadioGroup } - ExclusiveGroup { id: landLoiterRadioGroup } - ExclusiveGroup { id: returnAltRadioGroup } - Component.onCompleted: { // We use QtCharts only on Desktop platforms showAdvanced = !ScreenTools.isMobile diff --git a/src/AutoPilotPlugins/APM/APMTuningComponentSub.qml b/src/AutoPilotPlugins/APM/APMTuningComponentSub.qml index 9b7ddac528656f477a8d47853d8b7381130f42e5..c238b97132c8f459f89964cdd3e3a3f86d888f29 100644 --- a/src/AutoPilotPlugins/APM/APMTuningComponentSub.qml +++ b/src/AutoPilotPlugins/APM/APMTuningComponentSub.qml @@ -34,14 +34,12 @@ SetupPage { property real _margins: ScreenTools.defaultFontPixelHeight - ExclusiveGroup { id: buttonGroup } - Row { spacing: _margins QGCButton { id: atcButton text: qsTr("Attitude Controller Parameters") - exclusiveGroup: buttonGroup + autoExclusive: true checked: true onClicked: checked = true } @@ -49,14 +47,14 @@ SetupPage { QGCButton { id: posButton text: qsTr("Position Controller Parameters") - exclusiveGroup: buttonGroup + autoExclusive: true onClicked: checked = true } QGCButton { id: navButton text: qsTr("Waypoint navigation parameters") - exclusiveGroup: buttonGroup + autoExclusive: true onClicked: checked = true } } diff --git a/src/PlanView/CameraCalcCamera.qml b/src/PlanView/CameraCalcCamera.qml index ba069e82bd7be15e1d4b6989192530f6eab5dc5e..8464e96f9414ca408c16cb35025eda6a3b56f123 100644 --- a/src/PlanView/CameraCalcCamera.qml +++ b/src/PlanView/CameraCalcCamera.qml @@ -28,10 +28,6 @@ Column { QGCPalette { id: qgcPal; colorGroupEnabled: true } - ExclusiveGroup { - id: cameraOrientationGroup - } - Column { anchors.left: parent.left anchors.right: parent.right diff --git a/src/QmlControls/ParameterEditor.qml b/src/QmlControls/ParameterEditor.qml index 32c2e45853acfeee371bd73cc82bd1dc5fb16151..eb7c482f4f3c3954a131dfb1b94db3b364f3bc17 100644 --- a/src/QmlControls/ParameterEditor.qml +++ b/src/QmlControls/ParameterEditor.qml @@ -188,8 +188,6 @@ Item { } } - ExclusiveGroup { id: buttonGroup } - Repeater { model: categoryHeader.checked ? controller.getGroupsForCategory(category) : 0 @@ -198,7 +196,7 @@ Item { text: groupName height: _rowHeight checked: controller.currentGroup === text - exclusiveGroup: buttonGroup + autoExclusive: true readonly property string groupName: modelData diff --git a/src/QmlControls/QGCButton.qml b/src/QmlControls/QGCButton.qml index 8337459bfe1db8606b929d47c91908011baa8933..c99e7cc2478f802e78262bdf86d2daa607410a71 100644 --- a/src/QmlControls/QGCButton.qml +++ b/src/QmlControls/QGCButton.qml @@ -1,111 +1,76 @@ -import QtQuick 2.3 -import QtQuick.Controls 1.2 -import QtQuick.Controls.Styles 1.4 +import QtQuick 2.3 +import QtQuick.Controls 2.12 +import QtQuick.Controls.Styles 1.4 import QGroundControl.Palette 1.0 import QGroundControl.ScreenTools 1.0 Button { - activeFocusOnPress: true + id: control + hoverEnabled: true + topPadding: _verticalPadding + bottomPadding: _verticalPadding + leftPadding: _horizontalPadding + rightPadding: _horizontalPadding + focusPolicy: Qt.ClickFocus property bool primary: false ///< primary button for a group of buttons property real pointSize: ScreenTools.defaultFontPointSize ///< Point size for button text - property bool showBorder: _qgcPal.globalTheme === QGCPalette.Light + property bool showBorder: qgcPal.globalTheme === QGCPalette.Light property bool iconLeft: false property real backRadius: 0 property real heightFactor: 0.5 + property string iconSource - property var _qgcPal: QGCPalette { colorGroupEnabled: enabled } - property bool _showHighlight: (pressed | hovered | checked) && !__forceHoverOff + property bool _showHighlight: pressed | hovered | checked - // This fixes the issue with button hover where if a Button is near the edge oa QQuickWidget you can - // move the mouse fast enough such that the MouseArea does not trigger an onExited. This is turn - // cause the hover property to not be cleared correctly. - - property bool __forceHoverOff: false - - property int __lastGlobalMouseX: 0 - property int __lastGlobalMouseY: 0 property int _horizontalPadding: ScreenTools.defaultFontPixelWidth property int _verticalPadding: Math.round(ScreenTools.defaultFontPixelHeight * heightFactor) - Connections { - target: __behavior - onMouseXChanged: { - __lastGlobalMouseX = ScreenTools.mouseX() - __lastGlobalMouseY = ScreenTools.mouseY() - } - onMouseYChanged: { - __lastGlobalMouseX = ScreenTools.mouseX() - __lastGlobalMouseY = ScreenTools.mouseY() - } - onEntered: { __forceHoverOff = false; hoverTimer.start() } - onExited: { __forceHoverOff = false; hoverTimer.stop() } - } + QGCPalette { id: qgcPal; colorGroupEnabled: enabled } - Timer { - id: hoverTimer - interval: 250 - repeat: true - onTriggered: { - __forceHoverOff = (__lastGlobalMouseX !== ScreenTools.mouseX() || __lastGlobalMouseY !== ScreenTools.mouseY()); - } + background: Rectangle { + id: backRect + implicitWidth: ScreenTools.implicitButtonWidth + implicitHeight: ScreenTools.implicitButtonHeight + radius: backRadius + border.width: showBorder ? 1 : 0 + border.color: qgcPal.buttonText + color: _showHighlight ? + qgcPal.buttonHighlight : + (primary ? qgcPal.primaryButton : qgcPal.button) } - style: ButtonStyle { - /*! The padding between the background and the label components. */ - padding { - top: _verticalPadding - bottom: _verticalPadding - left: _horizontalPadding - right: _horizontalPadding - } - - /*! This defines the background of the button. */ - background: Rectangle { - id: backRect - implicitWidth: ScreenTools.implicitButtonWidth - implicitHeight: ScreenTools.implicitButtonHeight - radius: backRadius - border.width: showBorder ? 1 : 0 - border.color: _qgcPal.buttonText - color: _showHighlight ? - control._qgcPal.buttonHighlight : - (primary ? control._qgcPal.primaryButton : control._qgcPal.button) - } - - /*! This defines the label of the button. */ - label: Item { - implicitWidth: text.implicitWidth + icon.width - implicitHeight: text.implicitHeight - baselineOffset: text.y + text.baselineOffset + contentItem: Item { + implicitWidth: text.implicitWidth + icon.width + implicitHeight: text.implicitHeight + baselineOffset: text.y + text.baselineOffset - QGCColoredImage { - id: icon - source: control.iconSource - height: source === "" ? 0 : text.height - width: height - color: text.color - fillMode: Image.PreserveAspectFit - sourceSize.height: height - anchors.left: control.iconLeft ? parent.left : undefined - anchors.leftMargin: control.iconLeft ? ScreenTools.defaultFontPixelWidth : undefined - anchors.right: !control.iconLeft ? parent.right : undefined - anchors.rightMargin: !control.iconLeft ? ScreenTools.defaultFontPixelWidth : undefined - anchors.verticalCenter: parent.verticalCenter - } + QGCColoredImage { + id: icon + source: control.iconSource + height: source === "" ? 0 : text.height + width: height + color: text.color + fillMode: Image.PreserveAspectFit + sourceSize.height: height + anchors.left: control.iconLeft ? parent.left : undefined + anchors.leftMargin: control.iconLeft ? ScreenTools.defaultFontPixelWidth : undefined + anchors.right: !control.iconLeft ? parent.right : undefined + anchors.rightMargin: !control.iconLeft ? ScreenTools.defaultFontPixelWidth : undefined + anchors.verticalCenter: parent.verticalCenter + } - Text { - id: text - anchors.centerIn: parent - antialiasing: true - text: control.text - font.pointSize: pointSize - font.family: ScreenTools.normalFontFamily - color: _showHighlight ? - control._qgcPal.buttonHighlightText : - (primary ? control._qgcPal.primaryButtonText : control._qgcPal.buttonText) - } - } + Text { + id: text + anchors.centerIn: parent + antialiasing: true + text: control.text + font.pointSize: pointSize + font.family: ScreenTools.normalFontFamily + color: _showHighlight ? + qgcPal.buttonHighlightText : + (primary ? qgcPal.primaryButtonText : qgcPal.buttonText) } + } } diff --git a/src/ui/AppSettings.qml b/src/ui/AppSettings.qml index a6e5ce6ca3c00efb47241d24024f0b51e3ee87e6..b7a717cd5de3aa387af91662ef737603c59f7849 100644 --- a/src/ui/AppSettings.qml +++ b/src/ui/AppSettings.qml @@ -49,8 +49,6 @@ Rectangle { flickableDirection: Flickable.VerticalFlick clip: true - ExclusiveGroup { id: panelActionGroup } - ColumnLayout { id: buttonColumn spacing: _verticalMargin @@ -62,7 +60,7 @@ Rectangle { QGCButton { height: _buttonHeight text: modelData.title - exclusiveGroup: panelActionGroup + autoExclusive: true Layout.fillWidth: true onClicked: { diff --git a/src/ui/preferences/BluetoothSettings.qml b/src/ui/preferences/BluetoothSettings.qml index 0a98122ac67c1517ff5ac4be47a64ea20b8cf296..5c0befbcbf84b12b0d3a5371187c4d878a673d0a 100644 --- a/src/ui/preferences/BluetoothSettings.qml +++ b/src/ui/preferences/BluetoothSettings.qml @@ -25,7 +25,6 @@ Column { function saveSettings() { // No need } - ExclusiveGroup { id: linkGroup } Row { spacing: ScreenTools.defaultFontPixelWidth QGCLabel { @@ -79,10 +78,10 @@ Column { model: subEditConfig && subEditConfig.linkType === LinkConfiguration.TypeBluetooth ? subEditConfig.nameList : "" delegate: QGCButton { - text: modelData - width: _secondColumn + text: modelData + width: _secondColumn anchors.leftMargin: ScreenTools.defaultFontPixelWidth * 2 - exclusiveGroup: linkGroup + autoExclusive: true onClicked: { checked = true if(subEditConfig && modelData !== "") diff --git a/src/ui/preferences/LinkSettings.qml b/src/ui/preferences/LinkSettings.qml index 99713fd6df437da21565f2b7758ae06f4960f102..8b3d76106839c2f6a5d707bfb3cb6b0c4ee10f9d 100644 --- a/src/ui/preferences/LinkSettings.qml +++ b/src/ui/preferences/LinkSettings.qml @@ -27,8 +27,6 @@ Rectangle { property int _firstColumn: ScreenTools.defaultFontPixelWidth * 12 property int _secondColumn: ScreenTools.defaultFontPixelWidth * 30 - ExclusiveGroup { id: linkGroup } - QGCPalette { id: qgcPal colorGroupEnabled: enabled @@ -65,7 +63,7 @@ Rectangle { anchors.horizontalCenter: settingsColumn.horizontalCenter width: _linkRoot.width * 0.5 text: object.name - exclusiveGroup: linkGroup + autoExclusive: true visible: !object.dynamic onClicked: { checked = true diff --git a/src/ui/preferences/UdpSettings.qml b/src/ui/preferences/UdpSettings.qml index fc780a2f23e0aa408f8549454b8e6952f3651229..bc77297df4329b1d55a8a01d789d0ef550c080a8 100644 --- a/src/ui/preferences/UdpSettings.qml +++ b/src/ui/preferences/UdpSettings.qml @@ -28,8 +28,6 @@ Column { property string _currentHost: "" - ExclusiveGroup { id: linkGroup } - Row { spacing: ScreenTools.defaultFontPixelWidth QGCLabel { @@ -81,10 +79,10 @@ Column { model: subEditConfig && subEditConfig.linkType === LinkConfiguration.TypeUdp ? subEditConfig.hostList : "" delegate: QGCButton { - text: modelData - width: _secondColumn + text: modelData + width: _secondColumn anchors.leftMargin: ScreenTools.defaultFontPixelWidth * 2 - exclusiveGroup: linkGroup + autoExclusive: true onClicked: { checked = true _udpSetting._currentHost = modelData