26 #include <QVBoxLayout>
31 #include <QDialogButtonBox>
32 #include <QMessageBox>
59 QVBoxLayout *vlayout =
new QVBoxLayout();
61 QLabel *label =
new QLabel( tr(
"Description" ) );
62 vlayout->addWidget( label );
63 mDescriptionLineEdit =
new QLineEdit();
64 vlayout->addWidget( mDescriptionLineEdit );
68 mDescriptionLineEdit->setText( definition->
description() );
71 if ( mDefinitionWidget )
72 vlayout->addWidget( mDefinitionWidget );
74 vlayout->addSpacing( 20 );
75 mRequiredCheckBox =
new QCheckBox( tr(
"Mandatory" ) );
79 mRequiredCheckBox->setChecked(
true );
80 vlayout->addWidget( mRequiredCheckBox );
82 mAdvancedCheckBox =
new QCheckBox( tr(
"Advanced" ) );
86 mAdvancedCheckBox->setChecked(
false );
87 vlayout->addWidget( mAdvancedCheckBox );
89 vlayout->addStretch();
95 std::unique_ptr< QgsProcessingParameterDefinition > param;
96 QgsProcessingParameterDefinition::Flags flags = QgsProcessingParameterDefinition::Flags();
98 if ( !mRequiredCheckBox->isChecked() )
100 if ( mAdvancedCheckBox->isChecked() )
103 if ( mDefinitionWidget )
107 param.reset( mDefinitionWidget->
createParameter( name, mDescriptionLineEdit->text(), flags ) );
115 param->setDescription( mDescriptionLineEdit->text() );
116 param->setFlags( flags );
120 return param.release();
135 QVBoxLayout *vLayout =
new QVBoxLayout();
136 mTabWidget =
new QTabWidget();
137 vLayout->addWidget( mTabWidget );
139 QVBoxLayout *vLayout2 =
new QVBoxLayout();
141 vLayout2->addWidget( mWidget );
142 QWidget *w =
new QWidget();
143 w->setLayout( vLayout2 );
144 mTabWidget->addTab( w, tr(
"Properties" ) );
146 QVBoxLayout *commentLayout =
new QVBoxLayout();
147 mCommentEdit =
new QTextEdit();
148 mCommentEdit->setAcceptRichText(
false );
149 commentLayout->addWidget( mCommentEdit, 1 );
151 QHBoxLayout *hl =
new QHBoxLayout();
152 hl->setContentsMargins( 0, 0, 0, 0 );
153 hl->addWidget(
new QLabel( tr(
"Color" ) ) );
156 mCommentColorButton->setWindowTitle( tr(
"Comment Color" ) );
157 mCommentColorButton->
setShowNull(
true, tr(
"Default" ) );
158 hl->addWidget( mCommentColorButton );
159 commentLayout->addLayout( hl );
161 QWidget *w2 =
new QWidget();
162 w2->setLayout( commentLayout );
163 mTabWidget->addTab( w2, tr(
"Comments" ) );
165 QDialogButtonBox *bbox =
new QDialogButtonBox( QDialogButtonBox::Cancel | QDialogButtonBox::Ok );
167 connect( bbox, &QDialogButtonBox::rejected,
this, &QgsProcessingParameterDefinitionDialog::reject );
169 vLayout->addWidget( bbox );
170 setLayout( vLayout );
171 setWindowTitle( definition ? tr(
"%1 Parameter Definition" ).arg( definition->
description() )
173 tr(
"Parameter Definition" ) );
174 setObjectName( QStringLiteral(
"QgsProcessingParameterDefinitionDialog" ) );
185 mCommentEdit->setPlainText(
comments );
190 return mCommentEdit->toPlainText();
195 if ( color.isValid() )
196 mCommentColorButton->
setColor( color );
203 return !mCommentColorButton->
isNull() ? mCommentColorButton->
color() : QColor();
208 mTabWidget->setCurrentIndex( 1 );
209 mCommentEdit->setFocus();
210 mCommentEdit->selectAll();
215 if ( mWidget->mDescriptionLineEdit->text().isEmpty() )
217 QMessageBox::warning(
this, tr(
"Unable to define parameter" ),
218 tr(
"Invalid parameter name" ) );