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;