diff --git a/PayloadAPP.pro b/PayloadAPP.pro index fa49862..0f06328 100644 --- a/PayloadAPP.pro +++ b/PayloadAPP.pro @@ -1,6 +1,7 @@ QT += core gui webenginewidgets QT += network QT += quickwidgets qml +QT += sql greaterThan(QT_MAJOR_VERSION, 4): QT += widgets CONFIG += c++17 @@ -59,6 +60,7 @@ INCLUDEPATH += $$PWD/3rdparty/ffmpeg/include \ $$PWD/Src/VideoGL/ \ $$PWD/Src/Video/ \ $$PWD/3rdparty/QNotify/include \ + $$PWD/Src/UserManage \ LIBS += -L$$PWD/3rdparty/ffmpeg/lib \ -lavcodec -lavdevice -lavfilter -lavformat -lavutil -lpostproc \ @@ -87,3 +89,4 @@ include($$PWD/Src/RescueLoad/RescueLoad.pri) include($$PWD/Src/GDDC/GDDC.pri) include($$PWD/Src/Video/Video.pri) include($$PWD/Src/VideoGL/VideoGL.pri) +include($$PWD/Src/UserManage/UserManage.pri) diff --git a/SDFPDlg.cpp b/SDFPDlg.cpp index c6a0a29..b4e993d 100644 --- a/SDFPDlg.cpp +++ b/SDFPDlg.cpp @@ -14,9 +14,52 @@ SDFPDlg::SDFPDlg(QWidget *parent) setWindowFlags(Qt::CustomizeWindowHint|Qt::FramelessWindowHint); hide(); ui->label_version->setText(g_SoftwareVersion); + initButton(); } SDFPDlg::~SDFPDlg() { delete ui; } + +void SDFPDlg::initButton() +{ + ui->loginButton->setStyleSheet("QPushButton {" + "border: none;" // 没有边框 + "color: #CFCFCF;" // 默认字体颜色为白色 + "font-size: 18px;" // 字体大小为 20 + "font-weight: bold;" + "background-color: transparent;" // 背景透明 + "font-family: 'STHeiti';" + "}" + + // 设置按钮悬停时的样式 + "QPushButton:hover {" + "color: #5289C1;" // 悬停时字体颜色变为橙色 + "}" + + // 设置按钮按下时的字体颜色 + "QPushButton:pressed {" + "color: #4A7DB0;" // 按下时字体颜色变为绿色 + "}" + + // 设置按钮选中时的样式 + "QPushButton:checked {" + "color: #5289C1;" // 选中时字体颜色变为绿色 + "}" + ); +} + +void SDFPDlg::resizeEvent(QResizeEvent *event) +{ + QWidget::resizeEvent(event); + // double weidgeteWidth = (double)(this->width()); + // // 设置按钮位置和大小 + // _loginBtn->move(weidgeteWidth - _loginBtn->width() - 20,20); +} + +void SDFPDlg::on_loginButton_clicked() +{ + emit clickLoginBtn(); +} + diff --git a/SDFPDlg.h b/SDFPDlg.h index c4b4cef..a3650ee 100644 --- a/SDFPDlg.h +++ b/SDFPDlg.h @@ -3,6 +3,7 @@ #include #include "global.h" +#include namespace Ui { class SDFPDlg; @@ -18,6 +19,16 @@ public: private: Ui::SDFPDlg *ui; + void initButton(); + QPushButton* _loginBtn; +protected: + void resizeEvent(QResizeEvent *event) override; +private slots: + void on_loginButton_clicked(); + +signals: + void clickLoginBtn(); + }; #endif // SDFPDLG_H diff --git a/SDFPDlg.ui b/SDFPDlg.ui index d39cc04..a17c238 100644 --- a/SDFPDlg.ui +++ b/SDFPDlg.ui @@ -17,38 +17,8 @@ - - - - - 0 - 0 - - - - image: url(:/res/981csNew.png); - - - - - - - - - - 0 - 0 - - - - 版本号:V0.00.00 - - - - - - - + + Qt::Orientation::Horizontal @@ -63,8 +33,8 @@ - - + + Qt::Orientation::Horizontal @@ -79,6 +49,111 @@ + + + + + 0 + 0 + + + + image: url(:/res/981csNew.png); + + + + + + + + 0 + 20 + + + + + 16777215 + 40 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + Qt::Orientation::Horizontal + + + + 40 + 20 + + + + + + + + Qt::Orientation::Horizontal + + + QSizePolicy::Policy::Fixed + + + + 30 + 20 + + + + + + + + + 40 + 16777215 + + + + 登录 + + + + + + + + + + + + + 0 + 0 + + + + 版本号:V0.00.00 + + + + + diff --git a/Src/GDDC/gddcSet.cpp b/Src/GDDC/gddcSet.cpp index 484307b..97f4d3c 100644 --- a/Src/GDDC/gddcSet.cpp +++ b/Src/GDDC/gddcSet.cpp @@ -14,6 +14,10 @@ GDDCSet::GDDCSet(QWidget *parent) : QWidget(parent), ui(new Ui::GDDCSet) { ui->label_3->setVisible(false); ui->comboBox_streamType->setVisible(false); + QString urlFile = QCoreApplication::applicationDirPath() + "/config.ini"; + std::unique_ptr configIni = std::make_unique(urlFile, QSettings::IniFormat); + QString podIp = configIni->value("Pod/IP").toString(); + initPullURL(podIp); } GDDCSet::~GDDCSet() { diff --git a/Src/UserManage/UserManage.pri b/Src/UserManage/UserManage.pri new file mode 100644 index 0000000..47c06b5 --- /dev/null +++ b/Src/UserManage/UserManage.pri @@ -0,0 +1,13 @@ +HEADERS += \ + $$PWD/mydatabase.h \ + $$PWD/userlogin.h + +SOURCES += \ + $$PWD/mydatabase.cpp \ + $$PWD/userlogin.cpp + +RESOURCES += \ + $$PWD/res.qrc + +FORMS += \ + $$PWD/userlogin.ui diff --git a/Src/UserManage/img/eyesOpen.png b/Src/UserManage/img/eyesOpen.png new file mode 100644 index 0000000..8e50834 Binary files /dev/null and b/Src/UserManage/img/eyesOpen.png differ diff --git a/Src/UserManage/img/eyesOpen1.png b/Src/UserManage/img/eyesOpen1.png new file mode 100644 index 0000000..01c4183 Binary files /dev/null and b/Src/UserManage/img/eyesOpen1.png differ diff --git a/Src/UserManage/mydatabase.cpp b/Src/UserManage/mydatabase.cpp new file mode 100644 index 0000000..56710e4 --- /dev/null +++ b/Src/UserManage/mydatabase.cpp @@ -0,0 +1,243 @@ +#include "mydatabase.h" +#include + +MyDatabase::MyDatabase() +{ + if (QSqlDatabase::contains("qt_sql_default_connection")) + { + database = QSqlDatabase::database("qt_sql_default_connection"); + } + else + { + // 建立和SQlite数据库的连接 + database = QSqlDatabase::addDatabase("QSQLITE"); + QString dbPath = QCoreApplication::applicationDirPath() + "//UserDataBase.db"; + // 设置数据库文件的名字 + database.setDatabaseName(dbPath); + database.setUserName("root"); + database.setPassword("123456"); + } + + openDb(); + if(!isTableExist("user")) + { + createTable(); + } + + QList list; + userData u1 = {"wanghaoyu1","123456","yingji"}; + userData u2 = {"wanghaoyu2","123456","ceshi"}; + userData u3 = {"wanghaoyu3","123456","haha"}; + list += {u1,u2,u3}; + + multipleInsertData(list); + userData u4 = {"wanghaoyu4","123456","yingji1"}; + singleInsertData(u4); + // deleteData("wanghaoyu4"); + // queryDataByUsername("wanghaoyu3"); + // updateDataByUsername("wanghaoyu3","234567","ceshi"); +} + +bool MyDatabase::openDb() +{ + if (!database.open()) + { + qDebug() << "Error: Failed to connect database." << database.lastError(); + return false; + } + else + { + qDebug() << "数据库打开成功." ; + } + + return true; +} + +void MyDatabase::createTable() +{ + // 用于执行sql语句的对象 + QSqlQuery sqlQuery; + // 构建创建数据库的sql语句字符串 + QString createSql = QString("CREATE TABLE IF NOT EXISTS user (\ + id INTEGER PRIMARY KEY AUTOINCREMENT,\ + username VARCHAR(50) UNIQUE NOT NULL,\ + password VARCHAR(50) NOT NULL,\ + scene VARCHAR(100) NOT NULL,\ + is_del INTEGER DEFAULT 0,\ + created_at TIMESTAMP DEFAULT (DATETIME('now', 'localtime')),\ + updated_at TIMESTAMP DEFAULT (DATETIME('now', 'localtime')))"); + sqlQuery.prepare(createSql); + + // 创建触发器 + QString triggerSql = R"( + CREATE TRIGGER IF NOT EXISTS update_user_updated_at + AFTER UPDATE ON user + FOR EACH ROW + BEGIN + UPDATE user SET updated_at = CURRENT_TIMESTAMP WHERE id = OLD.id; + END; + )"; + + // 执行sql语句 + if(!sqlQuery.exec()) + { + qDebug() << "Error: Fail to create table. " << sqlQuery.lastError(); + } + else + { + qDebug() << "Table created!"; + } +} + +bool MyDatabase::isTableExist(const QString &tableName) +{ + if(!database.isOpen()) + { + return false; + } + + return database.tables().contains(tableName); +} + +bool MyDatabase::singleInsertData(userData &singleData) +{ + database.transaction();//开启事务 + QSqlQuery sqlQuery; + sqlQuery.prepare("INSERT INTO user (username, password, scene) VALUES(?, ?, ?)"); + sqlQuery.addBindValue(singleData.username); + sqlQuery.addBindValue(singleData.password); + sqlQuery.addBindValue(singleData.scene); + if(!sqlQuery.exec()) + { + if(sqlQuery.lastError().text().contains("UNIQUE constraint failed")) + { + qDebug() << "用户名已存在:" << singleData.username; + } + qDebug() << "Error: Fail to insert data. " << sqlQuery.lastError(); + database.rollback();//回滚 + return false; + } + else + { + database.commit();//提交 + return true; + } +} + +bool MyDatabase::multipleInsertData(QList &multipleData) +{ + database.transaction();//开启事务 + QSqlQuery sqlQuery; + sqlQuery.prepare("INSERT INTO user (username, password, scene) VALUES(?, ?, ?)"); + + QVariantList usernameList,passwordList,sceneList; + for(userData value : multipleData) + { + usernameList << value.username; + passwordList << value.password; + sceneList << value.scene; + } + + sqlQuery.addBindValue(usernameList); + sqlQuery.addBindValue(passwordList); + sqlQuery.addBindValue(sceneList); + + if(!sqlQuery.execBatch()) + { + qDebug() << "Error: Fail to insert data. " << sqlQuery.lastError(); + database.rollback();//回滚 + return false; + } + else + { + database.commit();//提交 + return true; + } +} + +bool MyDatabase::deleteData(const QString &username) +{ + database.transaction(); + QSqlQuery sqlQuery; + sqlQuery.prepare("UPDATE user SET is_del=?,updated_at=(DATETIME('now', 'localtime')) WHERE username=?"); + sqlQuery.addBindValue(1); + sqlQuery.addBindValue(username); + if(!sqlQuery.exec()) + { + qDebug() << "Error: Fail to delete data. "<< sqlQuery.lastError(); + database.rollback(); + return false; + } + else + { + qDebug() << "delete data success!"; + database.commit(); + return true; + } +} + +bool MyDatabase::updateDataByUsername(const QString &username, const QString &password, const QString &scene) +{ + if(!queryDataByUsername(username))//根据用户名没有查询到数据-不进行更新操作 + { + return false; + } + database.transaction(); + QSqlQuery sqlQuery; + sqlQuery.prepare("UPDATE user SET password=? ,scene=?,updated_at=(DATETIME('now', 'localtime')) WHERE username=?"); + sqlQuery.addBindValue(password); + sqlQuery.addBindValue(scene); + sqlQuery.addBindValue(username); + if(!sqlQuery.exec()) + { + qDebug() << "Error: Fail to update data. "<< sqlQuery.lastError(); + database.rollback(); + return false; + } + else + { + qDebug() << "update data success!"; + database.commit(); + return true; + } +} + +bool MyDatabase::queryDataByUsername(const QString &username) +{ + QSqlQuery sqlQuery; + sqlQuery.prepare("SELECT * FROM user WHERE is_del = 0 AND username=?"); + sqlQuery.addBindValue(username); + if(!sqlQuery.exec()) + { + qDebug() << "Error: Fail to query table. " << sqlQuery.lastError(); + return false; + } + else + { + qDebug() << "query data success!"; + if(!sqlQuery.next()) + { + qDebug() << "No data found!";//没找到数据 + return false; + } + + sqlQuery.previous(); + + while(sqlQuery.next()) + { + int id = sqlQuery.value("id").toInt(); + _queryUserData.username = sqlQuery.value("username").toString(); + _queryUserData.password = sqlQuery.value("password").toString(); + _queryUserData.scene = sqlQuery.value("scene").toString(); + + qDebug()< +#include +#include +#include +#include + +typedef struct +{ + QString username; + QString password; + QString scene; +}userData; + +class MyDatabase +{ +public: + MyDatabase(); + + // 打开数据库 + bool openDb(); + + // 创建数据表 + void createTable(); + + // 判断数据表是否存在 + bool isTableExist(const QString& tableName); + + // 插入数据 + bool singleInsertData(userData &singleData); // 插入单条数据 + bool multipleInsertData(QList &multipleData); // 插入多条数据 + + //删除数据 + bool deleteData(const QString &username); + + //修改数据-密码 场景 + bool updateDataByUsername(const QString &username, const QString &password, const QString &scene); + + //查询数据 + bool queryDataByUsername(const QString &username); + + //获取查询到的数据 + userData getQueryUserData(); +private: + QSqlDatabase database;// 用于建立和数据库的连接 + userData _queryUserData; +}; + +#endif // MYDATABASE_H diff --git a/Src/UserManage/res.qrc b/Src/UserManage/res.qrc new file mode 100644 index 0000000..01441c3 --- /dev/null +++ b/Src/UserManage/res.qrc @@ -0,0 +1,6 @@ + + + img/eyesOpen.png + img/eyesOpen1.png + + diff --git a/Src/UserManage/userlogin.cpp b/Src/UserManage/userlogin.cpp new file mode 100644 index 0000000..5846864 --- /dev/null +++ b/Src/UserManage/userlogin.cpp @@ -0,0 +1,230 @@ +#include "userlogin.h" +#include "ui_userlogin.h" +#include +#include +#include + +UserLogin::UserLogin(QWidget *parent) + : QWidget(parent) + , ui(new Ui::UserLogin) +{ + ui->setupUi(this); + initLineEdit(); + initControls(); +} + +UserLogin::~UserLogin() +{ + delete ui; +} + +void UserLogin::initLineEdit() +{ + // 定义正则表达式:允许大写字母、小写字母、数字和特殊符号 + QRegularExpression regExp("[A-Za-z0-9!@#$%^&*()_+\\-=\\[\\]{};':\"\\\\|,.<>\\/?]+"); + + // 创建验证器 + QRegularExpressionValidator *validator = new QRegularExpressionValidator(regExp, this); + + // 设置验证器 + ui->userlineEdit->setValidator(validator); + ui->passwordlineEdit->setValidator(validator); +} + +void UserLogin::initControls() +{ + QPixmap pixmap(":/res/SDFP3.png"); + ui->loginlabel->setPixmap(pixmap); + ui->loginlabel->setScaledContents(true); + + ui->widget_2->setStyleSheet("background-color: #1E1E1D;" + "border-top-left-radius: 20px; " + "border-top-right-radius: 20px;"); + + ui->widget_3->setObjectName("widget_3"); // 给 widget_3 设置对象名称 + ui->widget_3->setStyleSheet("QWidget#widget_3 {" + "background-color: #363636;" + "border-bottom-left-radius: 20px; " + "border-bottom-right-radius: 20px;" + "}"); + + ui->userlineEdit->setStyleSheet("border-radius: 5px;"); + ui->passwordlineEdit->setStyleSheet("border-radius: 5px;"); + ui->loginButton->setStyleSheet("QPushButton{" + "font-family: STHupo;" + "border-radius: 15px;" + "color: white;" + "font-weight: bold;" + "border: none;" + "background-color: #5289C1;" + "font-size: 20px;" + "}" + // 设置按钮悬停时的样式 + "QPushButton:hover {" + "background-color: #4078A9;" // 悬停时的背景颜色 + "}" + // 设置按钮按下或选中时的渐变背景 + "QPushButton::pressed, QPushButton::checked {" + "color: #FFFFFF;" // 字体颜色为白色 + "background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:0, y2:1, " + "stop:0 #273c75, stop:1 #487eb0);" // 渐变背景 + "}"); + + ui->exitButton->setStyleSheet("QPushButton{" + "font-family: STHupo;" + "border-radius: 15px;" + "color: white;" + "font-weight: bold;" + "border: none;" + "background-color: #A52A2A;" + "font-size: 20px;" + "}" + // 设置按钮悬停时的样式 + "QPushButton:hover {" + "background-color: #8B1C1C;" // 悬停时的背景颜色 + "}" + // 设置按钮按下或选中时的渐变背景 + "QPushButton::pressed, QPushButton::checked {" + "color: #FFFFFF;" // 字体颜色为白色 + "background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:0, y2:1, " + "stop:0 #5C1919, stop:1 #9E2A2A);" // 渐变背景 + "}"); + + + _passwordCheckBox = new QCheckBox(ui->passwordlineEdit); + //设置样式表(图片为眼睛样式) + _passwordCheckBox->setStyleSheet("QCheckBox::indicator {" + "width: 20px;" + "height: 20px;" + "image: url(:/res/eyec1.png);" // 未选中时的图片 + "}" + "QCheckBox::indicator:checked {" + "image: url(:/res/eye3.png);" // 选中时的图片 + "}"); + + + ui->label->setStyleSheet("QLabel {" + "font-family: 'STHupo';" // 使用艺术字体 + "font-size: 40px;" // 设置字体大小 + "font-weight: bold;" // 设置加粗 + "color: #5289C1;" // 设置字体颜色 + "text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);" // 添加阴影效果 + "}"); + ui->label->setAlignment(Qt::AlignCenter); + + ui->pushButton->setStyleSheet("QPushButton {" + "border: none;" // 没有边框 + "color: white;" // 默认字体颜色为白色 + "font-size: 18px;" // 字体大小为 20 + "font-weight: bold;" + "background-color: transparent;" // 背景透明 + "font-family: 'STHeiti';" + "}" + + // 设置按钮悬停时的样式 + "QPushButton:hover {" + "color: #5289C1;" // 悬停时字体颜色变为橙色 + "}" + + // 设置按钮按下时的字体颜色 + "QPushButton:pressed {" + "color: #4A7DB0;" // 按下时字体颜色变为绿色 + "}" + + // 设置按钮选中时的样式 + "QPushButton:checked {" + "color: #5289C1;" // 选中时字体颜色变为绿色 + "}"); + + connect(_passwordCheckBox,&QCheckBox::checkStateChanged,this,[this](int state){ + if(state == Qt::Checked) + { + ui->passwordlineEdit->setEchoMode(QLineEdit::Normal); + } + else if(state == Qt::Unchecked) + { + ui->passwordlineEdit->setEchoMode(QLineEdit::Password); + } + }); + +} + +bool UserLogin::checkEditFormat(const QString &edit, const QString &origins) +{ + if(edit.isEmpty()) + { + QMessageBox::information(NULL, "提示", "输入"+origins+"不能为空!"); + return false; + } + else + { + // 定义正则表达式:至少 8 个字符,且只能是大写字母、小写字母、数字和特殊符号 + QRegularExpression regExp("[A-Za-z0-9!@#$%^&*()_+\\-=\\[\\]{};':\"\\\\|,.<>\\/?]{6,}"); + + // 检查输入内容 + if (!regExp.match(edit).hasMatch()) + { + QMessageBox::information(NULL, "提示", origins +"至少输入 6 个字符,且只能包含大写字母、小写字母、数字和特殊符号!"); + return false; + } + } + return true; +} + +void UserLogin::resizeEvent(QResizeEvent *event) +{ + QWidget::resizeEvent(event); + _passwordCheckBox->setGeometry(ui->passwordlineEdit->width()-30,(ui->passwordlineEdit->height()/2)-10,20,20); +} + +void UserLogin::on_loginButton_clicked() +{ + if(!checkEditFormat(ui->userlineEdit->text(),"用户名")) + return; + if(!checkEditFormat(ui->passwordlineEdit->text(),"密码")) + return; + + //查询到数据 + if(dataBase.queryDataByUsername(ui->userlineEdit->text())) + { + _queryUserData = dataBase.getQueryUserData(); + if(_queryUserData.password == ui->passwordlineEdit->text())//密码匹配 + { + //判断场景 + if(_queryUserData.scene == "yingji") + { + emit sendSenceData(use_sence::Emergency); + QMessageBox::information(NULL, "提示", "进入应急场景!"); + } + else if(_queryUserData.scene == "ceshi") + { + emit sendSenceData(use_sence::Sea_Rescue); + QMessageBox::information(NULL, "提示", "进入测试场景!"); + } + } + else + { + QMessageBox::information(NULL, "提示", "密码输入错误!"); + return; + } + } + else + { + //用户名不存在 + QMessageBox::information(NULL, "提示", "用户名不存在!"); + return; + } +} + + +void UserLogin::on_pushButton_clicked() +{ + emit loginDlgClick(click_type::HomePageClick); +} + + +void UserLogin::on_exitButton_clicked() +{ + emit loginDlgClick(click_type::ExitLogin); +} + diff --git a/Src/UserManage/userlogin.h b/Src/UserManage/userlogin.h new file mode 100644 index 0000000..945abfa --- /dev/null +++ b/Src/UserManage/userlogin.h @@ -0,0 +1,55 @@ +#ifndef USERLOGIN_H +#define USERLOGIN_H + +#include +#include +#include "mydatabase.h" + +namespace Ui { +class UserLogin; +} + +class UserLogin : public QWidget +{ + Q_OBJECT + +public: + explicit UserLogin(QWidget *parent = nullptr); + ~UserLogin(); + + enum use_sence : unsigned char + { + Emergency = 1, //应急 1 + Sea_Rescue, //海上救捞 2 + }; + + enum click_type : unsigned char + { + HomePageClick = 0, //主页点击 + ExitLogin, //退出登录 + }; + +private slots: + void on_loginButton_clicked(); + + void on_pushButton_clicked(); + + void on_exitButton_clicked(); + +private: + Ui::UserLogin *ui; + MyDatabase dataBase; + void initLineEdit(); + void initControls(); + bool checkEditFormat(const QString &edit, const QString &origins); + userData _queryUserData; + QCheckBox *_passwordCheckBox; +signals: + void sendSenceData(use_sence sence); + void loginDlgClick(int clickType); + +protected: + void resizeEvent(QResizeEvent *event) override; +}; + +#endif // USERLOGIN_H diff --git a/Src/UserManage/userlogin.ui b/Src/UserManage/userlogin.ui new file mode 100644 index 0000000..8ea3dfa --- /dev/null +++ b/Src/UserManage/userlogin.ui @@ -0,0 +1,573 @@ + + + UserLogin + + + + 0 + 0 + 1288 + 826 + + + + Form + + + + 0 + + + + + + + + 0 + + + + + + + Qt::Orientation::Horizontal + + + + 40 + 20 + + + + + + + + + 16777215 + 40 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 40 + 16777215 + + + + 主页 + + + + + + + Qt::Orientation::Horizontal + + + QSizePolicy::Policy::Fixed + + + + 20 + 20 + + + + + + + + Qt::Orientation::Horizontal + + + + 40 + 20 + + + + + + + + + + + Qt::Orientation::Vertical + + + QSizePolicy::Policy::Fixed + + + + 20 + 130 + + + + + + + + + 0 + + + + + + 0 + 200 + + + + + 16777215 + 220 + + + + + 0 + + + + + Qt::Orientation::Horizontal + + + + 40 + 20 + + + + + + + + + 100 + 100 + + + + + 200 + 200 + + + + + + + Qt::AlignmentFlag::AlignCenter + + + + + + + Qt::Orientation::Horizontal + + + + 40 + 20 + + + + + + + + + 0 + 39 + + + + + 16777215 + 40 + + + + Qt::LayoutDirection::LeftToRight + + + HTFP-PayLoad + + + Qt::AlignmentFlag::AlignHCenter|Qt::AlignmentFlag::AlignTop + + + + + + + + + + + + + Qt::Orientation::Vertical + + + QSizePolicy::Policy::Fixed + + + + 20 + 28 + + + + + + + + 0 + + + + + Qt::Orientation::Horizontal + + + QSizePolicy::Policy::Fixed + + + + 20 + 20 + + + + + + + + + 400 + 40 + + + + + 480 + 50 + + + + 用户名 + + + + + + + Qt::Orientation::Horizontal + + + QSizePolicy::Policy::Fixed + + + + 20 + 20 + + + + + + + + + + Qt::Orientation::Vertical + + + QSizePolicy::Policy::Fixed + + + + 20 + 30 + + + + + + + + 0 + + + + + Qt::Orientation::Horizontal + + + QSizePolicy::Policy::Fixed + + + + 20 + 20 + + + + + + + + + 400 + 39 + + + + + 480 + 40 + + + + QLineEdit::EchoMode::Password + + + 密码 + + + + + + + Qt::Orientation::Horizontal + + + QSizePolicy::Policy::Fixed + + + + 20 + 20 + + + + + + + + + + Qt::Orientation::Vertical + + + QSizePolicy::Policy::Fixed + + + + 20 + 30 + + + + + + + + 0 + + + + + Qt::Orientation::Horizontal + + + QSizePolicy::Policy::Fixed + + + + 20 + 20 + + + + + + + + + 200 + 40 + + + + + 480 + 50 + + + + 登录 + + + + + + + Qt::Orientation::Horizontal + + + QSizePolicy::Policy::Fixed + + + + 20 + 20 + + + + + + + + + + Qt::Orientation::Vertical + + + QSizePolicy::Policy::Fixed + + + + 20 + 30 + + + + + + + + 0 + + + + + Qt::Orientation::Horizontal + + + QSizePolicy::Policy::Fixed + + + + 20 + 20 + + + + + + + + + 200 + 40 + + + + + 480 + 50 + + + + 退出登录 + + + + + + + Qt::Orientation::Horizontal + + + QSizePolicy::Policy::Fixed + + + + 20 + 20 + + + + + + + + + + Qt::Orientation::Vertical + + + QSizePolicy::Policy::MinimumExpanding + + + + 20 + 40 + + + + + + + + + + + + + + Qt::Orientation::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + diff --git a/mainwindow.cpp b/mainwindow.cpp index 39ca936..02562e0 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -19,6 +19,7 @@ #include "global.h" #include "ui_mainwindow.h" + MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); @@ -46,6 +47,7 @@ MainWindow::MainWindow(QWidget *parent) initUAVIDMap(); initNotifyManager(); + initUserLoginDlg(); } MainWindow::~MainWindow() { @@ -92,36 +94,26 @@ void MainWindow::initWindow() { // 使用类中的get方法获取配置文件中的IP m_allSetMap = m_HomePagedlg->settingWidget->getAllParam(); - m_GDDCdlg->setGlobalSetMap(m_allSetMap); - qDebug() << "=============设备配置================"; + //m_GDDCdlg->setGlobalSetMap(m_allSetMap); + /*qDebug() << "=============设备配置================"; qDebug() << "光电吊舱------"; - qDebug() << "远端ip" << m_allSetMap["光电吊舱"].net.remoteIp; + qDebug() << "远端ip" << m_allSetMap["Pod"].net.remoteIp; qDebug() << "L链----------"; - qDebug() << "ULR:" << m_allSetMap["L链"].url; + qDebug() << "ULR:" << m_allSetMap["L-Link"].url; qDebug() << "宽带自组网-----"; - qDebug() << "URL:" << m_allSetMap["宽带自组网"].url; + qDebug() << "URL:" << m_allSetMap["HocNetwork"].url; qDebug() << "机载卫通------"; - qDebug() << "URL:" << m_allSetMap["机载卫通"].url; + qDebug() << "URL:" << m_allSetMap["SatelliteComm"].url; qDebug() << "三维建模------"; - qDebug() << "远端ip:" << m_allSetMap["三维建模"].net.remoteIp; - qDebug() << "远端端口:" << m_allSetMap["三维建模"].net.remotePort; - qDebug() << "本地ip:" << m_allSetMap["三维建模"].net.localIp; - qDebug() << "本地端口:" << m_allSetMap["三维建模"].net.localPort; - - // mWeb = new CWebEngineView(); - // mWeb->setPage(new CustomWebEnginePage()); - // mWeb->load(QUrl("http://192.168.150.1")); + qDebug() << "远端ip:" << m_allSetMap["ModelCamera"].net.remoteIp; + qDebug() << "远端端口:" << m_allSetMap["ModelCamera"].net.remotePort; + qDebug() << "本地ip:" << m_allSetMap["ModelCamera"].net.localIp; + qDebug() << "本地端口:" << m_allSetMap["ModelCamera"].net.localPort;*/ + lLinkWeb = new CWebEngineView(); lLinkWeb->setPage(new CustomWebEnginePage()); - lLinkWeb->load(QUrl(m_allSetMap["L链"].url)); + lLinkWeb->load(QUrl(m_allSetMap["L-Link"].url)); connect(lLinkWeb->page(), &QWebEnginePage::loadFinished, this, [=]() { - // QString jsScript = R"( - // var usernameField = - // document.querySelector('input[name="username"]'); if - // (usernameField) { - // usernameField.value = 'admin'; // 填充用户名 - // } - // )"; QString jsScript = R"( var button = document.getElementById('clickButt'); if (button) { @@ -139,21 +131,20 @@ void MainWindow::initWindow() { adHocNetworkWeb = new CWebEngineView(); adHocNetworkWeb->setPage(new CustomWebEnginePage()); - adHocNetworkWeb->load(QUrl(m_allSetMap["宽带自组网"].url)); + adHocNetworkWeb->load(QUrl(m_allSetMap["HocNetwork"].url)); satelliteCommWeb = new CWebEngineView(); satelliteCommWeb->setPage(new CustomWebEnginePage()); - satelliteCommWeb->load(QUrl(m_allSetMap["机载卫通"].url)); + satelliteCommWeb->load(QUrl(m_allSetMap["SatelliteComm"].url)); m_ModelCameraDlg = new ModelCameraDlg(this); - emit m_ModelCameraDlg->sendNetParam_signal(m_allSetMap["三维建模"].net); + emit m_ModelCameraDlg->sendNetParam_signal(m_allSetMap["ModelCamera"].net); // 接收主页面设置窗口的url数据传递并设置 connect( m_HomePagedlg->settingWidget, &HomePageSetingWidget::sendOneSet, this, [&](unsigned char urlIndex, settingStruct settings) { switch (urlIndex) { case HomePageSetingWidget::GDDC: - // dosomething m_GDDCdlg->m_DlgGDDCSet->initPullURL(settings.net.remoteIp); break; case HomePageSetingWidget::L_Link: @@ -177,7 +168,6 @@ void MainWindow::initWindow() { ui->stackedWidget->addWidget(m_SDFPDlg); ui->stackedWidget->addWidget(m_HomePagedlg); ui->stackedWidget->addWidget(m_GDDCdlg); - // ui->stackedWidget->addWidget(mWeb); ui->stackedWidget->addWidget(lLinkWeb); ui->stackedWidget->addWidget(adHocNetworkWeb); ui->stackedWidget->addWidget(satelliteCommWeb); @@ -185,6 +175,7 @@ void MainWindow::initWindow() { ui->stackedWidget->addWidget(m_ModelCameraDlg); // 初始栈窗口显示主页 ui->stackedWidget->setCurrentWidget(m_SDFPDlg); + ui->senceContrlWidget->hide(); } void MainWindow::initButton() { @@ -200,6 +191,8 @@ void MainWindow::initButton() { ui->toolButton_7->setIcon(QIcon(":/res/research.png")); ui->toolButton_8->setIcon(QIcon(":/res/3D.png")); ui->toolButton_9->setIcon(QIcon(":/res/SDFP3.png")); + ui->toolButton_10->setIcon(QIcon(":/res/SDFP3.png")); + ui->toolButton_21->setIcon(QIcon(":/res/GDDC.png")); ui->toolButton->setIconSize(QSize(sizeX, sizeY)); ui->toolButton_2->setIconSize(QSize(sizeX, sizeY)); ui->toolButton_3->setIconSize(QSize(sizeX, sizeY)); @@ -209,6 +202,8 @@ void MainWindow::initButton() { ui->toolButton_7->setIconSize(QSize(sizeX, sizeY)); ui->toolButton_8->setIconSize(QSize(sizeX, sizeY)); ui->toolButton_9->setIconSize(QSize(sizeX * 1.2, sizeY * 1.2)); + ui->toolButton_10->setIconSize(QSize(sizeX * 1.2, sizeY * 1.2)); + ui->toolButton_21->setIconSize(QSize(sizeX, sizeY)); ui->toolButton->setText("主页"); ui->toolButton_2->setText("光电吊舱"); ui->toolButton_3->setText("L链"); @@ -218,6 +213,8 @@ void MainWindow::initButton() { ui->toolButton_7->setText("搜救载荷"); ui->toolButton_8->setText("三维建模"); ui->toolButton_9->setText("时代飞鹏"); + ui->toolButton_10->setText("时代飞鹏"); + ui->toolButton_21->setText("光电吊舱"); ui->toolButton->setFixedWidth(FixedWidth); ui->toolButton_2->setFixedWidth(FixedWidth); ui->toolButton_3->setFixedWidth(FixedWidth); @@ -227,6 +224,8 @@ void MainWindow::initButton() { ui->toolButton_7->setFixedWidth(FixedWidth); ui->toolButton_8->setFixedWidth(FixedWidth); ui->toolButton_9->setFixedWidth(FixedWidth); + ui->toolButton_10->setFixedWidth(FixedWidth); + ui->toolButton_21->setFixedWidth(FixedWidth); ui->toolButton->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); ui->toolButton_2->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); ui->toolButton_3->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); @@ -236,6 +235,8 @@ void MainWindow::initButton() { ui->toolButton_7->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); ui->toolButton_8->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); ui->toolButton_9->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); + ui->toolButton_10->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); + ui->toolButton_21->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); ui->toolButton->setStyleSheet(g_ToolBtnStyle); ui->toolButton_2->setStyleSheet(g_ToolBtnStyle); ui->toolButton_3->setStyleSheet(g_ToolBtnStyle); @@ -245,6 +246,8 @@ void MainWindow::initButton() { ui->toolButton_7->setStyleSheet(g_ToolBtnStyle); ui->toolButton_8->setStyleSheet(g_ToolBtnStyle); ui->toolButton_9->setStyleSheet(g_ToolBtnStyle); + ui->toolButton_10->setStyleSheet(g_ToolBtnStyle); + ui->toolButton_21->setStyleSheet(g_ToolBtnStyle); // ui->pushButton->setStyleSheet(g_PushBtnStyle); } @@ -359,6 +362,28 @@ void MainWindow::toolButton_9_clicked() { ui->stackedWidget->setCurrentWidget(m_SDFPDlg); } +void MainWindow::getUserSence(UserLogin::use_sence sence) +{ + _currentScene = sence; + switch(sence) + { + case UserLogin::Emergency: + { + QMessageBox::information(NULL, "提示", "进入switch emergency!"); + emergencySceneShow(); + break; + } + case UserLogin::Sea_Rescue: + { + QMessageBox::information(NULL, "提示", "进入switch Sea_Rescue!"); + seaRescueSceneShow(); + break; + } + default: + break; + } +} + // 更新主界面按钮颜色 void MainWindow::changeBtnColor(int num) { initButton(); @@ -390,6 +415,12 @@ void MainWindow::changeBtnColor(int num) { case 9: ui->toolButton_9->setStyleSheet(g_ToolBtnSelStyle); break; + case 10: + ui->toolButton_10->setStyleSheet(g_ToolBtnSelStyle); + break; + case 11: + ui->toolButton_21->setStyleSheet(g_ToolBtnSelStyle); + break; } } @@ -424,6 +455,22 @@ void MainWindow::initNotifyManager() { g_notifyManager->setNotifyWndSize(300, 60); } +void MainWindow::initUserLoginDlg() +{ + m_userLoginDlg = new UserLogin(this); + // m_userLoginDlg->setWindowFlags(Qt::Dialog); + // m_userLoginDlg->show(); + + ui->stackedWidget->addWidget(m_userLoginDlg); + + _currentScene = 0; + + //初始化槽函数 + connect(m_userLoginDlg,&UserLogin::sendSenceData,this,&MainWindow::getUserSence); + connect(m_userLoginDlg,&UserLogin::loginDlgClick,this,&MainWindow::getloginDlgBtnClicked); + connect(m_SDFPDlg,&SDFPDlg::clickLoginBtn,this,&MainWindow::receptLoginBtnClicked); +} + bool MainWindow::nativeEvent(const QByteArray &eventType, void *message, qintptr *result) { #ifdef Q_OS_WIN @@ -439,3 +486,78 @@ bool MainWindow::nativeEvent(const QByteArray &eventType, void *message, #endif return QMainWindow::nativeEvent(eventType, message, result); } + +// 海上 主页面 +void MainWindow::on_toolButton_10_clicked() +{ + changeBtnColor(10); + ui->stackedWidget->setCurrentWidget(m_SDFPDlg); +} + +// 海上 光电吊舱 +void MainWindow::on_toolButton_21_clicked() +{ + changeBtnColor(11); + ui->stackedWidget->setCurrentWidget(m_GDDCdlg); +} + +void MainWindow::receptLoginBtnClicked() +{ + ui->senceContrlWidget->hide(); + ui->stackedWidget->setCurrentWidget(m_userLoginDlg); +} + +void MainWindow::getloginDlgBtnClicked(int clickType) +{ + switch(clickType) + { + case UserLogin::click_type::HomePageClick: + { + if(_currentScene == 0) + { + ui->senceContrlWidget->hide(); + ui->stackedWidget->setCurrentWidget(m_SDFPDlg); + } + else if(_currentScene == 1) + { + emergencySceneShow(); + } + else if(_currentScene == 2) + { + seaRescueSceneShow(); + } + break; + } + case UserLogin::click_type::ExitLogin: //退出登录 + { + _currentScene = 0; + ui->stackedWidget->setCurrentWidget(m_SDFPDlg); + ui->senceContrlWidget->hide(); + } + default: + break; + } +} + +//应急场景显示 +void MainWindow::emergencySceneShow() +{ + toolButton_9_clicked(); + ui->senceContrlWidget->setCurrentIndex(0); + if(!ui->senceContrlWidget->isVisible()) + { + ui->senceContrlWidget->show(); + } +} + +//海上就捞场景显示 +void MainWindow::seaRescueSceneShow() +{ + on_toolButton_10_clicked(); + ui->senceContrlWidget->setCurrentIndex(1); + if(!ui->senceContrlWidget->isVisible()) + { + ui->senceContrlWidget->show(); + } +} + diff --git a/mainwindow.h b/mainwindow.h index 80d9ab1..9d16799 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -18,6 +18,7 @@ #include "Src/HomePage/homepagedlg.h" #include "Src/ModelCamera/modelcameradlg.h" #include "Src/RescueLoad/rescueloadwidget.h" +#include "userlogin.h" #ifdef Q_OS_WIN #include "windows.h" @@ -61,6 +62,12 @@ private slots: void toolButton_8_clicked(); void toolButton_9_clicked(); + void getUserSence(UserLogin::use_sence sence); + void on_toolButton_10_clicked(); + + void on_toolButton_21_clicked(); + void receptLoginBtnClicked();//sdfp页面登录按钮点击 + void getloginDlgBtnClicked(int clickType);//登录页面按钮点击 public: GDDCdlg *m_GDDCdlg; HomePageDlg *m_HomePagedlg; @@ -72,11 +79,15 @@ public: QWebEngineView *lLinkWeb; // L链 QWebEngineView *adHocNetworkWeb; // 自组网 QWebEngineView *satelliteCommWeb; // 卫通 + UserLogin *m_userLoginDlg; //用户登陆页面 private: QProcess *processPDT; QString exeDirPathName = ""; std::unordered_map m_allSetMap; + int _currentScene; + void emergencySceneShow(); + void seaRescueSceneShow(); public: void changeBtnColor(int num); @@ -87,5 +98,8 @@ private: void initUAVIDMap(); void initNotifyManager(); + + //初始化用户登陆页面 + void initUserLoginDlg(); }; #endif // MAINWINDOW_H diff --git a/mainwindow.qrc b/mainwindow.qrc index a9a244e..0985086 100644 --- a/mainwindow.qrc +++ b/mainwindow.qrc @@ -38,5 +38,11 @@ res/switch/switch_close3.png res/switch/switch_open3.png res/SDFP3.png + res/eyesOpen1.png + res/eyesOpen.png + res/eye1.png + res/eye2.png + res/eye3.png + res/eyec1.png diff --git a/mainwindow.ui b/mainwindow.ui index cb61ae2..1afbadf 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -57,8 +57,25 @@ 0 - - + + + + + 16777215 + 16777215 + + + + + + 2 + + + + + + + 0 @@ -68,138 +85,173 @@ background-color: rgb(40, 40, 40); - - - - - - - - - - ... - - - - - - - - 0 - 0 - - - - ... - - - - - - - - 0 - 0 - - - - ... - - - - - - - - 0 - 0 - - - - ... - - - - - - - - 0 - 0 - - - - ... - - - - - - - - 0 - 0 - - - - ... - - - - - - - - 0 - 0 - - - - ... - - - - - - - - 0 - 0 - - - - ... - - - - - - - - 0 - 0 - - - - ... - - - - - - - - - - - - - - - - - 2 - + + 1 + + + + + + + + + + + + ... + + + + + + + + 0 + 0 + + + + ... + + + + + + + + 0 + 0 + + + + ... + + + + + + + + 0 + 0 + + + + ... + + + + + + + + 0 + 0 + + + + ... + + + + + + + + 0 + 0 + + + + ... + + + + + + + + 0 + 0 + + + + ... + + + + + + + + 0 + 0 + + + + ... + + + + + + + + 0 + 0 + + + + ... + + + + + + + + + + + + + + + + + + + + + ... + + + + + + + ... + + + + + + + + + Qt::Orientation::Vertical + + + QSizePolicy::Policy::Fixed + + + + 20 + 48 + + + + @@ -261,7 +313,7 @@ - + :/res/GDDC.png:/res/GDDC.png @@ -273,7 +325,7 @@ - + :/res/LChain.png:/res/LChain.png @@ -347,6 +399,8 @@ - + + + diff --git a/res/eye1.png b/res/eye1.png new file mode 100644 index 0000000..0c397c7 Binary files /dev/null and b/res/eye1.png differ diff --git a/res/eye2.png b/res/eye2.png new file mode 100644 index 0000000..9de3dce Binary files /dev/null and b/res/eye2.png differ diff --git a/res/eye3.png b/res/eye3.png new file mode 100644 index 0000000..5cd2e1d Binary files /dev/null and b/res/eye3.png differ diff --git a/res/eyec1.png b/res/eyec1.png new file mode 100644 index 0000000..66f5cfe Binary files /dev/null and b/res/eyec1.png differ diff --git a/res/eyesOpen.png b/res/eyesOpen.png new file mode 100644 index 0000000..8e50834 Binary files /dev/null and b/res/eyesOpen.png differ diff --git a/res/eyesOpen1.png b/res/eyesOpen1.png new file mode 100644 index 0000000..01c4183 Binary files /dev/null and b/res/eyesOpen1.png differ