有线界面多网卡显示
This commit is contained in:
parent
f613c9c45e
commit
9d64f11b8c
|
@ -180,6 +180,7 @@ void KyNetworkDeviceResourse::disconnectDevice()
|
|||
{
|
||||
NetworkManager::Device::List networkDeviceList =
|
||||
m_networkResourceInstance->getNetworkDeviceList();
|
||||
qDebug() << "[KyNetworkDeviceResourse]:disconnectDevice" << networkDeviceList.size();
|
||||
|
||||
if (networkDeviceList.isEmpty()) {
|
||||
qDebug()<<"[KyNetworkDeviceResourse]"<<"the network device is empty, no need disconnect.";
|
||||
|
@ -190,21 +191,29 @@ void KyNetworkDeviceResourse::disconnectDevice()
|
|||
m_activeConnectUuidMap.clear();
|
||||
|
||||
for (int index = 0; index < networkDeviceList.size(); ++index) {
|
||||
qDebug() << "[KyNetworkDeviceResourse]:disconnectDevice" << index;
|
||||
NetworkManager::Device::Ptr networkDevicePtr = networkDeviceList.at(index);
|
||||
if (networkDevicePtr->isValid() &&
|
||||
NetworkManager::Device::Type::Ethernet == networkDevicePtr->type()) {
|
||||
NetworkManager::ActiveConnection::Ptr activeConnectPtr = networkDevicePtr->activeConnection();
|
||||
if (nullptr == activeConnectPtr) {
|
||||
continue;
|
||||
}
|
||||
|
||||
QString activeConnectUuid = activeConnectPtr->uuid();
|
||||
if (!activeConnectUuid.isEmpty()) {
|
||||
// m_activeConnectUuidList<<activeConnectUuid;
|
||||
m_activeConnectUuidMap.insert(networkDevicePtr->interfaceName(),activeConnectUuid);
|
||||
//TODO:save uuid for system reboot.
|
||||
}
|
||||
|
||||
networkDevicePtr->disconnectInterface();
|
||||
}
|
||||
|
||||
networkDevicePtr = nullptr;
|
||||
}
|
||||
|
||||
qDebug() << "[KyNetworkDeviceResourse]:disconnectDevice finished.";
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -411,7 +411,6 @@ NetworkManager::Connection::Ptr KyNetworkResourceManager::getConnect(const QStri
|
|||
if (connectUuid.isEmpty()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
for (index = 0; index < m_connections.size(); ++index) {
|
||||
connectPtr = m_connections.at(index);
|
||||
if (connectPtr->uuid() == connectUuid) {
|
||||
|
@ -549,8 +548,8 @@ void KyNetworkResourceManager::onActiveConnectionChanged(
|
|||
NetworkManager::ActiveConnection * activeConnect =
|
||||
qobject_cast<NetworkManager::ActiveConnection *>(sender());
|
||||
if (activeConnect->isValid()) {
|
||||
qDebug()<<"!New state change activate connect"<<activeConnect->uuid();
|
||||
qDebug()<<"!New the active connect state"<<state;
|
||||
// qDebug()<<"!New state change activate connect"<<activeConnect->uuid();
|
||||
// qDebug()<<"!New the active connect state"<<state;
|
||||
} else {
|
||||
|
||||
}
|
||||
|
|
|
@ -11,13 +11,28 @@ LanListItem::LanListItem(KyConnectItem *data, QString deviceName, QWidget *paren
|
|||
m_data = data;
|
||||
m_nameLabel->setText(m_data->m_connectName);
|
||||
|
||||
// if (m_data != nullptr) {
|
||||
// if (m_data->m_connectState == NetworkManager::ActiveConnection::State::Activated) {
|
||||
// setIcon(true);
|
||||
// m_isActive = true;
|
||||
// } else {
|
||||
// setIcon(false);
|
||||
// m_isActive = false;
|
||||
// }
|
||||
// }
|
||||
if (m_data != nullptr) {
|
||||
if (m_data->m_connectState == NetworkManager::ActiveConnection::State::Activated) {
|
||||
m_netButton->stopLoading();
|
||||
setIcon(true);
|
||||
m_isActive = true;
|
||||
} else {
|
||||
} else if (m_data->m_connectState == NetworkManager::ActiveConnection::State::Deactivated)
|
||||
{
|
||||
m_netButton->stopLoading();
|
||||
setIcon(false);
|
||||
m_isActive = false;
|
||||
} else
|
||||
{
|
||||
// m_netButton->startLoading();
|
||||
}
|
||||
}
|
||||
m_netButton->setActive(m_isActive);
|
||||
|
@ -25,17 +40,34 @@ LanListItem::LanListItem(KyConnectItem *data, QString deviceName, QWidget *paren
|
|||
connect(this->m_infoButton, &InfoButton::clicked, this, &LanListItem::onInfoButtonClicked);
|
||||
}
|
||||
|
||||
LanListItem::LanListItem(QWidget *parent) : ListItem(parent)
|
||||
{
|
||||
m_isActive = false;
|
||||
m_netButton->setIcon(QIcon::fromTheme("network-wireless-signal-none-symbolic"));
|
||||
const QString str="Not connected";
|
||||
m_nameLabel->setText(str);
|
||||
this->m_infoButton->hide();
|
||||
}
|
||||
|
||||
void LanListItem::onNetButtonClicked()
|
||||
{
|
||||
if(!m_data){
|
||||
qDebug() << "A nullItem clicked!" << Q_FUNC_INFO << __LINE__;
|
||||
return;
|
||||
}
|
||||
if (!m_isActive) {
|
||||
//未连接,点击后连
|
||||
m_connectOperation->activateWiredConnection(m_data->m_connectUuid, deviceName);
|
||||
qDebug() << m_data->m_connectName << "Connect after user clicked!";
|
||||
// m_data->m_connectState = NetworkManager::ActiveConnection::State::Activating;
|
||||
// refreshIcon();
|
||||
m_isActive = true;
|
||||
} else {
|
||||
//连接,点击后断开
|
||||
m_connectOperation->deactivateWiredConnection(m_data->m_connectName, m_data->m_connectUuid);
|
||||
qDebug() << m_data->m_connectName << "Disconnect after user clicked!";
|
||||
// m_data->m_connectState = NetworkManager::ActiveConnection::State::Deactivated;
|
||||
// refreshIcon();
|
||||
m_isActive = false;
|
||||
}
|
||||
}
|
||||
|
@ -48,6 +80,22 @@ void LanListItem::setIcon(bool isOn)
|
|||
m_netButton->setButtonIcon(QIcon::fromTheme("network-wired-disconnected-symbolic"));
|
||||
}
|
||||
}
|
||||
void LanListItem::refreshIcon()
|
||||
{
|
||||
switch (m_data->m_connectState) {
|
||||
case NetworkManager::ActiveConnection::State::Activated:
|
||||
m_netButton->stopLoading();
|
||||
setIcon(true);
|
||||
break;
|
||||
case NetworkManager::ActiveConnection::State::Activating:
|
||||
m_netButton->startLoading();
|
||||
break;
|
||||
case NetworkManager::ActiveConnection::State::Deactivated:
|
||||
m_netButton->stopLoading();
|
||||
setIcon(false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void LanListItem::onInfoButtonClicked()
|
||||
{
|
||||
|
|
|
@ -13,16 +13,21 @@ class LanListItem : public ListItem
|
|||
|
||||
public:
|
||||
LanListItem(KyConnectItem *data, QString deviceName, QWidget *parent = nullptr);
|
||||
LanListItem(QWidget *parent = nullptr);
|
||||
~LanListItem() = default;
|
||||
|
||||
protected:
|
||||
void setIcon(bool isOn);
|
||||
|
||||
private:
|
||||
KyConnectItem *m_data = nullptr;
|
||||
KyWiredConnectOperation *m_connectOperation = nullptr;
|
||||
|
||||
QString deviceName = nullptr;
|
||||
void refreshIcon();
|
||||
|
||||
protected:
|
||||
void setIcon(bool isOn);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
|
||||
private slots:
|
||||
void onInfoButtonClicked();
|
||||
|
|
|
@ -23,6 +23,7 @@ LanPage::LanPage(QWidget *parent) : TabPage(parent)
|
|||
m_connectResourse = new KyConnectResourse;
|
||||
m_device = new KyNetworkDeviceResourse;
|
||||
devList.empty();
|
||||
m_nullLanItem = new LanListItem();
|
||||
|
||||
initDevice();
|
||||
initUI();
|
||||
|
@ -33,13 +34,14 @@ LanPage::LanPage(QWidget *parent) : TabPage(parent)
|
|||
} else {
|
||||
qDebug()<<"[LanPage] org.ukui.kylin-nm.switch is not installed!";
|
||||
}
|
||||
initList();
|
||||
initList(m_deviceName);
|
||||
connect(m_activeResourse, &KyActiveConnectResourse::stateChangeReason, this, &LanPage::updateLanlist);
|
||||
connect(m_connectResourse, &KyConnectResourse::connectionAdd, this, &LanPage::addConnectionSlot);
|
||||
connect(m_connectResourse, &KyConnectResourse::connectionRemove, this, &LanPage::removeConnectionSlot);
|
||||
connect(m_device, &KyNetworkDeviceResourse::deviceAdd, this, &LanPage::onDeviceAdd);
|
||||
connect(m_device, &KyNetworkDeviceResourse::deviceRemove, this, &LanPage::onDeviceRemove);
|
||||
connect(m_device, &KyNetworkDeviceResourse::deviceNameUpdate, this, &LanPage::onDeviceNameUpdate);
|
||||
connect(this, &LanPage::deviceStatusChanged, this, &LanPage::onDeviceChanged);
|
||||
}
|
||||
|
||||
LanPage::~LanPage()
|
||||
|
@ -51,6 +53,17 @@ void LanPage::initNetSwitch()
|
|||
{
|
||||
if (m_switchGsettings->keys().contains(WIRED_SWITCH)) {
|
||||
m_netSwitch->setSwitchStatus(m_switchGsettings->get(WIRED_SWITCH).toBool());
|
||||
if (m_netSwitch->getSwitchStatus()) {
|
||||
if (m_deviceMap.count() <= 1) {
|
||||
m_deviceFrame->hide();
|
||||
} else {
|
||||
m_deviceFrame->show();
|
||||
initDeviceCombox();
|
||||
}
|
||||
} else {
|
||||
m_inactivatedLanListWidget->hide();
|
||||
m_deviceFrame->hide();
|
||||
}
|
||||
connect(m_switchGsettings, &QGSettings::changed, this, &LanPage::onSwithGsettingsChanged);
|
||||
}
|
||||
connect(m_netSwitch, &SwitchButton::clicked, this, &LanPage::onLanSwitchClicked);
|
||||
|
@ -61,7 +74,23 @@ void LanPage::onSwithGsettingsChanged(const QString &key)
|
|||
if (key == WIRED_SWITCH) {
|
||||
m_netSwitch->blockSignals(true);
|
||||
qDebug()<<"[LanPage] SwitchButton statue changed to ::"<<m_switchGsettings->get(WIRED_SWITCH).toBool();
|
||||
m_netSwitch->setSwitchStatus(m_switchGsettings->get(WIRED_SWITCH).toBool());
|
||||
bool isOn = m_switchGsettings->get(WIRED_SWITCH).toBool();
|
||||
if (isOn) {
|
||||
m_device->setDeviceAutoConnect();
|
||||
m_inactivatedLanListWidget->show();
|
||||
// m_deviceFrame->show();
|
||||
if (m_deviceMap.count() <= 1) {
|
||||
m_deviceFrame->hide();
|
||||
} else {
|
||||
m_deviceFrame->show();
|
||||
initDeviceCombox();
|
||||
}
|
||||
} else {
|
||||
m_device->disconnectDevice();
|
||||
m_inactivatedLanListWidget->hide();
|
||||
m_deviceFrame->hide();
|
||||
}
|
||||
m_netSwitch->setSwitchStatus(isOn);
|
||||
m_netSwitch->blockSignals(false);
|
||||
}
|
||||
}
|
||||
|
@ -72,12 +101,19 @@ void LanPage::onLanSwitchClicked()
|
|||
if (m_netSwitch->getSwitchStatus()) {
|
||||
m_device->setDeviceAutoConnect();
|
||||
m_inactivatedLanListWidget->show();
|
||||
// m_deviceFrame->show();
|
||||
if (m_deviceMap.count() <= 1) {
|
||||
m_deviceFrame->hide();
|
||||
} else {
|
||||
m_deviceFrame->show();
|
||||
initDeviceCombox();
|
||||
}
|
||||
m_switchGsettings->set(WIRED_SWITCH,true);
|
||||
} else {
|
||||
if (m_activeMap.count() != 0) {
|
||||
m_device->disconnectDevice();
|
||||
}
|
||||
qDebug()<<"[LanPage]Switch off! Disconnect Device!";
|
||||
m_device->disconnectDevice();
|
||||
m_inactivatedLanListWidget->hide();
|
||||
m_deviceFrame->hide();
|
||||
m_switchGsettings->set(WIRED_SWITCH,false);
|
||||
}
|
||||
}
|
||||
|
@ -151,6 +187,20 @@ void LanPage::initDevice()
|
|||
void LanPage::initDeviceCombox()
|
||||
{
|
||||
//TODO 获取设备列表,单设备时隐藏下拉框,多设备时添加到下拉框
|
||||
m_deviceComboBox->clear();
|
||||
m_deviceMap.clear();
|
||||
getWiredList(m_deviceMap);
|
||||
// if (m_deactiveMap.count() <= 1) {
|
||||
// m_deviceFrame->hide();
|
||||
// } else{
|
||||
m_deviceFrame->show();
|
||||
QMap<QString, QVector<QStringList> >::iterator iter;
|
||||
for (iter = m_deviceMap.begin(); iter != m_deviceMap.constEnd(); ++iter) {
|
||||
m_deviceComboBox->addItem(iter.key());
|
||||
}
|
||||
// }
|
||||
|
||||
qDebug() << "[LanPage]current:" << m_deviceComboBox->currentText();
|
||||
}
|
||||
|
||||
void LanPage::onDeviceAdd(QString deviceName, NetworkManager::Device::Type deviceType)
|
||||
|
@ -170,7 +220,7 @@ void LanPage::onDeviceAdd(QString deviceName, NetworkManager::Device::Type devic
|
|||
|
||||
void LanPage::onDeviceRemove(QString deviceName)
|
||||
{
|
||||
qDebug() << "deviceRemove" << deviceName;
|
||||
qDebug() << "[LanPage] deviceRemove:" << deviceName;
|
||||
if (getDefaultDevice() == deviceName)
|
||||
{
|
||||
QStringList list;
|
||||
|
@ -185,7 +235,24 @@ void LanPage::onDeviceRemove(QString deviceName)
|
|||
}
|
||||
if (devList.contains(deviceName)) {
|
||||
devList.removeOne(deviceName);
|
||||
emit deviceStatusChanged();
|
||||
}
|
||||
emit deviceStatusChanged();
|
||||
}
|
||||
|
||||
void LanPage::onDeviceChanged()
|
||||
{
|
||||
m_deviceMap.clear();
|
||||
getWiredList(m_deviceMap);
|
||||
qDebug() << "[LanPage]:Device Changed! initDeviceCombox!";
|
||||
if (m_netSwitch->getSwitchStatus()) {
|
||||
if (m_deviceMap.count() <= 1) {
|
||||
m_deviceFrame->hide();
|
||||
} else {
|
||||
m_deviceFrame->show();
|
||||
initDeviceCombox();
|
||||
}
|
||||
} else {
|
||||
m_deviceFrame->hide();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -207,6 +274,9 @@ void LanPage::onDeviceNameUpdate(QString oldName, QString newName)
|
|||
void LanPage::onDeviceComboxIndexChanged(int currentIndex)
|
||||
{
|
||||
//TODO 设备变更时更新设备和列表
|
||||
m_deviceName = m_deviceComboBox->currentText();
|
||||
qDebug() << "[LanPage]Device Changed:" << m_deviceName;
|
||||
initList(m_deviceName);
|
||||
}
|
||||
|
||||
void LanPage::initUI()
|
||||
|
@ -240,18 +310,6 @@ void LanPage::initUI()
|
|||
// m_inactivatedLanListWidget->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); //用了listwidget的滚动条
|
||||
|
||||
inactiveLanListLayout->addWidget(m_inactivatedLanListWidget);
|
||||
|
||||
// KyConnectItem *activeConnectItem = new KyConnectItem();
|
||||
// activeConnectItem->m_connectUuid = "e8f384a4-2214-361b-b328-eb36b36136ee";
|
||||
// activeConnectItem->m_connectName = "有线连接1";
|
||||
// activeConnectItem->m_connectPath = "fsfsef";
|
||||
//// activeConnectItem->m_connectState = NetworkManager::ActiveConnection::State::Activated;
|
||||
// m_testLanItem = new LanListItem(activeConnectItem);
|
||||
// m_testLanItem->setMinimumHeight(ITEM_HEIGHT);
|
||||
|
||||
// m_listWidgetItem = new QListWidgetItem(m_inactivatedLanListWidget);
|
||||
// m_inactivatedLanListWidget->addItem(m_listWidgetItem);
|
||||
// m_inactivatedLanListWidget->setItemWidget(m_listWidgetItem, m_testLanItem);
|
||||
}
|
||||
|
||||
void LanPage::addNewItem(KyConnectItem *itemData, QListWidget *listWidget)
|
||||
|
@ -264,9 +322,16 @@ void LanPage::addNewItem(KyConnectItem *itemData, QListWidget *listWidget)
|
|||
listWidget->setItemWidget(m_listWidgetItem, m_testLanItem);
|
||||
}
|
||||
|
||||
void LanPage::initList() //程序拉起,初始化显示
|
||||
void LanPage::initList(QString m_deviceName) //程序拉起,初始化显示
|
||||
{
|
||||
m_activatedLanListWidget->clear();
|
||||
m_inactivatedLanListWidget->clear();
|
||||
m_activeMap.clear();
|
||||
m_deactiveMap.clear();
|
||||
m_activedList.clear();
|
||||
m_deactivedList.clear();
|
||||
m_activeResourse->getActiveConnectionList(m_deviceName,NetworkManager::ConnectionSettings::Wired,m_activedList); //激活列表的显示
|
||||
qDebug() << "[LanPage]init list! Active list:" << m_activedList.size() << "Deactive list:" << m_deactivedList.size();
|
||||
if (!m_activedList.isEmpty()) {
|
||||
for (int i = 0; i < m_activedList.size(); i++) {
|
||||
|
||||
|
@ -275,6 +340,13 @@ void LanPage::initList() //程序拉起,初始化显示
|
|||
|
||||
m_activeMap.insert(activeItemData, m_listWidgetItem);
|
||||
}
|
||||
} else {
|
||||
m_nullItem = new QListWidgetItem(m_activatedLanListWidget);
|
||||
m_nullItem->setSizeHint(QSize(m_activatedLanListWidget->width(),ITEM_HEIGHT));
|
||||
m_activatedLanListWidget->addItem(m_nullItem);
|
||||
|
||||
m_nullLanItem = new LanListItem();
|
||||
m_activatedLanListWidget->setItemWidget(m_nullItem, m_nullLanItem);
|
||||
}
|
||||
|
||||
m_connectResourse->getConnectionList(m_deviceName, NetworkManager::ConnectionSettings::Wired, m_deactivedList); //未激活列表的显示
|
||||
|
@ -293,19 +365,6 @@ void LanPage::updateLanlist(QString uuid, NetworkManager::ActiveConnection::Stat
|
|||
qDebug()<<"[LanPage] State change slot:"<<state;
|
||||
|
||||
QString devName;
|
||||
NetworkManager::ConnectionSettings::ConnectionType type;
|
||||
if(m_connectResourse->getInterfaceByUuid(devName, type, uuid)) {
|
||||
|
||||
if (type != NetworkManager::ConnectionSettings::ConnectionType::Wired) {
|
||||
qDebug() << "[LanPage] updateLanlist but type is not wired";
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
qDebug() << "[LanPage] updateLanlist but uuid is invalid";
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (state == NetworkManager::ActiveConnection::State::Activating) {
|
||||
qDebug() << "[LanPage] wiredActivating " << devName;
|
||||
emit wiredActivating(devName,uuid);
|
||||
|
@ -317,25 +376,7 @@ void LanPage::updateLanlist(QString uuid, NetworkManager::ActiveConnection::Stat
|
|||
emit listUpdate(devName);
|
||||
}
|
||||
|
||||
if (state == NetworkManager::ActiveConnection::State::Activated) {
|
||||
qDebug()<<"Get an actived connection, begin to move it from deactive to avtive!";
|
||||
QMap<KyConnectItem *, QListWidgetItem *>::iterator iter; //在未激活列表里删除
|
||||
for (iter = m_deactiveMap.begin(); iter != m_deactiveMap.constEnd(); ++iter) {
|
||||
KyConnectItem *m_item = iter.key();
|
||||
if (m_item->m_connectUuid == uuid) {
|
||||
qDebug()<<"Add an active connection to activeList:"<<m_item->m_connectName;
|
||||
m_item->m_connectState = state;
|
||||
addNewItem(m_item, m_activatedLanListWidget);
|
||||
|
||||
m_inactivatedLanListWidget->removeItemWidget(iter.value());
|
||||
delete(iter.value());
|
||||
|
||||
m_activeMap.insert(m_item, m_listWidgetItem);
|
||||
m_deactiveMap.erase(iter);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if (state == NetworkManager::ActiveConnection::State::Deactivated) {
|
||||
if (state == NetworkManager::ActiveConnection::State::Deactivated) {
|
||||
qDebug()<<"Get a deactivate, begin to remove it from activeList";
|
||||
QMap<KyConnectItem *, QListWidgetItem *>::iterator i;
|
||||
for (i = m_activeMap.begin(); i != m_activeMap.constEnd(); ++i) { //有新断开,若在激活列表里则删掉
|
||||
|
@ -364,7 +405,6 @@ void LanPage::updateLanlist(QString uuid, NetworkManager::ActiveConnection::Stat
|
|||
if (m_item->m_connectUuid == uuid && !hasDeactiveNet) {
|
||||
qDebug()<<"Add a deactive connection to inactiveList:"<<m_item->m_connectName;
|
||||
m_item->m_connectState = state;
|
||||
|
||||
addNewItem(m_item, m_inactivatedLanListWidget);
|
||||
|
||||
m_deactiveMap.insert(m_item, m_listWidgetItem);
|
||||
|
@ -372,8 +412,38 @@ void LanPage::updateLanlist(QString uuid, NetworkManager::ActiveConnection::Stat
|
|||
break;
|
||||
}
|
||||
}
|
||||
} else if (state == NetworkManager::ActiveConnection::State::Activating){
|
||||
} else if (state == NetworkManager::ActiveConnection::State::Activated) {
|
||||
qDebug()<<"Get an actived connection, begin to move it from deactive to avtive!";
|
||||
QMap<KyConnectItem *, QListWidgetItem *>::iterator iter; //在未激活列表里删除
|
||||
for (iter = m_deactiveMap.begin(); iter != m_deactiveMap.constEnd(); ++iter) {
|
||||
KyConnectItem *m_item = iter.key();
|
||||
if (m_item->m_connectUuid == uuid) {
|
||||
m_activatedLanListWidget->clear();
|
||||
qDebug()<<"Add an active connection to activeList:"<<m_item->m_connectName;
|
||||
m_item->m_connectState = state;
|
||||
addNewItem(m_item, m_activatedLanListWidget);
|
||||
|
||||
m_inactivatedLanListWidget->removeItemWidget(iter.value());
|
||||
delete(iter.value());
|
||||
|
||||
m_activeMap.insert(m_item, m_listWidgetItem);
|
||||
m_deactiveMap.erase(iter);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (state == NetworkManager::ActiveConnection::State::Activating){
|
||||
|
||||
}
|
||||
|
||||
if (m_activeMap.count() <= 0) {
|
||||
m_activatedLanListWidget->clear();
|
||||
m_nullItem = new QListWidgetItem(m_activatedLanListWidget);
|
||||
m_nullItem->setSizeHint(QSize(m_activatedLanListWidget->width(),ITEM_HEIGHT));
|
||||
m_activatedLanListWidget->addItem(m_nullItem);
|
||||
m_nullLanItem = new LanListItem();
|
||||
qDebug() << "[LanPage] ADD!";
|
||||
m_activatedLanListWidget->setItemWidget(m_nullItem, m_nullLanItem);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -34,15 +34,18 @@ private:
|
|||
void initDevice();//初始化默认设备
|
||||
void initDeviceCombox();
|
||||
void initUI();
|
||||
void initList();
|
||||
void initList(QString m_deviceName);
|
||||
void addNewItem(KyConnectItem *itemData, QListWidget *listWidget);
|
||||
void addNew(LanListItem *item, QListWidget *listWidget);
|
||||
void initNetSwitch();
|
||||
|
||||
private:
|
||||
QListWidget * m_activatedLanListWidget = nullptr;
|
||||
QListWidget * m_inactivatedLanListWidget = nullptr;
|
||||
|
||||
LanListItem * m_nullLanItem = nullptr;
|
||||
LanListItem * m_testLanItem = nullptr;
|
||||
QListWidgetItem *m_nullItem = nullptr;
|
||||
QListWidgetItem *m_listWidgetItem = nullptr;
|
||||
|
||||
KyNetworkDeviceResourse *m_device = nullptr;
|
||||
|
@ -52,8 +55,14 @@ private:
|
|||
QList<KyConnectItem *> m_activedList;
|
||||
QList<KyConnectItem *> m_deactivedList;
|
||||
|
||||
QMap<QString, QVector<QStringList> > m_deviceMap;
|
||||
|
||||
QMap<KyConnectItem *, QListWidgetItem *> m_deactiveMap;
|
||||
QMap<KyConnectItem *, QListWidgetItem *> m_activeMap;
|
||||
|
||||
// QMap<LanListItem *, QListWidgetItem *> m_deactiveMap;
|
||||
// QMap<LanListItem *, QListWidgetItem *> m_activeMap;
|
||||
|
||||
QString m_deviceName;
|
||||
QStringList devList;
|
||||
QGSettings * m_switchGsettings = nullptr;
|
||||
|
@ -66,6 +75,7 @@ private slots:
|
|||
void onLanSwitchClicked();
|
||||
void onDeviceAdd(QString deviceName, NetworkManager::Device::Type deviceType);
|
||||
void onDeviceRemove(QString deviceName);
|
||||
void onDeviceChanged();
|
||||
void onDeviceNameUpdate(QString oldName, QString newName);
|
||||
void onDeviceComboxIndexChanged(int currentIndex);
|
||||
};
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
#include "radioitembutton.h"
|
||||
#include <QPainter>
|
||||
#include <QStyle>
|
||||
|
||||
#define FRAMESPEED 100
|
||||
#define ALLTIME 10000
|
||||
#define BUTTON_SIZE 36,36
|
||||
#define ICON_SIZE 16,16
|
||||
#define BACKGROUND_COLOR QColor(0,0,0,0)
|
||||
|
@ -20,11 +21,16 @@ RadioItemButton::RadioItemButton(QWidget *parent) : QPushButton(parent)
|
|||
this->setFixedSize(BUTTON_SIZE);
|
||||
m_iconLabel->setFixedSize(BUTTON_SIZE);
|
||||
m_iconLabel->setAlignment(Qt::AlignCenter);
|
||||
countCurrentTime=0;
|
||||
currentPage=10;
|
||||
|
||||
|
||||
setActive(false);
|
||||
//JXJ_TODO loading动画
|
||||
// switchTimer = new QTimer(this);
|
||||
// connect(switchTimer, &QTimer::timeout, this, &RadioItemButton::onLoadingStarted);
|
||||
switchTimer = new QTimer(this);
|
||||
connect(switchTimer, &QTimer::timeout, this, &RadioItemButton::onLoadingStarted);
|
||||
connect(this, &RadioItemButton::requestStartLoading, this, &RadioItemButton::onLoadingStarted);
|
||||
connect(this , &RadioItemButton::requestStopLoading, this, &RadioItemButton::onLoadingStopped);
|
||||
}
|
||||
|
||||
void RadioItemButton::startLoading()
|
||||
|
@ -54,31 +60,32 @@ void RadioItemButton::setActive(const bool &isActive)
|
|||
void RadioItemButton::onLoadingStarted()
|
||||
{
|
||||
//ZJP_TODO 开始播放转圈动画
|
||||
// switchTimer->start(FRAMESPEED);
|
||||
// QString qpmQss = ":/res/s/conning-b/";
|
||||
// qpmQss.append(QString::number(this->currentPage));
|
||||
// qpmQss.append(".png");
|
||||
// m_iconLabel->setPixmap(QPixmap(qpmQss));
|
||||
//// m_iconLabel->setProperty("useIconHighlightEffect", true);
|
||||
//// m_iconLabel->setProperty("iconHighlightEffectMode", true);
|
||||
switchTimer->start(FRAMESPEED);
|
||||
QString qpmQss = ":/res/s/conning-s/";
|
||||
qpmQss.append(QString::number(this->currentPage));
|
||||
qpmQss.append(".png");
|
||||
m_iconLabel->setPixmap(QPixmap(qpmQss));
|
||||
// m_iconLabel->setProperty("useIconHighlightEffect",true);
|
||||
// m_iconLabel->setProperty("iconHighlightEffectMode",true);
|
||||
|
||||
// this->currentPage --;
|
||||
this->currentPage --;
|
||||
|
||||
// if (this->currentPage < 1) {
|
||||
// this->currentPage = 12; //循环播放
|
||||
// }
|
||||
// this->countCurrentTime += FRAMESPEED;
|
||||
// //达到一定的时间退出。应该是收到连接成功或者失败的信号断开
|
||||
// if (this->countCurrentTime >= ALLTIME) {
|
||||
// emit this->onLoadingStopped();
|
||||
// }
|
||||
if (this->currentPage < 1) {
|
||||
this->currentPage = 10; //循环播放
|
||||
}
|
||||
this->countCurrentTime += FRAMESPEED;
|
||||
//达到一定的时间退出。应该是收到连接成功或者失败的信号断开
|
||||
if (this->countCurrentTime >= ALLTIME) {
|
||||
countCurrentTime=0;
|
||||
emit this->onLoadingStopped();
|
||||
}
|
||||
}
|
||||
|
||||
void RadioItemButton::onLoadingStopped()
|
||||
{
|
||||
//ZJP_TODO 停止播放转圈动画
|
||||
this->switchTimer->stop();
|
||||
|
||||
// this->m_iconLabel->hide();
|
||||
}
|
||||
|
||||
void RadioItemButton::paintEvent(QPaintEvent *event)
|
||||
|
|
|
@ -40,3 +40,4 @@ private slots:
|
|||
};
|
||||
|
||||
#endif // NETBUTTON_H
|
||||
|
||||
|
|
Loading…
Reference in New Issue