From 6f0229f450538496b63087ecb096c695596d9828 Mon Sep 17 00:00:00 2001 From: vladest Date: Tue, 22 Aug 2017 23:26:27 +0200 Subject: [PATCH] Reworked according to designers request. Do not fall back to default audion output --- .../resources/qml/controls-uit/CheckBox2.qml | 5 +- interface/resources/qml/hifi/audio/Audio.qml | 74 +++++++++++-------- .../qml/hifi/audio/AudioTabButton.qml | 1 + .../resources/qml/hifi/audio/CheckBox.qml | 1 + libraries/audio-client/src/AudioClient.cpp | 8 -- 5 files changed, 47 insertions(+), 42 deletions(-) diff --git a/interface/resources/qml/controls-uit/CheckBox2.qml b/interface/resources/qml/controls-uit/CheckBox2.qml index 7bd69f0b19..f845d24868 100644 --- a/interface/resources/qml/controls-uit/CheckBox2.qml +++ b/interface/resources/qml/controls-uit/CheckBox2.qml @@ -23,11 +23,12 @@ CheckBox { property string color: hifi.colors.lightGrayText readonly property bool isLightColorScheme: colorScheme === hifi.colorSchemes.light property bool isRedCheck: false + property bool isRound: false property int boxSize: 14 - property int boxRadius: 3 + property int boxRadius: isRound ? boxSize : 3 property bool wrap: true; readonly property int checkSize: Math.max(boxSize - 8, 10) - readonly property int checkRadius: 2 + readonly property int checkRadius: isRound ? checkSize / 2 : 2 focusPolicy: Qt.ClickFocus indicator: Rectangle { diff --git a/interface/resources/qml/hifi/audio/Audio.qml b/interface/resources/qml/hifi/audio/Audio.qml index dfecfbb50f..ed4a74b86f 100644 --- a/interface/resources/qml/hifi/audio/Audio.qml +++ b/interface/resources/qml/hifi/audio/Audio.qml @@ -37,6 +37,7 @@ Rectangle { } property bool isVR: Audio.context === "VR" + property real rightMostInputLevelPos: 0 //placeholder for control sizes and paddings //recalculates dynamically in case of UI size is changed QtObject { @@ -54,7 +55,7 @@ Rectangle { id: bar spacing: 0 width: parent.width - height: 36 + height: 42 AudioControls.AudioTabButton { height: parent.height @@ -68,21 +69,20 @@ Rectangle { Column { spacing: 12; - anchors.topMargin: 8 anchors.top: bar.bottom anchors.bottom: parent.bottom anchors.bottomMargin: 5 width: parent.width; + Separator { } + RalewayRegular { - x: margins.paddings; + x: margins.paddings + margins.sizeCheckBox; size: 16; color: "white"; - text: qsTr("Mic Settings") + text: qsTr("Input Device Settings") } - Separator { } - ColumnLayout { x: margins.paddings; // padding does not work spacing: 16; @@ -118,28 +118,27 @@ Rectangle { AvatarInputs.showAudioTools = checked; checked = Qt.binding(function() { return AvatarInputs.showAudioTools; }); // restore binding } + onXChanged: rightMostInputLevelPos = x + width } } } Separator {} - RowLayout { + Row { x: margins.paddings; width: parent.width - margins.paddings*2 height: 28 spacing: 0 HiFiGlyphs { - Layout.minimumWidth: margins.sizeCheckBox - Layout.maximumWidth: margins.sizeCheckBox + width: margins.sizeCheckBox text: hifi.glyphs.mic; color: hifi.colors.primaryHighlight; anchors.verticalCenter: parent.verticalCenter; - size: 36; + size: 30; } RalewayRegular { - Layout.minimumWidth: margins.sizeText + margins.sizeLevel - Layout.maximumWidth: margins.sizeText + margins.sizeLevel + width: margins.sizeText + margins.sizeLevel anchors.verticalCenter: parent.verticalCenter; size: 16; color: hifi.colors.lightGrayText; @@ -151,19 +150,22 @@ Rectangle { id: inputView width: parent.width - margins.paddings*2 x: margins.paddings - height: 145; + height: 150 spacing: 4; snapMode: ListView.SnapToItem; clip: true; model: Audio.devices.input; - delegate: RowLayout { - width: inputView.width; - spacing: 5 + delegate: Item { + width: rightMostInputLevelPos + height: margins.sizeCheckBox AudioControls.CheckBox { - Layout.fillWidth: true + anchors.left: parent.left + width: parent.width - inputLevel.width + clip: true checked: bar.currentIndex === 0 ? selectedDesktop : selectedHMD; - boxRadius: boxSize/2 + boxSize: margins.sizeCheckBox / 2 + isRound: true text: devicename onClicked: { if (checked) { @@ -172,6 +174,9 @@ Rectangle { } } InputLevel { + id: inputLevel + anchors.right: parent.right + anchors.verticalCenter: parent.verticalCenter visible: (bar.currentIndex === 1 && selectedHMD && isVR) || (bar.currentIndex === 0 && selectedDesktop && !isVR); } @@ -180,22 +185,20 @@ Rectangle { Separator {} - RowLayout { + Row { x: margins.paddings; width: parent.width - margins.paddings*2 - height: 28 + height: 36 spacing: 0 HiFiGlyphs { - Layout.minimumWidth: margins.sizeCheckBox - Layout.maximumWidth: margins.sizeCheckBox + width: margins.sizeCheckBox text: hifi.glyphs.unmuted; color: hifi.colors.primaryHighlight; anchors.verticalCenter: parent.verticalCenter; - size: 28; + size: 36; } RalewayRegular { - Layout.minimumWidth: margins.sizeText + margins.sizeLevel - Layout.maximumWidth: margins.sizeText + margins.sizeLevel + width: margins.sizeText + margins.sizeLevel anchors.verticalCenter: parent.verticalCenter; size: 16; color: hifi.colors.lightGrayText; @@ -207,18 +210,19 @@ Rectangle { id: outputView width: parent.width - margins.paddings*2 x: margins.paddings - height: Math.min(220, contentHeight); + height: Math.min(210, contentHeight); spacing: 4; snapMode: ListView.SnapToItem; clip: true; model: Audio.devices.output; - delegate: RowLayout { - width: outputView.width; - spacing: 0 + delegate: Item { + width: rightMostInputLevelPos + height: margins.sizeCheckBox AudioControls.CheckBox { - Layout.fillWidth: true - boxRadius: boxSize/2 + width: parent.width + boxSize: margins.sizeCheckBox / 2 + isRound: true checked: bar.currentIndex === 0 ? selectedDesktop : selectedHMD; text: devicename onClicked: { @@ -229,6 +233,12 @@ Rectangle { } } } - PlaySampleSound { anchors { left: parent.left; leftMargin: margins.paddings }} + PlaySampleSound { + x: margins.paddings + + visible: (bar.currentIndex === 1 && isVR) || + (bar.currentIndex === 0 && !isVR); + anchors { left: parent.left; leftMargin: margins.paddings } + } } } diff --git a/interface/resources/qml/hifi/audio/AudioTabButton.qml b/interface/resources/qml/hifi/audio/AudioTabButton.qml index bf50f1ba26..2e6e114039 100644 --- a/interface/resources/qml/hifi/audio/AudioTabButton.qml +++ b/interface/resources/qml/hifi/audio/AudioTabButton.qml @@ -16,6 +16,7 @@ import "../../styles-uit" TabButton { id: control + font.pixelSize: height / 2 HifiConstants { id: hifi; } diff --git a/interface/resources/qml/hifi/audio/CheckBox.qml b/interface/resources/qml/hifi/audio/CheckBox.qml index 77c001816f..806f08f439 100644 --- a/interface/resources/qml/hifi/audio/CheckBox.qml +++ b/interface/resources/qml/hifi/audio/CheckBox.qml @@ -14,5 +14,6 @@ import QtQuick 2.7 import "../../controls-uit" as HifiControls HifiControls.CheckBox2 { + spacing: 8 color: "white" } diff --git a/libraries/audio-client/src/AudioClient.cpp b/libraries/audio-client/src/AudioClient.cpp index 27bab687d5..b8f1bd876d 100644 --- a/libraries/audio-client/src/AudioClient.cpp +++ b/libraries/audio-client/src/AudioClient.cpp @@ -1717,14 +1717,6 @@ int AudioClient::setOutputBufferSize(int numFrames, bool persist) { if (persist) { _outputBufferSizeFrames.set(numFrames); } - - if (_audioOutput) { - // The buffer size can't be adjusted after QAudioOutput::start() has been called, so - // recreate the device by switching to the default. - QAudioDeviceInfo outputDeviceInfo = defaultAudioDeviceForMode(QAudio::AudioOutput); - qCDebug(audioclient) << __FUNCTION__ << "about to send changeDevice signal outputDeviceInfo: [" << outputDeviceInfo.deviceName() << "]"; - emit changeDevice(outputDeviceInfo); // On correct thread, please, as setOutputBufferSize can be called from main thread. - } } return numFrames; }