pref: ui布局调整

map
cbwu 3 weeks ago
parent cd83387b67
commit 5e3ef6ffa2

@ -6,91 +6,37 @@ CommandWidget::CommandWidget(QWidget *parent)
: QWidget(parent), ui(new Ui::CommandWidget) {
ui->setupUi(this);
udpSocket = new QUdpSocket(this);
ui->videoLayout1TBtn->setIcon(QIcon(":/images/videolayout1.png"));
ui->videoLayout4TBtn->setIcon(QIcon(":/images/videolayout4.png"));
m_commandUdpSocket = new QUdpSocket(this);
// 将套接字绑定到指定端口
if (m_commandUdpSocket->bind(QHostAddress::Any, 1200)) {
qDebug() << "UDP 套接字已绑定到端口 1200";
} else {
qDebug() << "绑定 UDP 套接字失败";
}
}
CommandWidget::~CommandWidget() {
delete ui;
if (udpSocket) udpSocket->deleteLater();
if (m_commandUdpSocket) m_commandUdpSocket->deleteLater();
}
// 连接
void CommandWidget::on_startConnectionToolBtn_clicked() {
ui->startConnectionToolBtn->setDisabled(true);
if (!g_networkSettingInfo) {
qWarning() << "Network settings are not initialized!";
return;
}
int dataSourceType = g_networkSettingInfo->value("DataSource").toInt();
QString groupName = "";
switch (dataSourceType) {
case 0:
groupName = "LLink";
break;
case 1:
groupName = "SATCOM1";
break;
case 2:
groupName = "SATCOM2";
break;
default:
qWarning() << "Unknown data source type:" << dataSourceType;
return;
}
m_remoteIP = g_networkSettingInfo->value(groupName + "/remoteIP").toString();
m_remotePort = g_networkSettingInfo->value(groupName + "/remotePort").toInt();
int localPort = g_networkSettingInfo->value(groupName + "/localPort").toInt();
QString localIP = g_networkSettingInfo->value(groupName + "/localIP").toString();
// 校验 IP 和端口
if (m_remoteIP.isEmpty() || m_remotePort <= 0 || localIP.isEmpty() || localPort <= 0) {
qWarning() << "Invalid IP or port configuration!";
return;
}
if (dataSourceType == 0) { // 组播
qDebug() << "Starting multicast connection to" << m_remoteIP << ":" << m_remotePort;
emit startConnectionSignal(m_remoteIP, m_remotePort);
} else { // 单播
qDebug() << "Starting unicast connection on" << localIP << ":" << localPort;
emit startConnectionSignal(localIP, localPort);
}
}
void CommandWidget::receiveMessageSlots(QString message, int type) {
emit sendErrorMessage(message, type);
}
unsigned char CommandWidget::getCrc(quint8* data, quint8 length)
{
unsigned char CommandWidget::getCrc(quint8 *data, quint8 length) {
quint16 crc = 0;
int i=0;
while (length-- > 0)
{
crc = CRC8TAB[crc ^ (data[i]&0x00FF)];
int i = 0;
while (length-- > 0) {
crc = CRC8TAB[crc ^ (data[i] & 0x00FF)];
i++;
}
return crc&0x00ff;
return crc & 0x00ff;
}
ProtocalKB CommandWidget::EncodeCommandCmd(quint8 cmd)
{
ProtocalKB CommandWidget::EncodeCommandCmd(quint8 cmd) {
std::unique_ptr<ProtocalKB> pBuff = std::make_unique<ProtocalKB>();
pBuff->head[0] = PROTOCOL_HEAD_0;
pBuff->head[1] = PROTOCOL_HEAD_1;
@ -99,161 +45,103 @@ ProtocalKB CommandWidget::EncodeCommandCmd(quint8 cmd)
pBuff->data[1] = cmd;
pBuff->data[2] = cmd;
pBuff->curPage = PROTOCOL_CUR_PAGE;
quint8 *ptr = reinterpret_cast<quint8*>(&pBuff);
quint8 *ptr = reinterpret_cast<quint8 *>(&pBuff);
pBuff->CHKSUM = getCrc(ptr, sizeof(pBuff) - sizeof(pBuff->CHKSUM));
return *pBuff;
}
bool CommandWidget::writeBufferToClient(const QByteArray &data)
{
bool CommandWidget::writeBufferToClient(const QByteArray &data) {
// 目标地址和端口
QHostAddress destination("172.10.1.216"); // 目标 IP 地址
quint16 port = 9003; // 目标端口
// 发送数据
qint64 bytesSent = g_CommandudpSocket->writeDatagram(data, destination, port);
qint64 bytesSent =
m_commandUdpSocket->writeDatagram(data, destination, port);
if (bytesSent == -1) {
qDebug() << "发送失败:" << g_CommandudpSocket->errorString();
qDebug() << "发送失败:" << m_commandUdpSocket->errorString();
return false;
} else {
qDebug() << "发送成功,字节数:" << bytesSent;
return true;
}
}
void CommandWidget::buttonResponse(quint8 cmd)
{
void CommandWidget::buttonResponse(quint8 cmd) {
ProtocalKB packet = EncodeCommandCmd(cmd);
// 将 ProtocalKB 结构体转换为 QByteArray
QByteArray data;
data.append(reinterpret_cast<const char*>(&packet), sizeof(ProtocalKB));
for(int i=0;i<3;i++)
{
data.append(reinterpret_cast<const char *>(&packet), sizeof(ProtocalKB));
for (int i = 0; i < 3; i++) {
writeBufferToClient(data);
}
}
void CommandWidget::on_pushButton_clicked()
{
void CommandWidget::on_pushButton_clicked() {
buttonResponse(0x75);
}
void CommandWidget::on_pushButton_2_clicked()
{
void CommandWidget::on_pushButton_2_clicked() {
buttonResponse(0x76);
}
void CommandWidget::on_pushButton_5_clicked()
{
void CommandWidget::on_pushButton_5_clicked() {
buttonResponse(0x7D);
}
void CommandWidget::on_pushButton_6_clicked()
{
void CommandWidget::on_pushButton_6_clicked() {
buttonResponse(0x7C);
}
void CommandWidget::on_pushButton_10_clicked()
{
void CommandWidget::on_pushButton_10_clicked() {
buttonResponse(0x69);
}
void CommandWidget::on_pushButton_9_clicked()
{
void CommandWidget::on_pushButton_9_clicked() {
buttonResponse(0x6A);
}
void CommandWidget::on_pushButton_4_clicked()
{
void CommandWidget::on_pushButton_4_clicked() {
buttonResponse(0x77);
}
void CommandWidget::on_pushButton_3_clicked()
{
void CommandWidget::on_pushButton_3_clicked() {
buttonResponse(0x78);
}
void CommandWidget::on_pushButton_14_clicked()
{
void CommandWidget::on_pushButton_14_clicked() {
buttonResponse(0x79);
}
void CommandWidget::on_pushButton_13_clicked()
{
void CommandWidget::on_pushButton_13_clicked() {
buttonResponse(0xC6);
}
void CommandWidget::on_pushButton_17_clicked()
{
void CommandWidget::on_pushButton_17_clicked() {
buttonResponse(0x66);
}
void CommandWidget::on_pushButton_8_clicked()
{
void CommandWidget::on_pushButton_8_clicked() {
buttonResponse(0x67);
}
void CommandWidget::on_pushButton_7_clicked()
{
void CommandWidget::on_pushButton_7_clicked() {
buttonResponse(0x68);
}
void CommandWidget::on_pushButton_12_clicked()
{
void CommandWidget::on_pushButton_12_clicked() {
buttonResponse(0x7B);
}
void CommandWidget::on_pushButton_11_clicked()
{
void CommandWidget::on_pushButton_11_clicked() {
buttonResponse(0x7A);
}
void CommandWidget::on_pushButton_16_clicked()
{
void CommandWidget::on_pushButton_16_clicked() {
buttonResponse(0xC8);
}
void CommandWidget::on_pushButton_15_clicked()
{
void CommandWidget::on_pushButton_15_clicked() {
buttonResponse(0xC9);
}
void CommandWidget::on_videoLayout1TBtn_clicked() {
ui->videoLayout1TBtn->setDisabled(true);
emit changeVideoLayout(0);
ui->videoLayout1TBtn->setDisabled(false);
}
void CommandWidget::on_videoLayout4TBtn_clicked() {
ui->videoLayout4TBtn->setDisabled(true);
emit changeVideoLayout(1);
ui->videoLayout4TBtn->setDisabled(false);
}

@ -3,17 +3,17 @@
#include <QUdpSocket>
#include <QWidget>
#include "global.h"
#include "communicationsettingdlg.h"
#include "global.h"
typedef struct struProtocalKB {
quint8 head[2]; //帧头0x
quint8 reserved; //预留
quint8 data[3]; //开关指令
quint8 curPage; //指令页
quint8 CHKSUM; //校验字节
}ProtocalKB;
quint8 head[2]; // 帧头0x
quint8 reserved; // 预留
quint8 data[3]; // 开关指令
quint8 curPage; // 指令页
quint8 CHKSUM; // 校验字节
} ProtocalKB;
// 定义常量
const unsigned char PROTOCOL_HEAD_0 = 0xEB;
@ -21,62 +21,55 @@ const unsigned char PROTOCOL_HEAD_1 = 0x98;
const unsigned char PROTOCOL_RESERVED = 0x00;
const unsigned char PROTOCOL_CUR_PAGE = 0x01;
const quint16 CRC8TAB[256] =
{
//0
0x0000, 0x0031, 0x0062, 0x0053, 0x00C4, 0x00F5, 0x00A6, 0x0097,
0x00B9, 0x0088, 0x00DB, 0x00EA, 0x007D, 0x004C, 0x001F, 0x002E,
//1
0x0043, 0x0072, 0x0021, 0x0010, 0x0087, 0x00B6, 0x00E5, 0x00D4,
0x00FA, 0x00CB, 0x0098, 0x00A9, 0x003E, 0x000F, 0x005C, 0x006D,
//2
0x0086, 0x00B7, 0x00E4, 0x00D5, 0x0042, 0x0073, 0x0020, 0x0011,
0x003F, 0x000E, 0x005D, 0x006C, 0x00FB, 0x00CA, 0x0099, 0x00A8,
//3
0x00C5, 0x00F4, 0x00A7, 0x0096, 0x0001, 0x0030, 0x0063, 0x0052,
0x007C, 0x004D, 0x001E, 0x002F, 0x00B8, 0x0089, 0x00DA, 0x00EB,
//4
0x003D, 0x000C, 0x005F, 0x006E, 0x00F9, 0x00C8, 0x009B, 0x00AA,
0x0084, 0x00B5, 0x00E6, 0x00D7, 0x0040, 0x0071, 0x0022, 0x0013,
//5
0x007E, 0x004F, 0x001C, 0x002D, 0x00BA, 0x008B, 0x00D8, 0x00E9,
0x00C7, 0x00F6, 0x00A5, 0x0094, 0x0003, 0x0032, 0x0061, 0x0050,
//6
0x00BB, 0x008A, 0x00D9, 0x00E8, 0x007F, 0x004E, 0x001D, 0x002C,
0x0002, 0x0033, 0x0060, 0x0051, 0x00C6, 0x00F7, 0x00A4, 0x0095,
//7
0x00F8, 0x00C9, 0x009A, 0x00AB, 0x003C, 0x000D, 0x005E, 0x006F,
0x0041, 0x0070, 0x0023, 0x0012, 0x0085, 0x00B4, 0x00E7, 0x00D6,
//8
0x007A, 0x004B, 0x0018, 0x0029, 0x00BE, 0x008F, 0x00DC, 0x00ED,
0x00C3, 0x00F2, 0x00A1, 0x0090, 0x0007, 0x0036, 0x0065, 0x0054,
//9
0x0039, 0x0008, 0x005B, 0x006A, 0x00FD, 0x00CC, 0x009F, 0x00AE,
0x0080, 0x00B1, 0x00E2, 0x00D3, 0x0044, 0x0075, 0x0026, 0x0017,
//A
0x00FC, 0x00CD, 0x009E, 0x00AF, 0x0038, 0x0009, 0x005A, 0x006B,
0x0045, 0x0074, 0x0027, 0x0016, 0x0081, 0x00B0, 0x00E3, 0x00D2,
//B
0x00BF, 0x008E, 0x00DD, 0x00EC, 0x007B, 0x004A, 0x0019, 0x0028,
0x0006, 0x0037, 0x0064, 0x0055, 0x00C2, 0x00F3, 0x00A0, 0x0091,
//C
0x0047, 0x0076, 0x0025, 0x0014, 0x0083, 0x00B2, 0x00E1, 0x00D0,
0x00FE, 0x00CF, 0x009C, 0x00AD, 0x003A, 0x000B, 0x0058, 0x0069,
//D
0x0004, 0x0035, 0x0066, 0x0057, 0x00C0, 0x00F1, 0x00A2, 0x0093,
0x00BD, 0x008C, 0x00DF, 0x00FE, 0x0079, 0x0048, 0x001B, 0x002A,
//E
0x00C1, 0x00F0, 0x00A3, 0x0092, 0x0005, 0x0034, 0x0067, 0x0056,
0x0078, 0x0049, 0x001A, 0x002B, 0x00BC, 0x008D, 0x00DE, 0x00EF,
//F
0x0082, 0x00B3, 0x00E0, 0x00D1, 0x0046, 0x0077, 0x0024, 0x0015,
0x003B, 0x000A, 0x0059, 0x0068, 0x00FF, 0x00CE, 0x009D, 0x00AC
};
const quint16 CRC8TAB[256] = {
// 0
0x0000, 0x0031, 0x0062, 0x0053, 0x00C4, 0x00F5, 0x00A6, 0x0097, 0x00B9,
0x0088, 0x00DB, 0x00EA, 0x007D, 0x004C, 0x001F, 0x002E,
// 1
0x0043, 0x0072, 0x0021, 0x0010, 0x0087, 0x00B6, 0x00E5, 0x00D4, 0x00FA,
0x00CB, 0x0098, 0x00A9, 0x003E, 0x000F, 0x005C, 0x006D,
// 2
0x0086, 0x00B7, 0x00E4, 0x00D5, 0x0042, 0x0073, 0x0020, 0x0011, 0x003F,
0x000E, 0x005D, 0x006C, 0x00FB, 0x00CA, 0x0099, 0x00A8,
// 3
0x00C5, 0x00F4, 0x00A7, 0x0096, 0x0001, 0x0030, 0x0063, 0x0052, 0x007C,
0x004D, 0x001E, 0x002F, 0x00B8, 0x0089, 0x00DA, 0x00EB,
// 4
0x003D, 0x000C, 0x005F, 0x006E, 0x00F9, 0x00C8, 0x009B, 0x00AA, 0x0084,
0x00B5, 0x00E6, 0x00D7, 0x0040, 0x0071, 0x0022, 0x0013,
// 5
0x007E, 0x004F, 0x001C, 0x002D, 0x00BA, 0x008B, 0x00D8, 0x00E9, 0x00C7,
0x00F6, 0x00A5, 0x0094, 0x0003, 0x0032, 0x0061, 0x0050,
// 6
0x00BB, 0x008A, 0x00D9, 0x00E8, 0x007F, 0x004E, 0x001D, 0x002C, 0x0002,
0x0033, 0x0060, 0x0051, 0x00C6, 0x00F7, 0x00A4, 0x0095,
// 7
0x00F8, 0x00C9, 0x009A, 0x00AB, 0x003C, 0x000D, 0x005E, 0x006F, 0x0041,
0x0070, 0x0023, 0x0012, 0x0085, 0x00B4, 0x00E7, 0x00D6,
// 8
0x007A, 0x004B, 0x0018, 0x0029, 0x00BE, 0x008F, 0x00DC, 0x00ED, 0x00C3,
0x00F2, 0x00A1, 0x0090, 0x0007, 0x0036, 0x0065, 0x0054,
// 9
0x0039, 0x0008, 0x005B, 0x006A, 0x00FD, 0x00CC, 0x009F, 0x00AE, 0x0080,
0x00B1, 0x00E2, 0x00D3, 0x0044, 0x0075, 0x0026, 0x0017,
// A
0x00FC, 0x00CD, 0x009E, 0x00AF, 0x0038, 0x0009, 0x005A, 0x006B, 0x0045,
0x0074, 0x0027, 0x0016, 0x0081, 0x00B0, 0x00E3, 0x00D2,
// B
0x00BF, 0x008E, 0x00DD, 0x00EC, 0x007B, 0x004A, 0x0019, 0x0028, 0x0006,
0x0037, 0x0064, 0x0055, 0x00C2, 0x00F3, 0x00A0, 0x0091,
// C
0x0047, 0x0076, 0x0025, 0x0014, 0x0083, 0x00B2, 0x00E1, 0x00D0, 0x00FE,
0x00CF, 0x009C, 0x00AD, 0x003A, 0x000B, 0x0058, 0x0069,
// D
0x0004, 0x0035, 0x0066, 0x0057, 0x00C0, 0x00F1, 0x00A2, 0x0093, 0x00BD,
0x008C, 0x00DF, 0x00FE, 0x0079, 0x0048, 0x001B, 0x002A,
// E
0x00C1, 0x00F0, 0x00A3, 0x0092, 0x0005, 0x0034, 0x0067, 0x0056, 0x0078,
0x0049, 0x001A, 0x002B, 0x00BC, 0x008D, 0x00DE, 0x00EF,
// F
0x0082, 0x00B3, 0x00E0, 0x00D1, 0x0046, 0x0077, 0x0024, 0x0015, 0x003B,
0x000A, 0x0059, 0x0068, 0x00FF, 0x00CE, 0x009D, 0x00AC};
namespace Ui {
class CommandWidget;
@ -89,19 +82,12 @@ public:
explicit CommandWidget(QWidget *parent = nullptr);
~CommandWidget();
QUdpSocket *udpSocket = nullptr;
signals:
void startConnectionSignal(QString ip, int port);
void stopConnectionSignal();
void sendErrorMessage(QString message, int type);
void changeVideoLayout(int index);
private slots:
void on_startConnectionToolBtn_clicked();
private slots:
void receiveMessageSlots(QString message, int type);
void on_pushButton_clicked();
void on_pushButton_2_clicked();
@ -136,25 +122,18 @@ private slots:
void on_pushButton_15_clicked();
void on_videoLayout1TBtn_clicked();
void on_videoLayout4TBtn_clicked();
private:
Ui::CommandWidget *ui;
QUdpSocket *m_commandUdpSocket = nullptr;
QString m_remoteIP;
int m_remotePort;
unsigned char getCrc(quint8* data, quint8 length);
unsigned char getCrc(quint8 *data, quint8 length);
ProtocalKB EncodeCommandCmd(quint8 cmd);
bool writeBufferToClient(const QByteArray &data);
void buttonResponse(quint8 cmd);
};
#endif // COMMANDWIDGET_H

@ -21,13 +21,13 @@
<number>4</number>
</property>
<property name="topMargin">
<number>4</number>
<number>0</number>
</property>
<property name="rightMargin">
<number>4</number>
<number>2</number>
</property>
<property name="bottomMargin">
<number>4</number>
<number>0</number>
</property>
<item>
<widget class="QFrame" name="frame">
@ -61,169 +61,135 @@
<property name="leftMargin">
<number>6</number>
</property>
<property name="topMargin">
<number>8</number>
</property>
<property name="rightMargin">
<number>6</number>
</property>
<property name="bottomMargin">
<number>6</number>
</property>
<property name="spacing">
<number>14</number>
</property>
<item row="1" column="0">
<widget class="QPushButton" name="pushButton">
<property name="text">
<string>方位+</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QPushButton" name="pushButton_4">
<item row="4" column="0">
<widget class="QPushButton" name="pushButton_10">
<property name="text">
<string>俯仰+</string>
<string>红外小</string>
</property>
</widget>
</item>
<item row="1" column="2">
<item row="0" column="2">
<widget class="QPushButton" name="pushButton_8">
<property name="text">
<string>画中画开</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QPushButton" name="pushButton_2">
<property name="text">
<string>方位-</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QPushButton" name="pushButton_3">
<property name="text">
<string>俯仰-</string>
</property>
</widget>
</item>
<item row="2" column="2">
<item row="1" column="2">
<widget class="QPushButton" name="pushButton_7">
<property name="text">
<string>画中画关</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QPushButton" name="pushButton_5">
<item row="5" column="2">
<widget class="QPushButton" name="pushButton_15">
<property name="text">
<string>变焦推远</string>
<string>4-6图拼接</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QPushButton" name="pushButton_14">
<item row="4" column="1">
<widget class="QPushButton" name="pushButton_17">
<property name="text">
<string>扫描</string>
<string>图像切换</string>
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="QPushButton" name="pushButton_12">
<item row="2" column="0">
<widget class="QPushButton" name="pushButton_5">
<property name="text">
<string>复位</string>
<string>变焦推远</string>
</property>
</widget>
</item>
<item row="4" column="0">
<item row="3" column="0">
<widget class="QPushButton" name="pushButton_6">
<property name="text">
<string>变焦拉近</string>
</property>
</widget>
</item>
<item row="4" column="1">
<item row="3" column="1">
<widget class="QPushButton" name="pushButton_13">
<property name="text">
<string>吊舱</string>
</property>
</widget>
</item>
<item row="4" column="2">
<widget class="QPushButton" name="pushButton_11">
<property name="text">
<string>锁定</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QPushButton" name="pushButton_10">
<widget class="QPushButton" name="pushButton_9">
<property name="text">
<string>红外</string>
<string>红外大</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QPushButton" name="pushButton_17">
<item row="2" column="2">
<widget class="QPushButton" name="pushButton_12">
<property name="text">
<string>图像切换</string>
<string>复位</string>
</property>
</widget>
</item>
<item row="5" column="2">
<widget class="QPushButton" name="pushButton_16">
<item row="2" column="1">
<widget class="QPushButton" name="pushButton_14">
<property name="text">
<string>0-3图拼接</string>
<string>扫描</string>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QPushButton" name="pushButton_9">
<item row="3" column="2">
<widget class="QPushButton" name="pushButton_11">
<property name="text">
<string>红外大</string>
<string>锁定</string>
</property>
</widget>
</item>
<item row="6" column="2">
<widget class="QPushButton" name="pushButton_15">
<item row="0" column="1">
<widget class="QPushButton" name="pushButton_4">
<property name="text">
<string>4-6图拼接</string>
<string>俯仰+</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QToolButton" name="startConnectionToolBtn">
<widget class="QPushButton" name="pushButton">
<property name="text">
<string>连接</string>
<string>方位+</string>
</property>
</widget>
</item>
<item row="0" column="1" colspan="2">
<widget class="QWidget" name="widget" native="true">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QToolButton" name="videoLayout1TBtn">
<item row="1" column="0">
<widget class="QPushButton" name="pushButton_2">
<property name="text">
<string>...</string>
<string>方位-</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="videoLayout4TBtn">
<item row="1" column="1">
<widget class="QPushButton" name="pushButton_3">
<property name="text">
<string>...</string>
<string>俯仰-</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
<item row="4" column="2">
<widget class="QPushButton" name="pushButton_16">
<property name="text">
<string>0-3图拼接</string>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
</layout>

@ -50,7 +50,7 @@
<number>2</number>
</property>
<item>
<layout class="QGridLayout" name="gridLayout" columnstretch="1,0">
<layout class="QGridLayout" name="gridLayout" columnstretch="1,2">
<property name="leftMargin">
<number>4</number>
</property>
@ -115,7 +115,7 @@
<item row="3" column="1">
<widget class="QSpinBox" name="remotePort">
<property name="buttonSymbols">
<enum>QAbstractSpinBox::NoButtons</enum>
<enum>QAbstractSpinBox::ButtonSymbols::NoButtons</enum>
</property>
<property name="maximum">
<number>65534</number>
@ -137,7 +137,7 @@
<item row="4" column="1">
<widget class="QSpinBox" name="localPort">
<property name="buttonSymbols">
<enum>QAbstractSpinBox::NoButtons</enum>
<enum>QAbstractSpinBox::ButtonSymbols::NoButtons</enum>
</property>
<property name="maximum">
<number>65534</number>
@ -154,7 +154,7 @@
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@ -179,7 +179,7 @@
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>

@ -1,10 +1,10 @@
#include "global.h"
QSettings* g_networkSettingInfo;
QUdpSocket* g_CommandudpSocket;
PullStreamInfoStruct g_pullStreamInfoStruct;
PushStreamInfoStruct g_pushStreamInfoStruct;
void getLocalIP(QStringList& localIPList) {
QHostInfo hostInfo = QHostInfo::fromName(QHostInfo::localHostName());
@ -86,8 +86,8 @@ QString calculateMD5(const QString& str) {
* @param expireTime: 1h
* @return
*/
QString generatePushURL(int uavID, QString appName, QString pushKey,
QString uavName, int clientID, QString pushDomain,
QString generatePushURL(int uavID, QString uavName, QString appName,
QString pushKey, int clientID, QString pushDomain,
long expireTime) {
QString clientName = "";
if (0 == clientID) {
@ -126,8 +126,8 @@ std::map<int, std::string> g_mapAppName;
* @param pullKey: Key
* @return
*/
QString generatePullURL(int uavID, QString appName, QString pullKey,
QString uavName, int clientID, QString pullDomain,
QString generatePullURL(int uavID, QString uavName, QString appName,
QString pullKey, int clientID, QString pullDomain,
long expireTime) {
QString rtmpUrl = "";
QString clientName = "";
@ -160,7 +160,7 @@ QString generatePullURL(int uavID, QString appName, QString pullKey,
* @param uavName:981cs
* @return
*/
QString generatePushURL2(int uavID, QString appName, QString uavName,
QString generatePushURL2(int uavID, QString uavName, QString appName,
int clientID, QString pushDomain) {
QString rtmpUrl = "";
QString clientName = "";
@ -184,7 +184,7 @@ QString generatePushURL2(int uavID, QString appName, QString uavName,
* @param pullDomain:
* @return
*/
QString generatePullURL2(int uavID, QString appName, QString uavName,
QString generatePullURL2(int uavID, QString uavName, QString appName,
int clientID, QString pullDomain) {
QString clientName = "";
if (0 == clientID) {

@ -11,8 +11,34 @@
#include <QSettings>
#include <QStringList>
#include <QUdpSocket>
struct NetworkIPStruct {
QString localIP;
QString remoteIP;
uint localPort;
uint remotePort;
};
struct PullStreamInfoStruct {
QString podPullIP;
QString pullIP1;
QString pullIP2;
QString pullIP3;
QString pullIP4;
};
struct PushStreamInfoStruct {
QString uavType;
int uavID;
int pushType;
QString pushStreamIP;
};
extern QSettings* g_networkSettingInfo;
extern QUdpSocket* g_CommandudpSocket;
extern PullStreamInfoStruct g_pullStreamInfoStruct;
extern PushStreamInfoStruct g_pushStreamInfoStruct;
extern void getLocalIP(QStringList& localIPList);
@ -22,13 +48,6 @@ extern bool isValidIPAddress(const QString& ip);
extern bool isMulticastAddress(const QString& ip);
struct NetworkIPStruct {
QString localIP;
QString remoteIP;
uint localPort;
uint remotePort;
};
// enum NotificationType {
// NOTIFICATION_INFORMATION = 0,
// NOTIFICATION_SUCCESS = 1,
@ -54,7 +73,7 @@ extern QString calculateMD5(const QString& str);
/**
* @brief
* @param uavID: ID
* @param uavName: 981cs
* @param uavName: 98
* @param clientID: ID01
* @param pushDomain:
* @param appName
@ -62,9 +81,10 @@ extern QString calculateMD5(const QString& str);
* @param pushKey: Key
* @return
*/
extern QString generatePushURL(int uavID, QString appName = "nmyj",
extern QString generatePushURL(int uavID, QString uavName = "fp98",
QString appName = "videoclient",
QString pushKey = "ZRjGVcPYGhKib0rdgH",
QString uavName = "981cs", int clientID = 0,
int clientID = 0,
QString pushDomain = "push.uavideo.cn",
long expireTime = 6 * 3600);
@ -73,28 +93,30 @@ extern QString generatePushURL(int uavID, QString appName = "nmyj",
* @param uavID:ID
* @param clientID: ID01
* @param appName:
* @param uavName:981cs
* @param uavName:98
* @param pushDomain:
* @return
*/
extern QString generatePushURL2(int uavID, QString appName = "nmyj",
QString uavName = "981cs", int clientID = 0,
extern QString generatePushURL2(int uavID, QString uavName = "fp98",
QString appName = "videoclient",
int clientID = 0,
QString pushDomain = "182.92.130.23");
/**
* @brief
* @param uavID: ID
* @param appName: app
* @param uavName: 981cs
* @param uavName: 98
* @param clientID: ID01
* @param pullDomain:
* @param expireTime: 1h
* @param pullKey: Key
* @return
*/
extern QString generatePullURL(int uavID, QString appName = "nmyj",
extern QString generatePullURL(int uavID, QString uavName = "fp98",
QString appName = "videoclient",
QString pullKey = "HDaMVkLnIcr0mGhV8d",
QString uavName = "981cs", int clientID = 0,
int clientID = 0,
QString pullDomain = "play.uavideo.cn",
long expireTime = 6 * 3600);
@ -102,13 +124,14 @@ extern QString generatePullURL(int uavID, QString appName = "nmyj",
* @brief
* @param uavID: ID
* @param appName: app
* @param uavName: 981cs
* @param uavName: 98
* @param clientID: ID01
* @param pullDomain:
* @return
*/
extern QString generatePullURL2(int uavID, QString appName = "nmyj",
QString uavName = "981cs", int clientID = 0,
extern QString generatePullURL2(int uavID, QString uavName = "fp98",
QString appName = "videoclient",
int clientID = 0,
QString pullDomain = "182.92.130.23");
class Global {

@ -56,8 +56,6 @@ MainWindow::MainWindow(QWidget *parent)
initNotifyManager();
initNotifyMessageConnection();
initCommunitions();
initChangeVideoLayoutConnection();
initHideButton();
@ -68,7 +66,6 @@ MainWindow::MainWindow(QWidget *parent)
// ui->videoWidget2->play(list.at(0));
// ui->videoWidget3->play(list.at(0));
// ui->videoWidget4->play(list.at(0));
}
MainWindow::~MainWindow() {
@ -99,15 +96,22 @@ void MainWindow::paintEvent(QPaintEvent *ev) {
hideCommandWidgetBtn->move(ui->stackedWidget->width() - offset,
ui->commandWidget->height() / 2);
int i = 0;
}
void MainWindow::initSignalConnection() {
connect(ui->commandWidget, &CommandWidget::startConnectionSignal,
connect(ui->videoControlWidget, &VideoControl::startConnectionSignal,
ui->videoWidget, &VideoWidget::udpPlay, Qt::UniqueConnection);
connect(ui->commandWidget, &CommandWidget::stopConnectionSignal,
connect(ui->videoControlWidget, &VideoControl::stopConnectionSignal,
ui->videoWidget, &VideoWidget::stopPlay, Qt::UniqueConnection);
connect(&streamAddrSettingsDlg,
&StreamAddrSettingsDlg::startPullStreamSignal, this,
&MainWindow::pullStreamSlot);
connect(&streamAddrSettingsDlg,
&StreamAddrSettingsDlg::startPushStreamSignal, this,
&MainWindow::pushStreamSlot);
}
void MainWindow::initNotifyMessageConnection() {
@ -117,15 +121,13 @@ void MainWindow::initNotifyMessageConnection() {
&MainWindow::showMessageSlots);
}
void MainWindow::initChangeVideoLayoutConnection() {
connect(ui->commandWidget, &CommandWidget::changeVideoLayout, this,
connect(ui->videoControlWidget, &VideoControl::changeVideoLayout, this,
[=](int index) {
ui->stackedWidget->setCurrentIndex(index);
});
}
void MainWindow::initNotifyManager() {
m_notifyManager = new NotifyManager(this, this);
m_notifyManager->setMaxCount(5);
@ -133,21 +135,6 @@ void MainWindow::initNotifyManager() {
m_notifyManager->setNotifyWndSize(400, 60);
}
void MainWindow::initCommunitions()
{
g_CommandudpSocket = new QUdpSocket(this);
// 将套接字绑定到指定端口
if (g_CommandudpSocket->bind(QHostAddress::Any, 1200)) {
qDebug() << "UDP 套接字已绑定到端口 1200";
} else {
qDebug() << "绑定 UDP 套接字失败";
}
}
void MainWindow::showMessageSlots(QString message, int type) {
if (m_notifyManager) {
m_notifyManager->notify(message, "", type, 3000);
@ -334,3 +321,80 @@ void MainWindow::openSavedVideoDirSlot() {
QDesktopServices::openUrl(
QUrl(QApplication::applicationDirPath() + "/video"));
}
// 拉流
void MainWindow::pullStreamSlot(bool bPull) {
if (!g_networkSettingInfo) return;
if (bPull) {
QString podPullStreamIP =
g_networkSettingInfo->value("NetworkStreamSettings/podPullAddress")
.toString();
QString pullStreamIP1 =
g_networkSettingInfo->value("NetworkStreamSettings/pullAddress1")
.toString();
QString pullStreamIP2 =
g_networkSettingInfo->value("NetworkStreamSettings/pullAddress2")
.toString();
QString pullStreamIP3 =
g_networkSettingInfo->value("NetworkStreamSettings/pullAddress3")
.toString();
QString pullStreamIP4 =
g_networkSettingInfo->value("NetworkStreamSettings/pullAddress4")
.toString();
ui->videoWidget->play(g_pullStreamInfoStruct.podPullIP);
ui->videoWidget1->play(g_pullStreamInfoStruct.pullIP1);
ui->videoWidget2->play(g_pullStreamInfoStruct.pullIP2);
ui->videoWidget3->play(g_pullStreamInfoStruct.pullIP3);
ui->videoWidget4->play(g_pullStreamInfoStruct.pullIP4);
} else {
ui->videoWidget->stopPlay();
ui->videoWidget1->stopPlay();
ui->videoWidget2->stopPlay();
ui->videoWidget3->stopPlay();
ui->videoWidget4->stopPlay();
}
}
// 推流
void MainWindow::pushStreamSlot(bool bPush) {
if (!g_networkSettingInfo) return;
if (bPush) {
// int uavType =
// g_networkSettingInfo->value("NetworkStreamSettings/uavType")
// .toInt();
// int uavID =
// g_networkSettingInfo->value("NetworkStreamSettings/uavID").toInt();
// int pushStreamIndex =
// g_networkSettingInfo->value("NetworkStreamSettings/pushStreamType")
// .toInt();
// if (2 == pushStreamIndex) {
// QString pushStreamIP =
// g_networkSettingInfo
// ->value("NetworkStreamSettings/pushStreamAddress")
// .toString();
// }
int pushStreamType = g_pushStreamInfoStruct.pushType;
QString pushStreamIP;
if (pushStreamType == 0) { // 公司服务器
pushStreamIP = generatePushURL2(g_pushStreamInfoStruct.uavID,
g_pushStreamInfoStruct.uavType);
qDebug() << pushStreamIP;
} else if (pushStreamType == 1) { // 阿里云服务器
pushStreamIP = generatePushURL(g_pushStreamInfoStruct.uavID,
g_pushStreamInfoStruct.uavType);
qDebug() << pushStreamIP;
} else {
pushStreamIP = g_pushStreamInfoStruct.pushStreamIP;
}
ui->videoWidget->pushStream(pushStreamIP);
} else {
ui->videoWidget->stopPushStream();
// ui->videoWidget1->stopPushStream();
// ui->videoWidget2->stopPushStream();
// ui->videoWidget3->stopPushStream();
// ui->videoWidget4->stopPushStream();
}
}

@ -12,6 +12,7 @@
#include "communicationsettingdlg.h"
#include "global.h"
#include "streamaddrsettingsdlg.h"
#include "videoControl.h"
#include "videowidget.h"
#ifdef Q_OS_WIN
@ -57,7 +58,6 @@ private:
void initNotifyManager();
void showMessageSlots(QString message, int type);
void initCommunitions();
void installWindowAgent();
void loadStyleSheet(Theme theme);
@ -70,6 +70,9 @@ private slots:
void hideCommandWidgetSlot();
void openSavedVideoDirSlot();
void pullStreamSlot(bool bPull);
void pushStreamSlot(bool bPush);
private:
Ui::MainWindow *ui;
VideoWidget *videoWidget1 = nullptr;

@ -19,19 +19,19 @@
<number>4</number>
</property>
<property name="leftMargin">
<number>2</number>
<number>0</number>
</property>
<property name="topMargin">
<number>2</number>
<number>0</number>
</property>
<property name="rightMargin">
<number>2</number>
</property>
<property name="bottomMargin">
<number>2</number>
<number>0</number>
</property>
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<layout class="QVBoxLayout" name="verticalLayout" stretch="15,1">
<property name="spacing">
<number>4</number>
</property>
@ -46,16 +46,16 @@
<widget class="QWidget" name="page_3">
<layout class="QHBoxLayout" name="horizontalLayout_7">
<property name="leftMargin">
<number>2</number>
<number>0</number>
</property>
<property name="topMargin">
<number>2</number>
<number>0</number>
</property>
<property name="rightMargin">
<number>2</number>
</property>
<property name="bottomMargin">
<number>2</number>
<number>0</number>
</property>
<item>
<widget class="VideoWidget" name="videoWidget"/>
@ -65,16 +65,16 @@
<widget class="QWidget" name="page_4">
<layout class="QHBoxLayout" name="horizontalLayout_4">
<property name="leftMargin">
<number>2</number>
<number>0</number>
</property>
<property name="topMargin">
<number>2</number>
<number>0</number>
</property>
<property name="rightMargin">
<number>2</number>
</property>
<property name="bottomMargin">
<number>2</number>
<number>0</number>
</property>
<item>
<layout class="QGridLayout" name="gridLayout">
@ -100,81 +100,7 @@
</widget>
</item>
<item>
<widget class="QWidget" name="widget_3" native="true">
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>4</number>
</property>
<property name="leftMargin">
<number>2</number>
</property>
<property name="topMargin">
<number>2</number>
</property>
<property name="rightMargin">
<number>2</number>
</property>
<property name="bottomMargin">
<number>2</number>
</property>
<item>
<layout class="QGridLayout" name="gridLayout_2" columnstretch="1,10,1">
<property name="verticalSpacing">
<number>4</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>00:00:00</string>
</property>
<property name="alignment">
<set>Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter</set>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="WProgressBar" name="widget_2" native="true"/>
</item>
<item row="0" column="2">
<widget class="QLabel" name="label_2">
<property name="text">
<string>00:00:00</string>
</property>
</widget>
</item>
<item row="1" column="0">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>37</width>
<height>17</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="1">
<widget class="VideoControl" name="widget" native="true"/>
</item>
<item row="1" column="2">
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="VideoControl" name="videoControlWidget" native="true"/>
</item>
</layout>
</item>
@ -212,12 +138,6 @@
<header>videoControl.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>WProgressBar</class>
<extends>QWidget</extends>
<header>wprogressbar.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

@ -46,28 +46,7 @@ void StreamAddrSettingsDlg::on_saveBtn_clicked() {
return;
}
g_networkSettingInfo->setValue("NetworkStreamSettings/uavType",
ui->uavTypeCombox->currentIndex());
g_networkSettingInfo->setValue("NetworkStreamSettings/uavID",
ui->uavIDspinBox->value());
g_networkSettingInfo->setValue("NetworkStreamSettings/podPullAddress",
ui->podPullStreamIPEdit->text());
g_networkSettingInfo->setValue("NetworkStreamSettings/pullAddress1",
ui->pullStreamAddrEdit1->text());
g_networkSettingInfo->setValue("NetworkStreamSettings/pullAddress2",
ui->pullStreamAddrEdit2->text());
g_networkSettingInfo->setValue("NetworkStreamSettings/pullAddress3",
ui->pullStreamAddrEdit3->text());
g_networkSettingInfo->setValue("NetworkStreamSettings/pullAddress4",
ui->pullStreamAddrEdit4->text());
int pushStreamIndex = ui->pushStreamIPCombox->currentIndex();
g_networkSettingInfo->setValue("NetworkStreamSettings/pushStreamType",
pushStreamIndex);
if (2 == pushStreamIndex) {
g_networkSettingInfo->setValue(
"NetworkStreamSettings/pushStreamAddress",
ui->pushStreamIPCombox->currentText());
}
saveParms();
this->close();
}
@ -105,3 +84,76 @@ void StreamAddrSettingsDlg::initSavedParms() {
.toString());
}
}
void StreamAddrSettingsDlg::saveParms() {
g_networkSettingInfo->setValue("NetworkStreamSettings/uavType",
ui->uavTypeCombox->currentIndex());
g_pushStreamInfoStruct.uavType = ui->uavTypeCombox->currentText().toLower();
g_networkSettingInfo->setValue("NetworkStreamSettings/uavID",
ui->uavIDspinBox->value());
g_pushStreamInfoStruct.uavID = ui->uavIDspinBox->value();
g_networkSettingInfo->setValue("NetworkStreamSettings/podPullAddress",
ui->podPullStreamIPEdit->text());
g_pullStreamInfoStruct.podPullIP = ui->podPullStreamIPEdit->text();
g_networkSettingInfo->setValue("NetworkStreamSettings/pullAddress1",
ui->pullStreamAddrEdit1->text());
g_pullStreamInfoStruct.pullIP1 = ui->pullStreamAddrEdit1->text();
g_networkSettingInfo->setValue("NetworkStreamSettings/pullAddress2",
ui->pullStreamAddrEdit2->text());
g_pullStreamInfoStruct.pullIP2 = ui->pullStreamAddrEdit2->text();
g_networkSettingInfo->setValue("NetworkStreamSettings/pullAddress3",
ui->pullStreamAddrEdit3->text());
g_pullStreamInfoStruct.pullIP3 = ui->pullStreamAddrEdit3->text();
g_networkSettingInfo->setValue("NetworkStreamSettings/pullAddress4",
ui->pullStreamAddrEdit4->text());
g_pullStreamInfoStruct.pullIP4 = ui->pullStreamAddrEdit4->text();
int pushStreamIndex = ui->pushStreamIPCombox->currentIndex();
g_networkSettingInfo->setValue("NetworkStreamSettings/pushStreamType",
pushStreamIndex);
g_pushStreamInfoStruct.pushType = pushStreamIndex;
if (2 == pushStreamIndex) {
g_networkSettingInfo->setValue(
"NetworkStreamSettings/pushStreamAddress",
ui->pushStreamIPCombox->currentText());
g_pushStreamInfoStruct.pushStreamIP =
ui->pushStreamIPCombox->currentText();
}
}
// 拉流
void StreamAddrSettingsDlg::on_pullStreamBtn_clicked() {
ui->pullStreamBtn->setDisabled(true);
saveParms();
if (ui->pullStreamBtn->text() == "开始播放") {
emit startPullStreamSignal(true);
ui->pullStreamBtn->setText("停止播放");
} else {
emit startPullStreamSignal(false);
ui->pullStreamBtn->setText("开始播放");
}
ui->pullStreamBtn->setDisabled(false);
}
// 推流
void StreamAddrSettingsDlg::on_pushStreamBtn_clicked() {
ui->pushStreamBtn->setDisabled(true);
saveParms();
if (ui->pushStreamBtn->text() == "开始推送") {
emit startPushStreamSignal(true);
ui->pushStreamBtn->setText("停止推送");
} else {
emit startPushStreamSignal(false);
ui->pushStreamBtn->setText("开始推送");
}
ui->pushStreamBtn->setDisabled(false);
}

@ -19,13 +19,22 @@ public:
protected:
void showEvent(QShowEvent *event);
signals:
void startPullStreamSignal(bool bPull);
void startPushStreamSignal(bool bPush);
private slots:
void on_pushStreamIPCombox_currentIndexChanged(int index);
void on_saveBtn_clicked();
void on_pullStreamBtn_clicked();
void on_pushStreamBtn_clicked();
private:
void initSavedParms();
void saveParms();
private:
Ui::StreamAddrSettingsDlg *ui;

@ -32,6 +32,18 @@
<string>飞机信息</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<property name="leftMargin">
<number>4</number>
</property>
<property name="topMargin">
<number>4</number>
</property>
<property name="rightMargin">
<number>4</number>
</property>
<property name="bottomMargin">
<number>4</number>
</property>
<item>
<layout class="QGridLayout" name="gridLayout_3" columnstretch="1,4,1,4">
<item row="0" column="0">
@ -159,6 +171,9 @@
<string>推流地址</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>7</number>
</property>
<property name="leftMargin">
<number>4</number>
</property>
@ -173,6 +188,9 @@
</property>
<item>
<layout class="QGridLayout" name="gridLayout_2" columnstretch="1,4" columnminimumwidth="0,0">
<property name="spacing">
<number>4</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
@ -190,6 +208,9 @@
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="spacing">
<number>14</number>
</property>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
@ -210,6 +231,20 @@
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pullStreamBtn">
<property name="text">
<string>开始播放</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushStreamBtn">
<property name="text">
<string>开始推送</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">

@ -6,7 +6,14 @@ VideoControl::VideoControl(QWidget *parent)
: QWidget(parent), ui(new Ui::VideoControl) {
ui->setupUi(this);
// 其他初始化代码...
initIconButton();
}
VideoControl::~VideoControl() {
delete ui;
}
void VideoControl::initIconButton() {
ui->pbPlayer->setIcon(QIcon(":/images/playMedio.png"));
ui->pbPlayer->setIconSize(QSize(32, 32));
ui->pbPlayer->setFixedSize(40, 40);
@ -26,8 +33,85 @@ VideoControl::VideoControl(QWidget *parent)
ui->pbSlow->setIconSize(QSize(24, 24));
ui->pbSlow->setFixedSize(32, 32);
ui->pbSlow->setObjectName("medio");
ui->videoLayout1Btn->setIcon(QIcon(":/images/videolayout1.png"));
ui->videoLayout1Btn->setIconSize(QSize(20, 20));
ui->videoLayout1Btn->setFixedSize(30, 30);
ui->videoLayout4Btn->setIcon(QIcon(":/images/videolayout4.png"));
ui->videoLayout4Btn->setIconSize(QSize(20, 20));
ui->videoLayout4Btn->setFixedSize(30, 30);
}
VideoControl::~VideoControl() {
delete ui;
void VideoControl::receiveMessageSlots(QString message, int type) {
emit sendErrorMessage(message, type);
}
void VideoControl::on_videoLayout1Btn_clicked() {
ui->videoLayout1Btn->setDisabled(true);
emit changeVideoLayout(0);
ui->videoLayout1Btn->setDisabled(false);
}
void VideoControl::on_videoLayout4Btn_clicked() {
ui->videoLayout4Btn->setDisabled(true);
emit changeVideoLayout(1);
ui->videoLayout4Btn->setDisabled(false);
}
// 连接
void VideoControl::on_pbPlayer_clicked() {
ui->pbPlayer->setDisabled(true);
if (!g_networkSettingInfo) {
qWarning() << "Network settings are not initialized!";
ui->pbPlayer->setDisabled(false);
return;
}
int dataSourceType = g_networkSettingInfo->value("DataSource").toInt();
QString groupName = "";
switch (dataSourceType) {
case 0:
groupName = "LLink";
break;
case 1:
groupName = "SATCOM1";
break;
case 2:
groupName = "SATCOM2";
break;
default:
qWarning() << "Unknown data source type:" << dataSourceType;
return;
}
m_remoteIP =
g_networkSettingInfo->value(groupName + "/remoteIP").toString();
m_remotePort =
g_networkSettingInfo->value(groupName + "/remotePort").toInt();
int localPort =
g_networkSettingInfo->value(groupName + "/localPort").toInt();
QString localIP =
g_networkSettingInfo->value(groupName + "/localIP").toString();
// 校验 IP 和端口
if (m_remoteIP.isEmpty() || m_remotePort <= 0 || localIP.isEmpty() ||
localPort <= 0) {
qWarning() << "Invalid IP or port configuration!";
ui->pbPlayer->setDisabled(false);
return;
}
if (dataSourceType == 0) { // 组播
qDebug() << "Starting multicast connection to" << m_remoteIP << ":"
<< m_remotePort;
emit startConnectionSignal(m_remoteIP, m_remotePort);
} else { // 单播
qDebug() << "Starting unicast connection on" << localIP << ":"
<< localPort;
emit startConnectionSignal(localIP, localPort);
}
ui->pbPlayer->setDisabled(false);
}

@ -3,28 +3,40 @@
#include <QWidget>
#include "global.h"
namespace Ui {
class VideoControl;
}
class VideoControl : public QWidget {
Q_OBJECT
public:
explicit VideoControl(QWidget *parent = nullptr);
~VideoControl();
private:
void initIconButton();
signals:
void startConnectionSignal(QString ip, int port);
void stopConnectionSignal();
void sendErrorMessage(QString message, int type);
void changeVideoLayout(int index);
private slots:
void receiveMessageSlots(QString message, int type);
void on_videoLayout1Btn_clicked();
void on_videoLayout4Btn_clicked();
void on_pbPlayer_clicked();
private:
Ui::VideoControl *ui;
QString m_remoteIP;
int m_remotePort;
};
#endif // VIDEOCONTROL_H

@ -6,19 +6,102 @@
<rect>
<x>0</x>
<y>0</y>
<width>450</width>
<height>53</height>
<width>681</width>
<height>83</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<property name="spacing">
<number>4</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>4</number>
</property>
<item>
<layout class="QGridLayout" name="gridLayout" rowstretch="0,0" columnstretch="1,4,4,1">
<property name="horizontalSpacing">
<number>6</number>
</property>
<property name="verticalSpacing">
<number>4</number>
</property>
<item row="1" column="3">
<widget class="QWidget" name="widget_3" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="spacing">
<number>5</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>15</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="videoLayout1Btn">
<property name="text">
<string/>
</property>
<property name="flat">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="videoLayout4Btn">
<property name="text">
<string/>
</property>
<property name="flat">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="1" column="1" colspan="2">
<widget class="QWidget" name="widget_2" native="true">
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>7</number>
</property>
<property name="leftMargin">
<number>2</number>
</property>
<property name="topMargin">
<number>2</number>
<number>0</number>
</property>
<property name="rightMargin">
<number>2</number>
@ -33,7 +116,7 @@
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<width>120</width>
<height>20</height>
</size>
</property>
@ -86,7 +169,7 @@
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<width>120</width>
<height>20</height>
</size>
</property>
@ -94,6 +177,84 @@
</item>
</layout>
</widget>
</item>
<item row="0" column="3">
<widget class="QLabel" name="label_2">
<property name="text">
<string>00:00:00</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="layoutDirection">
<enum>Qt::LayoutDirection::RightToLeft</enum>
</property>
<property name="text">
<string>00:00:00</string>
</property>
<property name="alignment">
<set>Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter</set>
</property>
</widget>
</item>
<item row="0" column="1" colspan="2">
<widget class="QSlider" name="horizontalSlider">
<property name="styleSheet">
<string notr="true">/*滑块的样式*/
QSlider::groove:horizontal {
border: 1px solid #64AA64;
background: #64AA64;
height: 2px;
border-radius: 1px;
padding-left:0px;
padding-right:0px;
}
/*滑块经过的颜色:前面的颜色*/
QSlider::sub-page:horizontal {
background: #64AA64;
border: 1px solid #64AA64;
height: 2px;
border-radius: 2px;
}
QSlider::add-page:horizontal {
background: #EAEAEA;
border: 0px solid #EAEAEA;
height: 2px;
border-radius: 2px;
}
QSlider::handle:horizontal
{
background: qradialgradient(spread:pad, cx:0.5, cy:0.5, radius:0.5, fx:0.5, fy:0.5,
stop:0.6 #64AA64,stop:0.98409 rgba(255, 255, 255, 255));
width: 15px;
margin-top: -6px;
margin-bottom: -6px;
border-radius: 5px;
}
QSlider::handle:horizontal:hover {
background: qradialgradient(spread:pad, cx:0.5, cy:0.5, radius:0.5, fx:0.5, fy:0.5,
stop:0.6 #64AA64,stop:0.98409 rgba(255, 255, 255, 255));
width: 15px;
margin-top: -6px;
margin-bottom: -6px;
border-radius: 5px;
}</string>
</property>
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

Loading…
Cancel
Save