Merge branch '0903' into 'dbus-interface'
网络详情页部分功能 See merge request kylin-desktop/kylin-nm!230
This commit is contained in:
commit
e278f6b568
|
@ -4,6 +4,7 @@ include(wireless-security/wireless-security.pri)
|
|||
include(xatom/xatom.pri)
|
||||
include(tab-pages/tab-pages.pri)
|
||||
include(list-items/list-items.pri)
|
||||
include(netdetails.pri)
|
||||
|
||||
FORMS += \
|
||||
$$PWD/confform.ui \
|
||||
|
|
|
@ -22,12 +22,7 @@ LanListItem::LanListItem(KyConnectItem *data, QString deviceName, QWidget *paren
|
|||
}
|
||||
m_netButton->setActive(m_isActive);
|
||||
m_itemFrame->installEventFilter(this);
|
||||
|
||||
}
|
||||
|
||||
void LanListItem::onInfoButtonClicked()
|
||||
{
|
||||
|
||||
connect(this->m_infoButton, &InfoButton::clicked, this, &LanListItem::onInfoButtonClicked);
|
||||
}
|
||||
|
||||
void LanListItem::onNetButtonClicked()
|
||||
|
@ -53,3 +48,16 @@ void LanListItem::setIcon(bool isOn)
|
|||
m_netButton->setButtonIcon(QIcon::fromTheme("network-wired-disconnected-symbolic"));
|
||||
}
|
||||
}
|
||||
|
||||
void LanListItem::onInfoButtonClicked()
|
||||
{
|
||||
if(m_data){
|
||||
qDebug()<<"Net active or not:"<<m_isActive;
|
||||
qDebug() << "On lan info button clicked! uuid = " << m_data->m_connectUuid << "; name = " << m_data->m_connectName << "." <<Q_FUNC_INFO << __LINE__;
|
||||
NetDetail *netDetail = new NetDetail(m_data->m_connectName, m_data->m_connectUuid, m_isActive,false, false);
|
||||
netDetail->show();
|
||||
}
|
||||
else{
|
||||
qDebug() << "On lan info button clicked! But there is no wlan connect " ;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -78,12 +78,7 @@ void ListItem::initUI()
|
|||
void ListItem::initConnection()
|
||||
{
|
||||
connect(this->m_netButton, &RadioItemButton::clicked, this, &ListItem::onNetButtonClicked);
|
||||
connect(this->m_infoButton, &InfoButton::clicked, this, &ListItem::onInfoButtonClicked);
|
||||
}
|
||||
|
||||
void ListItem::onInfoButtonClicked()
|
||||
{
|
||||
|
||||
// connect(this->m_infoButton, &InfoButton::clicked, this, &ListItem::onInfoButtonClicked);
|
||||
}
|
||||
|
||||
void ListItem::onNetButtonClicked()
|
||||
|
|
|
@ -3,8 +3,11 @@
|
|||
#include <QFrame>
|
||||
#include <QEvent>
|
||||
#include <QHBoxLayout>
|
||||
#include <QDebug>
|
||||
#include "radioitembutton.h"
|
||||
#include "infobutton.h"
|
||||
#include "netdetails/netdetail.h"
|
||||
|
||||
class ListItem : public QFrame
|
||||
{
|
||||
Q_OBJECT
|
||||
|
@ -29,13 +32,11 @@ protected:
|
|||
public:
|
||||
QVBoxLayout * m_mainLayout = nullptr;
|
||||
QHBoxLayout * m_hItemLayout = nullptr;
|
||||
|
||||
private:
|
||||
void initUI();
|
||||
void initConnection();
|
||||
|
||||
protected slots:
|
||||
virtual void onInfoButtonClicked();
|
||||
public slots:
|
||||
virtual void onNetButtonClicked();
|
||||
};
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@ WlanListItem::~WlanListItem()
|
|||
disconnect(m_resource, &KyWirelessNetResource::secuTypeChange, this, &WlanListItem::onSecurityChanged);
|
||||
disconnect(m_resource, &KyWirelessNetResource::connectionAdd, this, &WlanListItem::onConnectionAdd);
|
||||
disconnect(m_resource, &KyWirelessNetResource::connectionRemove, this, &WlanListItem::onConnectionRemove);
|
||||
disconnect(this->m_infoButton, &InfoButton::clicked, this, &WlanListItem::onInfoButtonClicked);
|
||||
}
|
||||
|
||||
void WlanListItem::setWlanSignal(const int &signal)
|
||||
|
@ -135,6 +136,7 @@ void WlanListItem::initWlanConnection()
|
|||
connect(m_resource, &KyWirelessNetResource::secuTypeChange, this, &WlanListItem::onSecurityChanged);
|
||||
connect(m_resource, &KyWirelessNetResource::connectionAdd, this, &WlanListItem::onConnectionAdd);
|
||||
connect(m_resource, &KyWirelessNetResource::connectionRemove, this, &WlanListItem::onConnectionRemove);
|
||||
connect(this->m_infoButton, &InfoButton::clicked, this, &WlanListItem::onInfoButtonClicked);
|
||||
}
|
||||
|
||||
void WlanListItem::refreshIcon()
|
||||
|
@ -193,7 +195,10 @@ void WlanListItem::onInfoButtonClicked()
|
|||
{
|
||||
//ZJP_TODO 呼出无线详情页
|
||||
if(m_data){
|
||||
qDebug()<<"Net active or not:"<<m_isActive;
|
||||
qDebug() << "On wlan info button clicked! ssid = " << m_data->m_NetSsid << "; name = " << m_data->m_connName << "." <<Q_FUNC_INFO << __LINE__;
|
||||
NetDetail *netDetail = new NetDetail(m_data->m_NetSsid, m_data->m_connectUuid,m_isActive, true, false);
|
||||
netDetail->show();
|
||||
}
|
||||
else{
|
||||
qDebug() << "On wlan info button clicked! But there is no wlan connect " ;
|
||||
|
@ -331,3 +336,4 @@ void WlanListItem::onConnectionRemove(QString deviceName, QString ssid)
|
|||
m_data->m_isConfigured = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -27,7 +27,6 @@ public:
|
|||
void setWlanSignal(const int &signal);
|
||||
void setWlanState(const int &state);
|
||||
void setExpanded(const bool &expanded);
|
||||
|
||||
protected:
|
||||
void resizeEvent(QResizeEvent *event);
|
||||
|
||||
|
@ -67,9 +66,11 @@ private:
|
|||
// QFrame * m_itemFrame = nullptr;
|
||||
// QHBoxLayout * m_hItemLayout = nullptr;
|
||||
// QLineEdit * m_lineEdit = nullptr;
|
||||
protected slots:
|
||||
void onInfoButtonClicked();
|
||||
|
||||
private slots:
|
||||
void onInfoButtonClicked();
|
||||
// void onInfoButtonClicked();
|
||||
void onNetButtonClicked();
|
||||
// void onNameLableClicked();
|
||||
void onSecurityChanged(QString interface, QString ssid, QString securityType);
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
HEADERS += \
|
||||
$$PWD/netdetails/creatnetpage.h \
|
||||
$$PWD/netdetails/customtabstyle.h \
|
||||
$$PWD/netdetails/detailpage.h \
|
||||
$$PWD/netdetails/ipv4page.h \
|
||||
$$PWD/netdetails/ipv6page.h \
|
||||
$$PWD/netdetails/netdetail.h \
|
||||
$$PWD/netdetails/securitypage.h
|
||||
|
||||
SOURCES += \
|
||||
$$PWD/netdetails/creatnetpage.cpp \
|
||||
$$PWD/netdetails/customtabstyle.cpp \
|
||||
$$PWD/netdetails/detailpage.cpp \
|
||||
$$PWD/netdetails/ipv4page.cpp \
|
||||
$$PWD/netdetails/ipv6page.cpp \
|
||||
$$PWD/netdetails/netdetail.cpp \
|
||||
$$PWD/netdetails/securitypage.cpp
|
|
@ -0,0 +1,6 @@
|
|||
#include "creatnetpage.h"
|
||||
|
||||
CreatNetPage::CreatNetPage(QWidget *parent) : QFrame(parent)
|
||||
{
|
||||
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
#ifndef CREATNETPAGE_H
|
||||
#define CREATNETPAGE_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QFrame>
|
||||
|
||||
class CreatNetPage : public QFrame
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
CreatNetPage(QWidget *parent = nullptr);
|
||||
};
|
||||
|
||||
#endif // CREATNETPAGE_H
|
|
@ -0,0 +1,73 @@
|
|||
#include "customtabstyle.h"
|
||||
|
||||
|
||||
CustomTabStyle::CustomTabStyle()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
QSize CustomTabStyle::sizeFromContents(QStyle::ContentsType type, const QStyleOption *option, const QSize &size, const QWidget *widget) const
|
||||
{
|
||||
QSize s = QProxyStyle::sizeFromContents(type, option, size, widget);
|
||||
if (type == QStyle::CT_TabBarTab) {
|
||||
s.transpose();
|
||||
s.rwidth() = 60; // 设置每个tabBar中item的大小
|
||||
s.rheight() = 36;
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
void CustomTabStyle::drawControl(QStyle::ControlElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const
|
||||
{
|
||||
if (element == CE_TabBarTab) {
|
||||
if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(option)) {
|
||||
QRect allRect = tab->rect;
|
||||
if (tab->state & QStyle::State_Selected) { //选中状态:tab的Qlabel为矩形,底色为白色,边框淡灰色,文字为淡蓝色且加粗居中(具体颜色值由拾色器提取)
|
||||
painter->save();
|
||||
painter->setPen(0x3790FA); //设置画笔颜色为淡灰色
|
||||
painter->setBrush(QBrush(0x3790FA)); //设置画刷为白色
|
||||
painter->drawRoundedRect(allRect.adjusted(0,0,0,0),6,6); //重绘tab的矩形边框
|
||||
painter->restore(); //还原为默认
|
||||
|
||||
painter->save();
|
||||
painter->setPen(0xffffff); //重新设置画笔颜色为淡蓝色
|
||||
QTextOption option;
|
||||
option.setAlignment(Qt::AlignCenter); //设置文字居中
|
||||
painter->drawText(allRect, tab->text, option); //重绘文字
|
||||
painter->restore();
|
||||
}
|
||||
else if(tab->state & QStyle::State_MouseOver) { //hover状态:tab的Qlabel为矩形,底色为灰色,边框仍未淡灰色,文字加粗居中
|
||||
painter->save();
|
||||
painter->setPen(tab->palette.color(QPalette::Window)); //设置画笔颜色为淡灰色
|
||||
painter->setBrush(tab->palette.color(QPalette::Window)); //设置画刷为灰色
|
||||
painter->drawRoundedRect(allRect.adjusted(0,0,0,0),6,6); //重绘tab的矩形边框
|
||||
painter->restore(); //还原
|
||||
|
||||
painter->save();
|
||||
QTextOption option;
|
||||
option.setAlignment(Qt::AlignCenter); //设置文字居中
|
||||
painter->drawText(allRect, tab->text, option); //重绘文字
|
||||
painter->restore();
|
||||
}
|
||||
else //其它的:tab的Qlabel为矩形,底色为灰色,边框为淡灰色不变,文字不加粗但居中
|
||||
{
|
||||
painter->save();
|
||||
painter->setPen(tab->palette.color(QPalette::Button));
|
||||
painter->setBrush(tab->palette.color(QPalette::Button));
|
||||
painter->drawRoundedRect(allRect.adjusted(0,0,0,0),6,6); //重绘tab的矩形边框
|
||||
painter->restore();
|
||||
painter->save();
|
||||
QTextOption option;
|
||||
option.setAlignment(Qt::AlignCenter);
|
||||
painter->drawText(allRect, tab->text, option);
|
||||
painter->restore();
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (element == CE_TabBarTab) {
|
||||
QProxyStyle::drawControl(element, option, painter, widget);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
#ifndef CUSTOMTABSTYLE_H
|
||||
#define CUSTOMTABSTYLE_H
|
||||
|
||||
#include <QPainter>
|
||||
#include <QProxyStyle>
|
||||
#include <QStyleOptionTab>
|
||||
#include <QDebug>
|
||||
#include <QLayout>
|
||||
class CustomTabStyle : public QProxyStyle
|
||||
{
|
||||
public:
|
||||
CustomTabStyle();
|
||||
QSize sizeFromContents(ContentsType type, const QStyleOption *option,
|
||||
const QSize &size, const QWidget *widget) const;
|
||||
|
||||
void drawControl(ControlElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const;
|
||||
};
|
||||
|
||||
#endif // CUSTOMTABSTYLE_H
|
|
@ -0,0 +1,145 @@
|
|||
#include "detailpage.h"
|
||||
|
||||
extern void qt_blurImage(QImage &blurImage, qreal radius, bool quality, int transposed);
|
||||
|
||||
DetailPage::DetailPage(bool isWlan, QWidget *parent)
|
||||
: mIsWlan(isWlan), QFrame(parent)
|
||||
{
|
||||
this->setFrameShape(QFrame::Shape::StyledPanel);
|
||||
this->setMaximumWidth(960);
|
||||
initUI();
|
||||
initComponent();
|
||||
}
|
||||
|
||||
void DetailPage::setSSID(const QString &ssid) {
|
||||
this->mSSID->setText(ssid);
|
||||
}
|
||||
|
||||
void DetailPage::setProtocol(const QString &protocol) {
|
||||
this->mProtocol->setText(protocol);
|
||||
}
|
||||
|
||||
void DetailPage::setSecType(const QString &secType) {
|
||||
this->mSecType->setText(secType);
|
||||
}
|
||||
|
||||
void DetailPage::setHz(const QString &hz) {
|
||||
this->mHz->setText(hz);
|
||||
}
|
||||
|
||||
void DetailPage::setChan(const QString &chan) {
|
||||
this->mChan->setText(chan);
|
||||
}
|
||||
|
||||
void DetailPage::setBandWidth(const QString &brandWidth) {
|
||||
this->mBandWidth->setText(brandWidth);
|
||||
}
|
||||
|
||||
void DetailPage::setIpv4(const QString &ipv4) {
|
||||
this->mIPV4->setText(ipv4);
|
||||
}
|
||||
|
||||
void DetailPage::setIpv4Dns(const QString &ipv4Dns) {
|
||||
this->mIPV4Dns->setText(ipv4Dns);
|
||||
}
|
||||
|
||||
void DetailPage::setIpv6(const QString &ipv6) {
|
||||
this->mIPV6->setText(ipv6);
|
||||
}
|
||||
|
||||
void DetailPage::setMac(const QString &mac) {
|
||||
this->mMac->setText(mac);
|
||||
}
|
||||
|
||||
void DetailPage::initUI() {
|
||||
forgetNetBox = new QCheckBox(this);
|
||||
layout = new QVBoxLayout(this);
|
||||
|
||||
mDetailLayout = new QFormLayout(this);
|
||||
|
||||
mSSID = new QLabel(this);
|
||||
QHBoxLayout *mSSIDLayout = new QHBoxLayout(this);
|
||||
mSSIDLayout->addStretch();
|
||||
mSSIDLayout->addWidget(mSSID);
|
||||
|
||||
mProtocol = new QLabel(this);
|
||||
QHBoxLayout *mProtocolLayout = new QHBoxLayout(this);
|
||||
mProtocolLayout->addStretch();
|
||||
mProtocolLayout->addWidget(mProtocol);
|
||||
|
||||
mSecType = new QLabel(this);
|
||||
QHBoxLayout *mSecTypeLayout = new QHBoxLayout(this);
|
||||
mSecTypeLayout->addStretch();
|
||||
mSecTypeLayout->addWidget(mSecType);
|
||||
|
||||
mHz = new QLabel(this);
|
||||
QHBoxLayout *mHzLayout = new QHBoxLayout(this);
|
||||
mHzLayout->addStretch();
|
||||
mHzLayout->addWidget(mHz);
|
||||
|
||||
mChan = new QLabel(this);
|
||||
QHBoxLayout *mChanLayout = new QHBoxLayout(this);
|
||||
mChanLayout->addStretch();
|
||||
mChanLayout->addWidget(mChan);
|
||||
|
||||
mBandWidth = new QLabel(this);
|
||||
QHBoxLayout *mBandWidthLayout = new QHBoxLayout(this);
|
||||
mBandWidthLayout->addStretch();
|
||||
mBandWidthLayout->addWidget(mBandWidth);
|
||||
|
||||
mIPV4 = new QLabel(this);
|
||||
QHBoxLayout *mIPV4Layout = new QHBoxLayout(this);
|
||||
mIPV4Layout->addStretch();
|
||||
mIPV4Layout->addWidget(mIPV4);
|
||||
|
||||
mIPV4Dns = new QLabel(this);
|
||||
QHBoxLayout *mIPV4DnsLayout = new QHBoxLayout(this);
|
||||
mIPV4DnsLayout->addStretch();
|
||||
mIPV4DnsLayout->addWidget(mIPV4Dns);
|
||||
|
||||
mIPV6 = new QLabel(this);
|
||||
QHBoxLayout *mIPV6Layout = new QHBoxLayout(this);
|
||||
mIPV6Layout->addStretch();
|
||||
mIPV6Layout->addWidget(mIPV6);
|
||||
|
||||
mMac = new QLabel(this);
|
||||
QHBoxLayout *mMacLayout = new QHBoxLayout(this);
|
||||
mMacLayout->addStretch();
|
||||
mMacLayout->addWidget(mMac);
|
||||
|
||||
autoConnect = new QLabel(this);
|
||||
|
||||
autoConnect->setText(tr("Auto Connection"));
|
||||
mAutoLayout = new QHBoxLayout(this);
|
||||
QSpacerItem *horizontalSpacer;
|
||||
horizontalSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
|
||||
|
||||
mAutoLayout->addWidget(forgetNetBox);
|
||||
mAutoLayout->addWidget(autoConnect);
|
||||
mAutoLayout->addSpacerItem(horizontalSpacer);
|
||||
|
||||
mDetailLayout->addRow(tr("SSID:"), mSSIDLayout);
|
||||
mDetailLayout->addRow(tr("Protocol:"), mProtocolLayout);
|
||||
if (mIsWlan) {
|
||||
mDetailLayout->addRow(tr("Security Type:"), mSecTypeLayout);
|
||||
mDetailLayout->addRow(tr("Hz:"), mHzLayout);
|
||||
mDetailLayout->addRow(tr("Chan:"), mChanLayout);
|
||||
}
|
||||
mDetailLayout->addRow(tr("BandWidth:"), mBandWidthLayout);
|
||||
mDetailLayout->addRow(tr("IPV6:"), mIPV6Layout);
|
||||
mDetailLayout->addRow(tr("IPV4:"), mIPV4Layout);
|
||||
mDetailLayout->addRow(tr("IPV4 Dns:"), mIPV4DnsLayout);
|
||||
mDetailLayout->addRow(tr("Mac:"), mMacLayout);
|
||||
|
||||
layout->addLayout(mDetailLayout);
|
||||
layout->addStretch();
|
||||
layout->addLayout(mAutoLayout);
|
||||
|
||||
}
|
||||
void DetailPage::initComponent() {
|
||||
connect(forgetNetBox, SIGNAL(toggled(bool)), this, SLOT(setNetStatus(bool)));
|
||||
}
|
||||
|
||||
void DetailPage::setNetStatus(bool checked) {
|
||||
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
#ifndef DETAILPAGE_H
|
||||
#define DETAILPAGE_H
|
||||
#include <QWidget>
|
||||
#include <QLabel>
|
||||
#include <QFormLayout>
|
||||
#include <QPainter>
|
||||
#include <QCheckBox>
|
||||
#include <QSpacerItem>
|
||||
#include <QDebug>
|
||||
class DetailPage : public QFrame
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
DetailPage(bool isWlan, QWidget *parent = nullptr);
|
||||
|
||||
void setSSID(const QString &ssid);
|
||||
void setProtocol(const QString &protocol);
|
||||
void setSecType(const QString &secType);
|
||||
void setHz(const QString &hz);
|
||||
void setChan(const QString &chan);
|
||||
void setBandWidth(const QString &brandWidth);
|
||||
void setIpv4(const QString &ipv4);
|
||||
void setIpv4Dns(const QString &ipv4Dns);
|
||||
void setIpv6(const QString &ipv6);
|
||||
void setMac(const QString &mac);
|
||||
|
||||
private:
|
||||
void initUI();
|
||||
void initComponent();
|
||||
|
||||
public:
|
||||
QLabel *mSSID;
|
||||
QLabel *mProtocol;
|
||||
QLabel *mSecType;
|
||||
QLabel *mHz;
|
||||
QLabel *mChan;
|
||||
QLabel *mBandWidth;
|
||||
QLabel *mIPV4;
|
||||
QLabel *mIPV4Dns;
|
||||
QLabel *mIPV6;
|
||||
QLabel *mMac;
|
||||
QLabel *autoConnect;
|
||||
|
||||
// QWidget *autoFrame;
|
||||
private:
|
||||
QVBoxLayout *layout;
|
||||
QFormLayout *mDetailLayout;
|
||||
QHBoxLayout *mAutoLayout;
|
||||
QCheckBox *forgetNetBox;
|
||||
bool mIsWlan;
|
||||
private slots:
|
||||
void setNetStatus(bool checked);
|
||||
|
||||
};
|
||||
|
||||
#endif // DETAILPAGE_H
|
|
@ -0,0 +1,157 @@
|
|||
#include "ipv4page.h"
|
||||
#include "netdetail.h"
|
||||
Ipv4Page::Ipv4Page(bool isWlan, QWidget *parent)
|
||||
: isWlan(isWlan), QFrame(parent)
|
||||
{
|
||||
initUI();
|
||||
initComponent();
|
||||
}
|
||||
|
||||
void Ipv4Page::initUI() {
|
||||
ipv4ConfigCombox = new QComboBox(this);
|
||||
ipv4addressEdit = new QLineEdit(this);
|
||||
netMaskCombox = new QComboBox(this);
|
||||
gateWayEdit = new QLineEdit(this);
|
||||
firstDnsEidt = new QLineEdit(this);
|
||||
secondDnsEidt = new QLineEdit(this);
|
||||
|
||||
m_configLabel = new QLabel(this);
|
||||
m_addressLabel = new QLabel(this);
|
||||
m_maskLabel = new QLabel(this);
|
||||
m_gateWayLabel = new QLabel(this);
|
||||
m_dnsLabel = new QLabel(this);
|
||||
m_secDnsLabel = new QLabel(this);
|
||||
|
||||
m_configLabel->setText(tr("Ipv4Config"));
|
||||
m_addressLabel->setText(tr("Address"));
|
||||
m_maskLabel->setText(tr("Netmask"));
|
||||
m_gateWayLabel->setText(tr("Default Gateway"));
|
||||
m_dnsLabel->setText(tr("Prefs DNS"));
|
||||
m_secDnsLabel->setText(tr("Alternative DNS"));
|
||||
|
||||
m_detailLayout = new QFormLayout(this);
|
||||
m_detailLayout->addRow(m_configLabel,ipv4ConfigCombox);
|
||||
m_detailLayout->addRow(m_addressLabel,ipv4addressEdit);
|
||||
m_detailLayout->addRow(m_maskLabel,netMaskCombox);
|
||||
m_detailLayout->addRow(m_gateWayLabel,gateWayEdit);
|
||||
m_detailLayout->addRow(m_dnsLabel,firstDnsEidt);
|
||||
m_detailLayout->addRow(m_secDnsLabel,secondDnsEidt);
|
||||
|
||||
ipv4ConfigCombox->addItem(tr("Auto(DHCP)")); //"自动(DHCP)"
|
||||
ipv4ConfigCombox->addItem(tr("Manual")); //"手动"
|
||||
|
||||
netMaskCombox->addItem("255.255.255.0"); //24
|
||||
netMaskCombox->addItem("255.255.254.0"); //23
|
||||
netMaskCombox->addItem("255.255.252.0"); //22
|
||||
netMaskCombox->addItem("255.255.0.0"); //16
|
||||
netMaskCombox->addItem("255.0.0.0"); //8
|
||||
|
||||
// IP的正则格式限制
|
||||
QRegExp rx("\\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\b");
|
||||
ipv4addressEdit->setValidator(new QRegExpValidator(rx, this));
|
||||
gateWayEdit->setValidator(new QRegExpValidator(rx, this));
|
||||
firstDnsEidt->setValidator(new QRegExpValidator(rx, this));
|
||||
secondDnsEidt->setValidator(new QRegExpValidator(rx, this));
|
||||
setEnableOfSaveBtn();
|
||||
}
|
||||
|
||||
void Ipv4Page::initComponent() {
|
||||
if (ipv4ConfigCombox->currentIndex() == AUTO_CONFIG) {
|
||||
setLineEnabled(false);
|
||||
} else if (ipv4ConfigCombox->currentIndex() == MANUAL_CONFIG) {
|
||||
setLineEnabled(true);
|
||||
}
|
||||
connect(ipv4ConfigCombox, SIGNAL(currentIndexChanged(int)), this, SLOT(configChanged(int)));
|
||||
// connect(mNetMask, SIGNAL(currentIndexChanged(int)), this, SLOT(cbMaskChanged(int)));
|
||||
}
|
||||
|
||||
void Ipv4Page::setIpv4Config(const QString &ipv4Config)
|
||||
{
|
||||
if (ipv4Config.toInt() == AUTO_CONFIG) {
|
||||
ipv4ConfigCombox->setCurrentIndex(MANUAL_CONFIG);
|
||||
} else {
|
||||
ipv4ConfigCombox->setCurrentIndex(AUTO_CONFIG);
|
||||
}
|
||||
}
|
||||
|
||||
void Ipv4Page::setIpv4(const QString &ipv4)
|
||||
{
|
||||
ipv4addressEdit->setText(ipv4);
|
||||
}
|
||||
|
||||
void Ipv4Page::setIpv4FirDns(const QString &ipv4FirDns)
|
||||
{
|
||||
firstDnsEidt->setText(ipv4FirDns);
|
||||
}
|
||||
|
||||
void Ipv4Page::setIpv4SecDns(const QString &ipv4SecDns)
|
||||
{
|
||||
secondDnsEidt->setText(ipv4SecDns);
|
||||
}
|
||||
|
||||
void Ipv4Page::setGateWay(const QString &gateWay)
|
||||
{
|
||||
gateWayEdit->setText(gateWay);
|
||||
}
|
||||
|
||||
void Ipv4Page::configChanged(int index) {
|
||||
if (index == AUTO_CONFIG) {
|
||||
setLineEnabled(false);
|
||||
}
|
||||
if (index == MANUAL_CONFIG) {
|
||||
setLineEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
void Ipv4Page::setLineEnabled(bool check) {
|
||||
m_addressLabel->setEnabled(check);
|
||||
m_maskLabel->setEnabled(check);
|
||||
m_gateWayLabel->setEnabled(check);
|
||||
m_dnsLabel->setEnabled(check);
|
||||
m_secDnsLabel->setEnabled(check);
|
||||
|
||||
ipv4addressEdit->setEnabled(check);
|
||||
netMaskCombox->setEnabled(check);
|
||||
gateWayEdit->setEnabled(check);
|
||||
firstDnsEidt->setEnabled(check);
|
||||
secondDnsEidt->setEnabled(check);
|
||||
}
|
||||
|
||||
void Ipv4Page::setEnableOfSaveBtn() {
|
||||
if (ipv4ConfigCombox->currentIndex() == 1) {
|
||||
// if (mIpv4address->text().isEmpty()) {
|
||||
// //当ipv4和ipv6地址均未设置时,禁止保存
|
||||
// emit setBtnEnableFalse();
|
||||
// return;
|
||||
// }
|
||||
|
||||
// if (!ui->leAddr->text().isEmpty() && !this->getTextEditState(ui->leAddr->text()) ) {
|
||||
// emit setBtnEnableFalse();
|
||||
// return;
|
||||
// }
|
||||
|
||||
// if (!ui->leGateway->text().isEmpty() && !this->getTextEditState(ui->leGateway->text()) ) {
|
||||
// emit setBtnEnableFalse();
|
||||
// return;
|
||||
// }
|
||||
|
||||
// if (!ui->leDns->text().isEmpty() && !this->getTextEditState(ui->leDns->text()) ) {
|
||||
// emit setBtnEnableFalse();
|
||||
// return;
|
||||
// }
|
||||
|
||||
// if (!ui->leAddr_ipv6->text().isEmpty() && ! this->getIpv6EditState(ui->leAddr_ipv6->text())) {
|
||||
// emit setBtnEnableFalse();
|
||||
// return;
|
||||
// }
|
||||
// if(ui->leDns2->text().isEmpty()){
|
||||
|
||||
// }else{
|
||||
// if(!this->getTextEditState(ui->leDns2->text())){
|
||||
// emit setBtnEnableFalse();
|
||||
// return ;
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,70 @@
|
|||
#ifndef IPV4PAGE_H
|
||||
#define IPV4PAGE_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QLayout>
|
||||
#include <QFormLayout>
|
||||
#include <QLabel>
|
||||
#include <QPainter>
|
||||
#include <QScrollArea>
|
||||
#include <QSpacerItem>
|
||||
#include <QComboBox>
|
||||
#include <QLineEdit>
|
||||
#include <QDebug>
|
||||
|
||||
struct ConnProperties
|
||||
{
|
||||
QString uuidName; //uuid
|
||||
QString v4method; //
|
||||
QString v4addr; //ipv4地址
|
||||
QString mask; //
|
||||
QString gateway; //网关
|
||||
QString dns; //DNS
|
||||
bool isActConf; //
|
||||
QString type; //网络类型
|
||||
};
|
||||
|
||||
class Ipv4Page : public QFrame
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
Ipv4Page(bool isWlan, QWidget *parent = nullptr);
|
||||
void setIpv4Config(const QString &ipv4Config);
|
||||
void setIpv4(const QString &ipv4);
|
||||
void setIpv4FirDns(const QString &ipv4FirDns);
|
||||
void setIpv4SecDns(const QString &ipv4SecDns);
|
||||
void setGateWay(const QString &gateWay);
|
||||
public:
|
||||
QComboBox *ipv4ConfigCombox;
|
||||
QLineEdit *ipv4addressEdit;
|
||||
QComboBox *netMaskCombox;
|
||||
QLineEdit *gateWayEdit;
|
||||
QLineEdit *firstDnsEidt;
|
||||
QLineEdit *secondDnsEidt;
|
||||
|
||||
private:
|
||||
QFormLayout *m_detailLayout;
|
||||
QVBoxLayout *mvBoxLayout;
|
||||
QLabel *m_configLabel;
|
||||
QLabel *m_addressLabel;
|
||||
QLabel *m_maskLabel;
|
||||
QLabel *m_gateWayLabel;
|
||||
QLabel *m_dnsLabel;
|
||||
QLabel *m_secDnsLabel;
|
||||
bool isWlan;
|
||||
private:
|
||||
void initUI();
|
||||
void initComponent();
|
||||
void setEnableOfSaveBtn();
|
||||
void setLineEnabled(bool check);
|
||||
void configSave();
|
||||
|
||||
|
||||
public slots:
|
||||
void configChanged(int index);
|
||||
Q_SIGNALS:
|
||||
// void setBtnEnableFalse();
|
||||
|
||||
};
|
||||
|
||||
#endif // IPV4PAGE_H
|
|
@ -0,0 +1,109 @@
|
|||
#include "ipv6page.h"
|
||||
#include "netdetail.h"
|
||||
Ipv6Page::Ipv6Page(bool isWlan, QWidget *parent)
|
||||
:isWlan(isWlan), QFrame(parent)
|
||||
{
|
||||
initUI();
|
||||
initComponent();
|
||||
}
|
||||
|
||||
void Ipv6Page::setIpv6Config(const QString &ipv6Config)
|
||||
{
|
||||
if (ipv6Config.toInt() == AUTO_CONFIG) {
|
||||
ipv6ConfigCombox->setCurrentIndex(MANUAL_CONFIG);
|
||||
} else {
|
||||
ipv6ConfigCombox->setCurrentIndex(AUTO_CONFIG);
|
||||
}
|
||||
}
|
||||
|
||||
void Ipv6Page::setIpv6(const QString &ipv4)
|
||||
{
|
||||
ipv6AddressEdit->setText(ipv4);
|
||||
}
|
||||
|
||||
void Ipv6Page::setIpv6FirDns(const QString &ipv6FirDns)
|
||||
{
|
||||
firstDnsEdit->setText(ipv6FirDns);
|
||||
}
|
||||
|
||||
void Ipv6Page::setIpv6SecDns(const QString &ipv6SecDns)
|
||||
{
|
||||
secondDnsEdit->setText(ipv6SecDns);
|
||||
}
|
||||
|
||||
void Ipv6Page::setGateWay(const QString &gateWay)
|
||||
{
|
||||
gateWayEdit->setText(gateWay);
|
||||
}
|
||||
|
||||
void Ipv6Page::initUI() {
|
||||
ipv6ConfigCombox = new QComboBox(this);
|
||||
ipv6AddressEdit = new QLineEdit(this);
|
||||
lengthEdit = new QLineEdit(this);
|
||||
gateWayEdit = new QLineEdit(this);
|
||||
firstDnsEdit = new QLineEdit(this);
|
||||
secondDnsEdit = new QLineEdit(this);
|
||||
|
||||
m_configLabel = new QLabel(this);
|
||||
m_addressLabel = new QLabel(this);
|
||||
m_subnetLabel = new QLabel(this);
|
||||
m_gateWayLabel = new QLabel(this);
|
||||
m_dnsLabel = new QLabel(this);
|
||||
m_secDnsLabel = new QLabel(this);
|
||||
|
||||
|
||||
m_configLabel->setText(tr("Ipv6Config"));
|
||||
m_addressLabel->setText(tr("Address"));
|
||||
m_subnetLabel->setText(tr("Subnet prefix Length"));
|
||||
m_gateWayLabel->setText(tr("Default Gateway"));
|
||||
m_dnsLabel->setText(tr("Prefs DNS"));
|
||||
m_secDnsLabel->setText(tr("Alternative DNS"));
|
||||
|
||||
|
||||
m_detailLayout = new QFormLayout(this);
|
||||
m_detailLayout->addRow(m_configLabel,ipv6ConfigCombox);
|
||||
m_detailLayout->addRow(m_addressLabel,ipv6AddressEdit);
|
||||
m_detailLayout->addRow(m_subnetLabel,lengthEdit);
|
||||
m_detailLayout->addRow(m_gateWayLabel,gateWayEdit);
|
||||
m_detailLayout->addRow(m_dnsLabel,firstDnsEdit);
|
||||
m_detailLayout->addRow(m_secDnsLabel,secondDnsEdit);
|
||||
|
||||
ipv6ConfigCombox->addItem(tr("Auto(DHCP)")); //"自动(DHCP)"
|
||||
ipv6ConfigCombox->addItem(tr("Manual")); //"手动"
|
||||
|
||||
QRegExp ipv6_rx("^\\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:)))(%.+)?\\s*$");
|
||||
ipv6AddressEdit->setValidator(new QRegExpValidator(ipv6_rx, this));
|
||||
}
|
||||
|
||||
void Ipv6Page::initComponent() {
|
||||
if (ipv6ConfigCombox->currentIndex() == MANUAL_CONFIG) {
|
||||
setControlEnabled(false);
|
||||
} else if (ipv6ConfigCombox->currentIndex() == MANUAL_CONFIG) {
|
||||
setControlEnabled(true);
|
||||
}
|
||||
connect(ipv6ConfigCombox, SIGNAL(currentIndexChanged(int)), this, SLOT(configChanged(int)));
|
||||
}
|
||||
|
||||
void Ipv6Page::configChanged(int index) {
|
||||
if (index == AUTO_CONFIG) {
|
||||
setControlEnabled(false);
|
||||
}
|
||||
if (index == MANUAL_CONFIG) {
|
||||
setControlEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
void Ipv6Page::setControlEnabled(bool check) {
|
||||
m_addressLabel->setEnabled(check);
|
||||
m_subnetLabel->setEnabled(check);
|
||||
lengthEdit->setEnabled(check);
|
||||
m_gateWayLabel->setEnabled(check);
|
||||
m_dnsLabel->setEnabled(check);
|
||||
m_secDnsLabel->setEnabled(check);
|
||||
|
||||
ipv6AddressEdit->setEnabled(check);
|
||||
m_subnetLabel->setEnabled(check);
|
||||
gateWayEdit->setEnabled(check);
|
||||
firstDnsEdit->setEnabled(check);
|
||||
secondDnsEdit->setEnabled(check);
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
#ifndef IPV6PAGE_H
|
||||
#define IPV6PAGE_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QLayout>
|
||||
#include <QFormLayout>
|
||||
#include <QLabel>
|
||||
#include <QPainter>
|
||||
#include <QCheckBox>
|
||||
#include <QScrollArea>
|
||||
#include <QSpacerItem>
|
||||
#include <QComboBox>
|
||||
#include <QLineEdit>
|
||||
|
||||
class Ipv6Page : public QFrame
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
Ipv6Page(bool isWlan, QWidget *parent = nullptr);
|
||||
void setIpv6Config(const QString &ipv6Config);
|
||||
void setIpv6(const QString &ipv4);
|
||||
void setIpv6FirDns(const QString &ipv6FirDns);
|
||||
void setIpv6SecDns(const QString &ipv6SecDns);
|
||||
void setGateWay(const QString &gateWay);
|
||||
|
||||
public:
|
||||
QComboBox *ipv6ConfigCombox;
|
||||
QLineEdit *ipv6AddressEdit;
|
||||
QLineEdit *lengthEdit;
|
||||
QLineEdit *gateWayEdit;
|
||||
QLineEdit *firstDnsEdit;
|
||||
QLineEdit *secondDnsEdit;
|
||||
private:
|
||||
QFormLayout *m_detailLayout;
|
||||
QLabel *m_configLabel;
|
||||
QLabel *m_addressLabel;
|
||||
QLabel *m_subnetLabel;
|
||||
QLabel *m_gateWayLabel;
|
||||
QLabel *m_dnsLabel;
|
||||
QLabel *m_secDnsLabel;
|
||||
private:
|
||||
bool isWlan;
|
||||
private:
|
||||
void initUI();
|
||||
void initComponent();
|
||||
void setControlEnabled(bool check);
|
||||
|
||||
public slots:
|
||||
void configChanged(int index);
|
||||
};
|
||||
|
||||
#endif // IPV6PAGE_H
|
|
@ -0,0 +1,468 @@
|
|||
#include "netdetail.h"
|
||||
|
||||
#define WINDOW_WIDTH 540
|
||||
#define WINDOW_HEIGHT 574
|
||||
#define BUTTON_SIZE 30
|
||||
#define ICON_SIZE 22,22
|
||||
#define TITLE_LAYOUT_MARGINS 9,9,0,0
|
||||
#define LAYOUT_MARGINS 24,0,24,0
|
||||
#define BOTTOM_LAYOUT_SPACING 16
|
||||
#define PAGE_LAYOUT_SPACING 1
|
||||
#define DETAIL_PAGE_NUM 0
|
||||
#define IPV4_PAGE_NUM 1
|
||||
#define IPV6_PAGE_NUM 2
|
||||
#define SECURITY_PAGE_NUM 3
|
||||
#define CREATE_NET_PAGE_NUM 4
|
||||
#define PAGE_MIN_HEIGHT 40
|
||||
|
||||
extern void qt_blurImage(QImage &blurImage, qreal radius, bool quality, int transposed);
|
||||
|
||||
NetDetail::NetDetail(QString name, QString uuid, bool isActive, bool isWlan, bool isCreateNet, QWidget *parent)
|
||||
:m_name(name), m_uuid(uuid), isActive(isActive), isWlan(isWlan), isCreateNet(isCreateNet), QDialog(parent)
|
||||
{
|
||||
setWindowFlags(Qt::FramelessWindowHint | Qt::Tool);
|
||||
setAttribute(Qt::WA_TranslucentBackground);
|
||||
setAttribute(Qt::WA_DeleteOnClose);
|
||||
setFixedSize(WINDOW_WIDTH,WINDOW_HEIGHT);
|
||||
centerToScreen();
|
||||
|
||||
m_netDeviceResource = new KyNetworkDeviceResourse(this);
|
||||
initWifiDevice();
|
||||
initLanDevice();
|
||||
initUI();
|
||||
loadPage();
|
||||
initComponent();
|
||||
getConInfo(mInfo);
|
||||
pagePadding(name,isWlan);
|
||||
}
|
||||
|
||||
NetDetail::~NetDetail()
|
||||
{
|
||||
|
||||
}
|
||||
void NetDetail::centerToScreen()
|
||||
{
|
||||
QDesktopWidget* m = QApplication::desktop();
|
||||
QRect desk_rect = m->screenGeometry(m->screenNumber(QCursor::pos()));
|
||||
int desk_x = desk_rect.width();
|
||||
int desk_y = desk_rect.height();
|
||||
int x = this->width();
|
||||
int y = this->height();
|
||||
this->move(desk_x / 2 - x / 2 + desk_rect.left(), desk_y / 2 - y / 2 + desk_rect.top());
|
||||
}
|
||||
|
||||
void NetDetail::initUI()
|
||||
{
|
||||
QVBoxLayout *mainLayout = new QVBoxLayout(this);
|
||||
mainLayout->setContentsMargins(9,9,14,24);
|
||||
|
||||
detailPage = new DetailPage(isWlan,this);
|
||||
ipv4Page = new Ipv4Page(isWlan,this);
|
||||
ipv6Page = new Ipv6Page(isWlan,this);
|
||||
securityWidget = new SecurityPage(this);
|
||||
createNetPage = new CreatNetPage(this);
|
||||
// addLanWidget = new AddLanWidget;
|
||||
|
||||
titleWidget = new QWidget(this);
|
||||
centerWidget = new QWidget(this);
|
||||
bottomWidget = new QWidget(this);
|
||||
|
||||
stackWidget = new QStackedWidget(centerWidget);
|
||||
stackWidget->addWidget(detailPage);
|
||||
stackWidget->addWidget(ipv4Page);
|
||||
stackWidget->addWidget(ipv6Page);
|
||||
stackWidget->addWidget(securityWidget);
|
||||
stackWidget->addWidget(createNetPage);
|
||||
|
||||
mainLayout->addWidget(titleWidget);
|
||||
mainLayout->addWidget(centerWidget);
|
||||
mainLayout->addWidget(bottomWidget);
|
||||
|
||||
titleWidget->setMinimumHeight(PAGE_MIN_HEIGHT);
|
||||
bottomWidget->setMinimumHeight(PAGE_MIN_HEIGHT);
|
||||
|
||||
QHBoxLayout *titleLayout = new QHBoxLayout(titleWidget);
|
||||
titleLayout->setContentsMargins(TITLE_LAYOUT_MARGINS);
|
||||
pageFrame = new QFrame(this);
|
||||
|
||||
QHBoxLayout *pageLayout = new QHBoxLayout(pageFrame);
|
||||
pageLayout->setSpacing(PAGE_LAYOUT_SPACING);
|
||||
|
||||
detailBtn = new QPushButton(this);
|
||||
detailBtn->setText(tr("Detail"));
|
||||
|
||||
ipv4Btn = new QPushButton(this);
|
||||
ipv4Btn->setText(tr("Ipv4"));
|
||||
|
||||
ipv6Btn = new QPushButton(this);
|
||||
ipv6Btn->setText(tr("Ipv6"));
|
||||
|
||||
securityBtn = new QPushButton(this);
|
||||
securityBtn->setText(tr("Security"));
|
||||
|
||||
pageLayout->addStretch();
|
||||
pageLayout->addWidget(detailBtn);
|
||||
pageLayout->addWidget(ipv4Btn);
|
||||
pageLayout->addWidget(ipv6Btn);
|
||||
pageLayout->addWidget(securityBtn);
|
||||
pageLayout->addStretch();
|
||||
|
||||
closeBtn = new QPushButton(this);
|
||||
closeBtn->setFixedSize(BUTTON_SIZE,BUTTON_SIZE);
|
||||
closeBtn->setToolTip(tr("Close"));
|
||||
closeBtn->setProperty("isWindowButton", 0x02);
|
||||
closeBtn->setProperty("useIconHighlightEffect", 0x08);
|
||||
closeBtn->setFlat(true);
|
||||
closeBtn->setIcon(QIcon::fromTheme("window-close-symbolic"));
|
||||
|
||||
confimBtn = new QPushButton(this);
|
||||
confimBtn->setText(tr("Confirm"));
|
||||
|
||||
cancelBtn = new QPushButton(this);
|
||||
cancelBtn->setText(tr("Cancel"));
|
||||
|
||||
forgetBtn = new QPushButton(this);
|
||||
forgetBtn->setText(tr("Forget this network"));
|
||||
|
||||
titleLabel = new QLabel(this);
|
||||
|
||||
iconLabel = new QLabel(this);
|
||||
iconLabel->setFixedSize(ICON_SIZE);
|
||||
titleLayout->addWidget(iconLabel);
|
||||
titleLayout->addWidget(titleLabel);
|
||||
titleLayout->addStretch();
|
||||
titleLayout->addWidget(closeBtn);
|
||||
|
||||
QVBoxLayout *centerlayout = new QVBoxLayout(centerWidget);
|
||||
centerlayout->setContentsMargins(LAYOUT_MARGINS);
|
||||
centerlayout->addWidget(pageFrame);
|
||||
centerlayout->addWidget(stackWidget);
|
||||
|
||||
QHBoxLayout *bottomLayout = new QHBoxLayout(bottomWidget);
|
||||
bottomLayout->setContentsMargins(LAYOUT_MARGINS);
|
||||
bottomLayout->setSpacing(BOTTOM_LAYOUT_SPACING);
|
||||
bottomLayout->addWidget(forgetBtn);
|
||||
bottomLayout->addStretch();
|
||||
bottomLayout->addWidget(cancelBtn);
|
||||
bottomLayout->addWidget(confimBtn);
|
||||
|
||||
}
|
||||
|
||||
void NetDetail::loadPage()
|
||||
{
|
||||
//判断是否创建网络
|
||||
if (isCreateNet) {
|
||||
pageFrame->hide();
|
||||
stackWidget->setCurrentIndex(CREATE_NET_PAGE_NUM);
|
||||
titleLabel->setText(tr("Add Connect"));
|
||||
} else {
|
||||
stackWidget->setCurrentIndex(DETAIL_PAGE_NUM);
|
||||
titleLabel->setText(m_name);
|
||||
}
|
||||
if (!isWlan) {
|
||||
securityBtn->hide();
|
||||
} else {
|
||||
securityBtn->show();
|
||||
}
|
||||
}
|
||||
|
||||
void NetDetail::initComponent()
|
||||
{
|
||||
connect(closeBtn, &QPushButton::clicked, this, [=] {
|
||||
close();
|
||||
});
|
||||
connect(cancelBtn, &QPushButton::clicked, this, [=] {
|
||||
close();
|
||||
});
|
||||
connect(detailBtn, &QPushButton::clicked, this, [=] {
|
||||
stackWidget->setCurrentIndex(DETAIL_PAGE_NUM);
|
||||
});
|
||||
connect(ipv4Btn, &QPushButton::clicked, this, [=] {
|
||||
stackWidget->setCurrentIndex(IPV4_PAGE_NUM);
|
||||
});
|
||||
connect(ipv6Btn, &QPushButton::clicked, this, [=] {
|
||||
stackWidget->setCurrentIndex(IPV6_PAGE_NUM);
|
||||
});
|
||||
connect(securityBtn, &QPushButton::clicked, this, [=] {
|
||||
stackWidget->setCurrentIndex(SECURITY_PAGE_NUM);
|
||||
});
|
||||
connect(confimBtn, SIGNAL(clicked()), this, SLOT(on_btnConfirm_clicked()));
|
||||
}
|
||||
|
||||
void NetDetail::pagePadding(QString netName, bool isWlan)
|
||||
{
|
||||
foreach (ConInfo netInfo, mInfo) {
|
||||
//网络详情页填充
|
||||
if (isWlan) {
|
||||
if (!netInfo.strConName.compare(netName, Qt::CaseInsensitive)) {
|
||||
detailPage->setSSID(netName);
|
||||
detailPage->setProtocol(netInfo.strConType);
|
||||
detailPage->setSecType(netInfo.strSecType);
|
||||
detailPage->setHz(netInfo.strHz);
|
||||
detailPage->setChan(netInfo.strChan);
|
||||
detailPage->setIpv4(netInfo.strIPV4Address);
|
||||
detailPage->setIpv4Dns(netInfo.strIPV4FirDns);
|
||||
detailPage->setIpv6(netInfo.strIPV6Address);
|
||||
detailPage->setMac(netInfo.strMac);
|
||||
detailPage->setBandWidth(netInfo.strBandWidth);
|
||||
}
|
||||
} else {
|
||||
if (!netInfo.strConName.compare(netName, Qt::CaseInsensitive)) {
|
||||
detailPage->setSSID(netName);
|
||||
detailPage->setProtocol(netInfo.strConType);
|
||||
detailPage->setIpv4(netInfo.strIPV4Address);
|
||||
detailPage->setIpv4Dns(netInfo.strIPV4FirDns);
|
||||
detailPage->setIpv6(netInfo.strIPV6Address);
|
||||
detailPage->setMac(netInfo.strMac);
|
||||
detailPage->setBandWidth(netInfo.strBandWidth);
|
||||
}
|
||||
}
|
||||
//ipv4页面填充
|
||||
if (!netInfo.strConName.compare(netName, Qt::CaseInsensitive)) {
|
||||
if (netInfo.strIPV4ConfigType.toInt() == AUTO_CONFIG) {
|
||||
ipv4Page->setIpv4Config(netInfo.strIPV4ConfigType);
|
||||
ipv4Page->setIpv4(netInfo.strIPV4Address);
|
||||
ipv4Page->setIpv4FirDns(netInfo.strIPV4FirDns);
|
||||
ipv4Page->setIpv4SecDns(netInfo.strIPV4SecDns);
|
||||
ipv4Page->setGateWay(netInfo.strIPV4GateWay);
|
||||
} else {
|
||||
ipv4Page->setIpv4Config(netInfo.strIPV4ConfigType);
|
||||
}
|
||||
}
|
||||
//ipv6页面填充
|
||||
if (!netInfo.strConName.compare(netName, Qt::CaseInsensitive)) {
|
||||
if (netInfo.strIPV4ConfigType.toInt() == AUTO_CONFIG) {
|
||||
ipv6Page->setIpv6Config(netInfo.strIPV6ConfigType);
|
||||
ipv6Page->setIpv6(netInfo.strIPV4Address);
|
||||
ipv6Page->setIpv6FirDns(netInfo.strIPV6FirDns);
|
||||
ipv6Page->setIpv6SecDns(netInfo.strIPV4SecDns);
|
||||
ipv6Page->setGateWay(netInfo.strIPV4GateWay);
|
||||
} else {
|
||||
ipv6Page->setIpv6Config(netInfo.strIPV6ConfigType);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void NetDetail::initLanDevice()
|
||||
{
|
||||
QSettings * m_settings = new QSettings(CONFIG_FILE_PATH, QSettings::IniFormat);
|
||||
m_settings->beginGroup("DEFAULTCARD");
|
||||
QString key("wired");
|
||||
m_deviceName = m_settings->value(key, "").toString();
|
||||
if (m_deviceName.isEmpty()) {
|
||||
qDebug() << "initDevice but defalut wired card is null";
|
||||
QStringList list;
|
||||
list.empty();
|
||||
m_netDeviceResource->getNetworkDeviceList(NetworkManager::Device::Type::Ethernet, list);
|
||||
if (!list.isEmpty()) {
|
||||
m_deviceName = list.at(0);
|
||||
m_settings->setValue(key, m_deviceName);
|
||||
}
|
||||
}
|
||||
qDebug() << "[LanPage] initDevice defaultDevice = " << m_deviceName;
|
||||
m_settings->endGroup();
|
||||
m_settings->sync();
|
||||
delete m_settings;
|
||||
m_settings = nullptr;
|
||||
}
|
||||
|
||||
void NetDetail::initWifiDevice()
|
||||
{
|
||||
QSettings * m_settings = new QSettings(CONFIG_FILE_PATH, QSettings::IniFormat);
|
||||
m_settings->beginGroup("DEFAULTCARD");
|
||||
QString key("wireless");
|
||||
QString deviceName = m_settings->value(key, "").toString();
|
||||
m_netDeviceResource->getNetworkDeviceList(NetworkManager::Device::Type::Wifi, m_devList);
|
||||
if (deviceName.isEmpty()) {
|
||||
qDebug() << "initDevice but defalut wireless card is null";
|
||||
if (!m_devList.isEmpty()) {
|
||||
deviceName = m_devList.at(0);
|
||||
m_settings->setValue(key, deviceName);
|
||||
}
|
||||
}
|
||||
qDebug() << "[WlanPage] initDevice defaultDevice = " << deviceName;
|
||||
m_settings->endGroup();
|
||||
m_settings->sync();
|
||||
delete m_settings;
|
||||
m_settings = nullptr;
|
||||
|
||||
}
|
||||
|
||||
//获取网路详情信息
|
||||
void NetDetail::getConInfo(QList<ConInfo>& qlConInfo)
|
||||
{
|
||||
ConInfo conInfo;
|
||||
KyConnectSetting connetSetting;
|
||||
KyWirelessNetItem kyWirelessNetItem;
|
||||
KyWirelessNetResource *m_resource = new KyWirelessNetResource(this);
|
||||
KyConnectResourse *kyConnectResourse = new KyConnectResourse(this);
|
||||
|
||||
QString deviceName;
|
||||
QString hardAddress;
|
||||
int bandWith;
|
||||
|
||||
if (!m_devList.isEmpty()) {
|
||||
deviceName = m_devList.at(0);
|
||||
}
|
||||
if(isWlan) {
|
||||
if (!m_resource->getWifiNetwork(deviceName, m_name, kyWirelessNetItem)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
kyConnectResourse->getConnectionSetting(m_uuid,connetSetting);
|
||||
|
||||
conInfo.strConUUID = m_uuid;
|
||||
conInfo.strIPV4ConfigType = QString("%1").arg(connetSetting.m_ipv4ConfigIpType);
|
||||
conInfo.strIPV6ConfigType = QString("%1").arg(connetSetting.m_ipv6ConfigIpType);
|
||||
qDebug()<<"conInfo.strConUUID:"<<conInfo.strConUUID<<"conInfo.strSecType"<<conInfo.strSecType;
|
||||
if (connetSetting.m_ipv4Address.length() > 0) {
|
||||
conInfo.strIPV4Address = connetSetting.m_ipv4Address.at(0).ip().toString();
|
||||
conInfo.strIPV4GateWay = connetSetting.m_ipv4Address.at(0).gateway().toString();
|
||||
} else {
|
||||
conInfo.strIPV4Address = "--";
|
||||
conInfo.strIPV4GateWay = "--";
|
||||
qDebug()<<"m_ipv4Address length is 0";
|
||||
}
|
||||
if (connetSetting.m_ipv6Address.length() > 0) {
|
||||
conInfo.strIPV6Address = connetSetting.m_ipv6Address.at(0).ip().toString();
|
||||
conInfo.strIPV6GateWay = connetSetting.m_ipv6Address.at(0).gateway().toString();
|
||||
} else {
|
||||
conInfo.strIPV6Address = "--";
|
||||
conInfo.strIPV6GateWay = "--";
|
||||
qDebug()<<"m_ipv4Address length is 0";
|
||||
}
|
||||
|
||||
if (isWlan && isActive) {
|
||||
conInfo.strConType = "802-11-wireless";
|
||||
KyActiveConnectResourse *activeResourse = new KyActiveConnectResourse(this);
|
||||
QString ipv4,ipv6;
|
||||
QList<QHostAddress> ipv4Dns,ipv6Dns;
|
||||
activeResourse->getActiveConnectIpInfo(m_uuid,ipv4,ipv6);
|
||||
activeResourse->getActiveConnectDnsInfo(m_uuid,ipv4Dns,ipv6Dns);
|
||||
m_netDeviceResource->getHardwareInfo(deviceName, hardAddress, bandWith);
|
||||
|
||||
qDebug()<<"802-11-wireless : "<<"deviceName:"<<deviceName<<",ssid:"<<m_ssid<<",uuid:"<<m_uuid;
|
||||
|
||||
if (ipv4Dns.length() == 1) {
|
||||
conInfo.strIPV4FirDns = ipv4Dns.at(0).toString();
|
||||
conInfo.strIPV4SecDns = "--";
|
||||
} else if (ipv4Dns.length() == 2){
|
||||
conInfo.strIPV4FirDns = ipv4Dns.at(0).toString();
|
||||
conInfo.strIPV4SecDns = ipv4Dns.at(1).toString();
|
||||
} else {
|
||||
conInfo.strIPV4FirDns = "--";
|
||||
conInfo.strIPV4SecDns = "--";
|
||||
qDebug()<<"ipv4Dns length is 0";
|
||||
}
|
||||
if (ipv6Dns.length() == 1) {
|
||||
conInfo.strIPV6FirDns = ipv6Dns.at(0).toString();
|
||||
conInfo.strIPV6SecDns = "--";
|
||||
} else if (ipv4Dns.length() == 2){
|
||||
conInfo.strIPV6FirDns = ipv6Dns.at(0).toString();
|
||||
conInfo.strIPV6SecDns = ipv6Dns.at(1).toString();
|
||||
} else {
|
||||
conInfo.strIPV6FirDns = "--";
|
||||
conInfo.strIPV6SecDns = "--";
|
||||
qDebug()<<"ipv6Dns length is 0";
|
||||
}
|
||||
|
||||
conInfo.strSecType = kyWirelessNetItem.m_secuType;
|
||||
conInfo.strMac = kyWirelessNetItem.m_bssid;
|
||||
conInfo.strHz = QString("%1").arg(kyWirelessNetItem.m_frequency) +" MHz";
|
||||
conInfo.strConName = kyWirelessNetItem.m_NetSsid;
|
||||
conInfo.strIPV4Address = ipv4;
|
||||
conInfo.strIPV6Address = ipv6;
|
||||
conInfo.strBandWidth = QString("%1").arg(bandWith/1000) + "Mbps";
|
||||
} else if (isWlan && !isActive) {
|
||||
conInfo.strConType = "802-11-wireless";
|
||||
} else {
|
||||
conInfo.strConType = "802-3-ethernet";
|
||||
qDebug()<<"802-11-ethernet : "<<"deviceName:"<<m_deviceName<<",ssid:"<<m_ssid<<",uuid:"<<m_uuid;
|
||||
conInfo.strConName = m_name;
|
||||
qDebug()<<"conInfo.strConName :aaaaaa"<<conInfo.strConName;
|
||||
m_netDeviceResource->getHardwareInfo(m_deviceName, hardAddress, bandWith);
|
||||
if (connetSetting.m_ipv4Dns.length() == 1) {
|
||||
conInfo.strIPV4FirDns = connetSetting.m_ipv4Dns.at(0).toString();
|
||||
conInfo.strIPV4SecDns = "--";
|
||||
} else if (connetSetting.m_ipv4Dns.length() == 2) {
|
||||
conInfo.strIPV4FirDns = connetSetting.m_ipv4Dns.at(0).toString();
|
||||
conInfo.strIPV4SecDns = connetSetting.m_ipv4Dns.at(1).toString();
|
||||
} else {
|
||||
conInfo.strIPV4FirDns = "--";
|
||||
conInfo.strIPV4SecDns = "--";
|
||||
qDebug()<<"m_ipv4DNS length is 0";
|
||||
}
|
||||
if (connetSetting.m_ipv6Dns.length() == 1) {
|
||||
conInfo.strIPV6FirDns = connetSetting.m_ipv6Dns.at(0).toString();
|
||||
conInfo.strIPV6SecDns = "--";
|
||||
} else if (connetSetting.m_ipv6Dns.length() == 2) {
|
||||
conInfo.strIPV6FirDns = connetSetting.m_ipv6Dns.at(0).toString();
|
||||
conInfo.strIPV6SecDns = connetSetting.m_ipv6Dns.at(1).toString();
|
||||
} else {
|
||||
conInfo.strIPV6FirDns = "--";
|
||||
conInfo.strIPV6SecDns = "--";
|
||||
qDebug()<<"m_ipv6DNS length is 0";
|
||||
}
|
||||
conInfo.strBandWidth = QString("%1").arg(bandWith/1000) + "Mbps";
|
||||
conInfo.strMac = hardAddress;
|
||||
}
|
||||
qlConInfo.append(conInfo);
|
||||
}
|
||||
|
||||
//点击了保存更改网络设置的按钮
|
||||
void NetDetail::on_btnConfirm_clicked()
|
||||
{
|
||||
if (checkConfig()) {
|
||||
|
||||
} else {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//检测网络配置信息是否改变
|
||||
bool NetDetail::checkConfig() {
|
||||
return false;
|
||||
}
|
||||
|
||||
void NetDetail::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
Q_UNUSED(event)
|
||||
|
||||
QPainter p(this);
|
||||
p.setRenderHint(QPainter::Antialiasing);
|
||||
QPainterPath rectPath;
|
||||
rectPath.addRoundedRect(this->rect().adjusted(12, 12, -12, -12), 12, 12);
|
||||
|
||||
// 画一个黑底
|
||||
QPixmap pixmap(this->rect().size());
|
||||
pixmap.fill(Qt::transparent);
|
||||
QPainter pixmapPainter(&pixmap);
|
||||
pixmapPainter.setRenderHint(QPainter::Antialiasing);
|
||||
pixmapPainter.setPen(Qt::transparent);
|
||||
pixmapPainter.setBrush(Qt::black);
|
||||
pixmapPainter.setOpacity(0.65);
|
||||
pixmapPainter.drawPath(rectPath);
|
||||
pixmapPainter.end();
|
||||
|
||||
// 模糊这个黑底
|
||||
QImage img = pixmap.toImage();
|
||||
qt_blurImage(img, 10, false, false);
|
||||
|
||||
// 挖掉中心
|
||||
pixmap = QPixmap::fromImage(img);
|
||||
QPainter pixmapPainter2(&pixmap);
|
||||
pixmapPainter2.setRenderHint(QPainter::Antialiasing);
|
||||
pixmapPainter2.setCompositionMode(QPainter::CompositionMode_Clear);
|
||||
pixmapPainter2.setPen(Qt::transparent);
|
||||
pixmapPainter2.setBrush(Qt::transparent);
|
||||
pixmapPainter2.drawPath(rectPath);
|
||||
|
||||
// 绘制阴影
|
||||
p.drawPixmap(this->rect(), pixmap, pixmap.rect());
|
||||
|
||||
// 绘制一个背景
|
||||
p.save();
|
||||
p.fillPath(rectPath, palette().color(QPalette::Base));
|
||||
p.restore();
|
||||
}
|
|
@ -0,0 +1,129 @@
|
|||
#ifndef NETDETAIL_H
|
||||
#define NETDETAIL_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QPainter>
|
||||
#include <QObject>
|
||||
#include <QStackedWidget>
|
||||
#include <QLayout>
|
||||
#include <QLabel>
|
||||
#include <QPushButton>
|
||||
#include <QVariantMap>
|
||||
#include <QDesktopWidget>
|
||||
#include <QApplication>
|
||||
#include <QDebug>
|
||||
#include <QSettings>
|
||||
|
||||
#include <QDBusMessage>
|
||||
#include <QDBusObjectPath>
|
||||
#include <QDBusInterface>
|
||||
#include <QDBusReply>
|
||||
|
||||
#include "detailpage.h"
|
||||
#include "ipv4page.h"
|
||||
#include "ipv6page.h"
|
||||
#include "securitypage.h"
|
||||
#include "creatnetpage.h"
|
||||
#include "kywirelessnetitem.h"
|
||||
#include "kylinconnectresource.h"
|
||||
#include "kylinactiveconnectresource.h"
|
||||
#include "kywirelessnetresource.h"
|
||||
#include "tab-pages/tabpage.h"
|
||||
|
||||
static int AUTO_CONFIG = 0;
|
||||
static int MANUAL_CONFIG = 1;
|
||||
|
||||
typedef struct ConInfo_s {
|
||||
QString strConName;
|
||||
QString strConUUID;
|
||||
QString strConType;
|
||||
QString strSecType;
|
||||
QString strChan;
|
||||
QString strMac;
|
||||
QString strHz;
|
||||
QString strBandWidth;
|
||||
|
||||
QString strIPV4ConfigType;
|
||||
QString strIPV4Address;
|
||||
QString strIPV4Prefix;
|
||||
QString strIPV4FirDns;
|
||||
QString strIPV4SecDns;
|
||||
QString strIPV4GateWay;
|
||||
|
||||
QString strIPV6ConfigType;
|
||||
QString strIPV6Address;
|
||||
QString strIPV6FirDns;
|
||||
QString strIPV6SecDns;
|
||||
QString strIPV6GateWay;
|
||||
QString strIPV6Prefix;
|
||||
}ConInfo;
|
||||
|
||||
|
||||
class NetDetail : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
NetDetail(QString name, QString uuid, bool isActive, bool isWlan, bool isCreateNet, QWidget *parent = nullptr);
|
||||
~NetDetail();
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *event);
|
||||
|
||||
private:
|
||||
void initUI();
|
||||
void initWifiDevice();//初始化无线默认设备
|
||||
void initLanDevice();//初始化有线默认设备
|
||||
void centerToScreen();
|
||||
void initComponent();
|
||||
void getConInfo(QList<ConInfo>& qlConInfo);
|
||||
bool checkConfig();
|
||||
void loadPage();
|
||||
void pagePadding(QString netName, bool isWlan);
|
||||
|
||||
private:
|
||||
KyNetworkDeviceResourse *m_netDeviceResource = nullptr;
|
||||
|
||||
QStackedWidget * stackWidget;
|
||||
|
||||
DetailPage * detailPage;
|
||||
Ipv4Page * ipv4Page;
|
||||
Ipv6Page * ipv6Page;
|
||||
SecurityPage * securityWidget;
|
||||
CreatNetPage * createNetPage;
|
||||
// AddLanWidget * addLanWidget;
|
||||
|
||||
QWidget * titleWidget;
|
||||
QWidget * centerWidget;
|
||||
QWidget * bottomWidget;
|
||||
|
||||
QLabel * titleLabel;
|
||||
QLabel * iconLabel;
|
||||
|
||||
QPushButton * closeBtn;
|
||||
QPushButton * cancelBtn;
|
||||
QPushButton * forgetBtn;
|
||||
QPushButton * confimBtn;
|
||||
|
||||
QPushButton * detailBtn;
|
||||
QPushButton * ipv4Btn;
|
||||
QPushButton * ipv6Btn;
|
||||
QPushButton * securityBtn;
|
||||
QFrame * pageFrame;
|
||||
|
||||
QString m_name;
|
||||
QString m_uuid;
|
||||
QString m_ssid;
|
||||
QStringList m_devList;
|
||||
QString m_deviceName;
|
||||
|
||||
bool isWlan;
|
||||
bool isCreateNet;
|
||||
bool isActive;
|
||||
|
||||
QList<ConInfo> mInfo;
|
||||
|
||||
private slots:
|
||||
void on_btnConfirm_clicked();
|
||||
|
||||
};
|
||||
#endif // NETDETAIL_H
|
|
@ -0,0 +1,11 @@
|
|||
#include "securitypage.h"
|
||||
|
||||
SecurityPage::SecurityPage(QWidget *parent) : QFrame(parent)
|
||||
{
|
||||
initUI();
|
||||
}
|
||||
|
||||
void SecurityPage::initUI()
|
||||
{
|
||||
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
#ifndef SECURITYWIDGET_H
|
||||
#define SECURITYWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QFormLayout>
|
||||
#include <QComboBox>
|
||||
#include <QLabel>
|
||||
#include <QLineEdit>
|
||||
|
||||
class SecurityPage : public QFrame
|
||||
{
|
||||
public:
|
||||
SecurityPage(QWidget *parent = nullptr);
|
||||
private:
|
||||
QFormLayout *mDetailLayout;
|
||||
|
||||
private:
|
||||
void initUI();
|
||||
|
||||
};
|
||||
|
||||
#endif // SECURITYWIDGET_H
|
Loading…
Reference in New Issue