Skip to content

Commit

Permalink
Use auto geometry restore for decoration dialogs
Browse files Browse the repository at this point in the history
  • Loading branch information
nirvn committed Nov 15, 2018
1 parent 6fa8820 commit 1e29878
Show file tree
Hide file tree
Showing 11 changed files with 25 additions and 55 deletions.
14 changes: 4 additions & 10 deletions src/app/decorations/qgsdecorationcopyrightdialog.cpp
Expand Up @@ -19,7 +19,7 @@
#include "qgsexpressioncontext.h"
#include "qgshelp.h"
#include "qgsmapcanvas.h"
#include "qgssettings.h"
#include "qgsgui.h"

//qt includes
#include <QColorDialog>
Expand All @@ -33,14 +33,14 @@ QgsDecorationCopyrightDialog::QgsDecorationCopyrightDialog( QgsDecorationCopyrig
, mDeco( deco )
{
setupUi( this );

QgsGui::enableAutoGeometryRestore( this );

connect( buttonBox, &QDialogButtonBox::accepted, this, &QgsDecorationCopyrightDialog::buttonBox_accepted );
connect( buttonBox, &QDialogButtonBox::rejected, this, &QgsDecorationCopyrightDialog::buttonBox_rejected );
connect( mInsertExpressionButton, &QPushButton::clicked, this, &QgsDecorationCopyrightDialog::mInsertExpressionButton_clicked );
connect( buttonBox, &QDialogButtonBox::helpRequested, this, &QgsDecorationCopyrightDialog::showHelp );

QgsSettings settings;
restoreGeometry( settings.value( QStringLiteral( "Windows/DecorationCopyright/geometry" ) ).toByteArray() );

QPushButton *applyButton = buttonBox->button( QDialogButtonBox::Apply );
connect( applyButton, &QAbstractButton::clicked, this, &QgsDecorationCopyrightDialog::apply );

Expand Down Expand Up @@ -78,12 +78,6 @@ QgsDecorationCopyrightDialog::QgsDecorationCopyrightDialog( QgsDecorationCopyrig
mButtonFontStyle->setTextFormat( mDeco.textFormat() );
}

QgsDecorationCopyrightDialog::~QgsDecorationCopyrightDialog()
{
QgsSettings settings;
settings.setValue( QStringLiteral( "Windows/DecorationCopyright/geometry" ), saveGeometry() );
}

void QgsDecorationCopyrightDialog::buttonBox_accepted()
{
apply();
Expand Down
2 changes: 1 addition & 1 deletion src/app/decorations/qgsdecorationcopyrightdialog.h
Expand Up @@ -9,6 +9,7 @@
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
***************************************************************************/

#ifndef QGSCOPYRIGHTLABELPLUGINGUI_H
#define QGSCOPYRIGHTLABELPLUGINGUI_H

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

public:
QgsDecorationCopyrightDialog( QgsDecorationCopyright &deco, QWidget *parent = nullptr );
~QgsDecorationCopyrightDialog() override;

private slots:
void buttonBox_accepted();
Expand Down
14 changes: 4 additions & 10 deletions src/app/decorations/qgsdecorationgriddialog.cpp
Expand Up @@ -26,13 +26,16 @@
#include "qgssymbolselectordialog.h"
#include "qgisapp.h"
#include "qgsguiutils.h"
#include "qgssettings.h"
#include "qgsgui.h"

QgsDecorationGridDialog::QgsDecorationGridDialog( QgsDecorationGrid &deco, QWidget *parent )
: QDialog( parent )
, mDeco( deco )
{
setupUi( this );

QgsGui::enableAutoGeometryRestore( this );

connect( buttonBox, &QDialogButtonBox::accepted, this, &QgsDecorationGridDialog::buttonBox_accepted );
connect( buttonBox, &QDialogButtonBox::rejected, this, &QgsDecorationGridDialog::buttonBox_rejected );
connect( mGridTypeComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsDecorationGridDialog::mGridTypeComboBox_currentIndexChanged );
Expand All @@ -45,9 +48,6 @@ QgsDecorationGridDialog::QgsDecorationGridDialog( QgsDecorationGrid &deco, QWidg

mAnnotationFontButton->setMode( QgsFontButton::ModeQFont );

QgsSettings settings;
// restoreGeometry( settings.value( "/Windows/DecorationGrid/geometry" ).toByteArray() );

grpEnable->setChecked( mDeco.enabled() );

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

QgsDecorationGridDialog::~QgsDecorationGridDialog()
{
QgsSettings settings;
settings.setValue( QStringLiteral( "/Windows/DecorationGrid/geometry" ), saveGeometry() );
}

void QgsDecorationGridDialog::showHelp()
{
QgsHelp::openHelp( QStringLiteral( "introduction/general_tools.html#grid" ) );
Expand Down
2 changes: 1 addition & 1 deletion src/app/decorations/qgsdecorationgriddialog.h
Expand Up @@ -15,6 +15,7 @@
* (at your option) any later version. *
* *
***************************************************************************/

#ifndef QGSDECORATIONGRIDDIALOG_H
#define QGSDECORATIONGRIDDIALOG_H

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

public:
QgsDecorationGridDialog( QgsDecorationGrid &decoGrid, QWidget *parent = nullptr );
~QgsDecorationGridDialog() override;

private slots:
void apply();
Expand Down
13 changes: 4 additions & 9 deletions src/app/decorations/qgsdecorationlayoutextentdialog.cpp
Expand Up @@ -28,20 +28,21 @@
#include "qgsguiutils.h"
#include "qgssettings.h"
#include "qgstextformatwidget.h"
#include "qgsgui.h"

QgsDecorationLayoutExtentDialog::QgsDecorationLayoutExtentDialog( QgsDecorationLayoutExtent &deco, QWidget *parent )
: QDialog( parent )
, mDeco( deco )
{
setupUi( this );

QgsGui::enableAutoGeometryRestore( this );

connect( buttonBox, &QDialogButtonBox::accepted, this, &QgsDecorationLayoutExtentDialog::buttonBox_accepted );
connect( buttonBox, &QDialogButtonBox::rejected, this, &QgsDecorationLayoutExtentDialog::buttonBox_rejected );

mSymbolButton->setSymbolType( QgsSymbol::Fill );

QgsSettings settings;
restoreGeometry( settings.value( QStringLiteral( "/Windows/DecorationLayoutExtent/geometry" ) ).toByteArray() );

updateGuiElements();
connect( buttonBox->button( QDialogButtonBox::Apply ), &QAbstractButton::clicked, this, &QgsDecorationLayoutExtentDialog::apply );
connect( buttonBox, &QDialogButtonBox::helpRequested, this, &QgsDecorationLayoutExtentDialog::showHelp );
Expand All @@ -65,12 +66,6 @@ void QgsDecorationLayoutExtentDialog::updateDecoFromGui()
mDeco.setLabelExtents( mCheckBoxLabelExtents->isChecked() );
}

QgsDecorationLayoutExtentDialog::~QgsDecorationLayoutExtentDialog()
{
QgsSettings settings;
settings.setValue( QStringLiteral( "/Windows/DecorationLayoutExtent/geometry" ), saveGeometry() );
}

void QgsDecorationLayoutExtentDialog::buttonBox_accepted()
{
apply();
Expand Down
2 changes: 1 addition & 1 deletion src/app/decorations/qgsdecorationlayoutextentdialog.h
Expand Up @@ -14,6 +14,7 @@
* (at your option) any later version. *
* *
***************************************************************************/

#ifndef QGSDECORATIONLAYOUTEXTENTDIALOG_H
#define QGSDECORATIONLAYOUTEXTENTDIALOG_H

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

public:
QgsDecorationLayoutExtentDialog( QgsDecorationLayoutExtent &decoration, QWidget *parent = nullptr );
~QgsDecorationLayoutExtentDialog() override;

private slots:
void apply();
Expand Down
14 changes: 4 additions & 10 deletions src/app/decorations/qgsdecorationnortharrowdialog.cpp
Expand Up @@ -15,10 +15,10 @@
#include "qgslogger.h"
#include "qgshelp.h"
#include "qgsproject.h"
#include "qgssettings.h"
#include "qgssymbollayerutils.h"
#include "qgssvgcache.h"
#include "qgssvgselectorwidget.h"
#include "qgsgui.h"

#include <QPainter>
#include <cmath>
Expand All @@ -31,12 +31,12 @@ QgsDecorationNorthArrowDialog::QgsDecorationNorthArrowDialog( QgsDecorationNorth
, mDeco( deco )
{
setupUi( this );

QgsGui::enableAutoGeometryRestore( this );

connect( buttonBox, &QDialogButtonBox::accepted, this, &QgsDecorationNorthArrowDialog::buttonBox_accepted );
connect( buttonBox, &QDialogButtonBox::rejected, this, &QgsDecorationNorthArrowDialog::buttonBox_rejected );

QgsSettings settings;
restoreGeometry( settings.value( QStringLiteral( "Windows/DecorationNorthArrow/geometry" ) ).toByteArray() );

QPushButton *applyButton = buttonBox->button( QDialogButtonBox::Apply );
connect( applyButton, &QAbstractButton::clicked, this, &QgsDecorationNorthArrowDialog::apply );
connect( buttonBox, &QDialogButtonBox::helpRequested, this, &QgsDecorationNorthArrowDialog::showHelp );
Expand Down Expand Up @@ -105,12 +105,6 @@ QgsDecorationNorthArrowDialog::QgsDecorationNorthArrowDialog( QgsDecorationNorth
drawNorthArrow();
}

QgsDecorationNorthArrowDialog::~QgsDecorationNorthArrowDialog()
{
QgsSettings settings;
settings.setValue( QStringLiteral( "Windows/DecorationNorthArrow/geometry" ), saveGeometry() );
}

void QgsDecorationNorthArrowDialog::showHelp()
{
QgsHelp::openHelp( QStringLiteral( "introduction/general_tools.html#north-arrow" ) );
Expand Down
2 changes: 1 addition & 1 deletion src/app/decorations/qgsdecorationnortharrowdialog.h
Expand Up @@ -9,6 +9,7 @@
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
***************************************************************************/

#ifndef QGSNORTHARROWPLUGINGUI_H
#define QGSNORTHARROWPLUGINGUI_H

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

public:
QgsDecorationNorthArrowDialog( QgsDecorationNorthArrow &deco, QWidget *parent = nullptr );
~QgsDecorationNorthArrowDialog() override;

private:
void updateSvgPath( const QString &svgPath );
Expand Down
14 changes: 4 additions & 10 deletions src/app/decorations/qgsdecorationscalebardialog.cpp
Expand Up @@ -14,7 +14,7 @@
#include "qgsdecorationscalebar.h"
#include "qgslogger.h"
#include "qgshelp.h"
#include "qgssettings.h"
#include "qgsgui.h"

#include <QColorDialog>
#include <QDialogButtonBox>
Expand All @@ -25,13 +25,13 @@ QgsDecorationScaleBarDialog::QgsDecorationScaleBarDialog( QgsDecorationScaleBar
, mDeco( deco )
{
setupUi( this );

QgsGui::enableAutoGeometryRestore( this );

connect( buttonBox, &QDialogButtonBox::accepted, this, &QgsDecorationScaleBarDialog::buttonBox_accepted );
connect( buttonBox, &QDialogButtonBox::rejected, this, &QgsDecorationScaleBarDialog::buttonBox_rejected );
connect( buttonBox, &QDialogButtonBox::helpRequested, this, &QgsDecorationScaleBarDialog::showHelp );

QgsSettings settings;
restoreGeometry( settings.value( QStringLiteral( "Windows/DecorationScaleBar/geometry" ) ).toByteArray() );

QPushButton *applyButton = buttonBox->button( QDialogButtonBox::Apply );
connect( applyButton, &QAbstractButton::clicked, this, &QgsDecorationScaleBarDialog::apply );

Expand Down Expand Up @@ -88,12 +88,6 @@ QgsDecorationScaleBarDialog::QgsDecorationScaleBarDialog( QgsDecorationScaleBar
mButtonFontStyle->setTextFormat( mDeco.mTextFormat );
}

QgsDecorationScaleBarDialog::~QgsDecorationScaleBarDialog()
{
QgsSettings settings;
settings.setValue( QStringLiteral( "Windows/DecorationScaleBar/geometry" ), saveGeometry() );
}

void QgsDecorationScaleBarDialog::showHelp()
{
QgsHelp::openHelp( QStringLiteral( "introduction/general_tools.html#scale-bar" ) );
Expand Down
2 changes: 1 addition & 1 deletion src/app/decorations/qgsdecorationscalebardialog.h
Expand Up @@ -9,6 +9,7 @@
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
***************************************************************************/

#ifndef QGSSCALEBARPLUGINGUI_H
#define QGSSCALEBARPLUGINGUI_H

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

public:
QgsDecorationScaleBarDialog( QgsDecorationScaleBar &deco, int units, QWidget *parent = nullptr );
~QgsDecorationScaleBarDialog() override;

private slots:
void buttonBox_accepted();
Expand Down
1 change: 0 additions & 1 deletion src/app/decorations/qgsdecorationtitledialog.cpp
Expand Up @@ -22,7 +22,6 @@
#include "qgsexpressioncontext.h"
#include "qgshelp.h"
#include "qgsmapcanvas.h"
#include "qgssettings.h"
#include "qgsgui.h"

#include <QColorDialog>
Expand Down

0 comments on commit 1e29878

Please sign in to comment.