Skip to content

Commit bdddc3b

Browse files
committedOct 2, 2017
[auth] Added setters to the auth settings widget
Also: - removed wrapper goupBox for added flexibility - explicit connections
1 parent 2fa6811 commit bdddc3b

File tree

3 files changed

+75
-9
lines changed

3 files changed

+75
-9
lines changed
 

‎python/gui/auth/qgsauthsettingswidget.sip

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,31 @@ class QgsAuthSettingsWidget : QWidget
5656
:rtype: str
5757
%End
5858

59+
void setUsername( const QString &username );
60+
%Docstring
61+
setUsername set the username
62+
\param username the user name
63+
%End
64+
5965
const QString password( ) const;
6066
%Docstring
6167
password
6268
:return: basic authentication password
6369
:rtype: str
6470
%End
6571

72+
void setPassword( const QString &password );
73+
%Docstring
74+
setPassword set the password
75+
\param password the password
76+
%End
77+
78+
void setConfigId( const QString &configId );
79+
%Docstring
80+
setConfigId set the authentication configuration id
81+
param configId the authentication configuration id
82+
%End
83+
6684
const QString configId( ) const;
6785
%Docstring
6886
configId

‎src/gui/auth/qgsauthsettingswidget.cpp

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,11 @@ QgsAuthSettingsWidget::QgsAuthSettingsWidget( QWidget *parent,
3636
if ( ! configId.isEmpty( ) )
3737
{
3838
mAuthConfigSelect->setConfigId( configId );
39-
tabAuth->setCurrentIndex( tabAuth->indexOf( tabConfigurations ) );
40-
}
41-
else if ( !( username.isEmpty() && password.isEmpty( ) ) )
42-
{
43-
tabAuth->setCurrentIndex( tabAuth->indexOf( tabBasic ) );
4439
}
4540
connect( btnConvertToEncrypted, &QPushButton::clicked, this, &QgsAuthSettingsWidget::convertToEncrypted );
41+
connect( txtUserName, &QLineEdit::textChanged, this, &QgsAuthSettingsWidget::userNameTextChanged );
42+
connect( txtPassword, &QLineEdit::textChanged, this, &QgsAuthSettingsWidget::passwordTextChanged );
43+
updateSelectedTab();
4644
updateConvertBtnState();
4745
}
4846

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

62+
void QgsAuthSettingsWidget::setUsername( const QString &username )
63+
{
64+
txtUserName->setText( username );
65+
updateSelectedTab();
66+
}
67+
6468
const QString QgsAuthSettingsWidget::password() const
6569
{
6670
return txtPassword->text();
6771
}
6872

73+
void QgsAuthSettingsWidget::setPassword( const QString &password )
74+
{
75+
txtPassword->setText( password );
76+
updateSelectedTab();
77+
}
78+
79+
void QgsAuthSettingsWidget::setConfigId( const QString &configId )
80+
{
81+
mAuthConfigSelect->setConfigId( configId );
82+
updateSelectedTab();
83+
}
84+
6985
const QString QgsAuthSettingsWidget::configId() const
7086
{
7187
return mAuthConfigSelect->configId();
@@ -102,13 +118,13 @@ bool QgsAuthSettingsWidget::convertToEncrypted( )
102118
}
103119
}
104120

105-
void QgsAuthSettingsWidget::on_txtUserName_textChanged( const QString &text )
121+
void QgsAuthSettingsWidget::userNameTextChanged( const QString &text )
106122
{
107123
Q_UNUSED( text );
108124
updateConvertBtnState();
109125
}
110126

111-
void QgsAuthSettingsWidget::on_txtPassword_textChanged( const QString &text )
127+
void QgsAuthSettingsWidget::passwordTextChanged( const QString &text )
112128
{
113129
Q_UNUSED( text );
114130
updateConvertBtnState();
@@ -118,3 +134,15 @@ void QgsAuthSettingsWidget::updateConvertBtnState()
118134
{
119135
btnConvertToEncrypted->setEnabled( ! txtUserName->text().isEmpty() || ! txtPassword->text().isEmpty() );
120136
}
137+
138+
void QgsAuthSettingsWidget::updateSelectedTab()
139+
{
140+
if ( ! mAuthConfigSelect->configId().isEmpty( ) )
141+
{
142+
tabAuth->setCurrentIndex( tabAuth->indexOf( tabConfigurations ) );
143+
}
144+
else if ( !( txtUserName->text( ).isEmpty() && txtPassword->text( ).isEmpty( ) ) )
145+
{
146+
tabAuth->setCurrentIndex( tabAuth->indexOf( tabBasic ) );
147+
}
148+
}

‎src/gui/auth/qgsauthsettingswidget.h

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,30 @@ class GUI_EXPORT QgsAuthSettingsWidget : public QWidget, private Ui::QgsAuthSett
6868
*/
6969
const QString username( ) const;
7070

71+
/**
72+
* \brief setUsername set the username
73+
* \param username the user name
74+
*/
75+
void setUsername( const QString &username );
76+
7177
/**
7278
* \brief password
7379
* \return basic authentication password
7480
*/
7581
const QString password( ) const;
7682

83+
/**
84+
* \brief setPassword set the password
85+
* \param password the password
86+
*/
87+
void setPassword( const QString &password );
88+
89+
/**
90+
* \brief setConfigId set the authentication configuration id
91+
* param configId the authentication configuration id
92+
*/
93+
void setConfigId( const QString &configId );
94+
7795
/**
7896
* \brief configId
7997
* \return authentication configuration id
@@ -107,20 +125,22 @@ class GUI_EXPORT QgsAuthSettingsWidget : public QWidget, private Ui::QgsAuthSett
107125
* \param text the changet text
108126
* \note Not available in Python bindings
109127
*/
110-
void on_txtUserName_textChanged( const QString &text ) SIP_SKIP;
128+
void userNameTextChanged( const QString &text ) SIP_SKIP;
111129

112130
/**
113131
* \brief on_txtPassword_textChanged set convert button state
114132
* \param text the changed text
115133
* \note Not available in Python bindings
116134
*/
117-
void on_txtPassword_textChanged( const QString &text ) SIP_SKIP;
135+
void passwordTextChanged( const QString &text ) SIP_SKIP;
118136

119137

120138
private:
121139

122140
void updateConvertBtnState( );
123141

142+
void updateSelectedTab( );
143+
124144
};
125145

126146
#endif // QGSAUTHSETTINGSWIDGET_H

0 commit comments

Comments
 (0)
Please sign in to comment.