Skip to content

Commit 2d9b573

Browse files
committedNov 7, 2017
Make custom projections dialog a bit more user friendly
...by updating the list immediately when changes are made to the current projection's name or definition. Previously the list was only updated when a new item in the list was clicked, but that made it appear as though the current changes were not applied immediately and left users looking for a "save" button to actually lock-in their changes. By updating the list immediately we make it obvious that the changes apply immediately and no further action is required (except for hitting OK on the dialog!)
1 parent e45c294 commit 2d9b573

File tree

2 files changed

+26
-4
lines changed

2 files changed

+26
-4
lines changed
 

‎src/app/qgscustomprojectiondialog.cpp

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -185,13 +185,15 @@ QgsCustomProjectionDialog::QgsCustomProjectionDialog( QWidget *parent, Qt::Windo
185185
populateList();
186186
if ( !mCustomCRSnames.empty() )
187187
{
188-
leName->setText( mCustomCRSnames[0] );
189-
teParameters->setPlainText( mCustomCRSparameters[0] );
188+
whileBlocking( leName )->setText( mCustomCRSnames[0] );
189+
whileBlocking( teParameters )->setPlainText( mCustomCRSparameters[0] );
190190
leNameList->setCurrentItem( leNameList->topLevelItem( 0 ) );
191191
}
192192

193193
leNameList->hideColumn( QgisCrsIdColumn );
194194

195+
connect( leName, &QLineEdit::textChanged, this, &QgsCustomProjectionDialog::updateListFromCurrentItem );
196+
connect( teParameters, &QPlainTextEdit::textChanged, this, &QgsCustomProjectionDialog::updateListFromCurrentItem );
195197
}
196198

197199
QgsCustomProjectionDialog::~QgsCustomProjectionDialog()
@@ -451,8 +453,8 @@ void QgsCustomProjectionDialog::leNameList_currentItemChanged( QTreeWidgetItem *
451453
if ( current )
452454
{
453455
currentIndex = leNameList->indexOfTopLevelItem( current );
454-
leName->setText( mCustomCRSnames[currentIndex] );
455-
teParameters->setPlainText( current->text( QgisCrsParametersColumn ) );
456+
whileBlocking( leName )->setText( mCustomCRSnames[currentIndex] );
457+
whileBlocking( teParameters )->setPlainText( current->text( QgisCrsParametersColumn ) );
456458
}
457459
else
458460
{
@@ -541,6 +543,22 @@ void QgsCustomProjectionDialog::buttonBox_accepted()
541543
}
542544
}
543545

546+
void QgsCustomProjectionDialog::updateListFromCurrentItem()
547+
{
548+
QTreeWidgetItem *item = leNameList->currentItem();
549+
if ( !item )
550+
return;
551+
552+
int currentIndex = leNameList->indexOfTopLevelItem( item );
553+
if ( currentIndex < 0 )
554+
return;
555+
556+
mCustomCRSnames[currentIndex] = leName->text();
557+
mCustomCRSparameters[currentIndex] = teParameters->toPlainText();
558+
item->setText( QgisCrsNameColumn, leName->text() );
559+
item->setText( QgisCrsParametersColumn, teParameters->toPlainText() );
560+
}
561+
544562
void QgsCustomProjectionDialog::pbnCalculate_clicked()
545563
{
546564
// We must check the prj def is valid!

‎src/app/qgscustomprojectiondialog.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ class APP_EXPORT QgsCustomProjectionDialog : public QDialog, private Ui::QgsCust
4343
void leNameList_currentItemChanged( QTreeWidgetItem *current, QTreeWidgetItem *prev );
4444
void buttonBox_accepted();
4545

46+
private slots:
47+
48+
void updateListFromCurrentItem();
49+
4650
private:
4751

4852
//helper functions

0 commit comments

Comments
 (0)