2024-09-10 16:12:38 +08:00
|
|
|
|
#include "mainwindow.h"
|
2024-09-10 14:38:23 +08:00
|
|
|
|
#include "ui_mainwindow.h"
|
2024-09-10 16:12:38 +08:00
|
|
|
|
#include <QPixmap>
|
|
|
|
|
#include <QMessageBox>
|
|
|
|
|
#include <QRegularExpression>
|
|
|
|
|
#include <QRegularExpressionValidator>
|
2024-09-10 14:38:23 +08:00
|
|
|
|
|
2024-09-10 16:55:41 +08:00
|
|
|
|
#include "MainDialog.h"
|
|
|
|
|
|
2024-09-10 14:38:23 +08:00
|
|
|
|
MainWindow::MainWindow(QWidget *parent)
|
|
|
|
|
: QMainWindow(parent)
|
|
|
|
|
, ui(new Ui::MainWindow)
|
2024-09-10 16:55:41 +08:00
|
|
|
|
, m_pMainDialog(nullptr)
|
2024-09-10 14:38:23 +08:00
|
|
|
|
{
|
|
|
|
|
ui->setupUi(this);
|
2024-09-10 16:12:38 +08:00
|
|
|
|
this->setWindowIcon(QIcon(":/images/icon.png"));
|
|
|
|
|
|
|
|
|
|
QPixmap pixmap(":/images/hj-net.png");
|
|
|
|
|
pixmap = pixmap.scaled(250, 75, Qt::KeepAspectRatio, Qt::SmoothTransformation); // 按比例缩放
|
|
|
|
|
ui->label_logo->setPixmap(pixmap);
|
|
|
|
|
|
|
|
|
|
QString qsLineEditStyle("QLineEdit { min-height: 20px; min-width: 120px; }");
|
|
|
|
|
ui->userToken->setStyleSheet(qsLineEditStyle);
|
|
|
|
|
ui->serverIp->setStyleSheet(qsLineEditStyle);
|
|
|
|
|
|
|
|
|
|
QRegularExpression rx("^((2[0-4]\\d|25[0-5]|[01]?\\d\\d?)\\.){3}(2[0-4]\\d|25[0-5]|[01]?\\d\\d?)$");
|
|
|
|
|
QRegularExpressionValidator* ipValidator = new QRegularExpressionValidator(rx, this);
|
|
|
|
|
ui->serverIp->setValidator(ipValidator);
|
|
|
|
|
setIp("127.0.0.1");
|
2024-09-10 14:38:23 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MainWindow::~MainWindow()
|
|
|
|
|
{
|
|
|
|
|
delete ui;
|
2024-09-10 16:55:41 +08:00
|
|
|
|
if (m_pMainDialog)
|
|
|
|
|
{
|
|
|
|
|
delete m_pMainDialog;
|
|
|
|
|
m_pMainDialog = nullptr;
|
|
|
|
|
}
|
2024-09-10 14:38:23 +08:00
|
|
|
|
}
|
|
|
|
|
|
2024-09-10 16:12:38 +08:00
|
|
|
|
void MainWindow::setIp(const QString &ip)
|
|
|
|
|
{
|
|
|
|
|
ui->serverIp->setText(ip);
|
|
|
|
|
}
|
2024-09-10 16:55:41 +08:00
|
|
|
|
|
|
|
|
|
void MainWindow::on_pb_Logon_clicked()
|
|
|
|
|
{
|
|
|
|
|
m_pMainDialog = new MainDialog();
|
|
|
|
|
m_pMainDialog->show();
|
|
|
|
|
this->close();
|
|
|
|
|
}
|
|
|
|
|
|