dbus - active && deactive

This commit is contained in:
jzxc95 2021-09-14 10:40:38 +08:00
parent 325f9dd634
commit 6d7e721972
4 changed files with 82 additions and 27 deletions

View File

@ -442,23 +442,23 @@ void MainWindow::showCreateWiredConnectWidget(const QString devName)
}
//有线连接断开
void MainWindow::activateWired(const QString& devName, const QString& connName)
void MainWindow::activateWired(const QString& devName, const QString& connUuid)
{
m_lanWidget->activateWired(devName, connUuid);
}
void MainWindow::deactivateWired(const QString& devName, const QString& connName)
void MainWindow::deactivateWired(const QString& devName, const QString& connUuid)
{
m_lanWidget->deactivateWired(devName, connUuid);
}
//无线连接断开
void MainWindow::activateWireless(const QString& devName, const QString& ssid)
{
m_wlanWidget->activateWireless(devName, ssid);
}
void MainWindow::deactivateWireless(const QString& devName, const QString& ssid)
{
m_wlanWidget->deactivateWireless(devName, ssid);
}

View File

@ -34,8 +34,8 @@ public:
//获取热点
void getStoredApInfo(QStringList &list);
//有线连接断开
void activateWired(const QString& devName, const QString& connName);
void deactivateWired(const QString& devName, const QString& connName);
void activateWired(const QString& devName, const QString& connUuid);
void deactivateWired(const QString& devName, const QString& connUuid);
//无线连接断开
void activateWireless(const QString& devName, const QString& ssid);
void deactivateWireless(const QString& devName, const QString& ssid);

View File

@ -25,16 +25,15 @@ LanPage::LanPage(QWidget *parent) : TabPage(parent)
m_device = new KyNetworkDeviceResourse;
devList.empty();
m_nullLanItem = new LanListItem();
initDevice();
initUI();
initDeviceCombox();
if (QGSettings::isSchemaInstalled(GSETTINGS_SCHEMA)) {
m_switchGsettings = new QGSettings(GSETTINGS_SCHEMA);
initNetSwitch();
} else {
} else {
qDebug()<<"[LanPage] org.ukui.kylin-nm.switch is not installed!";
}
}
initDevice();
initDeviceCombox();
initList(m_deviceName);
connect(m_activeResourse, &KyActiveConnectResourse::stateChangeReason, this, &LanPage::updateLanlist);
connect(m_connectResourse, &KyConnectResourse::connectionAdd, this, &LanPage::addConnectionSlot);
@ -212,18 +211,32 @@ void LanPage::initDevice()
void LanPage::initDeviceCombox()
{
//TODO 获取设备列表,单设备时隐藏下拉框,多设备时添加到下拉框
QMap<QString, bool> enableMap;
getDeviceEnableState(0,enableMap);
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_deviceFrame->show();
QMap<QString, QVector<QStringList> >::iterator iter;
for (iter = m_deviceMap.begin(); iter != m_deviceMap.constEnd(); ++iter) {
if (enableMap.contains(iter.key())) {
if (enableMap[iter.key()]) {
m_deviceComboBox->addItem(iter.key());
}
} else {
m_deviceComboBox->addItem(iter.key());
saveDeviceEnableState(iter.key(), true);
}
// }
}
if (m_deviceComboBox->currentText().isEmpty()) {
if (m_switchGsettings->get(WIRED_SWITCH).toBool()) {
m_switchGsettings->set(WIRED_SWITCH,false);
}
} else {
if (!m_switchGsettings->get(WIRED_SWITCH).toBool()) {
m_switchGsettings->set(WIRED_SWITCH,true);
}
}
qDebug() << "[LanPage]current:" << m_deviceComboBox->currentText();
}
@ -514,17 +527,30 @@ void LanPage::getWiredList(QMap<QString, QVector<QStringList> > &map)
void LanPage::setWiredDeviceEnable(const QString& devName, bool enable)
{
//todo:
saveDeviceEnableState(devName, enable);
initDeviceCombox();
}
void LanPage::activateWired(const QString& devName, const QString& connUuid)
{
//todo:
qDebug() << "activateWired" << devName << connUuid;
KyWiredConnectOperation a;
a.activateConnection(connUuid, devName);
}
void LanPage::deactivateWired(const QString& devName, const QString& connUuid)
{
//todo:
qDebug() << "deactivateWired" << devName << connUuid;
KyConnectItem *item = nullptr;
item = m_activeResourse->getActiveConnectionByUuid(connUuid, devName);
if (nullptr == item) {
//todo: 通知桌面
qDebug() << "not ActiveConnection";
return;
}
KyWiredConnectOperation a;
a.deactivateWiredConnection(item->m_connectName, connUuid);
}
void LanPage::showDetailPage(QString devName, QString uuid)

View File

@ -140,7 +140,6 @@ void WlanPage::initTimer()
{
m_scanTimer = new QTimer(this);
connect(m_scanTimer, &QTimer::timeout, this, &WlanPage::requestScan);
// m_scanTimer->start(10 * 1000);
}
/**
@ -648,12 +647,42 @@ void WlanPage::getStoredApInfo(QStringList &list)
void WlanPage::activateWireless(const QString& devName, const QString& ssid)
{
//todo
KyWirelessNetItem data;
if (!m_resource->getWifiNetwork(devName, ssid, data)) {
qDebug() << "no such wifi " << ssid << " in " << devName;
return;
}
if (data.m_isConfigured) {
m_wirelessConnectOpreation->activeWirelessConnect(devName, data.m_connectUuid);
} else {
//todo: 显示界面输入密码 无需密码的wifi
}
}
void WlanPage::deactivateWireless(const QString& devName, const QString& ssid)
{
//todo
KyWirelessNetItem data;
if (!m_resource->getWifiNetwork(devName, ssid, data)) {
qDebug() << "no such wifi " << ssid << " in " << devName;
return;
}
QMap<QString,QStringList> actMap;
m_resource->getWirelessActiveConnection(NetworkManager::ActiveConnection::State::Activated, actMap);
QMap<QString,QStringList>::iterator iter = actMap.begin();
if (!actMap.contains(devName)) {
qDebug() << "no such device" << devName;
return;
}
if (!actMap[devName].contains(ssid)) {
qDebug() << "no such actived wifi" << ssid;
return;
}
qDebug() << "deActivateWirelessConnection" << devName << ssid;
m_wirelessConnectOpreation->deActivateWirelessConnection(data.m_connName, data.m_connectUuid);
}
void WlanPage::onMainWindowVisibleChanged(const bool &visible)
@ -670,7 +699,7 @@ void WlanPage::onMainWindowVisibleChanged(const bool &visible)
}
//若页面打开,开始扫描倒计时,若关闭,停止扫描倒计时
if (visible) {
m_scanTimer->start(10 * 1000);
m_scanTimer->start(20 * 1000);
} else {
m_scanTimer->stop();
}