fixed visual artifact when add/remove sessions while window open

This commit is contained in:
Hane 2024-05-08 20:46:17 +02:00
commit cb320da8cd
2 changed files with 12 additions and 4 deletions

View file

@ -628,18 +628,21 @@ EndpointWidget::EndpointWidget(EndpointHandler* eph, QWidget *parent, uint64_t i
} }
void EndpointWidget::addSessionWidget(CustomWidgetEvent<SessionHandler*>* ev){ void EndpointWidget::addSessionWidget(CustomWidgetEvent<SessionHandler*>* ev){
this->setUpdatesEnabled(false);
uint64_t index = this->sessionWidgets.size(); uint64_t index = this->sessionWidgets.size();
SessionWidget* sw = new SessionWidget(index, ev->payload, this); SessionWidget* sw = new SessionWidget(index, ev->payload, this);
ev->payload->setFrontIndex(index); ev->payload->setFrontIndex(index);
sw->calculateSize(currentWidth, currentHeight);
this->widgetLayout->addWidget(sw, row, 0, 1, 4); this->widgetLayout->addWidget(sw, row, 0, 1, 4);
row++; row++;
sessionWidgets.push_back(sw); sessionWidgets.push_back(sw);
this->setUpdatesEnabled(true);
return; return;
} }
void EndpointWidget::removeSessionWidget(CustomWidgetEvent<SessionHandler*>* ev){ void EndpointWidget::removeSessionWidget(CustomWidgetEvent<SessionHandler*>* ev){
this->setUpdatesEnabled(false);
uint64_t i = ev->payload->getFrontIndex(); uint64_t i = ev->payload->getFrontIndex();
SessionWidget* deceased = sessionWidgets.at(i); SessionWidget* deceased = sessionWidgets.at(i);
deceased->setParent(nullptr); deceased->setParent(nullptr);
@ -649,6 +652,7 @@ void EndpointWidget::removeSessionWidget(CustomWidgetEvent<SessionHandler*>* ev)
sessionWidgets.at(i) = nullptr; sessionWidgets.at(i) = nullptr;
//row--; //row--;
ev->payload->setFrontIndex(INT_MAX); ev->payload->setFrontIndex(INT_MAX);
this->setUpdatesEnabled(true);
//this->sessionWidgetsUpdateTimer->start(); //this->sessionWidgetsUpdateTimer->start();
return; return;
} }
@ -736,6 +740,8 @@ void MainWindow::reorderEndpointWidgetCollection() {
void EndpointWidget::calculateSize(uint64_t width, uint64_t height) { void EndpointWidget::calculateSize(uint64_t width, uint64_t height) {
/* og 1080p 120% testing values */ /* og 1080p 120% testing values */
this->currentWidth = width;
this->currentHeight = height;
log_to_file("[EndpointWidget %s sizes]\n", converter.to_bytes(this->getEndpointHandler()->getName()).c_str()); log_to_file("[EndpointWidget %s sizes]\n", converter.to_bytes(this->getEndpointHandler()->getName()).c_str());
log_to_file("Params: {Width: %u Height: %u}\n", width, height); log_to_file("Params: {Width: %u Height: %u}\n", width, height);
this->mainLabel->setMaximumWidth((int)(width * 0.50) /* 1080p 120%*/); this->mainLabel->setMaximumWidth((int)(width * 0.50) /* 1080p 120%*/);
@ -1068,11 +1074,11 @@ void MainWindow::reloadEndpointWidgets() {
log_wdebugcpp(L"epw name: " + epw->getEndpointHandler()->getName()); log_wdebugcpp(L"epw name: " + epw->getEndpointHandler()->getName());
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; { ews[0] = epw; epw->setIndex(0); }
else if (epw->getEndpointHandler()->getRoles() & Roles::ROLE_COMMUNICATIONS) else if (epw->getEndpointHandler()->getRoles() & Roles::ROLE_COMMUNICATIONS)
ews[1] = epw; { ews[1] = epw; epw->setIndex(1); }
else else
ews.push_back(epw); { ews.push_back(epw); epw->setIndex(ews.size() - 1); }
} }
} }
//todo: ya no está aquí tirao como tal, y de hecho, no ha fallado de la manera arriba descrita //todo: ya no está aquí tirao como tal, y de hecho, no ha fallado de la manera arriba descrita

View file

@ -201,6 +201,8 @@ private:
ChannelWidget* cw; ChannelWidget* cw;
std::vector<SessionWidget*> sessionWidgets; std::vector<SessionWidget*> sessionWidgets;
QSize minimum; QSize minimum;
uint64_t currentWidth = 1;
uint64_t currentHeight = 1;
//std::vector<EndpointHandler*> *ephs; //std::vector<EndpointHandler*> *ephs;
//std::vector<QSlider> *sliders; //std::vector<QSlider> *sliders;