fix: solve the problem of thread blocking.
bug link:http://172.17.50.104/biz/bug-view-90268.html http://172.17.50.104/biz/bug-view-86473.html http://172.17.50.104/biz/bug-view-81153.html
This commit is contained in:
parent
5f3c1e923f
commit
ad1ca9917e
|
@ -74,6 +74,11 @@ KyConnectItem *KyActiveConnectResourse::getActiveConnectionByUuid(QString connec
|
|||
}
|
||||
|
||||
QStringList interfaces = activeConnectPtr->devices();
|
||||
if (interfaces.isEmpty()) {
|
||||
qWarning()<< LOG_FLAG << "get active connection device failed.";
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
QString ifaceUni = interfaces.at(0);
|
||||
NetworkManager::Device:: Ptr devicePtr =
|
||||
m_networkResourceInstance->findDeviceUni(ifaceUni);
|
||||
|
@ -159,7 +164,7 @@ void KyActiveConnectResourse::getActiveConnectionList(QString deviceName,
|
|||
activeConnectItem->m_ifaceName = deviceName;
|
||||
activeConnectItem->m_itemType = connectionType;
|
||||
activeConnectItemList << activeConnectItem;
|
||||
activeConnectItem->dumpInfo();
|
||||
//activeConnectItem->dumpInfo();
|
||||
}
|
||||
|
||||
activeConnectPtr = nullptr;
|
||||
|
@ -257,7 +262,10 @@ void KyActiveConnectResourse::getActiveConnectIpInfo(
|
|||
qWarning()<< "[KyActiveConnectResourse]" <<"it can not find connect "<< connectUuid;
|
||||
return;
|
||||
}
|
||||
|
||||
getActiveConnectIp(activeConnectPtr, ipv4Address, ipv6Address);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void KyActiveConnectResourse::getActiveConnectIp(
|
||||
|
@ -301,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)
|
||||
{
|
||||
|
@ -576,6 +587,11 @@ QString KyActiveConnectResourse::getDeviceOfActivateConnect(QString conUuid)
|
|||
}
|
||||
|
||||
QStringList interfaces = activeConnectPtr->devices();
|
||||
if (interfaces.isEmpty()) {
|
||||
qWarning()<< LOG_FLAG << "get device of active connection failed.";
|
||||
return deviceName;
|
||||
}
|
||||
|
||||
QString ifaceUni = interfaces.at(0);
|
||||
NetworkManager::Device:: Ptr devicePtr =
|
||||
m_networkResourceInstance->findDeviceUni(ifaceUni);
|
||||
|
@ -595,6 +611,11 @@ bool KyActiveConnectResourse::connectionIsVirtual(QString uuid)
|
|||
}
|
||||
|
||||
QStringList interfaces = activeConnectPtr->devices();
|
||||
if (interfaces.isEmpty()) {
|
||||
qWarning()<< LOG_FLAG << "active connection get device failed.";
|
||||
return false;
|
||||
}
|
||||
|
||||
QString ifaceUni = interfaces.at(0);
|
||||
NetworkManager::Device:: Ptr devicePtr =
|
||||
m_networkResourceInstance->findDeviceUni(ifaceUni);
|
||||
|
|
|
@ -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();
|
||||
|
@ -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, Qt::ConnectionType::DirectConnection);
|
||||
connect(m_networkResourceInstance, &KyNetworkResourceManager::connectionRemove,
|
||||
this, &KyWirelessNetResource::onConnectionRemove, Qt::ConnectionType::DirectConnection);
|
||||
connect(m_networkResourceInstance, &KyNetworkResourceManager::connectionUpdate,
|
||||
this, &KyWirelessNetResource::onConnectionUpdate, Qt::ConnectionType::DirectConnection);
|
||||
|
||||
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()
|
||||
|
@ -167,6 +176,10 @@ QString KyWirelessNetResource::getActiveConnectSsidByDevice(QString deviceName)
|
|||
}
|
||||
|
||||
QStringList interfaces = activeConnectionPtr->devices();
|
||||
if(interfaces.isEmpty()) {
|
||||
qWarning()<< LOG_FLAG <<"get active device failed.";
|
||||
continue;
|
||||
}
|
||||
QString ifaceUni = interfaces.at(0);
|
||||
NetworkManager::Device:: Ptr devicePtr =
|
||||
m_networkResourceInstance->findDeviceUni(ifaceUni);
|
||||
|
@ -233,6 +246,10 @@ QString KyWirelessNetResource::getDeviceIFace(NetworkManager::ActiveConnection::
|
|||
wirelessNetResourcessid = wireless_sett->ssid();
|
||||
|
||||
QStringList interfaces = actConn->devices();
|
||||
if (interfaces.isEmpty()) {
|
||||
return "";
|
||||
}
|
||||
|
||||
QString ifaceUni = interfaces.at(0);
|
||||
NetworkManager::Device:: Ptr devicePtr =
|
||||
m_networkResourceInstance->findDeviceUni(ifaceUni);
|
||||
|
|
|
@ -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;
|
||||
|
||||
};
|
||||
|
|
|
@ -88,6 +88,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"));
|
||||
|
@ -131,6 +132,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;
|
||||
}
|
||||
|
|
|
@ -374,6 +374,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;
|
||||
}
|
||||
|
||||
|
@ -482,6 +483,7 @@ void WlanListItem::onConnectButtonClicked()
|
|||
|
||||
m_wirelessConnectOperation->addAndActiveWirelessConnect(m_wlanDevice, settings, false);
|
||||
setExpanded(false);
|
||||
m_netButton->startLoading();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -517,6 +519,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);
|
||||
}
|
||||
|
|
|
@ -112,21 +112,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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -998,10 +999,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;
|
||||
|
@ -1030,7 +1031,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__;
|
||||
|
@ -1069,7 +1070,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);
|
||||
|
|
|
@ -34,6 +34,7 @@ SwitchButton::SwitchButton(QWidget *parent) : QWidget(parent)
|
|||
else {
|
||||
m_fCurrentValue = 4;
|
||||
}
|
||||
|
||||
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,13 +97,11 @@ 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);
|
||||
}
|
||||
|
||||
return QWidget::mousePressEvent(event);
|
||||
}
|
||||
|
@ -122,7 +129,11 @@ void SwitchButton::paintEvent(QPaintEvent *event) {
|
|||
}
|
||||
painter.restore();
|
||||
painter.save();
|
||||
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();
|
||||
|
||||
|
|
10
src/main.cpp
10
src/main.cpp
|
@ -29,6 +29,8 @@
|
|||
#include "xatom-helper.h"
|
||||
#endif
|
||||
|
||||
#include "threaddriver.h"
|
||||
|
||||
#define LOG_IDENT "ukui_kylin_nm"
|
||||
|
||||
void messageOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg)
|
||||
|
@ -97,6 +99,14 @@ int main(int argc, char *argv[])
|
|||
|
||||
QApplication::setQuitOnLastWindowClosed(false);
|
||||
|
||||
ThreadDriver networkManagerDiver;
|
||||
QThread thread;
|
||||
KyNetworkResourceManager *p_networkResource = KyNetworkResourceManager::getInstance();
|
||||
p_networkResource->moveToThread(&thread);
|
||||
QObject::connect(&networkManagerDiver, SIGNAL(initSignal()), p_networkResource, SLOT(onInitNetwork()));
|
||||
thread.start();
|
||||
networkManagerDiver.emitSignal();
|
||||
|
||||
// Internationalization
|
||||
QString locale = QLocale::system().name();
|
||||
QTranslator trans_global;
|
||||
|
|
|
@ -66,3 +66,6 @@ unix {
|
|||
|
||||
DISTFILES += \
|
||||
org.ukui.kylin-nm.switch.gschema.xml
|
||||
|
||||
HEADERS += \
|
||||
threaddriver.h
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
#ifndef THREADDRIVER_H
|
||||
#define THREADDRIVER_H
|
||||
|
||||
|
||||
#include <QtCore/QCoreApplication>
|
||||
#include <QtCore/QObject>
|
||||
#include <QtCore/QThread>
|
||||
#include <QtCore/QDebug>
|
||||
|
||||
class ThreadDriver:public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ThreadDriver(QObject* parent=0):QObject(parent){}
|
||||
|
||||
public slots:
|
||||
void emitSignal() {
|
||||
emit initSignal();
|
||||
}
|
||||
|
||||
signals:
|
||||
void initSignal();
|
||||
};
|
||||
|
||||
#endif // THREADDRIVER_H
|
Loading…
Reference in New Issue