17#include "ui_qgsattributesforminitcode.h"
30 mInitCodeSourceComboBox->addItem( QString(), QVariant::fromValue( Qgis::AttributeFormPythonInitCodeSource::NoSource ) );
31 mInitCodeSourceComboBox->addItem( tr(
"Load from External File" ), QVariant::fromValue( Qgis::AttributeFormPythonInitCodeSource::File ) );
32 mInitCodeSourceComboBox->addItem( tr(
"Provide Code in this Dialog" ), QVariant::fromValue( Qgis::AttributeFormPythonInitCodeSource::Dialog ) );
33 mInitCodeSourceComboBox->addItem( tr(
"Load from the Environment" ), QVariant::fromValue( Qgis::AttributeFormPythonInitCodeSource::Environment ) );
36 mInitFileWidget->setDefaultRoot( settings.
value( QStringLiteral(
"style/lastInitFilePathDir" ),
"." ).toString() );
37 mInitFileWidget->setDialogTitle( tr(
"Select Python File" ) );
38 mInitFileWidget->setFilter( tr(
"Python files (*.py *.PY)" ) );
40 connect( mInitCodeSourceComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsAttributesFormInitCode::mInitCodeSourceComboBox_currentIndexChanged );
41 connect( buttonBox, &QDialogButtonBox::helpRequested,
this, &QgsAttributesFormInitCode::showHelp );
46 mInitCodeSourceComboBox->setCurrentIndex( mInitCodeSourceComboBox->findData( QVariant::fromValue( initCodeSource ) ) );
47 mInitCodeSourceComboBox_currentIndexChanged( mInitCodeSourceComboBox->currentIndex() );
60 mInitCodeEditorPython->setText(
initCode );
70 return mInitFunctionLineEdit->text();
74 return mInitFileWidget->filePath();
78 return mInitCodeEditorPython->text();
81void QgsAttributesFormInitCode::mInitCodeSourceComboBox_currentIndexChanged(
int )
84 mInitFunctionContainer->setVisible(
codeSource != Qgis::AttributeFormPythonInitCodeSource::NoSource );
85 mInitFilePathLabel->setVisible(
codeSource == Qgis::AttributeFormPythonInitCodeSource::File );
86 mInitFileWidget->setVisible(
codeSource == Qgis::AttributeFormPythonInitCodeSource::File );
87 mInitCodeEditorPython->setVisible(
codeSource == Qgis::AttributeFormPythonInitCodeSource::Dialog );
90void QgsAttributesFormInitCode::showHelp()
92 QgsHelp::openHelp( QStringLiteral(
"working_with_vector/vector_properties.html#enhance-your-form-with-custom-functions" ) );
AttributeFormPythonInitCodeSource
The Python init code source for attribute forms.
static void enableAutoGeometryRestore(QWidget *widget, const QString &key=QString())
Register the widget to allow its position to be automatically saved and restored when open and closed...
static void openHelp(const QString &key)
Opens help topic for the given help key using default system web browser.
This class is a composition of two QSettings instances:
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), Section section=NoSection) const
Returns the value for setting key.