When closing a dialog, remove it from the docked dialogs, and delete it.

This commit is contained in:
dfighter1985 2014-09-10 19:52:35 +02:00
parent c8c28a8d90
commit 8394ce3796
7 changed files with 24 additions and 17 deletions

View file

@ -23,6 +23,7 @@ SET(OVQT_PLUG_GEORGES_EDITOR_HDR georges_editor_plugin.h
filepath_property_manager.h filepath_property_manager.h
typ_browser_ctrl.h typ_browser_ctrl.h
georges_typ_dialog.h georges_typ_dialog.h
georges_dock_widget.h
) )
SET(OVQT_PLUG_GEORGES_EDITOR_UIS georges_editor_form.ui SET(OVQT_PLUG_GEORGES_EDITOR_UIS georges_editor_form.ui

View file

@ -29,6 +29,11 @@ GeorgesDockWidget::~GeorgesDockWidget()
{ {
} }
void GeorgesDockWidget::closeEvent( QCloseEvent *e )
{
Q_EMIT closing( this );
}
QString GeorgesDockWidget::buildLogMsg( const QString &msg ) QString GeorgesDockWidget::buildLogMsg( const QString &msg )
{ {
QString user = getenv( "USER" ); QString user = getenv( "USER" );

View file

@ -25,6 +25,7 @@ class QUndoStack;
class GeorgesDockWidget : public QDockWidget class GeorgesDockWidget : public QDockWidget
{ {
Q_OBJECT
public: public:
GeorgesDockWidget( QWidget *parent = NULL ); GeorgesDockWidget( QWidget *parent = NULL );
~GeorgesDockWidget(); ~GeorgesDockWidget();
@ -39,6 +40,12 @@ public:
virtual bool load( const QString &fileName ) = 0; virtual bool load( const QString &fileName ) = 0;
virtual void write() = 0; virtual void write() = 0;
protected:
void closeEvent( QCloseEvent *e );
Q_SIGNALS:
void closing( GeorgesDockWidget *d );
protected: protected:
QString buildLogMsg( const QString &msg ); QString buildLogMsg( const QString &msg );
virtual void log( const QString &msg ) = 0; virtual void log( const QString &msg ) = 0;

View file

@ -252,7 +252,7 @@ namespace GeorgesQt
m_lastActiveDock = w; m_lastActiveDock = w;
m_dockedWidgets.append(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))); 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. // 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 ); addGeorgesWidget( w );
} }
void GeorgesEditorForm::closingTreeView() void GeorgesEditorForm::dialogClosing( GeorgesDockWidget *d )
{ {
//qDebug() << "closingTreeView"; m_dockedWidgets.removeAll( d );
m_dockedWidgets.removeAll(qobject_cast<CGeorgesTreeViewDialog*>(sender()));
if (qobject_cast<CGeorgesTreeViewDialog*>(sender()) == m_lastActiveDock) if( m_dockedWidgets.size() == 0 )
m_lastActiveDock = 0; m_lastActiveDock = NULL;
else
m_lastActiveDock = m_dockedWidgets.last();
delete d;
} }
void GeorgesEditorForm::setModified () void GeorgesEditorForm::setModified ()

View file

@ -52,7 +52,7 @@ public Q_SLOTS:
void save(); void save();
void settingsChanged(); void settingsChanged();
void closingTreeView(); void dialogClosing( GeorgesDockWidget *d );
void setModified(); void setModified();
void focusChanged(QWidget *old, QWidget *now); void focusChanged(QWidget *old, QWidget *now);

View file

@ -599,12 +599,6 @@ namespace GeorgesQt
modifiedFile(); modifiedFile();
} }
void CGeorgesTreeViewDialog::closeEvent(QCloseEvent *event)
{
Q_EMIT closing();
deleteLater();
}
void CGeorgesTreeViewDialog::checkVisibility(bool visible) { void CGeorgesTreeViewDialog::checkVisibility(bool visible) {
// this prevents invisible docks from getting tab focus // this prevents invisible docks from getting tab focus
qDebug() << "checkVisibility" << visible; qDebug() << "checkVisibility" << visible;

View file

@ -77,13 +77,9 @@ namespace GeorgesQt
QString loadedForm; QString loadedForm;
protected:
void closeEvent(QCloseEvent *event);
Q_SIGNALS: Q_SIGNALS:
void changeFile(QString); void changeFile(QString);
void modified(); void modified();
void closing();
public Q_SLOTS: public Q_SLOTS:
void setForm(const CForm*); void setForm(const CForm*);