mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-09-24 10:23:02 -07:00
* [Settings] Split cache_settings into multiple files Took 9 minutes Took 4 minutes * [Settings] Fwd declare settings classes in cache_settings Took 15 minutes * Fix oracle includes. Took 8 minutes * Address comments, fix windows CI Took 8 minutes * fix copy constructor visibility Took 3 minutes * lint Took 2 minutes * Fix native format tests. Took 5 minutes * Remove test header guard Took 4 seconds * Remove tests invalid in CI environ Took 24 seconds * Adjust to rebase. Took 11 minutes * Change settings file name. Took 8 minutes --------- Co-authored-by: Lukas Brübach <lukas.bruebach@bdosecurity.de> Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
73 lines
2.5 KiB
C++
73 lines
2.5 KiB
C++
#include "dlg_edit_password.h"
|
|
|
|
#include "../../../client/settings/cache_settings.h"
|
|
|
|
#include <QDialogButtonBox>
|
|
#include <QGridLayout>
|
|
#include <QHBoxLayout>
|
|
#include <QLabel>
|
|
#include <QMessageBox>
|
|
#include <libcockatrice/settings/servers_settings.h>
|
|
#include <libcockatrice/utility/string_limits.h>
|
|
|
|
DlgEditPassword::DlgEditPassword(QWidget *parent) : QDialog(parent)
|
|
{
|
|
oldPasswordLabel = new QLabel(tr("Old password:"));
|
|
oldPasswordEdit = new QLineEdit();
|
|
oldPasswordEdit->setMaxLength(MAX_NAME_LENGTH);
|
|
|
|
auto &servers = SettingsCache::instance().servers();
|
|
if (servers.getSavePassword()) {
|
|
oldPasswordEdit->setText(servers.getPassword());
|
|
}
|
|
|
|
oldPasswordLabel->setBuddy(oldPasswordEdit);
|
|
oldPasswordEdit->setEchoMode(QLineEdit::Password);
|
|
|
|
newPasswordLabel = new QLabel(tr("New password:"));
|
|
newPasswordEdit = new QLineEdit();
|
|
newPasswordEdit->setMaxLength(MAX_NAME_LENGTH);
|
|
newPasswordLabel->setBuddy(newPasswordLabel);
|
|
newPasswordEdit->setEchoMode(QLineEdit::Password);
|
|
|
|
newPasswordLabel2 = new QLabel(tr("Confirm new password:"));
|
|
newPasswordEdit2 = new QLineEdit();
|
|
newPasswordEdit2->setMaxLength(MAX_NAME_LENGTH);
|
|
newPasswordLabel2->setBuddy(newPasswordLabel2);
|
|
newPasswordEdit2->setEchoMode(QLineEdit::Password);
|
|
|
|
QGridLayout *grid = new QGridLayout;
|
|
grid->addWidget(oldPasswordLabel, 0, 0);
|
|
grid->addWidget(oldPasswordEdit, 0, 1);
|
|
grid->addWidget(newPasswordLabel, 1, 0);
|
|
grid->addWidget(newPasswordEdit, 1, 1);
|
|
grid->addWidget(newPasswordLabel2, 2, 0);
|
|
grid->addWidget(newPasswordEdit2, 2, 1);
|
|
|
|
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
|
connect(buttonBox, &QDialogButtonBox::accepted, this, &DlgEditPassword::actOk);
|
|
connect(buttonBox, &QDialogButtonBox::rejected, this, &DlgEditPassword::reject);
|
|
|
|
QVBoxLayout *mainLayout = new QVBoxLayout;
|
|
mainLayout->addLayout(grid);
|
|
mainLayout->addWidget(buttonBox);
|
|
setLayout(mainLayout);
|
|
|
|
setWindowTitle(tr("Change password"));
|
|
setFixedHeight(sizeHint().height());
|
|
setMinimumWidth(300);
|
|
}
|
|
|
|
void DlgEditPassword::actOk()
|
|
{
|
|
//! \todo This stuff should be using QValidators.
|
|
if (newPasswordEdit->text().length() < 8) {
|
|
QMessageBox::critical(this, tr("Error"), tr("Your password is too short."));
|
|
return;
|
|
} else if (newPasswordEdit->text() != newPasswordEdit2->text()) {
|
|
QMessageBox::warning(this, tr("Error"), tr("The new passwords don't match."));
|
|
return;
|
|
}
|
|
|
|
accept();
|
|
}
|