mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
Password strenght meter on login screen
This commit is contained in:
parent
aa9e500e22
commit
0ebaef3c34
|
@ -65,6 +65,11 @@ void SetPasswordDialog::onPasswordEdit()
|
|||
ui->body->setText(body);
|
||||
}
|
||||
|
||||
ui->strengthBar->setValue(getPasswordStrength(pswd));
|
||||
}
|
||||
|
||||
int SetPasswordDialog::getPasswordStrength(QString pswd)
|
||||
{
|
||||
// Password strength calculator
|
||||
// Based on code in the Master Password dialog in Firefox
|
||||
// (pref-masterpass.js)
|
||||
|
@ -98,7 +103,7 @@ void SetPasswordDialog::onPasswordEdit()
|
|||
if (pwstrength > 100)
|
||||
pwstrength = 100;
|
||||
|
||||
ui->strengthBar->setValue(pwstrength);
|
||||
return pwstrength;
|
||||
}
|
||||
|
||||
QString SetPasswordDialog::getPassword()
|
||||
|
|
|
@ -30,6 +30,7 @@ public:
|
|||
explicit SetPasswordDialog(QString body, QString extraButton, QWidget* parent = 0);
|
||||
~SetPasswordDialog();
|
||||
QString getPassword();
|
||||
static int getPasswordStrength(QString password);
|
||||
|
||||
private slots:
|
||||
void onPasswordEdit();
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include "src/profilelocker.h"
|
||||
#include "src/nexus.h"
|
||||
#include "src/misc/settings.h"
|
||||
#include "src/widget/form/setpassworddialog.h"
|
||||
#include <QMessageBox>
|
||||
#include <QDebug>
|
||||
|
||||
|
@ -22,6 +23,8 @@ LoginScreen::LoginScreen(QWidget *parent) :
|
|||
connect(ui->loginButton, &QPushButton::clicked, this, &LoginScreen::onLogin);
|
||||
connect(ui->loginUsernames, &QComboBox::currentTextChanged, this, &LoginScreen::onLoginUsernameSelected);
|
||||
connect(ui->loginPassword, &QLineEdit::returnPressed, this, &LoginScreen::onLogin);
|
||||
connect(ui->newPass, &QLineEdit::textChanged, this, &LoginScreen::onPasswordEdited);
|
||||
connect(ui->newPassConfirm, &QLineEdit::textChanged, this, &LoginScreen::onPasswordEdited);
|
||||
|
||||
reset();
|
||||
}
|
||||
|
@ -157,3 +160,8 @@ void LoginScreen::onLogin()
|
|||
nexus.setProfile(profile);
|
||||
nexus.showMainGUI();
|
||||
}
|
||||
|
||||
void LoginScreen::onPasswordEdited()
|
||||
{
|
||||
ui->passStrengthMeter->setValue(SetPasswordDialog::getPasswordStrength(ui->newPass->text()));
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ public:
|
|||
|
||||
private slots:
|
||||
void onLoginUsernameSelected(const QString& name);
|
||||
void onPasswordEdited();
|
||||
// Buttons to change page
|
||||
void onNewProfilePageClicked();
|
||||
void onLoginPageClicked();
|
||||
|
|
|
@ -317,9 +317,24 @@ margin-bottom:45px;</string>
|
|||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetMaximumSize</enum>
|
||||
</property>
|
||||
<property name="fieldGrowthPolicy">
|
||||
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
|
||||
</property>
|
||||
<property name="labelAlignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="formAlignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
<property name="horizontalSpacing">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="verticalSpacing">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>9</number>
|
||||
|
@ -333,20 +348,7 @@ margin-bottom:45px;</string>
|
|||
<property name="bottomMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Username:</string>
|
||||
|
@ -356,14 +358,14 @@ margin-bottom:45px;</string>
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="newUsername">
|
||||
<property name="maxLength">
|
||||
<number>64</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Password:</string>
|
||||
|
@ -373,44 +375,41 @@ margin-bottom:45px;</string>
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLineEdit" name="newPass">
|
||||
<property name="echoMode">
|
||||
<enum>QLineEdit::Password</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_8">
|
||||
<property name="text">
|
||||
<string>Confirm password:</string>
|
||||
<string>Confirm:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLineEdit" name="newPassConfirm">
|
||||
<property name="echoMode">
|
||||
<enum>QLineEdit::Password</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
<item row="7" column="0" colspan="2">
|
||||
<widget class="QProgressBar" name="passStrengthMeter">
|
||||
<property name="value">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
<property name="format">
|
||||
<string>Password strength: %p%</string>
|
||||
</property>
|
||||
</spacer>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<item row="9" column="0" colspan="2">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
|
@ -624,6 +623,32 @@ background-color:#6cc865;</string>
|
|||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="8" column="0" colspan="2">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="0" colspan="2">
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
|
|
Loading…
Reference in New Issue
Block a user