poc recompose
This commit is contained in:
parent
d75cf405f1
commit
6c588d068f
1 changed files with 24 additions and 22 deletions
|
|
@ -215,11 +215,13 @@ void MainWindow::compose() {
|
||||||
log_debugcpp("Window Width: " + std::to_string(windowWidth));
|
log_debugcpp("Window Width: " + std::to_string(windowWidth));
|
||||||
|
|
||||||
this->createLayout(new QGridLayout());
|
this->createLayout(new QGridLayout());
|
||||||
this->setAttribute(Qt::WA_DontShowOnScreen, true);
|
/*
|
||||||
this->show();
|
* this->setAttribute(Qt::WA_DontShowOnScreen, true);
|
||||||
this->widget->layout()->update();
|
* this->show();
|
||||||
this->hide();
|
* this->widget->layout()->update();
|
||||||
this->setAttribute(Qt::WA_DontShowOnScreen, false);
|
* this->hide();
|
||||||
|
* this->setAttribute(Qt::WA_DontShowOnScreen, false);
|
||||||
|
*/
|
||||||
|
|
||||||
for (auto *epw : ews) {
|
for (auto *epw : ews) {
|
||||||
if (!epw) continue;
|
if (!epw) continue;
|
||||||
|
|
@ -668,6 +670,9 @@ void MainWindow::customEvent(QEvent* ev) {
|
||||||
} else if (ev->type() == (QEvent::Type)CustomQEvent::EndpointWidgetCreated) {
|
} else if (ev->type() == (QEvent::Type)CustomQEvent::EndpointWidgetCreated) {
|
||||||
ev->setAccepted(true);
|
ev->setAccepted(true);
|
||||||
this->addEndpointWidget((CustomWidgetEvent<EndpointHandler*>*)ev);
|
this->addEndpointWidget((CustomWidgetEvent<EndpointHandler*>*)ev);
|
||||||
|
} else if (ev->type() == (QEvent::Type)CustomQEvent::RecomposeMainWindow) {
|
||||||
|
ev->setAccepted(true);
|
||||||
|
this->compose();
|
||||||
}
|
}
|
||||||
QMainWindow::customEvent(ev);
|
QMainWindow::customEvent(ev);
|
||||||
}
|
}
|
||||||
|
|
@ -826,22 +831,22 @@ HeaderWidget::HeaderWidget(QWidget *parent) : QWidget(parent) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::createLayout(QGridLayout *newLayout) {
|
void MainWindow::createLayout(QGridLayout *newLayout) {
|
||||||
//int row = 0;
|
widgetLayout->removeItem(lastRowSpacer);
|
||||||
//QGridLayout *newLayout = new QGridLayout();
|
|
||||||
delete this->widgetLayout;
|
delete this->widgetLayout;
|
||||||
widget->setLayout(newLayout);
|
widget->setLayout(newLayout);
|
||||||
this->widgetLayout = newLayout;
|
this->widgetLayout = newLayout;
|
||||||
//this->reloadEndpointWidgets();
|
|
||||||
uint64_t i = 0;
|
uint64_t i = 0;
|
||||||
for (EndpointWidget *epw : ews) {
|
for (EndpointWidget *epw : ews) {
|
||||||
if (!epw) continue;
|
if (!epw) continue;
|
||||||
log_debugcpp("EPWidget positioning");
|
log_debugcpp("EPWidget positioning");
|
||||||
log_wdebugcpp(L"epw name: " + epw->getEndpointHandler()->getName());
|
log_wdebugcpp(L"epw name: " + epw->getEndpointHandler()->getName());
|
||||||
|
epw->setIndex(i);
|
||||||
this->widgetLayout->addWidget(epw, i++, 0);
|
this->widgetLayout->addWidget(epw, i++, 0);
|
||||||
}
|
}
|
||||||
|
widgetLayout->addItem(lastRowSpacer, i, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) {
|
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) {
|
||||||
//setWindowState(Qt::WindowFullScreen);
|
//setWindowState(Qt::WindowFullScreen);
|
||||||
//setCentralWidget(centralWidget);
|
//setCentralWidget(centralWidget);
|
||||||
|
|
@ -930,6 +935,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) {
|
||||||
*/
|
*/
|
||||||
osh->setChangeFrontDefaultsFunction([this](Roles role, std::wstring endpointId) {
|
osh->setChangeFrontDefaultsFunction([this](Roles role, std::wstring endpointId) {
|
||||||
//Sigh... I hope to get this right when librole is done...
|
//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;
|
EndpointWidget *newDef = nullptr, *oldDef = nullptr;
|
||||||
for (uint64_t i = 0; i < ews.size(); i++) {
|
for (uint64_t i = 0; i < ews.size(); i++) {
|
||||||
auto epw = this->ews.at(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()));
|
log_debugcpp("oldDef new idx: " + std::to_string(oldDef->getIndex()));
|
||||||
oldDef->getDefaultRolesWidgets().at(role)->blockSignals(false);
|
oldDef->getDefaultRolesWidgets().at(role)->blockSignals(false);
|
||||||
}
|
}
|
||||||
|
QCoreApplication::instance()->postEvent
|
||||||
|
(this, new QEvent((QEvent::Type)CustomQEvent::RecomposeMainWindow));
|
||||||
});
|
});
|
||||||
|
|
||||||
osh->setRemoveEndpointWidgetFunction([this](uint64_t index) {
|
osh->setRemoveEndpointWidgetFunction([this](uint64_t index) {
|
||||||
|
|
@ -1031,9 +1039,7 @@ void MainWindow::trayIconActivated(QSystemTrayIcon::ActivationReason reason) {
|
||||||
void MainWindow::reloadEndpointWidgets() {
|
void MainWindow::reloadEndpointWidgets() {
|
||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
ews.resize(2);
|
ews.resize(2);
|
||||||
//widgetLayout->addItem(&lastRowSpacer, i++, 0);
|
|
||||||
//todo: -log flag
|
//todo: -log flag
|
||||||
//std::wofstream log("log.txt");
|
|
||||||
for (size_t epwIndex = 2; 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");
|
||||||
|
|
@ -1043,19 +1049,15 @@ 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; widgetLayout->addWidget(epw, 0, 0); epw->setIndex(0); }
|
ews[0] = epw;
|
||||||
else if (epw->getEndpointHandler()->getRoles() & Roles::ROLE_COMMUNICATIONS)
|
else if (epw->getEndpointHandler()->getRoles() & Roles::ROLE_COMMUNICATIONS)
|
||||||
{ ews[1] = epw; widgetLayout->addWidget(epw, 1, 0); epw->setIndex(1); }
|
ews[1] = epw;
|
||||||
else {
|
else
|
||||||
epw->setIndex(epwIndex++);
|
ews.push_back(epw);
|
||||||
//alfinal estoes solopara inicializarlmao
|
|
||||||
ews.push_back(epw);
|
|
||||||
widgetLayout->addWidget(epw, i, 0); }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//todo:: tas aqui tirao, no me gustas y probablemente yo a ti tampoco
|
//todo: ya no está aquí tirao como tal, y de hecho, no ha fallado de la manera arriba descrita
|
||||||
//seguramente falle al querer rematar esto con redimensionar la ventana sólo
|
//pero ahora lo añado porque sí solo para garantizar que está y poder reusarlo luego lmao
|
||||||
//con los default endpoints en vista
|
|
||||||
widgetLayout->addItem(lastRowSpacer, i, 0);
|
widgetLayout->addItem(lastRowSpacer, i, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue