21 #include <QMessageBox>
22 #include <QPushButton>
26 QgsArcgisVectorTileConnectionDialog::QgsArcgisVectorTileConnectionDialog( 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, &QgsArcgisVectorTileConnectionDialog::updateOkButtonState );
43 connect( mEditUrl, &QLineEdit::textChanged,
this, &QgsArcgisVectorTileConnectionDialog::updateOkButtonState );
46 void QgsArcgisVectorTileConnectionDialog::setConnection(
const QString &name,
const QString &uri )
48 mEditName->setText( name );
50 const QgsVectorTileProviderConnection::Data conn = QgsVectorTileProviderConnection::decodedUri( uri );
51 mEditUrl->setText( conn.url );
53 mCheckBoxZMin->setChecked( conn.zMin != -1 );
54 mSpinZMin->setValue( conn.zMin != -1 ? conn.zMin : 0 );
55 mCheckBoxZMax->setChecked( conn.zMax != -1 );
56 mSpinZMax->setValue( conn.zMax != -1 ? conn.zMax : 14 );
58 mAuthSettings->setUsername( conn.username );
59 mAuthSettings->setPassword( conn.password );
60 mEditReferer->setText( conn.referer );
61 mAuthSettings->setConfigId( conn.authCfg );
63 mEditStyleUrl->setText( conn.styleUrl );
66 QString QgsArcgisVectorTileConnectionDialog::connectionUri()
const
68 QgsVectorTileProviderConnection::Data conn;
69 conn.url = mEditUrl->text();
70 if ( conn.url.endsWith(
'/' ) )
71 conn.url = conn.url.left( conn.url.length() - 1 );
73 conn.serviceType = QgsVectorTileProviderConnection::ArcgisVectorTileService;
75 if ( mCheckBoxZMin->isChecked() )
76 conn.zMin = mSpinZMin->value();
77 if ( mCheckBoxZMax->isChecked() )
78 conn.zMax = mSpinZMax->value();
80 conn.username = mAuthSettings->username();
81 conn.password = mAuthSettings->password();
82 conn.referer = mEditReferer->text();
83 conn.authCfg = mAuthSettings->configId( );
85 conn.styleUrl = mEditStyleUrl->text();
87 return QgsVectorTileProviderConnection::encodedUri( conn );
90 QString QgsArcgisVectorTileConnectionDialog::connectionName()
const
92 return mEditName->text();
95 void QgsArcgisVectorTileConnectionDialog::accept()
97 if ( mCheckBoxZMin->isChecked() && mCheckBoxZMax->isChecked() && mSpinZMax->value() < mSpinZMin->value() )
99 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() ) );
105 void QgsArcgisVectorTileConnectionDialog::updateOkButtonState()
107 const bool enabled = !mEditName->text().isEmpty() && !mEditUrl->text().isEmpty();
108 buttonBox->button( QDialogButtonBox::Ok )->setEnabled( enabled );
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.