Refactor audioMicNameCombo
This commit is contained in:
@@ -46,26 +46,13 @@ MyStackViewPage {
|
||||
}
|
||||
|
||||
MirrorVolumeSlider {
|
||||
id: audioMirrorNameCombo
|
||||
}
|
||||
|
||||
ColumnLayout {
|
||||
spacing: 18
|
||||
RowLayout {
|
||||
MyText {
|
||||
text: "Microphone: "
|
||||
Layout.preferredWidth: 260
|
||||
}
|
||||
MyComboBox {
|
||||
id: audioMicNameCombo
|
||||
Layout.maximumWidth: 850
|
||||
Layout.minimumWidth: 850
|
||||
Layout.preferredWidth: 850
|
||||
onActivated: {
|
||||
if (componentCompleted) {
|
||||
AudioTabController.setMicDeviceIndex(currentIndex)
|
||||
}
|
||||
}
|
||||
}
|
||||
MicDeviceSelector {
|
||||
id: audioMicNameCombo
|
||||
}
|
||||
RowLayout {
|
||||
MyText {
|
||||
@@ -129,6 +116,7 @@ MyStackViewPage {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MyToggleButton {
|
||||
id: audioMuteProximitySensorToggle
|
||||
Layout.preferredWidth: 600
|
||||
@@ -311,15 +299,7 @@ MyStackViewPage {
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
var devs3 = []
|
||||
var micDeviceCount = AudioTabController.getRecordingDeviceCount()
|
||||
for (var i = 0; i < micDeviceCount; i++) {
|
||||
var name = AudioTabController.getRecordingDeviceName(i)
|
||||
devs3.push(name)
|
||||
}
|
||||
audioMicNameCombo.model = devs3
|
||||
if (AudioTabController.micDeviceIndex < 0) {
|
||||
audioMicNameCombo.currentIndex = 0
|
||||
audioMicVolumeMinusButton.enabled = false
|
||||
audioMicVolumeSlider.enabled = false
|
||||
audioMicVolumePlusButton.enabled = false
|
||||
@@ -334,7 +314,6 @@ MyStackViewPage {
|
||||
audioMicVolumeSlider.value = AudioTabController.micVolume
|
||||
audioMicMuteToggle.checked = AudioTabController.micMuted
|
||||
audioMuteProximitySensorToggle.checked = AudioTabController.micProximitySensorCanMute
|
||||
audioMicNameCombo.currentIndex = AudioTabController.micDeviceIndex
|
||||
}
|
||||
|
||||
|
||||
@@ -352,7 +331,6 @@ MyStackViewPage {
|
||||
target: AudioTabController
|
||||
onMicDeviceIndexChanged: {
|
||||
if (index < 0) {
|
||||
audioMicNameCombo.currentIndex = 0
|
||||
audioMicVolumeMinusButton.enabled = false
|
||||
audioMicVolumeSlider.enabled = false
|
||||
audioMicVolumePlusButton.enabled = false
|
||||
@@ -362,7 +340,6 @@ MyStackViewPage {
|
||||
audioMicVolumeSlider.enabled = true
|
||||
audioMicVolumePlusButton.enabled = true
|
||||
audioMicMuteToggle.enabled = true
|
||||
audioMicNameCombo.currentIndex = index
|
||||
}
|
||||
}
|
||||
onMicVolumeChanged: {
|
||||
@@ -431,15 +408,7 @@ MyStackViewPage {
|
||||
}
|
||||
}
|
||||
onRecordingDeviceListChanged: {
|
||||
var devs3 = []
|
||||
var micDeviceCount = AudioTabController.getRecordingDeviceCount()
|
||||
for (var i = 0; i < micDeviceCount; i++) {
|
||||
var name = AudioTabController.getRecordingDeviceName(i)
|
||||
devs3.push(name)
|
||||
}
|
||||
audioMicNameCombo.model = devs3
|
||||
if (AudioTabController.micDeviceIndex < 0) {
|
||||
audioMicNameCombo.currentIndex = 0
|
||||
audioMicVolumeMinusButton.enabled = false
|
||||
audioMicVolumeSlider.enabled = false
|
||||
audioMicVolumePlusButton.enabled = false
|
||||
@@ -451,7 +420,6 @@ MyStackViewPage {
|
||||
audioMicMuteToggle.enabled = true
|
||||
audioMicVolumeSlider.value = AudioTabController.micVolume
|
||||
audioMicMuteToggle.checked = AudioTabController.micMuted
|
||||
audioMicNameCombo.currentIndex = AudioTabController.micDeviceIndex
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
import QtQuick 2.7
|
||||
import QtQuick.Controls 2.0
|
||||
import QtQuick.Layouts 1.3
|
||||
import matzman666.advsettings 1.0
|
||||
import "../.." //common imports
|
||||
|
||||
RowLayout {
|
||||
id: audioMicNameCombo
|
||||
property string deviceText: "Microphone: "
|
||||
|
||||
// The entries in the dropdown box.
|
||||
property alias devices: selector.model
|
||||
// The current index of the chosen device.
|
||||
// Add one for use in the dropdown box because of the "None" entry.
|
||||
property alias deviceIndex: selector.currentIndex
|
||||
MyText {
|
||||
text: deviceText
|
||||
Layout.preferredWidth: 260
|
||||
}
|
||||
MyComboBox {
|
||||
id: selector
|
||||
Layout.maximumWidth: 850
|
||||
Layout.minimumWidth: 850
|
||||
Layout.preferredWidth: 850
|
||||
onActivated: {
|
||||
if (componentCompleted) {
|
||||
AudioTabController.setMicDeviceIndex(currentIndex)
|
||||
}
|
||||
}
|
||||
}
|
||||
function getAudioDeviceList() {
|
||||
var devices = []
|
||||
var playbackDevicesCount = AudioTabController.getRecordingDeviceCount()
|
||||
for (var i = 0; i < playbackDevicesCount; i++) {
|
||||
var deviceName = AudioTabController.getRecordingDeviceName(i)
|
||||
devices.push(deviceName)
|
||||
}
|
||||
// Setting the model zeroes out the
|
||||
// index so we need to set devices first.
|
||||
return devices
|
||||
}
|
||||
function setShownAudioDevice(index) {
|
||||
if (index < 0) {
|
||||
deviceIndex = 0
|
||||
}
|
||||
else {
|
||||
deviceIndex = index
|
||||
}
|
||||
}
|
||||
Component.onCompleted: {
|
||||
devices = getAudioDeviceList()
|
||||
setShownAudioDevice(AudioTabController.micDeviceIndex)
|
||||
}
|
||||
Connections {
|
||||
target: AudioTabController
|
||||
onMicDeviceIndexChanged: {
|
||||
setShownAudioDevice(index)
|
||||
}
|
||||
onRecordingDeviceListChanged: {
|
||||
devices = getAudioDeviceList()
|
||||
setShownAudioDevice(AudioTabController.micDeviceIndex)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user