26QgsVectorTileConnectionDialog::QgsVectorTileConnectionDialog( QWidget *parent )
33 connect( mCheckBoxZMin, &QCheckBox::toggled, mSpinZMin, &QSpinBox::setEnabled );
34 connect( mCheckBoxZMax, &QCheckBox::toggled, mSpinZMax, &QSpinBox::setEnabled );
35 mSpinZMax->setClearValue( 14 );
37 buttonBox->button( QDialogButtonBox::Ok )->setDisabled(
true );
38 connect( buttonBox, &QDialogButtonBox::helpRequested,
this, [ = ]
40 QgsHelp::openHelp( QStringLiteral(
"managing_data_source/opening_data.html#using-vector-tiles-services" ) );
42 connect( mEditName, &QLineEdit::textChanged,
this, &QgsVectorTileConnectionDialog::updateOkButtonState );
43 connect( mEditUrl, &QLineEdit::textChanged,
this, &QgsVectorTileConnectionDialog::updateOkButtonState );
46void QgsVectorTileConnectionDialog::setConnection(
const QString &name,
const QString &uri )
48 mEditName->setText( name );
50 const QgsVectorTileProviderConnection::Data conn = QgsVectorTileProviderConnection::decodedUri( uri );
51 mEditUrl->setText( conn.url );
52 mCheckBoxZMin->setChecked( conn.zMin != -1 );
53 mSpinZMin->setValue( conn.zMin != -1 ? conn.zMin : 0 );
54 mCheckBoxZMax->setChecked( conn.zMax != -1 );
55 mSpinZMax->setValue( conn.zMax != -1 ? conn.zMax : 14 );
57 mAuthSettings->setUsername( conn.username );
58 mAuthSettings->setPassword( conn.password );
60 mAuthSettings->setConfigId( conn.authCfg );
62 mEditStyleUrl->setText( conn.styleUrl );
65QString QgsVectorTileConnectionDialog::connectionUri()
const
67 QgsVectorTileProviderConnection::Data conn;
68 conn.url = mEditUrl->text();
69 if ( mCheckBoxZMin->isChecked() )
70 conn.zMin = mSpinZMin->value();
71 if ( mCheckBoxZMax->isChecked() )
72 conn.zMax = mSpinZMax->value();
73 conn.username = mAuthSettings->username();
74 conn.password = mAuthSettings->password();
76 conn.authCfg = mAuthSettings->configId( );
77 conn.styleUrl = mEditStyleUrl->text();
78 return QgsVectorTileProviderConnection::encodedUri( conn );
81QString QgsVectorTileConnectionDialog::connectionName()
const
83 return mEditName->text();
86void QgsVectorTileConnectionDialog::updateOkButtonState()
88 const bool enabled = !mEditName->text().isEmpty() && !mEditUrl->text().isEmpty();
89 buttonBox->button( QDialogButtonBox::Ok )->setEnabled( enabled );
92void QgsVectorTileConnectionDialog::accept()
94 if ( mCheckBoxZMin->isChecked() && mCheckBoxZMax->isChecked() && mSpinZMax->value() < mSpinZMin->value() )
96 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.