From 560696e41c20294c12029b2635345e0f37c597d1 Mon Sep 17 00:00:00 2001 From: vladest Date: Fri, 11 Aug 2017 20:39:17 +0200 Subject: [PATCH 01/14] Split logic and interface for HMD and desktop devices. Added CheckBox control based on QQC2 --- .../resources/qml/controls-uit/CheckBox2.qml | 111 +++++++++ interface/resources/qml/hifi/audio/Audio.qml | 234 +++++++++++++----- .../resources/qml/hifi/audio/CheckBox.qml | 4 +- interface/src/scripting/Audio.cpp | 8 +- interface/src/scripting/Audio.h | 4 +- interface/src/scripting/AudioDevices.cpp | 161 ++++++++---- interface/src/scripting/AudioDevices.h | 28 ++- 7 files changed, 436 insertions(+), 114 deletions(-) create mode 100644 interface/resources/qml/controls-uit/CheckBox2.qml diff --git a/interface/resources/qml/controls-uit/CheckBox2.qml b/interface/resources/qml/controls-uit/CheckBox2.qml new file mode 100644 index 0000000000..612e8d2662 --- /dev/null +++ b/interface/resources/qml/controls-uit/CheckBox2.qml @@ -0,0 +1,111 @@ +// +// CheckBox2.qml +// +// Created by Vlad Stelmahovsky on 10 Aug 2017 +// Copyright 2017 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +import QtQuick 2.7 +import QtQuick.Controls 2.2 + +import "../styles-uit" +import "../controls-uit" as HiFiControls + +CheckBox { + id: checkBox + + HifiConstants { id: hifi; } + + property int colorScheme: hifi.colorSchemes.light + property string color: hifi.colors.lightGrayText + readonly property bool isLightColorScheme: colorScheme === hifi.colorSchemes.light + property bool isRedCheck: false + property int boxSize: 14 + property int boxRadius: 3 + property bool wrap: true; + readonly property int checkSize: Math.max(boxSize - 8, 10) + readonly property int checkRadius: 2 + focusPolicy: Qt.ClickFocus + + indicator: Rectangle { + id: box + width: boxSize + height: boxSize + radius: boxRadius + x: checkBox.leftPadding + y: parent.height / 2 - height / 2 + border.width: 1 + border.color: pressed || hovered + ? hifi.colors.checkboxCheckedBorder + : (checkBox.isLightColorScheme ? hifi.colors.checkboxLightFinish : hifi.colors.checkboxDarkFinish) + + gradient: Gradient { + GradientStop { + position: 0.2 + color: pressed || hovered + ? (checkBox.isLightColorScheme ? hifi.colors.checkboxChecked : hifi.colors.checkboxLightStart) + : (checkBox.isLightColorScheme ? hifi.colors.checkboxLightStart : hifi.colors.checkboxDarkStart) + } + GradientStop { + position: 1.0 + color: pressed || hovered + ? (checkBox.isLightColorScheme ? hifi.colors.checkboxChecked : hifi.colors.checkboxLightFinish) + : (checkBox.isLightColorScheme ? hifi.colors.checkboxLightFinish : hifi.colors.checkboxDarkFinish) + } + } + + Rectangle { + visible: pressed || hovered + anchors.centerIn: parent + id: innerBox + width: checkSize - 4 + height: width + radius: checkRadius + color: hifi.colors.checkboxCheckedBorder + } + + Rectangle { + id: check + width: checkSize + height: checkSize + radius: checkRadius + anchors.centerIn: parent + color: isRedCheck ? hifi.colors.checkboxCheckedRed : hifi.colors.checkboxChecked + border.width: 2 + border.color: isRedCheck? hifi.colors.checkboxCheckedBorderRed : hifi.colors.checkboxCheckedBorder + visible: checked && !pressed || !checked && pressed + } + + Rectangle { + id: disabledOverlay + visible: !enabled + width: boxSize + height: boxSize + radius: boxRadius + border.width: 1 + border.color: hifi.colors.baseGrayHighlight + color: hifi.colors.baseGrayHighlight + opacity: 0.5 + } + } + + contentItem: Text { + id: root + FontLoader { id: ralewaySemiBold; source: pathToFonts + "fonts/Raleway-SemiBold.ttf"; } + font.pixelSize: hifi.fontSizes.inputLabel + font.family: ralewaySemiBold.name + text: checkBox.text + color: checkBox.color + x: 2 + wrapMode: checkBox.wrap ? Text.Wrap : Text.NoWrap + elide: checkBox.wrap ? Text.ElideNone : Text.ElideRight + enabled: checkBox.enabled + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + leftPadding: checkBox.indicator.width + checkBox.spacing + } +} + diff --git a/interface/resources/qml/hifi/audio/Audio.qml b/interface/resources/qml/hifi/audio/Audio.qml index 93742e39a5..3d3a9ceeaa 100644 --- a/interface/resources/qml/hifi/audio/Audio.qml +++ b/interface/resources/qml/hifi/audio/Audio.qml @@ -12,7 +12,7 @@ // import QtQuick 2.5 -import QtQuick.Controls 1.4 +import QtQuick.Controls 2.2 import QtQuick.Layouts 1.3 import "../../styles-uit" @@ -36,13 +36,27 @@ Rectangle { return (root.parent !== null) && root.parent.objectName == "loader"; } + property bool isVR: Audio.context === "VR" + //placeholder for control sizes and paddings + //recalculates dynamically in case of UI size is changed + QtObject { + id: margins + property real paddings: parent.width / 20.25 + + property real sizeCheckBox: parent.width / 13.5 + property real sizeText: parent.width / 2.5 + property real sizeLevel: parent.width / 5.8 + property real sizeDesktop: parent.width / 5.8 + property real sizeVR: parent.width / 13.5 + } + Column { y: 16; // padding does not work spacing: 16; width: parent.width; RalewayRegular { - x: 16; // padding does not work + x: margins.paddings; // padding does not work size: 16; color: "white"; text: root.title; @@ -53,8 +67,9 @@ Rectangle { Separator { visible: root.showTitle() } ColumnLayout { - x: 16; // padding does not work + x: margins.paddings; // padding does not work spacing: 16; + width: parent.width; // mute is in its own row RowLayout { @@ -93,52 +108,106 @@ Rectangle { Separator {} RowLayout { + x: margins.paddings; + width: parent.width - margins.paddings*2 + height: 28 + spacing: 0 HiFiGlyphs { + Layout.minimumWidth: margins.sizeCheckBox + Layout.maximumWidth: margins.sizeCheckBox text: hifi.glyphs.mic; 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 anchors.verticalCenter: parent.verticalCenter; size: 16; color: hifi.colors.lightGrayText; text: qsTr("CHOOSE INPUT DEVICE"); } + + RalewayRegular { + Layout.minimumWidth: margins.sizeDesktop + Layout.maximumWidth: margins.sizeDesktop + anchors.verticalCenter: parent.verticalCenter; + size: 16; + color: hifi.colors.lightGrayText; + text: qsTr("DESKTOP"); + } + + RalewayRegular { + Layout.minimumWidth: margins.sizeVR + Layout.maximumWidth: margins.sizeVR + Layout.alignment: Qt.AlignRight + anchors.verticalCenter: parent.verticalCenter; + size: 16; + color: hifi.colors.lightGrayText; + text: qsTr("VR"); + } } ListView { - anchors { left: parent.left; right: parent.right; leftMargin: 70 } + id: inputView + width: parent.width - margins.paddings*2 + x: margins.paddings height: 125; spacing: 0; snapMode: ListView.SnapToItem; clip: true; model: Audio.devices.input; - delegate: Item { - width: parent.width; + delegate: RowLayout { + width: inputView.width; height: 36; - + spacing: 0 + + RalewaySemiBold { + Layout.minimumWidth: margins.sizeCheckBox + margins.sizeText + Layout.maximumWidth: margins.sizeCheckBox + margins.sizeText + Layout.alignment: Qt.AlignVCenter + clip: true + size: 16; + color: "white"; + text: devicename; + } + + //placeholder for invisible level + Item { + Layout.minimumWidth: margins.sizeLevel + Layout.maximumWidth: margins.sizeLevel + Layout.alignment: Qt.AlignVCenter + height: 8; + InputLevel { + visible: (isVR && selectedHMD) || (!isVR && selectedDesktop); + anchors.fill: parent + } + } AudioControls.CheckBox { - id: checkbox - anchors.verticalCenter: parent.verticalCenter - anchors.left: parent.left - text: display; - wrap: false; - checked: selected; - enabled: false; + Layout.minimumWidth: margins.sizeDesktop + Layout.maximumWidth: margins.sizeDesktop + leftPadding: margins.sizeDesktop - implicitWidth/2 + Layout.alignment: Qt.AlignCenter + checked: selectedDesktop; + onClicked: { + if (checked) { + Audio.setInputDevice(info, false); + } + } } - MouseArea { - anchors.fill: checkbox - onClicked: Audio.setInputDevice(info); - } - - InputLevel { - id: level; - anchors.verticalCenter: parent.verticalCenter - anchors.right: parent.right - anchors.rightMargin: 30 - visible: selected; + AudioControls.CheckBox { + Layout.minimumWidth: margins.sizeVR + Layout.maximumWidth: margins.sizeVR + Layout.alignment: Qt.AlignCenter + leftPadding: margins.sizeVR - implicitWidth/2 + checked: selectedHMD; + onClicked: { + if (checked) { + Audio.setInputDevice(info, true); + } + } } } } @@ -146,51 +215,104 @@ Rectangle { Separator {} RowLayout { - Column { - RowLayout { - HiFiGlyphs { - text: hifi.glyphs.unmuted; - color: hifi.colors.primaryHighlight; - anchors.verticalCenter: parent.verticalCenter; - size: 36; - } - RalewayRegular { - anchors.verticalCenter: parent.verticalCenter; - size: 16; - color: hifi.colors.lightGrayText; - text: qsTr("CHOOSE OUTPUT DEVICE"); - } - } + x: margins.paddings; + width: parent.width - margins.paddings*2 + height: 28 + spacing: 0 + HiFiGlyphs { + Layout.minimumWidth: margins.sizeCheckBox + Layout.maximumWidth: margins.sizeCheckBox + text: hifi.glyphs.unmuted; + color: hifi.colors.primaryHighlight; + anchors.verticalCenter: parent.verticalCenter; + size: 28; + } + RalewayRegular { + Layout.minimumWidth: margins.sizeText + margins.sizeLevel + Layout.maximumWidth: margins.sizeText + margins.sizeLevel + anchors.verticalCenter: parent.verticalCenter; + size: 16; + color: hifi.colors.lightGrayText; + text: qsTr("CHOOSE OUTPUT DEVICE"); + } - PlaySampleSound { anchors { left: parent.left; leftMargin: 60 }} + RalewayRegular { + Layout.minimumWidth: margins.sizeDesktop + Layout.maximumWidth: margins.sizeDesktop + anchors.verticalCenter: parent.verticalCenter; + size: 16; + color: hifi.colors.lightGrayText; + text: qsTr("DESKTOP"); + } + + RalewayRegular { + Layout.minimumWidth: margins.sizeVR + Layout.maximumWidth: margins.sizeVR + Layout.alignment: Qt.AlignRight + anchors.verticalCenter: parent.verticalCenter; + size: 16; + color: hifi.colors.lightGrayText; + text: qsTr("VR"); } } ListView { - anchors { left: parent.left; right: parent.right; leftMargin: 70 } - height: Math.min(250, contentHeight); + id: outputView + width: parent.width - margins.paddings*2 + x: margins.paddings + height: Math.min(220, contentHeight); spacing: 0; snapMode: ListView.SnapToItem; clip: true; model: Audio.devices.output; - delegate: Item { - width: parent.width; + delegate: RowLayout { + width: inputView.width; height: 36; + spacing: 0 - AudioControls.CheckBox { - id: checkbox - anchors.verticalCenter: parent.verticalCenter - anchors.left: parent.left - text: display; - checked: selected; - enabled: false; + RalewaySemiBold { + Layout.minimumWidth: margins.sizeCheckBox + margins.sizeText + Layout.maximumWidth: margins.sizeCheckBox + margins.sizeText + Layout.alignment: Qt.AlignVCenter + clip: true + size: 16; + color: "white"; + text: devicename; } - MouseArea { - anchors.fill: checkbox - onClicked: Audio.setOutputDevice(info); + //placeholder for invisible level + Item { + Layout.minimumWidth: margins.sizeLevel + Layout.maximumWidth: margins.sizeLevel + Layout.alignment: Qt.AlignVCenter + height: 8; + } + AudioControls.CheckBox { + Layout.minimumWidth: margins.sizeDesktop + Layout.maximumWidth: margins.sizeDesktop + leftPadding: margins.sizeDesktop - implicitWidth/2 + Layout.alignment: Qt.AlignCenter + checked: selectedDesktop; + onClicked: { + if (checked) { + Audio.setOutputDevice(info, false); + } + } + } + AudioControls.CheckBox { + Layout.minimumWidth: margins.sizeVR + Layout.maximumWidth: margins.sizeVR + Layout.alignment: Qt.AlignCenter + leftPadding: margins.sizeVR - implicitWidth/2 + checked: selectedHMD; + onClicked: { + if (checked) { + Audio.setOutputDevice(info, true); + } + } } } } + PlaySampleSound { anchors { left: parent.left; leftMargin: margins.paddings }} } } diff --git a/interface/resources/qml/hifi/audio/CheckBox.qml b/interface/resources/qml/hifi/audio/CheckBox.qml index 1f632ac479..77c001816f 100644 --- a/interface/resources/qml/hifi/audio/CheckBox.qml +++ b/interface/resources/qml/hifi/audio/CheckBox.qml @@ -9,10 +9,10 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -import QtQuick 2.5 +import QtQuick 2.7 import "../../controls-uit" as HifiControls -HifiControls.CheckBox { +HifiControls.CheckBox2 { color: "white" } diff --git a/interface/src/scripting/Audio.cpp b/interface/src/scripting/Audio.cpp index 9719c23885..f9c1a95fb5 100644 --- a/interface/src/scripting/Audio.cpp +++ b/interface/src/scripting/Audio.cpp @@ -135,10 +135,10 @@ void Audio::setReverbOptions(const AudioEffectOptions* options) { DependencyManager::get()->setReverbOptions(options); } -void Audio::setInputDevice(const QAudioDeviceInfo& device) { - _devices.chooseInputDevice(device); +void Audio::setInputDevice(const QAudioDeviceInfo& device, bool isHMD) { + _devices.chooseInputDevice(device, isHMD); } -void Audio::setOutputDevice(const QAudioDeviceInfo& device) { - _devices.chooseOutputDevice(device); +void Audio::setOutputDevice(const QAudioDeviceInfo& device, bool isHMD) { + _devices.chooseOutputDevice(device, isHMD); } diff --git a/interface/src/scripting/Audio.h b/interface/src/scripting/Audio.h index bd40de4303..abd2312cf0 100644 --- a/interface/src/scripting/Audio.h +++ b/interface/src/scripting/Audio.h @@ -50,8 +50,8 @@ public: void showMicMeter(bool show); void setInputVolume(float volume); - Q_INVOKABLE void setInputDevice(const QAudioDeviceInfo& device); - Q_INVOKABLE void setOutputDevice(const QAudioDeviceInfo& device); + Q_INVOKABLE void setInputDevice(const QAudioDeviceInfo& device, bool isHMD); + Q_INVOKABLE void setOutputDevice(const QAudioDeviceInfo& device, bool isHMD); Q_INVOKABLE void setReverb(bool enable); Q_INVOKABLE void setReverbOptions(const AudioEffectOptions* options); diff --git a/interface/src/scripting/AudioDevices.cpp b/interface/src/scripting/AudioDevices.cpp index f2e6dbf4d7..e31641389c 100644 --- a/interface/src/scripting/AudioDevices.cpp +++ b/interface/src/scripting/AudioDevices.cpp @@ -53,22 +53,28 @@ static QString getTargetDevice(bool hmd, QAudio::Mode mode) { } QHash AudioDeviceList::_roles { - { Qt::DisplayRole, "display" }, - { Qt::CheckStateRole, "selected" }, - { Qt::UserRole, "info" } + { AudioDeviceList::DeviceNameRole, "devicename" }, + { AudioDeviceList::SelectedDesktopRole, "selectedDesktop" }, + { AudioDeviceList::SelectedHMDRole, "selectedHMD" }, + { AudioDeviceList::DeviceInfoRole, "info" } }; + Qt::ItemFlags AudioDeviceList::_flags { Qt::ItemIsSelectable | Qt::ItemIsEnabled }; +AudioDeviceList::AudioDeviceList(QAudio::Mode mode) : _mode(mode) {} + QVariant AudioDeviceList::data(const QModelIndex& index, int role) const { if (!index.isValid() || index.row() >= _devices.size()) { return QVariant(); } - if (role == Qt::DisplayRole) { + if (role == DeviceNameRole) { return _devices.at(index.row()).display; - } else if (role == Qt::CheckStateRole) { - return _devices.at(index.row()).selected; - } else if (role == Qt::UserRole) { + } else if (role == SelectedDesktopRole) { + return _devices.at(index.row()).selectedDesktop; + } else if (role == SelectedHMDRole) { + return _devices.at(index.row()).selectedHMD; + } else if (role == DeviceInfoRole) { return QVariant::fromValue(_devices.at(index.row()).info); } else { return QVariant(); @@ -109,36 +115,47 @@ void AudioDeviceList::resetDevice(bool contextIsHMD) { #endif } -void AudioDeviceList::onDeviceChanged(const QAudioDeviceInfo& device) { - auto oldDevice = _selectedDevice; - _selectedDevice = device; +void AudioDeviceList::onDeviceChanged(const QAudioDeviceInfo& device, bool isHMD) { + auto oldDevice = isHMD ? _selectedHMDDevice : _selectedDesktopDevice; + QAudioDeviceInfo& selectedDevice = isHMD ? _selectedHMDDevice : _selectedDesktopDevice; + selectedDevice = device; for (auto i = 0; i < _devices.size(); ++i) { AudioDevice& device = _devices[i]; - if (device.selected && device.info != _selectedDevice) { - device.selected = false; - } else if (device.info == _selectedDevice) { - device.selected = true; + bool &isSelected = isHMD ? device.selectedHMD : device.selectedDesktop; + if (isSelected && device.info != selectedDevice) { + isSelected = false; + } else if (device.info == selectedDevice) { + isSelected = true; } } - emit deviceChanged(_selectedDevice); + emit deviceChanged(selectedDevice); emit dataChanged(createIndex(0, 0), createIndex(rowCount() - 1, 0)); } -void AudioDeviceList::onDevicesChanged(const QList& devices) { +void AudioDeviceList::onDevicesChanged(const QList& devices, bool isHMD) { + QAudioDeviceInfo& selectedDevice = isHMD ? _selectedHMDDevice : _selectedDesktopDevice; + + const QString& savedDeviceName = isHMD ? _hmdSavedDeviceName : _desktopSavedDeviceName; beginResetModel(); _devices.clear(); foreach(const QAudioDeviceInfo& deviceInfo, devices) { AudioDevice device; + bool &isSelected = isHMD ? device.selectedHMD : device.selectedDesktop; device.info = deviceInfo; device.display = device.info.deviceName() .replace("High Definition", "HD") .remove("Device") .replace(" )", ")"); - device.selected = (device.info == _selectedDevice); + if (!selectedDevice.isNull()) { + isSelected = (device.info == selectedDevice); + } else { + //no selected device for context. fallback to saved + isSelected = (device.info.deviceName() == savedDeviceName); + } _devices.push_back(device); } @@ -151,11 +168,18 @@ AudioDevices::AudioDevices(bool& contextIsHMD) : _contextIsHMD(contextIsHMD) { connect(client.data(), &AudioClient::deviceChanged, this, &AudioDevices::onDeviceChanged, Qt::QueuedConnection); connect(client.data(), &AudioClient::devicesChanged, this, &AudioDevices::onDevicesChanged, Qt::QueuedConnection); + _inputs.onDeviceChanged(client->getActiveAudioDevice(QAudio::AudioInput), contextIsHMD); + _outputs.onDeviceChanged(client->getActiveAudioDevice(QAudio::AudioOutput), contextIsHMD); + // connections are made after client is initialized, so we must also fetch the devices - _inputs.onDeviceChanged(client->getActiveAudioDevice(QAudio::AudioInput)); - _outputs.onDeviceChanged(client->getActiveAudioDevice(QAudio::AudioOutput)); - _inputs.onDevicesChanged(client->getAudioDevices(QAudio::AudioInput)); - _outputs.onDevicesChanged(client->getAudioDevices(QAudio::AudioOutput)); + const QList& devicesInput = client->getAudioDevices(QAudio::AudioInput); + const QList& devicesOutput = client->getAudioDevices(QAudio::AudioOutput); + //setup HMD devices + _inputs.onDevicesChanged(devicesInput, true); + _outputs.onDevicesChanged(devicesOutput, true); + //setup Desktop devices + _inputs.onDevicesChanged(devicesInput, false); + _outputs.onDevicesChanged(devicesOutput, false); } void AudioDevices::onContextChanged(const QString& context) { @@ -163,10 +187,11 @@ void AudioDevices::onContextChanged(const QString& context) { _outputs.resetDevice(_contextIsHMD); } -void AudioDevices::onDeviceSelected(QAudio::Mode mode, const QAudioDeviceInfo& device, const QAudioDeviceInfo& previousDevice) { +void AudioDevices::onDeviceSelected(QAudio::Mode mode, const QAudioDeviceInfo& device, + const QAudioDeviceInfo& previousDevice, bool isHMD) { QString deviceName = device.isNull() ? QString() : device.deviceName(); - auto& setting = getSetting(_contextIsHMD, mode); + auto& setting = getSetting(isHMD, mode); // check for a previous device auto wasDefault = setting.get().isNull(); @@ -202,42 +227,94 @@ void AudioDevices::onDeviceSelected(QAudio::Mode mode, const QAudioDeviceInfo& d void AudioDevices::onDeviceChanged(QAudio::Mode mode, const QAudioDeviceInfo& device) { if (mode == QAudio::AudioInput) { if (_requestedInputDevice == device) { - onDeviceSelected(QAudio::AudioInput, device, _inputs._selectedDevice); + onDeviceSelected(QAudio::AudioInput, device, + _contextIsHMD ? _inputs._selectedHMDDevice : _inputs._selectedDesktopDevice, + _contextIsHMD); _requestedInputDevice = QAudioDeviceInfo(); } - _inputs.onDeviceChanged(device); + _inputs.onDeviceChanged(device, _contextIsHMD); } else { // if (mode == QAudio::AudioOutput) if (_requestedOutputDevice == device) { - onDeviceSelected(QAudio::AudioOutput, device, _outputs._selectedDevice); + onDeviceSelected(QAudio::AudioOutput, device, + _contextIsHMD ? _outputs._selectedHMDDevice : _outputs._selectedDesktopDevice, + _contextIsHMD); _requestedOutputDevice = QAudioDeviceInfo(); } - _outputs.onDeviceChanged(device); + _outputs.onDeviceChanged(device, _contextIsHMD); } } void AudioDevices::onDevicesChanged(QAudio::Mode mode, const QList& devices) { static std::once_flag once; + std::call_once(once, [&] { + //readout settings + auto client = DependencyManager::get(); + + _inputs._hmdSavedDeviceName = getTargetDevice(true, QAudio::AudioInput); + _inputs._desktopSavedDeviceName = getTargetDevice(false, QAudio::AudioInput); + + //fallback to default device + if (_inputs._desktopSavedDeviceName.isEmpty()) { + _inputs._desktopSavedDeviceName = client->getActiveAudioDevice(QAudio::AudioInput).deviceName(); + } + //fallback to desktop device + if (_inputs._hmdSavedDeviceName.isEmpty()) { + _inputs._hmdSavedDeviceName = _inputs._desktopSavedDeviceName; + } + + _outputs._hmdSavedDeviceName = getTargetDevice(true, QAudio::AudioOutput); + _outputs._desktopSavedDeviceName = getTargetDevice(false, QAudio::AudioOutput); + + if (_outputs._desktopSavedDeviceName.isEmpty()) { + _outputs._desktopSavedDeviceName = client->getActiveAudioDevice(QAudio::AudioOutput).deviceName(); + } + if (_outputs._hmdSavedDeviceName.isEmpty()) { + _outputs._hmdSavedDeviceName = _outputs._desktopSavedDeviceName; + } + onContextChanged(QString()); + }); + + //set devices for both contexts if (mode == QAudio::AudioInput) { - _inputs.onDevicesChanged(devices); + _inputs.onDevicesChanged(devices, _contextIsHMD); + _inputs.onDevicesChanged(devices, !_contextIsHMD); } else { // if (mode == QAudio::AudioOutput) - _outputs.onDevicesChanged(devices); + _outputs.onDevicesChanged(devices, _contextIsHMD); + _outputs.onDevicesChanged(devices, !_contextIsHMD); } - std::call_once(once, [&] { onContextChanged(QString()); }); } -void AudioDevices::chooseInputDevice(const QAudioDeviceInfo& device) { - auto client = DependencyManager::get(); - _requestedInputDevice = device; - QMetaObject::invokeMethod(client.data(), "switchAudioDevice", - Q_ARG(QAudio::Mode, QAudio::AudioInput), - Q_ARG(const QAudioDeviceInfo&, device)); +void AudioDevices::chooseInputDevice(const QAudioDeviceInfo& device, bool isHMD) { + //check if current context equals device to change + if (_contextIsHMD == isHMD) { + auto client = DependencyManager::get(); + _requestedInputDevice = device; + QMetaObject::invokeMethod(client.data(), "switchAudioDevice", + Q_ARG(QAudio::Mode, QAudio::AudioInput), + Q_ARG(const QAudioDeviceInfo&, device)); + } else { + //context is different. just save device in settings + onDeviceSelected(QAudio::AudioInput, device, + isHMD ? _inputs._selectedHMDDevice : _inputs._selectedDesktopDevice, + isHMD); + _inputs.onDeviceChanged(device, isHMD); + } } -void AudioDevices::chooseOutputDevice(const QAudioDeviceInfo& device) { - auto client = DependencyManager::get(); - _requestedOutputDevice = device; - QMetaObject::invokeMethod(client.data(), "switchAudioDevice", - Q_ARG(QAudio::Mode, QAudio::AudioOutput), - Q_ARG(const QAudioDeviceInfo&, device)); +void AudioDevices::chooseOutputDevice(const QAudioDeviceInfo& device, bool isHMD) { + //check if current context equals device to change + if (_contextIsHMD == isHMD) { + auto client = DependencyManager::get(); + _requestedOutputDevice = device; + QMetaObject::invokeMethod(client.data(), "switchAudioDevice", + Q_ARG(QAudio::Mode, QAudio::AudioOutput), + Q_ARG(const QAudioDeviceInfo&, device)); + } else { + //context is different. just save device in settings + onDeviceSelected(QAudio::AudioOutput, device, + isHMD ? _outputs._selectedHMDDevice : _outputs._selectedDesktopDevice, + isHMD); + _outputs.onDeviceChanged(device, isHMD); + } } diff --git a/interface/src/scripting/AudioDevices.h b/interface/src/scripting/AudioDevices.h index 3278a53374..5399123329 100644 --- a/interface/src/scripting/AudioDevices.h +++ b/interface/src/scripting/AudioDevices.h @@ -22,14 +22,22 @@ class AudioDevice { public: QAudioDeviceInfo info; QString display; - bool selected { false }; + bool selectedDesktop { false }; + bool selectedHMD { false }; }; class AudioDeviceList : public QAbstractListModel { Q_OBJECT + enum AudioDeviceRoles { + DeviceNameRole = Qt::UserRole + 1, + SelectedDesktopRole, + SelectedHMDRole, + DeviceInfoRole + }; + public: - AudioDeviceList(QAudio::Mode mode) : _mode(mode) {} + AudioDeviceList(QAudio::Mode mode); int rowCount(const QModelIndex& parent = QModelIndex()) const override { Q_UNUSED(parent); return _devices.size(); } QHash roleNames() const override { return _roles; } @@ -45,8 +53,8 @@ signals: void deviceChanged(const QAudioDeviceInfo& device); private slots: - void onDeviceChanged(const QAudioDeviceInfo& device); - void onDevicesChanged(const QList& devices); + void onDeviceChanged(const QAudioDeviceInfo& device, bool isHMD); + void onDevicesChanged(const QList& devices, bool isHMD); private: friend class AudioDevices; @@ -54,8 +62,11 @@ private: static QHash _roles; static Qt::ItemFlags _flags; const QAudio::Mode _mode; - QAudioDeviceInfo _selectedDevice; + QAudioDeviceInfo _selectedDesktopDevice; + QAudioDeviceInfo _selectedHMDDevice; QList _devices; + QString _hmdSavedDeviceName; + QString _desktopSavedDeviceName; }; class Audio; @@ -67,15 +78,16 @@ class AudioDevices : public QObject { public: AudioDevices(bool& contextIsHMD); - void chooseInputDevice(const QAudioDeviceInfo& device); - void chooseOutputDevice(const QAudioDeviceInfo& device); + void chooseInputDevice(const QAudioDeviceInfo& device, bool isHMD); + void chooseOutputDevice(const QAudioDeviceInfo& device, bool isHMD); signals: void nop(); private slots: void onContextChanged(const QString& context); - void onDeviceSelected(QAudio::Mode mode, const QAudioDeviceInfo& device, const QAudioDeviceInfo& previousDevice); + void onDeviceSelected(QAudio::Mode mode, const QAudioDeviceInfo& device, + const QAudioDeviceInfo& previousDevice, bool isHMD); void onDeviceChanged(QAudio::Mode mode, const QAudioDeviceInfo& device); void onDevicesChanged(QAudio::Mode mode, const QList& devices); From b22745d57a90df73b54f8d967e04c0f3fd6d92f4 Mon Sep 17 00:00:00 2001 From: vladest Date: Sat, 12 Aug 2017 12:52:35 +0200 Subject: [PATCH 02/14] Fix binding loops --- .../resources/qml/controls-uit/CheckBox2.qml | 4 +-- interface/resources/qml/hifi/audio/Audio.qml | 30 +++++++------------ 2 files changed, 13 insertions(+), 21 deletions(-) diff --git a/interface/resources/qml/controls-uit/CheckBox2.qml b/interface/resources/qml/controls-uit/CheckBox2.qml index 612e8d2662..ffdb85c1a1 100644 --- a/interface/resources/qml/controls-uit/CheckBox2.qml +++ b/interface/resources/qml/controls-uit/CheckBox2.qml @@ -32,8 +32,8 @@ CheckBox { indicator: Rectangle { id: box - width: boxSize - height: boxSize + implicitWidth: boxSize + implicitHeight: boxSize radius: boxRadius x: checkBox.leftPadding y: parent.height / 2 - height / 2 diff --git a/interface/resources/qml/hifi/audio/Audio.qml b/interface/resources/qml/hifi/audio/Audio.qml index 3d3a9ceeaa..aa2e0e32d5 100644 --- a/interface/resources/qml/hifi/audio/Audio.qml +++ b/interface/resources/qml/hifi/audio/Audio.qml @@ -41,13 +41,13 @@ Rectangle { //recalculates dynamically in case of UI size is changed QtObject { id: margins - property real paddings: parent.width / 20.25 + property real paddings: root.width / 20.25 - property real sizeCheckBox: parent.width / 13.5 - property real sizeText: parent.width / 2.5 - property real sizeLevel: parent.width / 5.8 - property real sizeDesktop: parent.width / 5.8 - property real sizeVR: parent.width / 13.5 + property real sizeCheckBox: root.width / 13.5 + property real sizeText: root.width / 2.5 + property real sizeLevel: root.width / 5.8 + property real sizeDesktop: root.width / 5.8 + property real sizeVR: root.width / 13.5 } Column { @@ -166,7 +166,6 @@ Rectangle { RalewaySemiBold { Layout.minimumWidth: margins.sizeCheckBox + margins.sizeText Layout.maximumWidth: margins.sizeCheckBox + margins.sizeText - Layout.alignment: Qt.AlignVCenter clip: true size: 16; color: "white"; @@ -177,7 +176,6 @@ Rectangle { Item { Layout.minimumWidth: margins.sizeLevel Layout.maximumWidth: margins.sizeLevel - Layout.alignment: Qt.AlignVCenter height: 8; InputLevel { visible: (isVR && selectedHMD) || (!isVR && selectedDesktop); @@ -187,8 +185,7 @@ Rectangle { AudioControls.CheckBox { Layout.minimumWidth: margins.sizeDesktop Layout.maximumWidth: margins.sizeDesktop - leftPadding: margins.sizeDesktop - implicitWidth/2 - Layout.alignment: Qt.AlignCenter + leftPadding: margins.sizeDesktop/2 - boxSize/2 checked: selectedDesktop; onClicked: { if (checked) { @@ -200,8 +197,7 @@ Rectangle { AudioControls.CheckBox { Layout.minimumWidth: margins.sizeVR Layout.maximumWidth: margins.sizeVR - Layout.alignment: Qt.AlignCenter - leftPadding: margins.sizeVR - implicitWidth/2 + leftPadding: margins.sizeVR/2 - boxSize/2 checked: selectedHMD; onClicked: { if (checked) { @@ -266,14 +262,13 @@ Rectangle { clip: true; model: Audio.devices.output; delegate: RowLayout { - width: inputView.width; + width: outputView.width; height: 36; spacing: 0 RalewaySemiBold { Layout.minimumWidth: margins.sizeCheckBox + margins.sizeText Layout.maximumWidth: margins.sizeCheckBox + margins.sizeText - Layout.alignment: Qt.AlignVCenter clip: true size: 16; color: "white"; @@ -284,14 +279,12 @@ Rectangle { Item { Layout.minimumWidth: margins.sizeLevel Layout.maximumWidth: margins.sizeLevel - Layout.alignment: Qt.AlignVCenter height: 8; } AudioControls.CheckBox { Layout.minimumWidth: margins.sizeDesktop Layout.maximumWidth: margins.sizeDesktop - leftPadding: margins.sizeDesktop - implicitWidth/2 - Layout.alignment: Qt.AlignCenter + leftPadding: margins.sizeDesktop/2 - boxSize/2 checked: selectedDesktop; onClicked: { if (checked) { @@ -302,8 +295,7 @@ Rectangle { AudioControls.CheckBox { Layout.minimumWidth: margins.sizeVR Layout.maximumWidth: margins.sizeVR - Layout.alignment: Qt.AlignCenter - leftPadding: margins.sizeVR - implicitWidth/2 + leftPadding: margins.sizeVR/2 - boxSize/2 checked: selectedHMD; onClicked: { if (checked) { From d6c426d064b5313965369dade6504f8968680d26 Mon Sep 17 00:00:00 2001 From: vladest Date: Thu, 17 Aug 2017 17:17:02 +0200 Subject: [PATCH 03/14] Reworking according new design --- .../resources/qml/controls-uit/CheckBox2.qml | 1 - interface/resources/qml/hifi/audio/Audio.qml | 154 +++++------------- 2 files changed, 37 insertions(+), 118 deletions(-) diff --git a/interface/resources/qml/controls-uit/CheckBox2.qml b/interface/resources/qml/controls-uit/CheckBox2.qml index ffdb85c1a1..7bd69f0b19 100644 --- a/interface/resources/qml/controls-uit/CheckBox2.qml +++ b/interface/resources/qml/controls-uit/CheckBox2.qml @@ -103,7 +103,6 @@ CheckBox { wrapMode: checkBox.wrap ? Text.Wrap : Text.NoWrap elide: checkBox.wrap ? Text.ElideNone : Text.ElideRight enabled: checkBox.enabled - horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter leftPadding: checkBox.indicator.width + checkBox.spacing } diff --git a/interface/resources/qml/hifi/audio/Audio.qml b/interface/resources/qml/hifi/audio/Audio.qml index aa2e0e32d5..fa34ffb6d1 100644 --- a/interface/resources/qml/hifi/audio/Audio.qml +++ b/interface/resources/qml/hifi/audio/Audio.qml @@ -50,21 +50,38 @@ Rectangle { property real sizeVR: root.width / 13.5 } + TabBar { + id: bar + spacing: 0 + width: parent.width + height: 36 + + AudioControls.AudioTabButton { + height: parent.height + text: qsTr("Desktop") + } + AudioControls.AudioTabButton { + height: parent.height + text: qsTr("VR") + } + } + Column { - y: 16; // padding does not work - spacing: 16; + spacing: 12; + anchors.topMargin: 8 + anchors.top: bar.bottom + anchors.bottom: parent.bottom + anchors.bottomMargin: 5 width: parent.width; RalewayRegular { - x: margins.paddings; // padding does not work + x: margins.paddings; size: 16; color: "white"; - text: root.title; - - visible: root.showTitle(); + text: qsTr("Mic Settings") } - Separator { visible: root.showTitle() } + Separator { } ColumnLayout { x: margins.paddings; // padding does not work @@ -128,80 +145,29 @@ Rectangle { color: hifi.colors.lightGrayText; text: qsTr("CHOOSE INPUT DEVICE"); } - - RalewayRegular { - Layout.minimumWidth: margins.sizeDesktop - Layout.maximumWidth: margins.sizeDesktop - anchors.verticalCenter: parent.verticalCenter; - size: 16; - color: hifi.colors.lightGrayText; - text: qsTr("DESKTOP"); - } - - RalewayRegular { - Layout.minimumWidth: margins.sizeVR - Layout.maximumWidth: margins.sizeVR - Layout.alignment: Qt.AlignRight - anchors.verticalCenter: parent.verticalCenter; - size: 16; - color: hifi.colors.lightGrayText; - text: qsTr("VR"); - } } ListView { id: inputView width: parent.width - margins.paddings*2 x: margins.paddings - height: 125; - spacing: 0; + height: 145; + spacing: 4; snapMode: ListView.SnapToItem; clip: true; model: Audio.devices.input; delegate: RowLayout { width: inputView.width; - height: 36; spacing: 0 - RalewaySemiBold { - Layout.minimumWidth: margins.sizeCheckBox + margins.sizeText - Layout.maximumWidth: margins.sizeCheckBox + margins.sizeText - clip: true - size: 16; - color: "white"; - text: devicename; - } - - //placeholder for invisible level - Item { - Layout.minimumWidth: margins.sizeLevel - Layout.maximumWidth: margins.sizeLevel - height: 8; - InputLevel { - visible: (isVR && selectedHMD) || (!isVR && selectedDesktop); - anchors.fill: parent - } - } AudioControls.CheckBox { - Layout.minimumWidth: margins.sizeDesktop - Layout.maximumWidth: margins.sizeDesktop - leftPadding: margins.sizeDesktop/2 - boxSize/2 - checked: selectedDesktop; + Layout.fillWidth: true + checked: bar.currentIndex === 0 ? selectedDesktop : selectedHMD; + boxRadius: boxSize/2 + text: devicename onClicked: { if (checked) { - Audio.setInputDevice(info, false); - } - } - } - - AudioControls.CheckBox { - Layout.minimumWidth: margins.sizeVR - Layout.maximumWidth: margins.sizeVR - leftPadding: margins.sizeVR/2 - boxSize/2 - checked: selectedHMD; - onClicked: { - if (checked) { - Audio.setInputDevice(info, true); + Audio.setInputDevice(info, bar.currentIndex === 1); } } } @@ -231,25 +197,6 @@ Rectangle { color: hifi.colors.lightGrayText; text: qsTr("CHOOSE OUTPUT DEVICE"); } - - RalewayRegular { - Layout.minimumWidth: margins.sizeDesktop - Layout.maximumWidth: margins.sizeDesktop - anchors.verticalCenter: parent.verticalCenter; - size: 16; - color: hifi.colors.lightGrayText; - text: qsTr("DESKTOP"); - } - - RalewayRegular { - Layout.minimumWidth: margins.sizeVR - Layout.maximumWidth: margins.sizeVR - Layout.alignment: Qt.AlignRight - anchors.verticalCenter: parent.verticalCenter; - size: 16; - color: hifi.colors.lightGrayText; - text: qsTr("VR"); - } } ListView { @@ -257,49 +204,22 @@ Rectangle { width: parent.width - margins.paddings*2 x: margins.paddings height: Math.min(220, contentHeight); - spacing: 0; + spacing: 4; snapMode: ListView.SnapToItem; clip: true; model: Audio.devices.output; delegate: RowLayout { width: outputView.width; - height: 36; spacing: 0 - RalewaySemiBold { - Layout.minimumWidth: margins.sizeCheckBox + margins.sizeText - Layout.maximumWidth: margins.sizeCheckBox + margins.sizeText - clip: true - size: 16; - color: "white"; - text: devicename; - } - - //placeholder for invisible level - Item { - Layout.minimumWidth: margins.sizeLevel - Layout.maximumWidth: margins.sizeLevel - height: 8; - } AudioControls.CheckBox { - Layout.minimumWidth: margins.sizeDesktop - Layout.maximumWidth: margins.sizeDesktop - leftPadding: margins.sizeDesktop/2 - boxSize/2 - checked: selectedDesktop; + Layout.fillWidth: true + boxRadius: boxSize/2 + checked: bar.currentIndex === 0 ? selectedDesktop : selectedHMD; + text: devicename onClicked: { if (checked) { - Audio.setOutputDevice(info, false); - } - } - } - AudioControls.CheckBox { - Layout.minimumWidth: margins.sizeVR - Layout.maximumWidth: margins.sizeVR - leftPadding: margins.sizeVR/2 - boxSize/2 - checked: selectedHMD; - onClicked: { - if (checked) { - Audio.setOutputDevice(info, true); + Audio.setOutputDevice(info, bar.currentIndex === 1); } } } From f77b913a143edeac05b8987cb8b2aa225cb9f0ca Mon Sep 17 00:00:00 2001 From: vladest Date: Thu, 17 Aug 2017 20:55:00 +0200 Subject: [PATCH 04/14] Added input meter --- interface/resources/qml/hifi/audio/Audio.qml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/interface/resources/qml/hifi/audio/Audio.qml b/interface/resources/qml/hifi/audio/Audio.qml index fa34ffb6d1..dfecfbb50f 100644 --- a/interface/resources/qml/hifi/audio/Audio.qml +++ b/interface/resources/qml/hifi/audio/Audio.qml @@ -158,7 +158,7 @@ Rectangle { model: Audio.devices.input; delegate: RowLayout { width: inputView.width; - spacing: 0 + spacing: 5 AudioControls.CheckBox { Layout.fillWidth: true @@ -171,6 +171,10 @@ Rectangle { } } } + InputLevel { + visible: (bar.currentIndex === 1 && selectedHMD && isVR) || + (bar.currentIndex === 0 && selectedDesktop && !isVR); + } } } From 855f9d8a950481d6b583129b8ff50c09a2b35766 Mon Sep 17 00:00:00 2001 From: vladest Date: Thu, 17 Aug 2017 21:47:48 +0200 Subject: [PATCH 05/14] Missed qml file added --- .../qml/hifi/audio/AudioTabButton.qml | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 interface/resources/qml/hifi/audio/AudioTabButton.qml diff --git a/interface/resources/qml/hifi/audio/AudioTabButton.qml b/interface/resources/qml/hifi/audio/AudioTabButton.qml new file mode 100644 index 0000000000..bf50f1ba26 --- /dev/null +++ b/interface/resources/qml/hifi/audio/AudioTabButton.qml @@ -0,0 +1,34 @@ +// +// AudioTabButton.qml +// qml/hifi/audio +// +// Created by Vlad Stelmahovsky on 8/16/2017 +// Copyright 2017 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +import QtQuick 2.7 +import QtQuick.Controls 2.2 +import "../../controls-uit" as HifiControls +import "../../styles-uit" + +TabButton { + id: control + + HifiConstants { id: hifi; } + + contentItem: Text { + text: control.text + font: control.font + color: "white" + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + elide: Text.ElideRight + } + + background: Rectangle { + color: control.checked ? hifi.colors.baseGray : "black" + } +} From 6f0229f450538496b63087ecb096c695596d9828 Mon Sep 17 00:00:00 2001 From: vladest Date: Tue, 22 Aug 2017 23:26:27 +0200 Subject: [PATCH 06/14] 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; } From f7a704d9f43468cdf4958f9a010d47e79ebdc3b4 Mon Sep 17 00:00:00 2001 From: vladest Date: Tue, 22 Aug 2017 23:33:09 +0200 Subject: [PATCH 07/14] Added current tab selection according to context --- interface/resources/qml/hifi/audio/Audio.qml | 1 + 1 file changed, 1 insertion(+) diff --git a/interface/resources/qml/hifi/audio/Audio.qml b/interface/resources/qml/hifi/audio/Audio.qml index ed4a74b86f..e80f278323 100644 --- a/interface/resources/qml/hifi/audio/Audio.qml +++ b/interface/resources/qml/hifi/audio/Audio.qml @@ -56,6 +56,7 @@ Rectangle { spacing: 0 width: parent.width height: 42 + currentIndex: isVR ? 1 : 0 AudioControls.AudioTabButton { height: parent.height From d4332e7776faa5081a1a86e5de697e509b066a04 Mon Sep 17 00:00:00 2001 From: vladest Date: Sat, 26 Aug 2017 20:55:16 +0200 Subject: [PATCH 08/14] Adopting according comments from designers --- .../resources/qml/controls-uit/CheckBox2.qml | 2 ++ interface/resources/qml/hifi/audio/Audio.qml | 34 ++++++++++++++----- .../qml/hifi/audio/AudioTabButton.qml | 2 +- .../resources/qml/hifi/audio/CheckBox.qml | 1 - .../resources/qml/styles-uit/HiFiGlyphs.qml | 2 -- 5 files changed, 28 insertions(+), 13 deletions(-) diff --git a/interface/resources/qml/controls-uit/CheckBox2.qml b/interface/resources/qml/controls-uit/CheckBox2.qml index f845d24868..92bad04d01 100644 --- a/interface/resources/qml/controls-uit/CheckBox2.qml +++ b/interface/resources/qml/controls-uit/CheckBox2.qml @@ -19,6 +19,8 @@ CheckBox { HifiConstants { id: hifi; } + padding: 0 + leftPadding: 0 property int colorScheme: hifi.colorSchemes.light property string color: hifi.colors.lightGrayText readonly property bool isLightColorScheme: colorScheme === hifi.colorSchemes.light diff --git a/interface/resources/qml/hifi/audio/Audio.qml b/interface/resources/qml/hifi/audio/Audio.qml index e80f278323..3a9077cbb7 100644 --- a/interface/resources/qml/hifi/audio/Audio.qml +++ b/interface/resources/qml/hifi/audio/Audio.qml @@ -78,7 +78,7 @@ Rectangle { Separator { } RalewayRegular { - x: margins.paddings + margins.sizeCheckBox; + x: margins.paddings + muteMic.boxSize + muteMic.spacing; size: 16; color: "white"; text: qsTr("Input Device Settings") @@ -92,7 +92,9 @@ Rectangle { // mute is in its own row RowLayout { AudioControls.CheckBox { + id: muteMic text: qsTr("Mute microphone"); + spacing: 8 isRedCheck: true; checked: Audio.muted; onClicked: { @@ -105,6 +107,7 @@ Rectangle { RowLayout { spacing: 16; AudioControls.CheckBox { + spacing: muteMic.spacing text: qsTr("Enable noise reduction"); checked: Audio.noiseReduction; onClicked: { @@ -113,6 +116,7 @@ Rectangle { } } AudioControls.CheckBox { + spacing: muteMic.spacing text: qsTr("Show audio level meter"); checked: AvatarInputs.showAudioTools; onClicked: { @@ -126,20 +130,25 @@ Rectangle { Separator {} - Row { + Item { x: margins.paddings; width: parent.width - margins.paddings*2 - height: 28 - spacing: 0 + height: 36 + HiFiGlyphs { width: margins.sizeCheckBox text: hifi.glyphs.mic; color: hifi.colors.primaryHighlight; + anchors.left: parent.left + anchors.leftMargin: -size/4 //the glyph has empty space at left about 25% anchors.verticalCenter: parent.verticalCenter; size: 30; } + RalewayRegular { width: margins.sizeText + margins.sizeLevel + anchors.left: parent.left + anchors.leftMargin: margins.sizeCheckBox anchors.verticalCenter: parent.verticalCenter; size: 16; color: hifi.colors.lightGrayText; @@ -151,7 +160,7 @@ Rectangle { id: inputView width: parent.width - margins.paddings*2 x: margins.paddings - height: 150 + height: Math.min(150, contentHeight); spacing: 4; snapMode: ListView.SnapToItem; clip: true; @@ -162,6 +171,7 @@ Rectangle { AudioControls.CheckBox { anchors.left: parent.left + spacing: margins.sizeCheckBox - boxSize width: parent.width - inputLevel.width clip: true checked: bar.currentIndex === 0 ? selectedDesktop : selectedHMD; @@ -186,20 +196,25 @@ Rectangle { Separator {} - Row { + Item { x: margins.paddings; width: parent.width - margins.paddings*2 height: 36 - spacing: 0 + HiFiGlyphs { + anchors.left: parent.left + anchors.leftMargin: -size/4 //the glyph has empty space at left about 25% + anchors.verticalCenter: parent.verticalCenter; width: margins.sizeCheckBox text: hifi.glyphs.unmuted; color: hifi.colors.primaryHighlight; - anchors.verticalCenter: parent.verticalCenter; size: 36; } + RalewayRegular { width: margins.sizeText + margins.sizeLevel + anchors.left: parent.left + anchors.leftMargin: margins.sizeCheckBox anchors.verticalCenter: parent.verticalCenter; size: 16; color: hifi.colors.lightGrayText; @@ -211,7 +226,7 @@ Rectangle { id: outputView width: parent.width - margins.paddings*2 x: margins.paddings - height: Math.min(210, contentHeight); + height: Math.min(360 - inputView.height, contentHeight); spacing: 4; snapMode: ListView.SnapToItem; clip: true; @@ -222,6 +237,7 @@ Rectangle { AudioControls.CheckBox { width: parent.width + spacing: margins.sizeCheckBox - boxSize boxSize: margins.sizeCheckBox / 2 isRound: true checked: bar.currentIndex === 0 ? selectedDesktop : selectedHMD; diff --git a/interface/resources/qml/hifi/audio/AudioTabButton.qml b/interface/resources/qml/hifi/audio/AudioTabButton.qml index 2e6e114039..3a3ed90f5e 100644 --- a/interface/resources/qml/hifi/audio/AudioTabButton.qml +++ b/interface/resources/qml/hifi/audio/AudioTabButton.qml @@ -20,7 +20,7 @@ TabButton { HifiConstants { id: hifi; } - contentItem: Text { + contentItem: RalewaySemiBold { text: control.text font: control.font color: "white" diff --git a/interface/resources/qml/hifi/audio/CheckBox.qml b/interface/resources/qml/hifi/audio/CheckBox.qml index 806f08f439..77c001816f 100644 --- a/interface/resources/qml/hifi/audio/CheckBox.qml +++ b/interface/resources/qml/hifi/audio/CheckBox.qml @@ -14,6 +14,5 @@ import QtQuick 2.7 import "../../controls-uit" as HifiControls HifiControls.CheckBox2 { - spacing: 8 color: "white" } diff --git a/interface/resources/qml/styles-uit/HiFiGlyphs.qml b/interface/resources/qml/styles-uit/HiFiGlyphs.qml index cbd6fa1d68..f78d6c6f59 100644 --- a/interface/resources/qml/styles-uit/HiFiGlyphs.qml +++ b/interface/resources/qml/styles-uit/HiFiGlyphs.qml @@ -9,8 +9,6 @@ // import QtQuick 2.5 -import QtQuick.Controls 1.4 -import QtQuick.Controls.Styles 1.4 Text { id: root From 78aa5820d06b9fbe6e4a20bdd9fc5ff08bea9e6d Mon Sep 17 00:00:00 2001 From: vladest Date: Sun, 27 Aug 2017 11:56:28 +0200 Subject: [PATCH 09/14] Added proper destructor call for audio scripting interface. Save settings in destructor. Added logging to check readed audio settings --- interface/src/Application.cpp | 1 + interface/src/scripting/AudioDevices.cpp | 50 +++++++++++++++++++++++- interface/src/scripting/AudioDevices.h | 3 ++ 3 files changed, 53 insertions(+), 1 deletion(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index d13b7880fa..3aa3fbf95d 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -2052,6 +2052,7 @@ void Application::cleanupBeforeQuit() { // this must happen after QML, as there are unexplained audio crashes originating in qtwebengine DependencyManager::destroy(); DependencyManager::destroy(); + DependencyManager::destroy(); qCDebug(interfaceapp) << "Application::cleanupBeforeQuit() complete"; } diff --git a/interface/src/scripting/AudioDevices.cpp b/interface/src/scripting/AudioDevices.cpp index e31641389c..cff17c1a5c 100644 --- a/interface/src/scripting/AudioDevices.cpp +++ b/interface/src/scripting/AudioDevices.cpp @@ -61,7 +61,52 @@ QHash AudioDeviceList::_roles { Qt::ItemFlags AudioDeviceList::_flags { Qt::ItemIsSelectable | Qt::ItemIsEnabled }; -AudioDeviceList::AudioDeviceList(QAudio::Mode mode) : _mode(mode) {} +AudioDeviceList::AudioDeviceList(QAudio::Mode mode) : _mode(mode) { + auto& setting1 = getSetting(true, QAudio::AudioInput); + if (setting1.isSet()) { + qDebug() << "Device name in settings for HMD, Input" << setting1.get(); + } else { + qDebug() << "Device name in settings for HMD, Input not set"; + } + + auto& setting2 = getSetting(true, QAudio::AudioOutput); + if (setting2.isSet()) { + qDebug() << "Device name in settings for HMD, Output" << setting2.get(); + } else { + qDebug() << "Device name in settings for HMD, Output not set"; + } + + auto& setting3 = getSetting(false, QAudio::AudioInput); + if (setting3.isSet()) { + qDebug() << "Device name in settings for Desktop, Input" << setting3.get(); + } else { + qDebug() << "Device name in settings for Desktop, Input not set"; + } + + auto& setting4 = getSetting(false, QAudio::AudioOutput); + if (setting4.isSet()) { + qDebug() << "Device name in settings for Desktop, Output" << setting4.get(); + } else { + qDebug() << "Device name in settings for Desktop, Output not set"; + } +} + +AudioDeviceList::~AudioDeviceList() { + //save all selected devices + auto& settingHMD = getSetting(true, _mode); + auto& settingDesktop = getSetting(false, _mode); + // store the selected device + foreach(AudioDevice adevice, _devices) { + if (adevice.selectedDesktop) { + qDebug() << "Saving Desktop for" << _mode << "name" << adevice.info.deviceName(); + settingDesktop.set(adevice.info.deviceName()); + } + if (adevice.selectedHMD) { + qDebug() << "Saving HMD for" << _mode << "name" << adevice.info.deviceName(); + settingHMD.set(adevice.info.deviceName()); + } + } +} QVariant AudioDeviceList::data(const QModelIndex& index, int role) const { if (!index.isValid() || index.row() >= _devices.size()) { @@ -156,6 +201,7 @@ void AudioDeviceList::onDevicesChanged(const QList& devices, b //no selected device for context. fallback to saved isSelected = (device.info.deviceName() == savedDeviceName); } + qDebug() << "adding audio device:" << device.display << device.selectedDesktop << device.selectedHMD << _mode; _devices.push_back(device); } @@ -182,6 +228,8 @@ AudioDevices::AudioDevices(bool& contextIsHMD) : _contextIsHMD(contextIsHMD) { _outputs.onDevicesChanged(devicesOutput, false); } +AudioDevices::~AudioDevices() {} + void AudioDevices::onContextChanged(const QString& context) { _inputs.resetDevice(_contextIsHMD); _outputs.resetDevice(_contextIsHMD); diff --git a/interface/src/scripting/AudioDevices.h b/interface/src/scripting/AudioDevices.h index 5399123329..9b3b2bce9b 100644 --- a/interface/src/scripting/AudioDevices.h +++ b/interface/src/scripting/AudioDevices.h @@ -38,6 +38,7 @@ class AudioDeviceList : public QAbstractListModel { public: AudioDeviceList(QAudio::Mode mode); + virtual ~AudioDeviceList(); int rowCount(const QModelIndex& parent = QModelIndex()) const override { Q_UNUSED(parent); return _devices.size(); } QHash roleNames() const override { return _roles; } @@ -78,6 +79,8 @@ class AudioDevices : public QObject { public: AudioDevices(bool& contextIsHMD); + virtual ~AudioDevices(); + void chooseInputDevice(const QAudioDeviceInfo& device, bool isHMD); void chooseOutputDevice(const QAudioDeviceInfo& device, bool isHMD); From e17f05a33764af13fae631b13f3bc2e56ccc3e12 Mon Sep 17 00:00:00 2001 From: vladest Date: Wed, 6 Sep 2017 14:52:08 +0200 Subject: [PATCH 10/14] Correct UI --- interface/resources/qml/hifi/audio/Audio.qml | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/interface/resources/qml/hifi/audio/Audio.qml b/interface/resources/qml/hifi/audio/Audio.qml index 3a9077cbb7..dd9fcdb533 100644 --- a/interface/resources/qml/hifi/audio/Audio.qml +++ b/interface/resources/qml/hifi/audio/Audio.qml @@ -85,7 +85,7 @@ Rectangle { } ColumnLayout { - x: margins.paddings; // padding does not work + x: margins.paddings; spacing: 16; width: parent.width; @@ -94,7 +94,7 @@ Rectangle { AudioControls.CheckBox { id: muteMic text: qsTr("Mute microphone"); - spacing: 8 + spacing: margins.sizeCheckBox - boxSize isRedCheck: true; checked: Audio.muted; onClicked: { @@ -105,7 +105,7 @@ Rectangle { } RowLayout { - spacing: 16; + spacing: muteMic.spacing*2; //make it visually distinguish AudioControls.CheckBox { spacing: muteMic.spacing text: qsTr("Enable noise reduction"); @@ -167,11 +167,14 @@ Rectangle { model: Audio.devices.input; delegate: Item { width: rightMostInputLevelPos - height: margins.sizeCheckBox + height: margins.sizeCheckBox > checkBoxInput.implicitHeight ? + margins.sizeCheckBox : checkBoxInput.implicitHeight AudioControls.CheckBox { + id: checkBoxInput anchors.left: parent.left spacing: margins.sizeCheckBox - boxSize + anchors.verticalCenter: parent.verticalCenter width: parent.width - inputLevel.width clip: true checked: bar.currentIndex === 0 ? selectedDesktop : selectedHMD; @@ -233,9 +236,11 @@ Rectangle { model: Audio.devices.output; delegate: Item { width: rightMostInputLevelPos - height: margins.sizeCheckBox + height: margins.sizeCheckBox > checkBoxOutput.implicitHeight ? + margins.sizeCheckBox : checkBoxOutput.implicitHeight AudioControls.CheckBox { + id: checkBoxOutput width: parent.width spacing: margins.sizeCheckBox - boxSize boxSize: margins.sizeCheckBox / 2 From 6297448e907660bf508db14ff2f635775346c9e7 Mon Sep 17 00:00:00 2001 From: vladest Date: Tue, 19 Sep 2017 19:49:19 +0200 Subject: [PATCH 11/14] Build fix --- interface/resources/qml/hifi/audio/Audio.qml | 7 ++- interface/src/scripting/AudioDevices.cpp | 46 ++++++++++++-------- interface/src/scripting/AudioDevices.h | 4 +- 3 files changed, 36 insertions(+), 21 deletions(-) diff --git a/interface/resources/qml/hifi/audio/Audio.qml b/interface/resources/qml/hifi/audio/Audio.qml index 0abd166b06..5a2ee86c09 100644 --- a/interface/resources/qml/hifi/audio/Audio.qml +++ b/interface/resources/qml/hifi/audio/Audio.qml @@ -70,6 +70,7 @@ Rectangle { } property bool showPeaks: true; + function enablePeakValues() { Audio.devices.input.peakValuesEnabled = true; Audio.devices.input.peakValuesEnabledChanged.connect(function(enabled) { @@ -78,6 +79,7 @@ Rectangle { } }); } + function disablePeakValues() { root.showPeaks = false; Audio.devices.input.peakValuesEnabled = false; @@ -202,12 +204,13 @@ Rectangle { } } } - InputLevel { + InputPeak { id: inputLevel anchors.right: parent.right anchors.verticalCenter: parent.verticalCenter visible: (bar.currentIndex === 1 && selectedHMD && isVR) || - (bar.currentIndex === 0 && selectedDesktop && !isVR); + (bar.currentIndex === 0 && selectedDesktop && !isVR) && + Audio.devices.input.peakValuesAvailable; } } } diff --git a/interface/src/scripting/AudioDevices.cpp b/interface/src/scripting/AudioDevices.cpp index c79db91dfc..a130b46877 100644 --- a/interface/src/scripting/AudioDevices.cpp +++ b/interface/src/scripting/AudioDevices.cpp @@ -105,14 +105,14 @@ AudioDeviceList::~AudioDeviceList() { auto& settingHMD = getSetting(true, _mode); auto& settingDesktop = getSetting(false, _mode); // store the selected device - foreach(AudioDevice adevice, _devices) { - if (adevice.selectedDesktop) { - qDebug() << "Saving Desktop for" << _mode << "name" << adevice.info.deviceName(); - settingDesktop.set(adevice.info.deviceName()); + foreach(std::shared_ptr adevice, _devices) { + if (adevice->selectedDesktop) { + qDebug() << "Saving Desktop for" << _mode << "name" << adevice->info.deviceName(); + settingDesktop.set(adevice->info.deviceName()); } - if (adevice.selectedHMD) { - qDebug() << "Saving HMD for" << _mode << "name" << adevice.info.deviceName(); - settingHMD.set(adevice.info.deviceName()); + if (adevice->selectedHMD) { + qDebug() << "Saving HMD for" << _mode << "name" << adevice->info.deviceName(); + settingHMD.set(adevice->info.deviceName()); } } } @@ -123,18 +123,30 @@ QVariant AudioDeviceList::data(const QModelIndex& index, int role) const { } if (role == DeviceNameRole) { - return _devices.at(index.row()).display; + return _devices.at(index.row())->display; } else if (role == SelectedDesktopRole) { - return _devices.at(index.row()).selectedDesktop; + return _devices.at(index.row())->selectedDesktop; } else if (role == SelectedHMDRole) { - return _devices.at(index.row()).selectedHMD; - } else if (role == DeviceInfoRole) { - return QVariant::fromValue(_devices.at(index.row()).info); + return _devices.at(index.row())->selectedHMD; + } else if (role == InfoRole) { + return QVariant::fromValue(_devices.at(index.row())->info); } else { return QVariant(); } } +QVariant AudioInputDeviceList::data(const QModelIndex& index, int role) const { + if (!index.isValid() || index.row() >= rowCount()) { + return QVariant(); + } + + if (role == PeakRole) { + return std::static_pointer_cast(_devices.at(index.row()))->peak; + } else { + return AudioDeviceList::data(index, role); + } +} + void AudioDeviceList::resetDevice(bool contextIsHMD) { auto client = DependencyManager::get().data(); QString deviceName = getTargetDevice(contextIsHMD, _mode); @@ -175,11 +187,11 @@ void AudioDeviceList::onDeviceChanged(const QAudioDeviceInfo& device, bool isHMD selectedDevice = device; for (auto i = 0; i < _devices.size(); ++i) { - AudioDevice& device = _devices[i]; - bool &isSelected = isHMD ? device.selectedHMD : device.selectedDesktop; - if (isSelected && device.info != selectedDevice) { + std::shared_ptr device = _devices[i]; + bool &isSelected = isHMD ? device->selectedHMD : device->selectedDesktop; + if (isSelected && device->info != selectedDevice) { isSelected = false; - } else if (device.info == selectedDevice) { + } else if (device->info == selectedDevice) { isSelected = true; } } @@ -211,7 +223,7 @@ void AudioDeviceList::onDevicesChanged(const QList& devices, b isSelected = (device.info.deviceName() == savedDeviceName); } qDebug() << "adding audio device:" << device.display << device.selectedDesktop << device.selectedHMD << _mode; - _devices.push_back(device); + _devices.push_back(newDevice(device)); } endResetModel(); diff --git a/interface/src/scripting/AudioDevices.h b/interface/src/scripting/AudioDevices.h index 162092f358..36f1653e38 100644 --- a/interface/src/scripting/AudioDevices.h +++ b/interface/src/scripting/AudioDevices.h @@ -33,8 +33,8 @@ class AudioDeviceList : public QAbstractListModel { Q_OBJECT public: - AudioDeviceList(QAudio::Mode mode = QAudio::AudioOutput) : _mode(mode) {} - ~AudioDeviceList() = default; + AudioDeviceList(QAudio::Mode mode = QAudio::AudioOutput); + virtual ~AudioDeviceList(); virtual std::shared_ptr newDevice(const AudioDevice& device) { return std::make_shared(device); } From 10f7f081713e491549bb9d5ceb4471cc262f98ef Mon Sep 17 00:00:00 2001 From: vladest Date: Tue, 19 Sep 2017 21:42:52 +0200 Subject: [PATCH 12/14] Added peak model, missed during merging --- interface/resources/qml/hifi/audio/Audio.qml | 1 + 1 file changed, 1 insertion(+) diff --git a/interface/resources/qml/hifi/audio/Audio.qml b/interface/resources/qml/hifi/audio/Audio.qml index 5a2ee86c09..bc55175f18 100644 --- a/interface/resources/qml/hifi/audio/Audio.qml +++ b/interface/resources/qml/hifi/audio/Audio.qml @@ -207,6 +207,7 @@ Rectangle { InputPeak { id: inputLevel anchors.right: parent.right + peak: model.peak; anchors.verticalCenter: parent.verticalCenter visible: (bar.currentIndex === 1 && selectedHMD && isVR) || (bar.currentIndex === 0 && selectedDesktop && !isVR) && From 7a36894f76e9f17b754e4e2c4e6aab9961769739 Mon Sep 17 00:00:00 2001 From: vladest Date: Tue, 19 Sep 2017 23:25:41 +0200 Subject: [PATCH 13/14] Make sure audio device not gets unchecked --- interface/resources/qml/hifi/audio/Audio.qml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/interface/resources/qml/hifi/audio/Audio.qml b/interface/resources/qml/hifi/audio/Audio.qml index bc55175f18..b1f80ac5e8 100644 --- a/interface/resources/qml/hifi/audio/Audio.qml +++ b/interface/resources/qml/hifi/audio/Audio.qml @@ -194,12 +194,13 @@ Rectangle { anchors.verticalCenter: parent.verticalCenter width: parent.width - inputLevel.width clip: true + checkable: !checked checked: bar.currentIndex === 0 ? selectedDesktop : selectedHMD; boxSize: margins.sizeCheckBox / 2 isRound: true text: devicename - onClicked: { - if (checked) { + onPressed: { + if (!checked) { Audio.setInputDevice(info, bar.currentIndex === 1); } } @@ -265,9 +266,10 @@ Rectangle { boxSize: margins.sizeCheckBox / 2 isRound: true checked: bar.currentIndex === 0 ? selectedDesktop : selectedHMD; + checkable: !checked text: devicename - onClicked: { - if (checked) { + onPressed: { + if (!checked) { Audio.setOutputDevice(info, bar.currentIndex === 1); } } From c48aba423ac7c168377d3c73fac0e5bca8155d4b Mon Sep 17 00:00:00 2001 From: vladest Date: Wed, 20 Sep 2017 22:48:39 +0200 Subject: [PATCH 14/14] Rename check box --- .../qml/controls-uit/{CheckBox2.qml => CheckBoxQQC2.qml} | 0 interface/resources/qml/hifi/audio/CheckBox.qml | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename interface/resources/qml/controls-uit/{CheckBox2.qml => CheckBoxQQC2.qml} (100%) diff --git a/interface/resources/qml/controls-uit/CheckBox2.qml b/interface/resources/qml/controls-uit/CheckBoxQQC2.qml similarity index 100% rename from interface/resources/qml/controls-uit/CheckBox2.qml rename to interface/resources/qml/controls-uit/CheckBoxQQC2.qml diff --git a/interface/resources/qml/hifi/audio/CheckBox.qml b/interface/resources/qml/hifi/audio/CheckBox.qml index 77c001816f..3a954d4004 100644 --- a/interface/resources/qml/hifi/audio/CheckBox.qml +++ b/interface/resources/qml/hifi/audio/CheckBox.qml @@ -13,6 +13,6 @@ import QtQuick 2.7 import "../../controls-uit" as HifiControls -HifiControls.CheckBox2 { +HifiControls.CheckBoxQQC2 { color: "white" }