mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-28 00:17:30 -05:00
Don't allow name-less parameters
This commit is contained in:
parent
8e3287a7ee
commit
074c584c54
@ -142,6 +142,10 @@ Returns a new instance of a parameter definition, using the current settings def
|
||||
The ``name`` parameter specifies the name for the newly created parameter.
|
||||
%End
|
||||
|
||||
public slots:
|
||||
virtual void accept();
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include <QCheckBox>
|
||||
#include <QDialog>
|
||||
#include <QDialogButtonBox>
|
||||
#include <QMessageBox>
|
||||
|
||||
QgsProcessingAbstractParameterDefinitionWidget::QgsProcessingAbstractParameterDefinitionWidget( QgsProcessingContext &,
|
||||
const QgsProcessingParameterWidgetContext &,
|
||||
@ -147,3 +148,14 @@ QgsProcessingParameterDefinition *QgsProcessingParameterDefinitionDialog::create
|
||||
{
|
||||
return mWidget->createParameter( name );
|
||||
}
|
||||
|
||||
void QgsProcessingParameterDefinitionDialog::accept()
|
||||
{
|
||||
if ( mWidget->mDescriptionLineEdit->text().isEmpty() )
|
||||
{
|
||||
QMessageBox::warning( this, tr( "Unable to define parameter" ),
|
||||
tr( "Invalid parameter name" ) );
|
||||
return;
|
||||
}
|
||||
QDialog::accept();
|
||||
}
|
||||
|
@ -122,6 +122,8 @@ class GUI_EXPORT QgsProcessingParameterDefinitionWidget: public QWidget
|
||||
QCheckBox *mRequiredCheckBox = nullptr;
|
||||
QCheckBox *mAdvancedCheckBox = nullptr;
|
||||
|
||||
friend class QgsProcessingParameterDefinitionDialog;
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
@ -165,6 +167,9 @@ class GUI_EXPORT QgsProcessingParameterDefinitionDialog: public QDialog
|
||||
*/
|
||||
QgsProcessingParameterDefinition *createParameter( const QString &name = QString() ) const SIP_FACTORY;
|
||||
|
||||
public slots:
|
||||
void accept() override;
|
||||
|
||||
private:
|
||||
|
||||
QgsProcessingParameterDefinitionWidget *mWidget = nullptr;
|
||||
|
@ -1888,8 +1888,6 @@ QgsAbstractProcessingParameterWidgetWrapper *QgsProcessingEnumWidgetWrapper::cre
|
||||
return new QgsProcessingEnumWidgetWrapper( parameter, type );
|
||||
}
|
||||
|
||||
|
||||
|
||||
//
|
||||
// QgsProcessingLayoutWidgetWrapper
|
||||
//
|
||||
|
@ -3206,7 +3206,7 @@ void TestProcessingGui::testColorWrapper()
|
||||
QCOMPARE( def->description(), QStringLiteral( "test desc" ) );
|
||||
QVERIFY( def->flags() & QgsProcessingParameterDefinition::FlagOptional );
|
||||
QVERIFY( def->flags() & QgsProcessingParameterDefinition::FlagAdvanced );
|
||||
QCOMPARE( static_cast< QgsProcessingParameterColor * >( def.get() )->defaultValue().value< QColor >(), QColor( 255, 0, 0 ) );
|
||||
QCOMPARE( static_cast< QgsProcessingParameterColor * >( def.get() )->defaultValue().value< QColor >(), QColor( 255, 0, 0 ) ); // (no opacity!)
|
||||
QVERIFY( !static_cast< QgsProcessingParameterColor * >( def.get() )->opacityEnabled() );
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user