From 815ef927cba9129734b31d51913b7fd054163e49 Mon Sep 17 00:00:00 2001 From: Le Tan Date: Fri, 16 Sep 2022 17:53:57 +0800 Subject: [PATCH] MainWindow: fix content area expand --- src/widgets/dockwidgethelper.cpp | 11 ----------- src/widgets/dockwidgethelper.h | 3 --- src/widgets/mainwindow.cpp | 10 +++++++++- src/widgets/mainwindow.h | 2 ++ 4 files changed, 11 insertions(+), 15 deletions(-) diff --git a/src/widgets/dockwidgethelper.cpp b/src/widgets/dockwidgethelper.cpp index 84847878..76fda5db 100644 --- a/src/widgets/dockwidgethelper.cpp +++ b/src/widgets/dockwidgethelper.cpp @@ -490,17 +490,6 @@ void DockWidgetHelper::restoreDocks(const QStringList &p_visibleDocks) updateDockWidgetTabBar(); } -bool DockWidgetHelper::isAnyDockVisible() const -{ - const auto &keepDocks = ConfigMgr::getInst().getWidgetConfig().getMainWindowKeepDocksExpandingContentArea(); - for (const auto dock : m_docks) { - if (!dock->isFloating() && dock->isVisible() && !keepDocks.contains(dock->objectName())) { - return true; - } - } - return false; -} - QVector DockWidgetHelper::getVisibleNavigationItems() { m_navigationItems.clear(); diff --git a/src/widgets/dockwidgethelper.h b/src/widgets/dockwidgethelper.h index 4579fd1c..387cbce8 100644 --- a/src/widgets/dockwidgethelper.h +++ b/src/widgets/dockwidgethelper.h @@ -56,9 +56,6 @@ namespace vnotex void restoreDocks(const QStringList &p_visibleDocks); - // If there is any dock that does not belong to keep docks visible. - bool isAnyDockVisible() const; - // NavigationMode. protected: QVector getVisibleNavigationItems() Q_DECL_OVERRIDE; diff --git a/src/widgets/mainwindow.cpp b/src/widgets/mainwindow.cpp index d1885119..cb13c3c6 100644 --- a/src/widgets/mainwindow.cpp +++ b/src/widgets/mainwindow.cpp @@ -400,6 +400,9 @@ void MainWindow::closeEvent(QCloseEvent *p_event) } } + // Do not expand the content area. + setContentAreaExpanded(false); + saveStateAndGeometry(); } @@ -496,6 +499,11 @@ void MainWindow::resetStateAndGeometry() void MainWindow::setContentAreaExpanded(bool p_expanded) { + if (m_contentAreaExpanded == p_expanded) { + return; + } + + m_contentAreaExpanded = p_expanded; if (p_expanded) { // Store the state and hide. m_visibleDocksBeforeExpand = m_dockWidgetHelper.hideDocks(); @@ -507,7 +515,7 @@ void MainWindow::setContentAreaExpanded(bool p_expanded) bool MainWindow::isContentAreaExpanded() const { - return !m_dockWidgetHelper.isAnyDockVisible(); + return m_contentAreaExpanded; } void MainWindow::demoWidget() diff --git a/src/widgets/mainwindow.h b/src/widgets/mainwindow.h index f14fce09..aedefe3c 100644 --- a/src/widgets/mainwindow.h +++ b/src/widgets/mainwindow.h @@ -201,6 +201,8 @@ namespace vnotex Qt::WindowStates m_windowOldState = Qt::WindowMinimized; QStringList m_visibleDocksBeforeExpand; + + bool m_contentAreaExpanded = false; }; } // ns vnotex