Skip to content
Permalink
Browse files
Attribute dialog: save/restore window geometry
Fix #8784
  • Loading branch information
m-kuhn committed Jun 26, 2014
1 parent b3bda8b commit 38c2eebf2efda13bed90e0ae02be385196244f04
Showing with 20 additions and 2 deletions.
  1. +9 −1 src/gui/qgsattributedialog.cpp
  2. +11 −1 src/gui/qgsattributedialog.h
@@ -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();
}
@@ -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;

0 comments on commit 38c2eeb

Please sign in to comment.