From b810be3eb825e884f08986eec3b9953853498a1c Mon Sep 17 00:00:00 2001 From: Vasily Date: Fri, 1 Feb 2019 19:28:18 +0100 Subject: [PATCH] Refactor PTT buttons into separate file The PttControllerConfigDialog was not used by anything else, hence it makes sense to move it into a more limited scope. The PttControllerConfigDialog file itself is only used by AudioPage and AccessibilityPage. Since the AccessibilityPage is going to be removed the PttControllerConfigDialog should be moved into the audio_page folder. --- src/res/qml/audio_page/AudioPage.qml | 57 +--------------- .../audio_page/push_to_talk/PttButtons.qml | 68 +++++++++++++++++++ 2 files changed, 70 insertions(+), 55 deletions(-) create mode 100644 src/res/qml/audio_page/push_to_talk/PttButtons.qml diff --git a/src/res/qml/audio_page/AudioPage.qml b/src/res/qml/audio_page/AudioPage.qml index 25f499e..1626c31 100644 --- a/src/res/qml/audio_page/AudioPage.qml +++ b/src/res/qml/audio_page/AudioPage.qml @@ -6,6 +6,7 @@ import ".." //common imports import "dialog_boxes" import "device_selector" import "proximity" +import "push_to_talk" MyStackViewPage { width: 1200 @@ -23,11 +24,6 @@ MyStackViewPage { id: audioDeleteProfileDialog } - PttControllerConfigDialog { - id: pttControllerConfigDialog - pttControllerConfigClass: AudioTabController - } - PttNewProfileDialog { id: pttNewProfileDialog } @@ -51,44 +47,7 @@ MyStackViewPage { spacing: 18 ProximityToggle { } - RowLayout { - MyToggleButton { - id: audioPttEnabledToggle - Layout.preferredWidth: 260 - text: "Push-to-Talk:" - onClicked: { - AudioTabController.pttEnabled = checked - } - } - MyToggleButton { - id: audioPttLeftControllerToggle - text: "Left Controller" - onClicked: { - AudioTabController.setPttLeftControllerEnabled(checked, false) - } - } - MyPushButton { - text: "Configure" - onClicked: { - pttControllerConfigDialog.openPopup(0) - } - } - Item { - Layout.fillWidth: true - } - MyToggleButton { - id: audioPttRightControllerToggle - text: "Right Controller" - onClicked: { - AudioTabController.setPttRightControllerEnabled(checked, false) - } - } - MyPushButton { - text: "Configure" - onClicked: { - pttControllerConfigDialog.openPopup(1) - } - } + PttButtons { } RowLayout { @@ -227,9 +186,6 @@ MyStackViewPage { Component.onCompleted: { reloadPttProfiles() reloadAudioProfiles() - audioPttEnabledToggle.checked = AudioTabController.pttEnabled - audioPttLeftControllerToggle.checked = AudioTabController.pttLeftControllerEnabled - audioPttRightControllerToggle.checked = AudioTabController.pttRightControllerEnabled audioPttShowNotificationToggle.checked = AudioTabController.pttShowNotification audioPttReverseToggle.checked = AudioTabController.micReversePtt } @@ -239,18 +195,9 @@ MyStackViewPage { onMicReversePttChanged: { audioPttReverseToggle.checked = AudioTabController.micReversePtt } - onPttEnabledChanged: { - audioPttEnabledToggle.checked = AudioTabController.pttEnabled - } onPttShowNotificationChanged: { audioPttShowNotificationToggle.checked = AudioTabController.pttShowNotification } - onPttLeftControllerEnabledChanged: { - audioPttLeftControllerToggle.checked = AudioTabController.pttLeftControllerEnabled - } - onPttRightControllerEnabledChanged: { - audioPttRightControllerToggle.checked = AudioTabController.pttRightControllerEnabled - } onPttProfilesUpdated: { reloadPttProfiles() } diff --git a/src/res/qml/audio_page/push_to_talk/PttButtons.qml b/src/res/qml/audio_page/push_to_talk/PttButtons.qml new file mode 100644 index 0000000..bc936b7 --- /dev/null +++ b/src/res/qml/audio_page/push_to_talk/PttButtons.qml @@ -0,0 +1,68 @@ +import QtQuick 2.7 +import QtQuick.Controls 2.0 +import QtQuick.Layouts 1.3 +import matzman666.advsettings 1.0 +import "../.." //common imports + +RowLayout { + PttControllerConfigDialog { + id: pttControllerConfigDialog + pttControllerConfigClass: AudioTabController + } + + MyToggleButton { + id: audioPttEnabledToggle + Layout.preferredWidth: 260 + text: "Push-to-Talk:" + onClicked: { + AudioTabController.pttEnabled = checked + } + } + MyToggleButton { + id: audioPttLeftControllerToggle + text: "Left Controller" + onClicked: { + AudioTabController.setPttLeftControllerEnabled(checked, false) + } + } + MyPushButton { + text: "Configure" + onClicked: { + pttControllerConfigDialog.openPopup(0) + } + } + Item { + Layout.fillWidth: true + } + MyToggleButton { + id: audioPttRightControllerToggle + text: "Right Controller" + onClicked: { + AudioTabController.setPttRightControllerEnabled(checked, false) + } + } + MyPushButton { + text: "Configure" + onClicked: { + pttControllerConfigDialog.openPopup(1) + } + } + Component.onCompleted: { + audioPttEnabledToggle.checked = AudioTabController.pttEnabled + audioPttLeftControllerToggle.checked = AudioTabController.pttLeftControllerEnabled + audioPttRightControllerToggle.checked = AudioTabController.pttRightControllerEnabled + + } + Connections { + target: AudioTabController + onPttEnabledChanged: { + audioPttEnabledToggle.checked = AudioTabController.pttEnabled + } + onPttLeftControllerEnabledChanged: { + audioPttLeftControllerToggle.checked = AudioTabController.pttLeftControllerEnabled + } + onPttRightControllerEnabledChanged: { + audioPttRightControllerToggle.checked = AudioTabController.pttRightControllerEnabled + } + } +}