Merge branch '1027-cc' into 'dbus-interface'
1027 cc See merge request kylin-desktop/kylin-nm!366
This commit is contained in:
commit
dd40b9b94e
|
@ -18,6 +18,7 @@ Build-Depends: debhelper (>=9),
|
|||
libkf5networkmanagerqt-dev (>= 5.36.0),
|
||||
libnm-dev,
|
||||
libcap-dev,
|
||||
libukcc-dev,
|
||||
Standards-Version: 4.5.0
|
||||
Rules-Requires-Root: no
|
||||
Homepage: https://github.com/ukui/kylin-nm
|
||||
|
|
|
@ -0,0 +1,105 @@
|
|||
#include "infobutton.h"
|
||||
#include <QEvent>
|
||||
#include <QPainter>
|
||||
#include <QApplication>
|
||||
#include <QDebug>
|
||||
|
||||
#define BUTTON_SIZE 36,36
|
||||
#define ICON_SIZE 16,16
|
||||
#define BACKGROUND_COLOR QColor(0,0,0,0)
|
||||
#define FOREGROUND_COLOR_NORMAL qApp->palette().text().color()
|
||||
#define FOREGROUND_COLOR_HOVER QColor(55,144,250,255)
|
||||
#define FOREGROUND_COLOR_PRESS QColor(36,109,212,255)
|
||||
#define OUTER_PATH 8,8,16,16
|
||||
#define INNER_PATH 9,9,14,14
|
||||
#define TEXT_POS 14,5,16,16,0
|
||||
|
||||
#define BUTTON_SIZE 36,36
|
||||
|
||||
#define THEME_SCHAME "org.ukui.style"
|
||||
#define COLOR_THEME "styleName"
|
||||
|
||||
InfoButton::InfoButton(QWidget *parent) : QPushButton(parent)
|
||||
{
|
||||
this->setFixedSize(BUTTON_SIZE);
|
||||
initUI();
|
||||
const QByteArray style_id(THEME_SCHAME);
|
||||
if (QGSettings::isSchemaInstalled(style_id)) {
|
||||
m_styleGsettings = new QGSettings(style_id);
|
||||
connect(m_styleGsettings, &QGSettings::changed, this, &InfoButton::onGSettingChaned);
|
||||
} else {
|
||||
qDebug() << "Gsettings interface \"org.ukui.style\" is not exist!";
|
||||
}
|
||||
}
|
||||
|
||||
void InfoButton::initUI()
|
||||
{
|
||||
this->setFixedSize(BUTTON_SIZE);
|
||||
m_backgroundColor = BACKGROUND_COLOR;
|
||||
m_foregroundColor = FOREGROUND_COLOR_NORMAL;
|
||||
}
|
||||
|
||||
void InfoButton::onGSettingChaned(const QString &key)
|
||||
{
|
||||
if (key == COLOR_THEME) {
|
||||
m_foregroundColor = FOREGROUND_COLOR_NORMAL;
|
||||
this->repaint();
|
||||
}
|
||||
}
|
||||
|
||||
void InfoButton::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
QPalette pal = this->palette();
|
||||
pal.setColor(QPalette::Base, m_backgroundColor);
|
||||
pal.setColor(QPalette::Text, m_foregroundColor);
|
||||
|
||||
QPainterPath cPath;
|
||||
cPath.addRect(0, 0, ICON_SIZE);
|
||||
cPath.addEllipse(0, 0, ICON_SIZE);
|
||||
|
||||
QPainterPath outerPath;
|
||||
outerPath.addEllipse(OUTER_PATH);
|
||||
|
||||
QPainterPath innerPath;
|
||||
innerPath.addEllipse(INNER_PATH);
|
||||
outerPath -= innerPath;
|
||||
|
||||
QPainter painter(this);
|
||||
painter.setRenderHint(QPainter:: Antialiasing, true); //设置渲染,启动反锯齿
|
||||
painter.setPen(Qt::NoPen);
|
||||
|
||||
painter.setBrush(pal.color(QPalette::Base));
|
||||
painter.drawPath(cPath);
|
||||
|
||||
painter.fillPath(outerPath, pal.color(QPalette::Text));
|
||||
painter.setPen(m_foregroundColor);
|
||||
QFont font("Noto Sans CJK SC", 11, QFont::Normal, false);
|
||||
painter.setFont(font);
|
||||
painter.drawText(TEXT_POS, "i");
|
||||
}
|
||||
|
||||
void InfoButton::enterEvent(QEvent *event)
|
||||
{
|
||||
m_foregroundColor = FOREGROUND_COLOR_HOVER;
|
||||
this->repaint();
|
||||
}
|
||||
|
||||
void InfoButton::leaveEvent(QEvent *event)
|
||||
{
|
||||
m_foregroundColor = FOREGROUND_COLOR_NORMAL;
|
||||
this->repaint();
|
||||
}
|
||||
|
||||
void InfoButton::mousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
m_foregroundColor = FOREGROUND_COLOR_PRESS;
|
||||
this->repaint();
|
||||
return QPushButton::mousePressEvent(event);
|
||||
}
|
||||
|
||||
void InfoButton::mouseReleaseEvent(QMouseEvent *event)
|
||||
{
|
||||
m_foregroundColor = FOREGROUND_COLOR_HOVER;
|
||||
this->repaint();
|
||||
return QPushButton::mouseReleaseEvent(event);
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
#ifndef INFOBUTTON_H
|
||||
#define INFOBUTTON_H
|
||||
#include <QPushButton>
|
||||
#include <QIcon>
|
||||
#include <QGSettings>
|
||||
|
||||
class InfoButton : public QPushButton
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit InfoButton(QWidget * parent = nullptr);
|
||||
~InfoButton() = default;
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *event);
|
||||
void enterEvent(QEvent *event);
|
||||
void leaveEvent(QEvent *event);
|
||||
void mousePressEvent(QMouseEvent *event);
|
||||
void mouseReleaseEvent(QMouseEvent *event);
|
||||
|
||||
private:
|
||||
void initUI();
|
||||
|
||||
private:
|
||||
QColor m_backgroundColor;
|
||||
QColor m_foregroundColor;
|
||||
|
||||
//监听主题的Gsettings
|
||||
QGSettings * m_styleGsettings = nullptr;
|
||||
|
||||
private slots:
|
||||
void onGSettingChaned(const QString &key);
|
||||
};
|
||||
|
||||
#endif // INFOBUTTON_H
|
|
@ -0,0 +1,9 @@
|
|||
#LIBINTERFACE_NAME = $$qtLibraryTarget(infobutton)
|
||||
|
||||
SOURCES += \
|
||||
$$PWD/InfoButton/infobutton.cpp \
|
||||
|
||||
HEADERS += \
|
||||
$$PWD/InfoButton/infobutton.h \
|
||||
|
||||
|
|
@ -22,9 +22,9 @@ void DrownLabel::setDropDownStatus(bool status)
|
|||
void DrownLabel::loadPixmap(bool isChecked)
|
||||
{
|
||||
if (isChecked) {
|
||||
setPixmap(QIcon::fromTheme("ukui-up-symbolic", QIcon(":/img/plugins/netconnect/up.svg")).pixmap(ICONSIZE));
|
||||
setPixmap(QIcon::fromTheme("ukui-up-symbolic").pixmap(ICONSIZE));
|
||||
} else {
|
||||
setPixmap(QIcon::fromTheme("ukui-down-symbolic", QIcon(":/img/plugins/netconnect/down.svg")).pixmap(ICONSIZE));
|
||||
setPixmap(QIcon::fromTheme("ukui-down-symbolic").pixmap(ICONSIZE));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#include <QDebug>
|
||||
#include <QImage>
|
||||
#include "fixlabel.h"
|
||||
#include "infobutton.h"
|
||||
#include "../component/InfoButton/infobutton.h"
|
||||
|
||||
class LanItem : public QPushButton
|
||||
{
|
||||
|
|
|
@ -170,7 +170,6 @@ void NetConnect::initComponent() {
|
|||
wiredSwitch->blockSignals(true);
|
||||
wiredSwitch->setChecked(true);
|
||||
wiredSwitch->blockSignals(false);
|
||||
initNet();
|
||||
qDebug()<<"[Netconnect] org.ukui.kylin-nm.switch is not installed!";
|
||||
}
|
||||
|
||||
|
@ -182,7 +181,7 @@ void NetConnect::initComponent() {
|
|||
}
|
||||
initNet();
|
||||
|
||||
if (deviceStatusMap.isEmpty() || !m_interface->isValid()) {
|
||||
if (!wiredSwitch->isChecked() || deviceStatusMap.isEmpty() || !m_interface->isValid()) {
|
||||
hideLayout(ui->availableLayout);
|
||||
}
|
||||
|
||||
|
@ -313,9 +312,7 @@ void NetConnect::initNet()
|
|||
}
|
||||
//再填充每个设备的列表
|
||||
for (int i = 0; i < deviceList.size(); ++i) {
|
||||
if (deviceStatusMap[deviceList.at(i)]) {
|
||||
initNetListFromDevice(deviceList.at(i));
|
||||
}
|
||||
initNetListFromDevice(deviceList.at(i));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -343,10 +340,6 @@ void NetConnect::deActiveConnect(QString ssid, QString deviceName, int type) {
|
|||
void NetConnect::initNetListFromDevice(QString deviceName)
|
||||
{
|
||||
qDebug() << "[NetConnect]initNetListFromDevice " << deviceName;
|
||||
if (!wiredSwitch->isChecked()) {
|
||||
qDebug() << "[NetConnect]initNetListFromDevice " << deviceName << " switch off";
|
||||
return;
|
||||
}
|
||||
if (!deviceFrameMap.contains(deviceName)) {
|
||||
qDebug() << "[NetConnect]initNetListFromDevice " << deviceName << " not exist";
|
||||
return;
|
||||
|
@ -468,8 +461,11 @@ void NetConnect::addDeviceFrame(QString devName)
|
|||
itemFrame->deviceFrame->deviceSwitch->setChecked(enable);
|
||||
if (enable) {
|
||||
itemFrame->lanItemFrame->show();
|
||||
itemFrame->deviceFrame->dropDownLabel->show();
|
||||
} else {
|
||||
itemFrame->lanItemFrame->hide();
|
||||
itemFrame->deviceFrame->dropDownLabel->hide();
|
||||
itemFrame->deviceFrame->dropDownLabel->setDropDownStatus(false);
|
||||
}
|
||||
deviceFrameMap.insert(devName, itemFrame);
|
||||
qDebug() << "[NetConnect]deviceFrameMap insert" << devName;
|
||||
|
@ -481,20 +477,13 @@ void NetConnect::addDeviceFrame(QString devName)
|
|||
if (checked) {
|
||||
qDebug() << "[NetConnect]set " << devName << "status" << true;
|
||||
itemFrame->lanItemFrame->show();
|
||||
initNetListFromDevice(devName);
|
||||
itemFrame->deviceFrame->dropDownLabel->show();
|
||||
itemFrame->deviceFrame->dropDownLabel->setDropDownStatus(true);
|
||||
deviceStatusMap[devName] = true;
|
||||
} else {
|
||||
qDebug() << "[NetConnect]set " << devName << "status" << false;
|
||||
if (itemFrame->lanItemFrame->layout() != NULL) {
|
||||
QLayoutItem* item;
|
||||
while ((item = itemFrame->lanItemFrame->layout()->takeAt(0)) != NULL) {
|
||||
delete item->widget();
|
||||
delete item;
|
||||
item = nullptr;
|
||||
}
|
||||
itemFrame->itemMap.clear();
|
||||
}
|
||||
|
||||
itemFrame->lanItemFrame->hide();
|
||||
itemFrame->deviceFrame->dropDownLabel->hide();
|
||||
deviceStatusMap[devName] = false;
|
||||
}
|
||||
});
|
||||
|
@ -514,6 +503,15 @@ void NetConnect::removeDeviceFrame(QString devName)
|
|||
qDebug() << "[NetConnect]removeDeviceFrame " << devName;
|
||||
if (deviceFrameMap.contains(devName)) {
|
||||
ItemFrame *item = deviceFrameMap[devName];
|
||||
if (item->lanItemFrame->layout() != NULL) {
|
||||
QLayoutItem* layoutItem;
|
||||
while ((layoutItem = item->lanItemFrame->layout()->takeAt(0)) != NULL) {
|
||||
delete layoutItem->widget();
|
||||
delete layoutItem;
|
||||
layoutItem = nullptr;
|
||||
}
|
||||
item->itemMap.clear();
|
||||
}
|
||||
delete item;
|
||||
item = nullptr;
|
||||
deviceFrameMap.remove(devName);
|
||||
|
@ -560,9 +558,7 @@ void NetConnect::onDeviceStatusChanged()
|
|||
for (int i = 0; i < addList.size(); ++i) {
|
||||
qDebug() << "add a device " << addList.at(i) << "status" << map[addList.at(i)];
|
||||
addDeviceFrame(addList.at(i));
|
||||
if (map[addList.at(i)]) {
|
||||
initNetListFromDevice(addList.at(i));
|
||||
}
|
||||
initNetListFromDevice(addList.at(i));
|
||||
}
|
||||
deviceStatusMap = map;
|
||||
if (deviceStatusMap.isEmpty()) {
|
||||
|
@ -606,9 +602,6 @@ void NetConnect::onDeviceNameChanged(QString oldName, QString newName, int type)
|
|||
void NetConnect::onLanAdd(QString deviceName, QStringList lanInfo)
|
||||
{
|
||||
qDebug()<<"[NetConnect]onLanAdd "<< deviceName << " " << lanInfo;
|
||||
if(!wiredSwitch->isChecked()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!deviceName.isEmpty() && !deviceStatusMap.contains(deviceName)) {
|
||||
return;
|
||||
|
@ -737,10 +730,6 @@ void NetConnect::removeOneLanFrame(ItemFrame *frame, QString deviceName, QString
|
|||
//activeconnect status change
|
||||
void NetConnect::onActiveConnectionChanged(QString deviceName, QString uuid, int status)
|
||||
{
|
||||
if (!wiredSwitch->isChecked()) {
|
||||
qDebug() << "[NetConnect]onActiveConnectionChanged but wiredSwitch is off";
|
||||
return;
|
||||
}
|
||||
if (uuid.isEmpty()) {
|
||||
qDebug() << "[NetConnect]onActiveConnectionChanged but uuid is empty";
|
||||
return;
|
||||
|
@ -848,6 +837,10 @@ int NetConnect::getInsertPos(QString connName, QString deviceName)
|
|||
auto dbusArg = result.arguments().at(0).value<QDBusArgument>();
|
||||
QMap<QString, QVector<QStringList>> variantList;
|
||||
dbusArg >> variantList;
|
||||
if (!variantList.contains(deviceName)) {
|
||||
qDebug() << "[NetConnect] getInsertPos but " << deviceName << "not exist";
|
||||
return 0;
|
||||
}
|
||||
for (int i = 0; i < variantList[deviceName].size(); ++i ) {
|
||||
if (variantList[deviceName].at(i).at(0) == connName) {
|
||||
qDebug() << "pos in kylin-nm is " << i;
|
||||
|
|
|
@ -3,6 +3,7 @@ TEMPLATE = lib
|
|||
CONFIG += plugin
|
||||
|
||||
include(../component/switchbutton.pri)
|
||||
include(../component/infobutton.pri)
|
||||
|
||||
TARGET = $$qtLibraryTarget(netconnect)
|
||||
DESTDIR = ../..
|
||||
|
|
|
@ -26,12 +26,12 @@ void DrownLabel::loadPixmap(bool isChecked)
|
|||
if (QIcon::fromTheme("ukui-up-symbolic").isNull()) {
|
||||
qDebug() << "ukui-up-symbolic is missing";
|
||||
}
|
||||
setPixmap(QIcon::fromTheme("ukui-up-symbolic", QIcon(":/img/plugins/netconnect/up.svg")).pixmap(ICONSIZE));
|
||||
setPixmap(QIcon::fromTheme("ukui-up-symbolic").pixmap(ICONSIZE));
|
||||
} else {
|
||||
if (QIcon::fromTheme("ukui-down-symbolic").isNull()) {
|
||||
qDebug() << "ukui-down-symbolic is missing";
|
||||
}
|
||||
setPixmap(QIcon::fromTheme("ukui-down-symbolic", QIcon(":/img/plugins/netconnect/down.svg")).pixmap(ICONSIZE));
|
||||
setPixmap(QIcon::fromTheme("ukui-down-symbolic").pixmap(ICONSIZE));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -214,6 +214,7 @@ void WlanConnect::initComponent() {
|
|||
//网卡name处理
|
||||
connect(m_interface, SIGNAL(deviceNameChanged(QString, QString, int)), this, SLOT(onDeviceNameChanged(QString, QString, int)), Qt::QueuedConnection);
|
||||
|
||||
connect(m_interface, SIGNAL(timeToUpdate()), this, SLOT(updateList()), Qt::QueuedConnection);
|
||||
//高级设置
|
||||
connect(ui->detailBtn, &QPushButton::clicked, this, [=](bool checked) {
|
||||
Q_UNUSED(checked)
|
||||
|
@ -226,9 +227,9 @@ void WlanConnect::initComponent() {
|
|||
connect(m_scanTimer, &QTimer::timeout, this, &WlanConnect::reScan, Qt::QueuedConnection);
|
||||
reScan();
|
||||
|
||||
m_updateTimer = new QTimer(this);
|
||||
m_updateTimer->start(UPDATETIMER);
|
||||
connect(m_scanTimer, &QTimer::timeout, this, &WlanConnect::updateList, Qt::QueuedConnection);
|
||||
// m_updateTimer = new QTimer(this);
|
||||
// m_updateTimer->start(UPDATETIMER);
|
||||
|
||||
}
|
||||
|
||||
void WlanConnect::reScan()
|
||||
|
@ -241,7 +242,7 @@ void WlanConnect::reScan()
|
|||
}
|
||||
}
|
||||
|
||||
//定时5秒更新列表顺序
|
||||
//更新列表顺序
|
||||
void WlanConnect::updateList()
|
||||
{
|
||||
if (!wifiSwtch->isChecked()) {
|
||||
|
@ -300,6 +301,19 @@ void WlanConnect::resortWifiList(ItemFrame *frame, QVector<QStringList> list)
|
|||
}
|
||||
} else {
|
||||
qDebug() << " no active connection when resort";
|
||||
if (!frame->uuid.isEmpty()) {
|
||||
QMap<QString, WlanItem*>::iterator itemIter;
|
||||
for (itemIter = frame->itemMap.begin(); itemIter != frame->itemMap.end(); itemIter++) {
|
||||
if (itemIter.value()->uuid == frame->uuid ) {
|
||||
WlanItem * item= nullptr;
|
||||
item = itemIter.value();
|
||||
qDebug() << "a active connect missing when resort";
|
||||
itemIter.value()->uuid.clear();
|
||||
itemActiveConnectionStatusChanged(item, DEACTIVATED);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
frame->uuid.clear();
|
||||
}
|
||||
|
||||
|
@ -469,7 +483,7 @@ void WlanConnect::onActiveConnectionChanged(QString deviceName, QString ssid, QS
|
|||
}
|
||||
WlanItem * item= nullptr;
|
||||
//device ssid 有可能均为空
|
||||
if (deviceName.isEmpty() && ssid.isEmpty()) {
|
||||
if (deviceName.isEmpty() || ssid.isEmpty()) {
|
||||
if (status == ACTIVATING || status == ACTIVATED) {
|
||||
return;
|
||||
}
|
||||
|
@ -490,9 +504,6 @@ void WlanConnect::onActiveConnectionChanged(QString deviceName, QString ssid, QS
|
|||
}
|
||||
}
|
||||
} else {
|
||||
if (deviceName.isEmpty() || ssid.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
if (!deviceFrameMap.contains(deviceName)) {
|
||||
return;
|
||||
}
|
||||
|
@ -834,6 +845,15 @@ void WlanConnect::removeDeviceFrame(QString devName)
|
|||
qDebug() << "[WlanConnect]removeDeviceFrame " << devName;
|
||||
if (deviceFrameMap.contains(devName)) {
|
||||
ItemFrame *item = deviceFrameMap[devName];
|
||||
if (item->lanItemFrame->layout() != NULL) {
|
||||
QLayoutItem* layoutItem;
|
||||
while ((layoutItem = item->lanItemFrame->layout()->takeAt(0)) != NULL) {
|
||||
delete layoutItem->widget();
|
||||
delete layoutItem;
|
||||
item = nullptr;
|
||||
}
|
||||
item->itemMap.clear();
|
||||
}
|
||||
delete item;
|
||||
item = nullptr;
|
||||
deviceFrameMap.remove(devName);
|
||||
|
|
|
@ -141,7 +141,7 @@ private:
|
|||
// DeviceWlanlistInfo deviceWlanlistInfo;
|
||||
|
||||
QTimer * m_scanTimer = nullptr;
|
||||
QTimer * m_updateTimer = nullptr;
|
||||
// QTimer * m_updateTimer = nullptr;
|
||||
private:
|
||||
SwitchButton *wifiSwtch;
|
||||
bool mFirstLoad;
|
||||
|
|
|
@ -3,6 +3,7 @@ TEMPLATE = lib
|
|||
CONFIG += plugin
|
||||
|
||||
include(../component/switchbutton.pri)
|
||||
include(../component/infobutton.pri)
|
||||
|
||||
TARGET = $$qtLibraryTarget(wlanconnect)
|
||||
DESTDIR = ../..
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#include <QGSettings>
|
||||
#include <QImage>
|
||||
#include "fixlabel.h"
|
||||
#include "infobutton.h"
|
||||
#include "../component/InfoButton/infobutton.h"
|
||||
|
||||
class WlanItem : public QPushButton
|
||||
{
|
||||
|
|
|
@ -108,6 +108,8 @@ Q_SIGNALS: // SIGNALS
|
|||
void signalStrengthChange(QString devName, QString ssid, int strength);
|
||||
//安全性变化
|
||||
void secuTypeChange(QString devName, QString ssid, QString secuType);
|
||||
//列表排序
|
||||
void timeToUpdate();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -17,6 +17,9 @@
|
|||
#define THEME_SCHAME "org.ukui.style"
|
||||
#define COLOR_THEME "styleName"
|
||||
|
||||
#define LAN_PAGE_INDEX 0
|
||||
#define WLAN_PAGE_INDEX 1
|
||||
|
||||
#include <kwindowsystem.h>
|
||||
#include <kwindowsystem_export.h>
|
||||
|
||||
|
@ -216,6 +219,8 @@ void MainWindow::initDbusConnnect()
|
|||
connect(m_wlanWidget, &WlanPage::hotspotActivated, this, &MainWindow::hotspotActivated);
|
||||
connect(m_wlanWidget, &WlanPage::secuTypeChange, this, &MainWindow::secuTypeChange);
|
||||
connect(m_wlanWidget, &WlanPage::signalStrengthChange, this, &MainWindow::signalStrengthChange);
|
||||
connect(m_wlanWidget, &WlanPage::timeToUpdate , this, &MainWindow::timeToUpdate);
|
||||
connect(m_wlanWidget, &WlanPage::showMainWindow, this, &MainWindow::onShowByWlanPage);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -339,9 +344,9 @@ void MainWindow::showControlCenter()
|
|||
{
|
||||
QProcess process;
|
||||
if (!m_lanWidget->lanIsConnected() && m_wlanWidget->wlanIsConnected()){
|
||||
process.startDetached("ukui-control-center --wlanconnect");
|
||||
process.startDetached("ukui-control-center -m wlanconnect");
|
||||
} else {
|
||||
process.startDetached("ukui-control-center --wiredconnect");
|
||||
process.startDetached("ukui-control-center -m netconnect");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -422,6 +427,19 @@ void MainWindow::onWlanConnectStatusToChangeTrayIcon(int state)
|
|||
}
|
||||
}
|
||||
|
||||
void MainWindow::onShowByWlanPage()
|
||||
{
|
||||
m_centralWidget->setCurrentIndex(WLAN_PAGE_INDEX);
|
||||
|
||||
if(QApplication::activeWindow() != this) {
|
||||
this->resetWindowPosition();
|
||||
this->showNormal();
|
||||
this->raise();
|
||||
this->activateWindow();
|
||||
emit this->mainWindowVisibleChanged(true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief MainWindow::keyPressEvent 按esc键关闭主界面
|
||||
* @param event
|
||||
|
|
|
@ -79,6 +79,8 @@ signals:
|
|||
//安全性变化
|
||||
void secuTypeChange(QString devName, QString ssid, QString secuType);
|
||||
void mainWindowVisibleChanged(const bool &visible);
|
||||
//列表排序
|
||||
void timeToUpdate();
|
||||
public slots:
|
||||
|
||||
protected:
|
||||
|
@ -133,6 +135,7 @@ private slots:
|
|||
void onSetTrayIconLoading();
|
||||
void onLanConnectStatusToChangeTrayIcon(int state);
|
||||
void onWlanConnectStatusToChangeTrayIcon(int state);
|
||||
void onShowByWlanPage();
|
||||
};
|
||||
|
||||
#endif // MAINWINDOW_H
|
||||
|
|
|
@ -1103,7 +1103,12 @@ bool LanPage::eventFilter(QObject *watched, QEvent *event)
|
|||
void LanPage::activateWired(const QString& devName, const QString& connUuid)
|
||||
{
|
||||
qDebug() << "[LanPage] activateWired" << devName << connUuid;
|
||||
m_wiredConnectOperation->activateConnection(connUuid, devName);
|
||||
if (!m_deviceResource->wiredDeviceCarriered(devName)) {
|
||||
qDebug() << LOG_FLAG << devName << "is not carried, so can not activate connection";
|
||||
this->showDesktopNotify(tr("Wired Device not carried"));
|
||||
} else {
|
||||
m_wiredConnectOperation->activateConnection(connUuid, devName);
|
||||
}
|
||||
}
|
||||
|
||||
void LanPage::deactivateWired(const QString& devName, const QString& connUuid)
|
||||
|
|
|
@ -170,6 +170,7 @@ void WlanPage::initTimer()
|
|||
|
||||
m_refreshIconTimer = new QTimer(this);
|
||||
connect(m_refreshIconTimer, &QTimer::timeout, this, &WlanPage::onRefreshIconTimer);
|
||||
m_refreshIconTimer->start(ICON_REFRESH_INTERVAL);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -227,7 +228,7 @@ void WlanPage::initDeviceCombox()
|
|||
}
|
||||
|
||||
connect(m_deviceComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged),
|
||||
this, &WlanPage::onDeviceComboxIndexChanged);
|
||||
this, &WlanPage::onDeviceComboxIndexChanged, Qt::DirectConnection);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -927,6 +928,7 @@ void WlanPage::onItemHeightChanged(const bool isExpanded, const QString &ssid)
|
|||
|
||||
void WlanPage::onDeviceComboxIndexChanged(int currentIndex)
|
||||
{
|
||||
qDebug() << "onDeviceComboxIndexChanged";
|
||||
if (!m_deviceComboBox || currentIndex < 0) {
|
||||
return;
|
||||
}
|
||||
|
@ -993,7 +995,14 @@ void WlanPage::onWifiEnabledChanged(bool isWifiOn)
|
|||
}
|
||||
|
||||
void WlanPage::onRefreshIconTimer()
|
||||
{
|
||||
{
|
||||
emit timeToUpdate();
|
||||
|
||||
if(!this->isVisible()) {
|
||||
return;
|
||||
}
|
||||
qDebug() << "onRefreshIconTimer";
|
||||
|
||||
if (m_expandedItem) {
|
||||
qDebug()<< LOG_FLAG << "Has expanded item and forbid refresh wifi strength" << Q_FUNC_INFO << __LINE__;
|
||||
return;
|
||||
|
@ -1180,31 +1189,31 @@ void WlanPage::activateWirelessConnection(const QString& devName, const QString&
|
|||
return;
|
||||
}
|
||||
|
||||
if (wirelessNetItem.m_isConfigured) {
|
||||
m_wirelessConnectOpreation->activeWirelessConnect(devName, wirelessNetItem.m_connectUuid);
|
||||
} else {
|
||||
//todo: 显示界面输入密码 (无需密码的wifi?)
|
||||
# if 0
|
||||
if (devName != m_currentDevice) {
|
||||
//todo
|
||||
if (devName != m_currentDevice) {
|
||||
int index = m_deviceComboBox->findText(devName);
|
||||
if (index >= 0) {
|
||||
m_deviceComboBox->setCurrentIndex(index);
|
||||
} else {
|
||||
QListWidgetItem *p_listWidgetItem = nullptr;
|
||||
WlanListItem *p_wlanItem = nullptr;
|
||||
|
||||
if (m_wirelessNetItemMap.contains(ssid)) {
|
||||
p_listWidgetItem = m_wirelessNetItemMap.value(ssid);
|
||||
p_wlanItem = (WlanListItem*)m_inactivatedNetListWidget->itemWidget(p_listWidgetItem);
|
||||
int row = m_inactivatedNetListWidget->row(p_listWidgetItem);
|
||||
|
||||
// m_inactivatedNetListArea->scrollToItem(p_listWidgetItem, QAbstractItemView::EnsureVisible);
|
||||
m_inactivatedNetListArea->verticalScrollBar()->setValue((p_listWidgetItem->sizeHint().height()*(row+1)/m_inactivatedNetListWidget->height())*m_inactivatedNetListArea->verticalScrollBar()->maximumHeight());
|
||||
|
||||
bool a = true;
|
||||
p_wlanItem->setExpanded(a);
|
||||
emit showMainWindow();
|
||||
}
|
||||
qDebug() << "[WlanPage]activateWirelessConnection no such " << devName;
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
QListWidgetItem *p_listWidgetItem = nullptr;
|
||||
WlanListItem *p_wlanItem = nullptr;
|
||||
|
||||
if (m_wirelessNetItemMap.contains(ssid)) {
|
||||
p_listWidgetItem = m_wirelessNetItemMap.value(ssid);
|
||||
p_wlanItem = (WlanListItem*)m_inactivatedNetListWidget->itemWidget(p_listWidgetItem);
|
||||
|
||||
m_inactivatedNetListWidget->scrollToItem(p_listWidgetItem, QAbstractItemView::EnsureVisible);
|
||||
|
||||
|
||||
QMouseEvent *event = new QMouseEvent(QEvent::MouseButtonPress, QPoint(0,0), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);
|
||||
QApplication::postEvent(p_wlanItem, event);
|
||||
emit showMainWindow();
|
||||
} else {
|
||||
qDebug() << "[WlanPage]activateWirelessConnection no such " << ssid << "in" << devName;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -1236,11 +1245,11 @@ void WlanPage::onMainWindowVisibleChanged(const bool &visible)
|
|||
//打开页面时先触发一次扫描,然后定时扫描wifi热点和刷新icon
|
||||
requestScan();
|
||||
m_scanTimer->start(AP_SCAN_INTERVAL);
|
||||
m_refreshIconTimer->start(ICON_REFRESH_INTERVAL);
|
||||
// m_refreshIconTimer->start(ICON_REFRESH_INTERVAL);
|
||||
} else {
|
||||
//界面关闭的时候,停止wifi扫描和刷新
|
||||
m_scanTimer->stop();
|
||||
m_refreshIconTimer->stop();
|
||||
// m_refreshIconTimer->stop();
|
||||
}
|
||||
|
||||
return;
|
||||
|
|
|
@ -60,6 +60,9 @@ signals:
|
|||
void secuTypeChange(QString devName, QString ssid, QString secuType);
|
||||
void hiddenWlanClicked();
|
||||
void wlanConnectChanged(int state);
|
||||
void timeToUpdate();
|
||||
|
||||
void showMainWindow();
|
||||
|
||||
public slots:
|
||||
void onMainWindowVisibleChanged(const bool &visible);
|
||||
|
|
Loading…
Reference in New Issue