Merge branch 'v101-1008' into 'yhkylin/v101'
pref(ui): 单网卡显示优化(story#18148) See merge request kylinos-src/kylin-nm!282
This commit is contained in:
commit
c81d6a4f59
|
@ -83,6 +83,16 @@ NetConnect::NetConnect() : mFirstLoad(true) {
|
||||||
|
|
||||||
pluginName = tr("LAN");
|
pluginName = tr("LAN");
|
||||||
pluginType = NETWORK;
|
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() {
|
NetConnect::~NetConnect() {
|
||||||
|
@ -110,6 +120,7 @@ QWidget *NetConnect::pluginUi() {
|
||||||
pluginWidget = new QWidget;
|
pluginWidget = new QWidget;
|
||||||
pluginWidget->setAttribute(Qt::WA_DeleteOnClose);
|
pluginWidget->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
ui->setupUi(pluginWidget);
|
ui->setupUi(pluginWidget);
|
||||||
|
|
||||||
m_interface = new QDBusInterface("com.kylin.network",
|
m_interface = new QDBusInterface("com.kylin.network",
|
||||||
"/com/kylin/network",
|
"/com/kylin/network",
|
||||||
"com.kylin.network",
|
"com.kylin.network",
|
||||||
|
@ -117,6 +128,9 @@ QWidget *NetConnect::pluginUi() {
|
||||||
if(!m_interface->isValid()) {
|
if(!m_interface->isValid()) {
|
||||||
qWarning() << qPrintable(QDBusConnection::sessionBus().lastError().message());
|
qWarning() << qPrintable(QDBusConnection::sessionBus().lastError().message());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
qDBusRegisterMetaType<QVector<QStringList>>();
|
||||||
|
|
||||||
initSearchText();
|
initSearchText();
|
||||||
initComponent();
|
initComponent();
|
||||||
}
|
}
|
||||||
|
@ -130,7 +144,54 @@ const QString NetConnect::name() const {
|
||||||
|
|
||||||
bool NetConnect::isEnable() 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->detailBtn->setText(tr("Advanced settings"));
|
||||||
ui->titleLabel->setText(tr("LAN"));
|
ui->titleLabel->setText(tr("LAN"));
|
||||||
//~ contents_path /netconnect/open
|
//~ contents_path /netconnect/open
|
||||||
ui->openLabel->setText(tr("open"));
|
tr("open");
|
||||||
|
ui->openLabel->setText(tr("LAN"));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NetConnect::eventFilter(QObject *w, QEvent *e) {
|
bool NetConnect::eventFilter(QObject *w, QEvent *e) {
|
||||||
|
@ -934,3 +996,8 @@ QMap<QString, QList<QStringList>> NetConnect::getWiredList()
|
||||||
}
|
}
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NetConnect::updatePluginShowSettings()
|
||||||
|
{
|
||||||
|
isEnable();
|
||||||
|
}
|
||||||
|
|
|
@ -156,6 +156,9 @@ private slots:
|
||||||
|
|
||||||
void onDeviceStatusChanged();
|
void onDeviceStatusChanged();
|
||||||
void onDeviceNameChanged(QString, QString, int);
|
void onDeviceNameChanged(QString, QString, int);
|
||||||
|
|
||||||
|
//更新控制面板插件Gsetting show
|
||||||
|
void updatePluginShowSettings();
|
||||||
};
|
};
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(QList<QDBusObjectPath>);
|
Q_DECLARE_METATYPE(QList<QDBusObjectPath>);
|
||||||
|
|
|
@ -139,6 +139,15 @@ WlanConnect::WlanConnect() : m_firstLoad(true) {
|
||||||
|
|
||||||
pluginName = tr("WLAN");
|
pluginName = tr("WLAN");
|
||||||
pluginType = NETWORK;
|
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()
|
WlanConnect::~WlanConnect()
|
||||||
|
@ -174,6 +183,7 @@ QWidget *WlanConnect::pluginUi() {
|
||||||
if(!m_interface->isValid()) {
|
if(!m_interface->isValid()) {
|
||||||
qWarning() << qPrintable(QDBusConnection::sessionBus().lastError().message());
|
qWarning() << qPrintable(QDBusConnection::sessionBus().lastError().message());
|
||||||
}
|
}
|
||||||
|
|
||||||
initSearchText();
|
initSearchText();
|
||||||
initComponent();
|
initComponent();
|
||||||
}
|
}
|
||||||
|
@ -187,7 +197,61 @@ const QString WlanConnect::name() const {
|
||||||
|
|
||||||
bool WlanConnect::isEnable() 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->detailBtn->setText(tr("Advanced settings"));
|
||||||
ui->titleLabel->setText(tr("WLAN"));
|
ui->titleLabel->setText(tr("WLAN"));
|
||||||
//~ contents_path /wlanconnect/open
|
//~ contents_path /wlanconnect/open
|
||||||
ui->openLabel->setText(tr("open"));
|
tr("open");
|
||||||
|
ui->openLabel->setText(tr("WLAN"));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WlanConnect::eventFilter(QObject *w, QEvent *e) {
|
bool WlanConnect::eventFilter(QObject *w, QEvent *e) {
|
||||||
|
@ -1133,3 +1198,8 @@ QMap<QString, QList<QStringList>> WlanConnect::getWirelessList()
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WlanConnect::updatePluginShowSettings()
|
||||||
|
{
|
||||||
|
isEnable();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -194,6 +194,7 @@ private slots:
|
||||||
|
|
||||||
void reScan();
|
void reScan();
|
||||||
|
|
||||||
|
//更新控制面板插件Gsetting show
|
||||||
|
void updatePluginShowSettings();
|
||||||
};
|
};
|
||||||
#endif // WLANCONNECT_H
|
#endif // WLANCONNECT_H
|
||||||
|
|
|
@ -38,6 +38,7 @@
|
||||||
#define MAINWINDOW_HEIGHT 476
|
#define MAINWINDOW_HEIGHT 476
|
||||||
#define LAYOUT_MARGINS 0,0,0,0
|
#define LAYOUT_MARGINS 0,0,0,0
|
||||||
#define LOADING_TRAYICON_TIMER_MS 60
|
#define LOADING_TRAYICON_TIMER_MS 60
|
||||||
|
#define TABBAR_HEIGHT 30
|
||||||
#define THEME_SCHAME "org.ukui.style"
|
#define THEME_SCHAME "org.ukui.style"
|
||||||
#define COLOR_THEME "styleName"
|
#define COLOR_THEME "styleName"
|
||||||
|
|
||||||
|
@ -174,6 +175,11 @@ void MainWindow::firstlyStart()
|
||||||
|
|
||||||
//加载key ring
|
//加载key ring
|
||||||
agent_init();
|
agent_init();
|
||||||
|
|
||||||
|
//单网卡显示
|
||||||
|
setCentralWidgetPages();
|
||||||
|
connect(m_lanWidget, &LanPage::deviceStatusChanged, this, &MainWindow::setCentralWidgetPages);
|
||||||
|
connect(m_wlanWidget, &LanPage::wirelessDeviceStatusChanged, this, &MainWindow::setCentralWidgetPages);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -826,8 +832,56 @@ void MainWindow::onRefreshTrayIconTooltip()
|
||||||
m_trayIcon->setToolTip(trayIconToolTip);
|
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)
|
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) {
|
if (type == LANPAGE || type == WLANPAGE) {
|
||||||
m_centralWidget->setCurrentIndex(type);
|
m_centralWidget->setCurrentIndex(type);
|
||||||
|
|
||||||
|
|
|
@ -206,6 +206,9 @@ private:
|
||||||
|
|
||||||
QString m_display;
|
QString m_display;
|
||||||
|
|
||||||
|
bool m_isWiredUsable = true;
|
||||||
|
bool m_isWirelessUsable = true;
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
void onShowMainWindow(int type);
|
void onShowMainWindow(int type);
|
||||||
|
|
||||||
|
@ -231,6 +234,8 @@ private Q_SLOTS:
|
||||||
void onShowCreateWiredConnectWidgetSlot(QString display, QString devName);
|
void onShowCreateWiredConnectWidgetSlot(QString display, QString devName);
|
||||||
//唤起加入其他无线网络界面
|
//唤起加入其他无线网络界面
|
||||||
void onShowAddOtherWlanWidgetSlot(QString display, QString devName);
|
void onShowAddOtherWlanWidgetSlot(QString display, QString devName);
|
||||||
|
//设置界面显示 单网卡/多网卡
|
||||||
|
void setCentralWidgetPages();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MAINWINDOW_H
|
#endif // MAINWINDOW_H
|
||||||
|
|
|
@ -52,6 +52,10 @@ public:
|
||||||
bool lanIsConnected();
|
bool lanIsConnected();
|
||||||
void getWiredDeviceConnectState(QMap<QString, QString> &map);
|
void getWiredDeviceConnectState(QMap<QString, QString> &map);
|
||||||
|
|
||||||
|
bool isWiredDeviceUsable() {
|
||||||
|
return !m_devList.isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool eventFilter(QObject *watched, QEvent *event);
|
bool eventFilter(QObject *watched, QEvent *event);
|
||||||
|
|
||||||
|
|
|
@ -294,9 +294,8 @@ void WlanPage::initDeviceCombox()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
m_deviceFrame->hide();
|
m_deviceFrame->hide();
|
||||||
//解决因m_currentDevice被置空,安全中心网络显示BUG
|
m_currentDevice = "";
|
||||||
// m_currentDevice = "";
|
setDefaultDevice(WIRELESS, m_currentDevice);
|
||||||
// setDefaultDevice(WIRELESS, m_currentDevice);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
connect(m_deviceComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged),
|
connect(m_deviceComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged),
|
||||||
|
@ -780,7 +779,6 @@ void WlanPage::deleteDeviceFromCombox(QString deviceName)
|
||||||
disconnect(m_deviceComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged),
|
disconnect(m_deviceComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged),
|
||||||
this, &WlanPage::onDeviceComboxIndexChanged);
|
this, &WlanPage::onDeviceComboxIndexChanged);
|
||||||
|
|
||||||
if (getSwitchBtnState()) {
|
|
||||||
if (0 == m_devList.count()) {
|
if (0 == m_devList.count()) {
|
||||||
m_deviceFrame->hide();
|
m_deviceFrame->hide();
|
||||||
//m_tipsLabel->show();
|
//m_tipsLabel->show();
|
||||||
|
@ -800,7 +798,6 @@ void WlanPage::deleteDeviceFromCombox(QString deviceName)
|
||||||
setDefaultDevice(WIRELESS, m_currentDevice);
|
setDefaultDevice(WIRELESS, m_currentDevice);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
connect(m_deviceComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged),
|
connect(m_deviceComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged),
|
||||||
this, &WlanPage::onDeviceComboxIndexChanged);
|
this, &WlanPage::onDeviceComboxIndexChanged);
|
||||||
|
|
|
@ -88,6 +88,10 @@ public:
|
||||||
return m_currentDevice;
|
return m_currentDevice;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isWirelessDeviceUsable() {
|
||||||
|
return !m_devList.isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void oneItemExpanded(const QString &ssid);
|
void oneItemExpanded(const QString &ssid);
|
||||||
void wlanAdd(QString devName, QStringList info);
|
void wlanAdd(QString devName, QStringList info);
|
||||||
|
|
Loading…
Reference in New Issue