Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix attribute form position/size is remembered only per layer/feature combo #6611

Merged
merged 1 commit into from
Mar 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions src/gui/qgsattributedialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

#include "qgsattributedialog.h"

#include "qgsgui.h"
#include "qgsattributeform.h"
#include "qgshighlight.h"
#include "qgsapplication.h"
Expand All @@ -40,6 +39,22 @@ QgsAttributeDialog::~QgsAttributeDialog()

if ( mOwnedFeature )
delete mOwnedFeature;

saveGeometry();
}

void QgsAttributeDialog::saveGeometry()
{
// WARNING!!!! Don't use QgsGui::enableAutoGeometryRestore for this dialog -- the object name
// is dynamic and is set to match the layer/feature combination.
QgsSettings().setValue( QStringLiteral( "Windows/AttributeDialog/geometry" ), QDialog::saveGeometry() );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nyalldawson are you sure we can't use enableAutoGeometryRestore here. Pretty sure I added support for dynamic keys if not I can have a look at how.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If anything just use the same settings wrapper that enableAutoGeometryRestore does so we can keep the logic in one place.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got an example? I tried this approach originally but couldn't work out out

}

void QgsAttributeDialog::restoreGeometry()
{
// WARNING!!!! Don't use QgsGui::enableAutoGeometryRestore for this dialog -- the object name
// is dynamic and is set to match the layer/feature combination.
QDialog::restoreGeometry( QgsSettings().value( QStringLiteral( "Windows/AttributeDialog/geometry" ) ).toByteArray() );
}

void QgsAttributeDialog::setHighlight( QgsHighlight *h )
Expand Down Expand Up @@ -73,7 +88,6 @@ void QgsAttributeDialog::reject()

void QgsAttributeDialog::init( QgsVectorLayer *layer, QgsFeature *feature, const QgsAttributeEditorContext &context, bool showDialogButtons )
{
QgsGui::enableAutoGeometryRestore( this );
QgsAttributeEditorContext trackedContext = context;
setWindowTitle( tr( "%1 - Feature Attributes" ).arg( layer->name() ) );
setLayout( new QGridLayout() );
Expand All @@ -99,6 +113,7 @@ void QgsAttributeDialog::init( QgsVectorLayer *layer, QgsFeature *feature, const
layout()->setMenuBar( menuBar );
}

restoreGeometry();
focusNextChild();
}

Expand Down
2 changes: 2 additions & 0 deletions src/gui/qgsattributedialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ class GUI_EXPORT QgsAttributeDialog : public QDialog
static int sFormCounter;
static QString sSettingsPath;

void saveGeometry();
void restoreGeometry();
};

#endif