From 805e97946ed8e72fc5c54785fb55fd8298b85253 Mon Sep 17 00:00:00 2001 From: Uwe Kindler Date: Tue, 13 Feb 2018 07:28:38 +0100 Subject: [PATCH] Fixed some issues with restoreState function --- .settings/language.settings.xml | 2 +- demo/mainwindow.cpp | 10 ++++++++++ demo/mainwindow.h | 13 +++++++++++++ src/DockContainerWidget.cpp | 1 - src/DockManager.cpp | 4 ++-- src/FloatingDockContainer.cpp | 5 +++-- 6 files changed, 29 insertions(+), 6 deletions(-) diff --git a/.settings/language.settings.xml b/.settings/language.settings.xml index 05c71b6..ef6f6a9 100644 --- a/.settings/language.settings.xml +++ b/.settings/language.settings.xml @@ -2,7 +2,7 @@ - + diff --git a/demo/mainwindow.cpp b/demo/mainwindow.cpp index 4ac1ddc..a9d6bb2 100644 --- a/demo/mainwindow.cpp +++ b/demo/mainwindow.cpp @@ -2,6 +2,7 @@ #include "ui_mainwindow.h" +#include #include #include @@ -14,6 +15,7 @@ #include #include #include +#include #include "DockManager.h" #include "DockWidget.h" @@ -90,6 +92,14 @@ MainWindow::MainWindow(QWidget *parent) : ui->toolBar->addAction(ui->actionRestoreState); ui->actionRestoreState->setIcon(style()->standardIcon(QStyle::SP_DialogOpenButton)); + m_SavePerspectiveAction = new QAction("Save Perspective", this); + m_PerspectiveListAction = new QWidgetAction(this); + m_PerspectiveComboBox = new QComboBox(this); + m_PerspectiveListAction->setDefaultWidget(m_PerspectiveComboBox); + ui->toolBar->addSeparator(); + ui->toolBar->addAction(m_PerspectiveListAction); + ui->toolBar->addAction(m_SavePerspectiveAction); + m_DockManager = new ads::CDockManager(this); createContent(); // Default window geometry diff --git a/demo/mainwindow.h b/demo/mainwindow.h index 0cec326..391e99b 100644 --- a/demo/mainwindow.h +++ b/demo/mainwindow.h @@ -1,6 +1,10 @@ #ifndef MAINWINDOW_H #define MAINWINDOW_H +#include +#include +#include + #include #include "DockManager.h" @@ -8,11 +12,20 @@ namespace Ui { class MainWindow; } +/** + * Simple main window for demo + */ class MainWindow : public QMainWindow { Q_OBJECT +private: + QAction* m_SavePerspectiveAction; + QWidgetAction* m_PerspectiveListAction; + QComboBox* m_PerspectiveComboBox; + protected: virtual void closeEvent(QCloseEvent* event) override; +; public: explicit MainWindow(QWidget *parent = 0); virtual ~MainWindow(); diff --git a/src/DockContainerWidget.cpp b/src/DockContainerWidget.cpp index 0ec1163..f6694a4 100644 --- a/src/DockContainerWidget.cpp +++ b/src/DockContainerWidget.cpp @@ -1002,7 +1002,6 @@ bool CDockContainerWidget::restoreState(QXmlStreamReader& s, bool Testing) { CFloatingDockContainer* FloatingWidget = internal::findParent(this); FloatingWidget->restoreGeometry(Geometry); - FloatingWidget->show(); } } diff --git a/src/DockManager.cpp b/src/DockManager.cpp index dd27845..7c190d5 100644 --- a/src/DockManager.cpp +++ b/src/DockManager.cpp @@ -346,9 +346,9 @@ bool CDockManager::restoreState(const QByteArray &state, int version) { DockWidget->flagAsUnassigned(); } - else if (!DockWidget->property("closed").toBool()) + else { - DockWidget->toggleView(true); + DockWidget->toggleView(!DockWidget->property("closed").toBool()); } } diff --git a/src/FloatingDockContainer.cpp b/src/FloatingDockContainer.cpp index d29be25..3d7ac45 100644 --- a/src/FloatingDockContainer.cpp +++ b/src/FloatingDockContainer.cpp @@ -300,15 +300,16 @@ void CFloatingDockContainer::moveEvent(QMoveEvent *event) //============================================================================ void CFloatingDockContainer::closeEvent(QCloseEvent *event) { + std::cout << "closeEvent" << std::endl; d->setDraggingActive(false); QWidget::closeEvent(event); - } //============================================================================ void CFloatingDockContainer::hideEvent(QHideEvent *event) { + std::cout << "hideEvent" << std::endl; QWidget::hideEvent(event); auto OpenDockAreas = d->DockContainer->openedDockAreas(); for (auto DockArea : OpenDockAreas) @@ -316,7 +317,7 @@ void CFloatingDockContainer::hideEvent(QHideEvent *event) auto OpenDockWidgets = DockArea->openedDockWidgets(); for (auto DockWidget : OpenDockWidgets) { - DockWidget->setToggleViewActionChecked(false); + DockWidget->toggleView(false); } } }