Merge branch 'dbus-interface' into 'dbus-interface'

# Conflicts:
#   src/frontend/netdetails/netdetail.h
#   src/frontend/tab-pages/lanpage.cpp
This commit is contained in:
Zhai Kangning 2021-10-15 11:41:34 +00:00
commit cd2d88e793
26 changed files with 391 additions and 126 deletions

View File

@ -560,3 +560,23 @@ bool KyActiveConnectResourse::isActiveConnection(QString uuid, QStringList &devN
}
}
}
QString KyActiveConnectResourse::getDeviceOfActivateConnect(QString conUuid)
{
QString deviceName = "";
NetworkManager::ActiveConnection::Ptr activeConnectPtr =
m_networkResourceInstance->getActiveConnect(conUuid);
if (nullptr == activeConnectPtr) {
qWarning()<< "[KyActiveConnectResourse]" <<"it can not find connect "<< conUuid;
return deviceName;
}
QStringList interfaces = activeConnectPtr->devices();
QString ifaceUni = interfaces.at(0);
NetworkManager::Device:: Ptr devicePtr =
m_networkResourceInstance->findDeviceUni(ifaceUni);
deviceName = devicePtr->interfaceName();
return deviceName;
}

View File

@ -37,6 +37,8 @@ public:
bool isActiveConnection(QString uuid, QStringList &devName);
QString getDeviceOfActivateConnect(QString conUuid);
private:
void getActiveConnectIp(NetworkManager::ActiveConnection::Ptr activeConnectPtr,
QString &ipv4Address,

View File

@ -7,6 +7,7 @@ KyApConnectItem::KyApConnectItem(QObject *parent) : QObject(parent)
m_connectUuid = "";
m_ifaceName = "";
m_password = "";
m_band = "";
m_isActivated = false;
}

View File

@ -16,7 +16,9 @@ public:
QString m_connectUuid;
QString m_ifaceName;
QString m_password;
QString m_band;
bool m_isActivated;
};
#endif // KYLINAPCONNECTITEM_H

View File

@ -211,6 +211,7 @@ void KyConnectOperation::deactivateConnection(const QString activeConnectName, c
NetworkManager::ActiveConnection::Ptr activateConnectPtr = nullptr;
qDebug()<<"deactivetate connect name"<<activeConnectName<<"uuid"<<activeConnectUuid;
activateConnectPtr = m_networkResourceInstance->getActiveConnect(activeConnectUuid);
if (nullptr == activateConnectPtr) {
QString errorMessage = tr("it can not find the activate connect")

View File

@ -8,6 +8,25 @@
#include <NetworkManagerQt/VpnPlugin>
#include <NetworkManagerQt/VpnSetting>
const QString str2GBand = "2.4Ghz";
const QString str5GBand = "5Ghz";
static bool subLanListSort(const KyConnectItem* info1, const KyConnectItem* info2)
{
QString name1 = info1->m_connectName;
QString name2 = info2->m_connectName;
bool result = true;
if (QString::compare(name1, name2, Qt::CaseInsensitive) > 0) {
result = false;
}
return result;
}
static void lanListSort(QList<KyConnectItem *> &list)
{
qSort(list.begin(), list.end(), subLanListSort);
}
KyConnectResourse::KyConnectResourse(QObject *parent) : QObject(parent)
{
m_networkResourceInstance = KyNetworkResourceManager::getInstance();
@ -152,6 +171,9 @@ void KyConnectResourse::getConnectionList(QString deviceName,
connectPtr = nullptr;
}
if (connectItemList.size() > 1) {
lanListSort(connectItemList);
}
return;
}
@ -530,6 +552,11 @@ KyApConnectItem *KyConnectResourse::getApConnectItem(NetworkManager::Connection:
KyApConnectItem *apConnectItem = new KyApConnectItem();
apConnectItem->m_connectName = connectPtr->name();
apConnectItem->m_connectUuid = connectPtr->uuid();
if (wirelessSetting->band() == NetworkManager::WirelessSetting::FrequencyBand::A) {
apConnectItem->m_band = str2GBand;
} else if (wirelessSetting->band() == NetworkManager::WirelessSetting::FrequencyBand::Bg) {
apConnectItem->m_band = str5GBand;
}
apConnectItem->m_ifaceName = settingPtr->interfaceName();
apConnectItem->m_isActivated = m_networkResourceInstance->isActiveConnection(connectPtr->uuid());

View File

@ -202,6 +202,33 @@ void KyNetworkDeviceResourse::getDeviceActiveAPInfo(const QString devName, QStri
}
}
int KyNetworkDeviceResourse::getWirelessDeviceCapability(const QString deviceName)
{
NetworkManager::Device::Ptr connectDevice =
m_networkResourceInstance->findDeviceInterface(deviceName);
if (connectDevice->isValid()
&& NetworkManager::Device::Type::Wifi == connectDevice->type()) {
NetworkManager::WirelessDevice *wirelessDevicePtr =
qobject_cast<NetworkManager::WirelessDevice *>(connectDevice.data());
int cap = 0;
if (wirelessDevicePtr->wirelessCapabilities() & NetworkManager::WirelessDevice::ApCap) {
cap = cap | 0x01;
}
if (wirelessDevicePtr->wirelessCapabilities() & NetworkManager::WirelessDevice::Freq2Ghz) {
cap = cap | 0x02;
}
if (wirelessDevicePtr->wirelessCapabilities() & NetworkManager::WirelessDevice::Freq5Ghz) {
cap = cap | 0x04;
}
return cap;
} else {
qWarning()<<"[KyNetworkDeviceResourse]"<<deviceName<<" is not valid or not wireless.";
}
return 0;
}
#if 0
void KyNetworkDeviceResourse::DeviceSpeed(QString deviceName, KyConnectItem *wiredItem)
{

View File

@ -37,6 +37,7 @@ public:
// void disconnectDevice();
//void setDeviceAutoConnect();
void getDeviceActiveAPInfo(const QString devName, QString &strMac, uint &iHz, uint &iChan, QString &secuType);
int getWirelessDeviceCapability(const QString deviceName);
private:
KyWiredConnectOperation wiredOperation;

View File

@ -684,7 +684,10 @@ bool KyWirelessConnectOperation::getConnSecretFlags(QString &connUuid, NetworkMa
}
NetworkManager::ConnectionSettings::Ptr
KyWirelessConnectOperation::createWirelessApSetting(const QString apSsid, const QString apPassword, const QString apDevice)
KyWirelessConnectOperation::createWirelessApSetting(const QString apSsid,
const QString apPassword,
const QString apDevice,
const QString wirelessBand)
{
NetworkManager::ConnectionSettings::Ptr connectionSettings =
NetworkManager::ConnectionSettings::Ptr(new NetworkManager::ConnectionSettings(NetworkManager::ConnectionSettings::Wireless));
@ -710,6 +713,15 @@ NetworkManager::ConnectionSettings::Ptr
wirelessSetting->setSsid(apSsid.toUtf8());
wirelessSetting->setMode(NetworkManager::WirelessSetting::NetworkMode::Ap);
wirelessSetting->setSecurity("802-11-wireless-security");
if (wirelessBand == WIFI_BAND_2_4GHZ) {
wirelessSetting->setBand(NetworkManager::WirelessSetting::FrequencyBand::Bg);
} else if (wirelessBand == WIFI_BAND_5GHZ) {
wirelessSetting->setBand(NetworkManager::WirelessSetting::FrequencyBand::A);
} else {
qWarning()<<"[KyWirelessConnectOperation] the band type undefined"<<wirelessBand;
wirelessSetting->setBand(NetworkManager::WirelessSetting::FrequencyBand::Automatic);
}
NetworkManager::WirelessSecuritySetting::Ptr wirelessSecuritySetting
= connectionSettings->setting(NetworkManager::Setting::WirelessSecurity).dynamicCast<NetworkManager::WirelessSecuritySetting>();
@ -726,7 +738,9 @@ NetworkManager::ConnectionSettings::Ptr
void KyWirelessConnectOperation::updateWirelessApSetting(
NetworkManager::Connection::Ptr apConnectPtr,
const QString apName, const QString apPassword, const QString apDevice)
const QString apName, const QString apPassword,
const QString apDevice, const QString wirelessBand)
{
NetworkManager::ConnectionSettings::Ptr apConnectSettingPtr = apConnectPtr->settings();
apConnectSettingPtr->setId(apName);
@ -737,6 +751,15 @@ void KyWirelessConnectOperation::updateWirelessApSetting(
= apConnectSettingPtr->setting(NetworkManager::Setting::Wireless).dynamicCast<NetworkManager::WirelessSetting>();
wirelessSetting->setInitialized(true);
wirelessSetting->setSsid(apName.toUtf8());
if (wirelessBand == WIFI_BAND_2_4GHZ) {
wirelessSetting->setBand(NetworkManager::WirelessSetting::FrequencyBand::Bg);
} else if (wirelessBand == WIFI_BAND_5GHZ) {
wirelessSetting->setBand(NetworkManager::WirelessSetting::FrequencyBand::A);
} else {
qWarning()<<"[KyWirelessConnectOperation] the band type undefined"<<wirelessBand;
wirelessSetting->setBand(NetworkManager::WirelessSetting::FrequencyBand::Automatic);
}
NetworkManager::WirelessSecuritySetting::Ptr wirelessSecuritySetting
= apConnectSettingPtr->setting(NetworkManager::Setting::WirelessSecurity).dynamicCast<NetworkManager::WirelessSecuritySetting>();
@ -752,8 +775,11 @@ void KyWirelessConnectOperation::updateWirelessApSetting(
}
void KyWirelessConnectOperation::activeWirelessAp(const QString apUuid, const QString apName,
const QString apPassword, const QString apDevice)
const QString apPassword, const QString apDevice,
const QString wirelessBand)
{
qDebug() << "activeWirelessAp]" << apUuid << apName << apPassword << apDevice << wirelessBand;
//1、检查连接是否存在
NetworkManager::Connection::Ptr connectPtr = m_networkResourceInstance->getConnect(apUuid);
if (nullptr == connectPtr) {
@ -768,7 +794,7 @@ void KyWirelessConnectOperation::activeWirelessAp(const QString apUuid, const QS
QString deviceIdentifier = devicePtr->uni();
NetworkManager::ConnectionSettings::Ptr apConnectSettingPtr =
createWirelessApSetting(apName, apPassword, apDevice);
createWirelessApSetting(apName, apPassword, apDevice, wirelessBand);
QString specificObject = "";
QDBusPendingCallWatcher * watcher;
watcher = new QDBusPendingCallWatcher{NetworkManager::addAndActivateConnection(apConnectSettingPtr->toMap(), deviceIdentifier, specificObject), this};
@ -781,7 +807,7 @@ void KyWirelessConnectOperation::activeWirelessAp(const QString apUuid, const QS
watcher->deleteLater();
});
} else {
updateWirelessApSetting(connectPtr, apName, apPassword, apDevice);
updateWirelessApSetting(connectPtr, apName, apPassword, apDevice, wirelessBand);
QTimer::singleShot(500, this, [=](){
activateApConnectionByUuid(apUuid, apDevice);
});

View File

@ -11,6 +11,9 @@
const QByteArray GSETTINGS_SCHEMA = "org.ukui.kylin-nm.switch";
const QString WIRELESS_SWITCH = "wirelessswitch";
const QString WIFI_BAND_2_4GHZ = "2.4Ghz";
const QString WIFI_BAND_5GHZ = "5Ghz";
enum KySecuType {
NONE = 0,
WPA_AND_WPA2_PERSONAL,
@ -105,13 +108,22 @@ public:
//申请扫描
void requestWirelessScan();
void activeWirelessAp(const QString apUuid, const QString apName, const QString apPassword, const QString apDevice);
void activeWirelessAp(const QString apUuid, const QString apName,
const QString apPassword, const QString apDevice,
const QString wirelessBand);
void deactiveWirelessAp(const QString apName, const QString apUuid);
private:
NetworkManager::ConnectionSettings::Ptr createWirelessApSetting(const QString apSsid, const QString apPassword, const QString apDevice);
NetworkManager::ConnectionSettings::Ptr createWirelessApSetting(const QString apSsid,
const QString apPassword,
const QString apDevice,
const QString wirelessBand);
void updateWirelessApSetting(NetworkManager::Connection::Ptr apConnectPtr,
const QString apName, const QString apPassword, const QString apDevice);
const QString apName,
const QString apPassword,
const QString apDevice,
const QString wirelessBand);

View File

@ -30,6 +30,7 @@ DbusAdaptor::DbusAdaptor(MainWindow *parent)
{
// constructor
qDBusRegisterMetaType<QMap<QString, bool> >();
qDBusRegisterMetaType<QMap<QString, int> >();
qDBusRegisterMetaType<QVector<QStringList> >();
qDBusRegisterMetaType<QMap<QString, QVector<QStringList> >>();
//setAutoRelaySignals(true)后会自动转发mainwindow发出的同名信号因此不必再额外写一个转发
@ -175,6 +176,14 @@ QMap<QString, bool> DbusAdaptor::getDeviceListAndEnabled(int devType)
return map;
}
//获取无线设备能力
QMap<QString, int> DbusAdaptor::getWirelessDeviceCap()
{
QMap<QString, int> map;
parent()->getWirelessDeviceCap(map);
return map;
}
//唤起属性页 根据网卡类型 参数2 为ssid/uuid
void DbusAdaptor::showPropertyWidget(QString devName, QString ssid)
{
@ -190,15 +199,15 @@ void DbusAdaptor::showCreateWiredConnectWidget(QString devName)
}
//开启热点
void DbusAdaptor::activeWirelessAp(const QString apName, const QString apPassword, const QString apDevice)
void DbusAdaptor::activeWirelessAp(const QString apName, const QString apPassword, const QString band, const QString apDevice)
{
parent()->activeWirelessAp(apName, apPassword, apDevice);
parent()->activeWirelessAp(apName, apPassword, band, apDevice);
}
//断开热点
void DbusAdaptor::deactiveWirelessAp(const QString apName, const QString apPassword, const QString apDevice)
void DbusAdaptor::deactiveWirelessAp(const QString apName, const QString uuid)
{
parent()->deactiveWirelessAp(apName, apPassword, apDevice);
parent()->deactiveWirelessAp(apName, uuid);
}
//获取热点
@ -210,6 +219,14 @@ QStringList DbusAdaptor::getStoredApInfo()
return list;
}
QStringList DbusAdaptor::getApInfoBySsid(QString devName, QString ssid)
{
QStringList list;
list.clear();
parent()->getApInfoBySsid(devName, ssid, list);
return list;
}
//扫描
void DbusAdaptor::reScan()

View File

@ -68,16 +68,19 @@ public Q_SLOTS: // METHODS
Q_NOREPLY void deActivateConnect(int type, QString devName, QString ssid);
//获取设备列表和启用/禁用状态
QMap<QString, bool> getDeviceListAndEnabled(int devType);
//获取无线设备能力
QMap<QString, int> getWirelessDeviceCap();
//唤起属性页 根据网卡类型 参数2 为ssid/uuid
Q_NOREPLY void showPropertyWidget(QString devName, QString ssid);
//唤起新建有线连接界面
Q_NOREPLY void showCreateWiredConnectWidget(QString devName);
//开启热点
void activeWirelessAp(const QString apName, const QString apPassword, const QString apDevice);
void activeWirelessAp(const QString apName, const QString apPassword, const QString band, const QString apDevice);
//断开热点
void deactiveWirelessAp(const QString apName, const QString apPassword, const QString apDevice);
void deactiveWirelessAp(const QString apName, const QString uuid);
//获取热点
QStringList getStoredApInfo();
QStringList getApInfoBySsid(QString devName, QString ssid);
//wifi扫描
void reScan();
Q_SIGNALS: // SIGNALS
@ -99,7 +102,7 @@ Q_SIGNALS: // SIGNALS
//热点断开
void hotspotDeactivated(QString devName, QString ssid);
//热点连接
void hotspotActivated(QString devName, QString ssid);
void hotspotActivated(QString devName, QString ssid, QString uuid);
//信号强度变化
void signalStrengthChange(QString devName, QString ssid, int strength);

View File

@ -420,30 +420,34 @@ void MainWindow::getWiredList(QMap<QString, QVector<QStringList>> &map)
* @param apPassword
* @param apDevice
*/
void MainWindow::activeWirelessAp(const QString apName, const QString apPassword, const QString apDevice)
void MainWindow::activeWirelessAp(const QString apName, const QString apPassword, const QString band, const QString apDevice)
{
m_wlanWidget->activeWirelessAp(apName, apPassword, apDevice);
m_wlanWidget->activeWirelessAp(apName, apPassword, band, apDevice);
}
/**
* @brief MainWindow::activeWirelessAp dbus调用
* @param apName
*/
void MainWindow::deactiveWirelessAp(const QString apName, const QString apPassword, const QString apDevice)
void MainWindow::deactiveWirelessAp(const QString apName, const QString uuid)
{
m_wlanWidget->deactiveWirelessAp(apName, apPassword, apDevice);
m_wlanWidget->deactiveWirelessAp(apName, uuid);
}
/**
* @brief MainWindow::activeWirelessAp dbus调用
* @param list
*/
void MainWindow::getApInfoBySsid(QString devName, QString ssid, QStringList &list)
{
m_wlanWidget->getApInfoBySsid(devName, ssid, list);
}
void MainWindow::getStoredApInfo(QStringList &list)
{
m_wlanWidget->getStoredApInfo(list);
}
void MainWindow::setWiredDeviceEnable(const QString& devName, bool enable)
{
m_lanWidget->setWiredDeviceEnable(devName, enable);
@ -485,6 +489,11 @@ void MainWindow::showCreateWiredConnectWidget(const QString devName)
netDetail->show();
}
void MainWindow::getWirelessDeviceCap(QMap<QString, int> &map)
{
m_wlanWidget->getWirelessDeviceCap(map);
}
//有线连接断开
void MainWindow::activateWired(const QString& devName, const QString& connUuid)
{

View File

@ -30,11 +30,12 @@ public:
void getWirelessList(QMap<QString, QVector<QStringList> > &map);
void getWiredList(QMap<QString, QVector<QStringList>> &map);
//开启热点
void activeWirelessAp(const QString apName, const QString apPassword, const QString apDevice);
void activeWirelessAp(const QString apName, const QString apPassword, const QString wirelessBand, const QString apDevice);
//断开热点
void deactiveWirelessAp(const QString apName, const QString apPassword, const QString apDevice);
void deactiveWirelessAp(const QString apName, const QString uuid);
//获取热点
void getStoredApInfo(QStringList &list);
void getApInfoBySsid(QString devName, QString ssid, QStringList &list);
//有线连接断开
void activateWired(const QString& devName, const QString& connUuid);
void deactivateWired(const QString& devName, const QString& connUuid);
@ -49,6 +50,8 @@ public:
//唤起新建有线连接界面
void showCreateWiredConnectWidget(const QString devName);
void getWirelessDeviceCap(QMap<QString, int> &map);
void rescan();
signals:
@ -68,7 +71,7 @@ signals:
void deactivateFailed(QString errorMessage);
//热点断开
void hotspotDeactivated(QString devName, QString ssid);
void hotspotActivated(QString devName, QString ssid);
void hotspotActivated(QString devName, QString ssid, QString uuid);
//信号强度变化
void signalStrengthChange(QString devName, QString ssid, int strength);
//安全性变化

View File

@ -1,6 +0,0 @@
#include "detailitem.h"
DetailItem::DetailItem(QWidget *parent) : QWidget(parent)
{
}

View File

@ -1,16 +0,0 @@
#ifndef DETAILITEM_H
#define DETAILITEM_H
#include <QWidget>
class DetailItem : public QWidget
{
Q_OBJECT
public:
explicit DetailItem(QWidget *parent = nullptr);
signals:
};
#endif // DETAILITEM_H

View File

@ -1,5 +1,6 @@
#include "detailpage.h"
#include <QPainter>
#include <QListWidget>
extern void qt_blurImage(QImage &blurImage, qreal radius, bool quality, int transposed);
@ -73,68 +74,78 @@ bool DetailPage::checkIsChanged(const ConInfo info)
}
}
void DetailPage::addDetailItem(QListWidget *listWidget, DetailWidget *detailWidget)
{
QListWidgetItem *listWidgetItem = new QListWidgetItem(listWidget);
listWidgetItem->setSizeHint(QSize(listWidget->width(),36));
listWidgetItem->setFlags(Qt::NoItemFlags);
listWidget->addItem(listWidgetItem);
listWidget->setItemWidget(listWidgetItem, detailWidget);
}
void DetailPage::initUI() {
forgetNetBox = new QCheckBox(this);
layout = new QVBoxLayout(this);
layout->setContentsMargins(0,0,0,0);
mDetailLayout = new QFormLayout(this);
QWidget *mDetailFrame = new QFrame(this);
mDetailLayout = new QVBoxLayout(mDetailFrame);
mDetailLayout->setContentsMargins(0,0,0,0);
m_listWidget = new QListWidget(mDetailFrame);
m_listWidget->setFrameShape(QFrame::Shape::NoFrame);
m_listWidget->setBackgroundRole(QPalette::Base);
m_listWidget->setFocusPolicy(Qt::FocusPolicy::NoFocus);
mDetailLayout->addWidget(m_listWidget);
mSSID = new QLineEdit(this);
mSSID->setAlignment(Qt::AlignRight);
if (!isCreate) {
mSSID->setStyleSheet("background:transparent;border-width:0;border-style:outset");
mSSID->setStyleSheet("background:transparent;border-width:0px;border-style:none");
mSSID->setFocusPolicy(Qt::NoFocus);
} else {
mSSID->setStyleSheet("border-width:0;border-style:outset");
// mSSID->setStyleSheet("border-width:1px;;border-style:solid;border-color:black;border-radius:2px");
mSSID->setStyleSheet("border-top:0px solid;border-bottom:1px solid;border-left:0px solid;border-right: 0px solid;");
mSSID->setPlaceholderText(tr("Please input SSID:"));
}
QHBoxLayout *mSsidLayout = new QHBoxLayout(this);
mSsidLayout->addStretch();
mSsidLayout->addWidget(mSSID);
m_ssidWidget = new DetailWidget(qobject_cast<QWidget *>(mSSID), m_listWidget);
m_ssidWidget->setKey(tr("SSID:"));
mProtocol = new QLabel(this);
QHBoxLayout *mProtocolLayout = new QHBoxLayout(this);
mProtocolLayout->addStretch();
mProtocolLayout->addWidget(mProtocol);
m_protocolWidget = new DetailWidget(qobject_cast<QWidget *>(mProtocol), m_listWidget);
m_protocolWidget->setKey(tr("Protocol:"));
mSecType = new QLabel(this);
QHBoxLayout *mSecTypeLayout = new QHBoxLayout(this);
mSecTypeLayout->addStretch();
mSecTypeLayout->addWidget(mSecType);
m_secTypeWidget = new DetailWidget(qobject_cast<QWidget *>(mSecType));
m_secTypeWidget->setKey(tr("Security Type:"));
mHz = new QLabel(this);
QHBoxLayout *mHzLayout = new QHBoxLayout(this);
mHzLayout->addStretch();
mHzLayout->addWidget(mHz);
m_hzWidget = new DetailWidget(qobject_cast<QWidget *>(mHz));
m_hzWidget->setKey(tr("Hz:"));
mChan = new QLabel(this);
QHBoxLayout *mChanLayout = new QHBoxLayout(this);
mChanLayout->addStretch();
mChanLayout->addWidget(mChan);
m_chanelWidget = new DetailWidget(qobject_cast<QWidget *>(mChan));
m_chanelWidget->setKey(tr("Chan:"));
mBandWidth = new QLabel(this);
QHBoxLayout *mBandWidthLayout = new QHBoxLayout(this);
mBandWidthLayout->addStretch();
mBandWidthLayout->addWidget(mBandWidth);
m_bandwidthWidget = new DetailWidget(qobject_cast<QWidget *>(mBandWidth), m_listWidget);
m_bandwidthWidget->setKey(tr("BandWidth:"));
mIPV4 = new QLabel(this);
QHBoxLayout *mIPV4Layout = new QHBoxLayout(this);
mIPV4Layout->addStretch();
mIPV4Layout->addWidget(mIPV4);
m_ipv4Widget = new DetailWidget(qobject_cast<QWidget *>(mIPV4), m_listWidget);
m_ipv4Widget->setKey(tr("IPV4:"));
mIPV4Dns = new QLabel(this);
QHBoxLayout *mIPV4DnsLayout = new QHBoxLayout(this);
mIPV4DnsLayout->addStretch();
mIPV4DnsLayout->addWidget(mIPV4Dns);
m_ipv4DnsWidget = new DetailWidget(qobject_cast<QWidget *>(mIPV4Dns), m_listWidget);
m_ipv4DnsWidget->setKey(tr("IPV4 Dns:"));
mIPV6 = new QLabel(this);
QHBoxLayout *mIPV6Layout = new QHBoxLayout(this);
mIPV6Layout->addStretch();
mIPV6Layout->addWidget(mIPV6);
m_ipv6Widget = new DetailWidget(qobject_cast<QWidget *>(mIPV6), m_listWidget);
m_ipv6Widget->setKey(tr("IPV6:"));
mMac = new QLabel(this);
QHBoxLayout *mMacLayout = new QHBoxLayout(this);
mMacLayout->addStretch();
mMacLayout->addWidget(mMac);
m_macWidget = new DetailWidget(qobject_cast<QWidget *>(mMac), m_listWidget);
m_macWidget->setKey(tr("Mac:"));
autoConnect = new QLabel(this);
@ -147,23 +158,28 @@ void DetailPage::initUI() {
mAutoLayout->addWidget(autoConnect);
mAutoLayout->addSpacerItem(horizontalSpacer);
mDetailLayout->addRow(tr("SSID:"), mSsidLayout);
mDetailLayout->addRow(tr("Protocol:"), mProtocolLayout);
this->addDetailItem(m_listWidget, m_ssidWidget);
this->addDetailItem(m_listWidget, m_protocolWidget);
if (mIsWlan) {
mDetailLayout->addRow(tr("Security Type:"), mSecTypeLayout);
mDetailLayout->addRow(tr("Hz:"), mHzLayout);
mDetailLayout->addRow(tr("Chan:"), mChanLayout);
this->addDetailItem(m_listWidget, m_secTypeWidget);
this->addDetailItem(m_listWidget, m_hzWidget);
this->addDetailItem(m_listWidget, m_chanelWidget);
}
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);
this->addDetailItem(m_listWidget, m_bandwidthWidget);
this->addDetailItem(m_listWidget, m_ipv6Widget);
this->addDetailItem(m_listWidget, m_ipv4Widget);
this->addDetailItem(m_listWidget, m_ipv4DnsWidget);
this->addDetailItem(m_listWidget, m_macWidget);
layout->addLayout(mDetailLayout);
layout->addStretch();
QPalette mpal(m_listWidget->palette());
mpal.setColor(QPalette::Base, qApp->palette().base().color());
mpal.setColor(QPalette::AlternateBase, qApp->palette().alternateBase().color());
m_listWidget->setAlternatingRowColors(true);
// m_listWidget->setAutoFillBackground(true);
m_listWidget->setPalette(mpal);
layout->addWidget(mDetailFrame);
layout->addLayout(mAutoLayout);
}
void DetailPage::setEnableOfSaveBtn() {

View File

@ -7,7 +7,10 @@
#include <QCheckBox>
#include <QSpacerItem>
#include <QDebug>
#include <QListWidget>
#include <QApplication>
#include "detailwidget.h"
#include "coninfo.h"
class DetailPage : public QFrame
@ -34,8 +37,21 @@ public:
private:
void initUI();
void addDetailItem(QListWidget *listWidget, DetailWidget *detailWidget);
public:
QListWidget * m_listWidget = nullptr;
DetailWidget * m_ssidWidget = nullptr;
DetailWidget * m_protocolWidget = nullptr;
DetailWidget * m_secTypeWidget = nullptr;
DetailWidget * m_hzWidget = nullptr;
DetailWidget * m_chanelWidget = nullptr;
DetailWidget * m_bandwidthWidget = nullptr;
DetailWidget * m_ipv4Widget = nullptr;
DetailWidget * m_ipv4DnsWidget = nullptr;
DetailWidget * m_ipv6Widget = nullptr;
DetailWidget * m_macWidget = nullptr;
QLineEdit *mSSID;
QLabel *mProtocol;
QLabel *mSecType;
@ -51,7 +67,7 @@ public:
// QWidget *autoFrame;
private:
QVBoxLayout *layout;
QFormLayout *mDetailLayout;
QVBoxLayout *mDetailLayout;
QHBoxLayout *mAutoLayout;
QCheckBox *forgetNetBox;
bool mIsWlan;

View File

@ -0,0 +1,32 @@
#include "detailwidget.h"
#define ITEM_HEIGHT 36
#define ITEM_MARGINS 18,0,16,0
DetailWidget::DetailWidget(QWidget *valueWidget, QWidget *parent)
: m_valueWidget(valueWidget) , QWidget(parent)
{
// m_valueWidget = valueWidget;
initUI();
}
DetailWidget::~DetailWidget()
{
}
void DetailWidget::initUI()
{
this->setFixedHeight(ITEM_HEIGHT);
m_mainLayout = new QHBoxLayout(this);
m_mainLayout->setContentsMargins(ITEM_MARGINS);
m_keyLabel = new QLabel(this);
m_mainLayout->addWidget(m_keyLabel);
m_mainLayout->addStretch();
m_mainLayout->addWidget(m_valueWidget);
}
void DetailWidget::setKey(const QString &keyLabel)
{
m_keyLabel->setText(keyLabel);
}

View File

@ -0,0 +1,27 @@
#ifndef DetailWidget_H
#define DetailWidget_H
#include <QWidget>
#include <QLabel>
#include <QHBoxLayout>
class DetailWidget : public QWidget
{
Q_OBJECT
public:
explicit DetailWidget(QWidget *valueWidget = nullptr, QWidget *parent = nullptr);
~DetailWidget();
void setKey(const QString &keyLabel);
private:
QHBoxLayout * m_mainLayout = nullptr;
QLabel * m_keyLabel = nullptr;
QWidget * m_valueWidget = nullptr;
void initUI();
signals:
};
#endif // DetailWidget_H

View File

@ -3,8 +3,8 @@
#include "backend/kylinipv6arping.h"
#include "xatom/xatom-helper.h"
#define WINDOW_WIDTH 540
#define WINDOW_HEIGHT 574
#define WINDOW_WIDTH 520
#define WINDOW_HEIGHT 590
#define BUTTON_SIZE 30
#define ICON_SIZE 22,22
#define TITLE_LAYOUT_MARGINS 9,9,0,0
@ -80,6 +80,7 @@ NetDetail::NetDetail(QString interface, QString name, QString uuid, bool isActiv
getConInfo(m_info);
pagePadding(name,isWlan);
connect(qApp, &QApplication::paletteChanged, this, &NetDetail::onPaletteChanged);
isCreateOk = !(m_isCreateNet && !isWlan);
isDetailOk = !(m_name.isEmpty());
@ -97,6 +98,20 @@ NetDetail::~NetDetail()
}
void NetDetail::onPaletteChanged()
{
QPalette pal = qApp->palette();
pal.setColor(QPalette::Window, qApp->palette().base().color());
this->setPalette(pal);
QPalette listwidget_pal(detailPage->m_listWidget->palette());
listwidget_pal.setColor(QPalette::Base, qApp->palette().base().color());
listwidget_pal.setColor(QPalette::AlternateBase, qApp->palette().alternateBase().color());
detailPage->m_listWidget->setAlternatingRowColors(true);
detailPage->m_listWidget->setPalette(listwidget_pal);
}
void NetDetail::paintEvent(QPaintEvent *event)
{
return QDialog::paintEvent(event);
@ -233,6 +248,10 @@ void NetDetail::initUI()
bottomLayout->addWidget(cancelBtn);
bottomLayout->addWidget(confimBtn);
QPalette pal(this->palette());
pal.setColor(QPalette::Background, qApp->palette().base().color());
this->setAutoFillBackground(true);
this->setPalette(pal);
}
void NetDetail::loadPage()

View File

@ -132,5 +132,6 @@ private slots:
signals:
void detailPageClose(bool on);
void onPaletteChanged();
};
#endif // NETDETAIL_H

View File

@ -5,6 +5,7 @@ HEADERS += \
$$PWD/creatnetpage.h \
$$PWD/customtabstyle.h \
$$PWD/detailpage.h \
$$PWD/detailwidget.h \
$$PWD/ipv4page.h \
$$PWD/ipv6page.h \
$$PWD/netdetail.h \
@ -14,6 +15,7 @@ SOURCES += \
$$PWD/creatnetpage.cpp \
$$PWD/customtabstyle.cpp \
$$PWD/detailpage.cpp \
$$PWD/detailwidget.cpp \
$$PWD/ipv4page.cpp \
$$PWD/ipv6page.cpp \
$$PWD/netdetail.cpp \

View File

@ -792,12 +792,21 @@ void LanPage::onUpdateLanlist(QString uuid,
} else if (state == NetworkManager::ActiveConnection::State::Deactivated) {
updateConnectionArea(uuid);
m_isLanConnected = false;
} else if (state == NetworkManager::ActiveConnection::State::Activating
|| state == NetworkManager::ActiveConnection::State::Deactivating) {
QString devName = m_activeResourse->getDeviceOfActivateConnect(uuid);
if (devName.isEmpty()) {
NetworkManager::ConnectionSettings::ConnectionType type;
m_connectResourse->getInterfaceByUuid(devName, type, uuid);
}
emit lanActiveConnectionStateChanged(devName, uuid, state);
}
emit this->lanConnectChanged();
emit this->lanConnectChanged();
return;
}
void LanPage::getWiredList(QMap<QString, QVector<QStringList> > &map)
{
QStringList devlist;

View File

@ -568,7 +568,7 @@ void WlanPage::onActivatedWlanChanged(QString uuid, NetworkManager::ActiveConnec
foreach (auto item, apConnectItemList) {
if (item->m_connectUuid == uuid) {
qDebug() << "[WlanPage] hotspot Deactivated";
emit hotspotActivated(item->m_ifaceName, ssid);
emit hotspotActivated(item->m_ifaceName, ssid, uuid);
break;
}
}
@ -703,6 +703,8 @@ void WlanPage::showControlCenter()
}
void WlanPage::onWifiEnabledChanged(bool isWifiOn)
{
qDebug() << "[WlanPage]onWifiEnabledChanged====================================" << isWifiOn;
qDebug() << "realstatus" << m_wirelessConnectOpreation->getWirelessEnabled();
//监听外部命令导致wifi状态变化更新界面
//应该先检测是否有无线网卡可用,才改变开关状态
m_netDeviceResource->getNetworkDeviceList(NetworkManager::Device::Type::Wifi, m_devList);
@ -828,7 +830,7 @@ void WlanPage::getWirelessList(QMap<QString, QVector<QStringList> > &map)
}
//开启热点
void WlanPage::activeWirelessAp(const QString apName, const QString apPassword, const QString apDevice)
void WlanPage::activeWirelessAp(const QString apName, const QString apPassword, const QString wirelessBand, const QString apDevice)
{
QString uuid("");
QList<KyApConnectItem *> apConnectItemList;
@ -836,29 +838,14 @@ void WlanPage::activeWirelessAp(const QString apName, const QString apPassword,
if (!apConnectItemList.isEmpty()) {
uuid = apConnectItemList.at(0)->m_connectUuid;
}
m_wirelessConnectOpreation->activeWirelessAp(uuid, apName, apPassword, apDevice);
m_wirelessConnectOpreation->activeWirelessAp(uuid, apName, apPassword, apDevice, wirelessBand);
}
//断开热点
void WlanPage::deactiveWirelessAp(const QString apName, const QString apPassword, const QString apDevice)
void WlanPage::deactiveWirelessAp(const QString apName, const QString uuid)
{
QString uuid("");
QList<KyApConnectItem *> apConnectItemList;
m_apConnectResource->getApConnections(apConnectItemList);
if (!apConnectItemList.isEmpty()) {
foreach (auto item, apConnectItemList) {
if (apName == item->m_connectName && apPassword == item->m_password && apDevice == item->m_ifaceName) {
uuid = item->m_connectUuid;
qDebug() << "[WlanPage] deactiveWirelessAp uuid = " << uuid;
break;
}
}
}
if (!uuid.isEmpty()) {
m_wirelessConnectOpreation->deactiveWirelessAp(apName, uuid);
} else {
qDebug() << "[WlanPage] deactiveWirelessAp can not find apName " << apName;
emit deactivateFailed("Deactivate hotspot failed.Don't exist " + apName);
}
}
@ -872,6 +859,22 @@ void WlanPage::getStoredApInfo(QStringList &list)
list << apConnectItemList.at(0)->m_password;
list << apConnectItemList.at(0)->m_ifaceName;
list << (apConnectItemList.at(0)->m_isActivated? "true":"false");
list << apConnectItemList.at(0)->m_connectUuid;
list << apConnectItemList.at(0)->m_band;
}
}
void WlanPage::getApInfoBySsid(QString devName, QString ssid, QStringList &list)
{
list.clear();
QList<KyApConnectItem *> apConnectItemList;
m_apConnectResource->getApConnections(apConnectItemList);
for (int i = 0; i < apConnectItemList.size(); i++) {
if (apConnectItemList.at(i)->m_connectName == ssid
&& apConnectItemList.at(i)->m_ifaceName == devName) {
list << apConnectItemList.at(i)->m_password;
list << apConnectItemList.at(i)->m_band;
}
}
}
@ -967,3 +970,11 @@ void WlanPage::showDetailPage(QString devName, QString ssid)
netDetail->show();
}
void WlanPage::getWirelessDeviceCap(QMap<QString, int> &map)
{
for (int i = 0; i < m_devList.size(); ++i) {
QString devName = m_devList.at(i);
map.insert(devName, m_netDeviceResource->getWirelessDeviceCapability(devName));
}
}

View File

@ -31,23 +31,26 @@ public:
//for dbus
void getWirelessList(QMap<QString, QVector<QStringList> > &map);
//开启热点
void activeWirelessAp(const QString apName, const QString apPassword, const QString apDevice);
void activeWirelessAp(const QString apName, const QString apPassword, const QString wirelessBand, const QString apDevice);
//断开热点
void deactiveWirelessAp(const QString apName, const QString apPassword, const QString apDevice);
void deactiveWirelessAp(const QString apName, const QString uuid);
//获取热点
void getStoredApInfo(QStringList &list);
void getApInfoBySsid(QString devName, QString ssid, QStringList &list);
void activateWireless(const QString& devName, const QString& ssid);
void deactivateWireless(const QString& devName, const QString& ssid);
void showDetailPage(QString devName, QString uuid);
void getWirelessDeviceCap(QMap<QString, int> &map);
signals:
void oneItemExpanded(const QString &ssid);
void wlanAdd(QString devName, QStringList info);
void wlanRemove(QString devName,QString ssid);
void wlanActiveConnectionStateChanged(QString interface, QString ssid, QString uuid, int status);
void hotspotDeactivated(QString devName, QString ssid);
void hotspotActivated(QString devName, QString ssid);
void hotspotActivated(QString devName, QString ssid, QString uuid);
void signalStrengthChange(QString devName, QString ssid, int strength);
void secuTypeChange(QString devName, QString ssid, QString secuType);
void hiddenWlanClicked();