mute city boton momento

This commit is contained in:
Hane 2023-02-16 20:34:54 +01:00
commit 308a0486b6
7 changed files with 50 additions and 7 deletions

View file

@ -26,6 +26,15 @@ float Endpoint::getVolume(int channel){
}
bool Endpoint::getMute(){
BOOL mut;
if(FAILED(endpointVolume->GetMute(&mut))) { log_debugcpp("si"); }
log_debugcpp("back BOOL is " << mut);
bool mute = (bool)mut;
log_debugcpp("translate to bool " << mute);
return mute;
}
/*
* float Endpoint::getLeftChannelVolume(){
* float volume;
@ -49,6 +58,15 @@ void Endpoint::setVolume(int channel, float volume) {
}
}
void Endpoint::setMute() {
log_debugcpp("bool mute arrives as " << mut);
BOOL mut;
if(FAILED(endpointVolume->GetMute(&mut))) { log_debugcpp("si"); }
log_debugcpp("translate to BOOL as " << mute);
if(FAILED(endpointVolume->SetMute((mut == false ? 1 : 0), NULL))) { log_debugcpp("si"); };
}
Endpoint::~Endpoint(){
log_debugcpp("cum");
free(friendlyName);

View file

@ -26,7 +26,9 @@ class Endpoint {
void setVolume(int channel, float volume);
/* float getLeftChannelVolume(); */
/* float getRightChannelVolume(); */
float getVolume(int channel);
float getVolume(int channel);
void setMute();
bool getMute();
LPWSTR getName();
~Endpoint();

View file

@ -15,6 +15,12 @@ void EndpointHandler::setValue(int channel, int value){
else ept->setVolume(channel, (float)value / 100);
}
void EndpointHandler::setMute(){
//Qt momento, de ahi el param?
log_debugcpp("kinda handling the muting tbh");
ept->setMute();
}
QString EndpointHandler::getName(){
return eptName;
}
@ -23,6 +29,10 @@ float EndpointHandler::getVolume(int channel){
return ept->getVolume(channel);
}
bool EndpointHandler::getMute(){
return ept->getMute();
}
Overseer* OverseerHandler::getOverseer(){
return &os;
}

View file

@ -10,6 +10,7 @@ public:
EndpointHandler(Endpoint *ept, QObject *parent = nullptr);
QString getName();
float getVolume(int channel);
bool getMute();
private:
Endpoint *ept;
@ -18,8 +19,7 @@ private:
public slots:
void setValue(int channel, int value);
void setMute();
//signals:

View file

@ -4,8 +4,12 @@
#define ENDPOINT_MASTER_VOLUME -1
#define ENDPOINT_LEFT_CHANNEL_VOLUME 0
#define ENDPOINT_RIGHT_CHANNEL_VOLUME 1
#define STRING_MUTE "Mute"
#define STRING_UNMUTE "Unmute"
//INIT BACK
class OverseerHandler;
extern OverseerHandler *osh;

View file

@ -8,6 +8,7 @@ EndpointWidget::EndpointWidget(EndpointHandler* eph, QWidget *parent) : QWidget(
log_debugcpp("olaW");
if (parent == nullptr) { log_debugcpp("owo?"); }
muteButton = new QPushButton();
mainLabel = new QLabel(eph->getName());
leftChannelLabel = new QLabel("88");
rightChannelLabel = new QLabel("77");
@ -15,9 +16,9 @@ EndpointWidget::EndpointWidget(EndpointHandler* eph, QWidget *parent) : QWidget(
leftChannelSlider = new QSlider(Qt::Horizontal);
rightChannelSlider = new QSlider(Qt::Horizontal);
muteButton->setStyleSheet("background-color: #A3C1DA; color: red");
mainSlider->setFocusPolicy(Qt::StrongFocus);
mainSlider->setTickPosition(QSlider::TicksBothSides);
mainSlider->setTickInterval(5);
mainSlider->setSingleStep(1);
mainSlider->setRange(0,100);
@ -27,7 +28,8 @@ EndpointWidget::EndpointWidget(EndpointHandler* eph, QWidget *parent) : QWidget(
rightChannelSlider->setTickInterval(5);
rightChannelSlider->setSingleStep(1);
rightChannelSlider->setRange(0,100);
muteButton->setText(eph->getMute() ? STRING_UNMUTE : STRING_MUTE);
float volume = eph->getVolume(ENDPOINT_MASTER_VOLUME) * 100;
mainSlider->setValue((int)volume);
volume = eph->getVolume(ENDPOINT_LEFT_CHANNEL_VOLUME) * 100;
@ -38,7 +40,10 @@ EndpointWidget::EndpointWidget(EndpointHandler* eph, QWidget *parent) : QWidget(
rightChannelLabel->setText(QString::number(volume));
log_debugcpp("ENDPOINT SET WITH VOLUME " << volume);
layout->addWidget(mainLabel, 0, 0);
mainMuteLayout = new QGridLayout();
layout->addLayout(mainMuteLayout, 0, 0);
mainMuteLayout->addWidget(mainLabel, 0, 0);
mainMuteLayout->addWidget(muteButton, 0, 1);
layout->addWidget(mainSlider, 0, 1);
layout->addWidget(leftChannelSlider, 1, 0);
layout->addWidget(leftChannelLabel, 2, 0);
@ -53,6 +58,7 @@ EndpointWidget::EndpointWidget(EndpointHandler* eph, QWidget *parent) : QWidget(
connect(mainSlider, &QSlider::valueChanged, [this](int newValue){this->eph->setValue(ENDPOINT_MASTER_VOLUME, newValue); });
connect(leftChannelSlider, &QSlider::valueChanged, [this](int newValue){ this->eph->setValue(ENDPOINT_LEFT_CHANNEL_VOLUME, newValue); this->leftChannelLabel->setText(QString::number(newValue)); });
connect(rightChannelSlider, &QSlider::valueChanged, [this](int newValue){ this->eph->setValue(ENDPOINT_RIGHT_CHANNEL_VOLUME, newValue); this->rightChannelLabel->setText(QString::number(newValue)); });
connect(muteButton, &QPushButton::clicked, [this](bool clicked){ log_debugcpp("cliqui" << clicked << "cloqui"); this->eph->setMute(); this->muteButton->setText(this->eph->getMute() ? STRING_UNMUTE : STRING_MUTE); });
log_debugcpp("ENDPOINT_WIDGETED");
}

View file

@ -8,6 +8,7 @@
#include <QLabel>
#include <QSlider>
#include <QGridLayout>
#include <QPushButton>
#include "contclasses.h"
//#include <Q>
//#include <QWidgets>
@ -20,14 +21,16 @@ public:
EndpointWidget(EndpointHandler* eph, QWidget *parent = nullptr);
//void populateEndpointWidget(EndpointHandler *eph);
//void setEndpointHandlers(std::vector<EndpointHandler*> *ephs);
private:
EndpointHandler* eph;
QPushButton *muteButton = nullptr;
QLabel *mainLabel = nullptr, *leftChannelLabel = nullptr, *rightChannelLabel = nullptr;
QSlider *mainSlider = nullptr;
QSlider *leftChannelSlider = nullptr;
QSlider *rightChannelSlider = nullptr;
QGridLayout *layout = nullptr;
QGridLayout *mainMuteLayout = nullptr;
//std::vector<EndpointHandler*> *ephs;
//std::vector<QSlider> *sliders;