wip: fixed role setting
This commit is contained in:
parent
76d0afe672
commit
5b3b50a0d2
4 changed files with 64 additions and 49 deletions
|
|
@ -426,7 +426,7 @@ void Endpoint::setRoles(Roles role){
|
||||||
SecureZeroMemory(&processInfo, sizeof(PROCESS_INFORMATION));
|
SecureZeroMemory(&processInfo, sizeof(PROCESS_INFORMATION));
|
||||||
|
|
||||||
std::wstring command = L"SoundVolumeView.exe /SetDefault " + endpointId + L" ";
|
std::wstring command = L"SoundVolumeView.exe /SetDefault " + endpointId + L" ";
|
||||||
std::wstring troublePair = L"0";
|
std::wstring troublePair = L"1";
|
||||||
switch (role) {
|
switch (role) {
|
||||||
case Roles::ROLE_ALL:
|
case Roles::ROLE_ALL:
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
|
|
@ -310,7 +310,6 @@ void OverseerHandler::reviseEndpointShowing(std::wstring endpointId, EndpointSta
|
||||||
Flows flow;
|
Flows flow;
|
||||||
if (!eph) {
|
if (!eph) {
|
||||||
if (state ^ EndpointState::ENDPOINT_ACTIVE) return;
|
if (state ^ EndpointState::ENDPOINT_ACTIVE) return;
|
||||||
//return;
|
|
||||||
//flow = Flows::FLOW_CAPTURE;
|
//flow = Flows::FLOW_CAPTURE;
|
||||||
eph = osh->addEndpoint(endpointId, &flow);
|
eph = osh->addEndpoint(endpointId, &flow);
|
||||||
} else
|
} else
|
||||||
|
|
@ -319,7 +318,6 @@ void OverseerHandler::reviseEndpointShowing(std::wstring endpointId, EndpointSta
|
||||||
//todo: mic done but disabled. Tab-kun will come...
|
//todo: mic done but disabled. Tab-kun will come...
|
||||||
if (flow == Flows::FLOW_CAPTURE) return;
|
if (flow == Flows::FLOW_CAPTURE) return;
|
||||||
|
|
||||||
|
|
||||||
if(eph && EndpointState::ENDPOINT_ACTIVE & state) {
|
if(eph && EndpointState::ENDPOINT_ACTIVE & state) {
|
||||||
this->addEndpointWidget(eph);
|
this->addEndpointWidget(eph);
|
||||||
} else if (eph && eph->getFrontVisibilityState() == EndpointState::ENDPOINT_ACTIVE){
|
} else if (eph && eph->getFrontVisibilityState() == EndpointState::ENDPOINT_ACTIVE){
|
||||||
|
|
|
||||||
|
|
@ -295,7 +295,7 @@ void ChannelWidget::updateChannel(int channel) {
|
||||||
this->channelSliders.at(channel)->blockSignals(false);
|
this->channelSliders.at(channel)->blockSignals(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
EndpointWidget::EndpointWidget(uint64_t idx, EndpointHandler* eph, QWidget *parent) : QWidget(parent) {
|
EndpointWidget::EndpointWidget(EndpointHandler* eph, QWidget *parent, uint64_t idx) : QWidget(parent) {
|
||||||
//todo: based on qgridlayout, name+mute should be its own widget, same with channels
|
//todo: based on qgridlayout, name+mute should be its own widget, same with channels
|
||||||
row = 0;
|
row = 0;
|
||||||
this->idx = idx;
|
this->idx = idx;
|
||||||
|
|
@ -520,7 +520,7 @@ void MainWindow::removeEndpointWidget(CustomWidgetEvent<uint64_t>* ev){
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::addEndpointWidget(CustomWidgetEvent<EndpointHandler*>* ev){
|
void MainWindow::addEndpointWidget(CustomWidgetEvent<EndpointHandler*>* ev){
|
||||||
EndpointWidget* epw = new EndpointWidget(this->ews.size(), ev->payload, widget);
|
EndpointWidget* epw = new EndpointWidget(ev->payload, widget, this->ews.size());
|
||||||
//epw->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
//epw->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
||||||
this->widgetLayout->addWidget(epw);
|
this->widgetLayout->addWidget(epw);
|
||||||
ews.push_back(epw);
|
ews.push_back(epw);
|
||||||
|
|
@ -621,7 +621,7 @@ EndpointHandler* EndpointWidget::getEndpointHandler(){
|
||||||
|
|
||||||
void EndpointWidget::setIndex(uint64_t idx){
|
void EndpointWidget::setIndex(uint64_t idx){
|
||||||
this->idx = idx;
|
this->idx = idx;
|
||||||
this->eph->setFrontVisibilityInfo(EndpointState::ENDPOINT_ACTIVE, this->idx);
|
this->eph->setState(EndpointState::ENDPOINT_ACTIVE, this->idx);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t EndpointWidget::getIndex(){
|
uint64_t EndpointWidget::getIndex(){
|
||||||
|
|
@ -733,41 +733,58 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) {
|
||||||
* Set of function callback definitons for EndpointSituationCallback
|
* Set of function callback definitons for EndpointSituationCallback
|
||||||
*/
|
*/
|
||||||
osh->setChangeFrontDefaultsFunction([this](Roles role, std::wstring endpointId) {
|
osh->setChangeFrontDefaultsFunction([this](Roles role, std::wstring endpointId) {
|
||||||
for (auto epw : this->ews) {
|
EndpointWidget *newDef = nullptr, *oldDef = nullptr;
|
||||||
/*
|
for (int i = 0; i < ews.size(); i++) {
|
||||||
* Is this the new default endpoint?
|
auto epw = this->ews.at(i);
|
||||||
*/
|
if (!epw) continue;
|
||||||
if (epw->getEndpointHandler()->getId() == endpointId) {
|
if (epw->getEndpointHandler()->getId() == endpointId) {
|
||||||
//not necessary to keep endpointState flags up to date right now, but updating it will allow for later config files / profiles
|
newDef = epw;
|
||||||
epw->getDefaultRolesWidgets().at(role)->blockSignals(true);
|
continue; }
|
||||||
epw->getEndpointHandler()->assignRoles(role);
|
if (epw->getEndpointHandler()->getRoles() & role) {
|
||||||
epw->getDefaultRolesWidgets().at(role)->blockSignals(false);
|
oldDef = epw;
|
||||||
QCoreApplication::instance()->postEvent(epw->getDefaultRolesWidgets().at(role), new QEvent((QEvent::Type)CustomQEvent::EndpointDefaultChange));
|
continue; }
|
||||||
//epw->defaultRolesCheckBoxes.at(role)->postEnableChange();
|
|
||||||
/*
|
|
||||||
* And were you THE default?
|
|
||||||
*/
|
|
||||||
if (epw->getEndpointHandler()->getRoles() == Roles::ROLE_ALL) {
|
|
||||||
QCoreApplication::instance()->postEvent(epw->getDefaultRolesWidgets().at(Roles::ROLE_ALL), new QEvent((QEvent::Type)CustomQEvent::EndpointDefaultChange));
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
* Are you the dethroned king?
|
|
||||||
*/
|
|
||||||
} else if (epw->getEndpointHandler()->getRoles() & role) {
|
|
||||||
/*
|
|
||||||
* And were you THE default up until now?
|
|
||||||
*/
|
|
||||||
if (epw->getEndpointHandler()->getRoles() == Roles::ROLE_ALL) {
|
|
||||||
QCoreApplication::instance()->postEvent(epw->getDefaultRolesWidgets().at(Roles::ROLE_ALL), new QEvent((QEvent::Type)CustomQEvent::EndpointDefaultChange));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
epw->getDefaultRolesWidgets().at(role)->blockSignals(true);
|
//debug if (role != Roles::ROLE_COMMUNICATIONS) return;
|
||||||
//Same as before. ini-san will come...
|
if (oldDef && newDef) {
|
||||||
epw->getEndpointHandler()->removeRoles(role);
|
this->ews.at(oldDef->getIndex()) = nullptr;
|
||||||
epw->getDefaultRolesWidgets().at(role)->blockSignals(false);
|
this->ews.at(newDef->getIndex()) = nullptr;
|
||||||
QCoreApplication::instance()->postEvent(epw->getDefaultRolesWidgets().at(role), new QEvent((QEvent::Type)CustomQEvent::EndpointDefaultChange));
|
newDef->getDefaultRolesWidgets().at(role)->blockSignals(true);
|
||||||
|
newDef->getEndpointHandler()->assignRoles(role);
|
||||||
|
QCoreApplication::instance()->postEvent(newDef->getDefaultRolesWidgets().at(role), new QEvent((QEvent::Type)CustomQEvent::EndpointDefaultChange));
|
||||||
|
uint8_t newDefIdx = newDef->getIndex();
|
||||||
|
uint8_t newDefRoles = newDef->getEndpointHandler()->getRoles();
|
||||||
|
if (newDefRoles == Roles::ROLE_ALL) {
|
||||||
|
newDef->setIndex(0);
|
||||||
|
this->ews[0] = newDef;
|
||||||
|
QCoreApplication::instance()->postEvent(newDef->getDefaultRolesWidgets().at(Roles::ROLE_ALL), new QEvent((QEvent::Type)CustomQEvent::EndpointDefaultChange));
|
||||||
|
} else if ((newDefRoles & Roles::ROLE_MULTIMEDIA) ||
|
||||||
|
(newDefRoles & Roles::ROLE_CONSOLE)){ newDef->setIndex(0);
|
||||||
|
this->ews[0] = newDef;
|
||||||
|
} else if (newDefRoles & Roles::ROLE_COMMUNICATIONS) { newDef->setIndex(1);
|
||||||
|
this->ews[1] = newDef;}
|
||||||
|
log_debugcpp("newDef new idx: " + std::to_string(newDef->getIndex()));
|
||||||
|
newDef->getDefaultRolesWidgets().at(role)->blockSignals(false);
|
||||||
|
|
||||||
}
|
oldDef->getDefaultRolesWidgets().at(role)->blockSignals(true);
|
||||||
|
uint8_t oldDefRoles = oldDef->getEndpointHandler()->getRoles();
|
||||||
|
if (oldDefRoles == Roles::ROLE_ALL) QCoreApplication::instance()->postEvent(oldDef->getDefaultRolesWidgets().at(Roles::ROLE_ALL), new QEvent((QEvent::Type)CustomQEvent::EndpointDefaultChange));
|
||||||
|
oldDef->getEndpointHandler()->removeRoles(role);
|
||||||
|
QCoreApplication::instance()->postEvent(oldDef->getDefaultRolesWidgets().at(role), new QEvent((QEvent::Type)CustomQEvent::EndpointDefaultChange));
|
||||||
|
oldDefRoles = oldDef->getEndpointHandler()->getRoles();
|
||||||
|
//this->ews[oldDef->getIndex()] = nullptr;
|
||||||
|
if ((oldDefRoles & Roles::ROLE_MULTIMEDIA) &&
|
||||||
|
(oldDefRoles & Roles::ROLE_CONSOLE)) { this-> ews[0] = oldDef;
|
||||||
|
oldDef->setIndex(0);
|
||||||
|
} else if (oldDefRoles & Roles::ROLE_COMMUNICATIONS) { this-> ews[1] = oldDef;
|
||||||
|
oldDef->setIndex(1);
|
||||||
|
} else { if (newDefIdx > 1) { this->ews[newDefIdx] = oldDef;
|
||||||
|
oldDef->setIndex(newDefIdx);
|
||||||
|
} else { this->ews.push_back(oldDef);
|
||||||
|
oldDef->setIndex(this->ews.size() - 1);
|
||||||
|
} }
|
||||||
|
log_debugcpp("oldDef new idx: " + std::to_string(oldDef->getIndex()));
|
||||||
|
oldDef->getDefaultRolesWidgets().at(role)->blockSignals(false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -809,18 +826,18 @@ void MainWindow::reloadEndpointWidgets() {
|
||||||
size_t i = 2;
|
size_t i = 2;
|
||||||
ews.resize(2);
|
ews.resize(2);
|
||||||
//widgetLayout->addItem(&lastRowSpacer, i++, 0);
|
//widgetLayout->addItem(&lastRowSpacer, i++, 0);
|
||||||
for (size_t epwIndex = 0; i < (osh->getPlaybackEndpointHandlers().size()); i++) {
|
for (size_t epwIndex = 2; i < (osh->getPlaybackEndpointHandlers().size()); i++) {
|
||||||
if (osh->getPlaybackEndpointHandlers().at(i)->getState() == EndpointState::ENDPOINT_ACTIVE){
|
if (osh->getPlaybackEndpointHandlers().at(i)->getState() == EndpointState::ENDPOINT_ACTIVE){
|
||||||
log_debugcpp("EPWidget creation");
|
log_debugcpp("EPWidget creation");
|
||||||
//osh->getPlaybackEndpointHandlers().at(i)->getCallbackInfo()->caller = osh->getGuid();
|
//osh->getPlaybackEndpointHandlers().at(i)->getCallbackInfo()->caller = osh->getGuid();
|
||||||
EndpointWidget *epw = new EndpointWidget(epwIndex, osh->getPlaybackEndpointHandlers().at(i), widget);
|
EndpointWidget *epw = new EndpointWidget(osh->getPlaybackEndpointHandlers().at(i), widget);
|
||||||
if ((epw->getEndpointHandler()->getRoles() & Roles::ROLE_ALL) ||
|
if ((epw->getEndpointHandler()->getRoles() == Roles::ROLE_ALL) ||
|
||||||
(epw->getEndpointHandler()->getRoles() & Roles::ROLE_MULTIMEDIA))
|
(epw->getEndpointHandler()->getRoles() & Roles::ROLE_MULTIMEDIA))
|
||||||
{ ews[0] = epw; widgetLayout->addWidget(epw, 0, 0); }
|
{ ews[0] = epw; widgetLayout->addWidget(epw, 0, 0); epw->setIndex(0); }
|
||||||
else if (epw->getEndpointHandler()->getRoles() & Roles::ROLE_CONSOLE)
|
else if (epw->getEndpointHandler()->getRoles() & Roles::ROLE_COMMUNICATIONS)
|
||||||
{ ews[0] = epw; widgetLayout->addWidget(epw, 1, 0); }
|
{ ews[1] = epw; widgetLayout->addWidget(epw, 1, 0); epw->setIndex(1); }
|
||||||
else {
|
else {
|
||||||
epwIndex++;
|
epw->setIndex(epwIndex++);
|
||||||
//alfinal estoes solopara inicializarlmao
|
//alfinal estoes solopara inicializarlmao
|
||||||
ews.push_back(epw);
|
ews.push_back(epw);
|
||||||
widgetLayout->addWidget(epw, i, 0); }
|
widgetLayout->addWidget(epw, i, 0); }
|
||||||
|
|
|
||||||
|
|
@ -124,7 +124,7 @@ class EndpointWidget : public QWidget {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
EndpointWidget(uint64_t idx, EndpointHandler* eph, QWidget *parent = nullptr);
|
EndpointWidget(EndpointHandler* eph, QWidget *parent = nullptr, uint64_t idx = INT_MAX);
|
||||||
//QSize minimumSizeHint() const override;
|
//QSize minimumSizeHint() const override;
|
||||||
//void setMinimum(uint64_t height, double heightRatio);
|
//void setMinimum(uint64_t height, double heightRatio);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue