Fixed some issues with restoreState function

This commit is contained in:
Uwe Kindler 2018-02-13 07:28:38 +01:00
parent e878bb47ed
commit 805e97946e
6 changed files with 29 additions and 6 deletions

View File

@ -2,7 +2,7 @@
<project> <project>
<configuration id="cdt.managedbuild.toolchain.gnu.mingw.base.1119687795" name="Default"> <configuration id="cdt.managedbuild.toolchain.gnu.mingw.base.1119687795" name="Default">
<extension point="org.eclipse.cdt.core.LanguageSettingsProvider"> <extension point="org.eclipse.cdt.core.LanguageSettingsProvider">
<provider class="org.eclipse.cdt.managedbuilder.internal.language.settings.providers.GCCBuiltinSpecsDetectorMinGW" console="false" env-hash="-550644722333667955" id="org.eclipse.cdt.managedbuilder.core.GCCBuiltinSpecsDetectorMinGW" keep-relative-paths="false" name="CDT GCC Built-in Compiler Settings MinGW" parameter="${COMMAND} ${FLAGS} -E -P -v -dD -std=c++14 &quot;${INPUTS}&quot;" prefer-non-shared="true"> <provider class="org.eclipse.cdt.managedbuilder.internal.language.settings.providers.GCCBuiltinSpecsDetectorMinGW" console="false" env-hash="-1519829723851667984" id="org.eclipse.cdt.managedbuilder.core.GCCBuiltinSpecsDetectorMinGW" keep-relative-paths="false" name="CDT GCC Built-in Compiler Settings MinGW" parameter="${COMMAND} ${FLAGS} -E -P -v -dD -std=c++14 &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/> <language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/> <language-scope id="org.eclipse.cdt.core.g++"/>
</provider> </provider>

View File

@ -2,6 +2,7 @@
#include "ui_mainwindow.h" #include "ui_mainwindow.h"
#include <iostream>
#include <QTime> #include <QTime>
#include <QLabel> #include <QLabel>
@ -14,6 +15,7 @@
#include <QSettings> #include <QSettings>
#include <QDockWidget> #include <QDockWidget>
#include <QDebug> #include <QDebug>
#include <QResizeEvent>
#include "DockManager.h" #include "DockManager.h"
#include "DockWidget.h" #include "DockWidget.h"
@ -90,6 +92,14 @@ MainWindow::MainWindow(QWidget *parent) :
ui->toolBar->addAction(ui->actionRestoreState); ui->toolBar->addAction(ui->actionRestoreState);
ui->actionRestoreState->setIcon(style()->standardIcon(QStyle::SP_DialogOpenButton)); 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); m_DockManager = new ads::CDockManager(this);
createContent(); createContent();
// Default window geometry // Default window geometry

View File

@ -1,6 +1,10 @@
#ifndef MAINWINDOW_H #ifndef MAINWINDOW_H
#define MAINWINDOW_H #define MAINWINDOW_H
#include <QAction>
#include <QWidgetAction>
#include <QComboBox>
#include <QMainWindow> #include <QMainWindow>
#include "DockManager.h" #include "DockManager.h"
@ -8,11 +12,20 @@ namespace Ui {
class MainWindow; class MainWindow;
} }
/**
* Simple main window for demo
*/
class MainWindow : public QMainWindow class MainWindow : public QMainWindow
{ {
Q_OBJECT Q_OBJECT
private:
QAction* m_SavePerspectiveAction;
QWidgetAction* m_PerspectiveListAction;
QComboBox* m_PerspectiveComboBox;
protected: protected:
virtual void closeEvent(QCloseEvent* event) override; virtual void closeEvent(QCloseEvent* event) override;
;
public: public:
explicit MainWindow(QWidget *parent = 0); explicit MainWindow(QWidget *parent = 0);
virtual ~MainWindow(); virtual ~MainWindow();

View File

@ -1002,7 +1002,6 @@ bool CDockContainerWidget::restoreState(QXmlStreamReader& s, bool Testing)
{ {
CFloatingDockContainer* FloatingWidget = internal::findParent<CFloatingDockContainer*>(this); CFloatingDockContainer* FloatingWidget = internal::findParent<CFloatingDockContainer*>(this);
FloatingWidget->restoreGeometry(Geometry); FloatingWidget->restoreGeometry(Geometry);
FloatingWidget->show();
} }
} }

View File

@ -346,9 +346,9 @@ bool CDockManager::restoreState(const QByteArray &state, int version)
{ {
DockWidget->flagAsUnassigned(); DockWidget->flagAsUnassigned();
} }
else if (!DockWidget->property("closed").toBool()) else
{ {
DockWidget->toggleView(true); DockWidget->toggleView(!DockWidget->property("closed").toBool());
} }
} }

View File

@ -300,15 +300,16 @@ void CFloatingDockContainer::moveEvent(QMoveEvent *event)
//============================================================================ //============================================================================
void CFloatingDockContainer::closeEvent(QCloseEvent *event) void CFloatingDockContainer::closeEvent(QCloseEvent *event)
{ {
std::cout << "closeEvent" << std::endl;
d->setDraggingActive(false); d->setDraggingActive(false);
QWidget::closeEvent(event); QWidget::closeEvent(event);
} }
//============================================================================ //============================================================================
void CFloatingDockContainer::hideEvent(QHideEvent *event) void CFloatingDockContainer::hideEvent(QHideEvent *event)
{ {
std::cout << "hideEvent" << std::endl;
QWidget::hideEvent(event); QWidget::hideEvent(event);
auto OpenDockAreas = d->DockContainer->openedDockAreas(); auto OpenDockAreas = d->DockContainer->openedDockAreas();
for (auto DockArea : OpenDockAreas) for (auto DockArea : OpenDockAreas)
@ -316,7 +317,7 @@ void CFloatingDockContainer::hideEvent(QHideEvent *event)
auto OpenDockWidgets = DockArea->openedDockWidgets(); auto OpenDockWidgets = DockArea->openedDockWidgets();
for (auto DockWidget : OpenDockWidgets) for (auto DockWidget : OpenDockWidgets)
{ {
DockWidget->setToggleViewActionChecked(false); DockWidget->toggleView(false);
} }
} }
} }