Skip to content

Commit 1e29878

Browse files
committed
Use auto geometry restore for decoration dialogs
1 parent 6fa8820 commit 1e29878

11 files changed

+25
-55
lines changed

src/app/decorations/qgsdecorationcopyrightdialog.cpp

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#include "qgsexpressioncontext.h"
2020
#include "qgshelp.h"
2121
#include "qgsmapcanvas.h"
22-
#include "qgssettings.h"
22+
#include "qgsgui.h"
2323

2424
//qt includes
2525
#include <QColorDialog>
@@ -33,14 +33,14 @@ QgsDecorationCopyrightDialog::QgsDecorationCopyrightDialog( QgsDecorationCopyrig
3333
, mDeco( deco )
3434
{
3535
setupUi( this );
36+
37+
QgsGui::enableAutoGeometryRestore( this );
38+
3639
connect( buttonBox, &QDialogButtonBox::accepted, this, &QgsDecorationCopyrightDialog::buttonBox_accepted );
3740
connect( buttonBox, &QDialogButtonBox::rejected, this, &QgsDecorationCopyrightDialog::buttonBox_rejected );
3841
connect( mInsertExpressionButton, &QPushButton::clicked, this, &QgsDecorationCopyrightDialog::mInsertExpressionButton_clicked );
3942
connect( buttonBox, &QDialogButtonBox::helpRequested, this, &QgsDecorationCopyrightDialog::showHelp );
4043

41-
QgsSettings settings;
42-
restoreGeometry( settings.value( QStringLiteral( "Windows/DecorationCopyright/geometry" ) ).toByteArray() );
43-
4444
QPushButton *applyButton = buttonBox->button( QDialogButtonBox::Apply );
4545
connect( applyButton, &QAbstractButton::clicked, this, &QgsDecorationCopyrightDialog::apply );
4646

@@ -78,12 +78,6 @@ QgsDecorationCopyrightDialog::QgsDecorationCopyrightDialog( QgsDecorationCopyrig
7878
mButtonFontStyle->setTextFormat( mDeco.textFormat() );
7979
}
8080

81-
QgsDecorationCopyrightDialog::~QgsDecorationCopyrightDialog()
82-
{
83-
QgsSettings settings;
84-
settings.setValue( QStringLiteral( "Windows/DecorationCopyright/geometry" ), saveGeometry() );
85-
}
86-
8781
void QgsDecorationCopyrightDialog::buttonBox_accepted()
8882
{
8983
apply();

src/app/decorations/qgsdecorationcopyrightdialog.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
* the Free Software Foundation; either version 2 of the License, or *
1010
* (at your option) any later version. *
1111
***************************************************************************/
12+
1213
#ifndef QGSCOPYRIGHTLABELPLUGINGUI_H
1314
#define QGSCOPYRIGHTLABELPLUGINGUI_H
1415

@@ -26,7 +27,6 @@ class APP_EXPORT QgsDecorationCopyrightDialog : public QDialog, private Ui::QgsD
2627

2728
public:
2829
QgsDecorationCopyrightDialog( QgsDecorationCopyright &deco, QWidget *parent = nullptr );
29-
~QgsDecorationCopyrightDialog() override;
3030

3131
private slots:
3232
void buttonBox_accepted();

src/app/decorations/qgsdecorationgriddialog.cpp

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,16 @@
2626
#include "qgssymbolselectordialog.h"
2727
#include "qgisapp.h"
2828
#include "qgsguiutils.h"
29-
#include "qgssettings.h"
29+
#include "qgsgui.h"
3030

3131
QgsDecorationGridDialog::QgsDecorationGridDialog( QgsDecorationGrid &deco, QWidget *parent )
3232
: QDialog( parent )
3333
, mDeco( deco )
3434
{
3535
setupUi( this );
36+
37+
QgsGui::enableAutoGeometryRestore( this );
38+
3639
connect( buttonBox, &QDialogButtonBox::accepted, this, &QgsDecorationGridDialog::buttonBox_accepted );
3740
connect( buttonBox, &QDialogButtonBox::rejected, this, &QgsDecorationGridDialog::buttonBox_rejected );
3841
connect( mGridTypeComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsDecorationGridDialog::mGridTypeComboBox_currentIndexChanged );
@@ -45,9 +48,6 @@ QgsDecorationGridDialog::QgsDecorationGridDialog( QgsDecorationGrid &deco, QWidg
4548

4649
mAnnotationFontButton->setMode( QgsFontButton::ModeQFont );
4750

48-
QgsSettings settings;
49-
// restoreGeometry( settings.value( "/Windows/DecorationGrid/geometry" ).toByteArray() );
50-
5151
grpEnable->setChecked( mDeco.enabled() );
5252

5353
// mXMinLineEdit->setValidator( new QDoubleValidator( mXMinLineEdit ) );
@@ -157,12 +157,6 @@ void QgsDecorationGridDialog::updateDecoFromGui()
157157
mDeco.setMarkerSymbol( mMarkerSymbolButton->clonedSymbol< QgsMarkerSymbol >() );
158158
}
159159

160-
QgsDecorationGridDialog::~QgsDecorationGridDialog()
161-
{
162-
QgsSettings settings;
163-
settings.setValue( QStringLiteral( "/Windows/DecorationGrid/geometry" ), saveGeometry() );
164-
}
165-
166160
void QgsDecorationGridDialog::showHelp()
167161
{
168162
QgsHelp::openHelp( QStringLiteral( "introduction/general_tools.html#grid" ) );

src/app/decorations/qgsdecorationgriddialog.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
* (at your option) any later version. *
1616
* *
1717
***************************************************************************/
18+
1819
#ifndef QGSDECORATIONGRIDDIALOG_H
1920
#define QGSDECORATIONGRIDDIALOG_H
2021

@@ -32,7 +33,6 @@ class APP_EXPORT QgsDecorationGridDialog : public QDialog, private Ui::QgsDecora
3233

3334
public:
3435
QgsDecorationGridDialog( QgsDecorationGrid &decoGrid, QWidget *parent = nullptr );
35-
~QgsDecorationGridDialog() override;
3636

3737
private slots:
3838
void apply();

src/app/decorations/qgsdecorationlayoutextentdialog.cpp

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,21 @@
2828
#include "qgsguiutils.h"
2929
#include "qgssettings.h"
3030
#include "qgstextformatwidget.h"
31+
#include "qgsgui.h"
3132

3233
QgsDecorationLayoutExtentDialog::QgsDecorationLayoutExtentDialog( QgsDecorationLayoutExtent &deco, QWidget *parent )
3334
: QDialog( parent )
3435
, mDeco( deco )
3536
{
3637
setupUi( this );
38+
39+
QgsGui::enableAutoGeometryRestore( this );
40+
3741
connect( buttonBox, &QDialogButtonBox::accepted, this, &QgsDecorationLayoutExtentDialog::buttonBox_accepted );
3842
connect( buttonBox, &QDialogButtonBox::rejected, this, &QgsDecorationLayoutExtentDialog::buttonBox_rejected );
3943

4044
mSymbolButton->setSymbolType( QgsSymbol::Fill );
4145

42-
QgsSettings settings;
43-
restoreGeometry( settings.value( QStringLiteral( "/Windows/DecorationLayoutExtent/geometry" ) ).toByteArray() );
44-
4546
updateGuiElements();
4647
connect( buttonBox->button( QDialogButtonBox::Apply ), &QAbstractButton::clicked, this, &QgsDecorationLayoutExtentDialog::apply );
4748
connect( buttonBox, &QDialogButtonBox::helpRequested, this, &QgsDecorationLayoutExtentDialog::showHelp );
@@ -65,12 +66,6 @@ void QgsDecorationLayoutExtentDialog::updateDecoFromGui()
6566
mDeco.setLabelExtents( mCheckBoxLabelExtents->isChecked() );
6667
}
6768

68-
QgsDecorationLayoutExtentDialog::~QgsDecorationLayoutExtentDialog()
69-
{
70-
QgsSettings settings;
71-
settings.setValue( QStringLiteral( "/Windows/DecorationLayoutExtent/geometry" ), saveGeometry() );
72-
}
73-
7469
void QgsDecorationLayoutExtentDialog::buttonBox_accepted()
7570
{
7671
apply();

src/app/decorations/qgsdecorationlayoutextentdialog.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
* (at your option) any later version. *
1515
* *
1616
***************************************************************************/
17+
1718
#ifndef QGSDECORATIONLAYOUTEXTENTDIALOG_H
1819
#define QGSDECORATIONLAYOUTEXTENTDIALOG_H
1920

@@ -33,7 +34,6 @@ class APP_EXPORT QgsDecorationLayoutExtentDialog : public QDialog, private Ui::Q
3334

3435
public:
3536
QgsDecorationLayoutExtentDialog( QgsDecorationLayoutExtent &decoration, QWidget *parent = nullptr );
36-
~QgsDecorationLayoutExtentDialog() override;
3737

3838
private slots:
3939
void apply();

src/app/decorations/qgsdecorationnortharrowdialog.cpp

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
#include "qgslogger.h"
1616
#include "qgshelp.h"
1717
#include "qgsproject.h"
18-
#include "qgssettings.h"
1918
#include "qgssymbollayerutils.h"
2019
#include "qgssvgcache.h"
2120
#include "qgssvgselectorwidget.h"
21+
#include "qgsgui.h"
2222

2323
#include <QPainter>
2424
#include <cmath>
@@ -31,12 +31,12 @@ QgsDecorationNorthArrowDialog::QgsDecorationNorthArrowDialog( QgsDecorationNorth
3131
, mDeco( deco )
3232
{
3333
setupUi( this );
34+
35+
QgsGui::enableAutoGeometryRestore( this );
36+
3437
connect( buttonBox, &QDialogButtonBox::accepted, this, &QgsDecorationNorthArrowDialog::buttonBox_accepted );
3538
connect( buttonBox, &QDialogButtonBox::rejected, this, &QgsDecorationNorthArrowDialog::buttonBox_rejected );
3639

37-
QgsSettings settings;
38-
restoreGeometry( settings.value( QStringLiteral( "Windows/DecorationNorthArrow/geometry" ) ).toByteArray() );
39-
4040
QPushButton *applyButton = buttonBox->button( QDialogButtonBox::Apply );
4141
connect( applyButton, &QAbstractButton::clicked, this, &QgsDecorationNorthArrowDialog::apply );
4242
connect( buttonBox, &QDialogButtonBox::helpRequested, this, &QgsDecorationNorthArrowDialog::showHelp );
@@ -105,12 +105,6 @@ QgsDecorationNorthArrowDialog::QgsDecorationNorthArrowDialog( QgsDecorationNorth
105105
drawNorthArrow();
106106
}
107107

108-
QgsDecorationNorthArrowDialog::~QgsDecorationNorthArrowDialog()
109-
{
110-
QgsSettings settings;
111-
settings.setValue( QStringLiteral( "Windows/DecorationNorthArrow/geometry" ), saveGeometry() );
112-
}
113-
114108
void QgsDecorationNorthArrowDialog::showHelp()
115109
{
116110
QgsHelp::openHelp( QStringLiteral( "introduction/general_tools.html#north-arrow" ) );

src/app/decorations/qgsdecorationnortharrowdialog.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
* the Free Software Foundation; either version 2 of the License, or *
1010
* (at your option) any later version. *
1111
***************************************************************************/
12+
1213
#ifndef QGSNORTHARROWPLUGINGUI_H
1314
#define QGSNORTHARROWPLUGINGUI_H
1415

@@ -23,7 +24,6 @@ class APP_EXPORT QgsDecorationNorthArrowDialog : public QDialog, private Ui::Qgs
2324

2425
public:
2526
QgsDecorationNorthArrowDialog( QgsDecorationNorthArrow &deco, QWidget *parent = nullptr );
26-
~QgsDecorationNorthArrowDialog() override;
2727

2828
private:
2929
void updateSvgPath( const QString &svgPath );

src/app/decorations/qgsdecorationscalebardialog.cpp

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#include "qgsdecorationscalebar.h"
1515
#include "qgslogger.h"
1616
#include "qgshelp.h"
17-
#include "qgssettings.h"
17+
#include "qgsgui.h"
1818

1919
#include <QColorDialog>
2020
#include <QDialogButtonBox>
@@ -25,13 +25,13 @@ QgsDecorationScaleBarDialog::QgsDecorationScaleBarDialog( QgsDecorationScaleBar
2525
, mDeco( deco )
2626
{
2727
setupUi( this );
28+
29+
QgsGui::enableAutoGeometryRestore( this );
30+
2831
connect( buttonBox, &QDialogButtonBox::accepted, this, &QgsDecorationScaleBarDialog::buttonBox_accepted );
2932
connect( buttonBox, &QDialogButtonBox::rejected, this, &QgsDecorationScaleBarDialog::buttonBox_rejected );
3033
connect( buttonBox, &QDialogButtonBox::helpRequested, this, &QgsDecorationScaleBarDialog::showHelp );
3134

32-
QgsSettings settings;
33-
restoreGeometry( settings.value( QStringLiteral( "Windows/DecorationScaleBar/geometry" ) ).toByteArray() );
34-
3535
QPushButton *applyButton = buttonBox->button( QDialogButtonBox::Apply );
3636
connect( applyButton, &QAbstractButton::clicked, this, &QgsDecorationScaleBarDialog::apply );
3737

@@ -88,12 +88,6 @@ QgsDecorationScaleBarDialog::QgsDecorationScaleBarDialog( QgsDecorationScaleBar
8888
mButtonFontStyle->setTextFormat( mDeco.mTextFormat );
8989
}
9090

91-
QgsDecorationScaleBarDialog::~QgsDecorationScaleBarDialog()
92-
{
93-
QgsSettings settings;
94-
settings.setValue( QStringLiteral( "Windows/DecorationScaleBar/geometry" ), saveGeometry() );
95-
}
96-
9791
void QgsDecorationScaleBarDialog::showHelp()
9892
{
9993
QgsHelp::openHelp( QStringLiteral( "introduction/general_tools.html#scale-bar" ) );

src/app/decorations/qgsdecorationscalebardialog.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
* the Free Software Foundation; either version 2 of the License, or *
1010
* (at your option) any later version. *
1111
***************************************************************************/
12+
1213
#ifndef QGSSCALEBARPLUGINGUI_H
1314
#define QGSSCALEBARPLUGINGUI_H
1415

@@ -24,7 +25,6 @@ class APP_EXPORT QgsDecorationScaleBarDialog : public QDialog, private Ui::QgsDe
2425

2526
public:
2627
QgsDecorationScaleBarDialog( QgsDecorationScaleBar &deco, int units, QWidget *parent = nullptr );
27-
~QgsDecorationScaleBarDialog() override;
2828

2929
private slots:
3030
void buttonBox_accepted();

src/app/decorations/qgsdecorationtitledialog.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
#include "qgsexpressioncontext.h"
2323
#include "qgshelp.h"
2424
#include "qgsmapcanvas.h"
25-
#include "qgssettings.h"
2625
#include "qgsgui.h"
2726

2827
#include <QColorDialog>

0 commit comments

Comments
 (0)