From 8394ce3796002073486acbc22691507bb3c72ed7 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Wed, 10 Sep 2014 19:52:35 +0200 Subject: [PATCH] When closing a dialog, remove it from the docked dialogs, and delete it. --- .../src/plugins/georges_editor/CMakeLists.txt | 1 + .../georges_editor/georges_dock_widget.cpp | 5 +++++ .../plugins/georges_editor/georges_dock_widget.h | 7 +++++++ .../georges_editor/georges_editor_form.cpp | 16 ++++++++++------ .../plugins/georges_editor/georges_editor_form.h | 2 +- .../georges_editor/georges_treeview_dialog.cpp | 6 ------ .../georges_editor/georges_treeview_dialog.h | 4 ---- 7 files changed, 24 insertions(+), 17 deletions(-) diff --git a/code/studio/src/plugins/georges_editor/CMakeLists.txt b/code/studio/src/plugins/georges_editor/CMakeLists.txt index 0f0cbc1e0..bf7e6e0c9 100644 --- a/code/studio/src/plugins/georges_editor/CMakeLists.txt +++ b/code/studio/src/plugins/georges_editor/CMakeLists.txt @@ -23,6 +23,7 @@ SET(OVQT_PLUG_GEORGES_EDITOR_HDR georges_editor_plugin.h filepath_property_manager.h typ_browser_ctrl.h georges_typ_dialog.h + georges_dock_widget.h ) SET(OVQT_PLUG_GEORGES_EDITOR_UIS georges_editor_form.ui diff --git a/code/studio/src/plugins/georges_editor/georges_dock_widget.cpp b/code/studio/src/plugins/georges_editor/georges_dock_widget.cpp index 921f59e0b..9602a7678 100644 --- a/code/studio/src/plugins/georges_editor/georges_dock_widget.cpp +++ b/code/studio/src/plugins/georges_editor/georges_dock_widget.cpp @@ -29,6 +29,11 @@ GeorgesDockWidget::~GeorgesDockWidget() { } +void GeorgesDockWidget::closeEvent( QCloseEvent *e ) +{ + Q_EMIT closing( this ); +} + QString GeorgesDockWidget::buildLogMsg( const QString &msg ) { QString user = getenv( "USER" ); diff --git a/code/studio/src/plugins/georges_editor/georges_dock_widget.h b/code/studio/src/plugins/georges_editor/georges_dock_widget.h index 53e4f6841..d7f80dff1 100644 --- a/code/studio/src/plugins/georges_editor/georges_dock_widget.h +++ b/code/studio/src/plugins/georges_editor/georges_dock_widget.h @@ -25,6 +25,7 @@ class QUndoStack; class GeorgesDockWidget : public QDockWidget { + Q_OBJECT public: GeorgesDockWidget( QWidget *parent = NULL ); ~GeorgesDockWidget(); @@ -39,6 +40,12 @@ public: virtual bool load( const QString &fileName ) = 0; virtual void write() = 0; +protected: + void closeEvent( QCloseEvent *e ); + +Q_SIGNALS: + void closing( GeorgesDockWidget *d ); + protected: QString buildLogMsg( const QString &msg ); virtual void log( const QString &msg ) = 0; diff --git a/code/studio/src/plugins/georges_editor/georges_editor_form.cpp b/code/studio/src/plugins/georges_editor/georges_editor_form.cpp index d544d14fd..4f4b814ec 100644 --- a/code/studio/src/plugins/georges_editor/georges_editor_form.cpp +++ b/code/studio/src/plugins/georges_editor/georges_editor_form.cpp @@ -252,7 +252,7 @@ namespace GeorgesQt m_lastActiveDock = w; m_dockedWidgets.append(w); - connect(m_dockedWidgets.last(), SIGNAL(closing()), this, SLOT(closingTreeView())); + connect( w, SIGNAL( closing( GeorgesDockWidget* ) ), this, SLOT( dialogClosing( GeorgesDockWidget* ) ) ); connect(m_dockedWidgets.last(), SIGNAL(visibilityChanged(bool)), m_dockedWidgets.last(), SLOT(checkVisibility(bool))); // If there is more than one form open - tabify the new form. If this is the first form open add it to the dock. @@ -337,12 +337,16 @@ namespace GeorgesQt addGeorgesWidget( w ); } - void GeorgesEditorForm::closingTreeView() + void GeorgesEditorForm::dialogClosing( GeorgesDockWidget *d ) { - //qDebug() << "closingTreeView"; - m_dockedWidgets.removeAll(qobject_cast(sender())); - if (qobject_cast(sender()) == m_lastActiveDock) - m_lastActiveDock = 0; + m_dockedWidgets.removeAll( d ); + + if( m_dockedWidgets.size() == 0 ) + m_lastActiveDock = NULL; + else + m_lastActiveDock = m_dockedWidgets.last(); + + delete d; } void GeorgesEditorForm::setModified () diff --git a/code/studio/src/plugins/georges_editor/georges_editor_form.h b/code/studio/src/plugins/georges_editor/georges_editor_form.h index adfaf2e59..031d6e0fc 100644 --- a/code/studio/src/plugins/georges_editor/georges_editor_form.h +++ b/code/studio/src/plugins/georges_editor/georges_editor_form.h @@ -52,7 +52,7 @@ public Q_SLOTS: void save(); void settingsChanged(); - void closingTreeView(); + void dialogClosing( GeorgesDockWidget *d ); void setModified(); void focusChanged(QWidget *old, QWidget *now); diff --git a/code/studio/src/plugins/georges_editor/georges_treeview_dialog.cpp b/code/studio/src/plugins/georges_editor/georges_treeview_dialog.cpp index 62d5ac653..ab5f03924 100644 --- a/code/studio/src/plugins/georges_editor/georges_treeview_dialog.cpp +++ b/code/studio/src/plugins/georges_editor/georges_treeview_dialog.cpp @@ -599,12 +599,6 @@ namespace GeorgesQt modifiedFile(); } - void CGeorgesTreeViewDialog::closeEvent(QCloseEvent *event) - { - Q_EMIT closing(); - deleteLater(); - } - void CGeorgesTreeViewDialog::checkVisibility(bool visible) { // this prevents invisible docks from getting tab focus qDebug() << "checkVisibility" << visible; diff --git a/code/studio/src/plugins/georges_editor/georges_treeview_dialog.h b/code/studio/src/plugins/georges_editor/georges_treeview_dialog.h index 87c64ead9..37ae55c20 100644 --- a/code/studio/src/plugins/georges_editor/georges_treeview_dialog.h +++ b/code/studio/src/plugins/georges_editor/georges_treeview_dialog.h @@ -77,13 +77,9 @@ namespace GeorgesQt QString loadedForm; - protected: - void closeEvent(QCloseEvent *event); - Q_SIGNALS: void changeFile(QString); void modified(); - void closing(); public Q_SLOTS: void setForm(const CForm*);