Navigation Menu

Skip to content

Commit

Permalink
Add a bunch of automatic geometry restoration
Browse files Browse the repository at this point in the history
and remove some dedicated methods
  • Loading branch information
DelazJ authored and nyalldawson committed Jun 30, 2019
1 parent 165b5c2 commit 62e8a9b
Show file tree
Hide file tree
Showing 57 changed files with 85 additions and 239 deletions.
1 change: 0 additions & 1 deletion python/gui/auto_generated/qgsnewvectorlayerdialog.sip.in
Expand Up @@ -57,7 +57,6 @@ If ``encoding`` is specified, it will be set to the encoding of the created file
%Docstring
New dialog constructor.
%End
~QgsNewVectorLayerDialog();
QgsWkbTypes::Type selectedType() const;
%Docstring
Returns the selected geometry type
Expand Down
2 changes: 0 additions & 2 deletions python/gui/auto_generated/qgsowssourceselect.sip.in
Expand Up @@ -38,8 +38,6 @@ layers from the WCS server to the map canvas.
Constructor
%End

~QgsOWSSourceSelect();

public slots:

virtual void refresh();
Expand Down
2 changes: 0 additions & 2 deletions python/gui/auto_generated/qgsquerybuilder.sip.in
Expand Up @@ -35,8 +35,6 @@ vector layer properties dialog
:param fl: dialog flags
%End

~QgsQueryBuilder();

virtual void showEvent( QShowEvent *event );


Expand Down
Expand Up @@ -42,7 +42,6 @@ class QgsRasterLayerSaveAsDialog: QDialog
%Docstring
Constructor for QgsRasterLayerSaveAsDialog
%End
~QgsRasterLayerSaveAsDialog();

Mode mode() const;
int nColumns() const;
Expand Down
2 changes: 0 additions & 2 deletions python/gui/auto_generated/qgstextformatwidget.sip.in
Expand Up @@ -170,8 +170,6 @@ Constructor for QgsTextFormatDialog.
:param fl: window flags for dialog
%End

~QgsTextFormatDialog();

QgsTextFormat format() const;
%Docstring
Returns the current formatting settings defined by the widget.
Expand Down
Expand Up @@ -233,8 +233,6 @@ Constructor for QgsRendererRulePropsDialog
:param context: symbol widget context
%End

~QgsRendererRulePropsDialog();

QgsRuleBasedRenderer::Rule *rule();

public slots:
Expand Down
Expand Up @@ -113,7 +113,6 @@ class QgsSvgSelectorDialog : QDialog
%Docstring
Constructor for QgsSvgSelectorDialog.
%End
~QgsSvgSelectorDialog();

QgsSvgSelectorWidget *svgSelector();
%Docstring
Expand Down
Expand Up @@ -203,7 +203,6 @@ Constructor for QgsSymbolSelectorDialog.
:param parent: Parent widget
:param embedded: ``True`` to embed in renderer properties dialog, ``False`` otherwise
%End
~QgsSymbolSelectorDialog();

QMenu *advancedMenu();
%Docstring
Expand Down
5 changes: 2 additions & 3 deletions src/app/dwg/qgsdwgimportdialog.cpp
Expand Up @@ -48,12 +48,14 @@
#include "qgsguiutils.h"
#include "qgsfilewidget.h"
#include "qgsmessagebar.h"
#include "qgsgui.h"


QgsDwgImportDialog::QgsDwgImportDialog( QWidget *parent, Qt::WindowFlags f )
: QDialog( parent, f )
{
setupUi( this );
QgsGui::instance()->enableAutoGeometryRestore( this );
mDatabaseFileWidget->setStorageMode( QgsFileWidget::SaveFile );

connect( buttonBox, &QDialogButtonBox::accepted, this, &QgsDwgImportDialog::buttonBox_accepted );
Expand Down Expand Up @@ -86,8 +88,6 @@ QgsDwgImportDialog::QgsDwgImportDialog( QWidget *parent, Qt::WindowFlags f )

pbLoadDatabase_clicked();
updateUI();

restoreGeometry( s.value( QStringLiteral( "/Windows/DwgImport/geometry" ) ).toByteArray() );
}

QgsDwgImportDialog::~QgsDwgImportDialog()
Expand All @@ -96,7 +96,6 @@ QgsDwgImportDialog::~QgsDwgImportDialog()
s.setValue( QStringLiteral( "/DwgImport/lastExpandInserts" ), cbExpandInserts->isChecked() );
s.setValue( QStringLiteral( "/DwgImport/lastMergeLayers" ), cbMergeLayers->isChecked() );
s.setValue( QStringLiteral( "/DwgImport/lastUseCurves" ), cbUseCurves->isChecked() );
s.setValue( QStringLiteral( "/Windows/DwgImport/geometry" ), saveGeometry() );
}

void QgsDwgImportDialog::updateUI()
Expand Down
11 changes: 3 additions & 8 deletions src/app/qgslabelpropertydialog.cpp
Expand Up @@ -27,6 +27,7 @@
#include "qgsproperty.h"
#include "qgssettings.h"
#include "qgsexpressioncontextutils.h"
#include "qgsgui.h"

#include <QColorDialog>
#include <QFontDatabase>
Expand All @@ -37,6 +38,8 @@ QgsLabelPropertyDialog::QgsLabelPropertyDialog( const QString &layerId, const QS
QDialog( parent, f ), mLabelFont( labelFont ), mCurLabelField( -1 )
{
setupUi( this );
QgsGui::instance()->enableAutoGeometryRestore( this );

connect( buttonBox, &QDialogButtonBox::clicked, this, &QgsLabelPropertyDialog::buttonBox_clicked );
connect( mShowLabelChkbx, &QCheckBox::toggled, this, &QgsLabelPropertyDialog::mShowLabelChkbx_toggled );
connect( mAlwaysShowChkbx, &QCheckBox::toggled, this, &QgsLabelPropertyDialog::mAlwaysShowChkbx_toggled );
Expand All @@ -63,18 +66,10 @@ QgsLabelPropertyDialog::QgsLabelPropertyDialog( const QString &layerId, const QS

init( layerId, providerId, featureId, labelText );

QgsSettings settings;
restoreGeometry( settings.value( QStringLiteral( "Windows/ChangeLabelProps/geometry" ) ).toByteArray() );
connect( mMinScaleWidget, &QgsScaleWidget::scaleChanged, this, &QgsLabelPropertyDialog::minScaleChanged );
connect( mMaxScaleWidget, &QgsScaleWidget::scaleChanged, this, &QgsLabelPropertyDialog::maxScaleChanged );
}

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

void QgsLabelPropertyDialog::setMapCanvas( QgsMapCanvas *canvas )
{
mMinScaleWidget->setMapCanvas( canvas );
Expand Down
1 change: 0 additions & 1 deletion src/app/qgslabelpropertydialog.h
Expand Up @@ -31,7 +31,6 @@ class APP_EXPORT QgsLabelPropertyDialog: public QDialog, private Ui::QgsLabelPro
Q_OBJECT
public:
QgsLabelPropertyDialog( const QString &layerId, const QString &providerId, int featureId, const QFont &labelFont, const QString &labelText, QWidget *parent = nullptr, Qt::WindowFlags f = nullptr );
~QgsLabelPropertyDialog() override;

//! Returns properties changed by the user
const QgsAttributeMap &changedProperties() const { return mChangedProperties; }
Expand Down
4 changes: 2 additions & 2 deletions src/app/qgsmeasuredialog.cpp
Expand Up @@ -25,6 +25,7 @@
#include "qgscoordinatereferencesystem.h"
#include "qgsunittypes.h"
#include "qgssettings.h"
#include "qgsgui.h"

#include <QCloseEvent>
#include <QLocale>
Expand All @@ -38,6 +39,7 @@ QgsMeasureDialog::QgsMeasureDialog( QgsMeasureTool *tool, Qt::WindowFlags f )
, mCanvas( tool->canvas() )
{
setupUi( this );
QgsGui::instance()->enableAutoGeometryRestore( this );
connect( buttonBox, &QDialogButtonBox::helpRequested, this, &QgsMeasureDialog::showHelp );

QPushButton *nb = new QPushButton( tr( "&New" ) );
Expand Down Expand Up @@ -310,7 +312,6 @@ void QgsMeasureDialog::closeEvent( QCloseEvent *e )
void QgsMeasureDialog::restorePosition()
{
QgsSettings settings;
restoreGeometry( settings.value( QStringLiteral( "Windows/Measure/geometry" ) ).toByteArray() );
int wh;
if ( mMeasureArea )
wh = settings.value( QStringLiteral( "Windows/Measure/hNoTable" ), 70 ).toInt();
Expand All @@ -323,7 +324,6 @@ void QgsMeasureDialog::restorePosition()
void QgsMeasureDialog::saveWindowLocation()
{
QgsSettings settings;
settings.setValue( QStringLiteral( "Windows/Measure/geometry" ), saveGeometry() );
const QString &key = mMeasureArea ? "/Windows/Measure/hNoTable" : "/Windows/Measure/h";
settings.setValue( key, height() );
}
Expand Down
8 changes: 2 additions & 6 deletions src/app/qgsvectorlayerloadstyledialog.cpp
Expand Up @@ -24,13 +24,15 @@
#include "qgsmaplayerstylecategoriesmodel.h"
#include "qgsmessagebar.h"
#include "qgsapplication.h"
#include "qgsgui.h"


QgsVectorLayerLoadStyleDialog::QgsVectorLayerLoadStyleDialog( QgsVectorLayer *layer, QWidget *parent )
: QDialog( parent )
, mLayer( layer )
{
setupUi( this );
QgsGui::instance()->enableAutoGeometryRestore( this );
setWindowTitle( QStringLiteral( "Database styles manager" ) );

mDeleteButton = mButtonBox->button( QDialogButtonBox::StandardButton::Close );
Expand Down Expand Up @@ -118,15 +120,9 @@ QgsVectorLayerLoadStyleDialog::QgsVectorLayerLoadStyleDialog( QgsVectorLayer *la

setTabOrder( mRelatedTable, mOthersTable );

restoreGeometry( settings.value( QStringLiteral( "Windows/vectorLayerLoadStyle/geometry" ) ).toByteArray() );
mStyleCategoriesListView->adjustSize();
}

QgsVectorLayerLoadStyleDialog::~QgsVectorLayerLoadStyleDialog()
{
QgsSettings().setValue( QStringLiteral( "Windows/vectorLayerLoadStyle/geometry" ), saveGeometry() );
}

QgsMapLayer::StyleCategories QgsVectorLayerLoadStyleDialog::styleCategories() const
{
return mModel->categories();
Expand Down
2 changes: 0 additions & 2 deletions src/app/qgsvectorlayerloadstyledialog.h
Expand Up @@ -30,8 +30,6 @@ class APP_EXPORT QgsVectorLayerLoadStyleDialog : public QDialog, private Ui::Qgs
public:
explicit QgsVectorLayerLoadStyleDialog( QgsVectorLayer *layer, QWidget *parent = nullptr );

~QgsVectorLayerLoadStyleDialog() override;

QgsMapLayer::StyleCategories styleCategories() const;

QgsVectorLayerProperties::StyleType currentStyleType() const;
Expand Down
5 changes: 1 addition & 4 deletions src/gui/attributetable/qgsattributetableview.cpp
Expand Up @@ -39,8 +39,7 @@
QgsAttributeTableView::QgsAttributeTableView( QWidget *parent )
: QTableView( parent )
{
QgsSettings settings;
restoreGeometry( settings.value( QStringLiteral( "BetterAttributeTable/geometry" ) ).toByteArray() );
QgsGui::instance()->enableAutoGeometryRestore( this );

//verticalHeader()->setDefaultSectionSize( 20 );
horizontalHeader()->setHighlightSections( false );
Expand Down Expand Up @@ -278,8 +277,6 @@ QWidget *QgsAttributeTableView::createActionWidget( QgsFeatureId fid )
void QgsAttributeTableView::closeEvent( QCloseEvent *e )
{
Q_UNUSED( e )
QgsSettings settings;
settings.setValue( QStringLiteral( "BetterAttributeTable/geometry" ), QVariant( saveGeometry() ) );
}

void QgsAttributeTableView::mousePressEvent( QMouseEvent *event )
Expand Down
5 changes: 3 additions & 2 deletions src/gui/providers/ogr/qgsogrdbsourceselect.cpp
Expand Up @@ -24,6 +24,7 @@
#include "qgsquerybuilder.h"
#include "qgssettings.h"
#include "qgsproject.h"
#include "qgsgui.h"

#include <QMessageBox>

Expand All @@ -35,6 +36,8 @@ QgsOgrDbSourceSelect::QgsOgrDbSourceSelect( const QString &theSettingsKey, const
, mExtension( theExtensions )
{
setupUi( this );
QgsGui::instance()->enableAutoGeometryRestore( this );

connect( btnConnect, &QPushButton::clicked, this, &QgsOgrDbSourceSelect::btnConnect_clicked );
connect( btnNew, &QPushButton::clicked, this, &QgsOgrDbSourceSelect::btnNew_clicked );
connect( btnDelete, &QPushButton::clicked, this, &QgsOgrDbSourceSelect::btnDelete_clicked );
Expand All @@ -50,7 +53,6 @@ QgsOgrDbSourceSelect::QgsOgrDbSourceSelect( const QString &theSettingsKey, const
connect( buttonBox, &QDialogButtonBox::helpRequested, this, &QgsOgrDbSourceSelect::showHelp );

QgsSettings settings;
restoreGeometry( settings.value( QStringLiteral( "ogr/%1SourceSelect/geometry" ).arg( ogrDriverName( ) ), QgsSettings::Section::Providers ).toByteArray() );
mHoldDialogOpen->setChecked( settings.value( QStringLiteral( "ogr/%1SourceSelect/HoldDialogOpen" ).arg( ogrDriverName( ) ), false, QgsSettings::Section::Providers ).toBool() );

setWindowTitle( tr( "Add %1 Layer(s)" ).arg( name( ) ) );
Expand Down Expand Up @@ -110,7 +112,6 @@ QgsOgrDbSourceSelect::QgsOgrDbSourceSelect( const QString &theSettingsKey, const
QgsOgrDbSourceSelect::~QgsOgrDbSourceSelect()
{
QgsSettings settings;
settings.setValue( QStringLiteral( "ogr/%1SourceSelect/geometry" ).arg( ogrDriverName( ) ), saveGeometry(), QgsSettings::Section::Providers );
settings.setValue( QStringLiteral( "ogr/%1SourceSelect/HoldDialogOpen" ).arg( ogrDriverName( ) ), mHoldDialogOpen->isChecked(), QgsSettings::Section::Providers );
}

Expand Down
11 changes: 3 additions & 8 deletions src/gui/providers/ogr/qgsogrsourceselect.cpp
Expand Up @@ -31,13 +31,16 @@
#include "qgsproviderregistry.h"
#include "ogr/qgsnewogrconnection.h"
#include "ogr/qgsogrhelperfunctions.h"
#include "qgsgui.h"

#include <gdal.h>

QgsOgrSourceSelect::QgsOgrSourceSelect( QWidget *parent, Qt::WindowFlags fl, QgsProviderRegistry::WidgetMode widgetMode )
: QgsAbstractDataSourceWidget( parent, fl, widgetMode )
{
setupUi( this );
QgsGui::instance()->enableAutoGeometryRestore( this );

connect( radioSrcFile, &QRadioButton::toggled, this, &QgsOgrSourceSelect::radioSrcFile_toggled );
connect( radioSrcDirectory, &QRadioButton::toggled, this, &QgsOgrSourceSelect::radioSrcDirectory_toggled );
connect( radioSrcDatabase, &QRadioButton::toggled, this, &QgsOgrSourceSelect::radioSrcDatabase_toggled );
Expand Down Expand Up @@ -67,8 +70,6 @@ QgsOgrSourceSelect::QgsOgrSourceSelect( QWidget *parent, Qt::WindowFlags fl, Qgs
QgsSettings settings;
QString enc = settings.value( QStringLiteral( "UI/encoding" ), "System" ).toString();

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

// The specified decoding is added if not existing already, and then set current.
// This should select it.
int encindex = cmbEncodings->findText( enc );
Expand Down Expand Up @@ -147,12 +148,6 @@ QgsOgrSourceSelect::QgsOgrSourceSelect( QWidget *parent, Qt::WindowFlags fl, Qgs
mAuthSettingsProtocol->setDataprovider( QStringLiteral( "ogr" ) );
}

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

QStringList QgsOgrSourceSelect::dataSources()
{
return mDataSources;
Expand Down
1 change: 0 additions & 1 deletion src/gui/providers/ogr/qgsogrsourceselect.h
Expand Up @@ -50,7 +50,6 @@ class QgsOgrSourceSelect : public QgsAbstractDataSourceWidget, private Ui::QgsOg

public:
QgsOgrSourceSelect( QWidget *parent = nullptr, Qt::WindowFlags fl = nullptr, QgsProviderRegistry::WidgetMode widgetMode = QgsProviderRegistry::WidgetMode::None );
~QgsOgrSourceSelect() override;
//! Opens a dialog to select a file datasource*/
QStringList openFile();
//! Opens a dialog to select a directory datasource*/
Expand Down
9 changes: 1 addition & 8 deletions src/gui/qgsbrowserdockwidget_p.cpp
Expand Up @@ -339,14 +339,7 @@ QgsBrowserPropertiesDialog::QgsBrowserPropertiesDialog( const QString &settingsS
, mSettingsSection( settingsSection )
{
setupUi( this );
QgsSettings settings;
restoreGeometry( settings.value( mSettingsSection + "/propertiesDialog/geometry" ).toByteArray() );
}

QgsBrowserPropertiesDialog::~QgsBrowserPropertiesDialog()
{
QgsSettings settings;
settings.setValue( mSettingsSection + "/propertiesDialog/geometry", saveGeometry() );
QgsGui::instance()->enableAutoGeometryRestore( this );
}

void QgsBrowserPropertiesDialog::setItem( QgsDataItem *item )
Expand Down
1 change: 0 additions & 1 deletion src/gui/qgsbrowserdockwidget_p.h
Expand Up @@ -171,7 +171,6 @@ class GUI_EXPORT QgsBrowserPropertiesDialog : public QDialog, private Ui::QgsBro
* \param parent parent widget
*/
QgsBrowserPropertiesDialog( const QString &settingsSection, QWidget *parent = nullptr );
~QgsBrowserPropertiesDialog() override;

//! Create dialog from the given item and add it
void setItem( QgsDataItem *item );
Expand Down
7 changes: 3 additions & 4 deletions src/gui/qgsgradientcolorrampdialog.cpp
Expand Up @@ -20,6 +20,7 @@
#include "qgscolordialog.h"
#include "qgscptcityarchive.h"
#include "qgssettings.h"
#include "qgsgui.h"

#include <QColorDialog>
#include <QHeaderView>
Expand Down Expand Up @@ -48,6 +49,7 @@ QgsGradientColorRampDialog::QgsGradientColorRampDialog( const QgsGradientColorRa
, mCurrentPlotMarkerIndex( 0 )
{
setupUi( this );
QgsGui::instance()->enableAutoGeometryRestore( this );
connect( cboType, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsGradientColorRampDialog::cboType_currentIndexChanged );
connect( btnInformation, &QPushButton::pressed, this, &QgsGradientColorRampDialog::btnInformation_pressed );
connect( mPositionSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsGradientColorRampDialog::mPositionSpinBox_valueChanged );
Expand Down Expand Up @@ -93,9 +95,6 @@ QgsGradientColorRampDialog::QgsGradientColorRampDialog( const QgsGradientColorRa
connect( mColorWidget, &QgsCompoundColorWidget::currentColorChanged, this, &QgsGradientColorRampDialog::colorWidgetChanged );
connect( mDeleteStopButton, &QAbstractButton::clicked, mStopEditor, &QgsGradientStopEditor::deleteSelectedStop );

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

// hide the ugly canvas frame
mPlot->setFrameStyle( QFrame::NoFrame );
QFrame *plotCanvasFrame = dynamic_cast<QFrame *>( mPlot->canvas() );
Expand Down Expand Up @@ -142,6 +141,7 @@ QgsGradientColorRampDialog::QgsGradientColorRampDialog( const QgsGradientColorRa
connect( mPlotFilter, &QgsGradientPlotEventFilter::mouseRelease, this, &QgsGradientColorRampDialog::plotMouseRelease );
connect( mPlotFilter, &QgsGradientPlotEventFilter::mouseMove, this, &QgsGradientColorRampDialog::plotMouseMove );

QgsSettings settings;
mPlotHueCheckbox->setChecked( settings.value( QStringLiteral( "GradientEditor/plotHue" ), false ).toBool() );
mPlotLightnessCheckbox->setChecked( settings.value( QStringLiteral( "GradientEditor/plotLightness" ), true ).toBool() );
mPlotSaturationCheckbox->setChecked( settings.value( QStringLiteral( "GradientEditor/plotSaturation" ), false ).toBool() );
Expand All @@ -161,7 +161,6 @@ QgsGradientColorRampDialog::QgsGradientColorRampDialog( const QgsGradientColorRa
QgsGradientColorRampDialog::~QgsGradientColorRampDialog()
{
QgsSettings settings;
settings.setValue( QStringLiteral( "Windows/GradientEditor/geometry" ), saveGeometry() );
settings.setValue( QStringLiteral( "GradientEditor/plotHue" ), mPlotHueCheckbox->isChecked() );
settings.setValue( QStringLiteral( "GradientEditor/plotLightness" ), mPlotLightnessCheckbox->isChecked() );
settings.setValue( QStringLiteral( "GradientEditor/plotSaturation" ), mPlotSaturationCheckbox->isChecked() );
Expand Down

0 comments on commit 62e8a9b

Please sign in to comment.