Skip to content
Permalink
Browse files

Merge pull request #4881 from boundlessgeo/xyz-auth-gui

[feature][needs-docs] XYZ authentication and referer added to GUI
  • Loading branch information
elpaso committed Jul 21, 2017
2 parents 0cba29c + e423eea commit 89ffecbf05f23d4f1f52b9344ebddd6f45dc8599
@@ -27,6 +27,14 @@ QString QgsXyzConnection::encodedUri() const
uri.setParam( QStringLiteral( "zmin" ), QString::number( zMin ) );
if ( zMax != -1 )
uri.setParam( QStringLiteral( "zmax" ), QString::number( zMax ) );
if ( ! authCfg.isEmpty() )
uri.setParam( QStringLiteral( "authcfg" ), authCfg );
if ( ! username.isEmpty() )
uri.setParam( QStringLiteral( "username" ), username );
if ( ! password.isEmpty() )
uri.setParam( QStringLiteral( "password" ), password );
if ( ! referer.isEmpty() )
uri.setParam( QStringLiteral( "referer" ), referer );
return uri.encodedUri();
}

@@ -47,6 +55,10 @@ QgsXyzConnection QgsXyzConnectionUtils::connection( const QString &name )
conn.url = settings.value( QStringLiteral( "url" ) ).toString();
conn.zMin = settings.value( QStringLiteral( "zmin" ), -1 ).toInt();
conn.zMax = settings.value( QStringLiteral( "zmax" ), -1 ).toInt();
conn.authCfg = settings.value( QStringLiteral( "authcfg" ) ).toString();
conn.username = settings.value( QStringLiteral( "username" ) ).toString();
conn.password = settings.value( QStringLiteral( "password" ) ).toString();
conn.referer = settings.value( QStringLiteral( "referer" ) ).toString();
return conn;
}

@@ -63,4 +75,8 @@ void QgsXyzConnectionUtils::addConnection( const QgsXyzConnection &conn )
settings.setValue( QStringLiteral( "url" ), conn.url );
settings.setValue( QStringLiteral( "zmin" ), conn.zMin );
settings.setValue( QStringLiteral( "zmax" ), conn.zMax );
settings.setValue( QStringLiteral( "authcfg" ), conn.authCfg );
settings.setValue( QStringLiteral( "username" ), conn.username );
settings.setValue( QStringLiteral( "password" ), conn.password );
settings.setValue( QStringLiteral( "referer" ), conn.referer );
}
@@ -24,6 +24,14 @@ struct QgsXyzConnection
QString url;
int zMin = -1;
int zMax = -1;
// Authentication configuration id
QString authCfg;
// HTTP Basic username
QString username;
// HTTP Basic password
QString password;
// Referer
QString referer;

QString encodedUri() const;
};
@@ -13,15 +13,18 @@
* *
***************************************************************************/

#include "qgsauthconfigselect.h"
#include "qgsxyzconnectiondialog.h"

#include "qgsxyzconnection.h"

QgsXyzConnectionDialog::QgsXyzConnectionDialog( QWidget *parent )
: QDialog( parent )
, mAuthConfigSelect( nullptr )
{
setupUi( this );

mAuthConfigSelect = new QgsAuthConfigSelect( this );
mTabAuth->insertTab( 1, mAuthConfigSelect, tr( "Configurations" ) );
// Behavior for min and max zoom checkbox
connect( mCheckBoxZMin, &QCheckBox::toggled, mSpinZMin, &QSpinBox::setEnabled );
connect( mCheckBoxZMax, &QCheckBox::toggled, mSpinZMax, &QSpinBox::setEnabled );
@@ -35,6 +38,18 @@ void QgsXyzConnectionDialog::setConnection( const QgsXyzConnection &conn )
mSpinZMin->setValue( conn.zMin != -1 ? conn.zMin : 0 );
mCheckBoxZMax->setChecked( conn.zMax != -1 );
mSpinZMax->setValue( conn.zMax != -1 ? conn.zMax : 18 );
mEditUsername->setText( conn.username );
mEditPassword->setText( conn.password );
mEditReferer->setText( conn.referer );
mAuthConfigSelect->setConfigId( conn.authCfg );
if ( ! conn.authCfg.isEmpty( ) )
{
mTabAuth->setCurrentIndex( mTabAuth->indexOf( mAuthConfigSelect ) );
}
else
{
mTabAuth->setCurrentIndex( 0 );
}
}

QgsXyzConnection QgsXyzConnectionDialog::connection() const
@@ -46,5 +61,9 @@ QgsXyzConnection QgsXyzConnectionDialog::connection() const
conn.zMin = mSpinZMin->value();
if ( mCheckBoxZMax->isChecked() )
conn.zMax = mSpinZMax->value();
conn.username = mEditUsername->text();
conn.password = mEditPassword->text();
conn.referer = mEditReferer->text();
conn.authCfg = mAuthConfigSelect->configId( );
return conn;
}
@@ -20,6 +20,8 @@

#include "ui_qgsxyzconnectiondialog.h"

class QgsAuthConfigSelect;

struct QgsXyzConnection;


@@ -33,6 +35,12 @@ class QgsXyzConnectionDialog : public QDialog, public Ui::QgsXyzConnectionDialog

QgsXyzConnection connection() const;

private:

QString mBaseKey;
QString mCredentialsBaseKey;
QgsAuthConfigSelect *mAuthConfigSelect = nullptr;

};

#endif // QGSXYZCONNECTIONDIALOG_H

0 comments on commit 89ffecb

Please sign in to comment.
You can’t perform that action at this time.