28QgsVectorTileConnectionDialog::QgsVectorTileConnectionDialog( QWidget *parent )
34 mEditUrl->setPlaceholderText( tr(
"URL(s) can be determined from the style." ) );
37 connect( mCheckBoxZMin, &QCheckBox::toggled, mSpinZMin, &QSpinBox::setEnabled );
38 connect( mCheckBoxZMax, &QCheckBox::toggled, mSpinZMax, &QSpinBox::setEnabled );
39 mSpinZMax->setClearValue( 14 );
41 buttonBox->button( QDialogButtonBox::Ok )->setDisabled(
true );
42 connect( buttonBox, &QDialogButtonBox::helpRequested,
this, [ = ]
44 QgsHelp::openHelp( QStringLiteral(
"managing_data_source/opening_data.html#using-vector-tiles-services" ) );
46 connect( mEditName, &QLineEdit::textChanged,
this, &QgsVectorTileConnectionDialog::updateOkButtonState );
47 connect( mEditUrl, &QLineEdit::textChanged,
this, &QgsVectorTileConnectionDialog::updateOkButtonState );
48 connect( mEditStyleUrl, &QLineEdit::textChanged,
this, &QgsVectorTileConnectionDialog::updateOkButtonState );
51void QgsVectorTileConnectionDialog::setConnection(
const QString &name,
const QString &uri )
53 mEditName->setText( name );
55 const QgsVectorTileProviderConnection::Data conn = QgsVectorTileProviderConnection::decodedUri( uri );
56 mEditUrl->setText( conn.url );
57 mCheckBoxZMin->setChecked( conn.zMin != -1 );
58 mSpinZMin->setValue( conn.zMin != -1 ? conn.zMin : 0 );
59 mCheckBoxZMax->setChecked( conn.zMax != -1 );
60 mSpinZMax->setValue( conn.zMax != -1 ? conn.zMax : 14 );
62 mAuthSettings->setUsername( conn.username );
63 mAuthSettings->setPassword( conn.password );
65 mAuthSettings->setConfigId( conn.authCfg );
67 mEditStyleUrl->setText( conn.styleUrl );
70QString QgsVectorTileConnectionDialog::connectionUri()
const
72 QgsVectorTileProviderConnection::Data conn;
73 conn.url = mEditUrl->text();
74 if ( mCheckBoxZMin->isChecked() )
75 conn.zMin = mSpinZMin->value();
76 if ( mCheckBoxZMax->isChecked() )
77 conn.zMax = mSpinZMax->value();
78 conn.username = mAuthSettings->username();
79 conn.password = mAuthSettings->password();
81 conn.authCfg = mAuthSettings->configId( );
82 conn.styleUrl = mEditStyleUrl->text();
83 return QgsVectorTileProviderConnection::encodedUri( conn );
86QString QgsVectorTileConnectionDialog::connectionName()
const
88 return mEditName->text();
91void QgsVectorTileConnectionDialog::updateOkButtonState()
93 const bool enabled = !mEditName->text().isEmpty() && ( !mEditUrl->text().isEmpty() || !mEditStyleUrl->text().isEmpty() );
94 buttonBox->button( QDialogButtonBox::Ok )->setEnabled( enabled );
98void QgsVectorTileConnectionDialog::accept()
100 if ( mCheckBoxZMin->isChecked() && mCheckBoxZMax->isChecked() && mSpinZMax->value() < mSpinZMin->value() )
102 QMessageBox::warning(
this, tr(
"Connection Properties" ), tr(
"The maximum zoom level (%1) cannot be lower than the minimum zoom level (%2)." ).arg( mSpinZMax->value() ).arg( mSpinZMin->value() ) );
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.