Merge branch 'yhkylin/v101' of https://gitlab2.kylin.com/kylinos-src/kylin-nm into 0928-up

This commit is contained in:
jzxc95 2023-11-01 10:39:11 +08:00
commit a070c22449
11 changed files with 254 additions and 28 deletions

20
debian/changelog vendored
View File

@ -1,3 +1,23 @@
kylin-nm (3.25.0.0-0k0.1) v101; urgency=medium
* BUG:
* 需求号:
- #23928 仅支持单一网络功能、单网卡时界面显示优化
* 其他改动说明:
* 其他改动影响域:控制面板 托盘tab页
-- zhaoshixu <zhaoshixu@kylinos.cn> Wed, 18 Oct 2023 14:47:09 +0800
kylin-nm (3.24.0.0-0k2.23) v101; urgency=medium
* BUG:
- #197411 【网络连接】点击控制面板-有线网络界面内"添加有线网络"和属性按钮无反应
* 需求号:无
* 其他改动说明:
* 其他改动影响域wayland环境下控制面板唤出网络界面
-- zhaoshixu <zhaoshixu@kylinos.cn> Tue, 17 Oct 2023 17:26:48 +0800
kylin-nm (3.24.0.0-0k2.22) v101; urgency=medium
* BUG:

View File

@ -83,6 +83,16 @@ NetConnect::NetConnect() : mFirstLoad(true) {
pluginName = tr("LAN");
pluginType = NETWORK;
m_interface = new QDBusInterface("com.kylin.network",
"/com/kylin/network",
"com.kylin.network",
QDBusConnection::sessionBus());
if(!m_interface->isValid()) {
qWarning() << qPrintable(QDBusConnection::sessionBus().lastError().message());
}
updatePluginShowSettings();
connect(m_interface, SIGNAL(deviceStatusChanged()), this, SLOT(updatePluginShowSettings()),Qt::QueuedConnection);
}
NetConnect::~NetConnect() {
@ -110,6 +120,7 @@ QWidget *NetConnect::pluginUi() {
pluginWidget = new QWidget;
pluginWidget->setAttribute(Qt::WA_DeleteOnClose);
ui->setupUi(pluginWidget);
m_interface = new QDBusInterface("com.kylin.network",
"/com/kylin/network",
"com.kylin.network",
@ -117,6 +128,9 @@ QWidget *NetConnect::pluginUi() {
if(!m_interface->isValid()) {
qWarning() << qPrintable(QDBusConnection::sessionBus().lastError().message());
}
qDBusRegisterMetaType<QVector<QStringList>>();
initSearchText();
initComponent();
}
@ -130,7 +144,54 @@ const QString NetConnect::name() const {
bool NetConnect::isEnable() const
{
return true;
//get isEnable
QDBusInterface dbus("com.kylin.network", "/com/kylin/network",
"com.kylin.network",
QDBusConnection::sessionBus());
if (!dbus.isValid()) {
return false;
}
QMap<QString,bool> map;
QDBusReply<QVariantMap> reply = dbus.call(QStringLiteral("getDeviceListAndEnabled"),0);
if(!reply.isValid())
{
qWarning() << "[NetConnect]getWiredDeviceList error:" << reply.error().message();
return false;
}
QVariantMap::const_iterator item = reply.value().cbegin();
while (item != reply.value().cend()) {
map.insert(item.key(), item.value().toBool());
item ++;
}
bool isEnabled = !map.isEmpty();
const QByteArray schema("org.ukui.control-center.plugins");
if (QGSettings::isSchemaInstalled(schema)) {
return isEnabled;
}
//get gsettings
QGSettings *showSettings;
QString path("/org/ukui/control-center/plugins/netconnect/");
showSettings = new QGSettings(schema, path.toUtf8());
QVariant enabledState = showSettings->get("show");
//set gsettings
if (!enabledState.isValid() || enabledState.isNull()) {
qWarning() << "QGSettins get plugin show status error";
} else {
if (enabledState.toBool() != isEnabled) {
showSettings->set("show", isEnabled);
}
}
delete showSettings;
showSettings = nullptr;
return isEnabled;
}
@ -154,7 +215,8 @@ void NetConnect::initSearchText() {
ui->detailBtn->setText(tr("Advanced settings"));
ui->titleLabel->setText(tr("LAN"));
//~ contents_path /netconnect/open
ui->openLabel->setText(tr("open"));
tr("open");
ui->openLabel->setText(tr("LAN"));
}
bool NetConnect::eventFilter(QObject *w, QEvent *e) {
@ -934,3 +996,8 @@ QMap<QString, QList<QStringList>> NetConnect::getWiredList()
}
return map;
}
void NetConnect::updatePluginShowSettings()
{
isEnable();
}

View File

@ -156,6 +156,9 @@ private slots:
void onDeviceStatusChanged();
void onDeviceNameChanged(QString, QString, int);
//更新控制面板插件Gsetting show
void updatePluginShowSettings();
};
Q_DECLARE_METATYPE(QList<QDBusObjectPath>);

View File

@ -139,6 +139,15 @@ WlanConnect::WlanConnect() : m_firstLoad(true) {
pluginName = tr("WLAN");
pluginType = NETWORK;
m_interface = new QDBusInterface("com.kylin.network", "/com/kylin/network",
"com.kylin.network",
QDBusConnection::sessionBus());
if(!m_interface->isValid()) {
qWarning() << qPrintable(QDBusConnection::sessionBus().lastError().message());
}
updatePluginShowSettings();
connect(m_interface, SIGNAL(wirelessDeviceStatusChanged()), this, SLOT(updatePluginShowSettings()), Qt::QueuedConnection);
}
WlanConnect::~WlanConnect()
@ -167,13 +176,14 @@ QWidget *WlanConnect::pluginUi() {
pluginWidget->setAttribute(Qt::WA_DeleteOnClose);
ui->setupUi(pluginWidget);
qDBusRegisterMetaType<QVector<QStringList>>();
qDBusRegisterMetaType<QStringList>();
qDBusRegisterMetaType<QStringList>();
m_interface = new QDBusInterface("com.kylin.network", "/com/kylin/network",
"com.kylin.network",
QDBusConnection::sessionBus());
if(!m_interface->isValid()) {
qWarning() << qPrintable(QDBusConnection::sessionBus().lastError().message());
}
initSearchText();
initComponent();
}
@ -187,7 +197,61 @@ const QString WlanConnect::name() const {
bool WlanConnect::isEnable() const
{
return true;
//get isEnable
QDBusInterface dbus("com.kylin.network", "/com/kylin/network",
"com.kylin.network",
QDBusConnection::sessionBus());
if (!dbus.isValid()) {
return false;
}
QMap<QString,bool> map;
QDBusReply<QVariantMap> reply = dbus.call(QStringLiteral("getDeviceListAndEnabled"), 1);
if(!reply.isValid())
{
qWarning() << "[NetConnect]getWiredDeviceList error:" << reply.error().message();
return false;
}
QVariantMap::const_iterator item = reply.value().cbegin();
while (item != reply.value().cend()) {
map.insert(item.key(), item.value().toBool());
item ++;
}
//筛选已托管(managed)网卡
QStringList list;
QMap<QString, bool>::iterator iters;
for (iters = map.begin(); iters != map.end(); ++iters) {
if (iters.value() == true) {
list << iters.key();
}
}
bool isEnabled = !list.isEmpty();
const QByteArray schema("org.ukui.control-center.plugins");
if (QGSettings::isSchemaInstalled(schema)) {
return isEnabled;
}
//get gsettings
QGSettings *showSettings;
QString path("/org/ukui/control-center/plugins/wlanconnect/");
showSettings = new QGSettings(schema, path.toUtf8());
QVariant enabledState = showSettings->get("show");
//set gsettings
if (!enabledState.isValid() || enabledState.isNull()) {
qWarning() << "QGSettins get plugin show status error";
} else {
if (enabledState.toBool() != isEnabled) {
showSettings->set("show", isEnabled);
}
}
delete showSettings;
showSettings = nullptr;
return isEnabled;
}
@ -211,7 +275,8 @@ void WlanConnect::initSearchText() {
ui->detailBtn->setText(tr("Advanced settings"));
ui->titleLabel->setText(tr("WLAN"));
//~ contents_path /wlanconnect/open
ui->openLabel->setText(tr("open"));
tr("open");
ui->openLabel->setText(tr("WLAN"));
}
bool WlanConnect::eventFilter(QObject *w, QEvent *e) {
@ -1133,3 +1198,8 @@ QMap<QString, QList<QStringList>> WlanConnect::getWirelessList()
return map;
}
void WlanConnect::updatePluginShowSettings()
{
isEnable();
}

View File

@ -194,6 +194,7 @@ private slots:
void reScan();
//更新控制面板插件Gsetting show
void updatePluginShowSettings();
};
#endif // WLANCONNECT_H

View File

@ -39,6 +39,7 @@
#define MAINWINDOW_HEIGHT 476
#define LAYOUT_MARGINS 0,0,0,0
#define LOADING_TRAYICON_TIMER_MS 60
#define TABBAR_HEIGHT 30
#define THEME_SCHAME "org.ukui.style"
#define COLOR_THEME "styleName"
@ -181,6 +182,11 @@ void MainWindow::firstlyStart()
//加载key ring
agent_init();
//单网卡显示
setCentralWidgetPages();
connect(m_lanWidget, &LanPage::deviceStatusChanged, this, &MainWindow::setCentralWidgetPages);
connect(m_wlanWidget, &LanPage::wirelessDeviceStatusChanged, this, &MainWindow::setCentralWidgetPages);
}
/**
@ -874,8 +880,56 @@ void MainWindow::onRefreshTrayIconTooltip()
m_trayIcon->setToolTip(trayIconToolTip);
}
void MainWindow::setCentralWidgetPages()
{
bool isChanged = false;
if (m_isWiredUsable != m_lanWidget->isWiredDeviceUsable()) {
if (m_lanWidget->isWiredDeviceUsable()) {
m_centralWidget->insertTab(LANPAGE, m_lanWidget, "");
m_isWiredUsable = true;
} else {
m_centralWidget->removeTab(LANPAGE);
m_isWiredUsable = false;
}
isChanged = true;
}
if (m_isWirelessUsable != m_wlanWidget->isWirelessDeviceUsable()) {
if (m_wlanWidget->isWirelessDeviceUsable()) {
m_centralWidget->insertTab(WLANPAGE, m_wlanWidget, "");
m_isWirelessUsable = true;
} else {
m_centralWidget->removeTab(WLANPAGE);
m_isWirelessUsable = false;
}
isChanged = true;
}
if (!isChanged) {
return;
}
if (m_isWiredUsable && m_isWirelessUsable) {
m_centralWidget->tabBar()->show();
this->setFixedHeight(MAINWINDOW_HEIGHT);
resetWindowPosition();
} else {
m_centralWidget->tabBar()->hide();
this->setFixedHeight(MAINWINDOW_HEIGHT - TABBAR_HEIGHT);
resetWindowPosition();
}
if (m_trayIcon) {
m_trayIcon->setVisible(m_isWiredUsable || m_isWirelessUsable);
}
}
void MainWindow::onShowMainWindow(int type)
{
if (!m_trayIcon->isVisible()) {
qWarning() << "no valid network card, do not show kylin-nm mainwindow";
return;
}
if (type == LANPAGE || type == WLANPAGE) {
m_centralWidget->setCurrentIndex(type);

View File

@ -212,6 +212,9 @@ private:
QString m_display;
bool m_isWiredUsable = true;
bool m_isWirelessUsable = true;
public Q_SLOTS:
void onShowMainWindow(int type);
@ -238,6 +241,8 @@ private Q_SLOTS:
void onShowCreateWiredConnectWidgetSlot(QString display, QString devName);
//唤起加入其他无线网络界面
void onShowAddOtherWlanWidgetSlot(QString display, QString devName);
//设置界面显示 单网卡/多网卡
void setCentralWidgetPages();
};
#endif // MAINWINDOW_H

View File

@ -52,6 +52,10 @@ public:
bool lanIsConnected();
void getWiredDeviceConnectState(QMap<QString, QString> &map);
bool isWiredDeviceUsable() {
return !m_devList.isEmpty();
}
protected:
bool eventFilter(QObject *watched, QEvent *event);

View File

@ -295,9 +295,8 @@ void WlanPage::initDeviceCombox()
}
} else {
m_deviceFrame->hide();
//解决因m_currentDevice被置空安全中心网络显示BUG
// m_currentDevice = "";
// setDefaultDevice(WIRELESS, m_currentDevice);
m_currentDevice = "";
setDefaultDevice(WIRELESS, m_currentDevice);
}
connect(m_deviceComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged),
@ -781,25 +780,23 @@ void WlanPage::deleteDeviceFromCombox(QString deviceName)
disconnect(m_deviceComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged),
this, &WlanPage::onDeviceComboxIndexChanged);
if (getSwitchBtnState()) {
if (0 == m_devList.count()) {
m_deviceFrame->hide();
//m_tipsLabel->show();
//m_deviceComboBox->hide();
m_currentDevice = "";
if (0 == m_devList.count()) {
m_deviceFrame->hide();
//m_tipsLabel->show();
//m_deviceComboBox->hide();
m_currentDevice = "";
setDefaultDevice(WIRELESS, m_currentDevice);
} else if (1 == m_devList.count()) {
m_deviceFrame->hide();
m_deviceComboBox->clear();
m_currentDevice = m_devList.at(0);
setDefaultDevice(WIRELESS, m_currentDevice);
} else {
int index = m_deviceComboBox->findText(deviceName);
if (-1 != index) {
m_deviceComboBox->removeItem(index);
m_currentDevice = m_deviceComboBox->currentText();
setDefaultDevice(WIRELESS, m_currentDevice);
} else if (1 == m_devList.count()) {
m_deviceFrame->hide();
m_deviceComboBox->clear();
m_currentDevice = m_devList.at(0);
setDefaultDevice(WIRELESS, m_currentDevice);
} else {
int index = m_deviceComboBox->findText(deviceName);
if (-1 != index) {
m_deviceComboBox->removeItem(index);
m_currentDevice = m_deviceComboBox->currentText();
setDefaultDevice(WIRELESS, m_currentDevice);
}
}
}

View File

@ -88,6 +88,10 @@ public:
return m_currentDevice;
}
bool isWirelessDeviceUsable() {
return !m_devList.isEmpty();
}
Q_SIGNALS:
void oneItemExpanded(const QString &ssid);
void wlanAdd(QString devName, QStringList info);

View File

@ -134,7 +134,8 @@ int main(int argc, char *argv[])
sessionType = "x11";
display = getenv("DISPLAY");
}
qDebug() << display;
qDebug() << sessionType << display;
qApp->setProperty("sessionType", sessionType);
QDBusInterface interface("com.kylin.network",
"/com/kylin/network",