diff --git a/src/commandwidget.cpp b/src/commandwidget.cpp index a18b525..829c58b 100644 --- a/src/commandwidget.cpp +++ b/src/commandwidget.cpp @@ -6,254 +6,142 @@ 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 pBuff = std::make_unique(); - pBuff->head[0] = PROTOCOL_HEAD_0; - pBuff->head[1] = PROTOCOL_HEAD_1; - pBuff->reserved = PROTOCOL_RESERVED; + pBuff->head[0] = PROTOCOL_HEAD_0; + pBuff->head[1] = PROTOCOL_HEAD_1; + pBuff->reserved = PROTOCOL_RESERVED; pBuff->data[0] = cmd; pBuff->data[1] = cmd; pBuff->data[2] = cmd; - pBuff->curPage = PROTOCOL_CUR_PAGE; - quint8 *ptr = reinterpret_cast(&pBuff); + pBuff->curPage = PROTOCOL_CUR_PAGE; + quint8 *ptr = reinterpret_cast(&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 地址 + 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(&packet), sizeof(ProtocalKB)); - for(int i=0;i<3;i++) - { + data.append(reinterpret_cast(&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() -{ - buttonResponse(0x7D); +void CommandWidget::on_pushButton_5_clicked() { + buttonResponse(0x7D); } - -void CommandWidget::on_pushButton_6_clicked() -{ - buttonResponse(0x7C); +void CommandWidget::on_pushButton_6_clicked() { + buttonResponse(0x7C); } - -void CommandWidget::on_pushButton_10_clicked() -{ - buttonResponse(0x69); +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() -{ - buttonResponse(0x78); +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); -} - diff --git a/src/commandwidget.h b/src/commandwidget.h index aa64753..f042863 100644 --- a/src/commandwidget.h +++ b/src/commandwidget.h @@ -3,17 +3,17 @@ #include #include -#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 diff --git a/src/commandwidget.ui b/src/commandwidget.ui index 671a1c1..daed3d5 100644 --- a/src/commandwidget.ui +++ b/src/commandwidget.ui @@ -21,13 +21,13 @@ 4 - 4 + 0 - 4 + 2 - 4 + 0 @@ -61,171 +61,137 @@ 6 + + 8 + 6 + + 6 + 14 - - + + - 方位+ + 红外小 - - + + - 俯仰+ + 画中画开 - + - 画中画开 + 画中画关 - - + + - 方位- + 4-6图拼接 - - + + - 俯仰- + 图像切换 - - + + - 画中画关 + 变焦推远 - + - 变焦推远 + 变焦拉近 - + - 扫描 + 吊舱 - - + + - 复位 + 红外大 - - + + - 变焦拉近 + 复位 - - + + - 吊舱 + 扫描 - + 锁定 - - + + - 红外小 + 俯仰+ - - + + - 图像切换 + 方位+ - - + + - 0-3图拼接 + 方位- - - + + - 红外大 + 俯仰- - - + + - 4-6图拼接 + 0-3图拼接 - - - - 连接 - - - - - - - - - - ... - - - - - - - ... - - - - - - - Qt::Orientation::Horizontal - - - - 40 - 20 - - - - - - - diff --git a/src/communicationsettingdlg.ui b/src/communicationsettingdlg.ui index 9e7ee6b..aa2fb4f 100644 --- a/src/communicationsettingdlg.ui +++ b/src/communicationsettingdlg.ui @@ -50,7 +50,7 @@ 2 - + 4 @@ -115,7 +115,7 @@ - QAbstractSpinBox::NoButtons + QAbstractSpinBox::ButtonSymbols::NoButtons 65534 @@ -137,7 +137,7 @@ - QAbstractSpinBox::NoButtons + QAbstractSpinBox::ButtonSymbols::NoButtons 65534 @@ -154,7 +154,7 @@ - Qt::Horizontal + Qt::Orientation::Horizontal @@ -179,7 +179,7 @@ - Qt::Horizontal + Qt::Orientation::Horizontal diff --git a/src/global.cpp b/src/global.cpp index 249eb3b..7c77b18 100644 --- a/src/global.cpp +++ b/src/global.cpp @@ -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 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) { diff --git a/src/global.h b/src/global.h index 7b48102..0323079 100644 --- a/src/global.h +++ b/src/global.h @@ -11,8 +11,34 @@ #include #include #include + +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: 客户端ID,0为地面端,1为载荷端。 * @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: 客户端ID,0为地面端,1为载荷端。 * @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: 数据推流端ID,0为地面端,1为载荷端。 * @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: 数据推流端ID,0为地面端,1为载荷端。 * @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 { diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index a450dbf..07cd481 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -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(); + } +} diff --git a/src/mainwindow.h b/src/mainwindow.h index 27a1d44..aad63ea 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -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; diff --git a/src/mainwindow.ui b/src/mainwindow.ui index f172b02..51eb3aa 100644 --- a/src/mainwindow.ui +++ b/src/mainwindow.ui @@ -19,19 +19,19 @@ 4 - 2 + 0 - 2 + 0 2 - 2 + 0 - + 4 @@ -46,16 +46,16 @@ - 2 + 0 - 2 + 0 2 - 2 + 0 @@ -65,16 +65,16 @@ - 2 + 0 - 2 + 0 2 - 2 + 0 @@ -100,81 +100,7 @@ - - - - 4 - - - 2 - - - 2 - - - 2 - - - 2 - - - - - 4 - - - - - 00:00:00 - - - Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter - - - - - - - - - - 00:00:00 - - - - - - - Qt::Orientation::Horizontal - - - - 37 - 17 - - - - - - - - - - - Qt::Orientation::Horizontal - - - - 40 - 20 - - - - - - - - + @@ -212,12 +138,6 @@
videoControl.h
1 - - WProgressBar - QWidget -
wprogressbar.h
- 1 -
diff --git a/src/resources/images/pullStream.png b/src/resources/images/pullStream.png new file mode 100644 index 0000000..81c4ca5 Binary files /dev/null and b/src/resources/images/pullStream.png differ diff --git a/src/resources/images/pullStream1.png b/src/resources/images/pullStream1.png new file mode 100644 index 0000000..8a3448f Binary files /dev/null and b/src/resources/images/pullStream1.png differ diff --git a/src/resources/images/pushStream1.png b/src/resources/images/pushStream1.png new file mode 100644 index 0000000..ca90c6e Binary files /dev/null and b/src/resources/images/pushStream1.png differ diff --git a/src/resources/images/pushStream2.png b/src/resources/images/pushStream2.png new file mode 100644 index 0000000..f470aaa Binary files /dev/null and b/src/resources/images/pushStream2.png differ diff --git a/src/streamaddrsettingsdlg.cpp b/src/streamaddrsettingsdlg.cpp index f3fb37c..564e61f 100644 --- a/src/streamaddrsettingsdlg.cpp +++ b/src/streamaddrsettingsdlg.cpp @@ -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); +} diff --git a/src/streamaddrsettingsdlg.h b/src/streamaddrsettingsdlg.h index b55be0b..4cfbc2c 100644 --- a/src/streamaddrsettingsdlg.h +++ b/src/streamaddrsettingsdlg.h @@ -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; diff --git a/src/streamaddrsettingsdlg.ui b/src/streamaddrsettingsdlg.ui index 0526a55..ac19452 100644 --- a/src/streamaddrsettingsdlg.ui +++ b/src/streamaddrsettingsdlg.ui @@ -32,6 +32,18 @@ 飞机信息
+ + 4 + + + 4 + + + 4 + + + 4 + @@ -159,6 +171,9 @@ 推流地址
+ + 7 + 4 @@ -173,6 +188,9 @@
+ + 4 + @@ -190,6 +208,9 @@ + + 14 + @@ -210,6 +231,20 @@
+ + + + 开始播放 + + + + + + + 开始推送 + + + diff --git a/src/videoControl.cpp b/src/videoControl.cpp index ff1c228..f6fa3d1 100644 --- a/src/videoControl.cpp +++ b/src/videoControl.cpp @@ -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); } diff --git a/src/videoControl.h b/src/videoControl.h index 54f7282..268f989 100644 --- a/src/videoControl.h +++ b/src/videoControl.h @@ -3,28 +3,40 @@ #include +#include "global.h" namespace Ui { class VideoControl; } - class VideoControl : public QWidget { Q_OBJECT - - public: explicit VideoControl(QWidget *parent = nullptr); ~VideoControl(); - private: - Ui::VideoControl *ui; + 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(); -#endif // VIDEOCONTROL_H + void on_pbPlayer_clicked(); +private: + Ui::VideoControl *ui; + + QString m_remoteIP; + int m_remotePort; +}; +#endif // VIDEOCONTROL_H diff --git a/src/videoControl.ui b/src/videoControl.ui index e0eb844..830c5d5 100644 --- a/src/videoControl.ui +++ b/src/videoControl.ui @@ -6,91 +6,252 @@ 0 0 - 450 - 53 + 681 + 83 Form - + + + 4 + - 2 + 0 - 2 + 0 - 2 + 0 - 2 + 4 - - - Qt::Orientation::Horizontal - - - - 40 - 20 - - - - - - - - - - - false - - - - - - - - - - false - - - - - - - - - - false - - - - - - - - - - false - - - - - - - Qt::Orientation::Horizontal + + + 6 - - - 40 - 20 - + + 4 - + + + + + 5 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + Qt::Orientation::Horizontal + + + + 15 + 20 + + + + + + + + + + + false + + + + + + + + + + false + + + + + + + + + + + 7 + + + 2 + + + 0 + + + 2 + + + 2 + + + + + Qt::Orientation::Horizontal + + + + 120 + 20 + + + + + + + + + + + false + + + + + + + + + + false + + + + + + + + + + false + + + + + + + + + + false + + + + + + + Qt::Orientation::Horizontal + + + + 120 + 20 + + + + + + + + + + + 00:00:00 + + + + + + + Qt::LayoutDirection::RightToLeft + + + 00:00:00 + + + Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter + + + + + + + /*滑块的样式*/ +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; +} + + + Qt::Orientation::Horizontal + + + +