Audio profile Save implemented no logic
This commit is contained in:
+108
-2
@@ -27,7 +27,38 @@ SOURCES += src/main.cpp\
|
||||
src/tabcontrollers/AccessibilityTabController.cpp \
|
||||
src/utils/ChaperoneUtils.cpp \
|
||||
src/tabcontrollers/audiomanager/AudioManagerDummy.cpp \
|
||||
src/tabcontrollers/keyboardinput/KeyboardInputDummy.cpp
|
||||
src/tabcontrollers/keyboardinput/KeyboardInputDummy.cpp \
|
||||
release/moc_AccessibilityTabController.cpp \
|
||||
release/moc_AudioTabController.cpp \
|
||||
release/moc_ChaperoneTabController.cpp \
|
||||
release/moc_FixFloorTabController.cpp \
|
||||
release/moc_MoveCenterTabController.cpp \
|
||||
release/moc_overlaycontroller.cpp \
|
||||
release/moc_PttController.cpp \
|
||||
release/moc_ReviveTabController.cpp \
|
||||
release/moc_SettingsTabController.cpp \
|
||||
release/moc_StatisticsTabController.cpp \
|
||||
release/moc_SteamVRTabController.cpp \
|
||||
release/moc_UtilitiesTabController.cpp \
|
||||
src/tabcontrollers/audiomanager/AudioManagerDummy.cpp \
|
||||
src/tabcontrollers/audiomanager/AudioManagerWindows.cpp \
|
||||
src/tabcontrollers/keyboardinput/KeyboardInputDummy.cpp \
|
||||
src/tabcontrollers/keyboardinput/KeyboardInputWindows.cpp \
|
||||
src/tabcontrollers/AccessibilityTabController.cpp \
|
||||
src/tabcontrollers/AudioTabController.cpp \
|
||||
src/tabcontrollers/ChaperoneTabController.cpp \
|
||||
src/tabcontrollers/FixFloorTabController.cpp \
|
||||
src/tabcontrollers/MoveCenterTabController.cpp \
|
||||
src/tabcontrollers/PttController.cpp \
|
||||
src/tabcontrollers/ReviveTabController.cpp \
|
||||
src/tabcontrollers/SettingsTabController.cpp \
|
||||
src/tabcontrollers/StatisticsTabController.cpp \
|
||||
src/tabcontrollers/SteamVRTabController.cpp \
|
||||
src/tabcontrollers/UtilitiesTabController.cpp \
|
||||
src/utils/ChaperoneUtils.cpp \
|
||||
src/main.cpp \
|
||||
src/overlaycontroller.cpp \
|
||||
src/tabcontrollers/AudioProfileController.cpp
|
||||
|
||||
HEADERS += src/overlaycontroller.h \
|
||||
src/logging.h \
|
||||
@@ -47,7 +78,38 @@ HEADERS += src/overlaycontroller.h \
|
||||
src/utils/Matrix.h \
|
||||
src/utils/ChaperoneUtils.h \
|
||||
src/tabcontrollers/audiomanager/AudioManagerDummy.h \
|
||||
src/tabcontrollers/keyboardinput/KeyboardInputDummy.h
|
||||
src/tabcontrollers/keyboardinput/KeyboardInputDummy.h \
|
||||
release/moc_predefs.h \
|
||||
src/tabcontrollers/audiomanager/AudioManagerDummy.h \
|
||||
src/tabcontrollers/audiomanager/AudioManagerWindows.h \
|
||||
src/tabcontrollers/audiomanager/IPolicyConfig.h \
|
||||
src/tabcontrollers/keyboardinput/KeyboardInputDummy.h \
|
||||
src/tabcontrollers/keyboardinput/KeyboardInputWindows.h \
|
||||
src/tabcontrollers/AccessibilityTabController.h \
|
||||
src/tabcontrollers/AudioManager.h \
|
||||
src/tabcontrollers/AudioTabController.h \
|
||||
src/tabcontrollers/ChaperoneTabController.h \
|
||||
src/tabcontrollers/FixFloorTabController.h \
|
||||
src/tabcontrollers/KeyboardInput.h \
|
||||
src/tabcontrollers/MoveCenterTabController.h \
|
||||
src/tabcontrollers/PttController.h \
|
||||
src/tabcontrollers/ReviveTabController.h \
|
||||
src/tabcontrollers/SettingsTabController.h \
|
||||
src/tabcontrollers/StatisticsTabController.h \
|
||||
src/tabcontrollers/SteamVRTabController.h \
|
||||
src/tabcontrollers/UtilitiesTabController.h \
|
||||
src/utils/ChaperoneUtils.h \
|
||||
src/utils/Matrix.h \
|
||||
src/logging.h \
|
||||
src/overlaycontroller.h \
|
||||
third-party/easylogging++/easylogging++.h \
|
||||
third-party/openvr/bin/osx64/OpenVR.framework/Versions/A/Headers/openvr.h \
|
||||
third-party/openvr/bin/osx64/OpenVR.framework/Versions/A/Headers/openvr_capi.h \
|
||||
third-party/openvr/bin/osx64/OpenVR.framework/Versions/A/Headers/openvr_driver.h \
|
||||
third-party/openvr/headers/openvr.h \
|
||||
third-party/openvr/headers/openvr_capi.h \
|
||||
third-party/openvr/headers/openvr_driver.h \
|
||||
src/tabcontrollers/AudioProfileController.h
|
||||
|
||||
win32 {
|
||||
SOURCES += src/tabcontrollers/audiomanager/AudioManagerWindows.cpp \
|
||||
@@ -65,3 +127,47 @@ LIBS += -lopenvr_api
|
||||
|
||||
win32:DESTDIR = bin/win64/AdvancedSettings
|
||||
unix:DESTDIR = bin/linux/AdvancedSettings
|
||||
|
||||
DISTFILES += \
|
||||
src/res/sounds/alarm01.wav \
|
||||
src/res/qml/ptt_notification.png \
|
||||
src/res/battery_0.png \
|
||||
src/res/battery_1.png \
|
||||
src/res/battery_2.png \
|
||||
src/res/battery_3.png \
|
||||
src/res/battery_4.png \
|
||||
src/res/battery_5.png \
|
||||
src/res/thumbicon.png \
|
||||
src/res/qml/backarrow.svg \
|
||||
src/res/qml/check.svg \
|
||||
src/res/qml/mic_off.svg \
|
||||
src/res/qml/mic_on.svg \
|
||||
src/res/qml/ptt_notification.svg \
|
||||
src/res/qml/speaker_off.svg \
|
||||
src/res/qml/speaker_on.svg \
|
||||
src/res/qml/qmldir \
|
||||
src/res/qml/AccessibilityPage.qml \
|
||||
src/res/qml/AudioPage.qml \
|
||||
src/res/qml/ChaperonePage.qml \
|
||||
src/res/qml/ChaperoneWarningsPage.qml \
|
||||
src/res/qml/FixFloorPage.qml \
|
||||
src/res/qml/mainwidget.qml \
|
||||
src/res/qml/MyComboBox.qml \
|
||||
src/res/qml/MyDialogOkCancelPopup.qml \
|
||||
src/res/qml/MyDialogOkPopup.qml \
|
||||
src/res/qml/MyPushButton.qml \
|
||||
src/res/qml/MyPushButton2.qml \
|
||||
src/res/qml/MyResources.qml \
|
||||
src/res/qml/MySlider.qml \
|
||||
src/res/qml/MyStackViewPage.qml \
|
||||
src/res/qml/MyText.qml \
|
||||
src/res/qml/MyTextField.qml \
|
||||
src/res/qml/MyToggleButton.qml \
|
||||
src/res/qml/PlayspacePage.qml \
|
||||
src/res/qml/PttControllerConfigDialog.qml \
|
||||
src/res/qml/RevivePage.qml \
|
||||
src/res/qml/RootPage.qml \
|
||||
src/res/qml/SettingsPage.qml \
|
||||
src/res/qml/StatisticsPage.qml \
|
||||
src/res/qml/SteamVRPage.qml \
|
||||
src/res/qml/UtilitiesPage.qml
|
||||
|
||||
@@ -38,9 +38,8 @@ MyStackViewPage {
|
||||
dialogTitle: "Delete Profile"
|
||||
dialogText: "Do you really want to delete this audio profile?"
|
||||
onClosed: {
|
||||
//TODO audio delete profile
|
||||
if (okClicked) {
|
||||
//AudioTabController.deletePttProfile(profileIndex)
|
||||
AudioTabController.deleteAudioProfile(profileIndex)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -121,8 +120,7 @@ MyStackViewPage {
|
||||
onClosed: {
|
||||
if (okClicked) {
|
||||
if (audioNewProfileName.text != "") {
|
||||
//TODO call AUDIO add profile
|
||||
//AudioTabController.addPttProfile(pttNewProfileName.text)
|
||||
AudioTabController.addAudioProfile(audioNewProfileName.text)
|
||||
} else {
|
||||
audioMessageDialog.showMessage("Create New Profile", "ERROR: No name given.")
|
||||
}
|
||||
@@ -415,8 +413,7 @@ MyStackViewPage {
|
||||
text: "Apply"
|
||||
onClicked: {
|
||||
if (audioProfileComboBox.currentIndex > 0) {
|
||||
//TODO
|
||||
// AudioTabController.applyPttProfile(pttProfileComboBox.currentIndex - 1)
|
||||
AudioTabController.applyAudioProfile(audioProfileComboBox.currentIndex - 1)
|
||||
audioProfileComboBox.currentIndex = 0
|
||||
}
|
||||
}
|
||||
@@ -555,6 +552,7 @@ MyStackViewPage {
|
||||
audioMicNameCombo.currentIndex = AudioTabController.micDeviceIndex
|
||||
}
|
||||
reloadPttProfiles()
|
||||
reloadAudioProfiles()
|
||||
audioPttEnabledToggle.checked = AudioTabController.pttEnabled
|
||||
audioPttLeftControllerToggle.checked = AudioTabController.pttLeftControllerEnabled
|
||||
audioPttRightControllerToggle.checked = AudioTabController.pttRightControllerEnabled
|
||||
@@ -634,6 +632,10 @@ MyStackViewPage {
|
||||
onPttProfilesUpdated: {
|
||||
reloadPttProfiles()
|
||||
}
|
||||
onAudioProfilesUpdated:{
|
||||
reloadAudioProfiles()
|
||||
}
|
||||
|
||||
onPlaybackDeviceListChanged: {
|
||||
var devs1 = []
|
||||
var devs2 = ["<None>"]
|
||||
@@ -698,4 +700,14 @@ MyStackViewPage {
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,107 @@
|
||||
#include "AudioProfileController.h"
|
||||
#include <QQuickWindow>
|
||||
#include <QApplication>
|
||||
#include "../overlaycontroller.h"
|
||||
|
||||
// application namespace
|
||||
namespace advsettings {
|
||||
|
||||
|
||||
//TODO DOCS/verify / other parts
|
||||
void AudioProfileController::reloadAudioProfiles() {
|
||||
audioProfiles.clear();
|
||||
auto settings = OverlayController::appSettings();
|
||||
settings->beginGroup(getSettingsName());
|
||||
auto profileCount = settings->beginReadArray("audioProfiles");
|
||||
for (int i = 0; i < profileCount; i++) {
|
||||
settings->setArrayIndex(i);
|
||||
audioProfiles.emplace_back();
|
||||
auto& entry = audioProfiles[i];
|
||||
entry.profileName = settings->value("profileName").toString().toStdString();
|
||||
}
|
||||
settings->endArray();
|
||||
settings->endGroup();
|
||||
}
|
||||
|
||||
void AudioProfileController::saveAudioProfiles() {
|
||||
auto settings = OverlayController::appSettings();
|
||||
settings->beginGroup(getSettingsName());
|
||||
settings->beginWriteArray("audioProfiles");
|
||||
unsigned i = 0;
|
||||
for (auto& p : audioProfiles) {
|
||||
settings->setArrayIndex(i);
|
||||
settings->setValue("profileName", QString::fromStdString(p.profileName));
|
||||
i++;
|
||||
}
|
||||
settings->endArray();
|
||||
settings->endGroup();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void AudioProfileController::addAudioProfile(QString name) {
|
||||
AudioProfile* profile = nullptr;
|
||||
for (auto& p : audioProfiles) {
|
||||
if (p.profileName.compare(name.toStdString()) == 0) {
|
||||
profile = &p;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!profile) {
|
||||
auto i = audioProfiles.size();
|
||||
audioProfiles.emplace_back();
|
||||
profile = &audioProfiles[i];
|
||||
}
|
||||
profile->profileName = name.toStdString();
|
||||
saveAudioProfiles();
|
||||
OverlayController::appSettings()->sync();
|
||||
emit audioProfilesUpdated();
|
||||
}
|
||||
|
||||
void AudioProfileController::applyAudioProfile(unsigned index) {
|
||||
//DO i need?
|
||||
std::lock_guard<std::recursive_mutex> lock(eventLoopMutexAudio);
|
||||
if (index < audioProfiles.size()) {
|
||||
auto& profile = audioProfiles[index];
|
||||
//TODO apply logic here
|
||||
//setPttShowNotification(profile.showNotification);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void AudioProfileController::deleteAudioProfile(unsigned index) {
|
||||
if (index < audioProfiles.size()) {
|
||||
auto pos = audioProfiles.begin() + index;
|
||||
audioProfiles.erase(pos);
|
||||
saveAudioProfiles();
|
||||
OverlayController::appSettings()->sync();
|
||||
emit audioProfilesUpdated();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
unsigned AudioProfileController::getAudioProfileCount() {
|
||||
return (unsigned)audioProfiles.size();
|
||||
}
|
||||
|
||||
QString AudioProfileController::getAudioProfileName(unsigned index) {
|
||||
if (index < audioProfiles.size()) {
|
||||
return QString::fromStdString(audioProfiles[index].profileName);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*void logControllerState(const vr::VRControllerState_t& state, const std::string& prefix) {
|
||||
if (state.ulButtonPressed & vr::ButtonMaskFromId(vr::k_EButton_ApplicationMenu)) {
|
||||
LOG(INFO) << prefix << vr::VRSystem()->GetButtonIdNameFromEnum(vr::k_EButton_ApplicationMenu) << " pressed";
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
//namespace advconfig
|
||||
@@ -0,0 +1,67 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QVariant>
|
||||
#include <string>
|
||||
#include <mutex>
|
||||
#include <openvr.h>
|
||||
#include "PttController.h"
|
||||
//#include "AudioTabController.h"
|
||||
|
||||
class QQuickWindow;
|
||||
// application namespace
|
||||
namespace advsettings {
|
||||
|
||||
// forward declaration
|
||||
class OverlayController;
|
||||
|
||||
struct AudioProfile {
|
||||
std::string profileName;
|
||||
std::string playbackName;
|
||||
std::string mirrorName;
|
||||
std::string micName;
|
||||
float mirrorVol = 0.0;
|
||||
float micVol = 0.0;
|
||||
bool micMute = false;
|
||||
bool mirrorMute = false;
|
||||
//TODO all the settings!!! huehue
|
||||
//bool showNotification = false;
|
||||
};
|
||||
|
||||
|
||||
class AudioProfileController : public PttController {
|
||||
Q_OBJECT
|
||||
//Q_PROPERTY(bool pttActive READ pttActive NOTIFY pttActiveChanged)
|
||||
//NEED TO DOUBLE CHECK THIS IS CORRECT!?
|
||||
|
||||
protected:
|
||||
|
||||
std::vector<AudioProfile> audioProfiles;
|
||||
|
||||
protected:
|
||||
virtual QString getSettingsName() = 0;
|
||||
//may have to change to prevent issues
|
||||
std::recursive_mutex eventLoopMutexAudio;
|
||||
|
||||
public:
|
||||
|
||||
void reloadAudioProfiles();
|
||||
void saveAudioProfiles();
|
||||
|
||||
//TODO
|
||||
|
||||
Q_INVOKABLE unsigned getAudioProfileCount();
|
||||
Q_INVOKABLE QString getAudioProfileName(unsigned index);
|
||||
|
||||
public slots:
|
||||
void addAudioProfile(QString name);
|
||||
void applyAudioProfile(unsigned index);
|
||||
void deleteAudioProfile(unsigned index);
|
||||
|
||||
signals:
|
||||
void audioProfilesUpdated();
|
||||
};
|
||||
|
||||
} // namespace advsettings
|
||||
@@ -38,6 +38,7 @@ namespace advsettings {
|
||||
m_micMuted = audioManager->getMicMuted();
|
||||
reloadPttProfiles();
|
||||
reloadPttConfig();
|
||||
reloadAudioProfiles();
|
||||
reloadAudioSettings();
|
||||
eventLoopTick();
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
#include "AudioManager.h"
|
||||
#include "PttController.h"
|
||||
#include "AudioProfileController.h"
|
||||
#include <memory>
|
||||
|
||||
class QQuickWindow;
|
||||
@@ -13,7 +14,7 @@ namespace advsettings {
|
||||
class OverlayController;
|
||||
|
||||
|
||||
class AudioTabController : public PttController {
|
||||
class AudioTabController : public AudioProfileController {
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(int playbackDeviceIndex READ playbackDeviceIndex WRITE setPlaybackDeviceIndex NOTIFY playbackDeviceIndexChanged)
|
||||
Q_PROPERTY(int mirrorDeviceIndex READ mirrorDeviceIndex WRITE setMirrorDeviceIndex NOTIFY mirrorDeviceIndexChanged)
|
||||
@@ -55,6 +56,7 @@ namespace advsettings {
|
||||
std::string lastMirrorDevId;
|
||||
|
||||
QString getSettingsName() override { return "audioSettings"; }
|
||||
//QString getSettingsNameAudio() override { return "audioSettingsTest"; }
|
||||
void onPttStart() override;
|
||||
void onPttStop() override;
|
||||
void onPttEnabled() override;
|
||||
|
||||
@@ -239,6 +239,7 @@ namespace advsettings {
|
||||
}
|
||||
|
||||
void PttController::addPttProfile(QString name) {
|
||||
int a = 0;
|
||||
PttProfile* profile = nullptr;
|
||||
for (auto& p : pttProfiles) {
|
||||
if (p.profileName.compare(name.toStdString()) == 0) {
|
||||
|
||||
Reference in New Issue
Block a user