123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- #include "Login.h"
- #include "OriginalWnd/OriginalWnd.h"
- #include "ui_Login.h"
- #include <QStackedWidget>
- #include <qDebug>
- #include <QSettings>
- #include "Src/common/JMessageTip.h"
- #include "Src/common/UserManagementShared.h"
- Login::Login(QWidget *parent)
- : QMainWindow(parent)
- , ui(new Ui::Login)
- {
- ui->setupUi(this);
- initForm();
- if(gen_if.getLanguageValue() == 0){
- }else{
- setChineseMode(this);
- }
- }
- Login::~Login()
- {
- delete ui;
- }
- void Login::initForm()
- {
- QPixmap pixmap(":/images/logo.png");
- QPixmap scaledPixmap = pixmap.scaled(283, 40, Qt::KeepAspectRatio);
- ui->label_logo->setPixmap(scaledPixmap);
-
- ui->userNameLineEdit->setPlaceholderText(tr("Please enter the account number"));
- ui->passLineEdit->setPlaceholderText(tr("Please enter your password"));
- connect(ui->userNameLineEdit, &QLineEdit::textChanged, this, &Login::onUserNameChanged);
- }
- void Login::setChineseMode(QMainWindow *Login)
- {
- Login->setWindowTitle(tr("Login", "主界面"));
- ui->SinginButton->setText(tr("Login", "登录"));
- ui->label_logo->setText(QString());
- ui->label_pass->setText(QString());
- ui->label_user->setText(QString());
- ui->ExitButton->setText(tr("Login", "退出"));
- ui->userNameLineEdit->setPlaceholderText("请输入账号");
- ui->passLineEdit->setPlaceholderText("请输入密码");
- }
- void Login::onUserNameChanged(const QString &userName)
- {
- QSettings settings("YourCompany_2", "YourAppName_2");
- settings.setValue("userName", userName);
- }
- void Login::on_SinginButton_clicked()
- {
- emit SendSwitchOriginalWndSignals();
- return;
- QString strTip;
- QString strUser = ui->userNameLineEdit->text().trimmed();
- if (!strUser.isEmpty())
- {
- QString strPass = ui->passLineEdit->text().trimmed();
- if (!strPass.isEmpty())
- {
- //JEncryption::Encryption();
- emit SendSwitchOriginalWndSignals();
- /*if (QStackedWidget* parent = qobject_cast<QStackedWidget*>(this->parentWidget()))
- {
- OriginalWnd* originalWnd = new OriginalWnd(this);
- parent->addWidget(originalWnd);
- parent->setCurrentIndex(parent->indexOf(originalWnd));
- }*/
- return;
- }
- else
- {
- strTip = tr("Please enter your password", "请输入密码");
- }
- }
- else
- {
- strTip = tr("Please enter your username", "请输入用户名称");
- }
-
- JMessageTip::Message_warning(strTip);
- }
- void Login::on_ExitButton_clicked()
- {
- emit CloseMainWndSig();
- }
|