first callback implemented; overload not working
This commit is contained in:
parent
f21619aa1f
commit
ad53af655b
6 changed files with 92 additions and 29 deletions
|
|
@ -43,10 +43,11 @@ HRESULT EndpointCallback::OnNotify(PAUDIO_VOLUME_NOTIFICATION_DATA pNotify) {
|
|||
NGuid* guid = osh->getGuid();
|
||||
|
||||
if (memcmp(guid, &eventData, sizeof(*guid)) == 0) {
|
||||
log_debugcpp("perlitas");
|
||||
log_debugcpp("Onnanokotify says You Shall Not Update Thy Interface.");
|
||||
} else {
|
||||
log_debugcpp("Onnanokotify says Stored: " << guid->data1);
|
||||
log_debugcpp("Onnanokotify says Grace of God: " << eventData.guidEventContext.Data1);
|
||||
osh->updateMuteCallback(this->ep->getIndex(), eventData.bMuted);
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
|
|
@ -123,14 +124,14 @@ void Endpoint::setVolume(int channel, float volume) {
|
|||
}
|
||||
}
|
||||
|
||||
void Endpoint::setMute(NGuid* guid) {
|
||||
BOOL mut;
|
||||
void Endpoint::setMute(NGuid* guid, bool muted) {
|
||||
//BOOL mut;
|
||||
//log_debugcpp("bool mute arrives as " << mut);
|
||||
if(FAILED(endpointVolume->GetMute(&mut))) { log_debugcpp("si"); }
|
||||
log_debugcpp("translate to BOOL as " << mut);
|
||||
//if(FAILED(endpointVolume->GetMute(&mut))) { log_debugcpp("si"); }
|
||||
//log_debugcpp("translate to BOOL as " << mut);
|
||||
//TODO: use new funcs
|
||||
GUID tempMsGuid = NGuidToGUID(guid);
|
||||
if(FAILED(endpointVolume->SetMute((mut == false ? 1 : 0), &tempMsGuid))) { log_debugcpp("si"); };
|
||||
if(FAILED(endpointVolume->SetMute(muted, &tempMsGuid))) { log_debugcpp("si"); };
|
||||
}
|
||||
|
||||
void Endpoint::setCallback(EndpointCallback *epc){
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ class Endpoint {
|
|||
/* float getLeftChannelVolume(); */
|
||||
/* float getRightChannelVolume(); */
|
||||
float getVolume(int channel);
|
||||
void setMute(NGuid* guid);
|
||||
void setMute(NGuid* guid, bool muted);
|
||||
bool getMute();
|
||||
std::wstring getName();
|
||||
void setCallback(EndpointCallback *epc);
|
||||
|
|
|
|||
|
|
@ -32,10 +32,10 @@ void EndpointHandler::setValue(int channel, int value){
|
|||
else ep->setVolume(channel, (float)value / 100);
|
||||
}
|
||||
|
||||
void EndpointHandler::setMute(NGuid* guid){
|
||||
void EndpointHandler::setMute(NGuid* guid, bool muted){
|
||||
//Qt momento, de ahi el param?
|
||||
log_debugcpp("kinda handling the muting tbh");
|
||||
ep->setMute(guid);
|
||||
ep->setMute(guid, muted);
|
||||
}
|
||||
|
||||
std::wstring EndpointHandler::getName(){
|
||||
|
|
@ -105,9 +105,12 @@ void OverseerHandler::setEndpointHandlers(std::vector<EndpointHandler*> ephs){
|
|||
this->endpointHandlers = ephs;
|
||||
}
|
||||
|
||||
/*
|
||||
* void OverseerHandler::setEndpointWidgets(std::vector<EndpointWidget*> ews){
|
||||
* this->endpointWidgets = ews;
|
||||
* }
|
||||
*/
|
||||
|
||||
void OverseerHandler::setEndpointWidgets(std::vector<EndpointWidget*> ews){
|
||||
this->endpointWidgets = ews;
|
||||
}
|
||||
|
||||
void OverseerHandler::updateMuteCallback(uint64_t idx, bool muted){
|
||||
epwMuteFunc f = &EndpointWidget::updateMuteC;
|
||||
std::invoke(f, endpointWidgets.at(idx), muted);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* class QMainWindow{}; */
|
||||
/* #endif */
|
||||
|
||||
/* class EndpointWidget; */
|
||||
class EndpointWidget;
|
||||
|
||||
class Endpoint;
|
||||
class EndpointCallback;
|
||||
|
|
@ -37,7 +37,7 @@ public:
|
|||
bool getMute();
|
||||
|
||||
void setValue(int channel, int value);
|
||||
void setMute(NGuid* guid);
|
||||
void setMute(NGuid* guid, bool muted);
|
||||
~EndpointHandler();
|
||||
private:
|
||||
uint64_t idx;
|
||||
|
|
@ -54,12 +54,13 @@ class OverseerHandler {
|
|||
public:
|
||||
//OverseerHandler();
|
||||
void setEndpointHandlers(std::vector<EndpointHandler*> ephs);
|
||||
/* void setEndpointWidgets(std::vector<EndpointWidget*> ews); */
|
||||
void setEndpointWidgets(std::vector<EndpointWidget*> ews);
|
||||
std::vector<EndpointHandler*> getEndpointHandlers();
|
||||
std::vector<Endpoint*> getPlaybackEndpoints();
|
||||
uint64_t getPlaybackEndpointsCount();
|
||||
void reloadEndpointHandlers();
|
||||
NGuid* getGuid();
|
||||
void updateMuteCallback(uint64_t idx, bool muted);
|
||||
|
||||
//void parseExternalEndpointCallback(EndpointCallback *epc, PAUDIO_VOLUME_NOTIFICATION_DATA pNotify);
|
||||
//static Overseer* getOverseer();
|
||||
|
|
@ -67,5 +68,5 @@ public:
|
|||
private:
|
||||
static Overseer os;
|
||||
std::vector<EndpointHandler*> endpointHandlers;
|
||||
/* std::vector<EndpointWidget*> endpointWidgets; */
|
||||
std::vector<EndpointWidget*> endpointWidgets;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,5 +1,21 @@
|
|||
#include "qtclasses.h"
|
||||
|
||||
/*
|
||||
* ToggleButton::ToggleButton(QWidget *parent) : QAbstractButton(parent) {
|
||||
* this->setCheckable(true);
|
||||
* }
|
||||
*
|
||||
* ToggleButton::~ToggleButton(){
|
||||
*
|
||||
* }
|
||||
*
|
||||
* void ToggleButton::checkStateSet(){ }
|
||||
*
|
||||
* bool hitButton(const QPoint &pos) {
|
||||
*
|
||||
* }
|
||||
*/
|
||||
|
||||
EndpointWidget::EndpointWidget(EndpointHandler* eph, QWidget *parent) : QWidget(parent){
|
||||
this->eph = eph;
|
||||
layout = new QGridLayout();
|
||||
|
|
@ -7,7 +23,7 @@ EndpointWidget::EndpointWidget(EndpointHandler* eph, QWidget *parent) : QWidget(
|
|||
log_debugcpp("olaW");
|
||||
if (parent == nullptr) { log_debugcpp("owo?"); }
|
||||
|
||||
muteButton = new QPushButton();
|
||||
muteButton = new QCheckBox();
|
||||
mainLabel = new QLabel(QString::fromStdWString(eph->getName()));
|
||||
leftChannelLabel = new QLabel("88");
|
||||
rightChannelLabel = new QLabel("77");
|
||||
|
|
@ -15,7 +31,7 @@ EndpointWidget::EndpointWidget(EndpointHandler* eph, QWidget *parent) : QWidget(
|
|||
leftChannelSlider = new QSlider(Qt::Horizontal);
|
||||
rightChannelSlider = new QSlider(Qt::Horizontal);
|
||||
|
||||
muteButton->setStyleSheet("background-color: #A3C1DA; color: red");
|
||||
//muteButton->setStyleSheet("background-color: #A3C1DA; color: red");
|
||||
mainSlider->setFocusPolicy(Qt::StrongFocus);
|
||||
mainSlider->setTickPosition(QSlider::TicksBothSides);
|
||||
mainSlider->setTickInterval(5);
|
||||
|
|
@ -28,6 +44,7 @@ EndpointWidget::EndpointWidget(EndpointHandler* eph, QWidget *parent) : QWidget(
|
|||
rightChannelSlider->setSingleStep(1);
|
||||
rightChannelSlider->setRange(0,100);
|
||||
|
||||
muteButton->setCheckState((eph->getMute() == false ? Qt::Unchecked : Qt::Checked));
|
||||
muteButton->setText(eph->getMute() ? STRING_UNMUTE : STRING_MUTE);
|
||||
float volume = eph->getVolume(ENDPOINT_MASTER_VOLUME) * 100;
|
||||
mainSlider->setValue((int)volume);
|
||||
|
|
@ -51,16 +68,31 @@ EndpointWidget::EndpointWidget(EndpointHandler* eph, QWidget *parent) : QWidget(
|
|||
layout->addItem(new QSpacerItem(1, 1, QSizePolicy::Minimum, QSizePolicy::MinimumExpanding), 3, 0);
|
||||
layout->addItem(new QSpacerItem(1, 1, QSizePolicy::Minimum, QSizePolicy::MinimumExpanding), 3, 1);
|
||||
|
||||
/*
|
||||
* connect(mainSlider, &QSlider::valueChanged, eph, &EndpointHandler::setValue);
|
||||
*/
|
||||
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(osh->getGuid()); this->muteButton->setText(this->eph->getMute() ? STRING_UNMUTE : STRING_MUTE); });
|
||||
connect(muteButton, &QCheckBox::stateChanged, this, &EndpointWidget::updateMute);
|
||||
/*
|
||||
* connect(muteButton, &QPushButton::clicked, [this](bool clicked){ log_debugcpp("cliqui" << clicked << "cloqui"); this->eph->setMute(osh->getGuid()); this->muteButton->setText(this->eph->getMute() ? STRING_UNMUTE : STRING_MUTE); });
|
||||
*/
|
||||
log_debugcpp("ENDPOINT_WIDGETED");
|
||||
}
|
||||
|
||||
void EndpointWidget::updateMuteC(bool muted){
|
||||
log_debugcpp("cliqui callboqui cloqui");
|
||||
this->eph->setMute(osh->getGuid(), muted);
|
||||
this->muteButton->setChecked(eph->getMute() ? true : false);
|
||||
this->muteButton->setText(this->eph->getMute() ? STRING_UNMUTE : STRING_MUTE);
|
||||
}
|
||||
|
||||
void EndpointWidget::updateMute(int checked){
|
||||
log_debugcpp("cliqui slOtty cloqui");
|
||||
bool muted = (checked == 2 ? true : false);
|
||||
log_debugcpp("int: " << checked << " bool: " << muted);
|
||||
this->eph->setMute(osh->getGuid(), muted);
|
||||
//this->muteButton->setCheckState();
|
||||
this->muteButton->setText(this->eph->getMute() ? STRING_UNMUTE : STRING_MUTE);
|
||||
}
|
||||
|
||||
void EndpointWidget::setIndex(uint64_t idx){
|
||||
this->idx = idx;
|
||||
|
|
@ -93,7 +125,7 @@ void MainWindow::reloadEndpointWidgets() {
|
|||
ews.push_back(epw);
|
||||
layout->addWidget(epw, i, 0);
|
||||
}
|
||||
//osh->setEndpointWidgets(ews);
|
||||
osh->setEndpointWidgets(ews);
|
||||
layout->addItem(new QSpacerItem(1, 1, QSizePolicy::Minimum, QSizePolicy::MinimumExpanding), i, 0);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
#include <QSlider>
|
||||
#include <QGridLayout>
|
||||
#include <QPushButton>
|
||||
|
||||
#include <QCheckBox>
|
||||
/*
|
||||
* #else
|
||||
* class QSlider;
|
||||
|
|
@ -25,6 +25,30 @@
|
|||
#include "contclasses.h"
|
||||
//class EndpointHandler;
|
||||
|
||||
/*
|
||||
* class ToggleButton : public QAbstractButton {
|
||||
* Q_OBJECT
|
||||
*
|
||||
* public:
|
||||
* ToggleButton(QWidget *parent = nullptr);
|
||||
* void checkStateSet();
|
||||
* bool hitButton(const QPoint &pos) const;
|
||||
* void nextCheckState();
|
||||
* void changeEvent(QEvent *e) override;
|
||||
* bool event(QEvent *e) override;
|
||||
* void focusInEvent(QFocusEvent *e) override;
|
||||
* void focusOutEvent(QFocusEvent *e) override;
|
||||
* void keyPressEvent(QKeyEvent *e) override;
|
||||
* void keyReleaseEvent(QKeyEvent *e) override;
|
||||
* void mouseMoveEvent(QMouseEvent *e) override;
|
||||
* void mousePressEvent(QMouseEvent *e) override;
|
||||
* void mouseReleaseEvent(QMouseEvent *e) override;
|
||||
* void paintEvent(QPaintEvent *e) override = 0;
|
||||
* void timerEvent(QTimerEvent *e) override;
|
||||
* ToggleButton(QWidget *parent = nullptr);
|
||||
* };
|
||||
*/
|
||||
|
||||
class EndpointWidget : public QWidget {
|
||||
Q_OBJECT
|
||||
|
||||
|
|
@ -37,29 +61,31 @@ public:
|
|||
|
||||
void setVolume(int channel, float volume);
|
||||
|
||||
QPushButton *muteButton = nullptr;
|
||||
QCheckBox *muteButton = nullptr;
|
||||
QLabel *mainLabel = nullptr, *leftChannelLabel = nullptr, *rightChannelLabel = nullptr;
|
||||
QSlider *mainSlider = nullptr;
|
||||
QSlider *leftChannelSlider = nullptr;
|
||||
QSlider *rightChannelSlider = nullptr;
|
||||
QGridLayout *layout = nullptr;
|
||||
QGridLayout *mainMuteLayout = nullptr;
|
||||
void updateMuteC(bool muted);
|
||||
//void populateEndpointWidget(EndpointHandler *eph);
|
||||
//void setEndpointHandlers(std::vector<EndpointHandler*> *ephs);
|
||||
public slots:
|
||||
void updateMute(int checked);
|
||||
|
||||
private:
|
||||
uint64_t idx;
|
||||
//std::vector<EndpointHandler*> *ephs;
|
||||
//std::vector<QSlider> *sliders;
|
||||
|
||||
//public slots:
|
||||
// void setEndpointHandlers(std::vector<EndpointHandler*> *ephs);
|
||||
|
||||
//signals:
|
||||
//void valueChanged(int value);
|
||||
|
||||
};
|
||||
|
||||
typedef void (EndpointWidget::*epwMuteFunc)(bool muted);
|
||||
|
||||
class MainWindow : public QMainWindow {
|
||||
Q_OBJECT
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue