25#include "moc_qgsauthsettingswidget.cpp"
27using namespace Qt::StringLiterals;
42 mAuthConfigSelect->setConfigId(
configId );
48 connect( txtUserName, &QLineEdit::textChanged,
this, &QgsAuthSettingsWidget::userNameTextChanged );
49 connect( txtPassword, &QLineEdit::textChanged,
this, &QgsAuthSettingsWidget::passwordTextChanged );
55 updateConvertBtnState();
60 tabAuth->removeTab( tabAuth->indexOf( tabBasic ) );
61 tabAuth->setCurrentIndex( tabAuth->indexOf( tabConfigurations ) );
66 lblWarning->setText( warningText );
71 lblBasic->setText( basicText );
73 lblBasic->setVisible( !basicText.isEmpty() );
78 return txtUserName->text();
89 return txtPassword->text();
100 mAuthConfigSelect->setConfigId(
configId );
112 return mDataprovider;
117 const QString out = tr(
"Warning: credentials stored as plain text in %1." );
121 return out.arg( tr(
"project file" ) );
123 return out.arg( tr(
"user settings" ) );
130 return mAuthConfigSelect->configId();
135 return btnConvertToEncrypted->isEnabled();
142 cbStorePassword->show();
143 cbStoreUsername->show();
147 cbStorePassword->hide();
148 cbStoreUsername->hide();
154 cbStoreUsername->setChecked( checked );
159 cbStorePassword->setChecked( checked );
164 return cbStorePassword->isChecked();
169 return cbStoreUsername->isChecked();
174 return tabAuth->currentIndex() == tabAuth->indexOf( tabConfigurations );
179 tabAuth->setCurrentIndex( tabAuth->indexOf( tabConfigurations ) );
181 config.
setName( tr(
"Converted config %1" ).arg( QDateTime::currentDateTime().toString() ) );
182 config.
setConfig( u
"username"_s, txtUserName->text() );
183 config.
setConfig( u
"password"_s, txtPassword->text() );
186 mAuthConfigSelect->showMessage( tr(
"Couldn't create a Basic authentication configuration!" ) );
191 txtUserName->setText( QString() );
192 txtPassword->setText( QString() );
193 mAuthConfigSelect->setConfigId( config.
id() );
198void QgsAuthSettingsWidget::userNameTextChanged(
const QString &text )
201 updateConvertBtnState();
205void QgsAuthSettingsWidget::passwordTextChanged(
const QString &text )
208 updateConvertBtnState();
212void QgsAuthSettingsWidget::updateConvertBtnState()
214 btnConvertToEncrypted->setEnabled( !txtUserName->text().isEmpty() || !txtPassword->text().isEmpty() );
217void QgsAuthSettingsWidget::updateSelectedTab()
219 if ( !mAuthConfigSelect->configId().isEmpty() )
221 tabAuth->setCurrentIndex( tabAuth->indexOf( tabConfigurations ) );
223 else if ( !( txtUserName->text().isEmpty() && txtPassword->text().isEmpty() ) )
225 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.