26#include "moc_qgsvectortileconnectiondialog.cpp"
31QgsVectorTileConnectionDialog::QgsVectorTileConnectionDialog( QWidget *parent )
37 mEditUrl->setPlaceholderText( tr(
"URL(s) can be determined from the style." ) );
40 connect( mCheckBoxZMin, &QCheckBox::toggled, mSpinZMin, &QSpinBox::setEnabled );
41 connect( mCheckBoxZMax, &QCheckBox::toggled, mSpinZMax, &QSpinBox::setEnabled );
42 mSpinZMax->setClearValue( 14 );
44 buttonBox->button( QDialogButtonBox::Ok )->setDisabled(
true );
45 connect( buttonBox, &QDialogButtonBox::helpRequested,
this, [] {
46 QgsHelp::openHelp( QStringLiteral(
"managing_data_source/opening_data.html#using-vector-tiles-services" ) );
48 connect( mEditName, &QLineEdit::textChanged,
this, &QgsVectorTileConnectionDialog::updateOkButtonState );
49 connect( mEditUrl, &QLineEdit::textChanged,
this, &QgsVectorTileConnectionDialog::updateOkButtonState );
50 connect( mEditStyleUrl, &QLineEdit::textChanged,
this, &QgsVectorTileConnectionDialog::updateOkButtonState );
53void QgsVectorTileConnectionDialog::setConnection(
const QString &name,
const QString &uri )
55 mEditName->setText( name );
57 const QgsVectorTileProviderConnection::Data conn = QgsVectorTileProviderConnection::decodedUri( uri );
58 mEditUrl->setText( conn.url );
59 mCheckBoxZMin->setChecked( conn.zMin != -1 );
60 mSpinZMin->setValue( conn.zMin != -1 ? conn.zMin : 0 );
61 mCheckBoxZMax->setChecked( conn.zMax != -1 );
62 mSpinZMax->setValue( conn.zMax != -1 ? conn.zMax : 14 );
64 mAuthSettings->setUsername( conn.username );
65 mAuthSettings->setPassword( conn.password );
67 mAuthSettings->setConfigId( conn.authCfg );
69 mEditStyleUrl->setText( conn.styleUrl );
72QString QgsVectorTileConnectionDialog::connectionUri()
const
74 QgsVectorTileProviderConnection::Data conn;
75 conn.url = mEditUrl->text();
76 if ( mCheckBoxZMin->isChecked() )
77 conn.zMin = mSpinZMin->value();
78 if ( mCheckBoxZMax->isChecked() )
79 conn.zMax = mSpinZMax->value();
80 conn.username = mAuthSettings->username();
81 conn.password = mAuthSettings->password();
83 conn.authCfg = mAuthSettings->configId();
84 conn.styleUrl = mEditStyleUrl->text();
85 return QgsVectorTileProviderConnection::encodedUri( conn );
88QString QgsVectorTileConnectionDialog::connectionName()
const
90 return mEditName->text();
93void QgsVectorTileConnectionDialog::updateOkButtonState()
95 const bool enabled = !mEditName->text().isEmpty() && ( !mEditUrl->text().isEmpty() || !mEditStyleUrl->text().isEmpty() );
96 buttonBox->button( QDialogButtonBox::Ok )->setEnabled( enabled );
100void QgsVectorTileConnectionDialog::accept()
102 if ( mCheckBoxZMin->isChecked() && mCheckBoxZMax->isChecked() && mSpinZMax->value() < mSpinZMin->value() )
104 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.