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));
|
||||
|
||||
std::wstring command = L"SoundVolumeView.exe /SetDefault " + endpointId + L" ";
|
||||
std::wstring troublePair = L"0";
|
||||
std::wstring troublePair = L"1";
|
||||
switch (role) {
|
||||
case Roles::ROLE_ALL:
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -310,7 +310,6 @@ void OverseerHandler::reviseEndpointShowing(std::wstring endpointId, EndpointSta
|
|||
Flows flow;
|
||||
if (!eph) {
|
||||
if (state ^ EndpointState::ENDPOINT_ACTIVE) return;
|
||||
//return;
|
||||
//flow = Flows::FLOW_CAPTURE;
|
||||
eph = osh->addEndpoint(endpointId, &flow);
|
||||
} else
|
||||
|
|
@ -319,7 +318,6 @@ void OverseerHandler::reviseEndpointShowing(std::wstring endpointId, EndpointSta
|
|||
//todo: mic done but disabled. Tab-kun will come...
|
||||
if (flow == Flows::FLOW_CAPTURE) return;
|
||||
|
||||
|
||||
if(eph && EndpointState::ENDPOINT_ACTIVE & state) {
|
||||
this->addEndpointWidget(eph);
|
||||
} else if (eph && eph->getFrontVisibilityState() == EndpointState::ENDPOINT_ACTIVE){
|
||||
|
|
|
|||
|
|
@ -295,7 +295,7 @@ void ChannelWidget::updateChannel(int channel) {
|
|||
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
|
||||
row = 0;
|
||||
this->idx = idx;
|
||||
|
|
@ -520,7 +520,7 @@ void MainWindow::removeEndpointWidget(CustomWidgetEvent<uint64_t>* 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);
|
||||
this->widgetLayout->addWidget(epw);
|
||||
ews.push_back(epw);
|
||||
|
|
@ -621,7 +621,7 @@ EndpointHandler* EndpointWidget::getEndpointHandler(){
|
|||
|
||||
void EndpointWidget::setIndex(uint64_t idx){
|
||||
this->idx = idx;
|
||||
this->eph->setFrontVisibilityInfo(EndpointState::ENDPOINT_ACTIVE, this->idx);
|
||||
this->eph->setState(EndpointState::ENDPOINT_ACTIVE, this->idx);
|
||||
}
|
||||
|
||||
uint64_t EndpointWidget::getIndex(){
|
||||
|
|
@ -733,41 +733,58 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) {
|
|||
* Set of function callback definitons for EndpointSituationCallback
|
||||
*/
|
||||
osh->setChangeFrontDefaultsFunction([this](Roles role, std::wstring endpointId) {
|
||||
for (auto epw : this->ews) {
|
||||
/*
|
||||
* Is this the new default endpoint?
|
||||
*/
|
||||
EndpointWidget *newDef = nullptr, *oldDef = nullptr;
|
||||
for (int i = 0; i < ews.size(); i++) {
|
||||
auto epw = this->ews.at(i);
|
||||
if (!epw) continue;
|
||||
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
|
||||
epw->getDefaultRolesWidgets().at(role)->blockSignals(true);
|
||||
epw->getEndpointHandler()->assignRoles(role);
|
||||
epw->getDefaultRolesWidgets().at(role)->blockSignals(false);
|
||||
QCoreApplication::instance()->postEvent(epw->getDefaultRolesWidgets().at(role), new QEvent((QEvent::Type)CustomQEvent::EndpointDefaultChange));
|
||||
//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));
|
||||
newDef = epw;
|
||||
continue; }
|
||||
if (epw->getEndpointHandler()->getRoles() & role) {
|
||||
oldDef = epw;
|
||||
continue; }
|
||||
}
|
||||
|
||||
epw->getDefaultRolesWidgets().at(role)->blockSignals(true);
|
||||
//Same as before. ini-san will come...
|
||||
epw->getEndpointHandler()->removeRoles(role);
|
||||
epw->getDefaultRolesWidgets().at(role)->blockSignals(false);
|
||||
QCoreApplication::instance()->postEvent(epw->getDefaultRolesWidgets().at(role), new QEvent((QEvent::Type)CustomQEvent::EndpointDefaultChange));
|
||||
//debug if (role != Roles::ROLE_COMMUNICATIONS) return;
|
||||
if (oldDef && newDef) {
|
||||
this->ews.at(oldDef->getIndex()) = nullptr;
|
||||
this->ews.at(newDef->getIndex()) = nullptr;
|
||||
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;
|
||||
ews.resize(2);
|
||||
//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){
|
||||
log_debugcpp("EPWidget creation");
|
||||
//osh->getPlaybackEndpointHandlers().at(i)->getCallbackInfo()->caller = osh->getGuid();
|
||||
EndpointWidget *epw = new EndpointWidget(epwIndex, osh->getPlaybackEndpointHandlers().at(i), widget);
|
||||
if ((epw->getEndpointHandler()->getRoles() & Roles::ROLE_ALL) ||
|
||||
EndpointWidget *epw = new EndpointWidget(osh->getPlaybackEndpointHandlers().at(i), widget);
|
||||
if ((epw->getEndpointHandler()->getRoles() == Roles::ROLE_ALL) ||
|
||||
(epw->getEndpointHandler()->getRoles() & Roles::ROLE_MULTIMEDIA))
|
||||
{ ews[0] = epw; widgetLayout->addWidget(epw, 0, 0); }
|
||||
else if (epw->getEndpointHandler()->getRoles() & Roles::ROLE_CONSOLE)
|
||||
{ ews[0] = epw; widgetLayout->addWidget(epw, 1, 0); }
|
||||
{ ews[0] = epw; widgetLayout->addWidget(epw, 0, 0); epw->setIndex(0); }
|
||||
else if (epw->getEndpointHandler()->getRoles() & Roles::ROLE_COMMUNICATIONS)
|
||||
{ ews[1] = epw; widgetLayout->addWidget(epw, 1, 0); epw->setIndex(1); }
|
||||
else {
|
||||
epwIndex++;
|
||||
epw->setIndex(epwIndex++);
|
||||
//alfinal estoes solopara inicializarlmao
|
||||
ews.push_back(epw);
|
||||
widgetLayout->addWidget(epw, i, 0); }
|
||||
|
|
|
|||
|
|
@ -124,7 +124,7 @@ class EndpointWidget : public QWidget {
|
|||
Q_OBJECT
|
||||
|
||||
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;
|
||||
//void setMinimum(uint64_t height, double heightRatio);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue