@@ -34,12 +34,10 @@ QgsRasterCalcDialog::QgsRasterCalcDialog( QgsRasterLayer *rasterLayer, QWidget *
34
34
setupUi ( this );
35
35
QgsGui::instance ()->enableAutoGeometryRestore ( this );
36
36
37
- connect ( mOutputLayerPushButton , &QPushButton::clicked, this , &QgsRasterCalcDialog::mOutputLayerPushButton_clicked );
38
37
connect ( mRasterBandsListWidget , &QListWidget::itemDoubleClicked, this , &QgsRasterCalcDialog::mRasterBandsListWidget_itemDoubleClicked );
39
38
connect ( mButtonBox , &QDialogButtonBox::accepted, this , &QgsRasterCalcDialog::mButtonBox_accepted );
40
39
connect ( mCurrentLayerExtentButton , &QPushButton::clicked, this , &QgsRasterCalcDialog::mCurrentLayerExtentButton_clicked );
41
40
connect ( mExpressionTextEdit , &QTextEdit::textChanged, this , &QgsRasterCalcDialog::mExpressionTextEdit_textChanged );
42
- connect ( mOutputLayerLineEdit , &QLineEdit::textChanged, this , &QgsRasterCalcDialog::mOutputLayerLineEdit_textChanged );
43
41
connect ( mPlusPushButton , &QPushButton::clicked, this , &QgsRasterCalcDialog::mPlusPushButton_clicked );
44
42
connect ( mMinusPushButton , &QPushButton::clicked, this , &QgsRasterCalcDialog::mMinusPushButton_clicked );
45
43
connect ( mMultiplyPushButton , &QPushButton::clicked, this , &QgsRasterCalcDialog::mMultiplyPushButton_clicked );
@@ -77,6 +75,11 @@ QgsRasterCalcDialog::QgsRasterCalcDialog( QgsRasterLayer *rasterLayer, QWidget *
77
75
insertAvailableRasterBands ();
78
76
79
77
mExpressionTextEdit ->setCurrentFont ( QFontDatabase::systemFont ( QFontDatabase::FixedFont ) );
78
+
79
+ QgsSettings settings;
80
+ mOutputLayer ->setDialogTitle ( tr ( " Enter result file" ) );
81
+ mOutputLayer ->setDefaultRoot ( settings.value ( QStringLiteral ( " /RasterCalculator/lastOutputDir" ), QDir::homePath () ).toString () );
82
+ connect ( mOutputLayer , &QgsFileWidget::fileChanged, this , [ = ]() { setAcceptButtonState (); } );
80
83
}
81
84
82
85
QString QgsRasterCalcDialog::formulaString () const
@@ -86,7 +89,7 @@ QString QgsRasterCalcDialog::formulaString() const
86
89
87
90
QString QgsRasterCalcDialog::outputFile () const
88
91
{
89
- QString outputFileName = mOutputLayerLineEdit -> text ();
92
+ QString outputFileName = mOutputLayer -> filePath ();
90
93
QFileInfo fileInfo ( outputFileName );
91
94
QString suffix = fileInfo.suffix ();
92
95
if ( !suffix.isEmpty () )
@@ -253,24 +256,14 @@ void QgsRasterCalcDialog::mButtonBox_accepted()
253
256
// save last output format
254
257
QgsSettings s;
255
258
s.setValue ( QStringLiteral ( " /RasterCalculator/lastOutputFormat" ), QVariant ( mOutputFormatComboBox ->currentText () ) );
256
- s.setValue ( QStringLiteral ( " /RasterCalculator/lastOutputDir" ), QVariant ( QFileInfo ( mOutputLayerLineEdit -> text () ).absolutePath () ) );
259
+ s.setValue ( QStringLiteral ( " /RasterCalculator/lastOutputDir" ), QVariant ( QFileInfo ( mOutputLayer -> filePath () ).absolutePath () ) );
257
260
}
258
261
259
262
void QgsRasterCalcDialog::showHelp ()
260
263
{
261
264
QgsHelp::openHelp ( QStringLiteral ( " working_with_raster/raster_analysis.html#raster-calculator" ) );
262
265
}
263
266
264
- void QgsRasterCalcDialog::mOutputLayerPushButton_clicked ()
265
- {
266
- QgsSettings s;
267
- QString saveFileName = QFileDialog::getSaveFileName ( nullptr , tr ( " Enter result file" ), s.value ( QStringLiteral ( " /RasterCalculator/lastOutputDir" ), QDir::homePath () ).toString () );
268
- if ( !saveFileName.isNull () )
269
- {
270
- mOutputLayerLineEdit ->setText ( saveFileName );
271
- }
272
- }
273
-
274
267
void QgsRasterCalcDialog::mCurrentLayerExtentButton_clicked ()
275
268
{
276
269
QListWidgetItem *currentLayerItem = mRasterBandsListWidget ->currentItem ();
@@ -320,12 +313,6 @@ void QgsRasterCalcDialog::mExpressionTextEdit_textChanged()
320
313
mButtonBox ->button ( QDialogButtonBox::Ok )->setEnabled ( false );
321
314
}
322
315
323
- void QgsRasterCalcDialog::mOutputLayerLineEdit_textChanged ( const QString &text )
324
- {
325
- Q_UNUSED ( text );
326
- setAcceptButtonState ();
327
- }
328
-
329
316
void QgsRasterCalcDialog::setAcceptButtonState ()
330
317
{
331
318
if ( expressionValid () && filePathValid () )
@@ -352,7 +339,7 @@ bool QgsRasterCalcDialog::expressionValid() const
352
339
353
340
bool QgsRasterCalcDialog::filePathValid () const
354
341
{
355
- QString outputPath = mOutputLayerLineEdit -> text ();
342
+ QString outputPath = mOutputLayer -> filePath ();
356
343
if ( outputPath.isEmpty () )
357
344
return false ;
358
345
0 commit comments