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
get_secrets_dialog_response_cb (GtkDialog *foo,
gint response,
@ -230,24 +256,6 @@ l_out:
//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 *
applet_secrets_request_new (size_t totsize,
NMConnection *connection,
@ -277,15 +285,6 @@ applet_secrets_request_new (size_t totsize,
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
get_existing_secrets_cb (NMSecretAgentOld *agent,
NMConnection *connection,

View File

@ -82,11 +82,17 @@ void LanListItem::onRightButtonClicked()
void LanListItem::onInfoButtonClicked()
{
if(isDetailShow){
qDebug() << "has show the detail page,and do not show again" << Q_FUNC_INFO << __LINE__;
return;
}
if(m_data){
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__;
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();
emit this->detailShow(true);
}
else{
qDebug() << "On lan info button clicked! But there is no wlan connect " ;

View File

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

View File

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

View File

@ -58,8 +58,8 @@ void WlanListItem::setExpanded(const bool &expanded)
}
this->setFixedHeight(expanded ? EXPANDED_HEIGHT : NORMAL_HEIGHT);
m_pwdFrame->setVisible(expanded);
m_autoConnectFrame->setVisible(expanded);
// m_pwdFrame->setVisible(false);
// m_autoConnectFrame->setVisible(false);
emit this->itemHeightChanged(m_data->m_NetSsid);
if (!expanded) {
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()
{
if (!m_data) {
@ -259,11 +265,17 @@ void WlanListItem::refreshIcon()
void WlanListItem::onInfoButtonClicked()
{
//ZJP_TODO 呼出无线详情页
if(isDetailShow){
qDebug() << "has show the detail page,and do not show again" << Q_FUNC_INFO << __LINE__;
return;
}
if(m_data){
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__;
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();
emit this->detailShow(true);
}
else{
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 setWlanState(const int &state);
void setExpanded(const bool &expanded);
void setWlanItemPwdVisible(const bool &expanded);
QString getSsid();
KyWirelessNetItem *m_data = nullptr;
protected:

View File

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

View File

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

View File

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

View File

@ -766,8 +766,6 @@ void LanPage::updateConnectionArea(QString uuid)
qDebug()<<"[LanPage] update connection item"<<p_newItem->m_connectName;
QListWidgetItem *p_listWidgetItem = addNewItem(p_newItem, m_inactivatedLanListWidget);
m_deactiveMap.insert(p_newItem, p_listWidgetItem);
emit this->lanConnectChanged();
} else {
delete p_newItem;
p_newItem = nullptr;
@ -790,8 +788,10 @@ void LanPage::onUpdateLanlist(QString uuid,
if (state == NetworkManager::ActiveConnection::State::Activated) {
updateActivatedConnectionArea(uuid);
m_isLanConnected = true;
} else if (state == NetworkManager::ActiveConnection::State::Deactivated) {
updateConnectionArea(uuid);
m_isLanConnected = false;
} else if (state == NetworkManager::ActiveConnection::State::Activating
|| state == NetworkManager::ActiveConnection::State::Deactivating) {
QString devName = m_activeResourse->getDeviceOfActivateConnect(uuid);
@ -801,6 +801,8 @@ void LanPage::onUpdateLanlist(QString uuid,
}
emit lanActiveConnectionStateChanged(devName, uuid, state);
}
emit this->lanConnectChanged();
return;
}
@ -1048,7 +1050,6 @@ void LanPage::activateWired(const QString& devName, const QString& connUuid)
{
qDebug() << "[LanPage] activateWired" << devName << connUuid;
m_wiredConnectOperation->activateConnection(connUuid, devName);
emit this->lanConnectChanged();
}
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);
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;
QListWidgetItem *wlanItem = new QListWidgetItem();
wlanItem->setSizeHint(QSize(m_activatedNetListWidget->width(), wlanItemWidget->height()));
m_activatedNetListWidget->addItem(wlanItem);
emit this->wlanConnectChanged();
qDebug() << "[wlanpage]emit wlanConnectChanged()" << Q_FUNC_INFO << __LINE__ ;
m_activatedNetListWidget->setItemWidget(wlanItem, wlanItemWidget);
wlanItemWidget->setActive(true);
@ -383,6 +384,10 @@ void WlanPage::onWlanRemoved(QString interface, QString ssid)
int height = m_itemsMap.value(ssid).second->height();
m_inactivatedNetListWidget->setFixedHeight(m_inactivatedNetListWidget->height() - height - NET_LIST_SPACING);
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);
}
@ -493,9 +498,11 @@ void WlanPage::onActivatedWlanChanged(QString uuid, NetworkManager::ActiveConnec
if(NetworkManager::ActiveConnection::State::Activated == state){
m_wlanIsConnected = true;
qDebug() << "[wlanpage] wlanIsConnected status : " << m_wlanIsConnected << Q_FUNC_INFO << __LINE__ ;
emit this->wlanConnectChanged();
} else {
m_wlanIsConnected = false;
qDebug() << "[wlanpage] wlanIsConnected status : " << m_wlanIsConnected << Q_FUNC_INFO << __LINE__ ;
emit this->wlanConnectChanged();
}
//弹窗显示wifi连接状况
@ -600,22 +607,32 @@ void WlanPage::onActivatedWlanChanged(QString uuid, NetworkManager::ActiveConnec
void WlanPage::onItemHeightChanged(const QString &ssid)
{
qDebug() << "onItemHeightChanged" << __LINE__;
if (!m_itemsMap.contains(ssid)) { return; }
//新的展开item
QListWidgetItem *item = (m_itemsMap.value(ssid)).first;
WlanListItem * m_item = (m_itemsMap.value(ssid)).second;
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);
//旧的收起
m_expandedItem->setSizeHint(size);
m_inactivatedNetListWidget->itemWidget(m_expandedItem)->setFixedHeight(NORMAL_HEIGHT);
m_wlanExpandedItem->setWlanItemPwdVisible(false);
//新的展开
m_expandedItem = item;
m_wlanExpandedItem = m_item;
item->setSizeHint(m_inactivatedNetListWidget->itemWidget(item)->size());
m_item->setWlanItemPwdVisible(true);
} else if (!m_expandedItem) {
qDebug() << "onItemHeightChanged : only expanded the new one " << m_expandedItem << item << __LINE__;
m_expandedItem = item;
m_wlanExpandedItem = m_item;
m_inactivatedNetListWidget->setFixedHeight(m_inactivatedNetListWidget->height() + m_inactivatedNetListWidget->itemWidget(item)->height() - item->sizeHint().height());
m_inactivatedWlanListAreaCentralWidget->setFixedHeight(m_inactivatedNetListWidget->height() + m_hiddenWlanLabel->height());
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;
QListWidgetItem *m_expandedItem = nullptr;
WlanListItem *m_wlanExpandedItem = nullptr;
QFrame * m_inactivatedWlanListAreaCentralWidget = nullptr;
QVBoxLayout * m_inactivatedWlanListAreaLayout = nullptr;
QFrame * m_hiddenWlanWidget = nullptr;