Skip to content
Permalink
Browse files

Locale support for extent and raster save as dlg

Fixes #41284

(cherry picked from commit 10a3740)
  • Loading branch information
elpaso authored and nyalldawson committed Feb 19, 2021
1 parent 1ffbb78 commit bee54fb543edb87391ba95cf8288463651b6e89c
Showing with 23 additions and 22 deletions.
  1. +11 −11 src/gui/qgsextentwidget.cpp
  2. +12 −11 src/gui/qgsrasterlayersaveasdialog.cpp
@@ -21,10 +21,10 @@
#include "qgsmaplayermodel.h"
#include "qgsexception.h"
#include "qgsproject.h"
#include "qgsdoublevalidator.h"

#include <QMenu>
#include <QAction>
#include <QDoubleValidator>
#include <QRegularExpression>

QgsExtentWidget::QgsExtentWidget( QWidget *parent, WidgetStyle style )
@@ -62,10 +62,10 @@ QgsExtentWidget::QgsExtentWidget( QWidget *parent, WidgetStyle style )
mCondensedToolButton->setMenu( mMenu );
mCondensedToolButton->setPopupMode( QToolButton::InstantPopup );

mXMinLineEdit->setValidator( new QDoubleValidator( this ) );
mXMaxLineEdit->setValidator( new QDoubleValidator( this ) );
mYMinLineEdit->setValidator( new QDoubleValidator( this ) );
mYMaxLineEdit->setValidator( new QDoubleValidator( this ) );
mXMinLineEdit->setValidator( new QgsDoubleValidator( this ) );
mXMaxLineEdit->setValidator( new QgsDoubleValidator( this ) );
mYMinLineEdit->setValidator( new QgsDoubleValidator( this ) );
mYMaxLineEdit->setValidator( new QgsDoubleValidator( this ) );

mOriginalExtentButton->setVisible( false );
mButtonDrawOnCanvas->setVisible( false );
@@ -203,10 +203,10 @@ void QgsExtentWidget::setOutputExtent( const QgsRectangle &r, const QgsCoordinat
decimals = 4;
break;
}
mXMinLineEdit->setText( QString::number( extent.xMinimum(), 'f', decimals ) );
mXMaxLineEdit->setText( QString::number( extent.xMaximum(), 'f', decimals ) );
mYMinLineEdit->setText( QString::number( extent.yMinimum(), 'f', decimals ) );
mYMaxLineEdit->setText( QString::number( extent.yMaximum(), 'f', decimals ) );
mXMinLineEdit->setText( QLocale().toString( extent.xMinimum(), 'f', decimals ) );
mXMaxLineEdit->setText( QLocale().toString( extent.xMaximum(), 'f', decimals ) );
mYMinLineEdit->setText( QLocale().toString( extent.yMinimum(), 'f', decimals ) );
mYMaxLineEdit->setText( QLocale().toString( extent.yMaximum(), 'f', decimals ) );

QString condensed = QStringLiteral( "%1,%2,%3,%4" ).arg( mXMinLineEdit->text(),
mXMaxLineEdit->text(),
@@ -416,8 +416,8 @@ void QgsExtentWidget::extentDrawn( const QgsRectangle &extent )

QgsRectangle QgsExtentWidget::outputExtent() const
{
return QgsRectangle( mXMinLineEdit->text().toDouble(), mYMinLineEdit->text().toDouble(),
mXMaxLineEdit->text().toDouble(), mYMaxLineEdit->text().toDouble() );
return QgsRectangle( QLocale().toDouble( mXMinLineEdit->text() ), QLocale().toDouble( mYMinLineEdit->text() ),
QLocale().toDouble( mXMaxLineEdit->text() ), QLocale().toDouble( mYMaxLineEdit->text() ) );
}

void QgsExtentWidget::setMapCanvas( QgsMapCanvas *canvas )
@@ -31,6 +31,7 @@
#include <gdal.h>
#include "qgsmessagelog.h"
#include "qgsgui.h"
#include "qgsdoublevalidator.h"

#include <QFileDialog>
#include <QMessageBox>
@@ -296,8 +297,8 @@ void QgsRasterLayerSaveAsDialog::insertAvailableOutputFormats()

void QgsRasterLayerSaveAsDialog::setValidators()
{
mXResolutionLineEdit->setValidator( new QDoubleValidator( this ) );
mYResolutionLineEdit->setValidator( new QDoubleValidator( this ) );
mXResolutionLineEdit->setValidator( new QgsDoubleValidator( this ) );
mYResolutionLineEdit->setValidator( new QgsDoubleValidator( this ) );
mColumnsLineEdit->setValidator( new QIntValidator( this ) );
mRowsLineEdit->setValidator( new QIntValidator( this ) );
mMaximumSizeXLineEdit->setValidator( new QIntValidator( this ) );
@@ -353,12 +354,12 @@ int QgsRasterLayerSaveAsDialog::nRows() const

double QgsRasterLayerSaveAsDialog::xResolution() const
{
return mXResolutionLineEdit->text().toDouble();
return QLocale().toDouble( mXResolutionLineEdit->text() );
}

double QgsRasterLayerSaveAsDialog::yResolution() const
{
return mYResolutionLineEdit->text().toDouble();
return QLocale().toDouble( mYResolutionLineEdit->text() );
}

int QgsRasterLayerSaveAsDialog::maximumTileSizeX() const
@@ -534,8 +535,8 @@ void QgsRasterLayerSaveAsDialog::setResolution( double xRes, double yRes, const
xRes = extent.width();
yRes = extent.height();
}
mXResolutionLineEdit->setText( QString::number( xRes ) );
mYResolutionLineEdit->setText( QString::number( yRes ) );
mXResolutionLineEdit->setText( QLocale().toString( xRes ) );
mYResolutionLineEdit->setText( QLocale().toString( yRes ) );
}

void QgsRasterLayerSaveAsDialog::recalcSize()
@@ -560,8 +561,8 @@ void QgsRasterLayerSaveAsDialog::recalcResolution()
QgsRectangle extent = outputRectangle();
double xRes = nColumns() != 0 ? extent.width() / nColumns() : 0;
double yRes = nRows() != 0 ? extent.height() / nRows() : 0;
mXResolutionLineEdit->setText( QString::number( xRes ) );
mYResolutionLineEdit->setText( QString::number( yRes ) );
mXResolutionLineEdit->setText( QLocale().toString( xRes ) );
mYResolutionLineEdit->setText( QLocale().toString( yRes ) );
updateResolutionStateMsg();
}

@@ -702,7 +703,7 @@ void QgsRasterLayerSaveAsDialog::addNoDataRow( double min, double max )
{
case Qgis::Float32:
case Qgis::Float64:
lineEdit->setValidator( new QDoubleValidator( nullptr ) );
lineEdit->setValidator( new QgsDoubleValidator( nullptr ) );
if ( !std::isnan( value ) )
{
valueString = QgsRasterBlock::printValue( value );
@@ -712,7 +713,7 @@ void QgsRasterLayerSaveAsDialog::addNoDataRow( double min, double max )
lineEdit->setValidator( new QIntValidator( nullptr ) );
if ( !std::isnan( value ) )
{
valueString = QString::number( static_cast<int>( value ) );
valueString = QLocale().toString( static_cast<int>( value ) );
}
break;
}
@@ -854,7 +855,7 @@ double QgsRasterLayerSaveAsDialog::noDataCellValue( int row, int column ) const
{
return std::numeric_limits<double>::quiet_NaN();
}
return lineEdit->text().toDouble();
return QLocale().toDouble( lineEdit->text() );
}

void QgsRasterLayerSaveAsDialog::adjustNoDataCellWidth( int row, int column )

0 comments on commit bee54fb

Please sign in to comment.