优化界面

This commit is contained in:
zhangsheng 2025-04-17 20:33:26 +08:00
parent 4b28af5a4e
commit 8f75f5672c
6 changed files with 827 additions and 385 deletions

View File

@ -70,6 +70,11 @@ enum CMTCommand {
kConfigSubCard = 16, // 请求无包体,响应有包体 kConfigSubCard = 16, // 请求无包体,响应有包体
kRS485BaudrateSet = 17, // RS485波特率配置 kRS485BaudrateSet = 17, // RS485波特率配置
kRS485BaudrateGet = 18, // RS485波特率获取 kRS485BaudrateGet = 18, // RS485波特率获取
kConfigIPv4 = 19, // 配置IP地址
kConfigMac = 20, // 配置Mac地址
kRebootCard = 21, // 重启板卡
kGetCardDcValue = 22, // 获取子板平均值
kGetRelayStatus = 23, // 获取继电器状态
}; };
enum RS485Baudrate { enum RS485Baudrate {
kBaudrate2400 = 0, kBaudrate2400 = 0,
@ -320,7 +325,48 @@ typedef struct {
typedef struct { typedef struct {
uint8_t code; // 0: success uint8_t code; // 0: success
} BaudrateSetRsp; } BaudrateSetRsp;
// cmd: kConfigIPv4
typedef struct {
uint8_t ethn; // 0: eth0, 1: eth1
char ip[16];
char netmask[16];
} ConfigIPv4Req;
// 配置IP的响应结构为CommonRsp
// cmd: kConfigMac
typedef struct {
uint8_t ethn; // 0: eth0, 1: eth1
char mac[18];
} ConfigMacReq;
// 配置MAC的响应结构为CommonRsp
// cmd: kRebootCard
typedef struct {
uint8_t card_id; // 0: cpu板卡 115对应相应槽位
} RebootCardReq;
// 此命令无响应,可观察各板卡灯的变化情况
// cmd: kGetCardDcValue
typedef struct {
uint8_t card_id; // 1 ~ 15
} GetCardDcValueReq;
typedef struct {
float dc_value[4];
} GetCardDcValueRsp;
// cmd: kGetRelayStatus
typedef struct {
uint8_t card_id;
} GetRelayStatusReq;
typedef struct {
uint8_t card_id;
uint16_t status; // 0: 正常 1开出, 从低位到高位分别为继电器的通道1 16
} GetRelayStatusRsp;
#pragma pack() #pragma pack()
#endif // DATA_CONFIG_H #endif // DATA_CONFIG_H

View File

@ -11,7 +11,7 @@
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>Form</string> <string>触发配置</string>
</property> </property>
<widget class="QGroupBox" name="groupBox_2"> <widget class="QGroupBox" name="groupBox_2">
<property name="geometry"> <property name="geometry">
@ -50,16 +50,6 @@
</property> </property>
</item> </item>
</widget> </widget>
<widget class="QComboBox" name="comboBox_5">
<property name="geometry">
<rect>
<x>80</x>
<y>30</y>
<width>69</width>
<height>22</height>
</rect>
</property>
</widget>
<widget class="QLabel" name="label_19"> <widget class="QLabel" name="label_19">
<property name="geometry"> <property name="geometry">
<rect> <rect>

View File

@ -6,6 +6,10 @@ SingleRelay::SingleRelay(QWidget *parent)
, ui(new Ui::SingleRelay) { , ui(new Ui::SingleRelay) {
ui->setupUi(this); ui->setupUi(this);
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
QVBoxLayout *layout = new QVBoxLayout(ui->widget_relay);
DropTextEdit *textEdit = new DropTextEdit;
layout->addWidget(textEdit);
} }
SingleRelay::~SingleRelay() { SingleRelay::~SingleRelay() {

View File

@ -2,6 +2,11 @@
#define SINGLERELAY_H #define SINGLERELAY_H
#include <QDialog> #include <QDialog>
#include <QTextEdit>
#include <QMimeData>
#include <QDrag>
#include <QDragEnterEvent>
#include <QDebug>
namespace Ui { namespace Ui {
class SingleRelay; class SingleRelay;
@ -20,5 +25,38 @@ class SingleRelay : public QDialog {
private: private:
Ui::SingleRelay *ui; Ui::SingleRelay *ui;
}; };
class DropTextEdit : public QTextEdit {
public:
DropTextEdit(QWidget *parent = nullptr) : QTextEdit(parent) {
setAcceptDrops(true);
setReadOnly(false); // 确保不是只读的
}
protected:
void dragEnterEvent(QDragEnterEvent *event) override {
qDebug() << "dragEnterEvent" << event->mimeData()->formats();
if (event->mimeData()->hasText()) {
event->acceptProposedAction();
} else {
event->ignore();
}
}
void dragMoveEvent(QDragMoveEvent *event) override {
if (event->mimeData()->hasText()) {
event->acceptProposedAction();
} else {
event->ignore();
}
}
void dropEvent(QDropEvent *event) override {
if (event->mimeData()->hasText()) {
insertPlainText(event->mimeData()->text());
event->acceptProposedAction();
} else {
event->ignore();
}
}
};
#endif // SINGLERELAY_H #endif // SINGLERELAY_H

View File

@ -11,7 +11,7 @@
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>Dialog</string> <string>继电器组态</string>
</property> </property>
<widget class="QLabel" name="label_4"> <widget class="QLabel" name="label_4">
<property name="geometry"> <property name="geometry">
@ -65,23 +65,6 @@
<string>或(*)</string> <string>或(*)</string>
</property> </property>
</widget> </widget>
<widget class="QTextEdit" name="textEdit">
<property name="geometry">
<rect>
<x>240</x>
<y>380</y>
<width>551</width>
<height>131</height>
</rect>
</property>
<property name="html">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'SimSun'; font-size:9pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'.AppleSystemUIFont'; font-size:13pt;&quot;&gt;S02C01P##NO&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
<widget class="QLabel" name="label_3"> <widget class="QLabel" name="label_3">
<property name="geometry"> <property name="geometry">
<rect> <rect>
@ -111,7 +94,7 @@ p, li { white-space: pre-wrap; }
<string>打 印...</string> <string>打 印...</string>
</property> </property>
</widget> </widget>
<widget class="QListWidget" name="listWidget"> <widget class="QListWidget" name="listWidget_available">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>620</x> <x>620</x>
@ -120,6 +103,12 @@ p, li { white-space: pre-wrap; }
<height>161</height> <height>161</height>
</rect> </rect>
</property> </property>
<property name="dragEnabled">
<bool>true</bool>
</property>
<property name="dragDropMode">
<enum>QAbstractItemView::DragOnly</enum>
</property>
<item> <item>
<property name="text"> <property name="text">
<string>S02C01P##NO (Slot 2 Channel 1 Not OK)</string> <string>S02C01P##NO (Slot 2 Channel 1 Not OK)</string>
@ -1096,6 +1085,16 @@ p, li { white-space: pre-wrap; }
</item> </item>
</layout> </layout>
</widget> </widget>
<widget class="QWidget" name="widget_relay" native="true">
<property name="geometry">
<rect>
<x>240</x>
<y>380</y>
<width>561</width>
<height>131</height>
</rect>
</property>
</widget>
</widget> </widget>
<resources/> <resources/>
<connections/> <connections/>

File diff suppressed because it is too large Load Diff