17#include "moc_qgsauthsettingswidget.cpp"
25 const QString &configId,
26 const QString &username,
27 const QString &password,
28 const QString &dataprovider )
30 , mDataprovider( dataprovider )
41 mAuthConfigSelect->setConfigId(
configId );
47 connect( txtUserName, &QLineEdit::textChanged,
this, &QgsAuthSettingsWidget::userNameTextChanged );
48 connect( txtPassword, &QLineEdit::textChanged,
this, &QgsAuthSettingsWidget::passwordTextChanged );
54 updateConvertBtnState();
59 lblWarning->setText( warningText );
64 lblBasic->setText( basicText );
66 lblBasic->setVisible( ! basicText.isEmpty() );
71 return txtUserName->text();
82 return txtPassword->text();
93 mAuthConfigSelect->setConfigId(
configId );
105 return mDataprovider;
110 const QString out = tr(
"Warning: credentials stored as plain text in %1." );
114 return out.arg( tr(
"project file" ) );
116 return out.arg( tr(
"user settings" ) );
123 return mAuthConfigSelect->configId();
128 return btnConvertToEncrypted->isEnabled( );
135 cbStorePassword->show();
136 cbStoreUsername->show();
140 cbStorePassword->hide();
141 cbStoreUsername->hide();
147 cbStoreUsername->setChecked( checked );
152 cbStorePassword->setChecked( checked );
157 return cbStorePassword->isChecked( );
162 return cbStoreUsername->isChecked( );
167 return tabAuth->currentIndex( ) == tabAuth->indexOf( tabConfigurations );
172 tabAuth->setCurrentIndex( tabAuth->indexOf( tabConfigurations ) );
174 config.
setName( tr(
"Converted config %1" ).arg( QDateTime::currentDateTime().toString( ) ) );
175 config.
setConfig( QStringLiteral(
"username" ), txtUserName->text() );
176 config.
setConfig( QStringLiteral(
"password" ), txtPassword->text() );
179 mAuthConfigSelect->showMessage( tr(
"Couldn't create a Basic authentication configuration!" ) );
184 txtUserName->setText( QString( ) );
185 txtPassword->setText( QString( ) );
186 mAuthConfigSelect->setConfigId( config.
id( ) );
191void QgsAuthSettingsWidget::userNameTextChanged(
const QString &text )
194 updateConvertBtnState();
198void QgsAuthSettingsWidget::passwordTextChanged(
const QString &text )
201 updateConvertBtnState();
205void QgsAuthSettingsWidget::updateConvertBtnState()
207 btnConvertToEncrypted->setEnabled( ! txtUserName->text().isEmpty() || ! txtPassword->text().isEmpty() );
210void QgsAuthSettingsWidget::updateSelectedTab()
212 if ( ! mAuthConfigSelect->configId().isEmpty( ) )
214 tabAuth->setCurrentIndex( tabAuth->indexOf( tabConfigurations ) );
216 else if ( !( txtUserName->text( ).isEmpty() && txtPassword->text( ).isEmpty( ) ) )
218 tabAuth->setCurrentIndex( tabAuth->indexOf( tabBasic ) );
static QgsAuthManager * authManager()
Returns the application's authentication manager instance.
void selectedConfigIdChanged(const QString &authcfg)
Emitted when authentication config is changed or missing.
Configuration storage class for authentication method configurations.
void setName(const QString &name)
Sets name of configuration.
const QString id() const
Gets 'authcfg' 7-character alphanumeric ID of the config.
void setConfig(const QString &key, const QString &value)
Set a single config value per key in the map.