Merge branch '1029' into 'dbus-interface'

bug#87649 && 毛玻璃效果

See merge request kylin-desktop/kylin-nm!378
This commit is contained in:
ren peijia 2021-11-05 09:41:57 +00:00
commit b3e6aa8777
13 changed files with 67 additions and 19 deletions

View File

@ -25,8 +25,6 @@ LanListItem::LanListItem(const KyConnectItem *lanConnectItem,
m_itemFrame->installEventFilter(this);
connect(this->m_infoButton, &InfoButton::clicked, this, &LanListItem::onInfoButtonClicked);
m_menu = new QMenu(this);//右键菜单
connect(m_menu, &QMenu::triggered, this, &LanListItem::onMenuTriggered);
}
@ -49,10 +47,8 @@ LanListItem::~LanListItem()
void LanListItem::setIcon(bool isOn)
{
if (isOn) {
// m_netButton->setButtonIcon(QIcon::fromTheme("network-wired-connected-symbolic"));
m_netButton->setActive(true); //设置图标显示不同颜色
} else {
// m_netButton->setButtonIcon(QIcon::fromTheme("network-wired-connected-symbolic"));
m_netButton->setActive(false);
}
}

View File

@ -5,7 +5,6 @@
#include <QDBusInterface>
#include <QEvent>
#include <QMenu>
#include <QAction>
class LanListItem : public ListItem
@ -46,7 +45,6 @@ private:
KyNetworkDeviceResourse *m_deviceResource = nullptr;
QString m_deviceName = "";
QMenu *m_menu = nullptr;
};
#endif // LANLISTITEM_H

View File

@ -15,6 +15,7 @@ ListItem::ListItem(QWidget *parent) : QFrame(parent)
{
m_connectState = UnknownState;
isDetailShow = false;
initUI();
initConnection();
connect(qApp, &QApplication::paletteChanged, this, &ListItem::onPaletteChanged);
@ -125,6 +126,11 @@ void ListItem::paintEvent(QPaintEvent *event)
void ListItem::initUI()
{
m_menu = new QMenu(this);//右键菜单
m_menu->setStyleSheet("QMenu::item{border:3px; border-radius:3px}");
m_menu->setStyleSheet("QMenu{border-radius:3px; margin:3px 3px 3px 3px}");
connect(m_menu, &QMenu::triggered, this, &ListItem::onMenuTriggered);
m_mainLayout = new QVBoxLayout(this);
m_mainLayout->setContentsMargins(MAIN_LAYOUT_MARGINS);
m_mainLayout->setSpacing(MAIN_LAYOUT_SPACING);

View File

@ -5,6 +5,7 @@
#include <QHBoxLayout>
#include <QDebug>
#include <QMouseEvent>
#include <QMenu>
#include "radioitembutton.h"
#include "infobutton.h"
#include "netdetails/netdetail.h"
@ -46,6 +47,7 @@ protected:
bool m_isActive = false;
ConnectState m_connectState;
QMenu *m_menu = nullptr;
public:
QVBoxLayout * m_mainLayout = nullptr;
QHBoxLayout * m_hItemLayout = nullptr;
@ -58,6 +60,7 @@ public slots:
virtual void onNetButtonClicked() = 0;
void onPaletteChanged();
void onDetailShow(bool isShow);
virtual void onMenuTriggered(QAction *action)=0;
signals:
void detailShow(bool isShow);

View File

@ -17,8 +17,6 @@ WlanListItem::WlanListItem(KyWirelessNetItem &wirelessNetItem, QString device, Q
setExpanded(false);
connect(this->m_infoButton, &InfoButton::clicked, this, &WlanListItem::onInfoButtonClicked);
m_menu = new QMenu(this);//右键菜单
connect(m_menu, &QMenu::triggered, this, &WlanListItem::onMenuTriggered);
m_wirelessConnectOperation = new KyWirelessConnectOperation(this);
@ -515,3 +513,12 @@ void WlanListItem::onMenuTriggered(QAction *action)
return;
}
void WlanListItem::forgetPwd()
{
if (!this->isConfigured()) {
m_pwdLineEdit->setText("");
return;
}
}

View File

@ -7,7 +7,6 @@
#include "kywirelessconnectoperation.h"
#include <QCheckBox>
#include "kylinactiveconnectresource.h"
#include <QMenu>
#include <QAction>
#include <networkmanagerqt/wirelesssecuritysetting.h>
@ -43,6 +42,8 @@ public:
void updateWirelessNetSecurity(QString ssid, QString securityType);
void updateWirelessNetItem(KyWirelessNetItem &wirelessNetItem);
void forgetPwd();
protected:
void resizeEvent(QResizeEvent *event);
void onRightButtonClicked();
@ -79,8 +80,6 @@ private:
QCheckBox *m_autoConnectCheckBox = nullptr;
QLabel *m_autoConnectLabel = nullptr;
QMenu *m_menu = nullptr;
bool m_focusIsOut = true;
bool m_mouseIsOut = true;

View File

@ -19,3 +19,7 @@ void WlanMoreItem::onNetButtonClicked() {
void WlanMoreItem::onRightButtonClicked() {
// Todo
}
void WlanMoreItem::onMenuTriggered(QAction *action) {
}

View File

@ -18,6 +18,7 @@ public:
~WlanMoreItem();
void onNetButtonClicked();
void onMenuTriggered(QAction *action);
signals:
void hiddenWlanClicked();
};

View File

@ -119,11 +119,14 @@ void MainWindow::initWindowProperties()
this->setWindowIcon(QIcon::fromTheme("kylin-network", QIcon(":/res/x/setup.png")));
this->setFixedSize(MAINWINDOW_WIDTH, MAINWINDOW_HEIGHT);
// //绘制毛玻璃特效
// this->setAttribute(Qt::WA_TranslucentBackground, true);
// QPainterPath path;
// auto rect = this->rect();
// path.addRoundedRect(rect, 6, 6);
// KWindowEffects::enableBlurBehind(this->winId(), true, QRegion(path.toFillPolygon().toPolygon()));
// this->setStyleSheet("background:transparent"); //透明
// this->setAttribute(Qt::WA_TranslucentBackground, true); //半透明
this->setWindowOpacity(0.8);
QPainterPath path;
auto rect = this->rect();
path.addRoundedRect(rect, 6, 6);
KWindowEffects::enableBlurBehind(this->winId(), true, QRegion(path.toFillPolygon().toPolygon())); //背景模糊
}
/**
@ -151,6 +154,7 @@ void MainWindow::initUI()
m_tabBarLayout->addWidget(m_lanLabel);
m_tabBarLayout->addWidget(m_wlanLabel);
m_centralWidget->tabBar()->setLayout(m_tabBarLayout);
connect(m_centralWidget, &QTabWidget::currentChanged, m_wlanWidget, &WlanPage::onWlanPageVisibleChanged);
}
/**

View File

@ -10,6 +10,7 @@
#define ICON_REFRESH_INTERVAL (5*1000)
#define EMPTY_SSID "emptyssid"
#define LOG_FLAG "[WlanPage]"
#define LAN_PAGE_INDEX 0
WlanPage::WlanPage(QWidget *parent) : TabPage(parent)
{
@ -59,6 +60,7 @@ bool WlanPage::eventFilter(QObject *w, QEvent *e)
showControlCenter();
}
}
return QWidget::eventFilter(w,e);
}
@ -544,6 +546,7 @@ void WlanPage::onConnectionAdd(QString deviceName, QString ssid)
return;
}
void WlanPage::onConnectionRemove(QString deviceName, QString ssid)
{
qDebug() << LOG_FLAG << "one connection is removed, it's ssid " << ssid << "device name"<< deviceName;
@ -1254,11 +1257,35 @@ void WlanPage::onMainWindowVisibleChanged(const bool &visible)
//界面关闭的时候停止wifi扫描和刷新
m_scanTimer->stop();
// m_refreshIconTimer->stop();
qDebug() << "wlanpage not visible";
showNonePwd();
}
return;
}
void WlanPage::onWlanPageVisibleChanged(int index)
{
if (index == LAN_PAGE_INDEX) {
qDebug() << "wlanpage not visible";
showNonePwd();
}
}
void WlanPage::showNonePwd()
{
QMap<QString, QListWidgetItem*>::iterator iter;
for(iter=m_wirelessNetItemMap.begin();iter!= m_wirelessNetItemMap.end();iter++)
{
if(iter.value() != nullptr) {
QListWidgetItem *p_listWidgetItem = iter.value();
WlanListItem *p_wlanItem = (WlanListItem*)m_inactivatedNetListWidget->itemWidget(p_listWidgetItem);
p_wlanItem->forgetPwd();
}
}
return;
}
void WlanPage::showDetailPage(QString devName, QString ssid)
{
KyWirelessNetItem wirelessNetItem;

View File

@ -68,6 +68,7 @@ public slots:
void onMainWindowVisibleChanged(const bool &visible);
void onSecurityTypeChange(QString devName, QString ssid, QString secuType);
void requestScan();
void onWlanPageVisibleChanged(int index);
private slots:
void onWlanAdded(QString interface, KyWirelessNetItem &item);
@ -108,6 +109,8 @@ private:
void initWlanArea();
void addWlanMoreItem();
void showNonePwd();
QListWidgetItem *addEmptyItem(QListWidget *wirelessListWidget);
QListWidgetItem *addNewItem(KyWirelessNetItem &wirelessNetItem,
QListWidget *wirelessListWidget);

Binary file not shown.

View File

@ -550,7 +550,7 @@
<message>
<location filename="../src/frontend/list-items/listitem.cpp" line="63"/>
<source>Kylin NM</source>
<translation></translation>
<translation></translation>
</message>
<message>
<location filename="../src/frontend/list-items/listitem.cpp" line="66"/>
@ -595,7 +595,7 @@
<message>
<location filename="../src/frontend/netdetails/netdetail.cpp" line="30"/>
<source>Kylin NM</source>
<translation></translation>
<translation></translation>
</message>
<message>
<location filename="../src/frontend/netdetails/netdetail.cpp" line="33"/>
@ -891,7 +891,7 @@
<message>
<location filename="../src/frontend/tab-pages/tabpage.cpp" line="127"/>
<source>Kylin NM</source>
<translation></translation>
<translation></translation>
</message>
<message>
<location filename="../src/frontend/tab-pages/tabpage.cpp" line="130"/>