fixed visuals when adding epw/sw while window is visible
This commit is contained in:
parent
53f9506115
commit
f1b734bea6
2 changed files with 28 additions and 26 deletions
|
|
@ -266,9 +266,12 @@ void MainWindow::updateColor(uint8_t r, uint8_t g, uint8_t b, uint8_t a) {
|
||||||
scrollArea->verticalScrollBar()->setPalette(pal);
|
scrollArea->verticalScrollBar()->setPalette(pal);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::compose() {
|
void MainWindow::compose(bool isVisible) {
|
||||||
//todo: invalidate layout when adding sessions with window open
|
|
||||||
//We need dynamically added child widgets to expand so that we know their height
|
//We need dynamically added child widgets to expand so that we know their height
|
||||||
|
this->setUpdatesEnabled(false);
|
||||||
|
uint64_t windowWidth;
|
||||||
|
uint64_t screenHeight;
|
||||||
|
uint64_t windowHeight;
|
||||||
/*
|
/*
|
||||||
* Setting correct widget widths and heights
|
* Setting correct widget widths and heights
|
||||||
*/
|
*/
|
||||||
|
|
@ -281,18 +284,16 @@ void MainWindow::compose() {
|
||||||
screenRes.getCoords(&srx1, &sry1, &srx2, &sry2);
|
screenRes.getCoords(&srx1, &sry1, &srx2, &sry2);
|
||||||
log_debugcpp("(for Percentage) Screen Res: " + std::to_string(srx1) + " " + std::to_string(srx2)+" " + std::to_string(sry1) + " " + std::to_string(sry2));
|
log_debugcpp("(for Percentage) Screen Res: " + std::to_string(srx1) + " " + std::to_string(srx2)+" " + std::to_string(sry1) + " " + std::to_string(sry2));
|
||||||
|
|
||||||
|
windowWidth = (((uint64_t)std::abs(screenRes.width())) * widthRatio);
|
||||||
uint64_t windowWidth = (((uint64_t)std::abs(screenRes.width())) * widthRatio);
|
screenHeight = (uint64_t)std::abs(screenRes.height());
|
||||||
uint64_t screenHeight = (uint64_t)std::abs(screenRes.height());
|
|
||||||
log_debugcpp("Window Width: " + std::to_string(windowWidth));
|
log_debugcpp("Window Width: " + std::to_string(windowWidth));
|
||||||
log_to_file("Window Width: %d \n", windowWidth);
|
log_to_file("Window Width: %d \n", windowWidth);
|
||||||
|
|
||||||
|
|
||||||
this->createLayout(new QGridLayout());
|
|
||||||
this->scrollArea->setMaximumWidth((int)windowWidth);
|
this->scrollArea->setMaximumWidth((int)windowWidth);
|
||||||
this->scrollArea->setMinimumWidth((int)windowWidth);
|
this->scrollArea->setMinimumWidth((int)windowWidth);
|
||||||
this->mainMenuBar->setMinimumWidth((int)windowWidth);
|
this->mainMenuBar->setMinimumWidth((int)windowWidth);
|
||||||
this->mainMenuBar->setMaximumWidth((int)windowWidth);
|
this->mainMenuBar->setMaximumWidth((int)windowWidth);
|
||||||
|
|
||||||
|
this->createLayout(new QGridLayout());
|
||||||
for (auto *epw : ews) {
|
for (auto *epw : ews) {
|
||||||
if (!epw) continue;
|
if (!epw) continue;
|
||||||
epw->updateChannelsVisibility();
|
epw->updateChannelsVisibility();
|
||||||
|
|
@ -309,7 +310,7 @@ void MainWindow::compose() {
|
||||||
/*
|
/*
|
||||||
* Calculating window height
|
* Calculating window height
|
||||||
*/
|
*/
|
||||||
uint64_t windowHeight = 0;
|
windowHeight = 0;
|
||||||
int left = 0, top = 0, right = 0, bottom = 0;
|
int left = 0, top = 0, right = 0, bottom = 0;
|
||||||
for (int i = 0; i < 2; i++) {
|
for (int i = 0; i < 2; i++) {
|
||||||
if (!ews[i]) continue;
|
if (!ews[i]) continue;
|
||||||
|
|
@ -321,13 +322,17 @@ void MainWindow::compose() {
|
||||||
windowHeight += mainMenuBar->sizeHint().height();
|
windowHeight += mainMenuBar->sizeHint().height();
|
||||||
log_debugcpp("windowHeight final value: " + std::to_string(windowHeight));
|
log_debugcpp("windowHeight final value: " + std::to_string(windowHeight));
|
||||||
|
|
||||||
//Undoing scrolling
|
this->setUpdatesEnabled(true);
|
||||||
|
if (!isVisible) {
|
||||||
|
/*
|
||||||
|
* Undoing scrolling
|
||||||
|
*/
|
||||||
scrollArea->verticalScrollBar()->setValue(0);
|
scrollArea->verticalScrollBar()->setValue(0);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Establishing initial window size and position
|
* Establishing initial window size and position
|
||||||
*/
|
*/
|
||||||
setGeometry(setSizePosition(screen, windowWidth, windowHeight));
|
setGeometry(setSizePosition(screen, windowWidth, windowHeight));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QScreen* MainWindow::getCurrentScreen() {
|
QScreen* MainWindow::getCurrentScreen() {
|
||||||
|
|
@ -683,7 +688,6 @@ EndpointWidget::EndpointWidget(EndpointHandler* eph, QWidget *parent, uint64_t i
|
||||||
eph->getSessionHandlers().at(i)->setFrontIndex(i);
|
eph->getSessionHandlers().at(i)->setFrontIndex(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Add/Remove SessionWidget callback */
|
/* Add/Remove SessionWidget callback */
|
||||||
eph->setAddSessionWidgetFunction([this](SessionHandler* sessionHandler) {
|
eph->setAddSessionWidgetFunction([this](SessionHandler* sessionHandler) {
|
||||||
QCoreApplication::instance()->postEvent(this, new CustomWidgetEvent<SessionHandler*>((QEvent::Type)CustomQEvent::SessionWidgetCreated, sessionHandler));
|
QCoreApplication::instance()->postEvent(this, new CustomWidgetEvent<SessionHandler*>((QEvent::Type)CustomQEvent::SessionWidgetCreated, sessionHandler));
|
||||||
|
|
@ -707,10 +711,8 @@ void EndpointWidget::addSessionWidget(CustomWidgetEvent<SessionHandler*>* ev){
|
||||||
const QWidgetList topLevelWidgets = QApplication::topLevelWidgets();
|
const QWidgetList topLevelWidgets = QApplication::topLevelWidgets();
|
||||||
for (QWidget *widget : topLevelWidgets) {
|
for (QWidget *widget : topLevelWidgets) {
|
||||||
if (qobject_cast<MainWindow*>(widget)) {
|
if (qobject_cast<MainWindow*>(widget)) {
|
||||||
double widthRatio = ((MainWindow*)widget)->widthRatio;
|
QCoreApplication::instance()->postEvent
|
||||||
double dpr = ((MainWindow*)widget)->dpr;
|
(widget, new QEvent((QEvent::Type)CustomQEvent::RecomposeMainWindow));
|
||||||
sw->calculateSize((std::abs(this->screen()->geometry().width()) * widthRatio) * dpr,
|
|
||||||
std::abs(this->screen()->geometry().height()));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this->widgetLayout->addWidget(sw, row, 0, 1, 4);
|
this->widgetLayout->addWidget(sw, row, 0, 1, 4);
|
||||||
|
|
@ -768,7 +770,7 @@ void MainWindow::customEvent(QEvent* ev) {
|
||||||
this->addEndpointWidget((CustomWidgetEvent<EndpointHandler*>*)ev);
|
this->addEndpointWidget((CustomWidgetEvent<EndpointHandler*>*)ev);
|
||||||
} else if (ev->type() == (QEvent::Type)CustomQEvent::RecomposeMainWindow) {
|
} else if (ev->type() == (QEvent::Type)CustomQEvent::RecomposeMainWindow) {
|
||||||
ev->setAccepted(true);
|
ev->setAccepted(true);
|
||||||
if (this->isVisible()) this->compose();
|
if (this->isVisible()) this->compose(true);
|
||||||
} else if (ev->type() == (QEvent::Type)CustomQEvent::EndpointRoleChange) {
|
} else if (ev->type() == (QEvent::Type)CustomQEvent::EndpointRoleChange) {
|
||||||
ev->setAccepted(true);
|
ev->setAccepted(true);
|
||||||
this->flushRoleChanges();
|
this->flushRoleChanges();
|
||||||
|
|
@ -1327,7 +1329,7 @@ void MainWindow::trayIconActivated(QSystemTrayIcon::ActivationReason reason) {
|
||||||
case QSystemTrayIcon::Trigger:
|
case QSystemTrayIcon::Trigger:
|
||||||
if (!this->isVisible() && !recentlyClosed) {
|
if (!this->isVisible() && !recentlyClosed) {
|
||||||
log_to_file("Recently Closed: %d \n", recentlyClosed);
|
log_to_file("Recently Closed: %d \n", recentlyClosed);
|
||||||
this->compose();
|
this->compose(false);
|
||||||
this->showNormal();
|
this->showNormal();
|
||||||
this->activateWindow();
|
this->activateWindow();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -183,7 +183,7 @@ class MainWindow : public QMainWindow {
|
||||||
public:
|
public:
|
||||||
MainWindow(QWidget *parent = nullptr);
|
MainWindow(QWidget *parent = nullptr);
|
||||||
void reloadEndpointWidgets();
|
void reloadEndpointWidgets();
|
||||||
void compose();
|
void compose(bool isVisible);
|
||||||
void updateColor(uint8_t r, uint8_t g, uint8_t b, uint8_t a);
|
void updateColor(uint8_t r, uint8_t g, uint8_t b, uint8_t a);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue