failed attempt at redrawing

This commit is contained in:
Hane 2023-08-09 15:55:25 +02:00
commit f84ddaef6c
8 changed files with 142 additions and 25 deletions

View file

@ -2,10 +2,13 @@
Overseer OverseerHandler::os;
EndpointHandler::EndpointHandler(Endpoint *ept, QObject *parent) : QObject(parent) {
this->ept = ept;
eptName = QString::fromStdWString(ept->getName());
EndpointHandler::EndpointHandler(Endpoint *ep, EndpointCallback *epc, QObject *parent) : QObject(parent) {
this->ep = ep;
this->epc = epc;
epName = QString::fromStdWString(ept->getName());
ep->setCallback(*epc);
}
/*
* -1 for master volume
*/
@ -33,6 +36,13 @@ bool EndpointHandler::getMute(){
return ept->getMute();
}
EndpointHandler::~EndpointHandler() {
ep->removeCallback(*epc);
delete epc;
delete ep;
}
Overseer* OverseerHandler::getOverseer(){
return &os;
}
@ -41,10 +51,29 @@ OverseerHandler::OverseerHandler(QObject *parent) : QObject(parent) {
}
std::vector<EndpointHandler*>* OverseerHandler::getEndpointHandlers(){
return endpointHandlers;
std::vector<EndpointWidget*>* OverseerHandler::getEndpointWidgets(){
return &endpointWidgets;
}
void OverseerHandler::setEndpointHandlers(std::vector<EndpointHandler*> *ephs){
this->endpointHandlers = ephs;
void OverseerHandler::parseExternalEndpointCallback(EndpointCallback *fEpc, PAUDIO_VOLUME_NOTIFICATION_DATA pNotify){
log_debugcpp("parsing in da ovasiar");
for (uint64_t i = 0; i < endpointWidgets.size(); i++){
if(endpointWidgets.at(i)->eph->epc == fEpc) {
endpointWidgets.at(i)->muteButton->setText(endpointWidgets.at(i)->eph->getMute() ? STRING_UNMUTE : STRING_MUTE);
break;
}
}
/*
* 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");
*/
}
void OverseerHandler::setEndpointWidgets(std::vector<EndpointWidget*> ews){
this->endpointWidgets = ews;
}

View file

@ -1,4 +1,5 @@
#pragma once
#include <QObject>
#include "backlasses.h"
@ -7,15 +8,18 @@ class EndpointHandler : public QObject {
Q_OBJECT
public:
EndpointHandler(Endpoint *ept, QObject *parent = nullptr);
EndpointHandler(Endpoint *ept, EndpointCallback *epc, QObject *parent = nullptr);
//TODO: get();
Endpoint *ep;
EndpointCallback *epc;
QString epName;
QString getName();
float getVolume(int channel);
bool getMute();
private:
Endpoint *ept;
QString eptName;
//QSlider *slidy;
//QSlider *slidy;
public slots:
void setValue(int channel, int value);
@ -31,18 +35,17 @@ class OverseerHandler : public QObject {
public:
OverseerHandler(QObject *parent = nullptr);
void setEndpointHandlers(std::vector<EndpointHandler*> *ephs);
std::vector<EndpointHandler*>* getEndpointHandlers();
void setEndpointWidgets(std::vector<EndpointWidget*> ews);
std::vector<EndpointWidget*>* getEndpointWidgets();
void parseExternalEndpointCallback(EndpointCallback *epc, PAUDIO_VOLUME_NOTIFICATION_DATA pNotify);
static Overseer* getOverseer();
private:
static Overseer os;
std::vector<EndpointHandler*> *endpointHandlers;
std::vector<EndpointWidget*> endpointWidgets;
//QSlider *slidy;
//public slots:
//void setValue(int value);
};