Skip to content
Permalink
Browse files

[auth] Added setters to the auth settings widget

Also:
- removed wrapper goupBox for added flexibility
- explicit connections
  • Loading branch information
elpaso committed Oct 2, 2017
1 parent 2fa6811 commit bdddc3ba66a68e797f78d51b08e891a4e2238fd5
@@ -56,13 +56,31 @@ class QgsAuthSettingsWidget : QWidget
:rtype: str
%End

void setUsername( const QString &username );
%Docstring
setUsername set the username
\param username the user name
%End

const QString password( ) const;
%Docstring
password
:return: basic authentication password
:rtype: str
%End

void setPassword( const QString &password );
%Docstring
setPassword set the password
\param password the password
%End

void setConfigId( const QString &configId );
%Docstring
setConfigId set the authentication configuration id
param configId the authentication configuration id
%End

const QString configId( ) const;
%Docstring
configId
@@ -36,13 +36,11 @@ QgsAuthSettingsWidget::QgsAuthSettingsWidget( QWidget *parent,
if ( ! configId.isEmpty( ) )
{
mAuthConfigSelect->setConfigId( configId );
tabAuth->setCurrentIndex( tabAuth->indexOf( tabConfigurations ) );
}
else if ( !( username.isEmpty() && password.isEmpty( ) ) )
{
tabAuth->setCurrentIndex( tabAuth->indexOf( tabBasic ) );
}
connect( btnConvertToEncrypted, &QPushButton::clicked, this, &QgsAuthSettingsWidget::convertToEncrypted );
connect( txtUserName, &QLineEdit::textChanged, this, &QgsAuthSettingsWidget::userNameTextChanged );
connect( txtPassword, &QLineEdit::textChanged, this, &QgsAuthSettingsWidget::passwordTextChanged );
updateSelectedTab();
updateConvertBtnState();
}

@@ -61,11 +59,29 @@ const QString QgsAuthSettingsWidget::username() const
return txtUserName->text();
}

void QgsAuthSettingsWidget::setUsername( const QString &username )
{
txtUserName->setText( username );
updateSelectedTab();
}

const QString QgsAuthSettingsWidget::password() const
{
return txtPassword->text();
}

void QgsAuthSettingsWidget::setPassword( const QString &password )
{
txtPassword->setText( password );
updateSelectedTab();
}

void QgsAuthSettingsWidget::setConfigId( const QString &configId )
{
mAuthConfigSelect->setConfigId( configId );
updateSelectedTab();
}

const QString QgsAuthSettingsWidget::configId() const
{
return mAuthConfigSelect->configId();
@@ -102,13 +118,13 @@ bool QgsAuthSettingsWidget::convertToEncrypted( )
}
}

void QgsAuthSettingsWidget::on_txtUserName_textChanged( const QString &text )
void QgsAuthSettingsWidget::userNameTextChanged( const QString &text )
{
Q_UNUSED( text );
updateConvertBtnState();
}

void QgsAuthSettingsWidget::on_txtPassword_textChanged( const QString &text )
void QgsAuthSettingsWidget::passwordTextChanged( const QString &text )
{
Q_UNUSED( text );
updateConvertBtnState();
@@ -118,3 +134,15 @@ void QgsAuthSettingsWidget::updateConvertBtnState()
{
btnConvertToEncrypted->setEnabled( ! txtUserName->text().isEmpty() || ! txtPassword->text().isEmpty() );
}

void QgsAuthSettingsWidget::updateSelectedTab()
{
if ( ! mAuthConfigSelect->configId().isEmpty( ) )
{
tabAuth->setCurrentIndex( tabAuth->indexOf( tabConfigurations ) );
}
else if ( !( txtUserName->text( ).isEmpty() && txtPassword->text( ).isEmpty( ) ) )
{
tabAuth->setCurrentIndex( tabAuth->indexOf( tabBasic ) );
}
}
@@ -68,12 +68,30 @@ class GUI_EXPORT QgsAuthSettingsWidget : public QWidget, private Ui::QgsAuthSett
*/
const QString username( ) const;

/**
* \brief setUsername set the username
* \param username the user name
*/
void setUsername( const QString &username );

/**
* \brief password
* \return basic authentication password
*/
const QString password( ) const;

/**
* \brief setPassword set the password
* \param password the password
*/
void setPassword( const QString &password );

/**
* \brief setConfigId set the authentication configuration id
* param configId the authentication configuration id
*/
void setConfigId( const QString &configId );

/**
* \brief configId
* \return authentication configuration id
@@ -107,20 +125,22 @@ class GUI_EXPORT QgsAuthSettingsWidget : public QWidget, private Ui::QgsAuthSett
* \param text the changet text
* \note Not available in Python bindings
*/
void on_txtUserName_textChanged( const QString &text ) SIP_SKIP;
void userNameTextChanged( const QString &text ) SIP_SKIP;

/**
* \brief on_txtPassword_textChanged set convert button state
* \param text the changed text
* \note Not available in Python bindings
*/
void on_txtPassword_textChanged( const QString &text ) SIP_SKIP;
void passwordTextChanged( const QString &text ) SIP_SKIP;


private:

void updateConvertBtnState( );

void updateSelectedTab( );

};

#endif // QGSAUTHSETTINGSWIDGET_H

0 comments on commit bdddc3b

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