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);
|
||||
}
|
||||
|
||||
void MainWindow::compose() {
|
||||
//todo: invalidate layout when adding sessions with window open
|
||||
void MainWindow::compose(bool isVisible) {
|
||||
//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
|
||||
*/
|
||||
|
|
@ -281,18 +284,16 @@ void MainWindow::compose() {
|
|||
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));
|
||||
|
||||
|
||||
uint64_t windowWidth = (((uint64_t)std::abs(screenRes.width())) * widthRatio);
|
||||
uint64_t screenHeight = (uint64_t)std::abs(screenRes.height());
|
||||
windowWidth = (((uint64_t)std::abs(screenRes.width())) * widthRatio);
|
||||
screenHeight = (uint64_t)std::abs(screenRes.height());
|
||||
log_debugcpp("Window Width: " + std::to_string(windowWidth));
|
||||
log_to_file("Window Width: %d \n", windowWidth);
|
||||
|
||||
|
||||
this->createLayout(new QGridLayout());
|
||||
this->scrollArea->setMaximumWidth((int)windowWidth);
|
||||
this->scrollArea->setMinimumWidth((int)windowWidth);
|
||||
this->mainMenuBar->setMinimumWidth((int)windowWidth);
|
||||
this->mainMenuBar->setMaximumWidth((int)windowWidth);
|
||||
|
||||
this->createLayout(new QGridLayout());
|
||||
for (auto *epw : ews) {
|
||||
if (!epw) continue;
|
||||
epw->updateChannelsVisibility();
|
||||
|
|
@ -309,7 +310,7 @@ void MainWindow::compose() {
|
|||
/*
|
||||
* Calculating window height
|
||||
*/
|
||||
uint64_t windowHeight = 0;
|
||||
windowHeight = 0;
|
||||
int left = 0, top = 0, right = 0, bottom = 0;
|
||||
for (int i = 0; i < 2; i++) {
|
||||
if (!ews[i]) continue;
|
||||
|
|
@ -321,13 +322,17 @@ void MainWindow::compose() {
|
|||
windowHeight += mainMenuBar->sizeHint().height();
|
||||
log_debugcpp("windowHeight final value: " + std::to_string(windowHeight));
|
||||
|
||||
//Undoing scrolling
|
||||
this->setUpdatesEnabled(true);
|
||||
if (!isVisible) {
|
||||
/*
|
||||
* Undoing scrolling
|
||||
*/
|
||||
scrollArea->verticalScrollBar()->setValue(0);
|
||||
|
||||
/*
|
||||
* Establishing initial window size and position
|
||||
*/
|
||||
setGeometry(setSizePosition(screen, windowWidth, windowHeight));
|
||||
}
|
||||
}
|
||||
|
||||
QScreen* MainWindow::getCurrentScreen() {
|
||||
|
|
@ -683,7 +688,6 @@ EndpointWidget::EndpointWidget(EndpointHandler* eph, QWidget *parent, uint64_t i
|
|||
eph->getSessionHandlers().at(i)->setFrontIndex(i);
|
||||
}
|
||||
|
||||
|
||||
/* Add/Remove SessionWidget callback */
|
||||
eph->setAddSessionWidgetFunction([this](SessionHandler* 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();
|
||||
for (QWidget *widget : topLevelWidgets) {
|
||||
if (qobject_cast<MainWindow*>(widget)) {
|
||||
double widthRatio = ((MainWindow*)widget)->widthRatio;
|
||||
double dpr = ((MainWindow*)widget)->dpr;
|
||||
sw->calculateSize((std::abs(this->screen()->geometry().width()) * widthRatio) * dpr,
|
||||
std::abs(this->screen()->geometry().height()));
|
||||
QCoreApplication::instance()->postEvent
|
||||
(widget, new QEvent((QEvent::Type)CustomQEvent::RecomposeMainWindow));
|
||||
}
|
||||
}
|
||||
this->widgetLayout->addWidget(sw, row, 0, 1, 4);
|
||||
|
|
@ -768,7 +770,7 @@ void MainWindow::customEvent(QEvent* ev) {
|
|||
this->addEndpointWidget((CustomWidgetEvent<EndpointHandler*>*)ev);
|
||||
} else if (ev->type() == (QEvent::Type)CustomQEvent::RecomposeMainWindow) {
|
||||
ev->setAccepted(true);
|
||||
if (this->isVisible()) this->compose();
|
||||
if (this->isVisible()) this->compose(true);
|
||||
} else if (ev->type() == (QEvent::Type)CustomQEvent::EndpointRoleChange) {
|
||||
ev->setAccepted(true);
|
||||
this->flushRoleChanges();
|
||||
|
|
@ -1327,7 +1329,7 @@ void MainWindow::trayIconActivated(QSystemTrayIcon::ActivationReason reason) {
|
|||
case QSystemTrayIcon::Trigger:
|
||||
if (!this->isVisible() && !recentlyClosed) {
|
||||
log_to_file("Recently Closed: %d \n", recentlyClosed);
|
||||
this->compose();
|
||||
this->compose(false);
|
||||
this->showNormal();
|
||||
this->activateWindow();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -183,7 +183,7 @@ class MainWindow : public QMainWindow {
|
|||
public:
|
||||
MainWindow(QWidget *parent = nullptr);
|
||||
void reloadEndpointWidgets();
|
||||
void compose();
|
||||
void compose(bool isVisible);
|
||||
void updateColor(uint8_t r, uint8_t g, uint8_t b, uint8_t a);
|
||||
|
||||
protected:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue