Skip to content
Permalink
Browse files

force most core dialogs to remember their state and restore it when

opened (adresses #206)
  • Loading branch information
alexbruy committed Jan 19, 2012
1 parent 32824e2 commit 27249d88d1a86e2eb92c72b2d971162c467cf7e0
@@ -23,12 +23,17 @@
#include <QInputDialog>
#include <QListWidgetItem>
#include <QMessageBox>
#include <QSettings>

QgsComposerManager::QgsComposerManager( QWidget * parent, Qt::WindowFlags f ): QDialog( parent, f )
{
QPushButton *pb;

setupUi( this );

QSettings settings;
restoreGeometry( settings.value( "/Windows/ComposerManager/geometry" ).toByteArray() );

connect( mButtonBox, SIGNAL( rejected() ), this, SLOT( close() ) );

pb = new QPushButton( tr( "&Show" ) );
@@ -48,7 +53,8 @@ QgsComposerManager::QgsComposerManager( QWidget * parent, Qt::WindowFlags f ): Q

QgsComposerManager::~QgsComposerManager()
{

QSettings settings;
settings.setValue( "/Windows/ComposerManager/geometry", saveGeometry() );
}

void QgsComposerManager::initialize()
@@ -38,6 +38,9 @@ QgsNewOgrConnection::QgsNewOgrConnection( QWidget *parent, const QString& connTy
{
setupUi( this );

QSettings settings;
restoreGeometry( settings.value( "/Windows/OGRDatabaseConnection/geometry" ).toByteArray() );

//add database drivers
QStringList dbDrivers = QgsProviderRegistry::instance()->databaseDrivers().split( ";" );
for ( int i = 0; i < dbDrivers.count(); i++ )
@@ -51,7 +54,6 @@ QgsNewOgrConnection::QgsNewOgrConnection( QWidget *parent, const QString& connTy
{
// populate the dialog with the information stored for the connection
// populate the fields with the stored setting parameters
QSettings settings;
QString key = "/" + connType + "/connections/" + connName;
txtHost->setText( settings.value( key + "/host" ).toString() );
txtDatabase->setText( settings.value( key + "/database" ).toString() );
@@ -72,6 +74,8 @@ QgsNewOgrConnection::QgsNewOgrConnection( QWidget *parent, const QString& connTy

QgsNewOgrConnection::~QgsNewOgrConnection()
{
QSettings settings;
settings.setValue( "/Windows/OGRDatabaseConnection/geometry", saveGeometry() );
}

void QgsNewOgrConnection::testConnection()
@@ -15,19 +15,26 @@

#include "qgsogrsublayersdialog.h"

#include <QSettings>
#include <QTableWidgetItem>


QgsOGRSublayersDialog::QgsOGRSublayersDialog( QWidget* parent, Qt::WFlags fl )
: QDialog( parent, fl )
{
setupUi( this );

QSettings settings;
restoreGeometry( settings.value( "/Windows/OGRSubLayers/geometry" ).toByteArray() );

QStringList labels = QStringList() << tr( "Layer ID" ) << tr( "Layer name" ) << tr( "Nb of features" ) << tr( "Geometry type" );
layersTable->setHeaderLabels( labels );
}

QgsOGRSublayersDialog::~QgsOGRSublayersDialog()
{
QSettings settings;
settings.setValue( "/Windows/OGRSubLayers/geometry", saveGeometry() );
}

QStringList QgsOGRSublayersDialog::getSelection()
@@ -48,6 +48,8 @@ QgsOpenVectorLayerDialog::QgsOpenVectorLayerDialog( QWidget* parent, Qt::WFlags
QSettings settings;
QString enc = settings.value( "/UI/encoding", QString( "System" ) ).toString();

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

// The specified decoding is added if not existing alread, and then set current.
// This should select it.
int encindex = cmbEncodings->findText( enc );
@@ -93,6 +95,8 @@ QgsOpenVectorLayerDialog::QgsOpenVectorLayerDialog( QWidget* parent, Qt::WFlags

QgsOpenVectorLayerDialog::~QgsOpenVectorLayerDialog()
{
QSettings settings;
settings.setValue( "/Windows/OpenVectorLayer/geometry", saveGeometry() );
}

QStringList QgsOpenVectorLayerDialog::openFile()
@@ -31,6 +31,7 @@ QgsVectorLayerSaveAsDialog::QgsVectorLayerSaveAsDialog( QWidget* parent, Qt::WFl
setupUi( this );

QSettings settings;
restoreGeometry( settings.value( "/Windows/VectorLayerSaveAs/geometry" ).toByteArray() );
QMap<QString, QString> map = QgsVectorFileWriter::ogrDriverList();
mFormatComboBox->blockSignals( true );
for ( QMap< QString, QString>::const_iterator it = map.constBegin(); it != map.constEnd(); ++it )
@@ -64,6 +65,8 @@ QgsVectorLayerSaveAsDialog::QgsVectorLayerSaveAsDialog( QWidget* parent, Qt::WFl

QgsVectorLayerSaveAsDialog::~QgsVectorLayerSaveAsDialog()
{
QSettings settings;
settings.setValue( "/Windows/VectorLayerSaveAs/geometry", saveGeometry() );
}

void QgsVectorLayerSaveAsDialog::accept()
@@ -2096,13 +2096,6 @@ void QgisApp::about()
abt->activateWindow();
}








/**
This method prompts the user for a list of vector file names with a dialog.
*/
@@ -28,6 +28,7 @@
#include <QFileInfo>
#include <QMessageBox>
#include <QLocale>
#include <QSettings>

//stdc++ includes
#include <fstream>
@@ -45,6 +46,9 @@ QgsCustomProjectionDialog::QgsCustomProjectionDialog( QWidget *parent, Qt::WFlag
{
setupUi( this );

QSettings settings;
restoreGeometry( settings.value( "/Windows/CustomProjection/geometry" ).toByteArray() );

pbnFirst->setIcon( QgisApp::getThemeIcon( "mIconFirst.png" ) );
pbnPrevious->setIcon( QgisApp::getThemeIcon( "mIconPrevious.png" ) );
pbnNext->setIcon( QgisApp::getThemeIcon( "mIconNext.png" ) );
@@ -87,7 +91,8 @@ QgsCustomProjectionDialog::QgsCustomProjectionDialog( QWidget *parent, Qt::WFlag

QgsCustomProjectionDialog::~QgsCustomProjectionDialog()
{

QSettings settings;
settings.setValue( "/Windows/CustomProjection/geometry", saveGeometry() );
}

void QgsCustomProjectionDialog::on_pbnDelete_clicked()
@@ -19,13 +19,16 @@
#include <QColorDialog>
#include <QColor>
#include <QFont>


#include <QSettings>

QgsDecorationCopyrightDialog::QgsDecorationCopyrightDialog( QgsDecorationCopyright& deco, QWidget* parent )
: QDialog( parent ), mDeco( deco )
{
setupUi( this );

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

//programmatically hide orientation selection for now
cboOrientation->hide();
textLabel15->hide();
@@ -47,6 +50,8 @@ QgsDecorationCopyrightDialog::QgsDecorationCopyrightDialog( QgsDecorationCopyrig

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

void QgsDecorationCopyrightDialog::on_buttonBox_accepted()
@@ -18,14 +18,17 @@
#include "qgscontexthelp.h"

#include <QPainter>
#include <QSettings>
#include <cmath>


QgsDecorationNorthArrowDialog::QgsDecorationNorthArrowDialog( QgsDecorationNorthArrow& deco, QWidget* parent )
: QDialog( parent ), mDeco( deco )
{
setupUi( this );

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

// rotation
rotatePixmap( mDeco.mRotationInt );
// signal/slot connection defined in 'designer' causes the slider to
@@ -46,6 +49,8 @@ QgsDecorationNorthArrowDialog::QgsDecorationNorthArrowDialog( QgsDecorationNorth

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

void QgsDecorationNorthArrowDialog::on_buttonBox_helpRequested()
@@ -18,12 +18,16 @@
#include "qgscontexthelp.h"

#include <QColorDialog>
#include <QSettings>

QgsDecorationScaleBarDialog::QgsDecorationScaleBarDialog( QgsDecorationScaleBar& deco, int units, QWidget* parent )
: QDialog( parent ), mDeco( deco )
{
setupUi( this );

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

// set the map units in the spin box
switch ( units )
{
@@ -59,6 +63,8 @@ QgsDecorationScaleBarDialog::QgsDecorationScaleBarDialog( QgsDecorationScaleBar&

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

void QgsDecorationScaleBarDialog::on_buttonBox_helpRequested()
@@ -10,11 +10,17 @@
QgsEmbedLayerDialog::QgsEmbedLayerDialog( QWidget * parent, Qt::WindowFlags f ): QDialog( parent, f )
{
setupUi( this );

QSettings settings;
restoreGeometry( settings.value( "/Windows/EmbedLayer/geometry" ).toByteArray() );

QObject::connect( mButtonBox, SIGNAL( rejected() ), this, SLOT( reject() ) );
}

QgsEmbedLayerDialog::~QgsEmbedLayerDialog()
{
QSettings settings;
settings.setValue( "/Windows/EmbedLayer/geometry", saveGeometry() );
}

QList< QPair < QString, QString > > QgsEmbedLayerDialog::embeddedGroups() const
@@ -32,6 +32,7 @@
#include <QTextEdit>
#include <QApplication>
#include <QMessageBox>
#include <QSettings>

QgsLabelingGui::QgsLabelingGui( QgsPalLabeling* lbl, QgsVectorLayer* layer, QgsMapCanvas* mapCanvas, QWidget* parent )
: QDialog( parent ), mLBL( lbl ), mLayer( layer ), mMapCanvas( mapCanvas )
@@ -40,6 +41,9 @@ QgsLabelingGui::QgsLabelingGui( QgsPalLabeling* lbl, QgsVectorLayer* layer, QgsM

setupUi( this );

QSettings settings;
restoreGeometry( settings.value( "/Windows/Labeling/geometry" ).toByteArray() );

connect( btnTextColor, SIGNAL( clicked() ), this, SLOT( changeTextColor() ) );
connect( btnChangeFont, SIGNAL( clicked() ), this, SLOT( changeTextFont() ) );
connect( chkBuffer, SIGNAL( toggled( bool ) ), this, SLOT( updatePreview() ) );
@@ -207,6 +211,8 @@ QgsLabelingGui::QgsLabelingGui( QgsPalLabeling* lbl, QgsVectorLayer* layer, QgsM

QgsLabelingGui::~QgsLabelingGui()
{
QSettings settings;
settings.setValue( "/Windows/Labeling/geometry", saveGeometry() );
}

void QgsLabelingGui::apply()
@@ -44,6 +44,10 @@ QgsNewSpatialiteLayerDialog::QgsNewSpatialiteLayerDialog( QWidget *parent, Qt::W
: QDialog( parent, fl )
{
setupUi( this );

QSettings settings;
restoreGeometry( settings.value( "/Windows/NewSpatiaLiteLayer/geometry" ).toByteArray() );

mAddAttributeButton->setIcon( QgisApp::getThemeIcon( "/mActionNewAttribute.png" ) );
mRemoveAttributeButton->setIcon( QgisApp::getThemeIcon( "/mActionDeleteAttribute.png" ) );
mTypeBox->addItem( tr( "Text data" ), "text" );
@@ -52,7 +56,6 @@ QgsNewSpatialiteLayerDialog::QgsNewSpatialiteLayerDialog( QWidget *parent, Qt::W

mPointRadioButton->setChecked( true );
// Populate the database list from the stored connections
QSettings settings;
settings.beginGroup( "/SpatiaLite/connections" );
QStringList keys = settings.childGroups();
QStringList::Iterator it = keys.begin();
@@ -87,6 +90,8 @@ QgsNewSpatialiteLayerDialog::QgsNewSpatialiteLayerDialog( QWidget *parent, Qt::W

QgsNewSpatialiteLayerDialog::~QgsNewSpatialiteLayerDialog()
{
QSettings settings;
settings.setValue( "/Windows/NewSpatiaLiteLayer/geometry", saveGeometry() );
}

void QgsNewSpatialiteLayerDialog::on_mTypeBox_currentIndexChanged( int index )
@@ -19,6 +19,7 @@

#include <qgsgenericprojectionselector.h>
#include <QApplication>
#include <QSettings>

/**
* \class QgsGenericProjectionSelector
@@ -29,6 +30,10 @@ QgsGenericProjectionSelector::QgsGenericProjectionSelector( QWidget *parent,
: QDialog( parent, fl )
{
setupUi( this );

QSettings settings;
restoreGeometry( settings.value( "/Windows/ProjectionSelector/geometry" ).toByteArray() );

//we will show this only when a message is set
textEdit->hide();
}
@@ -55,7 +60,10 @@ void QgsGenericProjectionSelector::setMessage( QString theMessage )
}
//! Destructor
QgsGenericProjectionSelector::~QgsGenericProjectionSelector()
{}
{
QSettings settings;
settings.setValue( "/Windows/ProjectionSelector/geometry", saveGeometry() );
}

void QgsGenericProjectionSelector::setSelectedEpsg( long theId )
{
@@ -35,6 +35,9 @@ QgsNewVectorLayerDialog::QgsNewVectorLayerDialog( QWidget *parent, Qt::WFlags fl
{
setupUi( this );

QSettings settings;
restoreGeometry( settings.value( "/Windows/NewVectorLayer/geometry" ).toByteArray() );

// TODO: do it without QgisApp
//mAddAttributeButton->setIcon( QgisApp::getThemeIcon( "/mActionNewAttribute.png" ) );
//mRemoveAttributeButton->setIcon( QgisApp::getThemeIcon( "/mActionDeleteAttribute.png" ) );
@@ -77,6 +80,8 @@ QgsNewVectorLayerDialog::QgsNewVectorLayerDialog( QWidget *parent, Qt::WFlags fl

QgsNewVectorLayerDialog::~QgsNewVectorLayerDialog()
{
QSettings settings;
settings.setValue( "/Windows/NewVectorLayer/geometry", saveGeometry() );
}

void QgsNewVectorLayerDialog::on_mTypeBox_currentIndexChanged( int index )
@@ -32,6 +32,9 @@ QgsQueryBuilder::QgsQueryBuilder( QgsVectorLayer *layer,
{
setupUi( this );

QSettings settings;
restoreGeometry( settings.value( "/Windows/QueryBuilder/geometry" ).toByteArray() );

QPushButton *pbn = new QPushButton( tr( "&Test" ) );
buttonBox->addButton( pbn, QDialogButtonBox::ActionRole );
connect( pbn, SIGNAL( clicked() ), this, SLOT( test() ) );
@@ -52,6 +55,8 @@ QgsQueryBuilder::QgsQueryBuilder( QgsVectorLayer *layer,

QgsQueryBuilder::~QgsQueryBuilder()
{
QSettings settings;
settings.setValue( "/Windows/QueryBuilder/geometry", saveGeometry() );
}

void QgsQueryBuilder::populateFields()

0 comments on commit 27249d8

Please sign in to comment.
You can’t perform that action at this time.