优化界面
This commit is contained in:
parent
84dad3a3aa
commit
546ed2d0fa
@ -5,6 +5,7 @@
|
||||
#include "data_config.h"
|
||||
#include <QSettings>
|
||||
#include <QMessageBox>
|
||||
#include <QNetworkProxy>
|
||||
|
||||
Connect::Connect(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
@ -26,6 +27,7 @@ Connect::~Connect()
|
||||
void Connect::on_pushButton_connect_clicked()
|
||||
{
|
||||
g_strServerIp = ui->lineEdit_IP->text();
|
||||
QNetworkProxy::setApplicationProxy(QNetworkProxy::NoProxy);
|
||||
m_tcpClient = MyTcpClient::instance();
|
||||
// 连接服务器
|
||||
m_tcpClient->connectToServer(g_strServerIp, 10000);
|
||||
|
||||
@ -938,6 +938,38 @@ typedef struct {
|
||||
uint16_t pid2; // 辅助进程进程号,只有振动板有这个号
|
||||
} GetCardProcessIDRsp;
|
||||
|
||||
typedef struct {
|
||||
uint8_t head[3]; // 固定值:0xAA55AA
|
||||
uint8_t cmd; // kGetProductInfo
|
||||
uint8_t version; // 版本号,默认为1
|
||||
} GetProductInfoReq;
|
||||
|
||||
typedef struct {
|
||||
uint8_t head[3]; // 固定值:0xAA55AA
|
||||
uint8_t cmd; // kGetProductInfo
|
||||
uint8_t version; // 版本号,默认为1
|
||||
uint8_t code; // 0: 成功, 1:失败
|
||||
char date[32]; // 生产日期
|
||||
char config_sw[64]; // config软件版本
|
||||
char view_sw[64]; // view软件版本
|
||||
} GetProductInfoRsp;
|
||||
|
||||
typedef struct {
|
||||
uint8_t head[3]; // 固定值:0xAA55AA
|
||||
uint8_t cmd; // kSetProductInfo
|
||||
uint8_t version; // 版本号,默认为1
|
||||
char date[32]; // 生产日期
|
||||
char config_sw[64]; // config软件版本
|
||||
char view_sw[64]; // view软件版本
|
||||
} SetProductInfoReq;
|
||||
|
||||
typedef struct {
|
||||
uint8_t head[3]; // 固定值:0xAA55AA
|
||||
uint8_t cmd; // kSetProductInfo
|
||||
uint8_t version; // 版本号,默认为1
|
||||
uint8_t code; // 0: 成功, 1:失败
|
||||
} SetProductInfoRsp;
|
||||
|
||||
struct BaseHeader {
|
||||
uint8_t head[3]; // 固定 0xAA 0x55 0xAA
|
||||
uint8_t cmd;
|
||||
|
||||
@ -29,7 +29,9 @@
|
||||
#include "dc_outputs.h"
|
||||
#include "mqtt_config.h"
|
||||
#include "singlerelay_nok.h"
|
||||
#include <QInputDialog>
|
||||
#include <QDesktopServices>
|
||||
#include <QUrl>
|
||||
#include <QFileInfo>
|
||||
|
||||
QString g_strServerIp;
|
||||
QString g_version;
|
||||
@ -55,6 +57,11 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
statusBar()->addWidget(progressBar);
|
||||
progressBar->setVisible(false); // 初始隐藏
|
||||
progressBar->setFixedWidth(300);
|
||||
|
||||
connect_status = new QLabel("网络: 未连接", this);
|
||||
statusBar()->addPermanentWidget(connect_status);
|
||||
|
||||
shouldReconnect = true;
|
||||
//this->initStyle();
|
||||
//添加信号槽
|
||||
QObject::connect(ui->action_realy, &QAction::triggered, this, &MainWindow::onMenuAction_relay);
|
||||
@ -105,18 +112,17 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
QObject::connect(ui->action_deviveID, &QAction::triggered, this, &MainWindow::onConfigDeviceID);
|
||||
QObject::connect(ui->action_get_deviceID, &QAction::triggered, this, &MainWindow::onGetDeviceID);
|
||||
QObject::connect(ui->action_close, &QAction::triggered, this, &MainWindow::onCloseConfig);
|
||||
|
||||
QObject::connect(ui->action_user_manual, &QAction::triggered, this, &MainWindow::onOpenUserManual);
|
||||
|
||||
QSettings settingsread(QCoreApplication::applicationDirPath() + "\\config\\config.ini", QSettings::IniFormat);
|
||||
g_strServerIp = settingsread.value("Server/IP").toString();
|
||||
connectServer();
|
||||
statusBar()->showMessage("未连接",10000);
|
||||
// 设置自定义日志处理函数
|
||||
#ifndef QT_DEBUG
|
||||
//qInstallMessageHandler(messageHandler);
|
||||
#endif
|
||||
QDate buildDate = QLocale( QLocale::English ).toDate( QString(__DATE__).replace(" ", " 0"), "MMM dd yyyy");
|
||||
QString Version = "V1.0_" + buildDate.toString("yyyyMMdd") + "_1c8b";
|
||||
QString Version = "V1.0_" + buildDate.toString("yyyyMMdd") + "_84da";
|
||||
ui->label_version->setText(Version);
|
||||
}
|
||||
|
||||
@ -125,16 +131,22 @@ MainWindow::~MainWindow() {
|
||||
}
|
||||
|
||||
void MainWindow::onDisConnected() {
|
||||
statusBar()->showMessage("连接失败!正在重连……", 3000); // 显示3秒
|
||||
if(shouldReconnect){
|
||||
statusBar()->showMessage("网络已断开,正在重连……", 3000); // 显示3秒
|
||||
}
|
||||
connect_status->setText("网络: 已断开");
|
||||
}
|
||||
|
||||
void MainWindow::onConnected() {
|
||||
shouldReconnect = true;
|
||||
statusBar()->showMessage("连接成功!", 3000);
|
||||
connect_status->setText("网络: 已连接");
|
||||
}
|
||||
void MainWindow::onerrorOccurred(const QString &errorMsg) {
|
||||
statusBar()->showMessage(errorMsg, 3000);
|
||||
}
|
||||
void MainWindow::connectServer() {
|
||||
QNetworkProxy::setApplicationProxy(QNetworkProxy::NoProxy);
|
||||
m_tcpClient = MyTcpClient::instance();
|
||||
// 监听信号
|
||||
connect(m_tcpClient, SIGNAL(dataReceived(const QByteArray &)), this, SLOT(readData(const QByteArray &)));
|
||||
@ -646,7 +658,7 @@ void MainWindow::on_pushButton_save_clicked() {
|
||||
QString strTips = QString("请输入保存的文件名称");
|
||||
bool ok = false;
|
||||
QString defaultInput = "tsi_config_file";
|
||||
file_name = QInputDialog::getText(this, tr("输入名称对话框"), strTips, QLineEdit::Normal, defaultInput, &ok);
|
||||
file_name = QInputDialog::getText(this, tr("输入保存文件名称"), strTips, QLineEdit::Normal, defaultInput, &ok);
|
||||
if(!ok) return;
|
||||
|
||||
if( file_name == ""){
|
||||
@ -682,7 +694,7 @@ void MainWindow::on_pushButton_save_clicked() {
|
||||
void MainWindow::on_pushButton_open_clicked() {
|
||||
|
||||
|
||||
tsi_config_file = QFileDialog::getOpenFileName(this, tr("选择文件"), tr(""), tr("*.json"));
|
||||
tsi_config_file = QFileDialog::getOpenFileName(this, tr("选择文件"), QCoreApplication::applicationDirPath()+ "\\config\\", tr("*.json"));
|
||||
QFileInfo fileinfo;
|
||||
fileinfo = QFileInfo(tsi_config_file);
|
||||
QString file_suffix = fileinfo.suffix();
|
||||
@ -889,7 +901,6 @@ void MainWindow::GetVoltageRangeValue(int slot){
|
||||
return;
|
||||
}
|
||||
get_sub_card_log_req.card_id = slot & 0xFF;
|
||||
|
||||
char send_buf[20] = {0};
|
||||
memcpy(send_buf, (char *)&get_sub_card_log_req, sizeof(GetSubCardVoltageRangeReq));
|
||||
int length = sizeof(GetSubCardVoltageRangeReq);
|
||||
@ -917,9 +928,9 @@ void MainWindow::GetCardProcessID(int slot){
|
||||
}
|
||||
void MainWindow::CopySubCard(int slot){
|
||||
slot_no = slot;
|
||||
QString strTips = QString("请输入1到15之间的数值");
|
||||
QString strTips = QString("请输入需要复制的板卡号(1 ~ 15)");
|
||||
bool ok = false;
|
||||
int value = QInputDialog::getInt(this, tr("输入整数对话框"), strTips, 0, 1, 15, 1, &ok);
|
||||
int value = QInputDialog::getInt(this, tr("请输入需要复制的板卡号"), strTips, 0, 1, 15, 1, &ok);
|
||||
if(!ok) return;
|
||||
if(value < 1){
|
||||
QMessageBox::information(this, QStringLiteral("提示"), QStringLiteral("请输入正确的板卡号!"));
|
||||
@ -999,13 +1010,12 @@ void MainWindow::CopySubCard(int slot){
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
void MainWindow::MoveSubCard(int slot){
|
||||
slot_no = slot;
|
||||
QString strTips = QString("请输入1到15之间的数值");
|
||||
QString strTips = QString("请输入需要移动的板卡号(1 ~ 15)");
|
||||
bool ok = false;
|
||||
int value = QInputDialog::getInt(this, tr("输入整数对话框"), strTips, 0, 1, 15, 1, &ok);
|
||||
int value = QInputDialog::getInt(this, tr("请输入需要移动的板卡号"), strTips, 0, 1, 15, 1, &ok);
|
||||
if(!ok) return;
|
||||
if(value < 1){
|
||||
QMessageBox::information(this, QStringLiteral("提示"), QStringLiteral("请输入正确的板卡号!"));
|
||||
@ -1212,6 +1222,7 @@ void MainWindow::onConnect(){
|
||||
connect_config->show();
|
||||
}
|
||||
void MainWindow::onDisconnect(){
|
||||
shouldReconnect = false;
|
||||
m_tcpClient->disconnectFromServer();
|
||||
}
|
||||
|
||||
@ -1252,11 +1263,21 @@ void MainWindow::onCloseConfig(){
|
||||
}
|
||||
tsi_config_file = "";
|
||||
}
|
||||
void MainWindow::onOpenUserManual(){
|
||||
QString pdfPath = QCoreApplication::applicationDirPath()+ "\\config\\南京凯奥思安全监视与保护装置使用说明书.pdf";
|
||||
QFileInfo file(pdfPath);
|
||||
if (!file.exists()) {
|
||||
QMessageBox::warning(this, QStringLiteral("警告"), QStringLiteral("文件不存在!"));
|
||||
return;
|
||||
}
|
||||
QDesktopServices::openUrl(
|
||||
QUrl::fromLocalFile(file.absoluteFilePath())
|
||||
);
|
||||
}
|
||||
void MainWindow::onConfigDeviceID(){
|
||||
QString strTips =QString("请输入0到99之间的数值");
|
||||
|
||||
QString strTips = QString("请输入设备ID(0 ~ 99)");
|
||||
bool ok = false;
|
||||
int value = QInputDialog::getInt(this, tr("输入整数对话框"), strTips, 0, 0, 99, 1, &ok);
|
||||
int value = QInputDialog::getInt(this, tr("请输入设备ID"), strTips, 0, 0, 99, 1, &ok);
|
||||
if(!ok) return;
|
||||
|
||||
if(value < 1){
|
||||
|
||||
@ -47,6 +47,8 @@ private:
|
||||
QProgressBar *progressBar;
|
||||
int current_slot;
|
||||
QString tsi_config_file;
|
||||
bool shouldReconnect ;
|
||||
QLabel *connect_status;
|
||||
|
||||
void createMenu();
|
||||
void createMenu(const QString& rootTitle, QPushButton* button = nullptr);
|
||||
@ -84,6 +86,7 @@ private slots:
|
||||
void onConfigDeviceID();
|
||||
void onGetDeviceID();
|
||||
void onCloseConfig();
|
||||
void onOpenUserManual();
|
||||
|
||||
|
||||
void onMenuActionTriggered();
|
||||
|
||||
@ -194,7 +194,7 @@
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>打开配置文件</string>
|
||||
<string>关闭配置文件</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>关闭</string>
|
||||
@ -1097,10 +1097,6 @@
|
||||
<property name="title">
|
||||
<string>开始</string>
|
||||
</property>
|
||||
<addaction name="action_new"/>
|
||||
<addaction name="action_open"/>
|
||||
<addaction name="action_close"/>
|
||||
<addaction name="action_import"/>
|
||||
<addaction name="action_connect"/>
|
||||
<addaction name="action_disconnect"/>
|
||||
</widget>
|
||||
@ -1108,6 +1104,7 @@
|
||||
<property name="title">
|
||||
<string>帮助</string>
|
||||
</property>
|
||||
<addaction name="action_user_manual"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menu_tool">
|
||||
<property name="title">
|
||||
@ -1196,6 +1193,11 @@
|
||||
<string>关闭</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="action_user_manual">
|
||||
<property name="text">
|
||||
<string>使用手册</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
|
||||
@ -1421,46 +1421,6 @@
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_copy_right_1">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>50</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>===></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>===</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_copy_left_1">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>50</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string><===</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_6">
|
||||
<property name="title">
|
||||
@ -1517,54 +1477,6 @@
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<widget class="QWidget" name="layoutWidget_3">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>210</y>
|
||||
<width>52</width>
|
||||
<height>91</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_copy_all_right">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>50</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>===></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_22">
|
||||
<property name="text">
|
||||
<string>===</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_copy_all_left">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>50</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string><===</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
@ -2757,46 +2669,6 @@
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_5">
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_copy_right_2">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>50</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>===></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="text">
|
||||
<string>===</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_copy_left_2">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>50</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string><===</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_10">
|
||||
<property name="title">
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user