Merge branch '0809-new-frontend' into 'dbus-interface'

Create new mainwindow.

See merge request kylin-desktop/kylin-nm!153
This commit is contained in:
ren peijia 2021-08-16 09:02:10 +00:00
commit f04dff6299
50 changed files with 1645 additions and 226 deletions

View File

@ -1,6 +1,7 @@
TEMPLATE = subdirs TEMPLATE = subdirs
CONFIG += ordered CONFIG += ordered \
qt
SUBDIRS = \ SUBDIRS = \
src \ src \
@ -9,3 +10,5 @@ TRANSLATIONS += \
translations/kylin-nm_zh_CN.ts \ translations/kylin-nm_zh_CN.ts \
translations/kylin-nm_tr.ts \ translations/kylin-nm_tr.ts \
translations/kylin-nm_bo.ts translations/kylin-nm_bo.ts
QT += widgets

View File

@ -50,7 +50,6 @@
<file>res/s/conning-a/6.png</file> <file>res/s/conning-a/6.png</file>
<file>res/s/conning-a/7.png</file> <file>res/s/conning-a/7.png</file>
<file>res/s/conning-a/8.png</file> <file>res/s/conning-a/8.png</file>
<file>qss/style.qss</file>
<file>res/g/close_black.png</file> <file>res/g/close_black.png</file>
<file>res/g/close_white.png</file> <file>res/g/close_white.png</file>
<file>res/s/conning-s/1.png</file> <file>res/s/conning-s/1.png</file>

View File

@ -1,10 +0,0 @@
QScrollBar:vertical{margin:0px 2px 0px 2px;width:10px;background:rgba(48,48,51,0);border-radius:6px;}
QScrollBar::up-arrow:vertical{height:0px;}
QScrollBar::sub-line:vertical{border:0px solid;height:0px}
QScrollBar::sub-page:vertical{background:transparent;}
QScrollBar::handle:vertical{width:6px;background:rgba(72,72,76,1);border-radius:3px;}
QScrollBar::handle:vertical:hover{width:6px;background:rgba(97,97,102,1);border-radius:3px;}
QScrollBar::handle:vertical:pressed{width:6px;background:rgba(133,133,140,1);border-radius:3px;}
QScrollBar::add-page:vertical{background:transparent;}
QScrollBar::add-line:vertical{border:0px solid;height:0px}
QScrollBar::down-arrow:vertical{height:0px;}

View File

@ -26,12 +26,8 @@ DbusAdaptor::DbusAdaptor(MainWindow *parent)
{ {
// constructor // constructor
qDBusRegisterMetaType<QVector<QStringList>>(); qDBusRegisterMetaType<QVector<QStringList>>();
//setAutoRelaySignals(true)后会自动转发mainwindow发出的同名信号因此不必再额外写一个转发
setAutoRelaySignals(true); setAutoRelaySignals(true);
//setAutoRelaySignals(true)后会自动转发同名信号,因此不必再额外像如下代码一样写一个转发
// connect(parent, &MainWindow::getWifiListFinished, this, [ = ]() {
// QDBusMessage msg = QDBusMessage::createSignal("/com/kylin/network", "com.kylin.network", "getWifiListFinished");
// QDBusConnection::sessionBus().send(msg);
// });
} }
DbusAdaptor::~DbusAdaptor() DbusAdaptor::~DbusAdaptor()
@ -41,24 +37,19 @@ DbusAdaptor::~DbusAdaptor()
void DbusAdaptor::showMainWindow() void DbusAdaptor::showMainWindow()
{ {
// handle method call com.kylin.weather.showMainWindow parent()->showMainwindow();
//edited the code manually by lixiang
//parent()->handleIconClicked();
parent()->on_showWindowAction();
} }
void DbusAdaptor::showPb(QString type, QString name) void DbusAdaptor::showPb(QString type, QString name)
{ {
parent()->showPb(type, name);
} }
void DbusAdaptor::requestRefreshWifiList() void DbusAdaptor::requestRefreshWifiList()
{ {
parent()->requestRefreshWifiList();
} }
QVector<QStringList> DbusAdaptor::getWifiList() QVector<QStringList> DbusAdaptor::getWifiList()
{ {
return parent()->dbus_wifiList; return QVector<QStringList>();
} }

View File

@ -29,7 +29,7 @@ QT_END_NAMESPACE
* Adaptor class for interface com.kylin.weather * Adaptor class for interface com.kylin.weather
*/ */
#include "mainwindow.h"//added the code manually by lixiang #include "new-mainwindow.h"
class DbusAdaptor: public QDBusAbstractAdaptor class DbusAdaptor: public QDBusAbstractAdaptor
{ {

View File

@ -44,7 +44,7 @@ void quitThread(QThread *thread)
} // namespace } // namespace
KylinDBus::KylinDBus(MainWindow *mainWindow, QObject *parent) :QObject(parent) KylinDBus::KylinDBus(OldMainWindow *mainWindow, QObject *parent) :QObject(parent)
{ {
this->mw = mainWindow; this->mw = mainWindow;

View File

@ -37,14 +37,14 @@
#define WIFI_CONNECTED 2 #define WIFI_CONNECTED 2
#define WIFI_DISCONNECTED 3 #define WIFI_DISCONNECTED 3
class MainWindow; class OldMainWindow;
class Utils; class Utils;
class KylinDBus : public QObject class KylinDBus : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit KylinDBus(MainWindow *mw = 0, QObject *parent = nullptr); explicit KylinDBus(OldMainWindow *mw = 0, QObject *parent = nullptr);
~KylinDBus(); ~KylinDBus();
void getObjectPath(); void getObjectPath();
@ -134,7 +134,7 @@ public slots:
void requestScanWifi(); void requestScanWifi();
private: private:
MainWindow *mw; OldMainWindow *mw;
Utils *mUtils; Utils *mUtils;
QThread *mUtilsThread; QThread *mUtilsThread;

View File

@ -0,0 +1,152 @@
#include "customstyle.h"
CustomStyle::CustomStyle(const QString &proxyStyleName) : QProxyStyle (proxyStyleName)
{
}
QSize CustomStyle::sizeFromContents(QStyle::ContentsType type, const QStyleOption *option, const QSize &contentsSize, const QWidget *widget) const
{
switch (type) {
case CT_TabBarTab: {
QSize size(0,40);
if (const QStyleOptionTab *tab= qstyleoption_cast<const QStyleOptionTab *>(option)) {
switch (tab->shape) {
case QTabBar::RoundedNorth:
case QTabBar::RoundedSouth: {
return size + QSize(50,0);
break;
}
case QTabBar::RoundedWest:
case QTabBar::RoundedEast: {
return size + QSize(0,50);
break;
}
default: {
break;
}
}
}
return size;
break;
}
default: {
break;
}
}
return QProxyStyle::sizeFromContents(type, option, contentsSize, widget);
}
void CustomStyle::drawControl(QStyle::ControlElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const
{
// switch (element) {
// case CE_TabBarTab: {
// if (QStyle::State_Selected != option->state) {
// painter->save();
// painter->setBrush(QColor(0,0,0,0));
// painter->drawRect(widget->rect());
//// painter->setOpacity(0.1);
// painter->restore();
// }
// break;
// }
// default: {
// break;
// }
// }
return QProxyStyle::drawControl(element, option, painter, widget);
}
//void CustomStyle::drawComplexControl(QStyle::ComplexControl control, const QStyleOptionComplex *option, QPainter *painter, const QWidget *widget) const
//{
// return QProxyStyle::drawComplexControl(control, option, painter, widget);
//}
//void CustomStyle::drawItemPixmap(QPainter *painter, const QRect &rectangle, int alignment, const QPixmap &pixmap) const
//{
// return QProxyStyle::drawItemPixmap(painter, rectangle, alignment, pixmap);
//}
//void CustomStyle::drawItemText(QPainter *painter, const QRect &rectangle, int alignment, const QPalette &palette, bool enabled, const QString &text, QPalette::ColorRole textRole) const
//{
// return QProxyStyle::drawItemText(painter, rectangle, alignment, palette, enabled, text, textRole);
//}
//void CustomStyle::drawPrimitive(QStyle::PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const
//{
// return QProxyStyle::drawPrimitive(element, option, painter, widget);
//}
//QPixmap CustomStyle::generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap, const QStyleOption *option) const
//{
// return QProxyStyle::generatedIconPixmap(iconMode, pixmap, option);
//}
//QStyle::SubControl CustomStyle::hitTestComplexControl(QStyle::ComplexControl control, const QStyleOptionComplex *option, const QPoint &position, const QWidget *widget) const
//{
// return QProxyStyle::hitTestComplexControl(control, option, position, widget);
//}
//QRect CustomStyle::itemPixmapRect(const QRect &rectangle, int alignment, const QPixmap &pixmap) const
//{
// return QProxyStyle::itemPixmapRect(rectangle, alignment, pixmap);
//}
//QRect CustomStyle::itemTextRect(const QFontMetrics &metrics, const QRect &rectangle, int alignment, bool enabled, const QString &text) const
//{
// return QProxyStyle::itemTextRect(metrics, rectangle, alignment, enabled, text);
//}
//int CustomStyle::pixelMetric(QStyle::PixelMetric metric, const QStyleOption *option, const QWidget *widget) const
//{
// return QProxyStyle::pixelMetric(metric, option, widget);
//}
//void CustomStyle::polish(QWidget *widget)
//{
// return QProxyStyle::polish(widget);
//}
//void CustomStyle::polish(QApplication *application)
//{
// return QProxyStyle::polish(application);
//}
//void CustomStyle::polish(QPalette &palette)
//{
// return QProxyStyle::polish(palette);
//}
//void CustomStyle::unpolish(QWidget *widget)
//{
// return QProxyStyle::unpolish(widget);
//}
//void CustomStyle::unpolish(QApplication *application)
//{
// return QProxyStyle::unpolish(application);
//}
//QIcon CustomStyle::standardIcon(QStyle::StandardPixmap standardIcon, const QStyleOption *option, const QWidget *widget) const
//{
// return QProxyStyle::standardIcon(standardIcon, option, widget);
//}
//QPalette CustomStyle::standardPalette() const
//{
// return QProxyStyle::standardPalette();
//}
//int CustomStyle::styleHint(QStyle::StyleHint hint, const QStyleOption *option, const QWidget *widget, QStyleHintReturn *returnData) const
//{
// return QProxyStyle::styleHint(hint, option, widget, returnData);
//}
//QRect CustomStyle::subControlRect(QStyle::ComplexControl control, const QStyleOptionComplex *option, QStyle::SubControl subControl, const QWidget *widget) const
//{
// return QProxyStyle::subControlRect(control, option, subControl, widget);
//}
//QRect CustomStyle::subElementRect(QStyle::SubElement element, const QStyleOption *option, const QWidget *widget) const
//{
// return QProxyStyle::subElementRect(element, option, widget);
//}

View File

@ -0,0 +1,47 @@
#ifndef CUSTOMSTYLE_H
#define CUSTOMSTYLE_H
#include <QStyle>
#include <QProxyStyle>
#include <QStyleFactory>
#include <QWidget>
#include <QPainter>
#include <QPainterPath>
#include <QStyleOptionSlider>
class CustomStyle : public QProxyStyle
{
Q_OBJECT
public:
explicit CustomStyle(const QString &proxyStyleName = "windows");
~CustomStyle() = default;
virtual QSize sizeFromContents(QStyle::ContentsType type, const QStyleOption *option, const QSize &contentsSize, const QWidget *widget = nullptr) const;
virtual void drawControl(QStyle::ControlElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget = nullptr) const;
// virtual void drawComplexControl(QStyle::ComplexControl control, const QStyleOptionComplex *option, QPainter *painter, const QWidget *widget = nullptr) const;
// virtual void drawItemPixmap(QPainter *painter, const QRect &rectangle, int alignment, const QPixmap &pixmap) const;
// virtual void drawItemText(QPainter *painter, const QRect &rectangle, int alignment, const QPalette &palette, bool enabled, const QString &text, QPalette::ColorRole textRole = QPalette::NoRole) const;
// virtual void drawPrimitive(QStyle::PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget = nullptr) const;
// virtual QPixmap generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap, const QStyleOption *option) const;
// virtual QStyle::SubControl hitTestComplexControl(QStyle::ComplexControl control, const QStyleOptionComplex *option, const QPoint &position, const QWidget *widget = nullptr) const;
// virtual QRect itemPixmapRect(const QRect &rectangle, int alignment, const QPixmap &pixmap) const;
// virtual QRect itemTextRect(const QFontMetrics &metrics, const QRect &rectangle, int alignment, bool enabled, const QString &text) const;
// //virtual int layoutSpacing(QSizePolicy::ControlType control1, QSizePolicy::ControlType control2, Qt::Orientation orientation, const QStyleOption *option, const QWidget *widget);
// virtual int pixelMetric(QStyle::PixelMetric metric, const QStyleOption *option = nullptr, const QWidget *widget = nullptr) const;
// virtual void polish(QWidget *widget);
// virtual void polish(QApplication *application);
// virtual void polish(QPalette &palette);
// virtual void unpolish(QWidget *widget);
// virtual void unpolish(QApplication *application);
// virtual QIcon standardIcon(QStyle::StandardPixmap standardIcon, const QStyleOption *option, const QWidget *widget) const;
// virtual QPalette standardPalette() const;
// virtual int styleHint(QStyle::StyleHint hint, const QStyleOption *option = nullptr, const QWidget *widget = nullptr, QStyleHintReturn *returnData = nullptr) const;
// virtual QRect subControlRect(QStyle::ComplexControl control, const QStyleOptionComplex *option, QStyle::SubControl subControl, const QWidget *widget = nullptr) const;
// virtual QRect subElementRect(QStyle::SubElement element, const QStyleOption *option, const QWidget *widget = nullptr) const;
};
#endif // CUSTOMSTYLE_H

View File

@ -1,31 +1,32 @@
INCLUDEPATH += $$PWD INCLUDEPATH += $$PWD
include(tools/tools.pri) include(tools/tools.pri)
include(wireless-security/wireless-security.pri) include(wireless-security/wireless-security.pri)
include(xatom/xatom.pri)
include(tab-pages/tab-pages.pri)
include(list-items/list-items.pri)
FORMS += \ FORMS += \
$$PWD/confform.ui \ $$PWD/confform.ui \
$$PWD/mainwindow.ui \ $$PWD/mainwindow.ui \
$$PWD/oneconnform.ui \
$$PWD/onelancform.ui \
$$PWD/wificonfigdialog.ui \ $$PWD/wificonfigdialog.ui \
$$PWD/wpawifidialog.ui $$PWD/wpawifidialog.ui
HEADERS += \ HEADERS += \
$$PWD/confform.h \ $$PWD/confform.h \
$$PWD/customstyle.h \
$$PWD/kylinwiredwidget.h \ $$PWD/kylinwiredwidget.h \
$$PWD/mainwindow.h \ $$PWD/mainwindow.h \
$$PWD/nmdemo.h \ $$PWD/nmdemo.h \
$$PWD/oneconnform.h \
$$PWD/onelancform.h \
$$PWD/wificonfigdialog.h \ $$PWD/wificonfigdialog.h \
$$PWD/wpawifidialog.h $$PWD/wpawifidialog.h \
$$PWD/new-mainwindow.h
SOURCES += \ SOURCES += \
$$PWD/confform.cpp \ $$PWD/confform.cpp \
$$PWD/customstyle.cpp \
$$PWD/kylinwiredwidget.cpp \ $$PWD/kylinwiredwidget.cpp \
$$PWD/mainwindow.cpp \ $$PWD/mainwindow.cpp \
$$PWD/nmdemo.cpp \ $$PWD/nmdemo.cpp \
$$PWD/oneconnform.cpp \
$$PWD/onelancform.cpp \
$$PWD/wificonfigdialog.cpp \ $$PWD/wificonfigdialog.cpp \
$$PWD/wpawifidialog.cpp $$PWD/wpawifidialog.cpp \
$$PWD/new-mainwindow.cpp

View File

@ -0,0 +1,16 @@
INCLUDEPATH += $$PWD
FORMS += \
$$PWD/oneconnform.ui \
$$PWD/onelancform.ui
HEADERS += \
$$PWD/listitem.h \
$$PWD/oneconnform.h \
$$PWD/onelancform.h
SOURCES += \
$$PWD/listitem.cpp \
$$PWD/oneconnform.cpp \
$$PWD/onelancform.cpp

View File

@ -0,0 +1,6 @@
#include "listitem.h"
ListItem::ListItem()
{
}

View File

@ -0,0 +1,12 @@
#ifndef LISTITEM_H
#define LISTITEM_H
#include <QFrame>
class ListItem : public QFrame
{
Q_OBJECT
public:
ListItem();
};
#endif // LISTITEM_H

View File

@ -34,7 +34,7 @@
#include <QDBusObjectPath> #include <QDBusObjectPath>
#include <QtConcurrent> #include <QtConcurrent>
OneConnForm::OneConnForm(QWidget *parent, MainWindow *mainWindow, ConfForm *confForm, KSimpleNM *ksnm) : OneConnForm::OneConnForm(QWidget *parent, OldMainWindow *mainWindow, ConfForm *confForm, KSimpleNM *ksnm) :
QWidget(parent), QWidget(parent),
ui(new Ui::OneConnForm) ui(new Ui::OneConnForm)
{ {
@ -154,7 +154,7 @@ OneConnForm::OneConnForm(QWidget *parent, MainWindow *mainWindow, ConfForm *conf
this->waitTimer = new QTimer(this); this->waitTimer = new QTimer(this);
connect(waitTimer, SIGNAL(timeout()), this, SLOT(waitAnimStep())); connect(waitTimer, SIGNAL(timeout()), this, SLOT(waitAnimStep()));
connect(mw, &MainWindow::reConnectWifi, this, [ = ](const QString& uuid) { connect(mw, &OldMainWindow::reConnectWifi, this, [ = ](const QString& uuid) {
if (isActive) { if (isActive) {
QThread *t = new QThread(); QThread *t = new QThread();
BackThread *bt = new BackThread(); BackThread *bt = new BackThread();
@ -168,12 +168,12 @@ OneConnForm::OneConnForm(QWidget *parent, MainWindow *mainWindow, ConfForm *conf
} }
}); });
connect(mw, &MainWindow::startReconnectWifi, this, [ = ](const QString &ssid) { connect(mw, &OldMainWindow::startReconnectWifi, this, [ = ](const QString &ssid) {
if (ssid == this->wifiName && !this->isWaiting) { if (ssid == this->wifiName && !this->isWaiting) {
this->startWifiWaiting(true); this->startWifiWaiting(true);
} }
}); });
connect(mw, &MainWindow::stopReconnectWifi, this, [ = ](const QString &ssid, const int &result) { connect(mw, &OldMainWindow::stopReconnectWifi, this, [ = ](const QString &ssid, const int &result) {
if (ssid == this->wifiName) { if (ssid == this->wifiName) {
qDebug()<<"Reconnect "<<ssid<<" finished. result="<<result; qDebug()<<"Reconnect "<<ssid<<" finished. result="<<result;
if (result != 0) { if (result != 0) {
@ -184,7 +184,7 @@ OneConnForm::OneConnForm(QWidget *parent, MainWindow *mainWindow, ConfForm *conf
} }
}); });
connect(mw, &MainWindow::wifiClicked, this, [ = ](QString name) { connect(mw, &OldMainWindow::wifiClicked, this, [ = ](QString name) {
if (QString::compare(name, this->wifiName) == 0 && !this->isActive) { if (QString::compare(name, this->wifiName) == 0 && !this->isActive) {
on_btnConn_clicked(); on_btnConn_clicked();
} }

View File

@ -52,7 +52,7 @@
#define Y_LINE_BIG_EXTEND 137 #define Y_LINE_BIG_EXTEND 137
#define X_LINE_BIG_EXTEND 2 #define X_LINE_BIG_EXTEND 2
class MainWindow; class OldMainWindow;
namespace Ui { namespace Ui {
class OneConnForm; class OneConnForm;
@ -63,7 +63,7 @@ class OneConnForm : public QWidget
Q_OBJECT Q_OBJECT
public: public:
explicit OneConnForm(QWidget *parent = 0, MainWindow *mw = 0, ConfForm *confForm = 0, KSimpleNM *ksnm = 0); explicit OneConnForm(QWidget *parent = 0, OldMainWindow *mw = 0, ConfForm *confForm = 0, KSimpleNM *ksnm = 0);
~OneConnForm(); ~OneConnForm();
// category:1->normal protocol 1->wifi 6 2->wifi 6+ // category:1->normal protocol 1->wifi 6 2->wifi 6+
@ -157,7 +157,7 @@ private:
bool m_connWithPwd = true; //是否使用密码连接 bool m_connWithPwd = true; //是否使用密码连接
Ui::OneConnForm *ui = nullptr; Ui::OneConnForm *ui = nullptr;
MainWindow *mw = nullptr; OldMainWindow *mw = nullptr;
ConfForm *cf = nullptr; ConfForm *cf = nullptr;
KSimpleNM *ks = nullptr; KSimpleNM *ks = nullptr;
bool hasPwd; bool hasPwd;

View File

@ -53,7 +53,7 @@
#define Y_LINE_EXTEND 161 #define Y_LINE_EXTEND 161
#define X_LINE_EXTEND 2 #define X_LINE_EXTEND 2
class MainWindow; class OldMainWindow;
namespace Ui { namespace Ui {
class OneLancForm; class OneLancForm;
@ -121,7 +121,7 @@ private:
int countCurrentTime; int countCurrentTime;
Ui::OneLancForm *ui = nullptr; Ui::OneLancForm *ui = nullptr;
MainWindow *mw = nullptr; OldMainWindow *mw = nullptr;
ConfForm *cf = nullptr; ConfForm *cf = nullptr;
KSimpleNM *ks = nullptr; KSimpleNM *ks = nullptr;
KyWiredConnectOperation *m_wiredConnectOperation = nullptr; KyWiredConnectOperation *m_wiredConnectOperation = nullptr;

View File

@ -39,7 +39,7 @@
QString llname, lwname, hideWiFiConn; QString llname, lwname, hideWiFiConn;
MainWindow::MainWindow(QWidget *parent) : OldMainWindow::OldMainWindow(QWidget *parent) :
QMainWindow(parent), QMainWindow(parent),
ui(new Ui::MainWindow) ui(new Ui::MainWindow)
{ {
@ -55,7 +55,7 @@ MainWindow::MainWindow(QWidget *parent) :
firstlyStart(); //先执行一些不耗时的一级启动项 firstlyStart(); //先执行一些不耗时的一级启动项
} }
MainWindow::~MainWindow() OldMainWindow::~OldMainWindow()
{ {
trayIcon->deleteLater(); trayIcon->deleteLater();
trayIconMenu->deleteLater(); trayIconMenu->deleteLater();
@ -65,7 +65,7 @@ MainWindow::~MainWindow()
/** /**
* @brief MainWindow::firstlyStart * @brief MainWindow::firstlyStart
*/ */
void MainWindow::firstlyStart() void OldMainWindow::firstlyStart()
{ {
qDebug()<<"Loading qss..."; qDebug()<<"Loading qss...";
UseQssFile::setStyle("style.qss"); UseQssFile::setStyle("style.qss");
@ -92,10 +92,10 @@ void MainWindow::firstlyStart()
hideWiFiConn = "Connect to Hidden WLAN Network"; hideWiFiConn = "Connect to Hidden WLAN Network";
createTrayIcon(); createTrayIcon();
connect(trayIcon, &QSystemTrayIcon::activated, this, &MainWindow::iconActivated); connect(trayIcon, &QSystemTrayIcon::activated, this, &OldMainWindow::iconActivated);
connect(mShowWindow, &QAction::triggered, this, &MainWindow::on_showWindowAction); connect(mShowWindow, &QAction::triggered, this, &OldMainWindow::on_showWindowAction);
connect(mAdvConf, &QAction::triggered, this, &MainWindow::actionTriggerSlots); connect(mAdvConf, &QAction::triggered, this, &OldMainWindow::actionTriggerSlots);
connect(this,&MainWindow::showPbSignal,trayIcon,&QSystemTrayIcon::activated); connect(this,&OldMainWindow::showPbSignal,trayIcon,&QSystemTrayIcon::activated);
//checkSingleAndShowTrayicon(); //checkSingleAndShowTrayicon();
//trayIcon->setVisible(true); //trayIcon->setVisible(true);
@ -111,7 +111,7 @@ void MainWindow::firstlyStart()
/** /**
* @brief MainWindow::secondaryStart * @brief MainWindow::secondaryStart
*/ */
void MainWindow::secondaryStart() void OldMainWindow::secondaryStart()
{ {
m_networkResourceInstance = KyNetworkResourceManager::getInstance(); m_networkResourceInstance = KyNetworkResourceManager::getInstance();
//m_networkResourceInstance = new KyNetworkResourceManager(); //m_networkResourceInstance = new KyNetworkResourceManager();
@ -164,10 +164,10 @@ void MainWindow::secondaryStart()
getSystemFontFamily();//建立GSetting监听系统字体 getSystemFontFamily();//建立GSetting监听系统字体
qDebug()<<"Init button connections..."; qDebug()<<"Init button connections...";
connect(ui->btnNetList, &QPushButton::clicked, this, &MainWindow::onBtnNetListClickeds); connect(ui->btnNetList, &QPushButton::clicked, this, &OldMainWindow::onBtnNetListClickeds);
connect(btnWireless, &SwitchButton::clicked,this, &MainWindow::onBtnWifiClicked); connect(btnWireless, &SwitchButton::clicked,this, &OldMainWindow::onBtnWifiClicked);
connect(btnWired, &SwitchButton::clicked, this, &MainWindow::onBtnLanClicked); connect(btnWired, &SwitchButton::clicked, this, &OldMainWindow::onBtnLanClicked);
connect(this, &MainWindow::onWiredDeviceChanged, this, &MainWindow::setLanSwitchStatus); connect(this, &OldMainWindow::onWiredDeviceChanged, this, &OldMainWindow::setLanSwitchStatus);
QVariant wifi_state = BackThread::getSwitchState(WIFI_SWITCH_OPENED); QVariant wifi_state = BackThread::getSwitchState(WIFI_SWITCH_OPENED);
QVariant lan_state = BackThread::getSwitchState(LAN_SWITCH_OPENED); QVariant lan_state = BackThread::getSwitchState(LAN_SWITCH_OPENED);
@ -211,7 +211,7 @@ void MainWindow::secondaryStart()
m_load_finished = true; m_load_finished = true;
} }
void MainWindow::checkSingleAndShowTrayicon() void OldMainWindow::checkSingleAndShowTrayicon()
{ {
int fd = 0; int fd = 0;
try { try {
@ -238,12 +238,12 @@ void MainWindow::checkSingleAndShowTrayicon()
} }
} }
void MainWindow::justShowTrayIcon() void OldMainWindow::justShowTrayIcon()
{ {
trayIcon->setVisible(true); trayIcon->setVisible(true);
} }
bool MainWindow::eventFilter(QObject *obj, QEvent *event) bool OldMainWindow::eventFilter(QObject *obj, QEvent *event)
{ {
if (obj == ui->btnNetList) { if (obj == ui->btnNetList) {
if (event->type() == QEvent::HoverEnter) { if (event->type() == QEvent::HoverEnter) {
@ -280,7 +280,7 @@ bool MainWindow::eventFilter(QObject *obj, QEvent *event)
// 初始化控件、网络、定时器 // 初始化控件、网络、定时器
// 初始化界面各控件 // 初始化界面各控件
void MainWindow::editQssString() void OldMainWindow::editQssString()
{ {
btnOffQss = "QLabel{min-width: 37px; min-height: 37px;max-width:37px; max-height: 37px;border-radius: 4px; background-color:rgba(255,255,255,0)}"; btnOffQss = "QLabel{min-width: 37px; min-height: 37px;max-width:37px; max-height: 37px;border-radius: 4px; background-color:rgba(255,255,255,0)}";
btnOnQss = "QLabel{min-width: 37px; min-height: 37px;max-width:37px; max-height: 37px;border-radius: 4px; background-color:rgba(61,107,229,1)}"; btnOnQss = "QLabel{min-width: 37px; min-height: 37px;max-width:37px; max-height: 37px;border-radius: 4px; background-color:rgba(61,107,229,1)}";
@ -296,7 +296,7 @@ void MainWindow::editQssString()
"QPushButton:Pressed{border-radius:4px;background-color:rgba(255,255,255,0);color:rgba(61,107,229,0.97);font-size:14px;}"; "QPushButton:Pressed{border-radius:4px;background-color:rgba(255,255,255,0);color:rgba(61,107,229,0.97);font-size:14px;}";
} }
void MainWindow::createTopLanUI() void OldMainWindow::createTopLanUI()
{ {
qDebug()<<"Creating Top Lan UI..."; qDebug()<<"Creating Top Lan UI...";
topLanListWidget = new KyWiredWidget(ui->centralWidget); topLanListWidget = new KyWiredWidget(ui->centralWidget);
@ -304,7 +304,7 @@ void MainWindow::createTopLanUI()
topLanListWidget->move(W_LEFT_AREA, Y_TOP_ITEM); topLanListWidget->move(W_LEFT_AREA, Y_TOP_ITEM);
topLanListWidget->resize(W_TOP_LIST_WIDGET, H_NORMAL_ITEM + H_GAP_UP + X_ITEM); topLanListWidget->resize(W_TOP_LIST_WIDGET, H_NORMAL_ITEM + H_GAP_UP + X_ITEM);
connect(topLanListWidget, &KyWiredWidget::updateSpeed, this, &MainWindow::on_setNetSpeeds); connect(topLanListWidget, &KyWiredWidget::updateSpeed, this, &OldMainWindow::on_setNetSpeeds);
/*顶部的一个item*/ /*顶部的一个item*/
lbTopLanList = new QLabel(topLanListWidget); lbTopLanList = new QLabel(topLanListWidget);
@ -325,7 +325,7 @@ void MainWindow::createTopLanUI()
connect(btnCreateNet,SIGNAL(clicked()),this,SLOT(onBtnCreateNetClicked())); connect(btnCreateNet,SIGNAL(clicked()),this,SLOT(onBtnCreateNetClicked()));
} }
void MainWindow::createTopWifiUI() void OldMainWindow::createTopWifiUI()
{ {
qDebug()<<"Creating Top Wifi UI..."; qDebug()<<"Creating Top Wifi UI...";
topWifiListWidget = new QWidget(ui->centralWidget); topWifiListWidget = new QWidget(ui->centralWidget);
@ -351,7 +351,7 @@ void MainWindow::createTopWifiUI()
connect(btnAddNet,SIGNAL(clicked()),this,SLOT(onBtnAddNetClicked())); connect(btnAddNet,SIGNAL(clicked()),this,SLOT(onBtnAddNetClicked()));
} }
void MainWindow::createOtherUI() void OldMainWindow::createOtherUI()
{ {
qDebug()<<"Creating Other Ui..."; qDebug()<<"Creating Other Ui...";
lbLoadDown = new QLabel(ui->centralWidget); lbLoadDown = new QLabel(ui->centralWidget);
@ -380,7 +380,7 @@ void MainWindow::createOtherUI()
lbNoItemTip->hide(); lbNoItemTip->hide();
} }
void MainWindow::createListAreaUI() void OldMainWindow::createListAreaUI()
{ {
qDebug()<<"Creating List Area Ui..."; qDebug()<<"Creating List Area Ui...";
scrollAreal = new QScrollArea(ui->centralWidget); scrollAreal = new QScrollArea(ui->centralWidget);
@ -430,7 +430,7 @@ void MainWindow::createListAreaUI()
//scrollAreaw->verticalScrollBar()->setStyleSheet(scrollBarQss);//// //scrollAreaw->verticalScrollBar()->setStyleSheet(scrollBarQss);////
} }
void MainWindow::createLeftAreaUI() void OldMainWindow::createLeftAreaUI()
{ {
qDebug()<<"Creating Left Area Ui..."; qDebug()<<"Creating Left Area Ui...";
btnWireless = new SwitchButton(this); btnWireless = new SwitchButton(this);
@ -515,7 +515,7 @@ void MainWindow::createLeftAreaUI()
} }
// 初始化有线网列表,初始化可回连wifi列表 // 初始化有线网列表,初始化可回连wifi列表
void MainWindow::initLanSlistAndGetReconnectNetList() void OldMainWindow::initLanSlistAndGetReconnectNetList()
{ {
qDebug()<<"Init Net List..."; qDebug()<<"Init Net List...";
canReconnectWifiList.clear(); canReconnectWifiList.clear();
@ -558,7 +558,7 @@ void MainWindow::initLanSlistAndGetReconnectNetList()
} }
// 初始化网络 // 初始化网络
void MainWindow::initNetwork() void OldMainWindow::initNetwork()
{ {
qDebug()<<"Init Net interface & list..."; qDebug()<<"Init Net interface & list...";
BackThread *bt = new BackThread(); BackThread *bt = new BackThread();
@ -648,7 +648,7 @@ void MainWindow::initNetwork()
} }
// 初始化定时器 // 初始化定时器
void MainWindow::initTimer() void OldMainWindow::initTimer()
{ {
qDebug()<<"Init Timer..."; qDebug()<<"Init Timer...";
//应用启动后,需要连接可连接的网络 //应用启动后,需要连接可连接的网络
@ -688,7 +688,7 @@ void MainWindow::initTimer()
} }
//初始化已经连接网络的DNS //初始化已经连接网络的DNS
void MainWindow::initActNetDNS() void OldMainWindow::initActNetDNS()
{ {
qDebug()<<"Init Active Net Dns..."; qDebug()<<"Init Active Net Dns...";
QList<QString> currConnLanSsidUuidState =objKyDBus->getAtiveLanSsidUuidState(); QList<QString> currConnLanSsidUuidState =objKyDBus->getAtiveLanSsidUuidState();
@ -703,7 +703,7 @@ void MainWindow::initActNetDNS()
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// 任务栏托盘管理、托盘图标处理 // 任务栏托盘管理、托盘图标处理
void MainWindow::createTrayIcon() void OldMainWindow::createTrayIcon()
{ {
qDebug()<<"Creating Tray Icon..."; qDebug()<<"Creating Tray Icon...";
trayIcon = new QSystemTrayIcon(); trayIcon = new QSystemTrayIcon();
@ -756,7 +756,7 @@ void MainWindow::createTrayIcon()
setTrayIcon(iconLanOnline); setTrayIcon(iconLanOnline);
} }
void MainWindow::iconStep() void OldMainWindow::iconStep()
{ {
if (currentIconIndex > 11) { if (currentIconIndex > 11) {
currentIconIndex = 0; currentIconIndex = 0;
@ -765,12 +765,12 @@ void MainWindow::iconStep()
currentIconIndex ++; currentIconIndex ++;
} }
void MainWindow::setTrayIcon(QIcon icon) void OldMainWindow::setTrayIcon(QIcon icon)
{ {
trayIcon->setIcon(icon); trayIcon->setIcon(icon);
} }
void MainWindow::setTrayIconOfWifi(int signal){ void OldMainWindow::setTrayIconOfWifi(int signal){
if (signal > 75) { if (signal > 75) {
setTrayIcon(iconWifiFull); setTrayIcon(iconWifiFull);
} else if(signal > 55 && signal <= 75) { } else if(signal > 55 && signal <= 75) {
@ -782,7 +782,7 @@ void MainWindow::setTrayIconOfWifi(int signal){
} }
} }
void MainWindow::setTrayLoading(bool isLoading) void OldMainWindow::setTrayLoading(bool isLoading)
{ {
if (isLoading) { if (isLoading) {
currentIconIndex = 0; currentIconIndex = 0;
@ -792,7 +792,7 @@ void MainWindow::setTrayLoading(bool isLoading)
} }
} }
void MainWindow::iconActivated(QSystemTrayIcon::ActivationReason reason) void OldMainWindow::iconActivated(QSystemTrayIcon::ActivationReason reason)
{ {
if (!m_load_finished) { if (!m_load_finished) {
m_secondary_start_timer->stop(); m_secondary_start_timer->stop();
@ -849,7 +849,7 @@ void MainWindow::iconActivated(QSystemTrayIcon::ActivationReason reason)
} }
} }
void MainWindow::handleIconClicked() void OldMainWindow::handleIconClicked()
{ {
QRect availableGeometry = qApp->primaryScreen()->availableGeometry(); QRect availableGeometry = qApp->primaryScreen()->availableGeometry();
QRect screenGeometry = qApp->primaryScreen()->geometry(); QRect screenGeometry = qApp->primaryScreen()->geometry();
@ -947,7 +947,7 @@ void MainWindow::handleIconClicked()
} }
} }
void MainWindow::showTrayIconMenu() void OldMainWindow::showTrayIconMenu()
{ {
QRect availableGeometry = qApp->primaryScreen()->availableGeometry(); QRect availableGeometry = qApp->primaryScreen()->availableGeometry();
QRect screenGeometry = qApp->primaryScreen()->geometry(); QRect screenGeometry = qApp->primaryScreen()->geometry();
@ -990,7 +990,7 @@ void MainWindow::showTrayIconMenu()
} }
} }
void MainWindow::on_showWindowAction() void OldMainWindow::on_showWindowAction()
{ {
if (!m_load_finished) { if (!m_load_finished) {
m_secondary_start_timer->stop(); m_secondary_start_timer->stop();
@ -1006,14 +1006,14 @@ void MainWindow::on_showWindowAction()
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
//加载动画,获取当前连接的网络和状态并设置图标 //加载动画,获取当前连接的网络和状态并设置图标
void MainWindow::startLoading() void OldMainWindow::startLoading()
{ {
qDebug()<<"Start loading..."; qDebug()<<"Start loading...";
loading->startLoading(); loading->startLoading();
setTrayLoading(true); setTrayLoading(true);
} }
void MainWindow::stopLoading() void OldMainWindow::stopLoading()
{ {
qDebug()<<"Stop loading!"; qDebug()<<"Stop loading!";
loading->stopLoading(); loading->stopLoading();
@ -1021,7 +1021,7 @@ void MainWindow::stopLoading()
getActiveInfoAndSetTrayIcon(); getActiveInfoAndSetTrayIcon();
} }
void MainWindow::on_checkOverTime() void OldMainWindow::on_checkOverTime()
{ {
QString cmd = "kill -9 $(pidof nmcli)"; //杀掉当前正在进行的有关nmcli命令的进程 QString cmd = "kill -9 $(pidof nmcli)"; //杀掉当前正在进行的有关nmcli命令的进程
int status = system(cmd.toUtf8().data()); int status = system(cmd.toUtf8().data());
@ -1033,7 +1033,7 @@ void MainWindow::on_checkOverTime()
is_stop_check_net_state = 0; is_stop_check_net_state = 0;
} }
void MainWindow::getActiveInfoAndSetTrayIcon() void OldMainWindow::getActiveInfoAndSetTrayIcon()
{ {
//bool hasNetConnecting =objKyDBus->checkNetworkConnectivity(); //bool hasNetConnecting =objKyDBus->checkNetworkConnectivity();
//if (hasNetConnecting) { //if (hasNetConnecting) {
@ -1086,7 +1086,7 @@ void MainWindow::getActiveInfoAndSetTrayIcon()
//网络设备管理 //网络设备管理
//网线插拔处理,由kylin-dbus-interface.cpp调用 //网线插拔处理,由kylin-dbus-interface.cpp调用
void MainWindow::onPhysicalCarrierChanged(bool flag) void OldMainWindow::onPhysicalCarrierChanged(bool flag)
{ {
#if 0 #if 0
this->startLoading(); this->startLoading();
@ -1123,7 +1123,7 @@ void MainWindow::onPhysicalCarrierChanged(bool flag)
#endif #endif
} }
void MainWindow::onCarrierUpHandle() void OldMainWindow::onCarrierUpHandle()
{ {
#if 0 #if 0
wiredCableUpTimer->stop(); wiredCableUpTimer->stop();
@ -1139,7 +1139,7 @@ void MainWindow::onCarrierUpHandle()
#endif #endif
} }
void MainWindow::onCarrierDownHandle() void OldMainWindow::onCarrierDownHandle()
{ {
//syslog(LOG_DEBUG, "Wired net is disconnected"); //syslog(LOG_DEBUG, "Wired net is disconnected");
#if 0 #if 0
@ -1158,7 +1158,7 @@ void MainWindow::onCarrierDownHandle()
#endif #endif
} }
void MainWindow::onDeleteLan() void OldMainWindow::onDeleteLan()
{ {
deleteLanTimer->stop(); deleteLanTimer->stop();
BackThread *btn_bt = new BackThread(); BackThread *btn_bt = new BackThread();
@ -1180,7 +1180,7 @@ void MainWindow::onDeleteLan()
is_stop_check_net_state = 0; is_stop_check_net_state = 0;
} }
void MainWindow::checkIfWiredNetExist() void OldMainWindow::checkIfWiredNetExist()
{ {
qDebug()<<"Checking Wired Net (num is 0?)..."; qDebug()<<"Checking Wired Net (num is 0?)...";
if (objKyDBus->getWiredNetworkNumber() == 0) { if (objKyDBus->getWiredNetworkNumber() == 0) {
@ -1189,7 +1189,7 @@ void MainWindow::checkIfWiredNetExist()
} }
//无线网卡插拔处理 //无线网卡插拔处理
void MainWindow::onNetworkDeviceAdded(QDBusObjectPath objPath) void OldMainWindow::onNetworkDeviceAdded(QDBusObjectPath objPath)
{ {
//仅处理无线网卡插入情况 //仅处理无线网卡插入情况
objKyDBus->isWirelessCardOn = false; objKyDBus->isWirelessCardOn = false;
@ -1209,7 +1209,7 @@ void MainWindow::onNetworkDeviceAdded(QDBusObjectPath objPath)
} }
} }
void MainWindow::onNetworkDeviceRemoved(QDBusObjectPath objPath) void OldMainWindow::onNetworkDeviceRemoved(QDBusObjectPath objPath)
{ {
if (objKyDBus->multiWirelessPaths.isEmpty()) if (objKyDBus->multiWirelessPaths.isEmpty())
return; return;
@ -1230,7 +1230,7 @@ void MainWindow::onNetworkDeviceRemoved(QDBusObjectPath objPath)
} }
} }
void MainWindow::checkIsWirelessDevicePluggedIn() void OldMainWindow::checkIsWirelessDevicePluggedIn()
{ {
qDebug()<<"Checking wireless device..."; qDebug()<<"Checking wireless device...";
//启动时判断是否有无线网卡 //启动时判断是否有无线网卡
@ -1242,7 +1242,7 @@ void MainWindow::checkIsWirelessDevicePluggedIn()
} }
} }
void MainWindow::getLanBandWidth() void OldMainWindow::getLanBandWidth()
{ {
BackThread *bt = new BackThread(); BackThread *bt = new BackThread();
IFace *iface = bt->execGetIface(); IFace *iface = bt->execGetIface();
@ -1253,7 +1253,7 @@ void MainWindow::getLanBandWidth()
} }
//检测网络设备状态 //检测网络设备状态
bool MainWindow::checkLanOn() bool OldMainWindow::checkLanOn()
{ {
BackThread *bt = new BackThread(); BackThread *bt = new BackThread();
IFace *iface = bt->execGetIface(); IFace *iface = bt->execGetIface();
@ -1266,7 +1266,7 @@ bool MainWindow::checkLanOn()
} }
} }
bool MainWindow::checkWlOn() bool OldMainWindow::checkWlOn()
{ {
BackThread *bt = new BackThread(); BackThread *bt = new BackThread();
IFace *iface = bt->execGetIface(); IFace *iface = bt->execGetIface();
@ -1283,7 +1283,7 @@ bool MainWindow::checkWlOn()
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
//有线网与无线网按钮响应 //有线网与无线网按钮响应
void MainWindow::onBtnNetClicked() void OldMainWindow::onBtnNetClicked()
{ {
if (checkLanOn()) { if (checkLanOn()) {
QThread *t = new QThread(); QThread *t = new QThread();
@ -1310,7 +1310,7 @@ void MainWindow::onBtnNetClicked()
this->startLoading(); this->startLoading();
} }
void MainWindow::onBtnWifiClicked(int flag) void OldMainWindow::onBtnWifiClicked(int flag)
{ {
qDebug()<<"Value of flag passed into function 'onBtnWifiClicked' is: "<<flag; qDebug()<<"Value of flag passed into function 'onBtnWifiClicked' is: "<<flag;
//syslog(LOG_DEBUG, "Value of flag passed into function 'onBtnWifiClicked' is: %d", flag); //syslog(LOG_DEBUG, "Value of flag passed into function 'onBtnWifiClicked' is: %d", flag);
@ -1416,7 +1416,7 @@ void MainWindow::onBtnWifiClicked(int flag)
* @brief MainWindow::onBtnLanClicked 线 * @brief MainWindow::onBtnLanClicked 线
* @param flag falg=0 0 UI关闭 1 UI打开 234线5线 * @param flag falg=0 0 UI关闭 1 UI打开 234线5线
*/ */
void MainWindow::onBtnLanClicked(int flag) void OldMainWindow::onBtnLanClicked(int flag)
{ {
switch (flag) { switch (flag) {
case 0: { case 0: {
@ -1485,7 +1485,7 @@ void MainWindow::onBtnLanClicked(int flag)
} }
} }
void MainWindow::setLanSwitchStatus(bool is_opened) void OldMainWindow::setLanSwitchStatus(bool is_opened)
{ {
if (is_opened) { if (is_opened) {
btnWired->setSwitchStatus(true); btnWired->setSwitchStatus(true);
@ -1496,7 +1496,7 @@ void MainWindow::setLanSwitchStatus(bool is_opened)
} }
} }
void MainWindow::onBtnNetListClickeds(int flag) void OldMainWindow::onBtnNetListClickeds(int flag)
{ {
this->scrollAreal->show(); this->scrollAreal->show();
topLanListWidget->constructWiredActiveConnectList(); topLanListWidget->constructWiredActiveConnectList();
@ -1510,7 +1510,7 @@ void MainWindow::onBtnNetListClickeds(int flag)
lbLoadUpImg->show(); lbLoadUpImg->show();
} }
void MainWindow::onBtnNetListClicked(int flag) void OldMainWindow::onBtnNetListClicked(int flag)
{ {
#if 0 #if 0
this->is_btnLanList_clicked = 1; this->is_btnLanList_clicked = 1;
@ -1569,7 +1569,7 @@ void MainWindow::onBtnNetListClicked(int flag)
#endif #endif
} }
void MainWindow::on_btnWifiList_clicked() void OldMainWindow::on_btnWifiList_clicked()
{ {
is_stop_check_net_state = 1; is_stop_check_net_state = 1;
current_wifi_list_state = LOAD_WIFI_LIST; current_wifi_list_state = LOAD_WIFI_LIST;
@ -1685,14 +1685,14 @@ void MainWindow::on_btnWifiList_clicked()
bt->deleteLater(); bt->deleteLater();
} }
void MainWindow::onLoadWifiListAfterScan() void OldMainWindow::onLoadWifiListAfterScan()
{ {
current_wifi_list_state = LOAD_WIFI_LIST; current_wifi_list_state = LOAD_WIFI_LIST;
this->ksnm->execGetWifiList(this->wcardname, this->isHuaWeiPC); //加载wifi列表 this->ksnm->execGetWifiList(this->wcardname, this->isHuaWeiPC); //加载wifi列表
objKyDBus->getWirelessCardName(); objKyDBus->getWirelessCardName();
} }
void MainWindow::on_wifi_changed() void OldMainWindow::on_wifi_changed()
{ {
QString actWifiUuid = objKyDBus->getActiveWifiUuid(); QString actWifiUuid = objKyDBus->getActiveWifiUuid();
objKyDBus->getConnectNetIp(actWifiUuid); objKyDBus->getConnectNetIp(actWifiUuid);
@ -1723,7 +1723,7 @@ void MainWindow::on_wifi_changed()
* @brief MainWindow::onNewConnAdded * @brief MainWindow::onNewConnAdded
* @param type 0线1线 * @param type 0线1线
*/ */
void MainWindow::onNewConnAdded(int type) { void OldMainWindow::onNewConnAdded(int type) {
if (type == 1) { if (type == 1) {
// isAddedWifi = true; // isAddedWifi = true;
} }
@ -1734,7 +1734,7 @@ void MainWindow::onNewConnAdded(int type) {
//网络列表加载与更新 //网络列表加载与更新
// 获取lan列表回调 // 获取lan列表回调
void MainWindow::getLanListDone(QStringList slist) void OldMainWindow::getLanListDone(QStringList slist)
{ {
#if 0 #if 0
if (this->is_btnWifiList_clicked == 1) { if (this->is_btnWifiList_clicked == 1) {
@ -1997,7 +1997,7 @@ void MainWindow::getLanListDone(QStringList slist)
} }
// 获取wifi列表回调 // 获取wifi列表回调
void MainWindow::onRequestRevalueUpdateWifi() void OldMainWindow::onRequestRevalueUpdateWifi()
{ {
if (!isReConnAfterTurnOnWifi) { if (!isReConnAfterTurnOnWifi) {
isReConnAfterTurnOnWifi = false; isReConnAfterTurnOnWifi = false;
@ -2007,7 +2007,7 @@ void MainWindow::onRequestRevalueUpdateWifi()
} }
// 获取wifi列表回调 // 获取wifi列表回调
void MainWindow::getWifiListDone(QStringList slist) void OldMainWindow::getWifiListDone(QStringList slist)
{ {
//要求使用上一次获取到的列表 //要求使用上一次获取到的列表
if (this->ksnm->isUseOldWifiSlist) { if (this->ksnm->isUseOldWifiSlist) {
@ -2129,7 +2129,7 @@ void MainWindow::getWifiListDone(QStringList slist)
} }
// 获取已保存的连接列表回调 // 获取已保存的连接列表回调
void MainWindow::getConnListDone(QStringList slist) void OldMainWindow::getConnListDone(QStringList slist)
{ {
if (isInitConnList) { if (isInitConnList) {
for (int i = 1; i < slist.length() - 1; i++) { for (int i = 1; i < slist.length() - 1; i++) {
@ -2227,7 +2227,7 @@ void MainWindow::getConnListDone(QStringList slist)
// return ret; // return ret;
//} //}
QStringList MainWindow::priorityList(QStringList slist){ QStringList OldMainWindow::priorityList(QStringList slist){
QStringList ret; QStringList ret;
ret.append(slist[0]); ret.append(slist[0]);
QString headLine = slist.at(0); QString headLine = slist.at(0);
@ -2281,7 +2281,7 @@ QStringList MainWindow::priorityList(QStringList slist){
return ret; return ret;
} }
QStringList MainWindow::sortApByFreq(QStringList list, int freqIndex, int signalIndex) QStringList OldMainWindow::sortApByFreq(QStringList list, int freqIndex, int signalIndex)
{ {
QStringList ret; QStringList ret;
QStringList p1,p2,p3,p4,p5,p6,p7; QStringList p1,p2,p3,p4,p5,p6,p7;
@ -2314,12 +2314,12 @@ QStringList MainWindow::sortApByFreq(QStringList list, int freqIndex, int signal
return ret; return ret;
} }
QVector<QStringList> MainWindow::repetitionFilter(QVector<QStringList>){ QVector<QStringList> OldMainWindow::repetitionFilter(QVector<QStringList>){
QVector<QStringList> ret; QVector<QStringList> ret;
return ret; return ret;
} }
QStringList MainWindow::sortApByCategory(QStringList list,int cateIndex){ QStringList OldMainWindow::sortApByCategory(QStringList list,int cateIndex){
QStringList ret; QStringList ret;
for(auto line:list){ for(auto line:list){
int conCate = line.mid(cateIndex).trimmed().toInt(); int conCate = line.mid(cateIndex).trimmed().toInt();
@ -2344,7 +2344,7 @@ QStringList MainWindow::sortApByCategory(QStringList list,int cateIndex){
//进行wifi列表优化选择分为2.4G和5G进行选择先每种频率形成一个列表 //进行wifi列表优化选择分为2.4G和5G进行选择先每种频率形成一个列表
//同一个列表中同名wifi只有一个再按信号强度由大到小合并列表 //同一个列表中同名wifi只有一个再按信号强度由大到小合并列表
void MainWindow::wifiListOptimize(QStringList& slist) void OldMainWindow::wifiListOptimize(QStringList& slist)
{ {
if (slist.size() < 2) return ; if (slist.size() < 2) return ;
@ -2442,7 +2442,7 @@ void MainWindow::wifiListOptimize(QStringList& slist)
} }
//最终优选出来的wifi列表 //最终优选出来的wifi列表
void MainWindow::getFinalWifiList(QStringList &slist) void OldMainWindow::getFinalWifiList(QStringList &slist)
{ {
if(slist.size() < 2) return ; if(slist.size() < 2) return ;
QString headLine = slist.at(0); QString headLine = slist.at(0);
@ -2508,7 +2508,7 @@ void MainWindow::getFinalWifiList(QStringList &slist)
} }
//从有配置文件的wifi选出最优wifi进行连接,同时考虑用户手动设置的优先级,这个函数在回连中用到 //从有配置文件的wifi选出最优wifi进行连接,同时考虑用户手动设置的优先级,这个函数在回连中用到
QVector<structWifiProperty> MainWindow::connectableWifiPriorityList(const QStringList slist){ QVector<structWifiProperty> OldMainWindow::connectableWifiPriorityList(const QStringList slist){
QVector<structWifiProperty> selectedWifiListStruct; QVector<structWifiProperty> selectedWifiListStruct;
if(slist.size()<2) return selectedWifiListStruct; if(slist.size()<2) return selectedWifiListStruct;
OneConnForm *ocf = new OneConnForm(); OneConnForm *ocf = new OneConnForm();
@ -2599,18 +2599,18 @@ QVector<structWifiProperty> MainWindow::connectableWifiPriorityList(const QStrin
} }
//排序 //排序
void MainWindow::devListSort(QVector<structWifiProperty> *list) void OldMainWindow::devListSort(QVector<structWifiProperty> *list)
{ {
// qSort(list->begin(), list->end(), subDevListSort); // qSort(list->begin(), list->end(), subDevListSort);
std::sort(list->begin(), list->end(), subDevListSort); std::sort(list->begin(), list->end(), subDevListSort);
} }
bool MainWindow::subDevListSort(const structWifiProperty &info1, const structWifiProperty &info2) bool OldMainWindow::subDevListSort(const structWifiProperty &info1, const structWifiProperty &info2)
{ {
return info1.priority > info2.priority; return info1.priority > info2.priority;
} }
// 加载wifi列表 // 加载wifi列表
void MainWindow::loadWifiListDone(QStringList slist) void OldMainWindow::loadWifiListDone(QStringList slist)
{ {
// qDebug() << "kkkkkkkkkkkkkkkkkkkkkkkk"; // qDebug() << "kkkkkkkkkkkkkkkkkkkkkkkk";
// foreach (QString kkkkk, slist) { // foreach (QString kkkkk, slist) {
@ -2852,7 +2852,7 @@ void MainWindow::loadWifiListDone(QStringList slist)
//qDebug() << "wifi的 bssid: " << wbssid << "当前连接的wifi的bssid: " << actWifiBssidList; //qDebug() << "wifi的 bssid: " << wbssid << "当前连接的wifi的bssid: " << actWifiBssidList;
if (actWifiBssid == wbssid && wifiActState == WIFI_CONNECTED) { if (actWifiBssid == wbssid && wifiActState == WIFI_CONNECTED) {
//对于已经连接的wifi //对于已经连接的wifi
connect(this, &MainWindow::actWifiSignalLvChanaged, ccf, [ = ](const int &signalLv) { connect(this, &OldMainWindow::actWifiSignalLvChanaged, ccf, [ = ](const int &signalLv) {
ccf->setSignal(QString::number(signalLv), wsecu, wcate, true); ccf->setSignal(QString::number(signalLv), wsecu, wcate, true);
}); });
connect(ccf, SIGNAL(selectedOneWifiForm(QString,int)), this, SLOT(oneTopWifiFormSelected(QString,int))); connect(ccf, SIGNAL(selectedOneWifiForm(QString,int)), this, SLOT(oneTopWifiFormSelected(QString,int)));
@ -3006,7 +3006,7 @@ void MainWindow::loadWifiListDone(QStringList slist)
} }
// 更新wifi列表 // 更新wifi列表
void MainWindow::updateWifiListDone(QStringList slist) void OldMainWindow::updateWifiListDone(QStringList slist)
{ {
qDebug()<<"Refreshed wifi list."; qDebug()<<"Refreshed wifi list.";
if (hasWifiConnected) { if (hasWifiConnected) {
@ -3208,7 +3208,7 @@ void MainWindow::updateWifiListDone(QStringList slist)
} }
//用于中英文系统有线网络名称国际话 //用于中英文系统有线网络名称国际话
QString MainWindow::TranslateLanName(QString lanName) QString OldMainWindow::TranslateLanName(QString lanName)
{ {
QString returnLanName = lanName; QString returnLanName = lanName;
@ -3252,7 +3252,7 @@ QString MainWindow::TranslateLanName(QString lanName)
} }
//使用uuid获取对应的mac地址 //使用uuid获取对应的mac地址
QString MainWindow::getMacByUuid(QString uuidName) QString OldMainWindow::getMacByUuid(QString uuidName)
{ {
QString resultMac = ""; QString resultMac = "";
@ -3279,7 +3279,7 @@ QString MainWindow::getMacByUuid(QString uuidName)
return resultMac; return resultMac;
} }
void MainWindow::checkIfConnectedWifiExist() void OldMainWindow::checkIfConnectedWifiExist()
{ {
//在点击托盘图标时判读有无wifi的连接若wstate不为0但是有wifi连接就断开 //在点击托盘图标时判读有无wifi的连接若wstate不为0但是有wifi连接就断开
BackThread *bt = new BackThread(); BackThread *bt = new BackThread();
@ -3293,7 +3293,7 @@ void MainWindow::checkIfConnectedWifiExist()
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
//主窗口其他按钮点击响应 //主窗口其他按钮点击响应
void MainWindow::on_btnAdvConf_clicked() void OldMainWindow::on_btnAdvConf_clicked()
{ {
// if (!kysec_is_disabled() && kysec_get_3adm_status()) { // if (!kysec_is_disabled() && kysec_get_3adm_status()) {
// //三权分立启用的操作 // //三权分立启用的操作
@ -3317,7 +3317,7 @@ void MainWindow::on_btnAdvConf_clicked()
return; return;
} }
void MainWindow::on_btnFlyMode_clicked() void OldMainWindow::on_btnFlyMode_clicked()
{ {
if (is_fly_mode_on == 0) { if (is_fly_mode_on == 0) {
is_fly_mode_on = 1; is_fly_mode_on = 1;
@ -3329,7 +3329,7 @@ void MainWindow::on_btnFlyMode_clicked()
} }
} }
void MainWindow::on_btnHotspot_clicked() void OldMainWindow::on_btnHotspot_clicked()
{ {
if (is_wireless_adapter_ready == 1) { if (is_wireless_adapter_ready == 1) {
if (is_hot_sopt_on == 0) { if (is_hot_sopt_on == 0) {
@ -3354,7 +3354,7 @@ void MainWindow::on_btnHotspot_clicked()
} }
} }
void MainWindow::onBtnAddNetClicked() void OldMainWindow::onBtnAddNetClicked()
{ {
QApplication::setQuitOnLastWindowClosed(false); QApplication::setQuitOnLastWindowClosed(false);
DlgHideWifi *connHidWifi = new DlgHideWifi(0, this); DlgHideWifi *connHidWifi = new DlgHideWifi(0, this);
@ -3362,7 +3362,7 @@ void MainWindow::onBtnAddNetClicked()
connHidWifi->show(); connHidWifi->show();
} }
void MainWindow::onBtnCreateNetClicked() void OldMainWindow::onBtnCreateNetClicked()
{ {
QPoint pos = QCursor::pos(); QPoint pos = QCursor::pos();
QRect primaryGeometry; QRect primaryGeometry;
@ -3384,7 +3384,7 @@ void MainWindow::onBtnCreateNetClicked()
} }
/* 右键菜单打开网络设置界面 */ /* 右键菜单打开网络设置界面 */
void MainWindow::actionTriggerSlots() void OldMainWindow::actionTriggerSlots()
{ {
if (!m_load_finished) { if (!m_load_finished) {
m_secondary_start_timer->stop(); m_secondary_start_timer->stop();
@ -3404,7 +3404,7 @@ void MainWindow::actionTriggerSlots()
//处理窗口变化、网络状态变化 //处理窗口变化、网络状态变化
//列表中item的扩展与收缩 //列表中item的扩展与收缩
void MainWindow::oneLanFormSelected(QString lanName, QString uniqueName) void OldMainWindow::oneLanFormSelected(QString lanName, QString uniqueName)
{ {
if (currSelNetName == uniqueName) { if (currSelNetName == uniqueName) {
return; return;
@ -3492,7 +3492,7 @@ void MainWindow::oneLanFormSelected(QString lanName, QString uniqueName)
#endif #endif
} }
void MainWindow::oneTopLanFormSelected(QString lanName, QString uniqueName) void OldMainWindow::oneTopLanFormSelected(QString lanName, QString uniqueName)
{ {
#if 0 #if 0
//应设计要求,选中同一选项卡不再缩小 //应设计要求,选中同一选项卡不再缩小
@ -3569,7 +3569,7 @@ void MainWindow::oneTopLanFormSelected(QString lanName, QString uniqueName)
#endif #endif
} }
void MainWindow::oneWifiFormSelected(QString wifibssid, int extendLength) void OldMainWindow::oneWifiFormSelected(QString wifibssid, int extendLength)
{ {
if (currSelNetName == wifibssid) { if (currSelNetName == wifibssid) {
//与win逻辑一致点击同一选项不再缩小选项卡 //与win逻辑一致点击同一选项不再缩小选项卡
@ -3676,7 +3676,7 @@ void MainWindow::oneWifiFormSelected(QString wifibssid, int extendLength)
OneConnForm *ocf = topWifiList.at(0); OneConnForm *ocf = topWifiList.at(0);
ocf->setTopItem(false); ocf->setTopItem(false);
} }
void MainWindow::oneTopWifiFormSelected(QString wifibssid, int extendLength) void OldMainWindow::oneTopWifiFormSelected(QString wifibssid, int extendLength)
{ {
//应设计师要求,此处展开后点击不再收起 //应设计师要求,此处展开后点击不再收起
if (currSelNetName == wifibssid) return; if (currSelNetName == wifibssid) return;
@ -3719,7 +3719,7 @@ void MainWindow::oneTopWifiFormSelected(QString wifibssid, int extendLength)
} }
//断开网络处理 //断开网络处理
void MainWindow::handleLanDisconn() void OldMainWindow::handleLanDisconn()
{ {
//syslog(LOG_DEBUG, "Wired net is disconnected"); //syslog(LOG_DEBUG, "Wired net is disconnected");
qDebug()<<"Wired net is disconnected!"; qDebug()<<"Wired net is disconnected!";
@ -3734,7 +3734,7 @@ void MainWindow::handleLanDisconn()
this->ksnm->execGetLanList(); this->ksnm->execGetLanList();
} }
void MainWindow::handleWifiDisconn() void OldMainWindow::handleWifiDisconn()
{ {
hasWifiConnected = false; hasWifiConnected = false;
currSelNetName = ""; currSelNetName = "";
@ -3743,7 +3743,7 @@ void MainWindow::handleWifiDisconn()
handleWifiDisconnLoading(); handleWifiDisconnLoading();
}); });
} }
void MainWindow::handleWifiDisconnLoading() void OldMainWindow::handleWifiDisconnLoading()
{ {
//syslog(LOG_DEBUG, "WLAN is disconnected"); //syslog(LOG_DEBUG, "WLAN is disconnected");
qDebug()<<"WLAN is disconnected!"; qDebug()<<"WLAN is disconnected!";
@ -3755,7 +3755,7 @@ void MainWindow::handleWifiDisconnLoading()
} }
//网络开关处理,打开与关闭网络 //网络开关处理,打开与关闭网络
void MainWindow::enNetDone() void OldMainWindow::enNetDone()
{ {
BackThread *bt = new BackThread(); BackThread *bt = new BackThread();
mwBandWidth = bt->execChkLanWidth(lcardname); mwBandWidth = bt->execChkLanWidth(lcardname);
@ -3771,7 +3771,7 @@ void MainWindow::enNetDone()
qDebug()<<"debug: already turn on the switch of lan network"; qDebug()<<"debug: already turn on the switch of lan network";
//syslog(LOG_DEBUG, "Already turn on the switch of lan network"); //syslog(LOG_DEBUG, "Already turn on the switch of lan network");
} }
void MainWindow::disNetDone() void OldMainWindow::disNetDone()
{ {
this->is_btnLanList_clicked = 1; this->is_btnLanList_clicked = 1;
this->is_btnWifiList_clicked = 0; this->is_btnWifiList_clicked = 0;
@ -3820,7 +3820,7 @@ void MainWindow::disNetDone()
this->stopLoading(); this->stopLoading();
} }
void MainWindow::enWifiDone() void OldMainWindow::enWifiDone()
{ {
if (isHuaWeiPC) { if (isHuaWeiPC) {
//这里先不做什么因为onRfkillStatusChanged这个函数也在处理wifi开关 //这里先不做什么因为onRfkillStatusChanged这个函数也在处理wifi开关
@ -3835,7 +3835,7 @@ void MainWindow::enWifiDone()
//syslog(LOG_DEBUG, "Already turn on the switch of wifi network"); //syslog(LOG_DEBUG, "Already turn on the switch of wifi network");
} }
} }
void MainWindow::disWifiDone() void OldMainWindow::disWifiDone()
{ {
if (isHuaWeiPC) { if (isHuaWeiPC) {
//这里先不做什么因为onRfkillStatusChanged这个函数也在处理wifi开关 //这里先不做什么因为onRfkillStatusChanged这个函数也在处理wifi开关
@ -3847,7 +3847,7 @@ void MainWindow::disWifiDone()
//syslog(LOG_DEBUG, "Already turn on the switch of wifi network"); //syslog(LOG_DEBUG, "Already turn on the switch of wifi network");
} }
} }
void MainWindow::disWifiStateKeep() void OldMainWindow::disWifiStateKeep()
{ {
if (this->is_btnLanList_clicked == 1) { if (this->is_btnLanList_clicked == 1) {
btnWireless->setSwitchStatus(false); btnWireless->setSwitchStatus(false);
@ -3857,7 +3857,7 @@ void MainWindow::disWifiStateKeep()
getActiveInfoAndSetTrayIcon(); getActiveInfoAndSetTrayIcon();
} }
} }
void MainWindow::disWifiDoneChangeUI() void OldMainWindow::disWifiDoneChangeUI()
{ {
wifiListWidget = new QWidget(scrollAreaw); wifiListWidget = new QWidget(scrollAreaw);
wifiListWidget->resize(W_LIST_WIDGET, H_WIFI_ITEM_BIG_EXTEND); wifiListWidget->resize(W_LIST_WIDGET, H_WIFI_ITEM_BIG_EXTEND);
@ -3899,7 +3899,7 @@ void MainWindow::disWifiDoneChangeUI()
this->scrollAreaw->show(); this->scrollAreaw->show();
} }
void MainWindow::on_btnHotspotState() void OldMainWindow::on_btnHotspotState()
{ {
ui->lbHotImg->setStyleSheet("QLabel{background-image:url(:/res/x/hot-spot-off.svg);}"); ui->lbHotImg->setStyleSheet("QLabel{background-image:url(:/res/x/hot-spot-off.svg);}");
ui->lbHotBG->setStyleSheet(btnOffQss); ui->lbHotBG->setStyleSheet(btnOffQss);
@ -3907,7 +3907,7 @@ void MainWindow::on_btnHotspotState()
} }
//执行wifi的重新连接 //执行wifi的重新连接
void MainWindow::toReconnectWifi() void OldMainWindow::toReconnectWifi()
{ {
if (ifCanReconnectWifiNow) { if (ifCanReconnectWifiNow) {
if (isHuaWeiPC) { if (isHuaWeiPC) {
@ -3922,7 +3922,7 @@ void MainWindow::toReconnectWifi()
} }
//处理外界对网络的连接与断开 //处理外界对网络的连接与断开
void MainWindow::onExternalConnectionChange(QString type, bool isConnUp) void OldMainWindow::onExternalConnectionChange(QString type, bool isConnUp)
{ {
isReconnectingWifi = false; isReconnectingWifi = false;
@ -4008,7 +4008,7 @@ void MainWindow::onExternalConnectionChange(QString type, bool isConnUp)
} }
} }
void MainWindow::onExternalLanChange() void OldMainWindow::onExternalLanChange()
{ {
emit this->actWiredConnectionChanged(); emit this->actWiredConnectionChanged();
if (is_btnLanList_clicked) { if (is_btnLanList_clicked) {
@ -4020,7 +4020,7 @@ void MainWindow::onExternalLanChange()
isToSetLanValue = true; isToSetLanValue = true;
} }
void MainWindow::onExternalWifiChange() void OldMainWindow::onExternalWifiChange()
{ {
// if (!isWifiBeConnUp) { // if (!isWifiBeConnUp) {
// //QString txt(tr("WiFi already disconnect")); // //QString txt(tr("WiFi already disconnect"));
@ -4045,17 +4045,17 @@ void MainWindow::onExternalWifiChange()
isToSetWifiValue = true; isToSetWifiValue = true;
} }
void MainWindow::onToSetTrayIcon() void OldMainWindow::onToSetTrayIcon()
{ {
getActiveInfoAndSetTrayIcon(); getActiveInfoAndSetTrayIcon();
} }
void MainWindow::onToResetValue() void OldMainWindow::onToResetValue()
{ {
addNumberForWifi = 0; addNumberForWifi = 0;
} }
void MainWindow::onWifiSwitchChange() void OldMainWindow::onWifiSwitchChange()
{ {
if (is_btnWifiList_clicked) { if (is_btnWifiList_clicked) {
//this->ksnm->execGetWifiList(); //this->ksnm->execGetWifiList();
@ -4064,7 +4064,7 @@ void MainWindow::onWifiSwitchChange()
} }
//处理外界对wifi开关的打开与关闭 //处理外界对wifi开关的打开与关闭
void MainWindow::onExternalWifiSwitchChange(bool wifiEnabled) void OldMainWindow::onExternalWifiSwitchChange(bool wifiEnabled)
{ {
if (!is_stop_check_net_state) { if (!is_stop_check_net_state) {
is_stop_check_net_state = 1; is_stop_check_net_state = 1;
@ -4086,7 +4086,7 @@ void MainWindow::onExternalWifiSwitchChange(bool wifiEnabled)
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
//循环处理部分目前仅on_checkWifiListChanged 与on_setNetSpeed两个函数在运行 //循环处理部分目前仅on_checkWifiListChanged 与on_setNetSpeed两个函数在运行
void MainWindow::onRequestScanAccesspoint() void OldMainWindow::onRequestScanAccesspoint()
{ {
if (isHuaWeiPC) { if (isHuaWeiPC) {
numberForWifiScan += 1; numberForWifiScan += 1;
@ -4153,7 +4153,7 @@ void MainWindow::onRequestScanAccesspoint()
} }
} }
void MainWindow::toScanWifi(bool isShow) void OldMainWindow::toScanWifi(bool isShow)
{ {
QtConcurrent::run([=](){ QtConcurrent::run([=](){
BackThread *loop_bt = new BackThread(); BackThread *loop_bt = new BackThread();
@ -4182,19 +4182,19 @@ void MainWindow::toScanWifi(bool isShow)
}); });
} }
void MainWindow::onRefreshWifiListAfterScan() void OldMainWindow::onRefreshWifiListAfterScan()
{ {
current_wifi_list_state = REFRESH_WIFI; current_wifi_list_state = REFRESH_WIFI;
this->ksnm->execGetWifiList(this->wcardname, this->isHuaWeiPC); //更新wifi列表 this->ksnm->execGetWifiList(this->wcardname, this->isHuaWeiPC); //更新wifi列表
} }
void MainWindow::onRequestReconnecWifi() void OldMainWindow::onRequestReconnecWifi()
{ {
qDebug() << "Receive request reconnect wifi signal, then to reconnect wifi"; qDebug() << "Receive request reconnect wifi signal, then to reconnect wifi";
toReconnectWifi(); toReconnectWifi();
} }
void MainWindow::on_setNetSpeeds(qulonglong rx, qulonglong tx) void OldMainWindow::on_setNetSpeeds(qulonglong rx, qulonglong tx)
{ {
long int delta_rcv = rx/1024; long int delta_rcv = rx/1024;
long int delta_tx = tx/1024; long int delta_tx = tx/1024;
@ -4244,7 +4244,7 @@ void MainWindow::on_setNetSpeeds(qulonglong rx, qulonglong tx)
return; return;
} }
void MainWindow::on_setNetSpeed() void OldMainWindow::on_setNetSpeed()
{ {
if (this->isVisible() && is_stop_check_net_state==0) { if (this->isVisible() && is_stop_check_net_state==0) {
if (is_btnWifiList_clicked == 1) { if (is_btnWifiList_clicked == 1) {
@ -4316,7 +4316,7 @@ void MainWindow::on_setNetSpeed()
} }
} }
void MainWindow::connLanDone(int connFlag) void OldMainWindow::connLanDone(int connFlag)
{ {
emit this->waitLanStop(); //停止加载动画 emit this->waitLanStop(); //停止加载动画
@ -4411,7 +4411,7 @@ void MainWindow::connLanDone(int connFlag)
this->is_stop_check_net_state = 0; this->is_stop_check_net_state = 0;
} }
void MainWindow::connWifiDone(int connFlag) void OldMainWindow::connWifiDone(int connFlag)
{ {
// Wifi连接结果0点击连接成功 1失败 2没有配置文件 3开机启动网络工具时已经连接 4密码错误 5找不到已保存的网络 // Wifi连接结果0点击连接成功 1失败 2没有配置文件 3开机启动网络工具时已经连接 4密码错误 5找不到已保存的网络
if (connFlag == 0) { if (connFlag == 0) {
@ -4463,13 +4463,13 @@ void MainWindow::connWifiDone(int connFlag)
is_stop_check_net_state = 0; is_stop_check_net_state = 0;
} }
void MainWindow::onRequestRefreshWifiList() void OldMainWindow::onRequestRefreshWifiList()
{ {
this->ksnm->execGetWifiList(this->wcardname, this->isHuaWeiPC); this->ksnm->execGetWifiList(this->wcardname, this->isHuaWeiPC);
} }
//重新绘制背景色 //重新绘制背景色
void MainWindow::paintEvent(QPaintEvent *event) void OldMainWindow::paintEvent(QPaintEvent *event)
{ {
double trans = objKyDBus->getTransparentData(); double trans = objKyDBus->getTransparentData();
@ -4485,7 +4485,7 @@ void MainWindow::paintEvent(QPaintEvent *event)
QWidget::paintEvent(event); QWidget::paintEvent(event);
} }
bool MainWindow::event(QEvent *event) bool OldMainWindow::event(QEvent *event)
{ {
if (event->type() == QEvent::ActivationChange) { if (event->type() == QEvent::ActivationChange) {
if (QApplication::activeWindow() != this) { if (QApplication::activeWindow() != this) {
@ -4499,7 +4499,7 @@ bool MainWindow::event(QEvent *event)
} }
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
QPixmap MainWindow::drawSymbolicColoredPixmap(const QPixmap &source) QPixmap OldMainWindow::drawSymbolicColoredPixmap(const QPixmap &source)
{ {
QColor gray(128,128,128); QColor gray(128,128,128);
QColor standard (31,32,34); QColor standard (31,32,34);
@ -4527,7 +4527,7 @@ QPixmap MainWindow::drawSymbolicColoredPixmap(const QPixmap &source)
return QPixmap::fromImage(img); return QPixmap::fromImage(img);
} }
QPixmap MainWindow::drawSymbolicBlackColoredPixmap(const QPixmap &source) QPixmap OldMainWindow::drawSymbolicBlackColoredPixmap(const QPixmap &source)
{ {
QImage img = source.toImage(); QImage img = source.toImage();
for (int x = 0; x < img.width(); x++) { for (int x = 0; x < img.width(); x++) {
@ -4546,7 +4546,7 @@ QPixmap MainWindow::drawSymbolicBlackColoredPixmap(const QPixmap &source)
return QPixmap::fromImage(img); return QPixmap::fromImage(img);
} }
const QPixmap MainWindow::loadSvg(const QString &fileName, const int size) const QPixmap OldMainWindow::loadSvg(const QString &fileName, const int size)
{ {
QPixmap pixmap(size, size); QPixmap pixmap(size, size);
QSvgRenderer renderer(fileName); QSvgRenderer renderer(fileName);
@ -4560,7 +4560,7 @@ const QPixmap MainWindow::loadSvg(const QString &fileName, const int size)
return pixmap; return pixmap;
} }
void MainWindow::getSystemFontFamily() void OldMainWindow::getSystemFontFamily()
{ {
qDebug()<<"Init Font Gsettings..."; qDebug()<<"Init Font Gsettings...";
const QByteArray id("org.ukui.style"); const QByteArray id("org.ukui.style");
@ -4578,7 +4578,7 @@ void MainWindow::getSystemFontFamily()
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
//解决双屏幕问题用到的dbus方法 //解决双屏幕问题用到的dbus方法
void MainWindow::PrimaryManager() void OldMainWindow::PrimaryManager()
{ {
qDebug()<<"Init primary settings..."; qDebug()<<"Init primary settings...";
//QDBusConnection conn = QDBusConnection::sessionBus(); //QDBusConnection conn = QDBusConnection::sessionBus();
@ -4616,7 +4616,7 @@ void MainWindow::PrimaryManager()
this, SLOT(priScreenChanged(int,int,int,int))); this, SLOT(priScreenChanged(int,int,int,int)));
} }
void MainWindow::toStart() void OldMainWindow::toStart()
{ {
qDebug()<<"Init geometry..."; qDebug()<<"Init geometry...";
m_priX = getScreenGeometry("x"); m_priX = getScreenGeometry("x");
@ -4634,7 +4634,7 @@ void MainWindow::toStart()
//qDebug("Start: Primary screen geometry is x=%d, y=%d, windth=%d, height=%d", m_priX, m_priY, m_priWid, m_priHei); //qDebug("Start: Primary screen geometry is x=%d, y=%d, windth=%d, height=%d", m_priX, m_priY, m_priWid, m_priHei);
} }
int MainWindow::getScreenGeometry(QString methodName) int OldMainWindow::getScreenGeometry(QString methodName)
{ {
int res = 0; int res = 0;
QDBusMessage message = QDBusMessage::createMethodCall(DBUS_NAME, QDBusMessage message = QDBusMessage::createMethodCall(DBUS_NAME,
@ -4656,7 +4656,7 @@ int MainWindow::getScreenGeometry(QString methodName)
return res; return res;
} }
void MainWindow::requestRefreshWifiList() void OldMainWindow::requestRefreshWifiList()
{ {
if (isHuaWeiPC) { if (isHuaWeiPC) {
QtConcurrent::run([=](){ QtConcurrent::run([=](){
@ -4673,7 +4673,7 @@ void MainWindow::requestRefreshWifiList()
} }
/* get primary screen changed */ /* get primary screen changed */
void MainWindow::priScreenChanged(int x, int y, int width, int height) void OldMainWindow::priScreenChanged(int x, int y, int width, int height)
{ {
m_priX = x; m_priX = x;
m_priY = y; m_priY = y;
@ -4684,7 +4684,7 @@ void MainWindow::priScreenChanged(int x, int y, int width, int height)
} }
// 通过kds的dbus发现rfkill状态变化 // 通过kds的dbus发现rfkill状态变化
void MainWindow::onRfkillStatusChanged() void OldMainWindow::onRfkillStatusChanged()
{ {
if (canExecHandleWifiSwitchChange) { if (canExecHandleWifiSwitchChange) {
canExecHandleWifiSwitchChange = false; canExecHandleWifiSwitchChange = false;
@ -4741,7 +4741,7 @@ void MainWindow::onRfkillStatusChanged()
} }
//wifi开关关闭 //wifi开关关闭
void MainWindow::rfkillDisableWifiDone() void OldMainWindow::rfkillDisableWifiDone()
{ {
canExecHandleWifiSwitchChange = true; canExecHandleWifiSwitchChange = true;
if (is_btnWifiList_clicked) if (is_btnWifiList_clicked)
@ -4755,7 +4755,7 @@ void MainWindow::rfkillDisableWifiDone()
} }
//wifi开关打开 //wifi开关打开
void MainWindow::rfkillEnableWifiDone() void OldMainWindow::rfkillEnableWifiDone()
{ {
canExecHandleWifiSwitchChange = true; canExecHandleWifiSwitchChange = true;
if (is_btnWifiList_clicked) { if (is_btnWifiList_clicked) {
@ -4778,7 +4778,7 @@ void MainWindow::rfkillEnableWifiDone()
} }
} }
void MainWindow::showPb(QString type, QString name) void OldMainWindow::showPb(QString type, QString name)
{ {
bShowPb = false; bShowPb = false;
if (type != "wifi") { if (type != "wifi") {

View File

@ -123,13 +123,13 @@ namespace Ui {
class MainWindow; class MainWindow;
} }
class MainWindow : public QMainWindow class OldMainWindow : public QMainWindow
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit MainWindow(QWidget *parent = 0); explicit OldMainWindow(QWidget *parent = 0);
~MainWindow(); ~OldMainWindow();
void justShowTrayIcon(); void justShowTrayIcon();

View File

@ -0,0 +1,307 @@
#include "new-mainwindow.h"
#include "customstyle.h"
#include "lanpage.h"
#include "wlanpage.h"
#include <KWindowEffects>
#include <QApplication>
#include <QDebug>
#include <QDBusReply>
#include <QKeyEvent>
#include <QProcess>
#define MAINWINDOW_WIDTH 420
#define MAINWINDOW_HEIGHT 456
#define THEME_SCHAME "org.ukui.style"
#define COLOR_THEME "styleName"
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
{
firstlyStart();
}
/**
* @brief MainWindow::showMainwindow show主窗口dbus接口提供给外部组件调用
*/
void MainWindow::showMainwindow()
{
if (!m_loadFinished) {
m_secondaryStartTimer->stop();
secondaryStart();
}
this->resetWindowPosition();
this->showNormal();
this->raise();
this->activateWindow();
}
/**
* @brief MainWindow::hideMainwindow
*/
void MainWindow::hideMainwindow()
{
this->hide();
}
/**
* @brief MainWindow::firstlyStart
*/
void MainWindow::firstlyStart()
{
initWindowProperties();
initUI();
initWindowTheme();
initTrayIcon();
installEventFilter(this);
m_secondaryStartTimer = new QTimer(this);
connect(m_secondaryStartTimer, &QTimer::timeout, this, [ = ]() {
m_secondaryStartTimer->stop();
secondaryStart();//满足条件后执行比较耗时的二级启动
});
m_secondaryStartTimer->start(5 * 1000);
}
/**
* @brief MainWindow::secondaryStart
*/
void MainWindow::secondaryStart()
{
if (m_loadFinished)
return;
m_loadFinished = true;
}
/**
* @brief MainWindow::initWindowProperties
*/
void MainWindow::initWindowProperties()
{
this->setAttribute(Qt::WA_TranslucentBackground, true);
this->setWindowTitle(tr("kylin-nm"));
this->setWindowIcon(QIcon::fromTheme("kylin-network", QIcon(":/res/x/setup.png")));
//绘制毛玻璃特效
this->setFixedSize(MAINWINDOW_WIDTH, MAINWINDOW_HEIGHT);
QPainterPath path;
auto rect = this->rect();
path.addRoundedRect(rect, 6, 6);
KWindowEffects::enableBlurBehind(this->winId(), true, QRegion(path.toFillPolygon().toPolygon()));
}
/**
* @brief MainWindow::initUI
*/
void MainWindow::initUI()
{
m_centralWidget = new QTabWidget(this);
this->setCentralWidget(m_centralWidget);
m_centralWidget->tabBar()->setFixedWidth(this->width());
LanPage * m_lanWidget = new LanPage(m_centralWidget);
WlanPage * m_wlanWidget = new WlanPage(m_centralWidget);
m_centralWidget->addTab(m_lanWidget, QIcon::fromTheme("network-wired-connected-symbolic", QIcon::fromTheme("network-wired-symbolic", QIcon(":/res/l/network-online.svg"))), tr("LAN"));
m_centralWidget->addTab(m_wlanWidget, QIcon::fromTheme("network-wireless-signal-excellent-symbolic", QIcon(":/res/x/wifi-list-bg.svg")), tr("WLAN"));
}
/**
* @brief MainWindow::initTrayIcon
*/
void MainWindow::initTrayIcon()
{
m_trayIcon = new QSystemTrayIcon();
m_trayIconMenu = new QMenu();
m_showMainwindowAction = new QAction(tr("Show MainWindow"),this);
m_showSettingsAction = new QAction(tr("Settings"),this);
m_trayIcon->setToolTip(QString(tr("kylin-nm")));
m_showSettingsAction->setIcon(QIcon::fromTheme("document-page-setup-symbolic", QIcon(":/res/x/setup.png")) );
m_trayIconMenu->addAction(m_showMainwindowAction);
m_trayIconMenu->addAction(m_showSettingsAction);
m_trayIcon->setContextMenu(m_trayIconMenu);
m_trayIcon->setIcon(QIcon::fromTheme("network-wireless-signal-excellent-symbolic"));
connect(m_trayIcon, &QSystemTrayIcon::activated, this, &MainWindow::onTrayIconActivated);
connect(m_showMainwindowAction, &QAction::triggered, this, &MainWindow::onShowMainwindowActionTriggled);
connect(m_showSettingsAction, &QAction::triggered, this, &MainWindow::onShowSettingsActionTriggled);
m_trayIcon->show();
}
/**
* @brief MainWindow::resetWindowPosition
*/
void MainWindow::resetWindowPosition()
{
#define MARGIN 4
#define PANEL_TOP 1
#define PANEL_LEFT 2
#define PANEL_RIGHT 3
//#define PANEL_BOTTOM 4
if (!m_positionInterface) {
m_positionInterface = new QDBusInterface("org.ukui.panel",
"/panel/position",
"org.ukui.panel",
QDBusConnection::sessionBus());
}
QDBusReply<QVariantList> reply = m_positionInterface->call("GetPrimaryScreenGeometry");
//reply获取的参数共5个分别是 主屏可用区域的起点x坐标主屏可用区域的起点y坐标主屏可用区域的宽度主屏可用区域高度任务栏位置
if (!m_positionInterface->isValid() || !reply.isValid() || reply.value().size() < 5) {
qCritical() << QDBusConnection::sessionBus().lastError().message();
this->setGeometry(0, 0, this->width(), this->height());
return;
}
QVariantList position_list = reply.value();
int position = position_list.at(4).toInt();
switch(position){
case PANEL_TOP:
//任务栏位于上方
this->setGeometry(position_list.at(0).toInt() + position_list.at(2).toInt() - this->width() - MARGIN,
position_list.at(1).toInt() + MARGIN,
this->width(), this->height());
break;
//任务栏位于左边
case PANEL_LEFT:
this->setGeometry(position_list.at(0).toInt() + MARGIN,
position_list.at(1).toInt() + reply.value().at(3).toInt() - this->height() - MARGIN,
this->width(), this->height());
break;
//任务栏位于右边
case PANEL_RIGHT:
this->setGeometry(position_list.at(0).toInt() + position_list.at(2).toInt() - this->width() - MARGIN,
position_list.at(1).toInt() + reply.value().at(3).toInt() - this->height() - MARGIN,
this->width(), this->height());
break;
//任务栏位于下方
default:
this->setGeometry(position_list.at(0).toInt() + position_list.at(2).toInt() - this->width() - MARGIN,
position_list.at(1).toInt() + reply.value().at(3).toInt() - this->height() - MARGIN,
this->width(), this->height());
break;
}
qDebug() << " Position of ukui-panel is " << position << "; Position of mainwindow is " << this->geometry() << "." << Q_FUNC_INFO << __LINE__;
}
/**
* @brief MainWindow::resetTrayIconTool tooltip
*/
void MainWindow::resetTrayIconTool()
{
//ZJP_TODO 检测当前连接的是有线还是无线是否可用设置图标和tooltip,图标最好提前define
// int connectivity = objKyDBus->getNetworkConectivity();
// qDebug() << "Value of current network Connectivity property : "<< connectivity;
// switch (connectivity) {
// case UnknownConnectivity:
// case Portal:
// case Limited:
// setTrayIcon(iconLanOnlineNoInternet);
// trayIcon->setToolTip(QString(tr("Network Connected But Can Not Access Internet")));
// break;
// case NoConnectivity:
// case Full:
// setTrayIcon(iconLanOnline);
// trayIcon->setToolTip(QString(tr("kylin-nm")));
// break;
// }
qDebug() << "Has set tray icon to be XXX." << Q_FUNC_INFO << __LINE__;
}
/**
* @brief MainWindow::initWindowTheme
*/
void MainWindow::initWindowTheme()
{
const QByteArray style_id(THEME_SCHAME);
if (QGSettings::isSchemaInstalled(style_id)) {
m_styleGsettings = new QGSettings(style_id);
resetWindowTheme();
connect(m_styleGsettings, &QGSettings::changed, this, &MainWindow::onThemeChanged);
} else {
qWarning() << "Gsettings interface \"org.ukui.style\" is not exist!" << Q_FUNC_INFO << __LINE__;
}
}
/**
* @brief MainWindow::resetWindowTheme
*/
void MainWindow::resetWindowTheme()
{
if (!m_styleGsettings) { return; }
QString currentTheme = m_styleGsettings->get(COLOR_THEME).toString();
auto app = static_cast<QApplication*>(QCoreApplication::instance());
if(currentTheme == "ukui-dark" || currentTheme == "ukui-black"){
app->setStyle(new CustomStyle("ukui-dark"));
qDebug() << "Has set color theme to ukui-dark." << Q_FUNC_INFO << __LINE__;
return;
}
app->setStyle(new CustomStyle("ukui-light"));
qDebug() << "Has set color theme to ukui-light." << Q_FUNC_INFO << __LINE__;
return;
}
/**
* @brief MainWindow::showControlCenter
*/
void MainWindow::showControlCenter()
{
QProcess process;
process.startDetached("ukui-control-center --netconnect");
}
/**
* @brief MainWindow::onTrayIconActivated
*/
void MainWindow::onTrayIconActivated()
{
if (this->isVisible()) {
qDebug() << "Received signal of tray icon activated, will hide mainwindow." << Q_FUNC_INFO << __LINE__;
hideMainwindow();
return;
}
qDebug() << "Received signal of tray icon activated, will show mainwindow." << Q_FUNC_INFO << __LINE__;
this->showMainwindow();
}
void MainWindow::onShowMainwindowActionTriggled()
{
showMainwindow();
}
void MainWindow::onShowSettingsActionTriggled()
{
showControlCenter();
}
void MainWindow::onThemeChanged(const QString &key)
{
if (key == COLOR_THEME) {
qDebug() << "Received signal of theme changed, will reset theme." << Q_FUNC_INFO << __LINE__;
resetWindowTheme();
} else {
qDebug() << "Received signal of theme changed, key=" << key << " will do nothing." << Q_FUNC_INFO << __LINE__;
}
}
/**
* @brief MainWindow::keyPressEvent esc键关闭主界面
* @param event
*/
void MainWindow::keyPressEvent(QKeyEvent *event)
{
if (event->key() == Qt::Key_Escape) {
hideMainwindow();
}
return QWidget::keyPressEvent(event);
}
/**
* @brief MainWindow::eventFilter
* @param watched
* @param event
* @return
*/
bool MainWindow::eventFilter(QObject *watched, QEvent *event)
{
if (event->type() == QEvent::ActivationChange) {
if(QApplication::activeWindow() != this) {
hideMainwindow();
}
}
return QMainWindow::eventFilter(watched,event);
}

View File

@ -0,0 +1,65 @@
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <QTableWidget>
#include <QGSettings/QGSettings>
#include <QTimer>
#include <QSystemTrayIcon>
#include <QMenu>
#include <QAction>
#include <QDBusInterface>
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = nullptr);
void showMainwindow();
void hideMainwindow();
signals:
public slots:
protected:
void keyPressEvent(QKeyEvent *event);
bool eventFilter(QObject *watched, QEvent *event) override;
private:
void firstlyStart(); //一级启动
void secondaryStart(); //二级启动
bool m_loadFinished = false; //是否二级启动已执行完
QTimer * m_secondaryStartTimer = nullptr; //执行二级启动的倒计时
void initWindowProperties();
void initUI();
void initTrayIcon();
void resetTrayIconTool();
void initWindowTheme();
void resetWindowTheme();
void showControlCenter();
//主窗口的主要构成控件
QTabWidget * m_centralWidget = nullptr;
//监听主题的Gsettings
QGSettings * m_styleGsettings = nullptr;
//获取和重置窗口位置
void resetWindowPosition();
QDBusInterface * m_positionInterface = nullptr;
//托盘图标,托盘图标右键菜单
QSystemTrayIcon * m_trayIcon = nullptr;
QMenu * m_trayIconMenu = nullptr;
QAction * m_showMainwindowAction = nullptr;
QAction * m_showSettingsAction = nullptr;
private slots:
void onTrayIconActivated();
void onShowMainwindowActionTriggled();
void onShowSettingsActionTriggled();
void onThemeChanged(const QString &key);
};
#endif // MAINWINDOW_H

View File

@ -0,0 +1,94 @@
#include "lanpage.h"
#define MAIN_LAYOUT_MARGINS 0,0,0,0
#define MAIN_LAYOUT_SPACING 0
#define TITLE_FRAME_HEIGHT 52
#define TITLE_LAYOUT_MARGINS 24,0,0,0
#define LAN_LAYOUT_MARGINS 8,8,8,8
#define LAN_LAYOUT_SPACING 8
#define LAN_LIST_SPACING 2
#define TEXT_MARGINS 16,0,0,0
//#define SCROLL_AREA_HEIGHT 200
#define SETTINGS_LAYOUT_MARGINS 24,16,24,16
LanPage::LanPage(QWidget *parent) : QWidget(parent)
{
initUI();
}
LanPage::~LanPage()
{
delete m_titleDivider;
delete m_activatedLanDivider;
delete m_inactivatedLanDivider;
}
void LanPage::initUI()
{
m_mainLayout = new QVBoxLayout(this);
m_mainLayout->setContentsMargins(MAIN_LAYOUT_MARGINS);
m_mainLayout->setSpacing(MAIN_LAYOUT_SPACING);
this->setLayout(m_mainLayout);
m_titleFrame = new QFrame(this);
m_titleFrame->setFixedHeight(TITLE_FRAME_HEIGHT);
m_titleLayout = new QHBoxLayout(m_titleFrame);
m_titleLayout->setContentsMargins(TITLE_LAYOUT_MARGINS);
m_titleLabel = new QLabel(m_titleFrame);
m_titleLabel->setText(tr("LAN"));
m_lanSwitch = new SwitchButton(m_titleFrame);
m_titleLayout->addWidget(m_titleLabel);
m_titleLayout->addStretch();
m_titleLayout->addWidget(m_lanSwitch);
m_titleDivider = new Divider(this);
m_activatedLanFrame = new QFrame(this);
m_activatedLanLayout = new QVBoxLayout(m_activatedLanFrame);
m_activatedLanLayout->setContentsMargins(LAN_LAYOUT_MARGINS);
m_activatedLanLayout->setSpacing(LAN_LAYOUT_SPACING);
m_activatedLanLabel = new QLabel(m_activatedLanFrame);
m_activatedLanLabel->setContentsMargins(TEXT_MARGINS);
m_activatedLanLabel->setText(tr("Activated LAN"));
m_activatedLanListWidget = new QListWidget(m_activatedLanFrame);
m_activatedLanListWidget->setContentsMargins(MAIN_LAYOUT_MARGINS);
m_activatedLanListWidget->setSpacing(LAN_LIST_SPACING);
m_activatedLanLayout->addWidget(m_activatedLanLabel);
m_activatedLanLayout->addWidget(m_activatedLanListWidget);
m_activatedLanDivider = new Divider(this);
m_inactivatedLanFrame = new QFrame(this);
m_inactivatedLanLayout = new QVBoxLayout(m_inactivatedLanFrame);
m_inactivatedLanLayout->setContentsMargins(LAN_LAYOUT_MARGINS);
m_inactivatedLanLayout->setSpacing(LAN_LAYOUT_SPACING);
m_inactivatedLanFrame->setLayout(m_inactivatedLanLayout);
m_inactivatedLanLabel = new QLabel(m_inactivatedLanFrame);
m_inactivatedLanLabel->setContentsMargins(TEXT_MARGINS);
m_inactivatedLanLabel->setText(tr("Inactivated LAN"));
m_inactivatedLanListArea = new QScrollArea(m_inactivatedLanFrame);
m_inactivatedLanListWidget = new QListWidget(m_inactivatedLanListArea);
m_inactivatedLanListArea->setWidget(m_inactivatedLanListWidget);
m_inactivatedLanListArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
m_inactivatedLanListArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
m_inactivatedLanListWidget->setContentsMargins(MAIN_LAYOUT_MARGINS);
m_inactivatedLanListWidget->setSpacing(LAN_LIST_SPACING);
// m_inactivated_lan_list_area->setFixedHeight(SCROLL_AREA_HEIGHT);
m_inactivatedLanLayout->addWidget(m_inactivatedLanLabel);
m_inactivatedLanLayout->addWidget(m_inactivatedLanListArea);
m_inactivatedLanDivider = new Divider(this);
m_settingsFrame = new QFrame(this);
m_settingsLayout = new QHBoxLayout(m_settingsFrame);
m_settingsLayout->setContentsMargins(SETTINGS_LAYOUT_MARGINS);
m_settingsLabel = new QLabel(m_settingsFrame);
m_settingsLabel->setText(tr("Settings"));
m_settingsLayout->addWidget(m_settingsLabel);
m_settingsFrame->setLayout(m_settingsLayout);
m_mainLayout->addWidget(m_titleFrame);
m_mainLayout->addWidget(m_titleDivider);
m_mainLayout->addWidget(m_activatedLanFrame);
m_mainLayout->addWidget(m_activatedLanDivider);
m_mainLayout->addWidget(m_inactivatedLanFrame);
m_mainLayout->addWidget(m_inactivatedLanDivider);
m_mainLayout->addWidget(m_settingsFrame);
}

View File

@ -0,0 +1,48 @@
#ifndef LANPAGE_H
#define LANPAGE_H
#include "divider.h"
#include "switchbutton.h"
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QLabel>
#include <QScrollArea>
#include <QListWidget>
class LanPage : public QWidget
{
Q_OBJECT
public:
explicit LanPage(QWidget *parent = nullptr);
~LanPage();
signals:
private:
void initUI();
QVBoxLayout * m_mainLayout = nullptr;
QFrame * m_titleFrame = nullptr;
QHBoxLayout * m_titleLayout = nullptr;
QLabel * m_titleLabel = nullptr;
SwitchButton * m_lanSwitch = nullptr;
Divider * m_titleDivider = nullptr;
QFrame * m_activatedLanFrame = nullptr;
QVBoxLayout * m_activatedLanLayout = nullptr;
QLabel * m_activatedLanLabel = nullptr;
QListWidget * m_activatedLanListWidget = nullptr;
Divider * m_activatedLanDivider = nullptr;
QFrame * m_inactivatedLanFrame = nullptr;
QVBoxLayout * m_inactivatedLanLayout = nullptr;
QLabel * m_inactivatedLanLabel = nullptr;
QScrollArea * m_inactivatedLanListArea = nullptr;
QListWidget * m_inactivatedLanListWidget = nullptr;
Divider * m_inactivatedLanDivider = nullptr;
QFrame * m_settingsFrame = nullptr;
QHBoxLayout * m_settingsLayout = nullptr;
QLabel * m_settingsLabel = nullptr;
};
#endif // LANPAGE_H

View File

@ -0,0 +1,10 @@
INCLUDEPATH += $$PWD
HEADERS += \
$$PWD/lanpage.h \
$$PWD/wlanpage.h
SOURCES += \
$$PWD/lanpage.cpp \
$$PWD/wlanpage.cpp

View File

@ -0,0 +1,121 @@
#include "wlanpage.h"
#include <QEvent>
#define MAIN_LAYOUT_MARGINS 0,0,0,0
#define MAIN_LAYOUT_SPACING 0
#define TITLE_FRAME_HEIGHT 52
#define TITLE_LAYOUT_MARGINS 24,0,0,0
#define LAN_LAYOUT_MARGINS 8,8,8,8
#define LAN_LAYOUT_SPACING 8
#define LAN_LIST_SPACING 2
#define TEXT_MARGINS 16,0,0,0
//#define SCROLL_AREA_HEIGHT 200
#define SETTINGS_LAYOUT_MARGINS 24,16,24,16
WlanPage::WlanPage(QWidget *parent) : QWidget(parent)
{
initUI();
}
WlanPage::~WlanPage()
{
delete m_titleDivider;
delete m_activatedWlanDivider;
delete m_inactivatedWlanDivider;
}
bool WlanPage::eventFilter(QObject *w, QEvent *e)
{
if (e->type() == QEvent::MouseButtonPress) {
if (w == m_hiddenWlanLabel) {
//ZJP_TODO 打开隐藏WiFi添加弹窗
} else if (w == m_settingsLabel) {
//ZJP_TODO 打开控制面板
}
}
return QWidget::eventFilter(w,e);
}
void WlanPage::initUI()
{
m_mainLayout = new QVBoxLayout(this);
m_mainLayout->setContentsMargins(MAIN_LAYOUT_MARGINS);
m_mainLayout->setSpacing(MAIN_LAYOUT_SPACING);
this->setLayout(m_mainLayout);
m_titleFrame = new QFrame(this);
m_titleFrame->setFixedHeight(TITLE_FRAME_HEIGHT);
m_titleLayout = new QHBoxLayout(m_titleFrame);
m_titleLayout->setContentsMargins(TITLE_LAYOUT_MARGINS);
m_titleLabel = new QLabel(m_titleFrame);
m_titleLabel->setText(tr("WLAN"));
m_lanSwitch = new SwitchButton(m_titleFrame);
m_titleLayout->addWidget(m_titleLabel);
m_titleLayout->addStretch();
m_titleLayout->addWidget(m_lanSwitch);
m_titleDivider = new Divider(this);
m_activatedWlanFrame = new QFrame(this);
m_activatedWlanLayout = new QVBoxLayout(m_activatedWlanFrame);
m_activatedWlanLayout->setContentsMargins(LAN_LAYOUT_MARGINS);
m_activatedWlanLayout->setSpacing(LAN_LAYOUT_SPACING);
m_activatedWlanLabel = new QLabel(m_activatedWlanFrame);
m_activatedWlanLabel->setContentsMargins(TEXT_MARGINS);
m_activatedWlanLabel->setText(tr("Activated WLAN"));
m_activatedWlanListWidget = new QListWidget(m_activatedWlanFrame);
m_activatedWlanListWidget->setContentsMargins(MAIN_LAYOUT_MARGINS);
m_activatedWlanListWidget->setSpacing(LAN_LIST_SPACING);
m_activatedWlanLayout->addWidget(m_activatedWlanLabel);
m_activatedWlanLayout->addWidget(m_activatedWlanListWidget);
m_activatedWlanDivider = new Divider(this);
m_inactivatedWlanFrame = new QFrame(this);
m_inactivatedWlanLayout = new QVBoxLayout(m_inactivatedWlanFrame);
m_inactivatedWlanLayout->setContentsMargins(LAN_LAYOUT_MARGINS);
m_inactivatedWlanLayout->setSpacing(LAN_LAYOUT_SPACING);
m_inactivatedWlanFrame->setLayout(m_inactivatedWlanLayout);
m_inactivatedWlanLabel = new QLabel(m_inactivatedWlanFrame);
m_inactivatedWlanLabel->setContentsMargins(TEXT_MARGINS);
m_inactivatedWlanLabel->setText(tr("Inactivated WLAN"));
m_inactivatedWlanListArea = new QScrollArea(m_inactivatedWlanFrame);
m_inactivatedWlanListArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
m_inactivatedWlanListArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
m_inactivatedWlanListAreaCentralWidget = new QFrame(m_inactivatedWlanListArea);
m_inactivatedWlanListArea->setWidget(m_inactivatedWlanListAreaCentralWidget);
m_inactivatedWlanListAreaLayout = new QVBoxLayout(m_inactivatedWlanListAreaCentralWidget);
m_inactivatedWlanListAreaCentralWidget->setLayout(m_inactivatedWlanListAreaLayout);
m_inactivatedWlanListAreaLayout->setContentsMargins(MAIN_LAYOUT_MARGINS);
m_inactivatedWlanListWidget = new QListWidget(m_inactivatedWlanListAreaCentralWidget);
m_inactivatedWlanListWidget->setContentsMargins(MAIN_LAYOUT_MARGINS);
m_inactivatedWlanListWidget->setSpacing(LAN_LIST_SPACING);
m_hiddenWlanWidget = new QFrame(m_inactivatedWlanListAreaCentralWidget);
m_hiddenWlanLayout = new QHBoxLayout(m_hiddenWlanWidget);
m_hiddenWlanLayout->setContentsMargins(MAIN_LAYOUT_MARGINS);
m_hiddenWlanLabel = new QLabel(m_hiddenWlanWidget);
m_hiddenWlanLabel->setText(tr("More..."));
m_hiddenWlanLayout->addWidget(m_hiddenWlanLabel);
m_hiddenWlanLayout->addStretch();
m_inactivatedWlanListAreaLayout->addWidget(m_inactivatedWlanListWidget);
m_inactivatedWlanListAreaLayout->addWidget(m_hiddenWlanWidget);
// m_inactivated_lan_list_area->setFixedHeight(SCROLL_AREA_HEIGHT);
m_inactivatedWlanLayout->addWidget(m_inactivatedWlanLabel);
m_inactivatedWlanLayout->addWidget(m_inactivatedWlanListArea);
m_inactivatedWlanDivider = new Divider(this);
m_settingsFrame = new QFrame(this);
m_settingsLayout = new QHBoxLayout(m_settingsFrame);
m_settingsLayout->setContentsMargins(SETTINGS_LAYOUT_MARGINS);
m_settingsLabel = new QLabel(m_settingsFrame);
m_settingsLabel->setText(tr("Settings"));
m_settingsLayout->addWidget(m_settingsLabel);
m_settingsFrame->setLayout(m_settingsLayout);
m_mainLayout->addWidget(m_titleFrame);
m_mainLayout->addWidget(m_titleDivider);
m_mainLayout->addWidget(m_activatedWlanFrame);
m_mainLayout->addWidget(m_activatedWlanDivider);
m_mainLayout->addWidget(m_inactivatedWlanFrame);
m_mainLayout->addWidget(m_inactivatedWlanDivider);
m_mainLayout->addWidget(m_settingsFrame);
}

View File

@ -0,0 +1,56 @@
#ifndef WLANPAGE_H
#define WLANPAGE_H
#include "divider.h"
#include "switchbutton.h"
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QLabel>
#include <QScrollArea>
#include <QListWidget>
class WlanPage : public QWidget
{
Q_OBJECT
public:
explicit WlanPage(QWidget *parent = nullptr);
~WlanPage();
signals:
protected:
bool eventFilter(QObject *watched, QEvent *event);
private:
void initUI();
QVBoxLayout * m_mainLayout = nullptr;
QFrame * m_titleFrame = nullptr;
QHBoxLayout * m_titleLayout = nullptr;
QLabel * m_titleLabel = nullptr;
SwitchButton * m_lanSwitch = nullptr;
Divider * m_titleDivider = nullptr;
QFrame * m_activatedWlanFrame = nullptr;
QVBoxLayout * m_activatedWlanLayout = nullptr;
QLabel *m_activatedWlanLabel = nullptr;
QListWidget * m_activatedWlanListWidget = nullptr;
Divider * m_activatedWlanDivider = nullptr;
QFrame * m_inactivatedWlanFrame = nullptr;
QVBoxLayout * m_inactivatedWlanLayout = nullptr;
QLabel * m_inactivatedWlanLabel = nullptr;
QScrollArea * m_inactivatedWlanListArea = nullptr;
QFrame * m_inactivatedWlanListAreaCentralWidget = nullptr;
QVBoxLayout * m_inactivatedWlanListAreaLayout = nullptr;
QListWidget * m_inactivatedWlanListWidget = nullptr;
QFrame * m_hiddenWlanWidget = nullptr;
QHBoxLayout * m_hiddenWlanLayout = nullptr;
QLabel * m_hiddenWlanLabel = nullptr;
Divider * m_inactivatedWlanDivider = nullptr;
QFrame * m_settingsFrame = nullptr;
QHBoxLayout * m_settingsLayout = nullptr;
QLabel * m_settingsLabel = nullptr;
};
#endif // WLANPAGE_H

View File

@ -0,0 +1,21 @@
#include "divider.h"
#include <QPainter>
Divider::Divider(QWidget * parent) : QFrame(parent)
{
this->setFixedHeight(1);
}
void Divider::paintEvent(QPaintEvent * e)
{
QPainter p(this);
p.save();
p.setBrush(this->palette().color(QPalette::Text));
p.setPen(Qt::transparent);
p.setOpacity(0.3);
p.drawRoundedRect(this->rect(), 6, 6);
p.restore();
return QFrame::paintEvent(e);
}

View File

@ -0,0 +1,15 @@
#ifndef DIVIDER_H
#define DIVIDER_H
#include <QFrame>
class Divider : public QFrame
{
public:
Divider(QWidget * parent = nullptr);
~Divider() = default;
protected:
void paintEvent(QPaintEvent *event);
};
#endif // DIVIDER_H

View File

@ -0,0 +1,30 @@
#include "infobutton.h"
#include <QEvent>
InfoButton::InfoButton(QWidget *parent) : QPushButton(parent)
{
initUI();
installEventFilter(this);
}
void InfoButton::initUI()
{
}
void InfoButton::enterEvent(QEvent *)
{
}
void InfoButton::leaveEvent(QEvent *)
{
}
bool InfoButton::eventFilter(QObject *w, QEvent *e)
{
if(e->type() == QEvent::MouseButtonPress) {
}
return QPushButton::eventFilter(w, e);
}

View File

@ -0,0 +1,21 @@
#ifndef INFOBUTTON_H
#define INFOBUTTON_H
#include <QPushButton>
class InfoButton : public QPushButton
{
Q_OBJECT
public:
explicit InfoButton(QWidget * parent = nullptr);
~InfoButton() = default;
private:
void initUI();
protected:
virtual void enterEvent(QEvent *event);
virtual void leaveEvent(QEvent *event);
bool eventFilter(QObject *watched, QEvent *event);
};
#endif // INFOBUTTON_H

View File

@ -0,0 +1,53 @@
#include "netbutton.h"
NetButton::NetButton(bool isActivated, QWidget *parent) : QPushButton(parent)
{
connect(this, &NetButton::requestStartLoading, this, &NetButton::onLoadingStarted);
connect(this, &NetButton::requestStopLoading, this, &NetButton::onLoadingStopped);
m_isActivated = isActivated;
this->setAutoFillBackground(false);
m_iconLabel = new QLabel(this);
m_iconLabel->setScaledContents(true);
}
void NetButton::startLoading()
{
emit this->requestStartLoading();
}
void NetButton::stopLoading()
{
emit this->requestStopLoading();
}
void NetButton::setPressed()
{
//ZJP_TODO 设置颜色为点击颜色,注意区分已连接/未连接
if (m_isActivated)
;
;
}
void NetButton::setReleased()
{
//ZJP_TODO 设置颜色为未点击颜色,注意区分已连接/未连接
if (m_isActivated)
;
;
}
void NetButton::setButtonIcon(QIcon *icon)
{
if (!icon) { return; }
m_iconLabel->setPixmap(icon->pixmap(this->size()));
}
void NetButton::onLoadingStarted()
{
//ZJP_TODO 开始播放转圈动画
}
void NetButton::onLoadingStopped()
{
//ZJP_TODO 停止播放转圈动画
}

View File

@ -0,0 +1,34 @@
#ifndef NETBUTTON_H
#define NETBUTTON_H
#include <QPushButton>
#include <QIcon>
#include <QLabel>
#define ACTIVATED true
#define INACTIVATED false
class NetButton : public QPushButton
{
Q_OBJECT
public:
NetButton(bool isActivated = INACTIVATED, QWidget * parent = nullptr);
~NetButton() = default;
void startLoading();
void stopLoading();
void setPressed();
void setReleased();
void setButtonIcon(QIcon *);
signals:
void requestStartLoading();
void requestStopLoading();
private:
bool m_isActivated = INACTIVATED;
QLabel * m_iconLabel = nullptr;
private slots:
void onLoadingStarted();
void onLoadingStopped();
};
#endif // NETBUTTON_H

View File

@ -1,10 +1,16 @@
INCLUDEPATH += $$PWD INCLUDEPATH += $$PWD
HEADERS += \ HEADERS += \
$$PWD/divider.h \
$$PWD/infobutton.h \
$$PWD/loadingdiv.h \ $$PWD/loadingdiv.h \
$$PWD/netbutton.h \
$$PWD/switchbutton.h $$PWD/switchbutton.h
SOURCES += \ SOURCES += \
$$PWD/divider.cpp \
$$PWD/infobutton.cpp \
$$PWD/loadingdiv.cpp \ $$PWD/loadingdiv.cpp \
$$PWD/netbutton.cpp \
$$PWD/switchbutton.cpp $$PWD/switchbutton.cpp

View File

@ -31,7 +31,7 @@
#include <QStandardItemModel> #include <QStandardItemModel>
#include <QDir> #include <QDir>
DlgHideWifi::DlgHideWifi(int type, MainWindow *mainWindow, QWidget *parent) : DlgHideWifi::DlgHideWifi(int type, OldMainWindow *mainWindow, QWidget *parent) :
isUsed(type), isUsed(type),
QDialog(parent), QDialog(parent),
ui(new Ui::DlgHideWifi) ui(new Ui::DlgHideWifi)

View File

@ -25,7 +25,7 @@
#include <QTimer> #include <QTimer>
#include <QFile> #include <QFile>
class MainWindow; class OldMainWindow;
namespace Ui { namespace Ui {
class DlgHideWifi; class DlgHideWifi;
@ -36,7 +36,7 @@ class DlgHideWifi : public QDialog
Q_OBJECT Q_OBJECT
public: public:
explicit DlgHideWifi(int type, MainWindow *mw = 0, QWidget *parent = 0); explicit DlgHideWifi(int type, OldMainWindow *mw = 0, QWidget *parent = 0);
~DlgHideWifi(); ~DlgHideWifi();
protected: protected:
@ -67,7 +67,7 @@ signals:
private: private:
Ui::DlgHideWifi *ui; Ui::DlgHideWifi *ui;
int isUsed;//=0 current wifi not used before; >=1 used int isUsed;//=0 current wifi not used before; >=1 used
MainWindow *mw; OldMainWindow *mw;
QString strWifiname; QString strWifiname;
// QString labelQss, cbxQss, leQss, btnConnQss, btnCancelQss, lineQss; // QString labelQss, cbxQss, leQss, btnConnQss, btnCancelQss, lineQss;

View File

@ -25,7 +25,7 @@
#include <QStandardItemModel> #include <QStandardItemModel>
#include <QDir> #include <QDir>
DlgHideWifiEapPeap::DlgHideWifiEapPeap(int type, int beUsed, MainWindow *mainWindow, QWidget *parent) : DlgHideWifiEapPeap::DlgHideWifiEapPeap(int type, int beUsed, OldMainWindow *mainWindow, QWidget *parent) :
WepOrWpa(type), WepOrWpa(type),
isUsed(beUsed), isUsed(beUsed),
QDialog(parent), QDialog(parent),

View File

@ -22,7 +22,7 @@
#include <QDialog> #include <QDialog>
#include <QMouseEvent> #include <QMouseEvent>
class MainWindow; class OldMainWindow;
namespace Ui { namespace Ui {
class DlgHideWifiEapPeap; class DlgHideWifiEapPeap;
@ -34,7 +34,7 @@ class DlgHideWifiEapPeap : public QDialog
public: public:
//type: 0是动态 WEP 1是企业wpa, beUsed:是否是之前已经连接过多网络 //type: 0是动态 WEP 1是企业wpa, beUsed:是否是之前已经连接过多网络
explicit DlgHideWifiEapPeap(int type, int beUsed, MainWindow *mw = 0, QWidget *parent = 0); explicit DlgHideWifiEapPeap(int type, int beUsed, OldMainWindow *mw = 0, QWidget *parent = 0);
~DlgHideWifiEapPeap(); ~DlgHideWifiEapPeap();
protected: protected:
@ -74,7 +74,7 @@ private:
Ui::DlgHideWifiEapPeap *ui; Ui::DlgHideWifiEapPeap *ui;
int WepOrWpa = 0;//0 WEP;1 WPA int WepOrWpa = 0;//0 WEP;1 WPA
int isUsed;//=0 current wifi not used before; >=1 used int isUsed;//=0 current wifi not used before; >=1 used
MainWindow *mw; OldMainWindow *mw;
void mousePressEvent(QMouseEvent *event); void mousePressEvent(QMouseEvent *event);
void mouseReleaseEvent(QMouseEvent *event); void mouseReleaseEvent(QMouseEvent *event);

View File

@ -24,7 +24,7 @@
#include <QStandardItemModel> #include <QStandardItemModel>
#include <QDir> #include <QDir>
DlgHideWifiEapTls::DlgHideWifiEapTls(int type, int beUsed, MainWindow *mainWindow, QWidget *parent) : DlgHideWifiEapTls::DlgHideWifiEapTls(int type, int beUsed, OldMainWindow *mainWindow, QWidget *parent) :
WepOrWpa(type), WepOrWpa(type),
isUsed(beUsed), isUsed(beUsed),
QDialog(parent), QDialog(parent),

View File

@ -22,7 +22,7 @@
#include <QDialog> #include <QDialog>
#include <QMouseEvent> #include <QMouseEvent>
class MainWindow; class OldMainWindow;
namespace Ui { namespace Ui {
class DlgHideWifiEapTls; class DlgHideWifiEapTls;
@ -33,7 +33,7 @@ class DlgHideWifiEapTls : public QDialog
Q_OBJECT Q_OBJECT
public: public:
explicit DlgHideWifiEapTls(int type, int beUsed, MainWindow *mw = 0, QWidget *parent = 0); explicit DlgHideWifiEapTls(int type, int beUsed, OldMainWindow *mw = 0, QWidget *parent = 0);
~DlgHideWifiEapTls(); ~DlgHideWifiEapTls();
protected: protected:
@ -77,7 +77,7 @@ private:
Ui::DlgHideWifiEapTls *ui; Ui::DlgHideWifiEapTls *ui;
int WepOrWpa = 0;//0 WEP;1WPA int WepOrWpa = 0;//0 WEP;1WPA
int isUsed;//=0 current wifi not used before; >=1 used int isUsed;//=0 current wifi not used before; >=1 used
MainWindow *mw; OldMainWindow *mw;
void mousePressEvent(QMouseEvent *event); void mousePressEvent(QMouseEvent *event);
void mouseReleaseEvent(QMouseEvent *event); void mouseReleaseEvent(QMouseEvent *event);

View File

@ -31,7 +31,7 @@
#include <QtConcurrent> #include <QtConcurrent>
#include <QFuture> #include <QFuture>
DlgHideWifiWpa::DlgHideWifiWpa(int type, MainWindow *mainWindow, QWidget *parent) : DlgHideWifiWpa::DlgHideWifiWpa(int type, OldMainWindow *mainWindow, QWidget *parent) :
isUsed(type), isUsed(type),
QDialog(parent), QDialog(parent),
ui(new Ui::DlgHideWifiWpa) ui(new Ui::DlgHideWifiWpa)

View File

@ -24,7 +24,7 @@
#include <QThread> #include <QThread>
#include <QProcess> #include <QProcess>
class MainWindow; class OldMainWindow;
namespace Ui { namespace Ui {
class DlgHideWifiWpa; class DlgHideWifiWpa;
@ -35,7 +35,7 @@ class DlgHideWifiWpa : public QDialog
Q_OBJECT Q_OBJECT
public: public:
explicit DlgHideWifiWpa(int type, MainWindow *mw = 0, QWidget *parent = 0); explicit DlgHideWifiWpa(int type, OldMainWindow *mw = 0, QWidget *parent = 0);
~DlgHideWifiWpa(); ~DlgHideWifiWpa();
protected: protected:
@ -74,7 +74,7 @@ signals:
private: private:
Ui::DlgHideWifiWpa *ui; Ui::DlgHideWifiWpa *ui;
int isUsed;//=0 current wifi not used before; >=1 used int isUsed;//=0 current wifi not used before; >=1 used
MainWindow *mw; OldMainWindow *mw;
QString strWifiname; QString strWifiname;
QString strWifiPassword; QString strWifiPassword;

View File

@ -60,7 +60,7 @@ void UpConnThread::run() {
emit connRes(res); emit connRes(res);
} }
WpaWifiDialog::WpaWifiDialog(QWidget *parent, MainWindow *mainWindow, QString conname) : WpaWifiDialog::WpaWifiDialog(QWidget *parent, OldMainWindow *mainWindow, QString conname) :
QDialog(parent), QDialog(parent),
ui(new Ui::WpaWifiDialog) ui(new Ui::WpaWifiDialog)
{ {
@ -99,7 +99,7 @@ WpaWifiDialog::WpaWifiDialog(QWidget *parent, MainWindow *mainWindow, QString co
checkConnectBtnIsEnabled(); checkConnectBtnIsEnabled();
} }
WpaWifiDialog::WpaWifiDialog(QWidget *parent, MainWindow *mw, WifiConfig *wifiConfig) WpaWifiDialog::WpaWifiDialog(QWidget *parent, OldMainWindow *mw, WifiConfig *wifiConfig)
{ {
if (wifiConfig) { if (wifiConfig) {
m_wifiConfig = wifiConfig; m_wifiConfig = wifiConfig;

View File

@ -43,7 +43,7 @@
#define WINDOW_HEIGHT_TLP 670 #define WINDOW_HEIGHT_TLP 670
#define WINDOW_HEIGHT_ELSE 360 #define WINDOW_HEIGHT_ELSE 360
class MainWindow; class OldMainWindow;
typedef QList<QObject*> QObjectList; typedef QList<QObject*> QObjectList;
@ -91,8 +91,8 @@ class WpaWifiDialog : public QDialog
Q_OBJECT Q_OBJECT
public: public:
explicit WpaWifiDialog(QWidget *parent = nullptr, MainWindow *mw = 0, QString conname = 0); explicit WpaWifiDialog(QWidget *parent = nullptr, OldMainWindow *mw = 0, QString conname = 0);
explicit WpaWifiDialog(QWidget *parent = nullptr, MainWindow *mw = 0, WifiConfig *wifiConfig = nullptr); explicit WpaWifiDialog(QWidget *parent = nullptr, OldMainWindow *mw = 0, WifiConfig *wifiConfig = nullptr);
~WpaWifiDialog(); ~WpaWifiDialog();
private: private:
@ -133,7 +133,7 @@ private:
QStringList user_list; QStringList user_list;
QString key_mgmt = "wpa-eap"; QString key_mgmt = "wpa-eap";
MainWindow *mw; OldMainWindow *mw;
QObjectList m_frameList; QObjectList m_frameList;
void setEditorEnable(bool is_checking); //设置是否禁用输入 void setEditorEnable(bool is_checking); //设置是否禁用输入

View File

@ -0,0 +1,210 @@
/*
* KWin Style UKUI
*
* Copyright (C) 2020, KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* Authors: Yue Lan <lanyue@kylinos.cn>
*
*/
#include "xatom-helper.h"
#include <limits.h>
#include <QX11Info>
#include <X11/X.h>
#include <X11/Xatom.h>
static XAtomHelper *global_instance = nullptr;
XAtomHelper *XAtomHelper::getInstance()
{
if(!global_instance)
global_instance = new XAtomHelper;
return global_instance;
}
bool XAtomHelper::isFrameLessWindow(int winId)
{
auto hints = getInstance()->getWindowMotifHint(winId);
if(hints.flags == MWM_HINTS_DECORATIONS && hints.functions == 1) {
return true;
}
return false;
}
bool XAtomHelper::isWindowDecorateBorderOnly(int winId)
{
return isWindowMotifHintDecorateBorderOnly(getInstance()->getWindowMotifHint(winId));
}
bool XAtomHelper::isWindowMotifHintDecorateBorderOnly(const MotifWmHints &hint) {
bool isDeco = false;
if(hint.flags & MWM_HINTS_DECORATIONS && hint.flags != MWM_HINTS_DECORATIONS) {
if(hint.decorations == MWM_DECOR_BORDER)
isDeco = true;
}
return isDeco;
}
bool XAtomHelper::isUKUICsdSupported()
{
// fixme:
return false;
}
bool XAtomHelper::isUKUIDecorationWindow(int winId)
{
if(m_ukuiDecorationAtion == None)
return false;
Atom type;
int format;
ulong nitems;
ulong bytes_after;
uchar *data;
bool isUKUIDecoration = false;
XGetWindowProperty(QX11Info::display(), winId, m_ukuiDecorationAtion,
0, LONG_MAX, false,
m_ukuiDecorationAtion, &type,
&format, &nitems,
&bytes_after, &data);
if(type == m_ukuiDecorationAtion) {
if(nitems == 1) {
isUKUIDecoration = data[0];
}
}
return isUKUIDecoration;
}
UnityCorners XAtomHelper::getWindowBorderRadius(int winId)
{
UnityCorners corners;
Atom type;
int format;
ulong nitems;
ulong bytes_after;
uchar *data;
if(m_unityBorderRadiusAtom != None) {
XGetWindowProperty(QX11Info::display(), winId, m_unityBorderRadiusAtom,
0, LONG_MAX, false,
XA_CARDINAL, &type,
&format, &nitems,
&bytes_after, &data);
if(type == XA_CARDINAL) {
if(nitems == 4) {
corners.topLeft = static_cast<ulong>(data[0]);
corners.topRight = static_cast<ulong>(data[1 * sizeof(ulong)]);
corners.bottomLeft = static_cast<ulong>(data[2 * sizeof(ulong)]);
corners.bottomRight = static_cast<ulong>(data[3 * sizeof(ulong)]);
}
XFree(data);
}
}
return corners;
}
void XAtomHelper::setWindowBorderRadius(int winId, const UnityCorners &data)
{
if(m_unityBorderRadiusAtom == None)
return;
ulong corners[4] = {data.topLeft, data.topRight, data.bottomLeft, data.bottomRight};
XChangeProperty(QX11Info::display(), winId, m_unityBorderRadiusAtom, XA_CARDINAL,
32, XCB_PROP_MODE_REPLACE, (const unsigned char *) &corners, sizeof(corners) / sizeof(corners[0]));
}
void XAtomHelper::setWindowBorderRadius(int winId, int topLeft, int topRight, int bottomLeft, int bottomRight)
{
if(m_unityBorderRadiusAtom == None)
return;
ulong corners[4] = {(ulong)topLeft, (ulong)topRight, (ulong)bottomLeft, (ulong)bottomRight};
XChangeProperty(QX11Info::display(), winId, m_unityBorderRadiusAtom, XA_CARDINAL,
32, XCB_PROP_MODE_REPLACE, (const unsigned char *) &corners, sizeof(corners) / sizeof(corners[0]));
}
void XAtomHelper::setUKUIDecoraiontHint(int winId, bool set)
{
if(m_ukuiDecorationAtion == None)
return;
XChangeProperty(QX11Info::display(), winId, m_ukuiDecorationAtion, m_ukuiDecorationAtion, 32, XCB_PROP_MODE_REPLACE, (const unsigned char *) &set, 1);
}
void XAtomHelper::setWindowMotifHint(int winId, const MotifWmHints &hints)
{
if(m_unityBorderRadiusAtom == None)
return;
XChangeProperty(QX11Info::display(), winId, m_motifWMHintsAtom, m_motifWMHintsAtom,
32, XCB_PROP_MODE_REPLACE, (const unsigned char *)&hints, sizeof(MotifWmHints) / sizeof(ulong));
}
MotifWmHints XAtomHelper::getWindowMotifHint(int winId)
{
MotifWmHints hints;
if(m_unityBorderRadiusAtom == None)
return hints;
uchar *data;
Atom type;
int format;
ulong nitems;
ulong bytes_after;
XGetWindowProperty(QX11Info::display(), winId, m_motifWMHintsAtom,
0, sizeof(MotifWmHints) / sizeof(long), false, AnyPropertyType, &type,
&format, &nitems, &bytes_after, &data);
if(type == None) {
return hints;
} else {
hints = *(MotifWmHints *)data;
XFree(data);
}
return hints;
}
XAtomHelper::XAtomHelper(QObject *parent) : QObject(parent)
{
if(!QX11Info::isPlatformX11())
return;
m_motifWMHintsAtom = XInternAtom(QX11Info::display(), "_MOTIF_WM_HINTS", true);
m_unityBorderRadiusAtom = XInternAtom(QX11Info::display(), "_UNITY_GTK_BORDER_RADIUS", false);
m_ukuiDecorationAtion = XInternAtom(QX11Info::display(), "_KWIN_UKUI_DECORAION", false);
}
Atom XAtomHelper::registerUKUICsdNetWmSupportAtom()
{
// fixme:
return None;
}
void XAtomHelper::unregisterUKUICsdNetWmSupportAtom()
{
// fixme:
}

View File

@ -0,0 +1,110 @@
/*
* KWin Style UKUI
*
* Copyright (C) 2020, KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* Authors: Yue Lan <lanyue@kylinos.cn>
*
*/
#ifndef XATOMHELPER_H
#define XATOMHELPER_H
#include <QObject>
#include <X11/Xlib.h>
#include <NETWM>
struct UnityCorners {
ulong topLeft = 0;
ulong topRight = 0;
ulong bottomLeft = 0;
ulong bottomRight = 0;
};
typedef struct {
ulong flags = 0;
ulong functions = 0;
ulong decorations = 0;
long input_mode = 0;
ulong status = 0;
} MotifWmHints, MwmHints;
#define MWM_HINTS_FUNCTIONS (1L << 0)
#define MWM_HINTS_DECORATIONS (1L << 1)
#define MWM_HINTS_INPUT_MODE (1L << 2)
#define MWM_HINTS_STATUS (1L << 3)
#define MWM_FUNC_ALL (1L << 0)
#define MWM_FUNC_RESIZE (1L << 1)
#define MWM_FUNC_MOVE (1L << 2)
#define MWM_FUNC_MINIMIZE (1L << 3)
#define MWM_FUNC_MAXIMIZE (1L << 4)
#define MWM_FUNC_CLOSE (1L << 5)
#define MWM_DECOR_ALL (1L << 0)
#define MWM_DECOR_BORDER (1L << 1)
#define MWM_DECOR_RESIZEH (1L << 2)
#define MWM_DECOR_TITLE (1L << 3)
#define MWM_DECOR_MENU (1L << 4)
#define MWM_DECOR_MINIMIZE (1L << 5)
#define MWM_DECOR_MAXIMIZE (1L << 6)
#define MWM_INPUT_MODELESS 0
#define MWM_INPUT_PRIMARY_APPLICATION_MODAL 1
#define MWM_INPUT_SYSTEM_MODAL 2
#define MWM_INPUT_FULL_APPLICATION_MODAL 3
#define MWM_INPUT_APPLICATION_MODAL MWM_INPUT_PRIMARY_APPLICATION_MODAL
#define MWM_TEAROFF_WINDOW (1L<<0)
namespace UKUI {
class Decoration;
}
class XAtomHelper : public QObject
{
// friend class UKUI::Decoration;
Q_OBJECT
public:
static XAtomHelper *getInstance();
static bool isFrameLessWindow(int winId);
static bool isWindowDecorateBorderOnly(int winId);
static bool isWindowMotifHintDecorateBorderOnly(const MotifWmHints &hint);
bool isUKUICsdSupported();
bool isUKUIDecorationWindow(int winId);
UnityCorners getWindowBorderRadius(int winId);
void setWindowBorderRadius(int winId, const UnityCorners &data);
void setWindowBorderRadius(int winId, int topLeft, int topRight, int bottomLeft, int bottomRight);
void setUKUIDecoraiontHint(int winId, bool set = true);
void setWindowMotifHint(int winId, const MotifWmHints &hints);
MotifWmHints getWindowMotifHint(int winId);
private:
explicit XAtomHelper(QObject *parent = nullptr);
Atom registerUKUICsdNetWmSupportAtom();
void unregisterUKUICsdNetWmSupportAtom();
Atom m_motifWMHintsAtom = None;
Atom m_unityBorderRadiusAtom = None;
Atom m_ukuiDecorationAtion = None;
};
#endif // XATOMHELPER_H

View File

@ -0,0 +1,7 @@
INCLUDEPATH += $$PWD
HEADERS += \
$$PWD/xatom-helper.h \
SOURCES += \
$$PWD/xatom-helper.cpp \

View File

@ -15,4 +15,4 @@ Type=Application
OnlyShowIn=UKUI OnlyShowIn=UKUI
X-UKUI-AutoRestart=true X-UKUI-AutoRestart=true
NoDisplay=true NoDisplay=true
X-UKUI-Autostart-Phase=Desktop X-UKUI-Autostart-Phase=Application

View File

@ -16,19 +16,21 @@
* *
*/ */
#include "mainwindow.h" //#include "mainwindow.h"
#include "new-mainwindow.h" //ZJP_TODO 载入新的主窗口
#include "ksimplenm.h" #include "ksimplenm.h"
#include "kylin-network-interface.h" #include "kylin-network-interface.h"
#include "wireless-security/dlghidewifi.h" #include "wireless-security/dlghidewifi.h"
#include "dbusadaptor.h" #include "dbusadaptor.h"
#include <QTranslator> #include <QTranslator>
#include <QLocale> #include <QLocale>
//#include <QApplication>
#include "qt-single-application.h" #include "qt-single-application.h"
#include <QDebug> #include <QDebug>
#include <QDesktopWidget> #include <QDesktopWidget>
#include <X11/Xlib.h>
#include <QFile> #include <QFile>
#if (QT_VERSION >= QT_VERSION_CHECK(5, 12, 0))
#include "xatom-helper.h"
#endif
#define LOG_IDENT "ukui_kylin_nm" #define LOG_IDENT "ukui_kylin_nm"
@ -97,13 +99,6 @@ int main(int argc, char *argv[])
qDebug()<<"Kylin Network Manager Is Already Launched"; qDebug()<<"Kylin Network Manager Is Already Launched";
int loopNum = 0;
while (!QSystemTrayIcon::isSystemTrayAvailable()) {
if (loopNum == 15) return 1;
qDebug()<<"I couldn't detect any system tray on this system now";
loopNum += 1;
sleep(1);
}
QApplication::setQuitOnLastWindowClosed(false); QApplication::setQuitOnLastWindowClosed(false);
// Internationalization // Internationalization
@ -111,7 +106,6 @@ int main(int argc, char *argv[])
QTranslator trans_global; QTranslator trans_global;
if (locale == "zh_CN") { if (locale == "zh_CN") {
trans_global.load(":/translations/kylin-nm_zh_CN.qm"); trans_global.load(":/translations/kylin-nm_zh_CN.qm");
//trans_global.load(":/translations/kylin-nm_bo.qm");
a.installTranslator(&trans_global); a.installTranslator(&trans_global);
} }
if (locale == "tr_TR") { if (locale == "tr_TR") {
@ -121,7 +115,17 @@ int main(int argc, char *argv[])
qDebug()<<"Translations Are Already Loaded"; qDebug()<<"Translations Are Already Loaded";
MainWindow w; MainWindow w;
qDebug()<<"Mainwindow is Already Registered"; w.setProperty("useStyleWindowManager", false); //禁用拖动
//设置窗口无边框,阴影
#if (QT_VERSION >= QT_VERSION_CHECK(5, 12, 0))
MotifWmHints window_hints;
window_hints.flags = MWM_HINTS_FUNCTIONS | MWM_HINTS_DECORATIONS;
window_hints.functions = MWM_FUNC_ALL;
window_hints.decorations = MWM_DECOR_BORDER;
XAtomHelper::getInstance()->setWindowMotifHint(w.winId(), window_hints);
#else
w.setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint | Qt::X11BypassWindowManagerHint);
#endif
DbusAdaptor adaptor(&w); DbusAdaptor adaptor(&w);
Q_UNUSED(adaptor); Q_UNUSED(adaptor);
@ -130,16 +134,6 @@ int main(int argc, char *argv[])
if (!connection.registerService("com.kylin.network") || !connection.registerObject("/com/kylin/network", &w)) { if (!connection.registerService("com.kylin.network") || !connection.registerObject("/com/kylin/network", &w)) {
qCritical() << "QDbus register service failed reason:" << connection.lastError(); qCritical() << "QDbus register service failed reason:" << connection.lastError();
} }
// QDBusInterface iface("com.kylin.network",
// "/com/kylin/network",
// "com.kylin.network",
// connection);
// iface.call("showMainWindow");
// return 0;
// }
w.justShowTrayIcon();
return a.exec(); return a.exec();
} }