Merge branch 'dbus-interface' into 'dbus-interface'

Fix:bug

See merge request kylin-desktop/kylin-nm!324
This commit is contained in:
Zhai Kangning 2021-10-15 11:41:53 +00:00
commit 4b46a52c92
12 changed files with 94 additions and 33 deletions

View File

@ -81,6 +81,32 @@ free_wifi_info (SecretsRequest *req)
} }
} }
void
applet_secrets_request_free (SecretsRequest *req)
{
g_return_if_fail (req != NULL);
if (req->free_func)
req->free_func (req);
secrets_reqs = g_slist_remove (secrets_reqs, req);
g_object_unref (req->connection);
g_free (req->setting_name);
g_strfreev (req->hints);
memset (req, 0, req->totsize);
g_free (req);
}
void
applet_secrets_request_complete (SecretsRequest *req,
GVariant *settings,
GError *error)
{
req->callback (req->agent, error ? NULL : settings, error, req->callback_data);
}
static void static void
get_secrets_dialog_response_cb (GtkDialog *foo, get_secrets_dialog_response_cb (GtkDialog *foo,
gint response, gint response,
@ -230,24 +256,6 @@ l_out:
//return 0; //return 0;
} }
void
applet_secrets_request_free (SecretsRequest *req)
{
g_return_if_fail (req != NULL);
if (req->free_func)
req->free_func (req);
secrets_reqs = g_slist_remove (secrets_reqs, req);
g_object_unref (req->connection);
g_free (req->setting_name);
g_strfreev (req->hints);
memset (req, 0, req->totsize);
g_free (req);
}
static SecretsRequest * static SecretsRequest *
applet_secrets_request_new (size_t totsize, applet_secrets_request_new (size_t totsize,
NMConnection *connection, NMConnection *connection,
@ -277,15 +285,6 @@ applet_secrets_request_new (size_t totsize,
return req; return req;
} }
void
applet_secrets_request_complete (SecretsRequest *req,
GVariant *settings,
GError *error)
{
req->callback (req->agent, error ? NULL : settings, error, req->callback_data);
}
static void static void
get_existing_secrets_cb (NMSecretAgentOld *agent, get_existing_secrets_cb (NMSecretAgentOld *agent,
NMConnection *connection, NMConnection *connection,

View File

@ -82,11 +82,17 @@ void LanListItem::onRightButtonClicked()
void LanListItem::onInfoButtonClicked() void LanListItem::onInfoButtonClicked()
{ {
if(isDetailShow){
qDebug() << "has show the detail page,and do not show again" << Q_FUNC_INFO << __LINE__;
return;
}
if(m_data){ if(m_data){
qDebug()<<"Net active or not:"<<m_isActive; qDebug()<<"Net active or not:"<<m_isActive;
qDebug() << "On lan info button clicked! uuid = " << m_data->m_connectUuid << "; name = " << m_data->m_connectName << "." <<Q_FUNC_INFO << __LINE__; qDebug() << "On lan info button clicked! uuid = " << m_data->m_connectUuid << "; name = " << m_data->m_connectName << "." <<Q_FUNC_INFO << __LINE__;
NetDetail *netDetail = new NetDetail(deviceName, m_data->m_connectName, m_data->m_connectUuid, m_isActive,false, false, this); NetDetail *netDetail = new NetDetail(deviceName, m_data->m_connectName, m_data->m_connectUuid, m_isActive,false, false, this);
connect(netDetail, &NetDetail::detailPageClose, this, &LanListItem::onDetailShow);
netDetail->show(); netDetail->show();
emit this->detailShow(true);
} }
else{ else{
qDebug() << "On lan info button clicked! But there is no wlan connect " ; qDebug() << "On lan info button clicked! But there is no wlan connect " ;

View File

@ -13,9 +13,11 @@
ListItem::ListItem(QWidget *parent) : QFrame(parent) ListItem::ListItem(QWidget *parent) : QFrame(parent)
{ {
isDetailShow = false;
initUI(); initUI();
initConnection(); initConnection();
connect(qApp, &QApplication::paletteChanged, this, &ListItem::onPaletteChanged); connect(qApp, &QApplication::paletteChanged, this, &ListItem::onPaletteChanged);
connect(this, &ListItem::detailShow, this, &ListItem::onDetailShow);
// m_itemFrame->installEventFilter(this); // m_itemFrame->installEventFilter(this);
} }
@ -160,3 +162,8 @@ void ListItem::onPaletteChanged()
pal.setColor(QPalette::Window, qApp->palette().base().color()); pal.setColor(QPalette::Window, qApp->palette().base().color());
this->setPalette(pal); this->setPalette(pal);
} }
void ListItem::onDetailShow(bool isShow)
{
isDetailShow = isShow;
}

View File

@ -39,6 +39,7 @@ protected:
public: public:
QVBoxLayout * m_mainLayout = nullptr; QVBoxLayout * m_mainLayout = nullptr;
QHBoxLayout * m_hItemLayout = nullptr; QHBoxLayout * m_hItemLayout = nullptr;
bool isDetailShow;
private: private:
void initUI(); void initUI();
void initConnection(); void initConnection();
@ -46,6 +47,10 @@ private:
public slots: public slots:
virtual void onNetButtonClicked() = 0; virtual void onNetButtonClicked() = 0;
void onPaletteChanged(); void onPaletteChanged();
void onDetailShow(bool isShow);
signals:
void detailShow(bool isShow);
}; };
#endif // LISTITEM_H #endif // LISTITEM_H

View File

@ -58,8 +58,8 @@ void WlanListItem::setExpanded(const bool &expanded)
} }
this->setFixedHeight(expanded ? EXPANDED_HEIGHT : NORMAL_HEIGHT); this->setFixedHeight(expanded ? EXPANDED_HEIGHT : NORMAL_HEIGHT);
m_pwdFrame->setVisible(expanded); // m_pwdFrame->setVisible(false);
m_autoConnectFrame->setVisible(expanded); // m_autoConnectFrame->setVisible(false);
emit this->itemHeightChanged(m_data->m_NetSsid); emit this->itemHeightChanged(m_data->m_NetSsid);
if (!expanded) { if (!expanded) {
QPalette pal = qApp->palette(); QPalette pal = qApp->palette();
@ -68,6 +68,12 @@ void WlanListItem::setExpanded(const bool &expanded)
} }
} }
void WlanListItem::setWlanItemPwdVisible(const bool &expanded)
{
m_pwdFrame->setVisible(expanded);
m_autoConnectFrame->setVisible(expanded);
}
QString WlanListItem::getSsid() QString WlanListItem::getSsid()
{ {
if (!m_data) { if (!m_data) {
@ -259,11 +265,17 @@ void WlanListItem::refreshIcon()
void WlanListItem::onInfoButtonClicked() void WlanListItem::onInfoButtonClicked()
{ {
//ZJP_TODO 呼出无线详情页 //ZJP_TODO 呼出无线详情页
if(isDetailShow){
qDebug() << "has show the detail page,and do not show again" << Q_FUNC_INFO << __LINE__;
return;
}
if(m_data){ if(m_data){
qDebug()<<"Net active or not:"<<m_isActive; qDebug()<<"Net active or not:"<<m_isActive;
qDebug() << "On wlan info button clicked! ssid = " << m_data->m_NetSsid << "; name = " << m_data->m_connName << "." <<Q_FUNC_INFO << __LINE__; qDebug() << "On wlan info button clicked! ssid = " << m_data->m_NetSsid << "; name = " << m_data->m_connName << "." <<Q_FUNC_INFO << __LINE__;
NetDetail *netDetail = new NetDetail(m_wlanDevice, m_data->m_NetSsid, m_data->m_connectUuid, m_isActive, true, !m_data->m_isConfigured, this); NetDetail *netDetail = new NetDetail(m_wlanDevice, m_data->m_NetSsid, m_data->m_connectUuid, m_isActive, true, !m_data->m_isConfigured, this);
connect(netDetail, &NetDetail::detailPageClose, this, &WlanListItem::onDetailShow);
netDetail->show(); netDetail->show();
emit this->detailShow(true);
} }
else{ else{
qDebug() << "On wlan info button clicked! But there is no wlan connect " ; qDebug() << "On wlan info button clicked! But there is no wlan connect " ;

View File

@ -30,6 +30,7 @@ public:
void setWlanSignal(const int &signal); void setWlanSignal(const int &signal);
void setWlanState(const int &state); void setWlanState(const int &state);
void setExpanded(const bool &expanded); void setExpanded(const bool &expanded);
void setWlanItemPwdVisible(const bool &expanded);
QString getSsid(); QString getSsid();
KyWirelessNetItem *m_data = nullptr; KyWirelessNetItem *m_data = nullptr;
protected: protected:

View File

@ -151,6 +151,7 @@ void MainWindow::initTrayIcon()
m_trayIconMenu->addAction(m_showSettingsAction); m_trayIconMenu->addAction(m_showSettingsAction);
m_trayIcon->setContextMenu(m_trayIconMenu); m_trayIcon->setContextMenu(m_trayIconMenu);
m_trayIcon->setIcon(QIcon::fromTheme("network-wired-signal-excellent-symbolic")); m_trayIcon->setIcon(QIcon::fromTheme("network-wired-signal-excellent-symbolic"));
onRefreshTrayIcon();
connect(m_trayIcon, &QSystemTrayIcon::activated, this, &MainWindow::onTrayIconActivated); connect(m_trayIcon, &QSystemTrayIcon::activated, this, &MainWindow::onTrayIconActivated);
// connect(m_showMainwindowAction, &QAction::triggered, this, &MainWindow::onShowMainwindowActionTriggled); // connect(m_showMainwindowAction, &QAction::triggered, this, &MainWindow::onShowMainwindowActionTriggled);

View File

@ -117,6 +117,12 @@ void NetDetail::paintEvent(QPaintEvent *event)
return QDialog::paintEvent(event); return QDialog::paintEvent(event);
} }
void NetDetail::closeEvent(QCloseEvent *event)
{
emit this->detailPageClose(false);
return QDialog::closeEvent(event);
}
void NetDetail::centerToScreen() void NetDetail::centerToScreen()
{ {
QDesktopWidget* m = QApplication::desktop(); QDesktopWidget* m = QApplication::desktop();

View File

@ -19,6 +19,7 @@
#include <QDBusObjectPath> #include <QDBusObjectPath>
#include <QDBusInterface> #include <QDBusInterface>
#include <QDBusReply> #include <QDBusReply>
#include <QCloseEvent>
#include "detailpage.h" #include "detailpage.h"
#include "ipv4page.h" #include "ipv4page.h"
@ -37,6 +38,7 @@ public:
~NetDetail(); ~NetDetail();
protected: protected:
void paintEvent(QPaintEvent *event); void paintEvent(QPaintEvent *event);
void closeEvent(QCloseEvent *event);
private: private:
void initUI(); void initUI();
@ -127,6 +129,9 @@ private:
private slots: private slots:
void on_btnConfirm_clicked(); void on_btnConfirm_clicked();
void on_btnForget_clicked(); void on_btnForget_clicked();
signals:
void detailPageClose(bool on);
void onPaletteChanged(); void onPaletteChanged();
}; };
#endif // NETDETAIL_H #endif // NETDETAIL_H

View File

@ -766,8 +766,6 @@ void LanPage::updateConnectionArea(QString uuid)
qDebug()<<"[LanPage] update connection item"<<p_newItem->m_connectName; qDebug()<<"[LanPage] update connection item"<<p_newItem->m_connectName;
QListWidgetItem *p_listWidgetItem = addNewItem(p_newItem, m_inactivatedLanListWidget); QListWidgetItem *p_listWidgetItem = addNewItem(p_newItem, m_inactivatedLanListWidget);
m_deactiveMap.insert(p_newItem, p_listWidgetItem); m_deactiveMap.insert(p_newItem, p_listWidgetItem);
emit this->lanConnectChanged();
} else { } else {
delete p_newItem; delete p_newItem;
p_newItem = nullptr; p_newItem = nullptr;
@ -790,8 +788,10 @@ void LanPage::onUpdateLanlist(QString uuid,
if (state == NetworkManager::ActiveConnection::State::Activated) { if (state == NetworkManager::ActiveConnection::State::Activated) {
updateActivatedConnectionArea(uuid); updateActivatedConnectionArea(uuid);
m_isLanConnected = true;
} else if (state == NetworkManager::ActiveConnection::State::Deactivated) { } else if (state == NetworkManager::ActiveConnection::State::Deactivated) {
updateConnectionArea(uuid); updateConnectionArea(uuid);
m_isLanConnected = false;
} else if (state == NetworkManager::ActiveConnection::State::Activating } else if (state == NetworkManager::ActiveConnection::State::Activating
|| state == NetworkManager::ActiveConnection::State::Deactivating) { || state == NetworkManager::ActiveConnection::State::Deactivating) {
QString devName = m_activeResourse->getDeviceOfActivateConnect(uuid); QString devName = m_activeResourse->getDeviceOfActivateConnect(uuid);
@ -801,6 +801,8 @@ void LanPage::onUpdateLanlist(QString uuid,
} }
emit lanActiveConnectionStateChanged(devName, uuid, state); emit lanActiveConnectionStateChanged(devName, uuid, state);
} }
emit this->lanConnectChanged();
return; return;
} }
@ -1048,7 +1050,6 @@ void LanPage::activateWired(const QString& devName, const QString& connUuid)
{ {
qDebug() << "[LanPage] activateWired" << devName << connUuid; qDebug() << "[LanPage] activateWired" << devName << connUuid;
m_wiredConnectOperation->activateConnection(connUuid, devName); m_wiredConnectOperation->activateConnection(connUuid, devName);
emit this->lanConnectChanged();
} }
void LanPage::deactivateWired(const QString& devName, const QString& connUuid) void LanPage::deactivateWired(const QString& devName, const QString& connUuid)

View File

@ -277,11 +277,12 @@ void WlanPage::appendActiveWlan(const QString &uuid, int &height)
} }
KyWirelessNetItem *item_data = new KyWirelessNetItem(data); KyWirelessNetItem *item_data = new KyWirelessNetItem(data);
WlanListItem *wlanItemWidget = new WlanListItem(m_resource, item_data, m_defaultDevice); WlanListItem *wlanItemWidget = new WlanListItem(m_resource, item_data, m_defaultDevice);
connect(wlanItemWidget, &WlanListItem::itemHeightChanged, this, &WlanPage::onItemHeightChanged);
connect(wlanItemWidget, &WlanListItem::connectButtonClicked, this, &WlanPage::onConnectButtonClicked);
qDebug() << "Activated wlan: ssid = " << item_data->m_NetSsid; qDebug() << "Activated wlan: ssid = " << item_data->m_NetSsid;
QListWidgetItem *wlanItem = new QListWidgetItem(); QListWidgetItem *wlanItem = new QListWidgetItem();
wlanItem->setSizeHint(QSize(m_activatedNetListWidget->width(), wlanItemWidget->height())); wlanItem->setSizeHint(QSize(m_activatedNetListWidget->width(), wlanItemWidget->height()));
m_activatedNetListWidget->addItem(wlanItem); m_activatedNetListWidget->addItem(wlanItem);
emit this->wlanConnectChanged();
qDebug() << "[wlanpage]emit wlanConnectChanged()" << Q_FUNC_INFO << __LINE__ ; qDebug() << "[wlanpage]emit wlanConnectChanged()" << Q_FUNC_INFO << __LINE__ ;
m_activatedNetListWidget->setItemWidget(wlanItem, wlanItemWidget); m_activatedNetListWidget->setItemWidget(wlanItem, wlanItemWidget);
wlanItemWidget->setActive(true); wlanItemWidget->setActive(true);
@ -383,6 +384,10 @@ void WlanPage::onWlanRemoved(QString interface, QString ssid)
int height = m_itemsMap.value(ssid).second->height(); int height = m_itemsMap.value(ssid).second->height();
m_inactivatedNetListWidget->setFixedHeight(m_inactivatedNetListWidget->height() - height - NET_LIST_SPACING); m_inactivatedNetListWidget->setFixedHeight(m_inactivatedNetListWidget->height() - height - NET_LIST_SPACING);
m_inactivatedWlanListAreaCentralWidget->setFixedHeight(m_inactivatedNetListWidget->height() + m_hiddenWlanLabel->height()); m_inactivatedWlanListAreaCentralWidget->setFixedHeight(m_inactivatedNetListWidget->height() + m_hiddenWlanLabel->height());
QListWidgetItem * aItem = (m_itemsMap.value(ssid)).first;
delete aItem;
WlanListItem * awItem = (m_itemsMap.value(ssid)).second;
delete awItem;
} }
m_itemsMap.remove(ssid); m_itemsMap.remove(ssid);
} }
@ -493,9 +498,11 @@ void WlanPage::onActivatedWlanChanged(QString uuid, NetworkManager::ActiveConnec
if(NetworkManager::ActiveConnection::State::Activated == state){ if(NetworkManager::ActiveConnection::State::Activated == state){
m_wlanIsConnected = true; m_wlanIsConnected = true;
qDebug() << "[wlanpage] wlanIsConnected status : " << m_wlanIsConnected << Q_FUNC_INFO << __LINE__ ; qDebug() << "[wlanpage] wlanIsConnected status : " << m_wlanIsConnected << Q_FUNC_INFO << __LINE__ ;
emit this->wlanConnectChanged();
} else { } else {
m_wlanIsConnected = false; m_wlanIsConnected = false;
qDebug() << "[wlanpage] wlanIsConnected status : " << m_wlanIsConnected << Q_FUNC_INFO << __LINE__ ; qDebug() << "[wlanpage] wlanIsConnected status : " << m_wlanIsConnected << Q_FUNC_INFO << __LINE__ ;
emit this->wlanConnectChanged();
} }
//弹窗显示wifi连接状况 //弹窗显示wifi连接状况
@ -600,22 +607,32 @@ void WlanPage::onActivatedWlanChanged(QString uuid, NetworkManager::ActiveConnec
void WlanPage::onItemHeightChanged(const QString &ssid) void WlanPage::onItemHeightChanged(const QString &ssid)
{ {
qDebug() << "onItemHeightChanged" << __LINE__;
if (!m_itemsMap.contains(ssid)) { return; } if (!m_itemsMap.contains(ssid)) { return; }
//新的展开item
QListWidgetItem *item = (m_itemsMap.value(ssid)).first; QListWidgetItem *item = (m_itemsMap.value(ssid)).first;
WlanListItem * m_item = (m_itemsMap.value(ssid)).second;
if (m_expandedItem && m_expandedItem != item) { if (m_expandedItem && m_expandedItem != item) {
qDebug() << "onItemHeightChanged : the old fold and the new expanded" << m_expandedItem << item << __LINE__;
QSize size(m_inactivatedNetListWidget->itemWidget(m_expandedItem)->size().width(), NORMAL_HEIGHT); QSize size(m_inactivatedNetListWidget->itemWidget(m_expandedItem)->size().width(), NORMAL_HEIGHT);
//旧的收起 //旧的收起
m_expandedItem->setSizeHint(size); m_expandedItem->setSizeHint(size);
m_inactivatedNetListWidget->itemWidget(m_expandedItem)->setFixedHeight(NORMAL_HEIGHT); m_inactivatedNetListWidget->itemWidget(m_expandedItem)->setFixedHeight(NORMAL_HEIGHT);
m_wlanExpandedItem->setWlanItemPwdVisible(false);
//新的展开 //新的展开
m_expandedItem = item; m_expandedItem = item;
m_wlanExpandedItem = m_item;
item->setSizeHint(m_inactivatedNetListWidget->itemWidget(item)->size()); item->setSizeHint(m_inactivatedNetListWidget->itemWidget(item)->size());
m_item->setWlanItemPwdVisible(true);
} else if (!m_expandedItem) { } else if (!m_expandedItem) {
qDebug() << "onItemHeightChanged : only expanded the new one " << m_expandedItem << item << __LINE__;
m_expandedItem = item; m_expandedItem = item;
m_wlanExpandedItem = m_item;
m_inactivatedNetListWidget->setFixedHeight(m_inactivatedNetListWidget->height() + m_inactivatedNetListWidget->itemWidget(item)->height() - item->sizeHint().height()); m_inactivatedNetListWidget->setFixedHeight(m_inactivatedNetListWidget->height() + m_inactivatedNetListWidget->itemWidget(item)->height() - item->sizeHint().height());
m_inactivatedWlanListAreaCentralWidget->setFixedHeight(m_inactivatedNetListWidget->height() + m_hiddenWlanLabel->height()); m_inactivatedWlanListAreaCentralWidget->setFixedHeight(m_inactivatedNetListWidget->height() + m_hiddenWlanLabel->height());
item->setSizeHint(m_inactivatedNetListWidget->itemWidget(item)->size()); item->setSizeHint(m_inactivatedNetListWidget->itemWidget(item)->size());
m_item->setWlanItemPwdVisible(true);
} }
} }

View File

@ -87,6 +87,7 @@ private:
QMap<QString, QPair<QListWidgetItem*, WlanListItem*>> m_itemsMap; QMap<QString, QPair<QListWidgetItem*, WlanListItem*>> m_itemsMap;
QListWidgetItem *m_expandedItem = nullptr; QListWidgetItem *m_expandedItem = nullptr;
WlanListItem *m_wlanExpandedItem = nullptr;
QFrame * m_inactivatedWlanListAreaCentralWidget = nullptr; QFrame * m_inactivatedWlanListAreaCentralWidget = nullptr;
QVBoxLayout * m_inactivatedWlanListAreaLayout = nullptr; QVBoxLayout * m_inactivatedWlanListAreaLayout = nullptr;
QFrame * m_hiddenWlanWidget = nullptr; QFrame * m_hiddenWlanWidget = nullptr;