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{" ) );
97 ss += !btnLock->isChecked() ? QLatin1String(
"" ) : 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;
void validityChanged(bool valid)
Validity of the ID has changed.
void setAuthConfigId(const QString &authcfg)
Sets the authentication configuration ID, storing it, and validating the passed value.
static QColor yellowColor()
Yellow color representing caution regarding action.
static QColor redColor()
Red color representing invalid, untrusted, etc. certificate.
void clear()
Clear all of the widget's editing state and contents.
QString const configId()
The authentication configuration ID, if valid, otherwise null QString.
bool validate()
Validate the widget state and ID.
static QgsAuthManager * authManager()
Returns the application's authentication manager instance.
void setAllowEmptyId(bool allowed)
Sets whether to allow no ID to be set.
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.
QgsAuthConfigIdEdit(QWidget *parent=nullptr, const QString &authcfg=QString(), bool allowEmpty=true)
Widget to unlock and edit an authentication configuration ID.