mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-28 00:17:30 -05:00
[raster calc] make use of qgsfilewidget and fix some labels
This commit is contained in:
parent
a29d6d27d2
commit
b6ff401452
@ -34,12 +34,10 @@ QgsRasterCalcDialog::QgsRasterCalcDialog( QgsRasterLayer *rasterLayer, QWidget *
|
||||
setupUi( this );
|
||||
QgsGui::instance()->enableAutoGeometryRestore( this );
|
||||
|
||||
connect( mOutputLayerPushButton, &QPushButton::clicked, this, &QgsRasterCalcDialog::mOutputLayerPushButton_clicked );
|
||||
connect( mRasterBandsListWidget, &QListWidget::itemDoubleClicked, this, &QgsRasterCalcDialog::mRasterBandsListWidget_itemDoubleClicked );
|
||||
connect( mButtonBox, &QDialogButtonBox::accepted, this, &QgsRasterCalcDialog::mButtonBox_accepted );
|
||||
connect( mCurrentLayerExtentButton, &QPushButton::clicked, this, &QgsRasterCalcDialog::mCurrentLayerExtentButton_clicked );
|
||||
connect( mExpressionTextEdit, &QTextEdit::textChanged, this, &QgsRasterCalcDialog::mExpressionTextEdit_textChanged );
|
||||
connect( mOutputLayerLineEdit, &QLineEdit::textChanged, this, &QgsRasterCalcDialog::mOutputLayerLineEdit_textChanged );
|
||||
connect( mPlusPushButton, &QPushButton::clicked, this, &QgsRasterCalcDialog::mPlusPushButton_clicked );
|
||||
connect( mMinusPushButton, &QPushButton::clicked, this, &QgsRasterCalcDialog::mMinusPushButton_clicked );
|
||||
connect( mMultiplyPushButton, &QPushButton::clicked, this, &QgsRasterCalcDialog::mMultiplyPushButton_clicked );
|
||||
@ -77,6 +75,11 @@ QgsRasterCalcDialog::QgsRasterCalcDialog( QgsRasterLayer *rasterLayer, QWidget *
|
||||
insertAvailableRasterBands();
|
||||
|
||||
mExpressionTextEdit->setCurrentFont( QFontDatabase::systemFont( QFontDatabase::FixedFont ) );
|
||||
|
||||
QgsSettings settings;
|
||||
mOutputLayer->setDialogTitle( tr( "Enter result file" ) );
|
||||
mOutputLayer->setDefaultRoot( settings.value( QStringLiteral( "/RasterCalculator/lastOutputDir" ), QDir::homePath() ).toString() );
|
||||
connect( mOutputLayer, &QgsFileWidget::fileChanged, this, [ = ]() { setAcceptButtonState(); } );
|
||||
}
|
||||
|
||||
QString QgsRasterCalcDialog::formulaString() const
|
||||
@ -86,7 +89,7 @@ QString QgsRasterCalcDialog::formulaString() const
|
||||
|
||||
QString QgsRasterCalcDialog::outputFile() const
|
||||
{
|
||||
QString outputFileName = mOutputLayerLineEdit->text();
|
||||
QString outputFileName = mOutputLayer->filePath();
|
||||
QFileInfo fileInfo( outputFileName );
|
||||
QString suffix = fileInfo.suffix();
|
||||
if ( !suffix.isEmpty() )
|
||||
@ -253,7 +256,7 @@ void QgsRasterCalcDialog::mButtonBox_accepted()
|
||||
//save last output format
|
||||
QgsSettings s;
|
||||
s.setValue( QStringLiteral( "/RasterCalculator/lastOutputFormat" ), QVariant( mOutputFormatComboBox->currentText() ) );
|
||||
s.setValue( QStringLiteral( "/RasterCalculator/lastOutputDir" ), QVariant( QFileInfo( mOutputLayerLineEdit->text() ).absolutePath() ) );
|
||||
s.setValue( QStringLiteral( "/RasterCalculator/lastOutputDir" ), QVariant( QFileInfo( mOutputLayer->filePath() ).absolutePath() ) );
|
||||
}
|
||||
|
||||
void QgsRasterCalcDialog::showHelp()
|
||||
@ -261,16 +264,6 @@ void QgsRasterCalcDialog::showHelp()
|
||||
QgsHelp::openHelp( QStringLiteral( "working_with_raster/raster_analysis.html#raster-calculator" ) );
|
||||
}
|
||||
|
||||
void QgsRasterCalcDialog::mOutputLayerPushButton_clicked()
|
||||
{
|
||||
QgsSettings s;
|
||||
QString saveFileName = QFileDialog::getSaveFileName( nullptr, tr( "Enter result file" ), s.value( QStringLiteral( "/RasterCalculator/lastOutputDir" ), QDir::homePath() ).toString() );
|
||||
if ( !saveFileName.isNull() )
|
||||
{
|
||||
mOutputLayerLineEdit->setText( saveFileName );
|
||||
}
|
||||
}
|
||||
|
||||
void QgsRasterCalcDialog::mCurrentLayerExtentButton_clicked()
|
||||
{
|
||||
QListWidgetItem *currentLayerItem = mRasterBandsListWidget->currentItem();
|
||||
@ -320,12 +313,6 @@ void QgsRasterCalcDialog::mExpressionTextEdit_textChanged()
|
||||
mButtonBox->button( QDialogButtonBox::Ok )->setEnabled( false );
|
||||
}
|
||||
|
||||
void QgsRasterCalcDialog::mOutputLayerLineEdit_textChanged( const QString &text )
|
||||
{
|
||||
Q_UNUSED( text );
|
||||
setAcceptButtonState();
|
||||
}
|
||||
|
||||
void QgsRasterCalcDialog::setAcceptButtonState()
|
||||
{
|
||||
if ( expressionValid() && filePathValid() )
|
||||
@ -352,7 +339,7 @@ bool QgsRasterCalcDialog::expressionValid() const
|
||||
|
||||
bool QgsRasterCalcDialog::filePathValid() const
|
||||
{
|
||||
QString outputPath = mOutputLayerLineEdit->text();
|
||||
QString outputPath = mOutputLayer->filePath();
|
||||
if ( outputPath.isEmpty() )
|
||||
return false;
|
||||
|
||||
|
@ -46,12 +46,10 @@ class APP_EXPORT QgsRasterCalcDialog: public QDialog, private Ui::QgsRasterCalcD
|
||||
QVector<QgsRasterCalculatorEntry> rasterEntries() const;
|
||||
|
||||
private slots:
|
||||
void mOutputLayerPushButton_clicked();
|
||||
void mRasterBandsListWidget_itemDoubleClicked( QListWidgetItem *item );
|
||||
void mButtonBox_accepted();
|
||||
void mCurrentLayerExtentButton_clicked();
|
||||
void mExpressionTextEdit_textChanged();
|
||||
void mOutputLayerLineEdit_textChanged( const QString &text );
|
||||
//! Enables OK button if calculator expression is valid and output file path exists
|
||||
void setAcceptButtonState();
|
||||
void showHelp();
|
||||
|
@ -84,7 +84,7 @@
|
||||
<item row="1" column="3">
|
||||
<widget class="QLabel" name="mXMaxLabel">
|
||||
<property name="text">
|
||||
<string>XMax</string>
|
||||
<string>X Max</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -163,8 +163,8 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="0" column="1" colspan="2">
|
||||
<widget class="QLineEdit" name="mOutputLayerLineEdit"/>
|
||||
<item row="0" column="1" colspan="3">
|
||||
<widget class="QgsFileWidget" name="mOutputLayer"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="mOutputFormatLabel">
|
||||
@ -176,7 +176,7 @@
|
||||
<item row="2" column="0">
|
||||
<widget class="QPushButton" name="mCurrentLayerExtentButton">
|
||||
<property name="text">
|
||||
<string>Current layer extent</string>
|
||||
<string>Selected layer extent</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -185,28 +185,6 @@
|
||||
<property name="text">
|
||||
<string>Output layer</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>mOutputLayerPushButton</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<widget class="QPushButton" name="mOutputLayerPushButton">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>…</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0" colspan="4">
|
||||
@ -526,11 +504,15 @@
|
||||
<header>qgsprojectionselectionwidget.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>QgsFileWidget</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>qgsfilewidget.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<tabstops>
|
||||
<tabstop>mRasterBandsListWidget</tabstop>
|
||||
<tabstop>mOutputLayerLineEdit</tabstop>
|
||||
<tabstop>mOutputLayerPushButton</tabstop>
|
||||
<tabstop>mOutputLayer</tabstop>
|
||||
<tabstop>mOutputFormatComboBox</tabstop>
|
||||
<tabstop>mCurrentLayerExtentButton</tabstop>
|
||||
<tabstop>mXMinSpinBox</tabstop>
|
||||
|
Loading…
x
Reference in New Issue
Block a user