mirror of
https://github.com/chenx-dust/EZ4Connect.git
synced 2026-09-20 10:23:33 +08:00
- Added credential validation in login and settings windows to ensure non-empty and ASCII-only username/password. - Introduced a checkbox to toggle password visibility in both login and settings interfaces. - Updated UI elements for better layout and user experience, including adjustments to labels and button properties. - Refactored signal connections for button actions to improve clarity and functionality.
45 lines
1.0 KiB
C++
45 lines
1.0 KiB
C++
#include "loginwindow.h"
|
|
|
|
#include "../utils/utils.h"
|
|
|
|
#include <QMessageBox>
|
|
#include <QPushButton>
|
|
|
|
LoginWindow::LoginWindow(QWidget *parent)
|
|
: QDialog(parent),
|
|
ui(new Ui::LoginWindow)
|
|
{
|
|
ui->setupUi(this);
|
|
|
|
setWindowModality(Qt::WindowModal);
|
|
setAttribute(Qt::WA_DeleteOnClose);
|
|
|
|
connect(ui->buttonBox->button(QDialogButtonBox::Ok), &QPushButton::clicked,
|
|
[&]()
|
|
{
|
|
if (!Utils::credentialCheck(ui->usernameLineEdit->text(), ui->passwordLineEdit->text()))
|
|
return;
|
|
emit login(ui->usernameLineEdit->text(), ui->passwordLineEdit->text(), ui->saveLoginDetailCheckBox->isChecked());
|
|
emit accept();
|
|
}
|
|
);
|
|
|
|
connect(ui->passwordVisibleCheckBox, &QCheckBox::checkStateChanged,
|
|
[&](Qt::CheckState state)
|
|
{
|
|
ui->passwordLineEdit->setEchoMode(state == Qt::Checked ? QLineEdit::Normal : QLineEdit::Password);
|
|
}
|
|
);
|
|
}
|
|
|
|
LoginWindow::~LoginWindow()
|
|
{
|
|
delete ui;
|
|
}
|
|
|
|
void LoginWindow::setDetail(const QString& username, const QString& password)
|
|
{
|
|
ui->usernameLineEdit->setText(username);
|
|
ui->passwordLineEdit->setText(password);
|
|
}
|