Skip to content

Commit

Permalink
[auth] Added setters to the auth settings widget
Browse files Browse the repository at this point in the history
Also:
- removed wrapper goupBox for added flexibility
- explicit connections
  • Loading branch information
elpaso committed Oct 2, 2017
1 parent 2fa6811 commit bdddc3b
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 9 deletions.
18 changes: 18 additions & 0 deletions python/gui/auth/qgsauthsettingswidget.sip
Expand Up @@ -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
Expand Down
42 changes: 35 additions & 7 deletions src/gui/auth/qgsauthsettingswidget.cpp
Expand Up @@ -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();
}

Expand All @@ -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();
Expand Down Expand Up @@ -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();
Expand All @@ -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 ) );
}
}
24 changes: 22 additions & 2 deletions src/gui/auth/qgsauthsettingswidget.h
Expand Up @@ -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
Expand Down Expand Up @@ -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.