Audio profile Save implemented no logic
This commit is contained in:
@@ -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