fixed lots of edge cases revolving role changes
This commit is contained in:
parent
0a301fb9bf
commit
109330dbbd
2 changed files with 28 additions and 22 deletions
|
|
@ -626,6 +626,7 @@ EndpointWidget::EndpointWidget(EndpointHandler* eph, QWidget *parent, uint64_t i
|
|||
defaultRolesCheckBoxes.at(role)->setDisabled(assignedRoles optor role ? true : false); \
|
||||
defaultRolesCheckBoxes.at(role)->setText(STRING_##role); \
|
||||
connect(defaultRolesCheckBoxes.at(role), &QCheckBox::stateChanged,[this] { \
|
||||
defaultRolesCheckBoxes.at(role)->setChecked(!(defaultRolesCheckBoxes.at(role)->isChecked())); \
|
||||
this->eph->setRoles(role); \
|
||||
}); \
|
||||
widgetLayout->addWidget(defaultRolesCheckBoxes.at(role), row, col++); \
|
||||
|
|
@ -1200,6 +1201,7 @@ void MainWindow::flushRoleChanges() {
|
|||
|
||||
EndpointWidget *newDef = nullptr, *oldDef = nullptr;
|
||||
for (uint64_t i = 0; i < ews.size(); i++) {
|
||||
if(newDef && oldDef) break;
|
||||
auto epw = this->ews.at(i);
|
||||
if (!epw) continue;
|
||||
if (epw->getEndpointHandler()->getId() == change.second) {
|
||||
|
|
@ -1218,20 +1220,28 @@ void MainWindow::flushRoleChanges() {
|
|||
}
|
||||
|
||||
void MainWindow::changeFrontDefaults(Roles role, EndpointWidget* newDef, EndpointWidget* oldDef) {
|
||||
//Sigh... I hope to get this right when librole is done...
|
||||
//todo: STILL BORKED. THEY'RE NOT FORFEITING THEIR OLD POSITION
|
||||
//debug if (role != Roles::ROLE_COMMUNICATIONS) return;
|
||||
//Sigh... MS's naive (non)API didn't help, but...
|
||||
//Since widgets are removed previously, they must be added back.
|
||||
//This produces unneeded vector size increases.
|
||||
//Also, there's no freaking way this must be this illegible.
|
||||
//TODO: Rewrite this method. Seriously. You'll have to get to, someday.
|
||||
if (newDef && !oldDef) {
|
||||
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 newDefCurRolesReversed = ~(newDef->getEndpointHandler()->getRoles());
|
||||
if(newDefCurRolesReversed & role) {
|
||||
newDef->getEndpointHandler()->assignRoles(role);
|
||||
QCoreApplication::instance()->sendEvent(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;
|
||||
//if (this->ews[1] && newDef->getEndpointHandler()->getId() == endpointId) this->ews[1] = nullptr;
|
||||
QCoreApplication::instance()->postEvent(newDef->getDefaultRolesWidgets().at(Roles::ROLE_ALL), new QEvent((QEvent::Type)CustomQEvent::EndpointDefaultChange));
|
||||
if(newDefCurRolesReversed & role) {
|
||||
newDef->getDefaultRolesWidgets().at(Roles::ROLE_ALL)->blockSignals(true);
|
||||
QCoreApplication::instance()->sendEvent(newDef->getDefaultRolesWidgets().at(Roles::ROLE_ALL), new QEvent((QEvent::Type)CustomQEvent::EndpointDefaultChange));
|
||||
newDef->getDefaultRolesWidgets().at(Roles::ROLE_ALL)->blockSignals(false);
|
||||
}
|
||||
} else if ((newDefRoles & Roles::ROLE_MULTIMEDIA) ||
|
||||
(newDefRoles & Roles::ROLE_CONSOLE)){
|
||||
newDef->setIndex(0);
|
||||
|
|
@ -1246,14 +1256,15 @@ void MainWindow::changeFrontDefaults(Roles role, EndpointWidget* newDef, Endpoin
|
|||
else if (oldDef && newDef) {
|
||||
newDef->getDefaultRolesWidgets().at(role)->blockSignals(true);
|
||||
newDef->getEndpointHandler()->assignRoles(role);
|
||||
QCoreApplication::instance()->postEvent(newDef->getDefaultRolesWidgets().at(role), new QEvent((QEvent::Type)CustomQEvent::EndpointDefaultChange));
|
||||
QCoreApplication::instance()->sendEvent(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;
|
||||
//if (this->ews[1] && newDef->getEndpointHandler()->getId() == endpointId) this->ews[1] = nullptr;
|
||||
QCoreApplication::instance()->postEvent(newDef->getDefaultRolesWidgets().at(Roles::ROLE_ALL), new QEvent((QEvent::Type)CustomQEvent::EndpointDefaultChange));
|
||||
newDef->getDefaultRolesWidgets().at(Roles::ROLE_ALL)->blockSignals(true);
|
||||
QCoreApplication::instance()->sendEvent(newDef->getDefaultRolesWidgets().at(Roles::ROLE_ALL), new QEvent((QEvent::Type)CustomQEvent::EndpointDefaultChange));
|
||||
newDef->getDefaultRolesWidgets().at(Roles::ROLE_ALL)->blockSignals(false);
|
||||
} else if ((newDefRoles & Roles::ROLE_MULTIMEDIA) ||
|
||||
(newDefRoles & Roles::ROLE_CONSOLE)){
|
||||
newDef->setIndex(0);
|
||||
|
|
@ -1267,9 +1278,13 @@ void MainWindow::changeFrontDefaults(Roles role, EndpointWidget* newDef, Endpoin
|
|||
|
||||
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));
|
||||
if (oldDefRoles == Roles::ROLE_ALL) {
|
||||
oldDef->getDefaultRolesWidgets().at(Roles::ROLE_ALL)->blockSignals(true);
|
||||
QCoreApplication::instance()->sendEvent(oldDef->getDefaultRolesWidgets().at(Roles::ROLE_ALL), new QEvent((QEvent::Type)CustomQEvent::EndpointDefaultChange));
|
||||
oldDef->getDefaultRolesWidgets().at(Roles::ROLE_ALL)->blockSignals(false);
|
||||
}
|
||||
oldDef->getEndpointHandler()->removeRoles(role);
|
||||
QCoreApplication::instance()->postEvent(oldDef->getDefaultRolesWidgets().at(role), new QEvent((QEvent::Type)CustomQEvent::EndpointDefaultChange));
|
||||
QCoreApplication::instance()->sendEvent(oldDef->getDefaultRolesWidgets().at(role), new QEvent((QEvent::Type)CustomQEvent::EndpointDefaultChange));
|
||||
oldDefRoles = oldDef->getEndpointHandler()->getRoles();
|
||||
//this->ews[oldDef->getIndex()] = nullptr;
|
||||
if ((oldDefRoles & Roles::ROLE_MULTIMEDIA) &&
|
||||
|
|
@ -1291,7 +1306,7 @@ void MainWindow::changeFrontDefaults(Roles role, EndpointWidget* newDef, Endpoin
|
|||
log_debugcpp("oldDef new idx: " + std::to_string(oldDef->getIndex()));
|
||||
oldDef->getDefaultRolesWidgets().at(role)->blockSignals(false);
|
||||
}
|
||||
QCoreApplication::instance()->postEvent
|
||||
QCoreApplication::instance()->sendEvent
|
||||
(this, new QEvent((QEvent::Type)CustomQEvent::RecomposeMainWindow));
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue