18 #include "ui_qgsauthconfigidedit.h"
27 , mAuthCfgOrig( authcfg )
28 , mAllowEmpty( allowEmpty )
31 connect( btnLock, &QToolButton::toggled,
this, &QgsAuthConfigIdEdit::btnLock_toggled );
32 connect( leAuthCfg, &QLineEdit::textChanged,
this, &QgsAuthConfigIdEdit::leAuthCfg_textChanged );
34 leAuthCfg->setReadOnly(
true );
38 leAuthCfg->setText( authcfg );
46 return leAuthCfg->text();
53 QString authcfg( leAuthCfg->text() );
54 bool curvalid = ( ( authcfg == mAuthCfgOrig && authcfg.size() == 7 )
55 || ( mAllowEmpty && authcfg.isEmpty() ) );
62 if ( mValid != curvalid )
73 if ( mAuthCfgOrig.isEmpty() )
75 mAuthCfgOrig = authcfg;
77 leAuthCfg->setText( authcfg );
83 mAllowEmpty = allowed;
89 leAuthCfg->setText( mAuthCfgOrig );
90 updateValidityStyle(
true );
93 void QgsAuthConfigIdEdit::updateValidityStyle(
bool valid )
95 QString ss( QStringLiteral(
"QLineEdit{" ) );
96 ss += valid ? QString() : QStringLiteral(
"color: %1;" ).arg(
QgsAuthGuiUtils::redColor().name() );
97 ss += !btnLock->isChecked() ? QString() : QStringLiteral(
"background-color: %1;" ).arg(
QgsAuthGuiUtils::yellowColor().name() );
100 leAuthCfg->setStyleSheet( ss );
103 void QgsAuthConfigIdEdit::btnLock_toggled(
bool checked )
105 leAuthCfg->setReadOnly( !checked );
107 leAuthCfg->setFocus();
112 void QgsAuthConfigIdEdit::leAuthCfg_textChanged(
const QString &txt )
118 bool QgsAuthConfigIdEdit::isAlphaNumeric(
const QString &authcfg )
120 QRegExp rx(
"([a-z]|[A-Z]|[0-9]){7}" );
121 return rx.indexIn( authcfg ) != -1;
static QgsAuthManager * authManager()
Returns the application's authentication manager instance.
bool validate()
Validate the widget state and ID.
QgsAuthConfigIdEdit(QWidget *parent=nullptr, const QString &authcfg=QString(), bool allowEmpty=true)
Widget to unlock and edit an authentication configuration ID.
void setAuthConfigId(const QString &authcfg)
Sets the authentication configuration ID, storing it, and validating the passed value.
void validityChanged(bool valid)
Validity of the ID has changed.
void setAllowEmptyId(bool allowed)
Sets whether to allow no ID to be set.
void clear()
Clear all of the widget's editing state and contents.
QString const configId()
The authentication configuration ID, if valid, otherwise null QString.
Utility functions for use by authentication GUI widgets or standalone apps.
bool isDisabled() const
Whether QCA has the qca-ossl plugin, which a base run-time requirement.
bool configIdUnique(const QString &id) const
Verify if provided authentication id is unique.