17#include "moc_qgsvectortileconnectiondialog.cpp"
29QgsVectorTileConnectionDialog::QgsVectorTileConnectionDialog( QWidget *parent )
35 mEditUrl->setPlaceholderText( tr(
"URL(s) can be determined from the style." ) );
38 connect( mCheckBoxZMin, &QCheckBox::toggled, mSpinZMin, &QSpinBox::setEnabled );
39 connect( mCheckBoxZMax, &QCheckBox::toggled, mSpinZMax, &QSpinBox::setEnabled );
40 mSpinZMax->setClearValue( 14 );
42 buttonBox->button( QDialogButtonBox::Ok )->setDisabled(
true );
43 connect( buttonBox, &QDialogButtonBox::helpRequested,
this, [ = ]
45 QgsHelp::openHelp( QStringLiteral(
"managing_data_source/opening_data.html#using-vector-tiles-services" ) );
47 connect( mEditName, &QLineEdit::textChanged,
this, &QgsVectorTileConnectionDialog::updateOkButtonState );
48 connect( mEditUrl, &QLineEdit::textChanged,
this, &QgsVectorTileConnectionDialog::updateOkButtonState );
49 connect( mEditStyleUrl, &QLineEdit::textChanged,
this, &QgsVectorTileConnectionDialog::updateOkButtonState );
52void QgsVectorTileConnectionDialog::setConnection(
const QString &name,
const QString &uri )
54 mEditName->setText( name );
56 const QgsVectorTileProviderConnection::Data conn = QgsVectorTileProviderConnection::decodedUri( uri );
57 mEditUrl->setText( conn.url );
58 mCheckBoxZMin->setChecked( conn.zMin != -1 );
59 mSpinZMin->setValue( conn.zMin != -1 ? conn.zMin : 0 );
60 mCheckBoxZMax->setChecked( conn.zMax != -1 );
61 mSpinZMax->setValue( conn.zMax != -1 ? conn.zMax : 14 );
63 mAuthSettings->setUsername( conn.username );
64 mAuthSettings->setPassword( conn.password );
66 mAuthSettings->setConfigId( conn.authCfg );
68 mEditStyleUrl->setText( conn.styleUrl );
71QString QgsVectorTileConnectionDialog::connectionUri()
const
73 QgsVectorTileProviderConnection::Data conn;
74 conn.url = mEditUrl->text();
75 if ( mCheckBoxZMin->isChecked() )
76 conn.zMin = mSpinZMin->value();
77 if ( mCheckBoxZMax->isChecked() )
78 conn.zMax = mSpinZMax->value();
79 conn.username = mAuthSettings->username();
80 conn.password = mAuthSettings->password();
82 conn.authCfg = mAuthSettings->configId( );
83 conn.styleUrl = mEditStyleUrl->text();
84 return QgsVectorTileProviderConnection::encodedUri( conn );
87QString QgsVectorTileConnectionDialog::connectionName()
const
89 return mEditName->text();
92void QgsVectorTileConnectionDialog::updateOkButtonState()
94 const bool enabled = !mEditName->text().isEmpty() && ( !mEditUrl->text().isEmpty() || !mEditStyleUrl->text().isEmpty() );
95 buttonBox->button( QDialogButtonBox::Ok )->setEnabled( enabled );
99void QgsVectorTileConnectionDialog::accept()
101 if ( mCheckBoxZMin->isChecked() && mCheckBoxZMax->isChecked() && mSpinZMax->value() < mSpinZMin->value() )
103 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.