mirror of
https://bitbucket.org/smil3y/kdelibs.git
synced 2025-02-23 18:32:49 +00:00
kdeui: format and indent
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
37ee627773
commit
ff8033e1f1
1 changed files with 63 additions and 63 deletions
|
@ -41,10 +41,13 @@
|
||||||
class KNewPasswordDialog::KNewPasswordDialogPrivate
|
class KNewPasswordDialog::KNewPasswordDialogPrivate
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
KNewPasswordDialogPrivate( KNewPasswordDialog *parent )
|
KNewPasswordDialogPrivate(KNewPasswordDialog *parent)
|
||||||
: q( parent ),
|
: q(parent),
|
||||||
minimumPasswordLength(0), passwordStrengthWarningLevel(1),reasonablePasswordLength(8)
|
minimumPasswordLength(0),
|
||||||
{}
|
passwordStrengthWarningLevel(1),
|
||||||
|
reasonablePasswordLength(8)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void init();
|
void init();
|
||||||
void _k_textChanged();
|
void _k_textChanged();
|
||||||
|
@ -73,24 +76,27 @@ void KNewPasswordDialog::KNewPasswordDialogPrivate::init()
|
||||||
ui.pixmapIcon->setPixmap( KIcon("dialog-password").pixmap(96, 96) );
|
ui.pixmapIcon->setPixmap( KIcon("dialog-password").pixmap(96, 96) );
|
||||||
ui.labelMatch->setHidden(true);
|
ui.labelMatch->setHidden(true);
|
||||||
|
|
||||||
const QString strengthBarWhatsThis(i18n("The password strength meter gives an indication of the security "
|
const QString strengthBarWhatsThis(
|
||||||
|
i18n(
|
||||||
|
"The password strength meter gives an indication of the security "
|
||||||
"of the password you have entered. To improve the strength of "
|
"of the password you have entered. To improve the strength of "
|
||||||
"the password, try:\n"
|
"the password, try:\n"
|
||||||
" - using a longer password;\n"
|
" - using a longer password;\n"
|
||||||
" - using a mixture of upper- and lower-case letters;\n"
|
" - using a mixture of upper- and lower-case letters;\n"
|
||||||
" - using numbers or symbols, such as #, as well as letters."));
|
" - using numbers or symbols, such as #, as well as letters."
|
||||||
|
)
|
||||||
|
);
|
||||||
ui.labelStrengthMeter->setWhatsThis(strengthBarWhatsThis);
|
ui.labelStrengthMeter->setWhatsThis(strengthBarWhatsThis);
|
||||||
ui.strengthBar->setWhatsThis(strengthBarWhatsThis);
|
ui.strengthBar->setWhatsThis(strengthBarWhatsThis);
|
||||||
|
|
||||||
connect( ui.linePassword, SIGNAL(textChanged(QString)), q, SLOT(_k_textChanged()) );
|
connect(ui.linePassword, SIGNAL(textChanged(QString)), q, SLOT(_k_textChanged()));
|
||||||
connect( ui.lineVerifyPassword, SIGNAL(textChanged(QString)), q, SLOT(_k_textChanged()) );
|
connect(ui.lineVerifyPassword, SIGNAL(textChanged(QString)), q, SLOT(_k_textChanged()));
|
||||||
|
|
||||||
ui.linePassword->setFocus();
|
ui.linePassword->setFocus();
|
||||||
|
|
||||||
_k_textChanged();
|
_k_textChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int KNewPasswordDialog::KNewPasswordDialogPrivate::effectivePasswordLength(const QString &password)
|
int KNewPasswordDialog::KNewPasswordDialogPrivate::effectivePasswordLength(const QString &password)
|
||||||
{
|
{
|
||||||
enum Category {
|
enum Category {
|
||||||
|
@ -110,39 +116,46 @@ int KNewPasswordDialog::KNewPasswordDialogPrivate::effectivePasswordLength(const
|
||||||
if (!password.left(i).contains(currentChar)) {
|
if (!password.left(i).contains(currentChar)) {
|
||||||
Category currentCategory;
|
Category currentCategory;
|
||||||
switch (currentChar.category()) {
|
switch (currentChar.category()) {
|
||||||
case QChar::Letter_Uppercase:
|
case QChar::Letter_Uppercase: {
|
||||||
currentCategory = Upper;
|
currentCategory = Upper;
|
||||||
break;
|
break;
|
||||||
case QChar::Letter_Lowercase:
|
}
|
||||||
|
case QChar::Letter_Lowercase: {
|
||||||
if (vowels.contains(currentChar)) {
|
if (vowels.contains(currentChar)) {
|
||||||
currentCategory = Vowel;
|
currentCategory = Vowel;
|
||||||
} else {
|
} else {
|
||||||
currentCategory = Consonant;
|
currentCategory = Consonant;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case QChar::Number_DecimalDigit:
|
}
|
||||||
|
case QChar::Number_DecimalDigit: {
|
||||||
currentCategory = Digit;
|
currentCategory = Digit;
|
||||||
break;
|
break;
|
||||||
default:
|
}
|
||||||
|
default: {
|
||||||
currentCategory = Special;
|
currentCategory = Special;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
switch (currentCategory) {
|
switch (currentCategory) {
|
||||||
case Vowel:
|
case Vowel: {
|
||||||
if (previousCategory != Consonant) {
|
if (previousCategory != Consonant) {
|
||||||
++count;
|
++count;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Consonant:
|
}
|
||||||
|
case Consonant: {
|
||||||
if (previousCategory != Vowel) {
|
if (previousCategory != Vowel) {
|
||||||
++count;
|
++count;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
}
|
||||||
|
default: {
|
||||||
if (previousCategory != currentCategory) {
|
if (previousCategory != currentCategory) {
|
||||||
++count;
|
++count;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
previousCategory = currentCategory;
|
previousCategory = currentCategory;
|
||||||
}
|
}
|
||||||
|
@ -154,28 +167,27 @@ int KNewPasswordDialog::KNewPasswordDialogPrivate::effectivePasswordLength(const
|
||||||
void KNewPasswordDialog::KNewPasswordDialogPrivate::_k_textChanged()
|
void KNewPasswordDialog::KNewPasswordDialogPrivate::_k_textChanged()
|
||||||
{
|
{
|
||||||
const bool match = ui.linePassword->text() == ui.lineVerifyPassword->text();
|
const bool match = ui.linePassword->text() == ui.lineVerifyPassword->text();
|
||||||
|
|
||||||
const int minPasswordLength = q->minimumPasswordLength();
|
const int minPasswordLength = q->minimumPasswordLength();
|
||||||
|
|
||||||
if ( ui.linePassword->text().length() < minPasswordLength) {
|
if (ui.linePassword->text().length() < minPasswordLength) {
|
||||||
q->enableButtonOk(false);
|
q->enableButtonOk(false);
|
||||||
} else {
|
} else {
|
||||||
q->enableButtonOk( match );
|
q->enableButtonOk(match);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( match && !q->allowEmptyPasswords() && ui.linePassword->text().isEmpty()) {
|
if ( match && !q->allowEmptyPasswords() && ui.linePassword->text().isEmpty()) {
|
||||||
ui.labelMatch->setPixmap( KIcon("dialog-error") );
|
ui.labelMatch->setPixmap(KIcon("dialog-error"));
|
||||||
ui.labelMatch->setText( i18n("Password is empty") );
|
ui.labelMatch->setText(i18n("Password is empty"));
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
if ( ui.linePassword->text().length() < minPasswordLength ) {
|
if ( ui.linePassword->text().length() < minPasswordLength ) {
|
||||||
ui.labelMatch->setPixmap( KIcon("dialog-error") );
|
ui.labelMatch->setPixmap( KIcon("dialog-error") );
|
||||||
ui.labelMatch->setText(i18np("Password must be at least 1 character long", "Password must be at least %1 characters long", minPasswordLength));
|
ui.labelMatch->setText(
|
||||||
|
i18np("Password must be at least 1 character long", "Password must be at least %1 characters long", minPasswordLength)
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
ui.labelMatch->setPixmap( match ? KIcon("dialog-ok") : KIcon("dialog-error") );
|
ui.labelMatch->setPixmap(match ? KIcon("dialog-ok") : KIcon("dialog-error"));
|
||||||
// "ok" icon should probably be "dialog-success", but we don't have that icon in KDE 4.0
|
// "ok" icon should probably be "dialog-success", but we don't have that icon in KDE 4.0
|
||||||
ui.labelMatch->setText( match? i18n("Passwords match")
|
ui.labelMatch->setText(match? i18n("Passwords match") : i18n("Passwords do not match"));
|
||||||
:i18n("Passwords do not match") );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -189,42 +201,34 @@ void KNewPasswordDialog::KNewPasswordDialogPrivate::_k_textChanged()
|
||||||
ui.strengthBar->setValue(pwstrength);
|
ui.strengthBar->setValue(pwstrength);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Password dialog.
|
|
||||||
*/
|
|
||||||
|
|
||||||
KNewPasswordDialog::KNewPasswordDialog( QWidget *parent)
|
KNewPasswordDialog::KNewPasswordDialog( QWidget *parent)
|
||||||
: KDialog(parent), d(new KNewPasswordDialogPrivate(this))
|
: KDialog(parent),
|
||||||
|
d(new KNewPasswordDialogPrivate(this))
|
||||||
{
|
{
|
||||||
d->init();
|
d->init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
KNewPasswordDialog::~KNewPasswordDialog()
|
KNewPasswordDialog::~KNewPasswordDialog()
|
||||||
{
|
{
|
||||||
delete d;
|
delete d;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void KNewPasswordDialog::setPrompt(const QString &prompt)
|
void KNewPasswordDialog::setPrompt(const QString &prompt)
|
||||||
{
|
{
|
||||||
d->ui.labelPrompt->setText(prompt);
|
d->ui.labelPrompt->setText(prompt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString KNewPasswordDialog::prompt() const
|
QString KNewPasswordDialog::prompt() const
|
||||||
{
|
{
|
||||||
return d->ui.labelPrompt->text();
|
return d->ui.labelPrompt->text();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void KNewPasswordDialog::setPixmap(const QPixmap &pixmap)
|
void KNewPasswordDialog::setPixmap(const QPixmap &pixmap)
|
||||||
{
|
{
|
||||||
d->ui.pixmapIcon->setPixmap(pixmap);
|
d->ui.pixmapIcon->setPixmap(pixmap);
|
||||||
d->ui.pixmapIcon->setFixedSize( d->ui.pixmapIcon->sizeHint() );
|
d->ui.pixmapIcon->setFixedSize(d->ui.pixmapIcon->sizeHint());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QPixmap KNewPasswordDialog::pixmap() const
|
QPixmap KNewPasswordDialog::pixmap() const
|
||||||
{
|
{
|
||||||
return d->ui.pixmapIcon->pixmap();
|
return d->ui.pixmapIcon->pixmap();
|
||||||
|
@ -234,28 +238,33 @@ bool KNewPasswordDialog::checkAndGetPassword(QString *pwd)
|
||||||
{
|
{
|
||||||
pwd->clear();
|
pwd->clear();
|
||||||
if ( d->ui.linePassword->text() != d->ui.lineVerifyPassword->text() ) {
|
if ( d->ui.linePassword->text() != d->ui.lineVerifyPassword->text() ) {
|
||||||
d->ui.labelMatch->setPixmap( KTitleWidget::ErrorMessage );
|
d->ui.labelMatch->setPixmap(KTitleWidget::ErrorMessage);
|
||||||
d->ui.labelMatch->setText( i18n("You entered two different "
|
d->ui.labelMatch->setText(i18n("You entered two different passwords. Please try again."));
|
||||||
"passwords. Please try again.") );
|
|
||||||
|
|
||||||
d->ui.linePassword->clear();
|
d->ui.linePassword->clear();
|
||||||
d->ui.lineVerifyPassword->clear();
|
d->ui.lineVerifyPassword->clear();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (d->ui.strengthBar && d->ui.strengthBar->value() < d->passwordStrengthWarningLevel) {
|
if (d->ui.strengthBar && d->ui.strengthBar->value() < d->passwordStrengthWarningLevel) {
|
||||||
int retVal = KMessageBox::warningYesNo(this,
|
int retVal = KMessageBox::warningYesNo(
|
||||||
i18n( "The password you have entered has a low strength. "
|
this,
|
||||||
"To improve the strength of "
|
i18n(
|
||||||
"the password, try:\n"
|
"The password you have entered has a low strength. "
|
||||||
" - using a longer password;\n"
|
"To improve the strength of "
|
||||||
" - using a mixture of upper- and lower-case letters;\n"
|
"the password, try:\n"
|
||||||
" - using numbers or symbols as well as letters.\n"
|
" - using a longer password;\n"
|
||||||
"\n"
|
" - using a mixture of upper- and lower-case letters;\n"
|
||||||
"Would you like to use this password anyway?"),
|
" - using numbers or symbols as well as letters.\n"
|
||||||
i18n("Low Password Strength"));
|
"\n"
|
||||||
if (retVal == KMessageBox::No) return false;
|
"Would you like to use this password anyway?"
|
||||||
|
),
|
||||||
|
i18n("Low Password Strength")
|
||||||
|
);
|
||||||
|
if (retVal == KMessageBox::No) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if ( !checkPassword(d->ui.linePassword->text()) ) {
|
if (!checkPassword(d->ui.linePassword->text())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -274,14 +283,12 @@ void KNewPasswordDialog::accept()
|
||||||
KDialog::accept();
|
KDialog::accept();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void KNewPasswordDialog::setAllowEmptyPasswords(bool allowed)
|
void KNewPasswordDialog::setAllowEmptyPasswords(bool allowed)
|
||||||
{
|
{
|
||||||
setMinimumPasswordLength( allowed ? 0 : 1 );
|
setMinimumPasswordLength(allowed ? 0 : 1);
|
||||||
d->_k_textChanged();
|
d->_k_textChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool KNewPasswordDialog::allowEmptyPasswords() const
|
bool KNewPasswordDialog::allowEmptyPasswords() const
|
||||||
{
|
{
|
||||||
return d->minimumPasswordLength == 0;
|
return d->minimumPasswordLength == 0;
|
||||||
|
@ -309,8 +316,6 @@ int KNewPasswordDialog::maximumPasswordLength() const
|
||||||
return d->ui.linePassword->maxLength();
|
return d->ui.linePassword->maxLength();
|
||||||
}
|
}
|
||||||
|
|
||||||
// reasonable password length code contributed by Steffen Mthing
|
|
||||||
|
|
||||||
void KNewPasswordDialog::setReasonablePasswordLength(int reasonableLength)
|
void KNewPasswordDialog::setReasonablePasswordLength(int reasonableLength)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -320,9 +325,7 @@ void KNewPasswordDialog::setReasonablePasswordLength(int reasonableLength)
|
||||||
if (reasonableLength >= maximumPasswordLength()) {
|
if (reasonableLength >= maximumPasswordLength()) {
|
||||||
reasonableLength = maximumPasswordLength();
|
reasonableLength = maximumPasswordLength();
|
||||||
}
|
}
|
||||||
|
|
||||||
d->reasonablePasswordLength = reasonableLength;
|
d->reasonablePasswordLength = reasonableLength;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int KNewPasswordDialog::reasonablePasswordLength() const
|
int KNewPasswordDialog::reasonablePasswordLength() const
|
||||||
|
@ -330,7 +333,6 @@ int KNewPasswordDialog::reasonablePasswordLength() const
|
||||||
return d->reasonablePasswordLength;
|
return d->reasonablePasswordLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void KNewPasswordDialog::setPasswordStrengthWarningLevel(int warningLevel)
|
void KNewPasswordDialog::setPasswordStrengthWarningLevel(int warningLevel)
|
||||||
{
|
{
|
||||||
if (warningLevel < 0) {
|
if (warningLevel < 0) {
|
||||||
|
@ -358,5 +360,3 @@ bool KNewPasswordDialog::checkPassword(const QString &)
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "moc_knewpassworddialog.cpp"
|
#include "moc_knewpassworddialog.cpp"
|
||||||
|
|
||||||
// kate: space-indent on; indent-width 4; encoding utf-8; replace-tabs on;
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue