1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

Confirm decrypt data, various ui/txt tweaks

This commit is contained in:
Dubslow 2015-01-23 07:05:46 -06:00
parent 18e875ef20
commit 358a56c555
No known key found for this signature in database
GPG Key ID: 3DB8E05315C220AA
6 changed files with 41 additions and 15 deletions

View File

@ -163,7 +163,7 @@ bool Core::loadEncryptedSave(QByteArray& data)
setPassword(pw, ptMain, salt);
error = tox_encrypted_key_load(tox, reinterpret_cast<uint8_t *>(data.data()), data.size(), pwsaltedkeys[ptMain]);
dialogtxt = a + " " + b;
dialogtxt = a + "\n" + b;
} while (error != 0);
Settings::getInstance().setEncryptTox(true);
@ -224,7 +224,7 @@ void Core::checkEncryptedHistory()
setPassword(pw, ptHistory, reinterpret_cast<uint8_t*>(salt.data()));
error = exists && !HistoryKeeper::checkPassword();
dialogtxt = a + " " + b;
dialogtxt = a + "\n" + b;
} while (error);
}

View File

@ -23,13 +23,14 @@ const double SetPasswordDialog::reasonablePasswordLength = 8.;
SetPasswordDialog::SetPasswordDialog(QString body, QString extraButton, QWidget* parent)
: QDialog(parent)
, ui(new Ui::SetPasswordDialog)
, body(body+"\n")
{
ui->setupUi(this);
connect(ui->passwordlineEdit, SIGNAL(textChanged(QString)), this, SLOT(onPasswordEdit()));
connect(ui->repasswordlineEdit, SIGNAL(textChanged(QString)), this, SLOT(onPasswordEdit()));
ui->body->setText(body + tr("\nTo encourage good habits, qTox requires at least 8 characters."));
ui->body->setText(body + "\n" + tr("The passwords don't match."));
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
if (!extraButton.isEmpty())
@ -50,9 +51,15 @@ void SetPasswordDialog::onPasswordEdit()
QString pswd = ui->passwordlineEdit->text();
if (pswd == ui->repasswordlineEdit->text() && pswd.length() > 0)
{
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
ui->body->setText(body);
}
else
{
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
ui->body->setText(body + tr("The passwords don't match."));
}
// Password strength calculator
// Based on code in the Master Password dialog in Firefox

View File

@ -37,6 +37,7 @@ private slots:
private:
Ui::SetPasswordDialog *ui;
QString body;
static const double reasonablePasswordLength;
};

View File

@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>493</width>
<width>325</width>
<height>160</height>
</rect>
</property>
@ -24,15 +24,21 @@
<layout class="QGridLayout" name="pswdsLayout">
<item row="4" column="0">
<widget class="QLabel" name="label_2">
<property name="alignment">
<set>Qt::AlignRight</set>
</property>
<property name="text">
<string>Repeat Password</string>
<string>Repeat password</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label">
<property name="alignment">
<set>Qt::AlignRight</set>
</property>
<property name="text">
<string>Type password:</string>
<string>Type password</string>
</property>
</widget>
</item>
@ -50,18 +56,17 @@
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="pswdStrengthLayout">
<item>
<item row="6" column="0">
<widget class="QLabel" name="label_3">
<property name="alignment">
<set>Qt::AlignRight</set>
</property>
<property name="text">
<string>Password strength meter</string>
<string>Password strength</string>
</property>
</widget>
</item>
<item>
<item row="6" column="1">
<widget class="QProgressBar" name="strengthBar">
<property name="value">
<number>0</number>

View File

@ -124,7 +124,7 @@ void PrivacyForm::onEncryptLogsUpdated()
QMessageBox::StandardButton button = QMessageBox::warning(
Widget::getInstance(),
tr("Old encrypted chat logs", "title"),
tr("Would you like to un-encrypt your chat logs?\nOtherwise they will be deleted."),
tr("Would you like to decrypt your chat logs?\nOtherwise they will be deleted."),
QMessageBox::Ok | QMessageBox::No | QMessageBox::Cancel,
QMessageBox::Cancel
);
@ -204,13 +204,26 @@ void PrivacyForm::onEncryptToxUpdated()
Core* core = Core::getInstance();
if (bodyUI->cbEncryptTox->isChecked())
{
if (!core->isPasswordSet(Core::ptMain))
{
if (setToxPassword())
{
bodyUI->cbEncryptTox->setChecked(true);
bodyUI->changeToxPwButton->setEnabled(true);
return;
}
}
}
else
{
if (!Widget::getInstance()->askQuestion(tr("Decrypt your data file", "title"), tr("Would you like to decrypt your data file?")))
{
bodyUI->cbEncryptTox->setChecked(true);
return;
}
// affirmative answer falls through to the catch all below
}
bodyUI->cbEncryptTox->setChecked(false);
Settings::getInstance().setEncryptTox(false);

View File

@ -68,8 +68,8 @@ public:
Q_INVOKABLE void setEnabledThreadsafe(bool enabled);
Q_INVOKABLE bool askQuestion(const QString& title, const QString& msg, bool defaultAns = false, bool warning = true);
Q_INVOKABLE QString passwordDialog(const QString& cancel, const QString& body);
// hooray for threading hacks
Q_INVOKABLE QString askProfiles();
// hooray for threading hacks
~Widget();
virtual void closeEvent(QCloseEvent *event);