18#include "moc_qgsauthconfigidedit.cpp"
19#include "ui_qgsauthconfigidedit.h"
25#include <QRegularExpression>
30 , mAuthCfgOrig( authcfg )
31 , mAllowEmpty( allowEmpty )
34 connect( btnLock, &QToolButton::toggled,
this, &QgsAuthConfigIdEdit::btnLock_toggled );
35 connect( leAuthCfg, &QLineEdit::textChanged,
this, &QgsAuthConfigIdEdit::leAuthCfg_textChanged );
37 leAuthCfg->setReadOnly(
true );
41 leAuthCfg->setText( authcfg );
49 return leAuthCfg->text();
56 const QString authcfg( leAuthCfg->text() );
57 bool curvalid = ( ( authcfg == mAuthCfgOrig && authcfg.size() == 7 )
58 || ( mAllowEmpty && authcfg.isEmpty() ) );
65 if ( mValid != curvalid )
76 if ( mAuthCfgOrig.isEmpty() )
78 mAuthCfgOrig = authcfg;
80 leAuthCfg->setText( authcfg );
86 mAllowEmpty = allowed;
92 leAuthCfg->setText( mAuthCfgOrig );
93 updateValidityStyle(
true );
96void QgsAuthConfigIdEdit::updateValidityStyle(
bool valid )
98 QString ss( QStringLiteral(
"QLineEdit{" ) );
99 ss += valid ? QString() : QStringLiteral(
"color: %1;" ).arg(
QgsAuthGuiUtils::redColor().name() );
100 ss += !btnLock->isChecked() ? QString() : QStringLiteral(
"background-color: %1;" ).arg(
QgsAuthGuiUtils::yellowColor().name() );
103 leAuthCfg->setStyleSheet( ss );
106void QgsAuthConfigIdEdit::btnLock_toggled(
bool checked )
108 leAuthCfg->setReadOnly( !checked );
110 leAuthCfg->setFocus();
115void QgsAuthConfigIdEdit::leAuthCfg_textChanged(
const QString &txt )
121bool QgsAuthConfigIdEdit::isAlphaNumeric(
const QString &authcfg )
123 const thread_local QRegularExpression alphaNumericRegExp(
"([a-z]|[A-Z]|[0-9]){7}" );
124 return authcfg.indexOf( alphaNumericRegExp ) != -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.