Skip to content

Commit

Permalink
Cleanup dialog code
Browse files Browse the repository at this point in the history
(cherry picked from commit a2bb366)
  • Loading branch information
nyalldawson committed Feb 14, 2022
1 parent e3399e5 commit 5599bb9
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 56 deletions.
42 changes: 15 additions & 27 deletions src/app/georeferencer/qgstransformsettingsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,16 +89,16 @@ QgsTransformSettingsDialog::QgsTransformSettingsDialog( const QString &raster, c
cmbTransformType->addItem( tr( "Projective" ), static_cast<int>( QgsGcpTransformerInterface::TransformMethod::Projective ) );

// Populate CompressionComboBox
mListCompression.append( QStringLiteral( "None" ) );
mListCompression.append( QStringLiteral( "LZW" ) );
mListCompression.append( QStringLiteral( "PACKBITS" ) );
mListCompression.append( QStringLiteral( "DEFLATE" ) );
QStringList listCompressionTr;
for ( const QString &item : std::as_const( mListCompression ) )
{
listCompressionTr.append( tr( item.toLatin1().data() ) );
}
cmbCompressionComboBox->addItems( listCompressionTr );
cmbCompressionComboBox->addItem( tr( "None" ), QStringLiteral( "None" ) );
cmbCompressionComboBox->addItem( tr( "LZW" ), QStringLiteral( "LZW" ) );
cmbCompressionComboBox->addItem( tr( "PACKBITS" ), QStringLiteral( "PACKBITS" ) );
cmbCompressionComboBox->addItem( tr( "DEFLATE" ), QStringLiteral( "DEFLATE" ) );

cmbResampling->addItem( tr( "Nearest Neighbour" ), QgsImageWarper::ResamplingMethod::NearestNeighbour );
cmbResampling->addItem( tr( "Linear" ), QgsImageWarper::ResamplingMethod::Bilinear );
cmbResampling->addItem( tr( "Cubic" ), QgsImageWarper::ResamplingMethod::Cubic );
cmbResampling->addItem( tr( "Cubic Spline" ), QgsImageWarper::ResamplingMethod::CubicSpline );
cmbResampling->addItem( tr( "Lanczos" ), QgsImageWarper::ResamplingMethod::Lanczos );

cmbTransformType->setCurrentIndex( settings.value( QStringLiteral( "/Plugin-GeoReferencer/lasttransformation" ), -1 ).toInt() );
cmbResampling->setCurrentIndex( settings.value( QStringLiteral( "/Plugin-GeoReferencer/lastresampling" ), 0 ).toInt() );
Expand Down Expand Up @@ -142,8 +142,8 @@ void QgsTransformSettingsDialog::getTransformSettings( QgsGeorefTransform::Trans
else
tp = static_cast< QgsGcpTransformerInterface::TransformMethod >( cmbTransformType->currentData().toInt() );

rm = ( QgsImageWarper::ResamplingMethod )cmbResampling->currentIndex();
comprMethod = mListCompression.at( cmbCompressionComboBox->currentIndex() ).toUpper();
rm = static_cast< QgsImageWarper::ResamplingMethod >( cmbResampling->currentData().toInt() );
comprMethod = cmbCompressionComboBox->currentData().toString();
if ( mWorldFileCheckBox->isChecked() )
{
raster.clear();
Expand Down Expand Up @@ -183,19 +183,6 @@ void QgsTransformSettingsDialog::resetSettings()
s.setValue( QStringLiteral( "/Plugin-GeoReferencer/lastPDFReportDir" ), QDir::homePath() );
}

void QgsTransformSettingsDialog::changeEvent( QEvent *e )
{
QDialog::changeEvent( e );
switch ( e->type() )
{
case QEvent::LanguageChange:
retranslateUi( this );
break;
default:
break;
}
}

void QgsTransformSettingsDialog::accept()
{
if ( !mOutputRaster->filePath().isEmpty() )
Expand Down Expand Up @@ -236,9 +223,10 @@ void QgsTransformSettingsDialog::accept()
QDialog::accept();
}

void QgsTransformSettingsDialog::cmbTransformType_currentIndexChanged( const QString &text )
void QgsTransformSettingsDialog::cmbTransformType_currentIndexChanged( const QString & )
{
if ( text == tr( "Linear" ) )
if ( cmbTransformType->currentIndex() != -1
&& static_cast< QgsGcpTransformerInterface::TransformMethod >( cmbTransformType->currentData().toInt() ) == QgsGcpTransformerInterface::TransformMethod::Linear )
{
mWorldFileCheckBox->setEnabled( true );
}
Expand Down
3 changes: 0 additions & 3 deletions src/app/georeferencer/qgstransformsettingsdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ class QgsTransformSettingsDialog : public QDialog, private Ui::QgsTransformSetti
static void resetSettings();

protected:
void changeEvent( QEvent *e ) override;
void accept() override;

private slots:
Expand All @@ -58,8 +57,6 @@ class QgsTransformSettingsDialog : public QDialog, private Ui::QgsTransformSetti
QString generateModifiedRasterFileName( const QString &raster );

QString mSourceRasterFile;

QStringList mListCompression;
};

#endif // QGSTRANSFORMSETTINGSDIALOG_H
27 changes: 1 addition & 26 deletions src/ui/georeferencer/qgstransformsettingsdialogbase.ui
Original file line number Diff line number Diff line change
Expand Up @@ -240,33 +240,8 @@
<item row="1" column="1">
<widget class="QComboBox" name="cmbResampling">
<property name="currentIndex">
<number>0</number>
<number>-1</number>
</property>
<item>
<property name="text">
<string>Nearest neighbour</string>
</property>
</item>
<item>
<property name="text">
<string>Linear</string>
</property>
</item>
<item>
<property name="text">
<string>Cubic</string>
</property>
</item>
<item>
<property name="text">
<string>Cubic Spline</string>
</property>
</item>
<item>
<property name="text">
<string>Lanczos</string>
</property>
</item>
</widget>
</item>
<item row="1" column="0">
Expand Down

0 comments on commit 5599bb9

Please sign in to comment.