From 02ad375017ed4e62f16f5d0ff326be64d11c24f0 Mon Sep 17 00:00:00 2001 From: Arin Alex Date: Wed, 24 Jan 2018 20:59:53 +0300 Subject: [PATCH] Hide & Show DocWidgets fixed --- limereport/lrreportdesignwindow.cpp | 45 +++++++++++++++++++++++++---- limereport/lrreportdesignwindow.h | 4 +++ 2 files changed, 44 insertions(+), 5 deletions(-) diff --git a/limereport/lrreportdesignwindow.cpp b/limereport/lrreportdesignwindow.cpp index b4e7801..a969617 100644 --- a/limereport/lrreportdesignwindow.cpp +++ b/limereport/lrreportdesignwindow.cpp @@ -659,14 +659,24 @@ void ReportDesignWindow::writePosition() { settings()->beginGroup("DesignerWindow"); settings()->setValue("Geometry",saveGeometry()); - settings()->setValue("State",saveState()); +// settings()->setValue("State",saveState()); settings()->endGroup(); } +void ReportDesignWindow::setDocWidgetsVisibility(bool visible) +{ + if (!m_hideLeftPanel->isChecked()) + hideDockWidgets(Qt::LeftDockWidgetArea,!visible); + if (!m_hideRightPanel->isChecked()) + hideDockWidgets(Qt::RightDockWidgetArea,!visible); +} + void ReportDesignWindow::writeState() { settings()->beginGroup("DesignerWindow"); + setDocWidgetsVisibility(true); + m_editorsStates[m_editorTabType] = saveState(); settings()->setValue("PageEditorsState", m_editorsStates[ReportDesignWidget::Page]); settings()->setValue("DialogEditorsState", m_editorsStates[ReportDesignWidget::Dialog]); @@ -1297,6 +1307,8 @@ void ReportDesignWindow::slotActivePageChanged() #endif } + setDocWidgetsVisibility(true); + m_editorsStates[m_editorTabType] = saveState(); m_editorTabType = m_reportDesignWidget->activeTabType(); @@ -1307,6 +1319,7 @@ void ReportDesignWindow::slotActivePageChanged() showDefaultToolBars(); } + setDocWidgetsVisibility(false); } void ReportDesignWindow::renderStarted() @@ -1350,20 +1363,42 @@ bool ReportDesignWindow::isDockAreaVisible(Qt::DockWidgetArea area){ void ReportDesignWindow::hideDockWidgets(Qt::DockWidgetArea area, bool value){ QList dockWidgets = findChildren(); + QMap* currentDocState = 0; + + switch (area) { + case Qt::LeftDockWidgetArea: + if (value) + m_leftDocVisibleState.clear(); + currentDocState = &m_leftDocVisibleState; + break; + case Qt::RightDockWidgetArea: + if (value) + m_rightDocVisibleState.clear(); + currentDocState = &m_rightDocVisibleState; + default: + break; + } + foreach (QDockWidget* dw, dockWidgets) { - if (dockWidgetArea(dw) == area) - value ? dw->show(): dw->hide(); + if (dockWidgetArea(dw) == area){ + if (!value){ + if (currentDocState->value(dw)) dw->show(); + } else { + currentDocState->insert(dw, dw->isVisible()); + dw->hide(); + } + } } } void ReportDesignWindow::slotHideLeftPanel(bool value) { - hideDockWidgets(Qt::LeftDockWidgetArea,value); + hideDockWidgets(Qt::LeftDockWidgetArea,!value); } void ReportDesignWindow::slotHideRightPanel(bool value) { - hideDockWidgets(Qt::RightDockWidgetArea,value); + hideDockWidgets(Qt::RightDockWidgetArea,!value); } void ReportDesignWindow::slotEditSettings() diff --git a/limereport/lrreportdesignwindow.h b/limereport/lrreportdesignwindow.h index 1abfcd8..6f3dba6 100644 --- a/limereport/lrreportdesignwindow.h +++ b/limereport/lrreportdesignwindow.h @@ -131,6 +131,8 @@ protected: void moveEvent(QMoveEvent *); void hideDockWidgets(Qt::DockWidgetArea area, bool value); bool isDockAreaVisible(Qt::DockWidgetArea area); + void setDocWidgetsVisibility(bool visible); + private: void initReportEditor(ReportEnginePrivate* report); void createActions(); @@ -268,6 +270,8 @@ private: QVector m_pageTools; QVector m_dialogTools; bool m_reportItemIsLocked; + QMap m_leftDocVisibleState; + QMap m_rightDocVisibleState; };