27#include "moc_qgsvectortileconnectiondialog.cpp"
29using namespace Qt::StringLiterals;
34QgsVectorTileConnectionDialog::QgsVectorTileConnectionDialog( QWidget *parent )
40 mEditUrl->setPlaceholderText( tr(
"URL(s) can be determined from the style." ) );
43 connect( mCheckBoxZMin, &QCheckBox::toggled, mSpinZMin, &QSpinBox::setEnabled );
44 connect( mCheckBoxZMax, &QCheckBox::toggled, mSpinZMax, &QSpinBox::setEnabled );
45 mSpinZMax->setClearValue( 14 );
47 buttonBox->button( QDialogButtonBox::Ok )->setDisabled(
true );
48 connect( buttonBox, &QDialogButtonBox::helpRequested,
this, [] {
QgsHelp::openHelp( u
"managing_data_source/opening_data.html#using-vector-tiles-services"_s ); } );
49 connect( mEditName, &QLineEdit::textChanged,
this, &QgsVectorTileConnectionDialog::updateOkButtonState );
50 connect( mEditUrl, &QLineEdit::textChanged,
this, &QgsVectorTileConnectionDialog::updateOkButtonState );
51 connect( mEditStyleUrl, &QLineEdit::textChanged,
this, &QgsVectorTileConnectionDialog::updateOkButtonState );
54void QgsVectorTileConnectionDialog::setConnection(
const QString &name,
const QString &uri )
56 mEditName->setText( name );
58 const QgsVectorTileProviderConnection::Data conn = QgsVectorTileProviderConnection::decodedUri( uri );
59 mEditUrl->setText( conn.url );
60 mCheckBoxZMin->setChecked( conn.zMin != -1 );
61 mSpinZMin->setValue( conn.zMin != -1 ? conn.zMin : 0 );
62 mCheckBoxZMax->setChecked( conn.zMax != -1 );
63 mSpinZMax->setValue( conn.zMax != -1 ? conn.zMax : 14 );
65 mAuthSettings->setUsername( conn.username );
66 mAuthSettings->setPassword( conn.password );
68 mAuthSettings->setConfigId( conn.authCfg );
70 mEditStyleUrl->setText( conn.styleUrl );
73QString QgsVectorTileConnectionDialog::connectionUri()
const
75 QgsVectorTileProviderConnection::Data conn;
76 conn.url = mEditUrl->text();
77 if ( mCheckBoxZMin->isChecked() )
78 conn.zMin = mSpinZMin->value();
79 if ( mCheckBoxZMax->isChecked() )
80 conn.zMax = mSpinZMax->value();
81 conn.username = mAuthSettings->username();
82 conn.password = mAuthSettings->password();
84 conn.authCfg = mAuthSettings->configId();
85 conn.styleUrl = mEditStyleUrl->text();
86 return QgsVectorTileProviderConnection::encodedUri( conn );
89QString QgsVectorTileConnectionDialog::connectionName()
const
91 return mEditName->text();
94void QgsVectorTileConnectionDialog::updateOkButtonState()
96 const bool enabled = !mEditName->text().isEmpty() && ( !mEditUrl->text().isEmpty() || !mEditStyleUrl->text().isEmpty() );
97 buttonBox->button( QDialogButtonBox::Ok )->setEnabled( enabled );
101void QgsVectorTileConnectionDialog::accept()
103 if ( mCheckBoxZMin->isChecked() && mCheckBoxZMax->isChecked() && mSpinZMax->value() < mSpinZMin->value() )
105 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.