diff --git a/src/coreencryption.cpp b/src/coreencryption.cpp index 0ee3906e9..7ad296ab4 100644 --- a/src/coreencryption.cpp +++ b/src/coreencryption.cpp @@ -72,6 +72,9 @@ void Core::clearPassword(PasswordType passtype) delete[] pwsaltedkeys[passtype]; pwsaltedkeys[passtype] = nullptr; } + + if (passtype == ptMain) + saveConfiguration(); } QByteArray Core::encryptData(const QByteArray& data, PasswordType passtype) diff --git a/src/historykeeper.cpp b/src/historykeeper.cpp index 9324a52e8..808d0bfc4 100644 --- a/src/historykeeper.cpp +++ b/src/historykeeper.cpp @@ -137,7 +137,7 @@ HistoryKeeper::~HistoryKeeper() void HistoryKeeper::reencrypt(QString newpw) { - // this needs to appropriately set the core password as well + // TODO: this needs to appropriately set the core password as well // if newpw.isEmpty(), then use the other core password } diff --git a/src/widget/form/setpassworddialog.cpp b/src/widget/form/setpassworddialog.cpp index 2e401b79f..c8d08cfef 100644 --- a/src/widget/form/setpassworddialog.cpp +++ b/src/widget/form/setpassworddialog.cpp @@ -27,7 +27,8 @@ SetPasswordDialog::SetPasswordDialog(QString body, QString extraButton, QWidget* connect(ui->passwordlineEdit, SIGNAL(textChanged(QString)), this, SLOT(onPasswordEdit())); connect(ui->repasswordlineEdit, SIGNAL(textChanged(QString)), this, SLOT(onPasswordEdit())); - ui->body->setText(body); + ui->body->setText(body + tr("\nTo encourage good habits, qTox requires at least 8 characters.")); + ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false); if (!extraButton.isEmpty()) { @@ -44,7 +45,7 @@ SetPasswordDialog::~SetPasswordDialog() void SetPasswordDialog::onPasswordEdit() { - if ( !ui->passwordlineEdit->text().isEmpty() + if ( ui->passwordlineEdit->text().length() >= 8 && ui->passwordlineEdit->text() == ui->repasswordlineEdit->text()) ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true); else diff --git a/src/widget/form/setpassworddialog.ui b/src/widget/form/setpassworddialog.ui index 02d803bb5..3d6229d79 100644 --- a/src/widget/form/setpassworddialog.ui +++ b/src/widget/form/setpassworddialog.ui @@ -20,6 +20,19 @@ + + + + Qt::Vertical + + + + 20 + 12 + + + + @@ -64,7 +77,7 @@ 20 - 40 + 12 diff --git a/src/widget/form/settings/privacyform.cpp b/src/widget/form/settings/privacyform.cpp index 158f03683..3c994013e 100644 --- a/src/widget/form/settings/privacyform.cpp +++ b/src/widget/form/settings/privacyform.cpp @@ -32,10 +32,15 @@ PrivacyForm::PrivacyForm() : bodyUI = new Ui::PrivacySettings; bodyUI->setupUi(this); + bodyUI->encryptToxHLayout->addStretch(); + bodyUI->encryptLogsHLayout->addStretch(); + connect(bodyUI->cbTypingNotification, SIGNAL(stateChanged(int)), this, SLOT(onTypingNotificationEnabledUpdated())); connect(bodyUI->cbKeepHistory, SIGNAL(stateChanged(int)), this, SLOT(onEnableLoggingUpdated())); connect(bodyUI->cbEncryptHistory, SIGNAL(clicked()), this, SLOT(onEncryptLogsUpdated())); + connect(bodyUI->changeLogsPwButton, &QPushButton::clicked, this, &PrivacyForm::setChatLogsPassword); connect(bodyUI->cbEncryptTox, SIGNAL(clicked()), this, SLOT(onEncryptToxUpdated())); + connect(bodyUI->changeToxPwButton, &QPushButton::clicked, this, &PrivacyForm::setToxPassword); connect(bodyUI->nospamLineEdit, SIGNAL(editingFinished()), this, SLOT(setNospam())); connect(bodyUI->randomNosapamButton, SIGNAL(clicked()), this, SLOT(generateRandomNospam())); connect(bodyUI->nospamLineEdit, SIGNAL(textChanged(QString)), this, SLOT(onNospamEdit())); @@ -61,8 +66,9 @@ void PrivacyForm::onTypingNotificationEnabledUpdated() bool PrivacyForm::setChatLogsPassword() { + Core* core = Core::getInstance(); SetPasswordDialog* dialog; - QString body = tr("Please set your new chat log password:"); + QString body = tr("Please set your new chat log password."); if (core->isPasswordSet(Core::ptMain)) dialog = new SetPasswordDialog(body, tr("Use data file password", "pushbutton text"), this); else @@ -110,7 +116,8 @@ void PrivacyForm::onEncryptLogsUpdated() Settings::getInstance().setEncryptLogs(true); bodyUI->cbEncryptHistory->setChecked(true); // not logically necessary, but more consistent (esp. if the logic changes) - // enable change pw button + bodyUI->changeLogsPwButton->setEnabled(true); + return; } } } @@ -127,13 +134,14 @@ void PrivacyForm::onEncryptLogsUpdated() core->clearPassword(Core::ptHistory); Settings::getInstance().setEncryptLogs(false); bodyUI->cbEncryptHistory->setChecked(false); - // disable change pw button + bodyUI->changeLogsPwButton->setEnabled(false); } bool PrivacyForm::setToxPassword() { + Core* core = Core::getInstance(); SetPasswordDialog* dialog; - QString body = tr("Please set your new data file password:"); + QString body = tr("Please set your new data file password."); if (core->isPasswordSet(Core::ptHistory)) dialog = new SetPasswordDialog(body, tr("Use chat log password", "pushbutton text"), this); else @@ -162,18 +170,18 @@ void PrivacyForm::onEncryptToxUpdated() Core* core = Core::getInstance(); if (bodyUI->cbEncryptTox->isChecked()) - if (!Core::getInstance()->isPasswordSet(Core::ptMain)) + if (!core->isPasswordSet(Core::ptMain)) if (setToxPassword()) { bodyUI->cbEncryptTox->setChecked(true); Settings::getInstance().setEncryptTox(true); - // enable change pw button + bodyUI->changeToxPwButton->setEnabled(true); return; } bodyUI->cbEncryptTox->setChecked(false); Settings::getInstance().setEncryptTox(false); - // disable change pw button + bodyUI->changeToxPwButton->setEnabled(false); core->clearPassword(Core::ptMain); } @@ -193,8 +201,10 @@ void PrivacyForm::present() bodyUI->cbTypingNotification->setChecked(Settings::getInstance().isTypingNotificationEnabled()); bodyUI->cbKeepHistory->setChecked(Settings::getInstance().getEnableLogging()); bodyUI->cbEncryptHistory->setChecked(Settings::getInstance().getEncryptLogs()); + bodyUI->changeLogsPwButton->setEnabled(Settings::getInstance().getEncryptLogs()); bodyUI->cbEncryptHistory->setEnabled(Settings::getInstance().getEnableLogging()); bodyUI->cbEncryptTox->setChecked(Settings::getInstance().getEncryptTox()); + bodyUI->changeToxPwButton->setEnabled(Settings::getInstance().getEncryptTox()); } void PrivacyForm::generateRandomNospam() diff --git a/src/widget/form/settings/privacysettings.ui b/src/widget/form/settings/privacysettings.ui index 0491dab15..452725c2e 100644 --- a/src/widget/form/settings/privacysettings.ui +++ b/src/widget/form/settings/privacysettings.ui @@ -71,27 +71,49 @@ - - - true - - - Encrypt Tox data file - - + + + + + true + + + Encrypt Tox data file + + + + + + + Change password + + + + - - - true - - - Encrypt chat logs - - - true - - + + + + + true + + + Encrypt chat logs + + + true + + + + + + + Change password + + + +