From 083e85cf59d190c27e87038b2811a75ef4b30958 Mon Sep 17 00:00:00 2001 From: Vasily Date: Fri, 1 Feb 2019 20:15:51 +0100 Subject: [PATCH] Refactor profile buttons and popups The popups have been moved inside the scope of the ProfileButtons. Since the popups open based on the location of their parents, they are currently opening underneath where they used to open. Since the profiles and ptt settings do not work anyway, this is seen as acceptable. --- advancedSettings.pro | 3 + src/res/qml/audio_page/AudioPage.qml | 180 +---------------- .../audio_page/profiles/ProfileButtons.qml | 185 ++++++++++++++++++ 3 files changed, 190 insertions(+), 178 deletions(-) create mode 100644 src/res/qml/audio_page/profiles/ProfileButtons.qml diff --git a/advancedSettings.pro b/advancedSettings.pro index 6cf56d6..2987a38 100644 --- a/advancedSettings.pro +++ b/advancedSettings.pro @@ -166,3 +166,6 @@ DISTFILES += \ src/res/qml/utilities_page/alarm_clock/* \ src/res/qml/audio_page/dialog_boxes/* \ src/res/qml/audio_page/device_selector/* + src/res/qml/audio_page/proximity/* + src/res/qml/audio_page/push_to_talk/* + src/res/qml/audio_page/profiles/* diff --git a/src/res/qml/audio_page/AudioPage.qml b/src/res/qml/audio_page/AudioPage.qml index a54af80..dbec66b 100644 --- a/src/res/qml/audio_page/AudioPage.qml +++ b/src/res/qml/audio_page/AudioPage.qml @@ -3,35 +3,15 @@ import QtQuick.Controls 2.0 import QtQuick.Layouts 1.3 import matzman666.advsettings 1.0 import ".." //common imports -import "dialog_boxes" import "device_selector" import "proximity" import "push_to_talk" +import "profiles" MyStackViewPage { width: 1200 headerText: "Audio Settings" - AudioMessageDialog { - id: audioMessageDialog - } - - PttDeleteProfileDialog { - id: pttDeleteProfileDialog - } - - AudioDeleteProfileDialog { - id: audioDeleteProfileDialog - } - - PttNewProfileDialog { - id: pttNewProfileDialog - } - - AudioNewProfileDialog { - id: audioNewProfileDialog - } - content: ColumnLayout { spacing: 24 @@ -49,164 +29,8 @@ MyStackViewPage { } PttButtons { } - - RowLayout { - spacing: 10 - - MyText { - Layout.preferredWidth: 150 - text: "Audio Profile:" - - } - - MyComboBox { - id: audioProfileComboBox - Layout.preferredWidth: 250 - model: [""] - onCurrentIndexChanged: { - if (currentIndex > 0) { - audioApplyProfileButton.enabled = true - audioDeleteProfileButton.enabled = true - } else { - audioApplyProfileButton.enabled = false - audioDeleteProfileButton.enabled = false - } - } - } - - MyPushButton { - id: audioApplyProfileButton - enabled: true - Layout.preferredWidth: 150 - text: "Apply" - onClicked: { - if (audioProfileComboBox.currentIndex > 0) { - AudioTabController.applyAudioProfile(audioProfileComboBox.currentIndex - 1) - } - } - } - - MyText { - text: "PTT Profile:" - Layout.preferredWidth: 150 - } - - MyComboBox { - id: pttProfileComboBox - Layout.preferredWidth: 250 - model: [""] - onCurrentIndexChanged: { - if (currentIndex > 0) { - pttApplyProfileButton.enabled = true - pttDeleteProfileButton.enabled = true - } else { - pttApplyProfileButton.enabled = false - pttDeleteProfileButton.enabled = false - } - } - } - - MyPushButton { - id: pttApplyProfileButton - enabled: true - Layout.preferredWidth: 150 - text: "Apply" - onClicked: { - if (pttProfileComboBox.currentIndex > 0) { - AudioTabController.applyPttProfile(pttProfileComboBox.currentIndex - 1) - } - } - } - } - RowLayout { - spacing: 18 - - MyPushButton { - id: audioDeleteProfileButton - enabled: true - Layout.preferredWidth: 200 - text: "Delete Profile" - onClicked: { - if (audioProfileComboBox.currentIndex > 0) { - audioDeleteProfileDialog.profileIndex = audioProfileComboBox.currentIndex - 1 - audioDeleteProfileDialog.open() - } - } - } - MyPushButton { - Layout.preferredWidth: 200 - text: "New Profile" - onClicked: { - audioNewProfileDialog.openPopup() - } - } - Item { - Layout.fillWidth: true - } - MyPushButton { - id: pttDeleteProfileButton - enabled: true - Layout.preferredWidth: 200 - text: "Delete Profile" - onClicked: { - if (pttProfileComboBox.currentIndex > 0) { - pttDeleteProfileDialog.profileIndex = pttProfileComboBox.currentIndex - 1 - pttDeleteProfileDialog.open() - } - } - } - MyPushButton { - Layout.preferredWidth: 200 - text: "New Profile" - onClicked: { - pttNewProfileDialog.openPopup() - } + ProfileButtons { } } - } - - Component.onCompleted: { - reloadPttProfiles() - reloadAudioProfiles() - } - - Connections { - target: AudioTabController - onPttProfilesUpdated: { - reloadPttProfiles() - } - onAudioProfilesUpdated: { - reloadAudioProfiles() - } - onAudioProfileAdded:{ - audioProfileComboBox.currentIndex = AudioTabController.getAudioProfileCount() - } - onPttProfileAdded:{ - pttProfileComboBox.currentIndex = AudioTabController.getPttProfileCount() - } - onDefaultProfileDisplay:{ - audioProfileComboBox.currentIndex = AudioTabController.getDefaultAudioProfileIndex() + 1 - } - } - } - - function reloadPttProfiles() { - var profiles = [""] - var profileCount = AudioTabController.getPttProfileCount() - for (var i = 0; i < profileCount; i++) { - profiles.push(AudioTabController.getPttProfileName(i)) - } - pttProfileComboBox.currentIndex = 0 - pttProfileComboBox.model = profiles - } - - function reloadAudioProfiles(){ - var profiles = [""] - var profileCount = AudioTabController.getAudioProfileCount() - for (var i = 0; i < profileCount; i++) { - profiles.push(AudioTabController.getAudioProfileName(i)) - } - audioProfileComboBox.currentIndex = 0; - audioProfileComboBox.model = profiles } } diff --git a/src/res/qml/audio_page/profiles/ProfileButtons.qml b/src/res/qml/audio_page/profiles/ProfileButtons.qml new file mode 100644 index 0000000..87c6cae --- /dev/null +++ b/src/res/qml/audio_page/profiles/ProfileButtons.qml @@ -0,0 +1,185 @@ +import QtQuick 2.7 +import QtQuick.Controls 2.0 +import QtQuick.Layouts 1.3 +import matzman666.advsettings 1.0 +import "../.." //common imports +import "../dialog_boxes" + +ColumnLayout { + AudioMessageDialog { + id: audioMessageDialog + } + + PttDeleteProfileDialog { + id: pttDeleteProfileDialog + } + + AudioDeleteProfileDialog { + id: audioDeleteProfileDialog + } + + PttNewProfileDialog { + id: pttNewProfileDialog + } + + AudioNewProfileDialog { + id: audioNewProfileDialog + } + + RowLayout { + spacing: 10 + + MyText { + Layout.preferredWidth: 150 + text: "Audio Profile:" + } + + MyComboBox { + id: audioProfileComboBox + Layout.preferredWidth: 250 + model: [""] + onCurrentIndexChanged: { + if (currentIndex > 0) { + audioApplyProfileButton.enabled = true + audioDeleteProfileButton.enabled = true + } else { + audioApplyProfileButton.enabled = false + audioDeleteProfileButton.enabled = false + } + } + } + + MyPushButton { + id: audioApplyProfileButton + enabled: true + Layout.preferredWidth: 150 + text: "Apply" + onClicked: { + if (audioProfileComboBox.currentIndex > 0) { + AudioTabController.applyAudioProfile( + audioProfileComboBox.currentIndex - 1) + } + } + } + + MyText { + text: "PTT Profile:" + Layout.preferredWidth: 150 + } + + MyComboBox { + id: pttProfileComboBox + Layout.preferredWidth: 250 + model: [""] + onCurrentIndexChanged: { + if (currentIndex > 0) { + pttApplyProfileButton.enabled = true + pttDeleteProfileButton.enabled = true + } else { + pttApplyProfileButton.enabled = false + pttDeleteProfileButton.enabled = false + } + } + } + + MyPushButton { + id: pttApplyProfileButton + enabled: true + Layout.preferredWidth: 150 + text: "Apply" + onClicked: { + if (pttProfileComboBox.currentIndex > 0) { + AudioTabController.applyPttProfile( + pttProfileComboBox.currentIndex - 1) + } + } + } + } + RowLayout { + spacing: 18 + + MyPushButton { + id: audioDeleteProfileButton + enabled: true + Layout.preferredWidth: 200 + text: "Delete Profile" + onClicked: { + if (audioProfileComboBox.currentIndex > 0) { + audioDeleteProfileDialog.profileIndex = audioProfileComboBox.currentIndex - 1 + audioDeleteProfileDialog.open() + } + } + } + MyPushButton { + Layout.preferredWidth: 200 + text: "New Profile" + onClicked: { + audioNewProfileDialog.openPopup() + } + } + Item { + Layout.fillWidth: true + } + MyPushButton { + id: pttDeleteProfileButton + enabled: true + Layout.preferredWidth: 200 + text: "Delete Profile" + onClicked: { + if (pttProfileComboBox.currentIndex > 0) { + pttDeleteProfileDialog.profileIndex = pttProfileComboBox.currentIndex - 1 + pttDeleteProfileDialog.open() + } + } + } + MyPushButton { + Layout.preferredWidth: 200 + text: "New Profile" + onClicked: { + pttNewProfileDialog.openPopup() + } + } + } + Component.onCompleted: { + reloadPttProfiles() + reloadAudioProfiles() + } + Connections { + target: AudioTabController + onPttProfilesUpdated: { + reloadPttProfiles() + } + onAudioProfilesUpdated: { + reloadAudioProfiles() + } + onAudioProfileAdded: { + audioProfileComboBox.currentIndex = AudioTabController.getAudioProfileCount() + } + onPttProfileAdded: { + pttProfileComboBox.currentIndex = AudioTabController.getPttProfileCount() + } + onDefaultProfileDisplay: { + audioProfileComboBox.currentIndex = AudioTabController.getDefaultAudioProfileIndex( + ) + 1 + } + } + function reloadPttProfiles() { + var profiles = [""] + var profileCount = AudioTabController.getPttProfileCount() + for (var i = 0; i < profileCount; i++) { + profiles.push(AudioTabController.getPttProfileName(i)) + } + pttProfileComboBox.currentIndex = 0 + pttProfileComboBox.model = profiles + } + + function reloadAudioProfiles() { + var profiles = [""] + var profileCount = AudioTabController.getAudioProfileCount() + for (var i = 0; i < profileCount; i++) { + profiles.push(AudioTabController.getAudioProfileName(i)) + } + audioProfileComboBox.currentIndex = 0 + audioProfileComboBox.model = profiles + } +}