This commit is contained in:
wuuhii 2019-12-04 20:06:54 +08:00
parent 9ac2f52724
commit e9fc1ad6d9
3 changed files with 273 additions and 0 deletions

View File

@ -0,0 +1,81 @@
/*
* Copyright (C) 2018-2019 wuuhii. All rights reserved.
*
* The file is encoding with utf-8 (with BOM). It is a part of QtSwissArmyKnife
* project. The project is a open source project, you can get the source from:
* https://github.com/wuuhii/QtSwissArmyKnife
* https://gitee.com/wuuhii/QtSwissArmyKnife
*
* If you want to know more about the project, please join our QQ group(952218522).
* In addition, the email address of the project author is wuuhii@outlook.com.
*/
#include <QList>
#include <QMetaEnum>
#include <QLineEdit>
#include "SAKGlobal.hh"
#include "SAKUdpDeviceController.hh"
#include "ui_SAKUdpDeviceController.h"
SAKUdpDeviceController::SAKUdpDeviceController(QWidget *parent)
:QWidget (parent)
,ui (new Ui::SAKUdpDeviceController)
{
ui->setupUi(this);
localhostComboBox = ui->localhostComboBox;
localPortlineEdit = ui->localPortlineEdit;
enableLocalSettingCheckBox = ui->enableLocalSettingCheckBox;
targetHostLineEdit = ui->targetHostLineEdit;
targetPortLineEdit = ui->targetPortLineEdit;
broadcastCheckBox = ui->broadcastCheckBox;
broadcastPortLineEdit = ui->broadcastPortLineEdit;
multicastCheckBox = ui->multicastCheckBox;
multicastAddressLineEdit = ui->multicastAddressLineEdit;
multicastPortLineEdit = ui->multicastPortLineEdit;
refresh();
}
SAKUdpDeviceController::~SAKUdpDeviceController()
{
delete ui;
}
QString SAKUdpDeviceController::localHost()
{
return localhostComboBox->currentText();
}
quint16 SAKUdpDeviceController::localPort()
{
return static_cast<quint16>(localPortlineEdit->text().toInt());
}
QString SAKUdpDeviceController::targetHost()
{
return targetHostLineEdit->text();
}
quint16 SAKUdpDeviceController::targetPort()
{
return static_cast<quint16>(targetPortLineEdit->text().toInt());
}
bool SAKUdpDeviceController::enableCustomLocalSetting()
{
return enableLocalSettingCheckBox->isChecked();
}
void SAKUdpDeviceController::refresh()
{
SAKGlobal::initIpComboBox(localhostComboBox);
}
void SAKUdpDeviceController::setUiEnable(bool enable)
{
localhostComboBox->setEnabled(enable);
localPortlineEdit->setEnabled(enable);
enableLocalSettingCheckBox->setEnabled(enable);
targetHostLineEdit->setEnabled(enable);
targetPortLineEdit->setEnabled(enable);
}

View File

@ -0,0 +1,53 @@
/*
* Copyright (C) 2018-2019 wuuhii. All rights reserved.
*
* The file is encoding with utf-8 (with BOM). It is a part of QtSwissArmyKnife
* project. The project is a open source project, you can get the source from:
* https://github.com/wuuhii/QtSwissArmyKnife
* https://gitee.com/wuuhii/QtSwissArmyKnife
*
* If you want to know more about the project, please join our QQ group(952218522).
* In addition, the email address of the project author is wuuhii@outlook.com.
*/
#ifndef SAKUDPDEVICECONTROLLER_HH
#define SAKUDPDEVICECONTROLLER_HH
#include <QWidget>
#include <QCheckBox>
#include <QComboBox>
namespace Ui {
class SAKUdpDeviceController;
}
class SAKUdpDeviceController:public QWidget
{
Q_OBJECT
public:
SAKUdpDeviceController(QWidget *parent = Q_NULLPTR);
~SAKUdpDeviceController();
QString localHost();
quint16 localPort();
QString targetHost();
quint16 targetPort();
bool enableCustomLocalSetting();
void refresh();
void setUiEnable(bool enable);
private:
Ui::SAKUdpDeviceController *ui;
QComboBox *localhostComboBox;
QLineEdit *localPortlineEdit;
QCheckBox *enableLocalSettingCheckBox;
QLineEdit *targetHostLineEdit;
QLineEdit *targetPortLineEdit;
QCheckBox *broadcastCheckBox;
QLineEdit *broadcastPortLineEdit;
QCheckBox *multicastCheckBox;
QLineEdit *multicastAddressLineEdit;
QLineEdit *multicastPortLineEdit;
};
#endif

View File

@ -0,0 +1,139 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>SAKUdpDeviceController</class>
<widget class="QWidget" name="SAKUdpDeviceController">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>362</width>
<height>182</height>
</rect>
</property>
<property name="windowTitle">
<string>UDP高级设置</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="1" column="2">
<widget class="QLineEdit" name="broadcastPortLineEdit">
<property name="text">
<string notr="true">55555</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="broadcastCheckBox">
<property name="text">
<string>允许广播</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="label_8">
<property name="text">
<string>广播端口</string>
</property>
</widget>
</item>
<item row="4" column="0" colspan="3">
<widget class="QFrame" name="frame">
<property name="styleSheet">
<string notr="true">QFrame{
border:none
}</string>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QGridLayout" name="gridLayout">
<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 row="0" column="3">
<widget class="QPushButton" name="deletePushButton">
<property name="text">
<string>删除</string>
</property>
</widget>
</item>
<item row="0" column="4">
<widget class="QPushButton" name="addPushButton">
<property name="text">
<string>添加</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QPushButton" name="cancelPushButton">
<property name="text">
<string>取消</string>
</property>
</widget>
</item>
<item row="0" column="0">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="1">
<widget class="QCheckBox" name="multicastCheckBox">
<property name="text">
<string>禁止所有组播</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="3" column="0" colspan="3">
<widget class="QListWidget" name="listWidget"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_9">
<property name="styleSheet">
<string notr="true">QLabel{
color:green
}</string>
</property>
<property name="text">
<string>组播设置</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="styleSheet">
<string notr="true">QLabel{
color:green
}</string>
</property>
<property name="text">
<string>广播设置</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>