1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- #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()
- {
- 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();
- }
|