Merge branch 'kylin-nm-thread-block' into 'dbus-interface'
解决线程阻塞的问题 See merge request kylin-desktop/kylin-nm!415
This commit is contained in:
commit
1d426f1f11
|
@ -14,11 +14,11 @@ KyActiveConnectResourse::KyActiveConnectResourse(QObject *parent) : QObject(pare
|
|||
m_networkdevice = new KyNetworkDeviceResourse();
|
||||
|
||||
connect(m_networkResourceInstance, &KyNetworkResourceManager::activeConnectionRemove,
|
||||
this, &KyActiveConnectResourse::activeConnectRemove);
|
||||
this, &KyActiveConnectResourse::activeConnectRemove);
|
||||
connect(m_networkResourceInstance, &KyNetworkResourceManager::activeConnectStateChangeReason,
|
||||
this, &KyActiveConnectResourse::stateChangeReason);
|
||||
this, &KyActiveConnectResourse::stateChangeReason);
|
||||
connect(m_networkResourceInstance, &KyNetworkResourceManager::vpnActiveConnectStateChangeReason,
|
||||
this, &KyActiveConnectResourse::vpnConnectChangeReason);
|
||||
this, &KyActiveConnectResourse::vpnConnectChangeReason);
|
||||
}
|
||||
|
||||
KyActiveConnectResourse::~KyActiveConnectResourse()
|
||||
|
@ -164,7 +164,7 @@ void KyActiveConnectResourse::getActiveConnectionList(QString deviceName,
|
|||
activeConnectItem->m_ifaceName = deviceName;
|
||||
activeConnectItem->m_itemType = connectionType;
|
||||
activeConnectItemList << activeConnectItem;
|
||||
activeConnectItem->dumpInfo();
|
||||
//activeConnectItem->dumpInfo();
|
||||
}
|
||||
|
||||
activeConnectPtr = nullptr;
|
||||
|
@ -262,7 +262,10 @@ void KyActiveConnectResourse::getActiveConnectIpInfo(
|
|||
qWarning()<< "[KyActiveConnectResourse]" <<"it can not find connect "<< connectUuid;
|
||||
return;
|
||||
}
|
||||
|
||||
getActiveConnectIp(activeConnectPtr, ipv4Address, ipv6Address);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void KyActiveConnectResourse::getActiveConnectIp(
|
||||
|
@ -306,15 +309,18 @@ void KyActiveConnectResourse::getActiveConnectDnsInfo(
|
|||
{
|
||||
NetworkManager::ActiveConnection::Ptr activeConnectPtr =
|
||||
m_networkResourceInstance->getActiveConnect(connectUuid);
|
||||
|
||||
if (activeConnectPtr.isNull()) {
|
||||
qWarning()<< "[KyActiveConnectResourse]" <<"it can not find connect "<< connectUuid;
|
||||
return;
|
||||
}
|
||||
|
||||
getActiveConnectDns(activeConnectPtr, ipv4Dns, ipv6Dns);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void KyActiveConnectResourse::getActiveConnectDns(NetworkManager::ActiveConnection::Ptr activeConnectPtr,
|
||||
void KyActiveConnectResourse::getActiveConnectDns(
|
||||
NetworkManager::ActiveConnection::Ptr activeConnectPtr,
|
||||
QList<QHostAddress> &ipv4Dns,
|
||||
QList<QHostAddress> &ipv6Dns)
|
||||
{
|
||||
|
@ -588,7 +594,7 @@ QString KyActiveConnectResourse::getDeviceOfActivateConnect(QString conUuid)
|
|||
|
||||
QString ifaceUni = interfaces.at(0);
|
||||
NetworkManager::Device:: Ptr devicePtr =
|
||||
m_networkResourceInstance->findDeviceUni(ifaceUni);
|
||||
m_networkResourceInstance->findDeviceUni(ifaceUni);
|
||||
deviceName = devicePtr->interfaceName();
|
||||
|
||||
return deviceName;
|
||||
|
|
|
@ -122,7 +122,7 @@ KyConnectItem * KyConnectResourse::getConnectionItemByUuid(QString connectUuid)
|
|||
|
||||
KyConnectItem *connectItem = getConnectionItem(connectPtr, "");
|
||||
if (nullptr != connectItem) {
|
||||
connectItem->dumpInfo();
|
||||
//connectItem->dumpInfo();
|
||||
return connectItem;
|
||||
}
|
||||
|
||||
|
@ -154,7 +154,7 @@ KyConnectItem * KyConnectResourse::getConnectionItemByUuid(QString connectUuid,
|
|||
|
||||
KyConnectItem *connectItem = getConnectionItem(connectPtr, deviceName);
|
||||
if (nullptr != connectItem) {
|
||||
connectItem->dumpInfo();
|
||||
//connectItem->dumpInfo();
|
||||
return connectItem;
|
||||
}
|
||||
|
||||
|
@ -208,7 +208,7 @@ void KyConnectResourse::getConnectionList(QString deviceName,
|
|||
if (nullptr != connectItem) {
|
||||
// connectItem->m_itemType = connectionType;
|
||||
connectItemList << connectItem;
|
||||
connectItem->dumpInfo();
|
||||
//connectItem->dumpInfo();
|
||||
}
|
||||
|
||||
connectPtr = nullptr;
|
||||
|
|
|
@ -13,13 +13,19 @@ KyNetworkDeviceResourse::KyNetworkDeviceResourse(QObject *parent) : QObject(pare
|
|||
|
||||
initDeviceMap();
|
||||
|
||||
connect(m_networkResourceInstance, &KyNetworkResourceManager::deviceAdd, this, &KyNetworkDeviceResourse::onDeviceAdd);
|
||||
connect(m_networkResourceInstance, &KyNetworkResourceManager::deviceRemove, this, &KyNetworkDeviceResourse::onDeviceRemove);
|
||||
connect(m_networkResourceInstance, &KyNetworkResourceManager::deviceUpdate, this, &KyNetworkDeviceResourse::onDeviceUpdate);
|
||||
connect(m_networkResourceInstance, &KyNetworkResourceManager::deviceAdd,
|
||||
this, &KyNetworkDeviceResourse::onDeviceAdd, Qt::ConnectionType::DirectConnection);
|
||||
connect(m_networkResourceInstance, &KyNetworkResourceManager::deviceRemove,
|
||||
this, &KyNetworkDeviceResourse::onDeviceRemove, Qt::ConnectionType::DirectConnection);
|
||||
connect(m_networkResourceInstance, &KyNetworkResourceManager::deviceUpdate,
|
||||
this, &KyNetworkDeviceResourse::onDeviceUpdate, Qt::ConnectionType::DirectConnection);
|
||||
|
||||
connect(m_networkResourceInstance, &KyNetworkResourceManager::deviceCarrierChanage, this, &KyNetworkDeviceResourse::carrierChanage);
|
||||
connect(m_networkResourceInstance, &KyNetworkResourceManager::deviceBitRateChanage, this, &KyNetworkDeviceResourse::deviceBitRateChanage);
|
||||
connect(m_networkResourceInstance, &KyNetworkResourceManager::deviceMacAddressChanaged, this, &KyNetworkDeviceResourse::deviceMacAddressChanaged);
|
||||
connect(m_networkResourceInstance, &KyNetworkResourceManager::deviceCarrierChanage,
|
||||
this, &KyNetworkDeviceResourse::carrierChanage);
|
||||
connect(m_networkResourceInstance, &KyNetworkResourceManager::deviceBitRateChanage,
|
||||
this, &KyNetworkDeviceResourse::deviceBitRateChanage);
|
||||
connect(m_networkResourceInstance, &KyNetworkResourceManager::deviceMacAddressChanaged,
|
||||
this, &KyNetworkDeviceResourse::deviceMacAddressChanaged);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
*/
|
||||
|
||||
#include "kylinnetworkresourcemanager.h"
|
||||
#include <QMetaType>
|
||||
|
||||
#define SIGNAL_DELAY 80000
|
||||
#define EMIT_DELAY 10000
|
||||
|
||||
|
@ -41,6 +43,14 @@ void KyNetworkResourceManager::Release()
|
|||
}
|
||||
|
||||
KyNetworkResourceManager::KyNetworkResourceManager(QObject *parent) : QObject(parent)
|
||||
{
|
||||
qRegisterMetaType<NetworkManager::ActiveConnection::State>("NetworkManager::ActiveConnection::State");
|
||||
qRegisterMetaType<NetworkManager::Connectivity>("NetworkManager::Connectivity");
|
||||
qRegisterMetaType<NetworkManager::ActiveConnection::Reason>("NetworkManager::ActiveConnection::Reason");
|
||||
qRegisterMetaType<NetworkManager::Device::Type>("NetworkManager::Device::Type");
|
||||
}
|
||||
|
||||
void KyNetworkResourceManager::onInitNetwork()
|
||||
{
|
||||
insertActiveConnections();
|
||||
insertConnections();
|
||||
|
@ -64,7 +74,7 @@ KyNetworkResourceManager::KyNetworkResourceManager(QObject *parent) : QObject(pa
|
|||
connect(NetworkManager::notifier(), &NetworkManager::Notifier::serviceDisappeared, this, &KyNetworkResourceManager::clearConnections);
|
||||
|
||||
qDebug() <<"[KyNetworkResourceManager]"
|
||||
<< "active connections:" << m_activeConns.size()
|
||||
<< "active connections:" << m_activeConns.size()
|
||||
<< "connections:" << m_connections.size()
|
||||
<< "network device:" << m_devices.size();
|
||||
}
|
||||
|
@ -924,6 +934,10 @@ void KyNetworkResourceManager::removeConnection(QString const & uuid)
|
|||
}
|
||||
}
|
||||
|
||||
void KyNetworkResourceManager::setWirelessNetworkEnabled(bool enabled)
|
||||
{
|
||||
NetworkManager::setWirelessEnabled(enabled);
|
||||
}
|
||||
|
||||
void KyNetworkResourceManager::connectionDump()
|
||||
{
|
||||
|
|
|
@ -136,6 +136,10 @@ signals:
|
|||
|
||||
void connectivityChanged(NetworkManager::Connectivity connectivity);
|
||||
|
||||
public slots:
|
||||
void onInitNetwork();
|
||||
void setWirelessNetworkEnabled(bool enabled);
|
||||
|
||||
private slots:
|
||||
//connection
|
||||
void onConnectionUpdated();
|
||||
|
|
|
@ -103,6 +103,8 @@ KyWirelessConnectOperation::KyWirelessConnectOperation(QObject *parent) : KyConn
|
|||
{
|
||||
connect(m_networkResourceInstance, &KyNetworkResourceManager::wifiEnabledChanged,
|
||||
this, &KyWirelessConnectOperation::wifiEnabledChanged);
|
||||
connect(this, &KyWirelessConnectOperation::enabledWirelessNetwork,
|
||||
m_networkResourceInstance, &KyNetworkResourceManager::setWirelessNetworkEnabled, Qt::ConnectionType::QueuedConnection);
|
||||
}
|
||||
|
||||
KyWirelessConnectOperation::~KyWirelessConnectOperation()
|
||||
|
@ -696,7 +698,9 @@ void KyWirelessConnectOperation::addAndActiveWirelessEnterPriseTtlsConnect(KyEap
|
|||
//无线网络开关设置
|
||||
void KyWirelessConnectOperation::setWirelessEnabled(bool enabled)
|
||||
{
|
||||
NetworkManager::setWirelessEnabled(enabled);
|
||||
emit enabledWirelessNetwork(enabled);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
bool KyWirelessConnectOperation::getWirelessEnabled()
|
||||
|
|
|
@ -129,6 +129,7 @@ private:
|
|||
|
||||
signals:
|
||||
void wifiEnabledChanged(bool);
|
||||
void enabledWirelessNetwork(bool enabled);
|
||||
void addAndActivateConnectionError(QString errorMessage);
|
||||
|
||||
private:
|
||||
|
|
|
@ -18,27 +18,36 @@ static void wifiListSort(QList<KyWirelessNetItem> &list)
|
|||
KyWirelessNetResource::KyWirelessNetResource(QObject *parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
qDebug()<<"KyWirelessNetResource";
|
||||
qDebug()<< LOG_FLAG <<"KyWirelessNetResource";
|
||||
|
||||
qRegisterMetaType<KyWirelessNetItem>("KyWirelessNetItem&");
|
||||
|
||||
m_networkResourceInstance = KyNetworkResourceManager::getInstance();
|
||||
m_connectResource = new KyConnectResourse(this);
|
||||
m_operation = new KyWirelessConnectOperation(this);
|
||||
m_networkDevice = new KyNetworkDeviceResourse(this);
|
||||
|
||||
kyWirelessNetItemListInit();
|
||||
|
||||
//TODO:connect device signal
|
||||
connect(m_networkResourceInstance, &KyNetworkResourceManager::wifiNetworkAdded, this, &KyWirelessNetResource::onWifiNetworkAdded);
|
||||
connect(m_networkResourceInstance, &KyNetworkResourceManager::wifiNetworkRemoved, this, &KyWirelessNetResource::onWifiNetworkRemoved);
|
||||
connect(m_networkResourceInstance, &KyNetworkResourceManager::wifiNetworkPropertyChange, this, &KyWirelessNetResource::onWifiNetworkPropertyChange);
|
||||
connect(m_networkResourceInstance, &KyNetworkResourceManager::wifiNetworkDeviceDisappear, this, &KyWirelessNetResource::onWifiNetworkDeviceDisappear);
|
||||
connect(m_networkResourceInstance, &KyNetworkResourceManager::wifiNetworkAdded,
|
||||
this, &KyWirelessNetResource::onWifiNetworkAdded, Qt::ConnectionType::DirectConnection);
|
||||
connect(m_networkResourceInstance, &KyNetworkResourceManager::wifiNetworkRemoved,
|
||||
this, &KyWirelessNetResource::onWifiNetworkRemoved, Qt::ConnectionType::DirectConnection);
|
||||
connect(m_networkResourceInstance, &KyNetworkResourceManager::wifiNetworkPropertyChange,
|
||||
this, &KyWirelessNetResource::onWifiNetworkPropertyChange, Qt::ConnectionType::DirectConnection);
|
||||
connect(m_networkResourceInstance, &KyNetworkResourceManager::wifiNetworkDeviceDisappear,
|
||||
this, &KyWirelessNetResource::onWifiNetworkDeviceDisappear, Qt::ConnectionType::DirectConnection);
|
||||
|
||||
connect(m_connectResource, &KyConnectResourse::connectionAdd, this, &KyWirelessNetResource::onConnectionAdd);
|
||||
connect(m_connectResource, &KyConnectResourse::connectionRemove, this, &KyWirelessNetResource::onConnectionRemove);
|
||||
connect(m_connectResource, &KyConnectResourse::connectionUpdate, this, &KyWirelessNetResource::onConnectionUpdate);
|
||||
|
||||
connect(m_device, &KyNetworkDeviceResourse::deviceAdd, this, &KyWirelessNetResource::onDeviceAdd);
|
||||
connect(m_device, &KyNetworkDeviceResourse::deviceRemove, this, &KyWirelessNetResource::onDeviceRemove);
|
||||
connect(m_device, &KyNetworkDeviceResourse::deviceNameUpdate, this, &KyWirelessNetResource::onDeviceNameUpdate);
|
||||
connect(m_networkResourceInstance, &KyNetworkResourceManager::connectionAdd,
|
||||
this, &KyWirelessNetResource::onConnectionAdd);
|
||||
connect(m_networkResourceInstance, &KyNetworkResourceManager::connectionRemove,
|
||||
this, &KyWirelessNetResource::onConnectionRemove);
|
||||
connect(m_networkResourceInstance, &KyNetworkResourceManager::connectionUpdate,
|
||||
this, &KyWirelessNetResource::onConnectionUpdate);
|
||||
|
||||
connect(m_networkDevice, &KyNetworkDeviceResourse::deviceAdd, this, &KyWirelessNetResource::onDeviceAdd);
|
||||
connect(m_networkDevice, &KyNetworkDeviceResourse::deviceRemove, this, &KyWirelessNetResource::onDeviceRemove);
|
||||
connect(m_networkDevice, &KyNetworkDeviceResourse::deviceNameUpdate, this, &KyWirelessNetResource::onDeviceNameUpdate);
|
||||
}
|
||||
|
||||
KyWirelessNetResource::~KyWirelessNetResource()
|
||||
|
|
|
@ -21,7 +21,7 @@ public:
|
|||
|
||||
//ui层调用接口
|
||||
bool getWifiNetwork(const QString &devIfaceName, const QString &ssid, KyWirelessNetItem &wirelessNetResource);
|
||||
bool getAllDeviceWifiNetwork(QMap<QString, QList<KyWirelessNetItem> > &map);
|
||||
bool getAllDeviceWifiNetwork(QMap<QString, QList<KyWirelessNetItem>> &map);
|
||||
bool getDeviceWifiNetwork(QString devIfaceName, QList<KyWirelessNetItem> &wirelessNetResource);
|
||||
|
||||
bool getEnterPriseInfoTls(QString &uuid, KyEapMethodTlsInfo &info);
|
||||
|
@ -67,9 +67,8 @@ signals:
|
|||
|
||||
private:
|
||||
KyNetworkResourceManager *m_networkResourceInstance = nullptr;
|
||||
KyConnectResourse *m_connectResource = nullptr;
|
||||
KyWirelessConnectOperation *m_operation = nullptr;
|
||||
KyNetworkDeviceResourse *m_device = nullptr;
|
||||
KyNetworkDeviceResourse *m_networkDevice = nullptr;
|
||||
QMap<QString, QList<KyWirelessNetItem> > m_WifiNetworkList;
|
||||
|
||||
};
|
||||
|
|
|
@ -95,6 +95,7 @@ void LanListItem::onNetButtonClicked()
|
|||
m_connectOperation->activateWiredConnection(m_lanConnectItem.m_connectUuid, m_deviceName);
|
||||
qDebug() << LOG_FLAG << "it will activate connection" << m_lanConnectItem.m_connectName
|
||||
<< ". it's device is" << m_deviceName;
|
||||
m_netButton->startLoading();
|
||||
} else {
|
||||
qDebug() << LOG_FLAG << m_deviceName << "is not carried, so can not activate connection";
|
||||
this->showDesktopNotify(tr("Wired Device not carried"));
|
||||
|
@ -138,6 +139,7 @@ void LanListItem::onMenuTriggered(QAction *action)
|
|||
m_connectOperation->deactivateWiredConnection(m_lanConnectItem.m_connectName, m_lanConnectItem.m_connectUuid);
|
||||
qDebug() << LOG_FLAG << "it will disconnect connection" << m_lanConnectItem.m_connectName
|
||||
<< ". it's device is" << m_deviceName;
|
||||
m_netButton->startLoading();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -399,6 +399,7 @@ void WlanListItem::onNetButtonClicked()
|
|||
m_wirelessConnectOperation->activeWirelessConnect(m_wlanDevice, m_wirelessNetItem.m_connectUuid);
|
||||
qDebug()<<"[WlanListItem] Has configuration, will be activated. ssid = "
|
||||
<< m_wirelessNetItem.m_NetSsid << Q_FUNC_INFO << __LINE__;
|
||||
m_netButton->startLoading();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -507,6 +508,7 @@ void WlanListItem::onConnectButtonClicked()
|
|||
|
||||
m_wirelessConnectOperation->addAndActiveWirelessConnect(m_wlanDevice, settings, false);
|
||||
setExpanded(false);
|
||||
m_netButton->startLoading();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -542,6 +544,7 @@ void WlanListItem::onMenuTriggered(QAction *action)
|
|||
m_wirelessConnectOperation->deActivateWirelessConnection(m_wlanDevice, m_wirelessNetItem.m_connectUuid);
|
||||
qDebug()<<"[WlanListItem] Clicked on connected wifi, it will be inactivated. ssid = "
|
||||
<< m_wirelessNetItem.m_NetSsid << Q_FUNC_INFO << __LINE__;
|
||||
m_netButton->startLoading();
|
||||
} else if (action->text() == tr("Forget")) {
|
||||
m_wirelessConnectOperation->deleteWirelessConnect(m_wirelessNetItem.m_connectUuid);
|
||||
}
|
||||
|
|
|
@ -381,6 +381,9 @@ void LanPage::constructConnectionArea()
|
|||
KyConnectItem *p_deactiveConnectionItem = deactivedList.at(index);
|
||||
qDebug()<<"[LanPage] construct connection area add deactive item"<<p_deactiveConnectionItem->m_connectName;
|
||||
QListWidgetItem *p_listWidgetItem = addNewItem(p_deactiveConnectionItem, m_inactivatedLanListWidget);
|
||||
if (m_inactiveConnectionMap.contains(p_deactiveConnectionItem->m_connectUuid)) {
|
||||
qDebug()<<LOG_FLAG << "has contain uuid" << p_deactiveConnectionItem->m_connectUuid;
|
||||
}
|
||||
m_inactiveConnectionMap.insert(p_deactiveConnectionItem->m_connectUuid, p_listWidgetItem);
|
||||
|
||||
delete p_deactiveConnectionItem;
|
||||
|
@ -471,6 +474,9 @@ void LanPage::onAddConnection(QString uuid) //新增一个有线
|
|||
if (p_newItem->m_ifaceName == m_currentDeviceName || p_newItem->m_ifaceName == "") {
|
||||
qDebug()<<"[LanPage] Add a new connection, name:"<<p_newItem->m_connectName;
|
||||
QListWidgetItem *p_listWidgetItem = insertNewItem(p_newItem, m_inactivatedLanListWidget);
|
||||
if (m_inactiveConnectionMap.contains(p_newItem->m_connectUuid)) {
|
||||
qDebug()<<LOG_FLAG << "the connection is exsit" << p_newItem->m_connectUuid;
|
||||
}
|
||||
m_inactiveConnectionMap.insert(p_newItem->m_connectUuid, p_listWidgetItem);
|
||||
}
|
||||
|
||||
|
@ -965,6 +971,9 @@ void LanPage::updateConnectionProperty(KyConnectItem *p_connectItem)
|
|||
//只要名字改变就要删除,重新插入,主要是为了排序
|
||||
deleteConnectionMapItem(m_inactiveConnectionMap, m_inactivatedLanListWidget, newUuid);
|
||||
QListWidgetItem *p_sortListWidgetItem = insertNewItem(p_connectItem, m_inactivatedLanListWidget);
|
||||
if (m_inactiveConnectionMap.contains(newUuid)) {
|
||||
qDebug()<<LOG_FLAG << "has contained connection" << newUuid;
|
||||
}
|
||||
m_inactiveConnectionMap.insert(newUuid, p_sortListWidgetItem);
|
||||
} else if (p_connectItem->m_connectPath != p_lanItem->getConnectionPath()) {
|
||||
p_lanItem->updateConnectionPath(p_connectItem->m_connectPath);
|
||||
|
@ -975,6 +984,9 @@ void LanPage::updateConnectionProperty(KyConnectItem *p_connectItem)
|
|||
if (p_connectItem->m_ifaceName == m_currentDeviceName
|
||||
|| p_connectItem->m_ifaceName.isEmpty()) {
|
||||
QListWidgetItem *p_listWidgetItem = insertNewItem(p_connectItem, m_inactivatedLanListWidget);
|
||||
if (m_inactiveConnectionMap.contains(newUuid)) {
|
||||
qDebug()<<LOG_FLAG << "has contained connection uuid" << newUuid;
|
||||
}
|
||||
m_inactiveConnectionMap.insert(newUuid, p_listWidgetItem);
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -113,21 +113,22 @@ void WlanPage::onWlanSwithGsettingsChanged(const QString &key)
|
|||
*/
|
||||
void WlanPage::onWlanSwitchClicked()
|
||||
{
|
||||
qDebug() <<"[WlanPage] On wlan switch button clicked! old state = "
|
||||
<< !m_netSwitch->getSwitchStatus() << Q_FUNC_INFO << __LINE__;
|
||||
|
||||
if (m_devList.isEmpty()) {
|
||||
qDebug() << "[WlanPage] have no device to use " << Q_FUNC_INFO << __LINE__;
|
||||
showDesktopNotify(tr("No wireless network card detected"));
|
||||
//检测不到无线网卡不再触发click信号
|
||||
m_netSwitch->setSwitchStatus(false);
|
||||
//m_netSwitch->setEnabled(false);
|
||||
} else {
|
||||
bool switchEnable = m_netSwitch->getSwitchStatus();
|
||||
if (m_wlanSwitchEnable != switchEnable) {
|
||||
qDebug()<< LOG_FLAG << "wlan switch state " << switchEnable;
|
||||
m_wirelessConnectOpreation->setWirelessEnabled(switchEnable);
|
||||
//m_switchGsettings->set(WIRELESS_SWITCH, switchEnable);
|
||||
if (!switchEnable) {
|
||||
m_netSwitch->setEnabled(false);
|
||||
m_activatedNetFrame->hide();
|
||||
m_activatedNetDivider->hide();
|
||||
m_inactivatedNetFrame->hide();
|
||||
m_deviceFrame->hide();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1008,10 +1009,10 @@ void WlanPage::onWifiEnabledChanged(bool isWifiOn)
|
|||
if (m_wlanSwitchEnable == isWifiOn) {
|
||||
return;
|
||||
} else {
|
||||
//m_netSwitch->setSwitchStatus(isWifiOn);
|
||||
//m_netSwitch->setEnabled(isWifiOn);
|
||||
if (!m_netSwitch->getEnabled()) {
|
||||
m_netSwitch->setEnabled(true);
|
||||
}
|
||||
m_switchGsettings->set(WIRELESS_SWITCH, isWifiOn);
|
||||
// emit this->wlanConnectChanged();
|
||||
}
|
||||
|
||||
return;
|
||||
|
@ -1040,7 +1041,7 @@ void WlanPage::onRefreshIconTimer()
|
|||
if(!this->isVisible()) {
|
||||
return;
|
||||
}
|
||||
qDebug() << "onRefreshIconTimer";
|
||||
//qDebug() << "onRefreshIconTimer";
|
||||
|
||||
if (m_expandedItem) {
|
||||
qDebug()<< LOG_FLAG << "Has expanded item and forbid refresh wifi strength" << Q_FUNC_INFO << __LINE__;
|
||||
|
@ -1079,7 +1080,7 @@ void WlanPage::onRefreshIconTimer()
|
|||
continue;
|
||||
}
|
||||
|
||||
qDebug()<< LOG_FLAG << "row" << sortRow << "item ssid" << p_wlanItem->getSsid();
|
||||
//qDebug()<< LOG_FLAG << "row" << sortRow << "item ssid" << p_wlanItem->getSsid();
|
||||
if (sortSsid == p_wlanItem->getSsid()) {
|
||||
// qDebug()<< LOG_FLAG << "sort wlan set signal strength." << Q_FUNC_INFO << __LINE__;
|
||||
p_wlanItem->setSignalStrength(sortItem.m_signalStrength);
|
||||
|
@ -1357,6 +1358,13 @@ void WlanPage::setWirelessSwitchEnable(bool enable)
|
|||
//m_netSwitch->setEnabled(false);
|
||||
}else{
|
||||
m_wirelessConnectOpreation->setWirelessEnabled(enable);
|
||||
if (!enable) {
|
||||
m_netSwitch->setEnabled(false);
|
||||
m_activatedNetFrame->hide();
|
||||
m_activatedNetDivider->hide();
|
||||
m_inactivatedNetFrame->hide();
|
||||
m_deviceFrame->hide();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -34,7 +34,8 @@ SwitchButton::SwitchButton(QWidget *parent) : QWidget(parent)
|
|||
else {
|
||||
m_fCurrentValue = 4;
|
||||
}
|
||||
connect(m_cTimer,SIGNAL(timeout()),this,SLOT(startAnimation()));
|
||||
|
||||
connect(m_cTimer, SIGNAL(timeout()), this, SLOT(startAnimation()));
|
||||
|
||||
|
||||
}
|
||||
|
@ -42,12 +43,15 @@ SwitchButton::SwitchButton(QWidget *parent) : QWidget(parent)
|
|||
void SwitchButton::setSwitchStatus(bool check) {
|
||||
if (!m_enabled)
|
||||
return;
|
||||
|
||||
if(check == true) {
|
||||
m_bIsOn = 1;
|
||||
} else {
|
||||
m_bIsOn = 0;
|
||||
}
|
||||
|
||||
emit this->switchStatusChanged();
|
||||
|
||||
m_cTimer->start(); //开始播放动画
|
||||
}
|
||||
|
||||
|
@ -61,9 +65,15 @@ bool SwitchButton::getSwitchStatus()
|
|||
void SwitchButton::setEnabled(bool enabled)
|
||||
{
|
||||
m_enabled = enabled;
|
||||
update();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
bool SwitchButton::getEnabled()
|
||||
{
|
||||
return m_enabled;
|
||||
}
|
||||
/* 播放按钮开启关闭动画 */
|
||||
void SwitchButton::startAnimation() { //滑动按钮动作播放
|
||||
int pos = 4;
|
||||
|
@ -74,7 +84,6 @@ void SwitchButton::startAnimation() { //滑动按钮动作播放
|
|||
m_fCurrentValue = size - pos;
|
||||
m_cTimer->stop();
|
||||
}
|
||||
|
||||
} else {
|
||||
m_fCurrentValue --;
|
||||
if(m_fCurrentValue <= pos) { //到达最小值,停止继续前进
|
||||
|
@ -88,14 +97,12 @@ void SwitchButton::startAnimation() { //滑动按钮动作播放
|
|||
/* 按钮按下处理 */
|
||||
void SwitchButton::mousePressEvent(QMouseEvent *event) {
|
||||
Q_UNUSED(event);
|
||||
// if (!m_enabled)
|
||||
// return QWidget::mousePressEvent(event);
|
||||
|
||||
if (m_enabled) {
|
||||
m_bIsOn = !m_bIsOn;
|
||||
Q_EMIT clicked(m_bIsOn);
|
||||
}
|
||||
|
||||
Q_EMIT clicked(m_bIsOn);
|
||||
|
||||
return QWidget::mousePressEvent(event);
|
||||
}
|
||||
|
||||
|
@ -109,7 +116,7 @@ void SwitchButton::paintEvent(QPaintEvent *event) {
|
|||
QColor colorActive(61,107,229);
|
||||
QColor colorInactive(190,190,190);
|
||||
colorInactive.setAlphaF(0.12);
|
||||
if(m_bIsOn) {
|
||||
if(m_bIsOn && m_enabled) {
|
||||
painter.save();
|
||||
painter.setBrush(colorActive);
|
||||
QRectF active_rect = QRectF(0,0,m_fWidth,m_fHeight);
|
||||
|
@ -122,7 +129,11 @@ void SwitchButton::paintEvent(QPaintEvent *event) {
|
|||
}
|
||||
painter.restore();
|
||||
painter.save();
|
||||
painter.setBrush(Qt::white);
|
||||
if (!m_enabled) {
|
||||
painter.setBrush(Qt::darkGray);
|
||||
} else {
|
||||
painter.setBrush(Qt::white);
|
||||
}
|
||||
painter.drawEllipse(m_fCurrentValue,4, 16, 16);
|
||||
painter.restore();
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@ public:
|
|||
void setSwitchStatus(bool check);
|
||||
bool getSwitchStatus();
|
||||
void setEnabled(bool enabled);
|
||||
bool getEnabled();
|
||||
|
||||
private:
|
||||
int m_bIsOn = 1;
|
||||
|
@ -45,6 +46,7 @@ private:
|
|||
Q_SIGNALS:
|
||||
void clicked(int check);
|
||||
void switchStatusChanged();
|
||||
|
||||
private Q_SLOTS:
|
||||
void startAnimation();
|
||||
|
||||
|
|
|
@ -97,6 +97,12 @@ int main(int argc, char *argv[])
|
|||
|
||||
QApplication::setQuitOnLastWindowClosed(false);
|
||||
|
||||
QThread thread;
|
||||
KyNetworkResourceManager *p_networkResource = KyNetworkResourceManager::getInstance();
|
||||
p_networkResource->moveToThread(&thread);
|
||||
QObject::connect(&thread, SIGNAL(started()), p_networkResource, SLOT(onInitNetwork()));
|
||||
thread.start();
|
||||
|
||||
// Internationalization
|
||||
QString locale = QLocale::system().name();
|
||||
QTranslator trans_global;
|
||||
|
|
Loading…
Reference in New Issue