diff --git a/src/qt/qtclasses.cpp b/src/qt/qtclasses.cpp index 56fa131..12cb687 100644 --- a/src/qt/qtclasses.cpp +++ b/src/qt/qtclasses.cpp @@ -215,11 +215,13 @@ void MainWindow::compose() { log_debugcpp("Window Width: " + std::to_string(windowWidth)); this->createLayout(new QGridLayout()); - this->setAttribute(Qt::WA_DontShowOnScreen, true); - this->show(); - this->widget->layout()->update(); - this->hide(); - this->setAttribute(Qt::WA_DontShowOnScreen, false); + /* + * this->setAttribute(Qt::WA_DontShowOnScreen, true); + * this->show(); + * this->widget->layout()->update(); + * this->hide(); + * this->setAttribute(Qt::WA_DontShowOnScreen, false); + */ for (auto *epw : ews) { if (!epw) continue; @@ -668,6 +670,9 @@ void MainWindow::customEvent(QEvent* ev) { } else if (ev->type() == (QEvent::Type)CustomQEvent::EndpointWidgetCreated) { ev->setAccepted(true); this->addEndpointWidget((CustomWidgetEvent*)ev); + } else if (ev->type() == (QEvent::Type)CustomQEvent::RecomposeMainWindow) { + ev->setAccepted(true); + this->compose(); } QMainWindow::customEvent(ev); } @@ -826,22 +831,22 @@ HeaderWidget::HeaderWidget(QWidget *parent) : QWidget(parent) { } void MainWindow::createLayout(QGridLayout *newLayout) { - //int row = 0; - //QGridLayout *newLayout = new QGridLayout(); + widgetLayout->removeItem(lastRowSpacer); delete this->widgetLayout; widget->setLayout(newLayout); this->widgetLayout = newLayout; - //this->reloadEndpointWidgets(); + uint64_t i = 0; for (EndpointWidget *epw : ews) { if (!epw) continue; log_debugcpp("EPWidget positioning"); log_wdebugcpp(L"epw name: " + epw->getEndpointHandler()->getName()); + epw->setIndex(i); this->widgetLayout->addWidget(epw, i++, 0); - } + } + widgetLayout->addItem(lastRowSpacer, i, 0); } - MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { //setWindowState(Qt::WindowFullScreen); //setCentralWidget(centralWidget); @@ -930,6 +935,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { */ osh->setChangeFrontDefaultsFunction([this](Roles role, std::wstring endpointId) { //Sigh... I hope to get this right when librole is done... + //todo: STILL BORKED. THEY'RE NOT FORFEITING THEIR OLD POSITION EndpointWidget *newDef = nullptr, *oldDef = nullptr; for (uint64_t i = 0; i < ews.size(); i++) { auto epw = this->ews.at(i); @@ -992,6 +998,8 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { log_debugcpp("oldDef new idx: " + std::to_string(oldDef->getIndex())); oldDef->getDefaultRolesWidgets().at(role)->blockSignals(false); } + QCoreApplication::instance()->postEvent + (this, new QEvent((QEvent::Type)CustomQEvent::RecomposeMainWindow)); }); osh->setRemoveEndpointWidgetFunction([this](uint64_t index) { @@ -1031,9 +1039,7 @@ void MainWindow::trayIconActivated(QSystemTrayIcon::ActivationReason reason) { void MainWindow::reloadEndpointWidgets() { size_t i = 0; ews.resize(2); - //widgetLayout->addItem(&lastRowSpacer, i++, 0); //todo: -log flag - //std::wofstream log("log.txt"); for (size_t epwIndex = 2; i < (osh->getPlaybackEndpointHandlers().size()); i++) { if (osh->getPlaybackEndpointHandlers().at(i)->getState() == EndpointState::ENDPOINT_ACTIVE){ log_debugcpp("EPWidget creation"); @@ -1043,19 +1049,15 @@ void MainWindow::reloadEndpointWidgets() { log_wdebugcpp(L"epw name: " + epw->getEndpointHandler()->getName()); if ((epw->getEndpointHandler()->getRoles() == Roles::ROLE_ALL) || (epw->getEndpointHandler()->getRoles() & Roles::ROLE_MULTIMEDIA)) - { ews[0] = epw; widgetLayout->addWidget(epw, 0, 0); epw->setIndex(0); } + ews[0] = epw; else if (epw->getEndpointHandler()->getRoles() & Roles::ROLE_COMMUNICATIONS) - { ews[1] = epw; widgetLayout->addWidget(epw, 1, 0); epw->setIndex(1); } - else { - epw->setIndex(epwIndex++); - //alfinal estoes solopara inicializarlmao - ews.push_back(epw); - widgetLayout->addWidget(epw, i, 0); } + ews[1] = epw; + else + ews.push_back(epw); } } - //todo:: tas aqui tirao, no me gustas y probablemente yo a ti tampoco - //seguramente falle al querer rematar esto con redimensionar la ventana sólo - //con los default endpoints en vista + //todo: ya no está aquí tirao como tal, y de hecho, no ha fallado de la manera arriba descrita + //pero ahora lo añado porque sí solo para garantizar que está y poder reusarlo luego lmao widgetLayout->addItem(lastRowSpacer, i, 0); }