24 const QString &configId,
25 const QString &username,
26 const QString &password,
27 const QString &dataprovider )
29 , mDataprovider( dataprovider )
40 mAuthConfigSelect->setConfigId(
configId );
46 connect( txtUserName, &QLineEdit::textChanged,
this, &QgsAuthSettingsWidget::userNameTextChanged );
47 connect( txtPassword, &QLineEdit::textChanged,
this, &QgsAuthSettingsWidget::passwordTextChanged );
53 updateConvertBtnState();
58 lblWarning->setText( warningText );
63 lblBasic->setText( basicText );
65 lblBasic->setVisible( ! basicText.isEmpty() );
70 return txtUserName->text();
81 return txtPassword->text();
92 mAuthConfigSelect->setConfigId(
configId );
104 return mDataprovider;
109 const QString out = tr(
"Warning: credentials stored as plain text in %1." );
113 return out.arg( tr(
"project file" ) );
115 return out.arg( tr(
"user settings" ) );
122 return mAuthConfigSelect->configId();
127 return btnConvertToEncrypted->isEnabled( );
134 cbStorePassword->show();
135 cbStoreUsername->show();
139 cbStorePassword->hide();
140 cbStoreUsername->hide();
146 cbStoreUsername->setChecked( checked );
151 cbStorePassword->setChecked( checked );
156 return cbStorePassword->isChecked( );
161 return cbStoreUsername->isChecked( );
166 return tabAuth->currentIndex( ) == tabAuth->indexOf( tabConfigurations );
171 tabAuth->setCurrentIndex( tabAuth->indexOf( tabConfigurations ) );
173 config.
setName( tr(
"Converted config %1" ).arg( QDateTime::currentDateTime().toString( ) ) );
174 config.
setConfig( QStringLiteral(
"username" ), txtUserName->text() );
175 config.
setConfig( QStringLiteral(
"password" ), txtPassword->text() );
178 mAuthConfigSelect->showMessage( tr(
"Couldn't create a Basic authentication configuration!" ) );
183 txtUserName->setText( QString( ) );
184 txtPassword->setText( QString( ) );
185 mAuthConfigSelect->setConfigId( config.
id( ) );
190 void QgsAuthSettingsWidget::userNameTextChanged(
const QString &text )
193 updateConvertBtnState();
197 void QgsAuthSettingsWidget::passwordTextChanged(
const QString &text )
200 updateConvertBtnState();
204 void QgsAuthSettingsWidget::updateConvertBtnState()
206 btnConvertToEncrypted->setEnabled( ! txtUserName->text().isEmpty() || ! txtPassword->text().isEmpty() );
209 void QgsAuthSettingsWidget::updateSelectedTab()
211 if ( ! mAuthConfigSelect->configId().isEmpty( ) )
213 tabAuth->setCurrentIndex( tabAuth->indexOf( tabConfigurations ) );
215 else if ( !( txtUserName->text( ).isEmpty() && txtPassword->text( ).isEmpty( ) ) )
217 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.