From ca6bcd4944f11b7fde5d198792278ab6233aadc1 Mon Sep 17 00:00:00 2001 From: peri4 Date: Mon, 21 Aug 2023 19:51:37 +0300 Subject: [PATCH] fix EMainWindow --- libs/application/emainwindow.cpp | 26 ++++++++++++++++---------- libs/application/emainwindow.h | 1 + 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/libs/application/emainwindow.cpp b/libs/application/emainwindow.cpp index 9de81e2..40dddb9 100644 --- a/libs/application/emainwindow.cpp +++ b/libs/application/emainwindow.cpp @@ -59,15 +59,7 @@ void EMainWindow::setRecentMenu(QMenu * m) { void EMainWindow::showEvent(QShowEvent * e) { QWidget::showEvent(e); initMenus(); - if (!first_show) return; - first_show = false; - QList docks(findChildren()); - for (QDockWidget * d: docks) { - connect(d, SIGNAL(dockLocationChanged(Qt::DockWidgetArea)), this, SLOT(changedDock())); - connect(d, SIGNAL(topLevelChanged(bool)), this, SLOT(changedDock())); - connect(d, SIGNAL(visibilityChanged(bool)), this, SLOT(changedDock())); - } - changedDock(); + initDocks(); } @@ -261,6 +253,20 @@ void EMainWindow::initMenus() { } +void EMainWindow::initDocks() { + QList docks(findChildren()); + for (QDockWidget * d: docks) { + static const char * pname = "__edock_inited__"; + if (d->property(pname).toBool()) continue; + d->setProperty(pname, true); + connect(d, SIGNAL(dockLocationChanged(Qt::DockWidgetArea)), this, SLOT(changedDock())); + connect(d, SIGNAL(topLevelChanged(bool)), this, SLOT(changedDock())); + connect(d, SIGNAL(visibilityChanged(bool)), this, SLOT(changedDock())); + } + changedDock(); +} + + void EMainWindow::initSession() { connect(&session, SIGNAL(loading(QPIConfig &)), this, SLOT(sessionLoading(QPIConfig &))); connect(&session, SIGNAL(saving(QPIConfig &)), this, SLOT(sessionSaving(QPIConfig &))); @@ -288,7 +294,7 @@ void EMainWindow::changedDock() { QSet invalid_tab_docks; QList tabs(findChildren()); QList docks = findChildren(); - QRect geom = geometry(); + QRect geom = rect(); // qDebug() << "### change" << docks.size() << tabs.size(); for (QTabBar * t: tabs) { if (!t->objectName().isEmpty() || t->isHidden()) continue; diff --git a/libs/application/emainwindow.h b/libs/application/emainwindow.h index d0d0b5d..63c7e75 100644 --- a/libs/application/emainwindow.h +++ b/libs/application/emainwindow.h @@ -120,6 +120,7 @@ protected: } void initMenus(); + void initDocks(); void initSession(); QAction action_show_all_tools, action_hide_all_tools, action_show_all_docks, action_hide_all_docks;