Attribute dialog: save/restore window geometry

Fix #8784
This commit is contained in:
Matthias Kuhn 2014-06-26 19:12:03 +02:00
parent b3bda8bb30
commit 38c2eebf2e
2 changed files with 20 additions and 2 deletions

View File

@ -60,7 +60,6 @@ QgsAttributeDialog::~QgsAttributeDialog()
delete mHighlight;
}
saveGeometry();
delete mDialog;
}
@ -116,6 +115,7 @@ void QgsAttributeDialog::show()
mDialog->raise();
mDialog->activateWindow();
mDialog->installEventFilter( this );
setParent( mDialog );
}
}
@ -141,6 +141,12 @@ bool QgsAttributeDialog::eventFilter( QObject* obj, QEvent* e )
return false;
}
void QgsAttributeDialog::onDialogFinished( int result )
{
Q_UNUSED( result )
saveGeometry();
}
void QgsAttributeDialog::init( QgsVectorLayer* layer, QgsFeature* feature, QgsAttributeEditorContext& context, QWidget* parent )
{
mDialog = new QDialog( parent );
@ -152,4 +158,6 @@ void QgsAttributeDialog::init( QgsVectorLayer* layer, QgsFeature* feature, QgsAt
QDialogButtonBox* buttonBox = mAttributeForm->findChild<QDialogButtonBox*>();
connect( buttonBox, SIGNAL( rejected() ), mDialog, SLOT( reject() ) );
connect( buttonBox, SIGNAL( accepted() ), mDialog, SLOT( accept() ) );
connect( mDialog, SIGNAL( finished( int ) ), this, SLOT( onDialogFinished( int ) ) );
restoreGeometry();
}

View File

@ -22,6 +22,7 @@
#include "qgsattributeform.h"
#include <QDialog>
#include <QPointer>
class QLayout;
@ -114,16 +115,25 @@ class GUI_EXPORT QgsAttributeDialog : public QObject
public slots:
void accept();
//! Show the dialog and block the application until the dialog is closed. Ownership of this object is not changed.
int exec();
//! Show the dialog non-blocking. Reparents this dialog to be a child of the dialog form and is deleted when
//! closed.
void show();
protected:
bool eventFilter( QObject *obj, QEvent *e );
private slots:
void onDialogFinished( int result );
private:
void init( QgsVectorLayer* layer, QgsFeature* feature, QgsAttributeEditorContext& context, QWidget* parent );
QDialog *mDialog;
// Using a guarded pointer we can savely delete the dialog in the destructor even
// when the dialog is this object's parent
QPointer<QDialog> mDialog;
QString mSettingsPath;
// Used to sync multiple widgets for the same field
QgsHighlight *mHighlight;