jfc ms/qt go to hell: defaults working as expected
This commit is contained in:
parent
4fc1019409
commit
d2ff934cd9
3 changed files with 70 additions and 35 deletions
|
|
@ -295,7 +295,13 @@ void Endpoint::setRoles(Roles role){
|
||||||
std::wstring command = L"SoundVolumeView.exe /SetDefault " + endpointId + L" ";
|
std::wstring command = L"SoundVolumeView.exe /SetDefault " + endpointId + L" ";
|
||||||
switch (role) {
|
switch (role) {
|
||||||
case Roles::ROLE_ALL:
|
case Roles::ROLE_ALL:
|
||||||
command += L"all";
|
/*
|
||||||
|
* one sends both, at least for now;
|
||||||
|
* either cos of ms or dis guy, no choice
|
||||||
|
* but to treat them as one for now
|
||||||
|
* command += L"all";
|
||||||
|
*/
|
||||||
|
command += L"0 1";
|
||||||
break;
|
break;
|
||||||
case Roles::ROLE_CONSOLE:
|
case Roles::ROLE_CONSOLE:
|
||||||
command += std::to_wstring(0);
|
command += std::to_wstring(0);
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,24 @@
|
||||||
#include "qtclasses.h"
|
#include "qtclasses.h"
|
||||||
|
|
||||||
|
|
||||||
|
bool ExtendedCheckBox::event(QEvent* ev) {
|
||||||
|
if (ev->type() == QEvent::User) {
|
||||||
|
this->blockSignals(true);
|
||||||
|
if (this->isEnabled()) {
|
||||||
|
this->setCheckState(Qt::Checked);
|
||||||
|
this->setDisabled(true);
|
||||||
|
} else {
|
||||||
|
this->setDisabled(false);
|
||||||
|
this->setCheckState(Qt::Unchecked);
|
||||||
|
}
|
||||||
|
this->blockSignals(false);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// Make sure the rest of events are handled
|
||||||
|
return QCheckBox::event(ev);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
EndpointWidget::EndpointWidget(uint64_t idx, EndpointHandler* eph, QWidget *parent) : QWidget(parent){
|
EndpointWidget::EndpointWidget(uint64_t idx, EndpointHandler* eph, QWidget *parent) : QWidget(parent){
|
||||||
this->idx = idx;
|
this->idx = idx;
|
||||||
this->eph = eph;
|
this->eph = eph;
|
||||||
|
|
@ -9,10 +28,10 @@ EndpointWidget::EndpointWidget(uint64_t idx, EndpointHandler* eph, QWidget *pare
|
||||||
if (parent == nullptr) { log_debugcpp("owo?"); }
|
if (parent == nullptr) { log_debugcpp("owo?"); }
|
||||||
|
|
||||||
defaultRolesCheckBoxes = {
|
defaultRolesCheckBoxes = {
|
||||||
{Roles::ROLE_ALL, new QCheckBox()},
|
{Roles::ROLE_ALL, new ExtendedCheckBox()},
|
||||||
{Roles::ROLE_CONSOLE, new QCheckBox()},
|
{Roles::ROLE_CONSOLE, new ExtendedCheckBox()},
|
||||||
{Roles::ROLE_MULTIMEDIA, new QCheckBox()},
|
{Roles::ROLE_MULTIMEDIA, new ExtendedCheckBox()},
|
||||||
{Roles::ROLE_COMMUNICATIONS, new QCheckBox()}
|
{Roles::ROLE_COMMUNICATIONS, new ExtendedCheckBox()}
|
||||||
};
|
};
|
||||||
|
|
||||||
muteButton = new QCheckBox();
|
muteButton = new QCheckBox();
|
||||||
|
|
@ -32,11 +51,12 @@ EndpointWidget::EndpointWidget(uint64_t idx, EndpointHandler* eph, QWidget *pare
|
||||||
mainSlider->setValue((int)volume);
|
mainSlider->setValue((int)volume);
|
||||||
log_debugcpp("ENDPOINT SET WITH VOLUME " << volume);
|
log_debugcpp("ENDPOINT SET WITH VOLUME " << volume);
|
||||||
|
|
||||||
|
//todo: parent
|
||||||
mainMuteLayout = new QGridLayout();
|
mainMuteLayout = new QGridLayout();
|
||||||
layout->addLayout(mainMuteLayout, 0, 0);
|
layout->addLayout(mainMuteLayout, 0, 0, 2, 1, Qt::AlignLeft | Qt::AlignBottom);
|
||||||
mainMuteLayout->addWidget(mainLabel, 0, 0);
|
mainMuteLayout->addWidget(mainLabel, 0, 0);
|
||||||
mainMuteLayout->addWidget(muteButton, 0, 1);
|
mainMuteLayout->addWidget(muteButton, 0, 1);
|
||||||
layout->addWidget(mainSlider, 0, 1);
|
layout->addWidget(mainSlider, 0, 2, 1, 2, Qt::AlignLeft | Qt::AlignBottom);
|
||||||
|
|
||||||
//TODO:0 = mute and muted, change volume = unmuted are client side tricks = 2 callbacks, one for volume, one for mute state. Implement as an user selectable option?
|
//TODO:0 = mute and muted, change volume = unmuted are client side tricks = 2 callbacks, one for volume, one for mute state. Implement as an user selectable option?
|
||||||
connect<void(QSlider::*)(int), void(EndpointWidget::*)(int)>(mainSlider, &QSlider::valueChanged, this,&EndpointWidget::updateMainVolume);
|
connect<void(QSlider::*)(int), void(EndpointWidget::*)(int)>(mainSlider, &QSlider::valueChanged, this,&EndpointWidget::updateMainVolume);
|
||||||
|
|
@ -55,8 +75,8 @@ EndpointWidget::EndpointWidget(uint64_t idx, EndpointHandler* eph, QWidget *pare
|
||||||
tmpLb->setText(QString::number(volume));
|
tmpLb->setText(QString::number(volume));
|
||||||
this->channelSliders.push_back(tmp);
|
this->channelSliders.push_back(tmp);
|
||||||
this->channelLabels.push_back(tmpLb);
|
this->channelLabels.push_back(tmpLb);
|
||||||
layout->addWidget(tmp, 1, i);
|
layout->addWidget(tmp, 2, i, 1, 2, Qt::AlignLeft | Qt::AlignTop);
|
||||||
layout->addWidget(tmpLb, 2, i);
|
layout->addWidget(tmpLb, 3, i, 1, 2, Qt::AlignLeft | Qt::AlignTop);
|
||||||
//TODO: check if there's a need to prevent deadlocks; probably this will eventually turn into its own func
|
//TODO: check if there's a need to prevent deadlocks; probably this will eventually turn into its own func
|
||||||
//this causes channel bar desync when back -> front. blocksignals below fix it. huh.
|
//this causes channel bar desync when back -> front. blocksignals below fix it. huh.
|
||||||
connect(tmp, &QSlider::valueChanged, [this, i](int newValue){
|
connect(tmp, &QSlider::valueChanged, [this, i](int newValue){
|
||||||
|
|
@ -95,19 +115,20 @@ EndpointWidget::EndpointWidget(uint64_t idx, EndpointHandler* eph, QWidget *pare
|
||||||
this->eph->setRoles(Roles::ROLE_MULTIMEDIA);
|
this->eph->setRoles(Roles::ROLE_MULTIMEDIA);
|
||||||
//todo: bloquiar pto
|
//todo: bloquiar pto
|
||||||
});
|
});
|
||||||
|
|
||||||
connect(defaultRolesCheckBoxes.at(Roles::ROLE_COMMUNICATIONS), &QCheckBox::stateChanged,[this] {
|
connect(defaultRolesCheckBoxes.at(Roles::ROLE_COMMUNICATIONS), &QCheckBox::stateChanged,[this] {
|
||||||
this->eph->setRoles(Roles::ROLE_COMMUNICATIONS);
|
this->eph->setRoles(Roles::ROLE_COMMUNICATIONS);
|
||||||
//todo: bloquiar pto
|
//todo: bloquiar pto
|
||||||
});
|
});
|
||||||
|
|
||||||
layout->addWidget(defaultRolesCheckBoxes.at(Roles::ROLE_ALL), 3, 0);
|
layout->addWidget(defaultRolesCheckBoxes.at(Roles::ROLE_ALL), 5, 0);
|
||||||
layout->addWidget(defaultRolesCheckBoxes.at(Roles::ROLE_CONSOLE), 3, 1);
|
layout->addWidget(defaultRolesCheckBoxes.at(Roles::ROLE_CONSOLE), 5, 1);
|
||||||
layout->addWidget(defaultRolesCheckBoxes.at(Roles::ROLE_MULTIMEDIA), 3, 2);
|
layout->addWidget(defaultRolesCheckBoxes.at(Roles::ROLE_MULTIMEDIA), 5, 2);
|
||||||
layout->addWidget(defaultRolesCheckBoxes.at(Roles::ROLE_COMMUNICATIONS), 3, 3);
|
layout->addWidget(defaultRolesCheckBoxes.at(Roles::ROLE_COMMUNICATIONS), 5, 3);
|
||||||
|
|
||||||
|
|
||||||
//Polling time
|
//Polling time
|
||||||
timer = new QTimer(this);
|
timer = new QTimer();
|
||||||
connect(timer, &QTimer::timeout, [this, eph](){
|
connect(timer, &QTimer::timeout, [this, eph](){
|
||||||
//if (memcmp(osh->callbackInfo[idx]->caller, osh->getGuid(), sizeof(NGuid)) == 0) return; CHECK IF THIS PROGRAM GENERATED THE FUNSIES IS NO LONGER IN USE FOR NOW.
|
//if (memcmp(osh->callbackInfo[idx]->caller, osh->getGuid(), sizeof(NGuid)) == 0) return; CHECK IF THIS PROGRAM GENERATED THE FUNSIES IS NO LONGER IN USE FOR NOW.
|
||||||
const float roundingFactor = 0.005;
|
const float roundingFactor = 0.005;
|
||||||
|
|
@ -130,9 +151,11 @@ EndpointWidget::EndpointWidget(uint64_t idx, EndpointHandler* eph, QWidget *pare
|
||||||
muteButton->blockSignals(false);
|
muteButton->blockSignals(false);
|
||||||
});
|
});
|
||||||
timer->start(10);
|
timer->start(10);
|
||||||
|
//todo parent?
|
||||||
layout->addItem(new QSpacerItem(1, 1, QSizePolicy::Minimum, QSizePolicy::MinimumExpanding), 4, 0);
|
layout->addItem(new QSpacerItem(1, 1, QSizePolicy::Minimum, QSizePolicy::Minimum), 1, 0);
|
||||||
layout->addItem(new QSpacerItem(1, 1, QSizePolicy::Minimum, QSizePolicy::MinimumExpanding), 4, 1);
|
layout->addItem(new QSpacerItem(1, 1, QSizePolicy::Minimum, QSizePolicy::Minimum), 4, 0);
|
||||||
|
layout->addItem(new QSpacerItem(1, 1, QSizePolicy::Minimum, QSizePolicy::MinimumExpanding), 6, 0);
|
||||||
|
layout->addItem(new QSpacerItem(1, 1, QSizePolicy::Minimum, QSizePolicy::MinimumExpanding), 6, 1);
|
||||||
log_debugcpp("ENDPOINT_WIDGETED");
|
log_debugcpp("ENDPOINT_WIDGETED");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -212,6 +235,8 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) {
|
||||||
trayIcon = new QSystemTrayIcon();
|
trayIcon = new QSystemTrayIcon();
|
||||||
trayIconMenu = new QMenu();
|
trayIconMenu = new QMenu();
|
||||||
trayIconMenuQuit = new QAction(STRING_QUIT);
|
trayIconMenuQuit = new QAction(STRING_QUIT);
|
||||||
|
changeDefaultCheckboxEnablement = new QEvent(QEvent::User);
|
||||||
|
changeDefaultCheckboxEnablement->setAccepted(true);
|
||||||
|
|
||||||
widget->setLayout(layout);
|
widget->setLayout(layout);
|
||||||
setCentralWidget(widget);
|
setCentralWidget(widget);
|
||||||
|
|
@ -244,15 +269,12 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) {
|
||||||
//not necessary to keep endpointState flags up to date right now, but updating it will allow for later config files / profiles
|
//not necessary to keep endpointState flags up to date right now, but updating it will allow for later config files / profiles
|
||||||
epw->defaultRolesCheckBoxes.at(role)->blockSignals(true);
|
epw->defaultRolesCheckBoxes.at(role)->blockSignals(true);
|
||||||
epw->getEndpointHandler()->assignRoles(role);
|
epw->getEndpointHandler()->assignRoles(role);
|
||||||
epw->defaultRolesCheckBoxes.at(role)->setCheckState(Qt::Checked);
|
|
||||||
//epw->defaultRolesCheckBoxes.at(role)->setDisabled(true);
|
|
||||||
epw->defaultRolesCheckBoxes.at(role)->blockSignals(false);
|
epw->defaultRolesCheckBoxes.at(role)->blockSignals(false);
|
||||||
|
QCoreApplication::instance()->postEvent(epw->defaultRolesCheckBoxes.at(role), changeDefaultCheckboxEnablement);
|
||||||
|
//epw->defaultRolesCheckBoxes.at(role)->postEnableChange();
|
||||||
|
|
||||||
if (epw->getEndpointHandler()->getRoles() == Roles::ROLE_ALL) {
|
if (epw->getEndpointHandler()->getRoles() == Roles::ROLE_ALL) {
|
||||||
epw->defaultRolesCheckBoxes.at(Roles::ROLE_ALL)->blockSignals(true);
|
QCoreApplication::instance()->postEvent(epw->defaultRolesCheckBoxes.at(Roles::ROLE_ALL), changeDefaultCheckboxEnablement);
|
||||||
epw->defaultRolesCheckBoxes.at(Roles::ROLE_ALL)->setCheckState(Qt::Checked);
|
|
||||||
//epw->defaultRolesCheckBoxes.at(Roles::ROLE_ALL)->setDisabled(true);
|
|
||||||
epw->defaultRolesCheckBoxes.at(Roles::ROLE_ALL)->blockSignals(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -269,19 +291,15 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) {
|
||||||
*/
|
*/
|
||||||
} else {
|
} else {
|
||||||
if (epw->getEndpointHandler()->getRoles() & role) {
|
if (epw->getEndpointHandler()->getRoles() & role) {
|
||||||
|
if (epw->getEndpointHandler()->getRoles() == Roles::ROLE_ALL) {
|
||||||
|
QCoreApplication::instance()->postEvent(epw->defaultRolesCheckBoxes.at(Roles::ROLE_ALL), changeDefaultCheckboxEnablement);
|
||||||
|
}
|
||||||
|
|
||||||
epw->defaultRolesCheckBoxes.at(role)->blockSignals(true);
|
epw->defaultRolesCheckBoxes.at(role)->blockSignals(true);
|
||||||
epw->getEndpointHandler()->removeRoles(role);
|
epw->getEndpointHandler()->removeRoles(role);
|
||||||
epw->defaultRolesCheckBoxes.at(role)->setCheckState(Qt::Unchecked);
|
|
||||||
//epw->defaultRolesCheckBoxes.at(role)->setDisabled(false);
|
//epw->defaultRolesCheckBoxes.at(role)->setDisabled(false);
|
||||||
epw->defaultRolesCheckBoxes.at(role)->blockSignals(false);
|
epw->defaultRolesCheckBoxes.at(role)->blockSignals(false);
|
||||||
|
QCoreApplication::instance()->postEvent(epw->defaultRolesCheckBoxes.at(role), changeDefaultCheckboxEnablement);
|
||||||
if (!epw->defaultRolesCheckBoxes.at(Roles::ROLE_ALL)->isEnabled()) {
|
|
||||||
epw->defaultRolesCheckBoxes.at(Roles::ROLE_ALL)->blockSignals(true);
|
|
||||||
//epw->defaultRolesCheckBoxes.at(Roles::ROLE_ALL)->setDisabled(false);
|
|
||||||
epw->defaultRolesCheckBoxes.at(Roles::ROLE_ALL)->setCheckState(Qt::Unchecked);
|
|
||||||
epw->defaultRolesCheckBoxes.at(Roles::ROLE_ALL)->blockSignals(false);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -57,6 +57,16 @@
|
||||||
* };
|
* };
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
class ExtendedCheckBox : public QCheckBox {
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
bool event(QEvent* ev) override;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
class EndpointWidget : public QWidget {
|
class EndpointWidget : public QWidget {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
|
@ -76,7 +86,7 @@ public:
|
||||||
std::vector<QLabel*> channelLabels;
|
std::vector<QLabel*> channelLabels;
|
||||||
QGridLayout *layout = nullptr;
|
QGridLayout *layout = nullptr;
|
||||||
QGridLayout *mainMuteLayout = nullptr;
|
QGridLayout *mainMuteLayout = nullptr;
|
||||||
std::map<Roles, QCheckBox*> defaultRolesCheckBoxes;
|
std::map<Roles, ExtendedCheckBox*> defaultRolesCheckBoxes;
|
||||||
|
|
||||||
//void updateMainVolume(float newValue);
|
//void updateMainVolume(float newValue);
|
||||||
//void updateVolume(uint32_t channel, float newValue);
|
//void updateVolume(uint32_t channel, float newValue);
|
||||||
|
|
@ -127,6 +137,7 @@ private:
|
||||||
QSystemTrayIcon *trayIcon;
|
QSystemTrayIcon *trayIcon;
|
||||||
QMenu *trayIconMenu;
|
QMenu *trayIconMenu;
|
||||||
QAction *trayIconMenuQuit;
|
QAction *trayIconMenuQuit;
|
||||||
|
QEvent* changeDefaultCheckboxEnablement;
|
||||||
//public slots:
|
//public slots:
|
||||||
// void setEndpointHandlers(std::vector<EndpointHandler*> *ephs);
|
// void setEndpointHandlers(std::vector<EndpointHandler*> *ephs);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue