diff --git a/backthread.cpp b/backthread.cpp index b3b4c74b..616874b6 100644 --- a/backthread.cpp +++ b/backthread.cpp @@ -195,8 +195,7 @@ void BackThread::execConnWifiPWD(QString connName, QString password){ system(cmd.toUtf8().data()); QFile file("/tmp/kylin-nm-btoutput"); - if(!file.open(QIODevice::ReadOnly | QIODevice::Text)) - { + if(!file.open(QIODevice::ReadOnly | QIODevice::Text)){ syslog(LOG_DEBUG, "Can't open the file /tmp/kylin-nm-btoutput !"); qDebug()<<"Can't open the file /tmp/kylin-nm-btoutput !"< -Installed-Size: 2150 +Installed-Size: 2513 Depends: kylin-nm (= 1.0.4-1) Section: debug Priority: optional Description: debug symbols for kylin-nm -Build-Ids: d0ea598f653671ec7ae29f02cfe8a223bb295ffb +Build-Ids: 063b3688b29c269bac25fe162b774cd18111ad17 diff --git a/debian/.debhelper/kylin-nm/dbgsym-root/DEBIAN/md5sums b/debian/.debhelper/kylin-nm/dbgsym-root/DEBIAN/md5sums index d164cc96..e9c2eb2c 100644 --- a/debian/.debhelper/kylin-nm/dbgsym-root/DEBIAN/md5sums +++ b/debian/.debhelper/kylin-nm/dbgsym-root/DEBIAN/md5sums @@ -1 +1 @@ -c48517cf1b116f015acf8816247d5b42 usr/lib/debug/.build-id/d0/ea598f653671ec7ae29f02cfe8a223bb295ffb.debug +01f1f57cd381771bd8181ce5baa6a75b usr/lib/debug/.build-id/06/3b3688b29c269bac25fe162b774cd18111ad17.debug diff --git a/debian/.debhelper/kylin-nm/dbgsym-root/usr/lib/debug/.build-id/06/3b3688b29c269bac25fe162b774cd18111ad17.debug b/debian/.debhelper/kylin-nm/dbgsym-root/usr/lib/debug/.build-id/06/3b3688b29c269bac25fe162b774cd18111ad17.debug new file mode 100644 index 00000000..677b9f6d Binary files /dev/null and b/debian/.debhelper/kylin-nm/dbgsym-root/usr/lib/debug/.build-id/06/3b3688b29c269bac25fe162b774cd18111ad17.debug differ diff --git a/debian/.debhelper/kylin-nm/dbgsym-root/usr/lib/debug/.build-id/d0/ea598f653671ec7ae29f02cfe8a223bb295ffb.debug b/debian/.debhelper/kylin-nm/dbgsym-root/usr/lib/debug/.build-id/d0/ea598f653671ec7ae29f02cfe8a223bb295ffb.debug deleted file mode 100644 index daf5644f..00000000 Binary files a/debian/.debhelper/kylin-nm/dbgsym-root/usr/lib/debug/.build-id/d0/ea598f653671ec7ae29f02cfe8a223bb295ffb.debug and /dev/null differ diff --git a/hot-spot/dlghotspotcreate.cpp b/hot-spot/dlghotspotcreate.cpp new file mode 100644 index 00000000..d3670ce5 --- /dev/null +++ b/hot-spot/dlghotspotcreate.cpp @@ -0,0 +1,133 @@ +#include "dlghotspotcreate.h" +#include "ui_dlghotspotcreate.h" + +DlgHotspotCreate::DlgHotspotCreate(QString wiFiCardName, QWidget *parent) : + wirelessCardName(wiFiCardName), + QDialog(parent), + ui(new Ui::DlgHotspotCreate) +{ + ui->setupUi(this); + + this->setWindowFlags(Qt::FramelessWindowHint); + this->setStyleSheet("background-color:white;"); + + ui->lbLeftup->setStyleSheet("QLabel{background-color:#266ab5;}"); + ui->lbLeftupIcon->setStyleSheet("QLabel{background-image:url(:/res/h/no-pwd-wifi.png);background-color:transparent;}"); + ui->lbLeftupTitle->setStyleSheet("QLabel{font-size:12px;color:#ffffff;background-color:transparent;}"); + ui->btnCancel->setStyleSheet("QPushButton{border:1px solid #aaaaaa;background-color:#f5f5f5;}" + "QPushButton:Hover{border:2px solid #629ee8;background-color:#eeeeee;}" + "QPushButton:Pressed{border:1px solid #aaaaaa;background-color:#d8d8d8;}"); + ui->btnOk->setStyleSheet("QPushButton{border:1px solid #aaaaaa;background-color:#f5f5f5;}" + "QPushButton:Hover{border:2px solid #629ee8;background-color:#eeeeee;}" + "QPushButton:Pressed{border:1px solid #aaaaaa;background-color:#d8d8d8;}"); + ui->checkBoxPwd->setStyleSheet("QCheckBox::indicator {width: 18px; height: 9px;}" + "QCheckBox::indicator:checked {image: url(:/res/h/show-pwd.png);}" + "QCheckBox::indicator:unchecked {image: url(:/res/h/hide-pwd.png);}"); + + ui->lbLeftupTitle->setText(tr("Create Hotspot")); //创建个人热点 + ui->lbNetName->setText(tr("Network name")); //网络名称: + ui->lbSecurity->setText(tr("Wi-Fi security")); //Wi-Fi 安全性: + ui->lbPassword->setText(tr("Password")); //密码: + ui->btnCancel->setText(tr("Cancel")); //取消 + ui->btnOk->setText(tr("Ok")); //确定 + ui->btnOk->setEnabled(false); + + ui->cbxSecurity->addItem(tr("None")); //无 + ui->cbxSecurity->addItem(tr("WPA & WPA2 Personal")); //WPA 及 WPA2 个人 + ui->cbxSecurity->setCurrentIndex(1); + connect(ui->cbxSecurity,SIGNAL(currentIndexChanged(QString)),this,SLOT(changeDialog())); +} + +DlgHotspotCreate::~DlgHotspotCreate() +{ + delete ui; +} + +void DlgHotspotCreate::mousePressEvent(QMouseEvent *event){ + if(event->button() == Qt::LeftButton){ + this->isPress = true; + this->winPos = this->pos(); + this->dragPos = event->globalPos(); + event->accept(); + } +} +void DlgHotspotCreate::mouseReleaseEvent(QMouseEvent *event){ + this->isPress = false; + this->setWindowOpacity(1); +} +void DlgHotspotCreate::mouseMoveEvent(QMouseEvent *event){ + if(this->isPress){ + this->move(this->winPos - (this->dragPos - event->globalPos())); + this->setWindowOpacity(0.9); + event->accept(); + } +} + +void DlgHotspotCreate::on_btnCancel_clicked() +{ + this->close(); + emit btnHotspotState(); +} + +void DlgHotspotCreate::on_btnOk_clicked() +{ + //nmcli device wifi hotspot [ifname ifname] [con-name name] [ssid SSID] [band {a | bg}] [channel channel] [password password] + //example: nmcli device wifi hotspot ifname wlan0 con-name MyHostspot ssid MyHostspotSSID password 12345678 + QString str; + if(ui->cbxSecurity->currentIndex() == 0 ){ + str = "nmcli device wifi hotspot ifname " + wirelessCardName + " con-name " + ui->leNetName->text() + " ssid " + ui->leNetName->text() + "SSID"; + }else{ + str = "nmcli device wifi hotspot ifname " + wirelessCardName + " con-name " + ui->leNetName->text() + " ssid " + ui->leNetName->text() + " password " + ui->lePassword->text(); + } + system(str.toUtf8().data()); + this->close(); + emit updateHotspotList(); +} + +void DlgHotspotCreate::on_checkBoxPwd_stateChanged(int arg1) +{ + if (arg1 == 0) { + ui->lePassword ->setEchoMode(QLineEdit::Password); + } else { + ui->lePassword->setEchoMode(QLineEdit::Normal); + } +} + +void DlgHotspotCreate::on_leNetName_textEdited(const QString &arg1) +{ + if(ui->cbxSecurity->currentIndex() == 0 ){ + if (ui->leNetName->text() == ""){ + ui->btnOk->setEnabled(false); + } else { + ui->btnOk->setEnabled(true); + } + }else{ + if (ui->leNetName->text() == "" || ui->lePassword->text().size() < 5){ + ui->btnOk->setEnabled(false); + } else { + ui->btnOk->setEnabled(true); + } + } +} + +void DlgHotspotCreate::on_lePassword_textEdited(const QString &arg1) +{ + if (ui->leNetName->text() == "" || ui->lePassword->text().size() < 5){ + ui->btnOk->setEnabled(false); + } else { + ui->btnOk->setEnabled(true); + } +} + +void DlgHotspotCreate::changeDialog() +{ + if(ui->cbxSecurity->currentIndex()==0){ + ui->lbPassword->setEnabled(false); + ui->lePassword->setEnabled(false); + ui->checkBoxPwd->setEnabled(false); + } else { + ui->lbPassword->setEnabled(true); + ui->lePassword->setEnabled(true); + ui->checkBoxPwd->setEnabled(true); + } +} diff --git a/hot-spot/dlghotspotcreate.h b/hot-spot/dlghotspotcreate.h new file mode 100644 index 00000000..b819fc54 --- /dev/null +++ b/hot-spot/dlghotspotcreate.h @@ -0,0 +1,51 @@ +#ifndef DLGHOTSPOTCREATE_H +#define DLGHOTSPOTCREATE_H + +#include +#include +#include + +namespace Ui { +class DlgHotspotCreate; +} + +class DlgHotspotCreate : public QDialog +{ + Q_OBJECT + +public: + explicit DlgHotspotCreate(QString wiFiCardName, QWidget *parent = nullptr); + ~DlgHotspotCreate(); + +public slots: + void changeDialog(); + +private slots: + void on_btnCancel_clicked(); + + void on_btnOk_clicked(); + + void on_checkBoxPwd_stateChanged(int arg1); + + void on_leNetName_textEdited(const QString &arg1); + + void on_lePassword_textEdited(const QString &arg1); + +private: + Ui::DlgHotspotCreate *ui; + + QString wirelessCardName; + + void mousePressEvent(QMouseEvent *event); + void mouseReleaseEvent(QMouseEvent *event); + void mouseMoveEvent(QMouseEvent *event); + bool isPress; + QPoint winPos; + QPoint dragPos; + +signals: + void updateHotspotList(); + void btnHotspotState(); +}; + +#endif // DLGHOTSPOTCREATE_H diff --git a/hot-spot/dlghotspotcreate.ui b/hot-spot/dlghotspotcreate.ui new file mode 100644 index 00000000..989108f6 --- /dev/null +++ b/hot-spot/dlghotspotcreate.ui @@ -0,0 +1,169 @@ + + + DlgHotspotCreate + + + + 0 + 0 + 432 + 250 + + + + Dialog + + + + + 0 + 0 + 120 + 32 + + + + + + + + + + 9 + 9 + 16 + 16 + + + + + + + + + + 34 + 6 + 80 + 20 + + + + + + + + + + 215 + 210 + 90 + 30 + + + + + + + + + + 315 + 210 + 90 + 30 + + + + + + + + + + 76 + 60 + 90 + 20 + + + + + + + + + + 175 + 55 + 200 + 32 + + + + + + + 76 + 105 + 90 + 20 + + + + + + + + + + 175 + 100 + 200 + 32 + + + + + + + 76 + 150 + 90 + 20 + + + + + + + + + + 175 + 145 + 200 + 32 + + + + QLineEdit::Password + + + + + + 350 + 157 + 18 + 9 + + + + + + + + + + diff --git a/kylin-dbus-interface.cpp b/kylin-dbus-interface.cpp index bf2e9ab3..ec0a22c1 100644 --- a/kylin-dbus-interface.cpp +++ b/kylin-dbus-interface.cpp @@ -26,6 +26,8 @@ KylinDBus::KylinDBus(MainWindow *mainWindow, QObject *parent) :QObject(parent) getObjectPath(); //获取dbus中 lan 与 WiFi 的device路径 getPhysicalCarrierState(0); //初始化获取网线插入状态 + getLanHwAddressState(); //获取有线网Mac地址 + getWiredCardName(); QDBusConnection::systemBus().connect(QString("org.freedesktop.NetworkManager"), QString("/org/freedesktop/NetworkManager"), @@ -42,7 +44,7 @@ KylinDBus::KylinDBus(MainWindow *mainWindow, QObject *parent) :QObject(parent) QString("org.freedesktop.NetworkManager.Device.Wired"), QString("PropertiesChanged"), this, SLOT(onLanPropertyChanged(QVariantMap) ) ); - if (wiredPath.path() != ""){ + if (wirelessPath.path() != ""){ QDBusConnection::systemBus().connect(QString("org.freedesktop.NetworkManager"), QString(wirelessPath.path()), QString("org.freedesktop.NetworkManager.Device.Wireless"), @@ -52,6 +54,7 @@ KylinDBus::KylinDBus(MainWindow *mainWindow, QObject *parent) :QObject(parent) QString(wirelessPath.path()), QString("org.freedesktop.NetworkManager.Device.Wireless"), QString("AccessPointAdded"), this, SLOT(onAccessPointAdded(QDBusObjectPath) ) ); + getWirelessCardName();//获取无线网卡名称 } time = new QTimer(this); @@ -95,10 +98,8 @@ void KylinDBus::getPhysicalCarrierState(int n) QDBusReply reply = interface.call("Get", "org.freedesktop.NetworkManager.Device.Wired", "Carrier"); if (reply.value().toString() == "true"){ - qDebug()<<"physical carrier is found: "<mw->onPhysicalCarrierChanged(isWiredCableOn);} } +void KylinDBus::getLanHwAddressState() +{ + QDBusInterface lanInterface( "org.freedesktop.NetworkManager", + wiredPath.path(), + "org.freedesktop.DBus.Properties", + QDBusConnection::systemBus() ); + + QDBusReply lanReply = lanInterface.call("Get", "org.freedesktop.NetworkManager.Device.Wired", "HwAddress"); + dbusLanMac = lanReply.value().toString(); +} + +void KylinDBus::getWiredCardName() +{ + QDBusInterface lanInterface( "org.freedesktop.NetworkManager", + wiredPath.path(), + "org.freedesktop.DBus.Properties", + QDBusConnection::systemBus() ); + + QDBusReply lanReply = lanInterface.call("Get", "org.freedesktop.NetworkManager.Device", "Interface"); + dbusLanCardName = lanReply.value().toString(); +} + +void KylinDBus::getWirelessCardName() +{ + QDBusInterface lanInterface( "org.freedesktop.NetworkManager", + wirelessPath.path(), + "org.freedesktop.DBus.Properties", + QDBusConnection::systemBus() ); + + QDBusReply lanReply = lanInterface.call("Get", "org.freedesktop.NetworkManager.Device", "Interface"); + dbusWiFiCardName = lanReply.value().toString(); +} + +void KylinDBus::getLanIp(QString netName) +{ + QDBusInterface m_interface("org.freedesktop.NetworkManager", + "/org/freedesktop/NetworkManager/Settings", + "org.freedesktop.NetworkManager.Settings", + QDBusConnection::systemBus() ); + QDBusReply> m_reply = m_interface.call("ListConnections"); + + QList m_objNets = m_reply.value(); + foreach (QDBusObjectPath objNet, m_objNets){ + QDBusInterface m_interface("org.freedesktop.NetworkManager", + objNet.path(), + "org.freedesktop.NetworkManager.Settings.Connection", + QDBusConnection::systemBus()); + QDBusMessage reply = m_interface.call("GetSettings"); + const QDBusArgument &dbusArg = reply.arguments().at( 0 ).value(); + //DBus type : a{sa{sv}}, a map with a key of QString, which maps to another map of QString,QVariant + QMap> map; + dbusArg >> map; + + //方法一 + for (int i =0;i<2;i++){ + if(map.values().at(1).values().at(i).toString() == netName){ + dbusLanIpv4 = map.values().at(2).values().at(4).toString(); + dbusLanIpv6 = map.values().at(3).values().at(5).toString(); + break; + } + } + +// //方法二,仅供参考,暂不能用 +// for(QString key : map.keys() ){ +// QMap innerMap = map.value(key); +// qDebug() << "Key: " << key; +// if (key == "ipv4") { +// for (QString inner_key : innerMap.keys()){ +// qDebug() << " " << inner_key << ":" << innerMap.value(inner_key); +// } +// } +// } + } +} + +void KylinDBus::getWifiMac(QString netName, int num) +{ + dbusWifiMac = ""; + + QDBusInterface interface( "org.freedesktop.NetworkManager", + wirelessPath.path(), + "org.freedesktop.NetworkManager.Device.Wireless", + QDBusConnection::systemBus() ); + + QDBusReply> reply = interface.call("GetAllAccessPoints"); + QList objPaths = reply.value(); + int n = 0; + foreach (QDBusObjectPath objPath, objPaths){ + if (n == num){ + QDBusInterface path_interface( "org.freedesktop.NetworkManager", + objPath.path(), + "org.freedesktop.DBus.Properties", + QDBusConnection::systemBus() ); + + QDBusReply path_reply = path_interface.call("Get", "org.freedesktop.NetworkManager.AccessPoint", "HwAddress"); + dbusWifiMac = path_reply.value().toString(); + } + n += 1; + } +} + +void KylinDBus::getActWifiMac(QString netName) +{ + dbusWifiMac = ""; + + QDBusInterface m_interface("org.freedesktop.NetworkManager", + "/org/freedesktop/NetworkManager/Settings", + "org.freedesktop.NetworkManager.Settings", + QDBusConnection::systemBus() ); + QDBusReply> m_reply = m_interface.call("ListConnections"); + + QList m_objNets = m_reply.value(); + foreach (QDBusObjectPath objNet, m_objNets){ + QDBusInterface m_interface("org.freedesktop.NetworkManager", + objNet.path(), + "org.freedesktop.NetworkManager.Settings.Connection", + QDBusConnection::systemBus()); + QDBusMessage reply = m_interface.call("GetSettings"); + const QDBusArgument &dbusArg = reply.arguments().at( 0 ).value(); + QMap> map; + dbusArg >> map; + if (map.values().at(0).values().size() >= 5){ + if(map.values().at(2).values().at(0).toString() == netName){ + dbusWifiMac = map.values().at(0).values().at(3).toString(); + } + } + } +} + int KylinDBus::getAccessPointsNumber() { QDBusInterface interface( "org.freedesktop.NetworkManager", @@ -119,7 +249,7 @@ int KylinDBus::getAccessPointsNumber() QList objPaths = reply.value(); // foreach (QDBusObjectPath objPath, objPaths){ -// qDebug()<<"*****path is: "<resize(316, 467); + this->resize(480, 500); this->loadingGif = new QLabel(this); this->loadingGif->resize(96, 96); - this->loadingGif->move(this->width() / 2 - 96 / 2, this->height() / 2 - 96 / 2); + this->loadingGif->move(this->width() / 2 - 96 / 2 + 20, this->height() / 2 - 96 / 2); this->loadingGif->show(); diff --git a/mainwindow.cpp b/mainwindow.cpp index e6112a2f..ba50dd36 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -20,6 +20,7 @@ #include "ui_mainwindow.h" #include "oneconnform.h" #include "onelancform.h" +#include "hot-spot/dlghotspotcreate.h" QString llname, lwname, hideWiFiConn; int currentActWifiSignalLv, count_loop; @@ -34,7 +35,7 @@ MainWindow::MainWindow(QWidget *parent) : // 如果使用Qt::Popup 任务栏不显示且保留X事件如XCB_FOCUS_OUT, 但如果indicator点击鼠标右键触发,XCB_FOCUS_OUT事件依然会失效 // 如果使用Qt::ToolTip, Qt::Tool + Qt::WindowStaysOnTopHint, Qt::X11BypassWindowManagerHint等flag则会导致X事件失效 - this->setWindowFlags(Qt::FramelessWindowHint | Qt::Popup); + this->setWindowFlags(Qt::FramelessWindowHint | Qt::Popup);//QTool // this->setWindowFlags(Qt::FramelessWindowHint | Qt::Tool | Qt::WindowStaysOnTopHint); // this->setWindowFlags(Qt::FramelessWindowHint); @@ -53,15 +54,42 @@ MainWindow::MainWindow(QWidget *parent) : loading = new LoadingDiv(this); + topLanListWidget = new QWidget(ui->centralWidget); + topLanListWidget->move(41, 52); + topLanListWidget->resize(435, 60 + 46); + lbTopLanList = new QLabel(topLanListWidget); + lbTopLanList->setText(tr("Ethernet Networks"));//"可用网络列表" + lbTopLanList->resize(260, 46); + lbTopLanList->move(12, 60); + lbTopLanList->setStyleSheet("QLabel{font-size:16px;color:rgba(255,255,255,0.97);}"); + lbTopLanList->show(); + + lbLoadDown = new QLabel(ui->centralWidget); + lbLoadDown->move(41 + 132, 52 + 31); + lbLoadDown->resize(65, 20); + lbLoadUp = new QLabel(ui->centralWidget); + lbLoadUp->move(41 + 207, 52 + 31); + lbLoadUp->resize(65, 20); + + topWifiListWidget = new QWidget(ui->centralWidget); + topWifiListWidget->move(41, 52); + topWifiListWidget->resize(435, 60 + 46); + lbTopWifiList = new QLabel(topWifiListWidget); + lbTopWifiList->setText(tr("Wifi Networks"));//"可用网络列表" + lbTopWifiList->resize(260, 46); + lbTopWifiList->move(12, 60); + lbTopWifiList->setStyleSheet("QLabel{font-size:16px;color:rgba(255,255,255,0.97);}"); + lbTopWifiList->show(); + scrollAreal = new QScrollArea(ui->centralWidget); - scrollAreal->move(1, 38); - scrollAreal->resize(314, 354); + scrollAreal->move(41, 158); + scrollAreal->resize(440, 356); scrollAreal->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); scrollAreal->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); scrollAreaw = new QScrollArea(ui->centralWidget); - scrollAreaw->move(1, 38); - scrollAreaw->resize(314, 354); + scrollAreaw->move(41, 158); + scrollAreaw->resize(440, 356); scrollAreaw->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); scrollAreaw->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); @@ -70,71 +98,126 @@ MainWindow::MainWindow(QWidget *parent) : lbLanList = new QLabel(lanListWidget); lbWifiList = new QLabel(wifiListWidget); - btnOffQss = "QLabel{background-color:#283138;}"; - btnOnQss = "QLabel{background-color:#3593b5;}"; + 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)}"; + btnBgOffQss = "QLabel{min-width: 48px; min-height: 22px;max-width:48px; max-height: 22px;border-radius: 10px; background-color:rgba(255,255,255,0.2)}"; + btnBgOnQss = "QLabel{min-width: 48px; min-height: 22px;max-width:48px; max-height: 22px;border-radius: 10px; background-color:rgba(61,107,229,1);}"; ui->centralWidget->setStyleSheet("#centralWidget{border:1px solid #626c6e;background-color:#151a1e;}"); - ui->wdgHead->setStyleSheet("#wdgHead{background-color:rgba(8,10,12,0.6);}"); + ui->wdgHead->setStyleSheet("#wdgHead{background:rgba(14,19,22,0.75);}"); + + ui->lbNetwork->setStyleSheet("QLabel{font-size:20px;color:rgba(255,255,255,0.97);}"); + ui->lbNetwork->show(); + + topLanListWidget->setStyleSheet("QWidget{border:none;}"); + topLanListWidget->setStyleSheet("background-color:transparent;"); + + topWifiListWidget->setStyleSheet("QWidget{border:none;}"); + topWifiListWidget->setStyleSheet("background-color:transparent;"); + + lbLoadUp->setStyleSheet("QLabel{font-size:14px;color:rgba(255,255,255,0.57);}"); + lbLoadDown->setStyleSheet("QLabel{font-size:14px;color:rgba(255,255,255,0.57);}"); + lbLoadUp->setText("0Kb/s"); + lbLoadDown->setText("0Kb/s"); scrollAreal->setStyleSheet("QScrollArea{border:none;}"); scrollAreal->viewport()->setStyleSheet("background-color:transparent;"); - scrollAreal->verticalScrollBar()->setStyleSheet("QScrollBar:vertical{margin:0px 0px 0px 0px;background:transparent;border:0px;width:6px;}" + scrollAreal->verticalScrollBar()->setStyleSheet("QScrollBar:vertical{margin:0px 0px 0px 0px;background:transparent;border:0px;width:3px;}" "QScrollBar::up-arrow:vertical{height:0px;}" "QScrollBar::sub-line:vertical{border:0px solid;height:0px}" "QScrollBar::sub-page:vertical{background:transparent;}" - "QScrollBar::handle:vertical{background-color:#3593b5;}" - "QScrollBar::handle:vertical:hover{background-color:#3593b5;}" - "QScrollBar::handle:vertical:pressed{background-color:#3593b5;}" + "QScrollBar::handle:vertical{background:rgba(255,255,255,0.25);}" + "QScrollBar::handle:vertical:hover{background:rgba(255,255,255,1);}" + "QScrollBar::handle:vertical:pressed{background:rgba(255,255,255,1);}" "QScrollBar::add-page:vertical{background:transparent;}" "QScrollBar::add-line:vertical{border:0px solid;height:0px}" "QScrollBar::down-arrow:vertical{height:0px;}"); + scrollAreaw->setStyleSheet("QScrollArea{border:none;}"); scrollAreaw->viewport()->setStyleSheet("background-color:transparent;"); - scrollAreaw->verticalScrollBar()->setStyleSheet("QScrollBar:vertical{margin:0px 0px 0px 0px;background:transparent;border:0px;width:6px;}" + scrollAreaw->verticalScrollBar()->setStyleSheet("QScrollBar:vertical{margin:0px 0px 0px 0px;background:transparent;border:0px;width:10px;}" "QScrollBar::up-arrow:vertical{height:0px;}" "QScrollBar::sub-line:vertical{border:0px solid;height:0px}" "QScrollBar::sub-page:vertical{background:transparent;}" - "QScrollBar::handle:vertical{background-color:#3593b5;}" - "QScrollBar::handle:vertical:hover{background-color:#3593b5;}" - "QScrollBar::handle:vertical:pressed{background-color:#3593b5;}" + "QScrollBar::handle:vertical{background:rgba(255,255,255,0.25);}" + "QScrollBar::handle:vertical:hover{background:rgba(255,255,255,1);}" + "QScrollBar::handle:vertical:pressed{background:rgba(255,255,255,1);}" "QScrollBar::add-page:vertical{background:transparent;}" "QScrollBar::add-line:vertical{border:0px solid;height:0px}" "QScrollBar::down-arrow:vertical{height:0px;}"); - ui->btnNetList->setStyleSheet("#btnNetList{font-size:12px;color:white;border:1px solid rgba(255,255,255,0.1);background:transparent;background-color:rgba(0,0,0,0.2);}" - "#btnNetList:Pressed{border:1px solid rgba(255,255,255,0.5);background:transparent;background-color:rgba(255,255,255,0.1);}"); - ui->btnWifiList->setStyleSheet("#btnWifiList{font-size:12px;color:white;border:1px solid rgba(255,255,255,0.1);background:transparent;background-color:rgba(0,0,0,0.2);}" - "#btnWifiList:Pressed{border:1px solid rgba(255,255,255,0.5);background:transparent;background-color:rgba(255,255,255,0.1);}"); + ui->btnNetList->setStyleSheet("QPushButton{border:none;}"); + ui->btnNetList->setFocusPolicy(Qt::NoFocus); + QString txtEthernet(tr("Ethernet")); + ui->btnNetList->setToolTip("  " + txtEthernet + "  "); + ui->lbNetListBG->setStyleSheet(btnOffQss); + ui->lbNetListImg->setStyleSheet("QLabel{background-image:url(:/res/x/net-list-bg.svg);}"); + + ui->btnWifiList->setStyleSheet("QPushButton{border:none;}"); + ui->btnWifiList->setFocusPolicy(Qt::NoFocus); + QString txtWifi(tr("Wifi")); + ui->btnWifiList->setToolTip("  " + txtWifi + "  "); + ui->lbWifiListBG->setStyleSheet(btnOffQss); + ui->lbWifiListImg->setStyleSheet("QLabel{background-image:url(:/res/x/wifi-list-bg.svg);}"); ui->btnNet->setStyleSheet("QPushButton{border:none;}"); - ui->lbBtnNetT1->setStyleSheet("QLabel{font-size:13px;color:#ffffff;}"); - ui->lbBtnNetT2->setStyleSheet("QLabel{font-size:12px;font-weight:100;color:#ffffff;}"); + ui->btnNet->hide(); + ui->lbBtnNetBG->hide(); ui->btnWifi->setStyleSheet("QPushButton{border:none;}"); - ui->lbBtnWifiT1->setStyleSheet("QLabel{font-size:13px;color:#ffffff;}"); - ui->lbBtnWifiT2->setStyleSheet("QLabel{font-size:12px;font-weight:100;color:#ffffff;}"); + ui->btnWifi->setFocusPolicy(Qt::NoFocus); + ui->lbBtnWifiBall->setStyleSheet("QLabel{min-width: 16px; min-height: 16px;max-width:16px; max-height: 16px;" + "border-radius: 8px; border:1px solid white;background:white;}"); - ui->btnAdvConf->setStyleSheet("QPushButton{border:none;}"); - ui->lbConfImg->setStyleSheet("QLabel{background-image:url(:/res/x/setup.png);}"); - ui->lbBtnConfT2->setStyleSheet("QLabel{font-size:12px;font-weight:100;color:#ffffff;}"); + ui->btnHotspot->setStyleSheet("QPushButton{border:0px;border-radius:4px;background-color:rgba(255,255,255,0.12);color:white;font-size:14px;}" + "QPushButton:Hover{border:0px solid rgba(255,255,255,0.2);border-radius:4px;background-color:rgba(255,255,255,0.2);}" + "QPushButton:Pressed{border-radius:4px;background-color:rgba(255,255,255,0.08);}"); + ui->btnHotspot->setFocusPolicy(Qt::NoFocus); + QString txtHotSpot(tr("HotSpot")); + ui->btnHotspot->setToolTip("  " + txtHotSpot + "  "); + ui->btnHotspot->hide(); + ui->lbHotImg->hide(); + ui->lbHotImg->setStyleSheet("QLabel{background-image:url(:/res/x/hot-spot-off.svg);}"); + ui->lbHotBG->hide(); + ui->lbHotBG->setStyleSheet(btnOffQss); + + ui->btnFlyMode->setStyleSheet("QPushButton{border:0px;border-radius:4px;background-color:rgba(255,255,255,0.12);color:white;font-size:14px;}" + "QPushButton:Hover{border:0px solid rgba(255,255,255,0.2);border-radius:4px;background-color:rgba(255,255,255,0.2);}" + "QPushButton:Pressed{border-radius:4px;background-color:rgba(255,255,255,0.08);}"); + ui->btnFlyMode->setFocusPolicy(Qt::NoFocus); + QString txtFlyMode(tr("FlyMode")); + ui->btnFlyMode->setToolTip("  " + txtFlyMode + "  "); + ui->btnFlyMode->hide(); + ui->lbFlyImg->hide(); + ui->lbFlyImg->setStyleSheet("QLabel{background-image:url(:/res/x/fly-mode-off.svg);}"); + ui->lbFlyBG->hide(); + ui->lbFlyBG->setStyleSheet(btnOffQss); + + ui->btnAdvConf->setStyleSheet("QPushButton{border:0px;border-radius:4px;background-color:rgba(255,255,255,0.12);color:white;font-size:14px;}" + "QPushButton:Hover{border:0px solid rgba(255,255,255,0.2);border-radius:4px;background-color:rgba(255,255,255,0.2);}" + "QPushButton:Pressed{border-radius:4px;background-color:rgba(255,255,255,0.08);}"); + ui->btnAdvConf->setFocusPolicy(Qt::NoFocus); + QString txtAdvanced(tr("Advanced")); + ui->btnAdvConf->setToolTip("  " + txtAdvanced + "  "); + ui->lbBtnConfImg->setStyleSheet("QLabel{background-image:url(:/res/x/setup.png);}"); + ui->lbBtnConfBG->hide(); ui->lbBtnConfBG->setStyleSheet(btnOffQss); - ui->lbBtnNetT2->setText(tr("Network"));//"网络" - ui->lbBtnWifiT2->setText("Wifi"); - ui->lbBtnConfT2->setText(tr("Advanced"));//"高级设置" - - ui->btnNetList->setText(tr("Ethernet"));//"有线网络" - ui->btnWifiList->setText(tr("Wifi"));//"无线网络" + ui->line->hide(); createTrayIcon(); connect(trayIcon, &QSystemTrayIcon::activated, this, &MainWindow::iconActivated); + connect(mShowWindow,SIGNAL(triggered()),this,SLOT(on_showWindowAction())); + connect(mAdvConf,SIGNAL(triggered()),this,SLOT(on_btnAdvConf_clicked())); + connect(ksnm, SIGNAL(getLanListFinished(QStringList)), this, SLOT(getLanListDone(QStringList))); connect(ksnm, SIGNAL(getWifiListFinished(QStringList)), this, SLOT(getWifiListDone(QStringList))); objKyDBus = new KylinDBus(this); + objNetSpeed = new NetworkSpeed(); checkIsWirelessDeviceOn(); //检测无线网卡是否插入 getInitLanSlist(); //初始化有线网列表 @@ -181,11 +264,31 @@ bool MainWindow::nativeEvent(const QByteArray &eventType, void *message, long *r return false; } +//托盘管理 void MainWindow::createTrayIcon() { - trayIconMenu = new QMenu(this); trayIcon = new QSystemTrayIcon(this); trayIcon->setToolTip(QString(tr("kylin-nm"))); + + trayIconMenu = new QMenu(this); + trayIconMenu->setStyleSheet("QMenu {background-color: rgba(8,10,12,90%);" + "border: 1px solid #626c6e;" + "border-radius: 2px;" + "padding: 4px 2px 4px 2px;}"); + mShowWindow = new QWidgetAction(trayIconMenu); + mAdvConf = new QWidgetAction(trayIconMenu); + + wid = new QWidget(); + wid_new = new QWidget(); + + mShowWindow->setDefaultWidget(wid); + mAdvConf->setDefaultWidget(wid_new); + + init_widget_action(wid, "", tr("Show MainWindow")); + init_widget_action(wid_new, ":/res/x/setup.png", tr("Advanced")); + + trayIconMenu->addAction(mShowWindow); + trayIconMenu->addAction(mAdvConf); trayIcon->setContextMenu(trayIconMenu); // 初始化托盘所有Icon @@ -237,6 +340,124 @@ void MainWindow::setTrayLoading(bool isLoading){ } } +void MainWindow::iconActivated(QSystemTrayIcon::ActivationReason reason) +{ + // switch (reason) { + // case QSystemTrayIcon::Trigger: + // case QSystemTrayIcon::DoubleClick: + // case QSystemTrayIcon::MiddleClick: + // break; + // } + + switch(reason){ + case QSystemTrayIcon::Trigger: + case QSystemTrayIcon::MiddleClick: + //这里右键点击托盘图标无效 + handleIconClicked(); + if(this->isHidden()){ + this->showNormal(); + }else{ + this->hide(); + } + break; + default: + break; + } +} + +void MainWindow::handleIconClicked() +{ + QRect availableGeometry = qApp->primaryScreen()->availableGeometry(); + QRect screenGeometry = qApp->primaryScreen()->geometry(); + + QDesktopWidget* pDesktopWidget = QApplication::desktop(); +// int nScreenCount = QApplication::desktop()->screenCount(); +// QRect deskRect = pDesktopWidget->availableGeometry();//可用区域 + QRect screenRect = pDesktopWidget->screenGeometry();//屏幕区域 + +// qDebug()<<"screenRect.x(): "<move(availableGeometry.x() + availableGeometry.width() - this->width(), availableGeometry.height() - this->height()); + }else { + this->move(availableGeometry.x() + availableGeometry.width() - this->width(), availableGeometry.height() - this->height() - 40); + } + +// QPoint pos = QCursor::pos(); +// QRect primaryGeometry; +// for (QScreen *screen : qApp->screens()) { +// if (screen->geometry().contains(pos)) { +// primaryGeometry = screen->geometry(); +// } +// } +// if (primaryGeometry.isEmpty()) { +// primaryGeometry = qApp->primaryScreen()->geometry(); +// } +// this->move(primaryGeometry.x() + primaryGeometry.width() - this->width(), primaryGeometry.height() - this->height()); +} + +void MainWindow::on_showWindowAction() +{ + handleIconClicked(); + this->showNormal(); +} + +void MainWindow::init_widget_action(QWidget *wid, QString iconstr, QString textstr) +{ + QString style="QWidget{background:transparent;border:0px;}\ + QWidget:hover{background-color:#34bed8ef;}\ + QWidget:pressed{background-color:#3abed8ef;}"; + + QHBoxLayout* layout=new QHBoxLayout(wid); + wid->setLayout(layout); + wid->setFixedSize(250, 42); + wid->setStyleSheet(style); + wid->setFocusPolicy(Qt::NoFocus); + + if(!iconstr.isEmpty()) { + QLabel* labelicon=new QLabel(wid); + labelicon->setFixedSize(16, 16); + labelicon->move(10, 14); + QPixmap *pixmap = new QPixmap(":/res/x/setup.png"); + pixmap->scaled(labelicon->size(), Qt::KeepAspectRatio); + labelicon->setScaledContents(true); + labelicon->setPixmap(*pixmap); + +// QLabel* labelicon=new QLabel(wid); +// QSvgRenderer* svg=new QSvgRenderer(wid); //#include +// svg->load(iconstr); +// QPixmap* pixmap=new QPixmap(22, 22); +// pixmap->fill(Qt::transparent); +// QPainter p(pixmap); +// svg->render(&p); +// labelicon->setPixmap(*pixmap); +// labelicon->setFixedSize(pixmap->size()); +// labelicon->move(10, 14); +// labelicon->setAlignment(Qt::AlignCenter); +// labelicon->setStyleSheet("QLabel{background:transparent;border:0px;}"); +// labelicon->setStyleSheet("QLabel{background-image:url(:/res/x/setup.png);}"); +// layout->addWidget(labelicon); + } + + QLabel* labeltext=new QLabel(wid); + labeltext->setStyleSheet("background:transparent;border:0px;color:rgba(255,255,255,0.91);font-size:14px;"); + QByteArray textbyte=textstr.toLocal8Bit(); + char* text=textbyte.data(); + labeltext->setText(tr(text)); + labeltext->adjustSize(); + layout->addWidget(labeltext); + + iconstr = ""; //用QSvgRenderer的话这句要注释掉 + if(!iconstr.isEmpty()) { + layout->setContentsMargins(10,0,wid->width()-16-labeltext->width()-20,0); + layout->setSpacing(5); + } + else { + layout->setContentsMargins(36,0,0,0); + } +} + +//加载动画 void MainWindow::startLoading() { loading->startLoading(); @@ -268,14 +489,25 @@ void MainWindow::getActiveInfo() index ++; } - // 确保currentActWifiSignalLv有值 - QList wifiList = wifiListWidget->findChildren(); - for(int i = 0; i < wifiList.size(); i ++){ - OneConnForm *ocf = wifiList.at(i); - if(ocf->isActive == true){ - currentActWifiSignalLv = ocf->signalLv; - break; - } + //ukui2.0中获取currentActWifiSignalLv的值 + //QList wifiList = wifiListWidget->findChildren(); + //for(int i = 0; i < wifiList.size(); i ++){ + // OneConnForm *ocf = wifiList.at(i); + // if(ocf->isActive == true){ + // currentActWifiSignalLv = ocf->signalLv; + // break; + // } + //} + + //ukui3.0中获取currentActWifiSignalLv的值 + if(activeWifiSignalLv > 75){ + currentActWifiSignalLv = 1; + }else if(activeWifiSignalLv > 55 && activeWifiSignalLv <= 75){ + currentActWifiSignalLv = 2; + }else if(activeWifiSignalLv > 35 && activeWifiSignalLv <= 55){ + currentActWifiSignalLv = 3; + }else if( activeWifiSignalLv <= 35){ + currentActWifiSignalLv = 4; } // 设置图标 @@ -491,28 +723,20 @@ void MainWindow::initNetwork() qDebug()<<"lstate ="<lstate<<" wstate ="<wstate ; syslog(LOG_DEBUG, "state of switch: lstate =%d wstate =%d", iface->lstate, iface->wstate); if(iface->lstate == 0 || iface->lstate == 1){ - ui->lbLanImg->setStyleSheet("QLabel{background-image:url(:/res/x/network-line.png);}"); ui->lbBtnNetBG->setStyleSheet(btnOnQss); - ui->lbBtnNetT1->setText(tr("Enabled"));//"已开启" if(iface->wstate == 0 || iface->wstate == 1){ - ui->lbWifiImg->setStyleSheet("QLabel{background-image:url(:/res/x/wifi-line.png);}"); - ui->lbBtnWifiBG->setStyleSheet(btnOnQss); - ui->lbBtnWifiT1->setText(tr("Enabled"));//"已开启" + ui->lbBtnWifiBG->setStyleSheet(btnBgOnQss); + ui->lbBtnWifiBall->move(438, 22); }else{ - ui->lbWifiImg->setStyleSheet("QLabel{background-image:url(:/res/x/wifi-offline.png);}"); - ui->lbBtnWifiBG->setStyleSheet(btnOffQss); - ui->lbBtnWifiT1->setText(tr("Disabled"));//"已关闭" + ui->lbBtnWifiBG->setStyleSheet(btnBgOffQss); + ui->lbBtnWifiBall->move(412, 22); } - }else{ - ui->lbLanImg->setStyleSheet("QLabel{background-image:url(:/res/x/network-offline.png);}"); ui->lbBtnNetBG->setStyleSheet(btnOffQss); - ui->lbBtnNetT1->setText(tr("Disabled"));//"已关闭" - ui->lbWifiImg->setStyleSheet("QLabel{background-image:url(:/res/x/wifi-offline.png);}"); - ui->lbBtnWifiBG->setStyleSheet(btnOffQss); - ui->lbBtnWifiT1->setText(tr("Disabled"));//"已关闭" + ui->lbBtnWifiBG->setStyleSheet(btnBgOffQss); + ui->lbBtnWifiBall->move(412, 22); } // 初始化网络列表 @@ -530,9 +754,10 @@ void MainWindow::initNetwork() } } on_btnWifiList_clicked(); - ui->btnWifiList->setStyleSheet("#btnWifiList{font-size:12px;color:white;border:1px solid rgba(255,255,255,0.1);border:1px solid rgba(255,255,255,0.5);background:transparent;background-color:rgba(255,255,255,0.1);}"); - ui->btnNetList->setStyleSheet("#btnNetList{font-size:12px;color:white;border:1px solid rgba(255,255,255,0.1);background:transparent;background-color:rgba(0,0,0,0.2);}" - "#btnNetList:Pressed{border:1px solid rgba(255,255,255,0.5);background:transparent;background-color:rgba(255,255,255,0.1);}"); + + ui->btnNetList->setStyleSheet("QPushButton{border:0px solid rgba(255,255,255,0);background-color:rgba(255,255,255,0);}"); + ui->btnWifiList->setStyleSheet("QPushButton{border:none;}"); + }else{ if(iface->lstate != 2){ if (iface->lstate == 0) { @@ -544,9 +769,9 @@ void MainWindow::initNetwork() //checkIfNetworkOn->start(8000); } on_btnNetList_clicked(); - ui->btnNetList->setStyleSheet("#btnNetList{font-size:12px;color:white;border:1px solid rgba(255,255,255,0.1);border:1px solid rgba(255,255,255,0.5);background:transparent;background-color:rgba(255,255,255,0.1);}"); - ui->btnWifiList->setStyleSheet("#btnWifiList{font-size:12px;color:white;border:1px solid rgba(255,255,255,0.1);background:transparent;background-color:rgba(0,0,0,0.2);}" - "#btnWifiList:Pressed{border:1px solid rgba(255,255,255,0.5);background:transparent;background-color:rgba(255,255,255,0.1);}"); + + ui->btnNetList->setStyleSheet("QPushButton{border:0px solid rgba(255,255,255,0);background-color:rgba(255,255,255,0);}"); + ui->btnWifiList->setStyleSheet("QPushButton{border:none;}"); }else { disNetDone(); } @@ -570,63 +795,11 @@ void MainWindow::initNetwork() deleteLanTimer = new QTimer(this); deleteLanTimer->setTimerType(Qt::PreciseTimer); QObject::connect(deleteLanTimer, SIGNAL(timeout()), this, SLOT(onDeleteLan())); -} -void MainWindow::iconActivated(QSystemTrayIcon::ActivationReason reason) -{ - // switch (reason) { - // case QSystemTrayIcon::Trigger: - // case QSystemTrayIcon::DoubleClick: - // case QSystemTrayIcon::MiddleClick: - // break; - // } - - switch(reason){ - case QSystemTrayIcon::Trigger: - case QSystemTrayIcon::MiddleClick: - //这里右键点击托盘图标无效 - moveBottomRight(); - if(this->isHidden()){ - this->showNormal(); - }else{ - this->hide(); - } - break; - default: - break; - - } -} - -void MainWindow::moveBottomRight() -{ - QRect availableGeometry = qApp->primaryScreen()->availableGeometry(); - QRect screenGeometry = qApp->primaryScreen()->geometry(); - - QDesktopWidget* pDesktopWidget = QApplication::desktop(); -// int nScreenCount = QApplication::desktop()->screenCount(); -// QRect deskRect = pDesktopWidget->availableGeometry();//可用区域 - QRect screenRect = pDesktopWidget->screenGeometry();//屏幕区域 - -// qDebug()<<"screenRect.x(): "<move(availableGeometry.x() + availableGeometry.width() - this->width(), availableGeometry.height() - this->height()); - }else { - this->move(availableGeometry.x() + availableGeometry.width() - this->width(), availableGeometry.height() - this->height() - 40); - } - -// QPoint pos = QCursor::pos(); -// QRect primaryGeometry; -// for (QScreen *screen : qApp->screens()) { -// if (screen->geometry().contains(pos)) { -// primaryGeometry = screen->geometry(); -// } -// } -// if (primaryGeometry.isEmpty()) { -// primaryGeometry = qApp->primaryScreen()->geometry(); -// } -// this->move(primaryGeometry.x() + primaryGeometry.width() - this->width(), primaryGeometry.height() - this->height()); + setNetSpeed = new QTimer(this); + setNetSpeed->setTimerType(Qt::PreciseTimer); + QObject::connect(setNetSpeed, SIGNAL(timeout()), this, SLOT(on_setNetSpeed())); + setNetSpeed->start(3000); } bool MainWindow::checkLanOn() @@ -664,10 +837,23 @@ void MainWindow::getLanListDone(QStringList slist) this->ksnm->isUseOldLanSlist = false; } + // 清空top列表 + delete topLanListWidget; + topLanListWidget = new QWidget(ui->centralWidget); + topLanListWidget->move(41, 52); + topLanListWidget->resize(435, 60 + 46); + lbTopLanList = new QLabel(topLanListWidget); + lbTopLanList->setText(tr("Ethernet Networks"));//"可用网络列表" + lbTopLanList->resize(260, 46); + lbTopLanList->move(12, 60); + lbTopLanList->setStyleSheet("QLabel{font-size:16px;color:rgba(255,255,255,0.97);}"); + lbTopLanList->show(); // 清空lan列表 lanListWidget = new QWidget(scrollAreal); - lanListWidget->resize(314, 8 + 60 + 46 + 51); + lanListWidget->resize(440, 60 + 108); scrollAreal->setWidget(lanListWidget); + scrollAreal->move(41, 158); + // 获取当前连接的lan name QString actLanName = "--"; activecon *act = kylin_network_get_activecon_info(); @@ -679,25 +865,20 @@ void MainWindow::getLanListDone(QStringList slist) } index ++; } + // 若当前lan name为"--",设置OneConnForm - OneLancForm *ccf = new OneLancForm(lanListWidget, this, confForm, ksnm); + OneLancForm *ccf = new OneLancForm(topLanListWidget, this, confForm, ksnm); if(actLanName == "--"){ ccf->setName(tr("Not connected"));//"当前未连接任何 以太网" ccf->setIcon(false); - ccf->setConnedString(tr("Disconnected"));//"未连接" - ccf->setBandWidth("--"); - ccf->setShowPoint(true); + ccf->setConnedString(1, tr("Disconnected"));//"未连接" + ccf->isConnected = false; + ccf->setTopItem(false); } ccf->setAct(true); - ccf->move(0, 8); + ccf->move(0, 0); ccf->show(); - // 可用lan列表 - lbLanList = new QLabel(lanListWidget); - lbLanList->setText(tr("Ethernet Networks"));//"可用网络列表" - lbLanList->resize(260, 46); - lbLanList->move(12, 68); - lbLanList->setStyleSheet("QLabel{font-size:12px;color:white;}"); - lbLanList->show(); + // 填充可用网络列表 QString headLine = slist.at(0); headLine = headLine.trimmed(); @@ -711,28 +892,30 @@ void MainWindow::getLanListDone(QStringList slist) if(ltype != "wifi" && ltype != "" && ltype != "--"){ // 当前连接的lan + objKyDBus->getLanIp(nname); if(nname == actLanName){ if (mwBandWidth == "Unknown!") { getLanBandWidth(); } - connect(ccf, SIGNAL(selectedOneLanForm(QString)), this, SLOT(oneLanFormSelected(QString))); + connect(ccf, SIGNAL(selectedOneLanForm(QString)), this, SLOT(oneTopLanFormSelected(QString))); connect(ccf, SIGNAL(disconnActiveLan()), this, SLOT(activeLanDisconn())); ccf->setName(nname); ccf->setIcon(true); - ccf->setBandWidth(mwBandWidth); - ccf->setShowPoint(true); - ccf->setConnedString(tr("Connected"));//"已连接" + ccf->setLanInfo(objKyDBus->dbusLanIpv4, objKyDBus->dbusLanIpv6, mwBandWidth, objKyDBus->dbusLanMac); + ccf->setConnedString(1, tr("Connected"));//"已连接" + ccf->isConnected = true; + ccf->setTopItem(false); currSelNetName = ""; syslog(LOG_DEBUG, "already insert an active lannet in the top of lan list"); }else{ - lanListWidget->resize(314, lanListWidget->height() + 60); + lanListWidget->resize(440, lanListWidget->height() + 60); OneLancForm *ocf = new OneLancForm(lanListWidget, this, confForm, ksnm); connect(ocf, SIGNAL(selectedOneLanForm(QString)), this, SLOT(oneLanFormSelected(QString))); ocf->setName(nname); ocf->setIcon(true); - ocf->setBandWidth(""); - ocf->setShowPoint(false); - ocf->move(0, 114 + j * 60); + ocf->setLanInfo(objKyDBus->dbusLanIpv4, objKyDBus->dbusLanIpv6, tr("Disconnected"), objKyDBus->dbusLanMac); + ocf->setConnedString(0, tr("Disconnected"));//"未连接" + ocf->move(0, j * 60); ocf->show(); j ++; @@ -741,7 +924,9 @@ void MainWindow::getLanListDone(QStringList slist) } this->lanListWidget->show(); + this->topLanListWidget->show(); this->wifiListWidget->hide(); + this->topWifiListWidget->hide(); this->stopLoading(); oldLanSlist = slist; @@ -763,10 +948,23 @@ void MainWindow::getWifiListDone(QStringList slist) // 加载wifi列表 void MainWindow::loadWifiListDone(QStringList slist) { + //清空top列表 + delete topWifiListWidget; + topWifiListWidget = new QWidget(ui->centralWidget); + topWifiListWidget->move(41, 52); + topWifiListWidget->resize(435, 60 + 46); + lbTopWifiList = new QLabel(topWifiListWidget); + lbTopWifiList->setText(tr("Wifi Networks"));//"可用网络列表" + lbTopWifiList->resize(260, 46); + lbTopWifiList->move(12, 60); + lbTopWifiList->setStyleSheet("QLabel{font-size:16px;color:rgba(255,255,255,0.97);}"); + lbTopWifiList->show(); // 清空wifi列表 wifiListWidget = new QWidget(scrollAreaw); - wifiListWidget->resize(314, 8 + 60 + 46 + 51); + wifiListWidget->resize(440, /*60 + */88); scrollAreaw->setWidget(wifiListWidget); + scrollAreaw->move(41, 158); + // 获取当前连接的wifi name QString actWifiName = "--"; activecon *act = kylin_network_get_activecon_info(); @@ -778,25 +976,21 @@ void MainWindow::loadWifiListDone(QStringList slist) } index ++; } + // 根据当前连接的wifi 设置OneConnForm - OneConnForm *ccf = new OneConnForm(wifiListWidget, this, confForm, ksnm); + OneConnForm *ccf = new OneConnForm(topWifiListWidget, this, confForm, ksnm); if(actWifiName == "--"){ ccf->setName(tr("Not connected"));//"当前未连接任何 Wifi" - ccf->setSafe("--"); - ccf->setSignal("0"); - ccf->setSafeString("--"); - ccf->setConnedString(tr("Disconnected"));//"未连接" + ccf->setSignal("0", "--"); + activeWifiSignalLv = 0; + ccf->setConnedString(1, tr("Disconnected"), "");//"未连接" + ccf->isConnected = false; + ccf->setTopItem(false); } ccf->setAct(true); - ccf->move(0, 8); + ccf->move(0, 0); ccf->show(); - // 可用wifi列表表头 - lbWifiList = new QLabel(wifiListWidget); - lbWifiList->setText(tr("Wifi Networks"));//"可用网络列表" - lbWifiList->resize(260, 46); - lbWifiList->move(12, 68); - lbWifiList->setStyleSheet("QLabel{font-size:12px;color:white;}"); - lbWifiList->show(); + // 填充可用网络列表 QString headLine = slist.at(0); headLine = headLine.trimmed(); @@ -805,7 +999,6 @@ void MainWindow::loadWifiListDone(QStringList slist) int indexName = headLine.indexOf("SSID"); QStringList wnames; - int count = 0; for(int i = 1, j = 0; i < slist.size(); i ++) { QString line = slist.at(i); @@ -824,26 +1017,32 @@ void MainWindow::loadWifiListDone(QStringList slist) if(wname != "" && wname != "--"){ // 当前连接的wifi if(wname == actWifiName){ - connect(ccf, SIGNAL(selectedOneWifiForm(QString)), this, SLOT(oneWifiFormSelected(QString))); + connect(ccf, SIGNAL(selectedOneWifiForm(QString)), this, SLOT(oneTopWifiFormSelected(QString))); connect(ccf, SIGNAL(disconnActiveWifi()), this, SLOT(activeWifiDisconn())); ccf->setName(wname); - ccf->setSafe(wsecu); ccf->setRate(wrate); - ccf->setSignal(wsignal); - ccf->setConnedString(tr("Connected"));//"已连接" + ccf->setSignal(wsignal, wsecu); + activeWifiSignalLv = wsignal.toInt(); + objKyDBus->getActWifiMac(wname); + ccf->setWifiInfo(wsecu, wsignal, objKyDBus->dbusWifiMac); + ccf->setConnedString(1, tr("Connected"), wsecu);//"已连接" + ccf->isConnected = true; + ccf->setTopItem(false); currSelNetName = ""; syslog(LOG_DEBUG, "already insert an active wifi in the top of wifi list"); }else{ - wifiListWidget->resize(314, wifiListWidget->height() + 60); + wifiListWidget->resize(440, wifiListWidget->height() + 60); OneConnForm *ocf = new OneConnForm(wifiListWidget, this, confForm, ksnm); connect(ocf, SIGNAL(selectedOneWifiForm(QString)), this, SLOT(oneWifiFormSelected(QString))); ocf->setName(wname); - ocf->setSafe(wsecu); ocf->setRate(wrate); - ocf->setSignal(wsignal); - ocf->move(0, 114 + j * 60); + ocf->setSignal(wsignal, wsecu); + objKyDBus->getWifiMac(wname, i-1); + ocf->setWifiInfo(wsecu, wsignal, objKyDBus->dbusWifiMac); + ocf->setConnedString(0, tr("Disconnected"), wsecu);//"未连接" + ocf->move(0, j * 60); ocf->show(); j ++; @@ -855,17 +1054,18 @@ void MainWindow::loadWifiListDone(QStringList slist) } //添加 连接到隐藏的Wi-Fi网络 小窗口 - wifiListWidget->resize(314, wifiListWidget->height() + 60); + wifiListWidget->resize(440, wifiListWidget->height() + 60); OneConnForm *hideNetButton = new OneConnForm(wifiListWidget, this, confForm, ksnm); connect(hideNetButton, SIGNAL(selectedOneWifiForm(QString)), this, SLOT(oneWifiFormSelected(QString))); hideNetButton->setSpecialName(hideWiFiConn); - hideNetButton->setSignal(0); - hideNetButton->setSafe("Safe"); - hideNetButton->move(0, 114 + count * 60); + hideNetButton->setHideItem(true, true); + hideNetButton->move(0, count * 60); hideNetButton->show(); this->lanListWidget->hide(); + this->topLanListWidget->hide(); this->wifiListWidget->show(); + this->topWifiListWidget->show(); is_stop_check_net_state = 0; this->stopLoading(); } @@ -906,10 +1106,10 @@ void MainWindow::updateWifiListDone(QStringList slist) //删除元素下面的的所有元素上移 for(int after_pos = pos+1; after_pos < wifiList.size(); after_pos ++){ OneConnForm *after_ocf = wifiList.at(after_pos); - if (lastWname == currSelNetName) {after_ocf->move(0, after_ocf->y() - 111);} + if (lastWname == currSelNetName) {after_ocf->move(0, after_ocf->y() - 60 - 88);} else {after_ocf->move(0, after_ocf->y() - 60);} } - wifiListWidget->resize(314, wifiListWidget->height() - 60); + wifiListWidget->resize(440, wifiListWidget->height() - 60); break; } } @@ -951,22 +1151,23 @@ void MainWindow::updateWifiListDone(QStringList slist) int n = wifiList.size(); OneConnForm *lastOcf = wifiList.at(n-1); lastOcf->setName(wname); - lastOcf->setSafe(wsecu); + lastOcf->setHideItem(false, false); lastOcf->setRate(wrate); - lastOcf->setSignal(wsignal); + lastOcf->setSignal(wsignal, wsecu); + objKyDBus->getWifiMac(wname, i-1); + lastOcf->setWifiInfo(wsecu, wsignal, objKyDBus->dbusWifiMac); + lastOcf->setConnedString(0, tr("Disconnected"), wsecu);//"未连接" lastOcf->setSelected(false); //lastOcf->show(); //添加 连接到隐藏的Wi-Fi网络 小窗口 - wifiListWidget->resize(314, wifiListWidget->height() + 60); + wifiListWidget->resize(440, wifiListWidget->height() + 60); OneConnForm *hideNetButton = new OneConnForm(wifiListWidget, this, confForm, ksnm); connect(hideNetButton, SIGNAL(selectedOneWifiForm(QString)), this, SLOT(oneWifiFormSelected(QString))); hideNetButton->setSpecialName(hideWiFiConn); - hideNetButton->setSignal(0); - hideNetButton->setSafe("Safe"); + hideNetButton->setHideItem(true, true); hideNetButton->move(0, lastOcf->y()+60); - hideNetButton->setHideSelected(false); - if (currSelNetName == hideWiFiConn){ hideNetButton->setHideSelected(true); } + if (currSelNetName == hideWiFiConn){ hideNetButton->setHideItem(true, true); } hideNetButton->show(); count += 1; @@ -975,7 +1176,9 @@ void MainWindow::updateWifiListDone(QStringList slist) } this->lanListWidget->hide(); + this->topLanListWidget->hide(); this->wifiListWidget->show(); + this->topWifiListWidget->show(); this->stopLoading(); } @@ -1021,18 +1224,22 @@ void MainWindow::on_btnWifi_clicked() connect(bt, SIGNAL(disWifiDone()), this, SLOT(disWifiDone())); connect(bt, SIGNAL(btFinish()), t, SLOT(quit())); t->start(); + this->startLoading(); }else{ - on_btnWifiList_clicked(); - is_stop_check_net_state = 1; - QThread *t = new QThread(); - BackThread *bt = new BackThread(); - bt->moveToThread(t); - connect(t, SIGNAL(finished()), t, SLOT(deleteLater())); - connect(t, SIGNAL(started()), bt, SLOT(execEnWifi())); - connect(bt, SIGNAL(enWifiDone()), this, SLOT(enWifiDone())); - connect(bt, SIGNAL(launchLanDone()), this, SLOT(launchLanDone())); - connect(bt, SIGNAL(btFinish()), t, SLOT(quit())); - t->start(); + if (is_fly_mode_on == 0){ + on_btnWifiList_clicked(); + is_stop_check_net_state = 1; + QThread *t = new QThread(); + BackThread *bt = new BackThread(); + bt->moveToThread(t); + connect(t, SIGNAL(finished()), t, SLOT(deleteLater())); + connect(t, SIGNAL(started()), bt, SLOT(execEnWifi())); + connect(bt, SIGNAL(enWifiDone()), this, SLOT(enWifiDone())); + connect(bt, SIGNAL(launchLanDone()), this, SLOT(launchLanDone())); + connect(bt, SIGNAL(btFinish()), t, SLOT(quit())); + t->start(); + this->startLoading(); + } } }else{ if(!checkWlOn()){ @@ -1052,8 +1259,9 @@ void MainWindow::on_btnWifi_clicked() connect(bt, SIGNAL(btFinish()), t, SLOT(quit())); t->start(); } + this->startLoading(); } - this->startLoading(); + //this->startLoading(); } else { QString txt(tr("please insert the wireless network adapter")); QString cmd = "export LANG='en_US.UTF-8';export LANGUAGE='en_US';notify-send '" + txt + "' -t 3800"; @@ -1076,12 +1284,22 @@ void MainWindow::on_btnNetList_clicked(int flag) this->is_btnNetList_clicked = 1; this->is_btnWifiList_clicked = 0; + ui->lbNetListBG->setStyleSheet(btnOnQss); + ui->lbWifiListBG->setStyleSheet(btnOffQss); + + ui->lbNetwork->setText("有线网络"); + ui->btnWifi->hide(); + ui->lbBtnWifiBG->hide(); + ui->lbBtnWifiBall->hide(); + // 强行设置为打开 if(flag == 1){ this->startLoading(); this->ksnm->execGetLanList(); this->scrollAreal->show(); + this->topLanListWidget->show(); this->scrollAreaw->hide(); + this->topWifiListWidget->hide(); on_btnNetList_pressed(); return; } @@ -1109,36 +1327,41 @@ void MainWindow::on_btnNetList_clicked(int flag) return; } + // 清空top列表 + delete topLanListWidget; + topLanListWidget = new QWidget(ui->centralWidget); + topLanListWidget->move(41, 52); + topLanListWidget->resize(435, 60 + 46); + lbTopLanList = new QLabel(topLanListWidget); + lbTopLanList->setText(tr("Ethernet Networks"));//"可用网络列表" + lbTopLanList->resize(260, 46); + lbTopLanList->move(12, 60); + lbTopLanList->setStyleSheet("QLabel{font-size:16px;color:rgba(255,255,255,0.97);}"); + lbTopLanList->show(); + // 清空lan列表 lanListWidget = new QWidget(scrollAreal); - lanListWidget->resize(314, 8 + 60 + 46 + 51); + lanListWidget->resize(440, 60 + 108); scrollAreal->setWidget(lanListWidget); + scrollAreal->move(41, 158); // 当前连接的lan - OneLancForm *ccf = new OneLancForm(lanListWidget, this, confForm, ksnm); + OneLancForm *ccf = new OneLancForm(topLanListWidget, this, confForm, ksnm); ccf->setName(tr("Not connected"));//"当前未连接任何 以太网" ccf->setIcon(false); - ccf->setConnedString(tr("Disconnected"));//"未连接" - ccf->setBandWidth("--"); - ccf->setShowPoint(true); + ccf->setConnedString(1, tr("Disconnected"));//"未连接" ccf->setAct(true); - ccf->move(0, 8); + ccf->move(0, 0); ccf->show(); - // 可用lan列表 - lbLanList = new QLabel(lanListWidget); - lbLanList->setText(tr("Ethernet Networks"));//"可用网络列表" - lbLanList->resize(260, 46); - lbLanList->move(12, 68); - lbLanList->setStyleSheet("QLabel{font-size:12px;color:white;}"); - lbLanList->show(); - this->lanListWidget->show(); this->wifiListWidget->hide(); } this->scrollAreal->show(); + this->topLanListWidget->show(); this->scrollAreaw->hide(); + this->topWifiListWidget->hide(); on_btnNetList_pressed(); } @@ -1147,41 +1370,55 @@ void MainWindow::on_btnWifiList_clicked() this->is_btnWifiList_clicked = 1; this->is_btnNetList_clicked = 0; + ui->lbNetListBG->setStyleSheet(btnOffQss); + ui->lbWifiListBG->setStyleSheet(btnOnQss); + + ui->lbNetwork->setText("无线网络"); + ui->btnWifi->show(); + ui->lbBtnWifiBG->show(); + ui->lbBtnWifiBall->show(); + if(checkWlOn()){ this->startLoading(); this->ksnm->execGetWifiList(); }else{ + delete topWifiListWidget; + topWifiListWidget = new QWidget(ui->centralWidget); + topWifiListWidget->move(41, 52); + topWifiListWidget->resize(435, 60 + 46); + lbTopWifiList = new QLabel(topWifiListWidget); + lbTopWifiList->setText(tr("Wifi Networks"));//"可用网络列表" + lbTopWifiList->resize(260, 46); + lbTopWifiList->move(12, 60); + lbTopWifiList->setStyleSheet("QLabel{font-size:16px;color:rgba(255,255,255,0.97);}"); + lbTopWifiList->show(); + // 清空wifi列表 wifiListWidget = new QWidget(scrollAreaw); - wifiListWidget->resize(314, 8 + 60 + 46 + 51); + wifiListWidget->resize(440, /*60 + */88); scrollAreaw->setWidget(wifiListWidget); + scrollAreaw->move(41, 158); // 当前连接的wifi - OneConnForm *ccf = new OneConnForm(wifiListWidget, this, confForm, ksnm); + OneConnForm *ccf = new OneConnForm(topWifiListWidget, this, confForm, ksnm); ccf->setName(tr("Not connected"));//"当前未连接任何 Wifi" - ccf->setSafe("--"); - ccf->setSignal("0"); + ccf->setSignal("0", "--"); ccf->setRate("0"); - ccf->setSafeString("--"); - ccf->setConnedString(tr("Disconnected"));//"未连接" + ccf->setConnedString(1, tr("Disconnected"), "");//"未连接" + ccf->isConnected = false; + ccf->setTopItem(false); ccf->setAct(true); - ccf->setShowPoint(true); - ccf->move(0, 8); + ccf->move(0, 0); ccf->show(); - lbWifiList = new QLabel(wifiListWidget); - lbWifiList->setText(tr("Wifi Networks"));//"可用网络列表" - lbWifiList->resize(260, 46); - lbWifiList->move(12, 68); - lbWifiList->setStyleSheet("QLabel{font-size:12px;color:white;}"); - lbWifiList->show(); - this->lanListWidget->hide(); this->wifiListWidget->show(); } this->scrollAreal->hide(); + this->topLanListWidget->hide(); this->scrollAreaw->show(); + this->topWifiListWidget->show(); on_btnWifiList_pressed(); } @@ -1201,6 +1438,31 @@ void MainWindow::on_checkWifiListChanged(){ } } +void MainWindow::on_setNetSpeed() +{ + if (this->isVisible() && is_stop_check_net_state==0){ + if (is_btnWifiList_clicked == 1){ + objNetSpeed->getCurrentDownloadRates(objKyDBus->dbusWiFiCardName.toUtf8().data(), &start_rcv_rates, &start_tx_rates); + }else if(is_btnNetList_clicked == 1){ + objNetSpeed->getCurrentDownloadRates(objKyDBus->dbusLanCardName.toUtf8().data(), &start_rcv_rates, &start_tx_rates); + } + + long int delta_rcv = (start_rcv_rates - end_rcv_rates)/8; + long int delta_tx = (start_tx_rates - end_tx_rates)/8; + if (delta_rcv>=10000 || delta_rcv<0){delta_rcv = 0;} + if (delta_tx>=10000 || delta_tx<0){delta_tx = 0;} + + QString str_rcv = QString::number(delta_rcv) + "kb/s"; + QString str_tx = QString::number(delta_tx) + "kb/s"; + + lbLoadUp->setText(str_rcv); + lbLoadDown->setText(str_tx); + + end_rcv_rates = start_rcv_rates; + end_tx_rates = start_tx_rates; + } +} + void MainWindow::connLanDone(int connFlag){ // Lan连接结果,0点击连接成功 1失败 3开机启动网络工具时已经连接 if(connFlag == 0){ @@ -1406,16 +1668,16 @@ void MainWindow::on_btnAdvConf_clicked() void MainWindow::on_btnNetList_pressed() { - ui->btnNetList->setStyleSheet("#btnNetList{font-size:12px;color:white;border:1px solid rgba(255,255,255,0.1);border:1px solid rgba(255,255,255,0.5);background:transparent;background-color:rgba(255,255,255,0.1);}"); - ui->btnWifiList->setStyleSheet("#btnWifiList{font-size:12px;color:white;border:1px solid rgba(255,255,255,0.1);background:transparent;background-color:rgba(0,0,0,0.2);}" - "#btnWifiList:Pressed{border:1px solid rgba(255,255,255,0.5);background:transparent;background-color:rgba(255,255,255,0.1);}"); +// ui->btnNetList->setStyleSheet("#btnNetList{font-size:12px;color:white;border:1px solid rgba(255,255,255,0.1);border:1px solid rgba(255,255,255,0.5);background:transparent;background-color:rgba(255,255,255,0.1);}"); +// ui->btnWifiList->setStyleSheet("#btnWifiList{font-size:12px;color:white;border:1px solid rgba(255,255,255,0.1);background:transparent;background-color:rgba(0,0,0,0.2);}" +// "#btnWifiList:Pressed{border:1px solid rgba(255,255,255,0.5);background:transparent;background-color:rgba(255,255,255,0.1);}"); } void MainWindow::on_btnWifiList_pressed() { - ui->btnWifiList->setStyleSheet("#btnWifiList{font-size:12px;color:white;border:1px solid rgba(255,255,255,0.1);border:1px solid rgba(255,255,255,0.5);background:transparent;background-color:rgba(255,255,255,0.1);}"); - ui->btnNetList->setStyleSheet("#btnNetList{font-size:12px;color:white;border:1px solid rgba(255,255,255,0.1);background:transparent;background-color:rgba(0,0,0,0.2);}" - "#btnNetList:Pressed{border:1px solid rgba(255,255,255,0.5);background:transparent;background-color:rgba(255,255,255,0.1);}"); +// ui->btnWifiList->setStyleSheet("#btnWifiList{font-size:12px;color:white;border:1px solid rgba(255,255,255,0.1);border:1px solid rgba(255,255,255,0.5);background:transparent;background-color:rgba(255,255,255,0.1);}"); +// ui->btnNetList->setStyleSheet("#btnNetList{font-size:12px;color:white;border:1px solid rgba(255,255,255,0.1);background:transparent;background-color:rgba(0,0,0,0.2);}" +// "#btnNetList:Pressed{border:1px solid rgba(255,255,255,0.5);background:transparent;background-color:rgba(255,255,255,0.1);}"); } void MainWindow::oneLanFormSelected(QString lanName) @@ -1426,21 +1688,20 @@ void MainWindow::oneLanFormSelected(QString lanName) for(int i = 0, j = 0;i < lanList.size(); i ++){ OneLancForm *ocf = lanList.at(i); if(ocf->isActive == true){ - ocf->move(0, 8); + ocf->move(0, 0); } if(ocf->isActive == false){ - ocf->move(0, 114 + j * 60); + ocf->move(0, j * 60); j ++; } } - lbLanList->move(12, 68); //是否与上一次选中同一个网络框 if (currSelNetName == lanName){ // 设置选中,缩小所有选项卡 for(int i = 0;i < lanList.size(); i ++){ OneLancForm *ocf = lanList.at(i); - ocf->setSelected(false); + ocf->setSelected(false); } currSelNetName = ""; @@ -1457,21 +1718,44 @@ void MainWindow::oneLanFormSelected(QString lanName) } } - // 选中元素下面的所有元素下移51 + // 选中元素下面的所有元素下移108 for(int i = 0;i < lanList.size(); i ++){ OneLancForm *ocf = lanList.at(i); if(ocf->y() > selectY){ - ocf->move(0, ocf->y() + 51); + ocf->move(0, ocf->y() + 108); } } - if(lbLanList->y() > selectY){ - lbLanList->move(12, 68 + 51); - } currSelNetName = lanName; } } +void MainWindow::oneTopLanFormSelected(QString lanName) +{ + QList lanList = topLanListWidget->findChildren(); + + if (currSelNetName == lanName){ + // 与上一次选中同一个网络框,缩小当前选项卡 + topLanListWidget->resize(435, 60 + 46); + lbTopLanList->move(12, 60); + scrollAreal->move(41, 158); + + OneLancForm *ocf = lanList.at(0); + ocf->setTopItem(false); + + currSelNetName = ""; + } else { + // 没有与上一次选中同一个网络框,放大当前选项卡 + topLanListWidget->resize(435, 60 + 108 + 46); + lbTopLanList->move(12, 60 + 108); + scrollAreal->move(41, 158 + 108); + + OneLancForm *ocf = lanList.at(0); + ocf->setTopItem(true); + + currSelNetName = lanName; + } +} void MainWindow::oneWifiFormSelected(QString wifiName) { @@ -1481,22 +1765,21 @@ void MainWindow::oneWifiFormSelected(QString wifiName) for(int i = 0, j = 0;i < wifiList.size(); i ++){ OneConnForm *ocf = wifiList.at(i); if(ocf->isActive == true){ - ocf->move(0, 8); + ocf->move(0, 0); } if(ocf->isActive == false){ - ocf->move(0, 114 + j * 60); + ocf->move(0, j * 60); j ++; } } - lbWifiList->move(12, 68); //是否与上一次选中同一个网络框 if (currSelNetName == wifiName){ - // 设置选中,缩小所有选项卡 + // 置选中,缩小所有选项卡 for(int i = 0;i < wifiList.size(); i ++){ OneConnForm *ocf = wifiList.at(i); if (ocf->wifiName == hideWiFiConn){ - ocf->setHideSelected(false); + ocf->setHideItem(true, true); }else{ ocf->setSelected(false); } @@ -1505,55 +1788,63 @@ void MainWindow::oneWifiFormSelected(QString wifiName) } else { // 设置选中,放大或缩小所有选项卡 int selectY = 0; - int selectWidgetY = 0; + for(int i = 0;i < wifiList.size(); i ++){ OneConnForm *ocf = wifiList.at(i); if(ocf->wifiName == wifiName){ if (ocf->wifiName == hideWiFiConn){ - ocf->setHideSelected(true); + ocf->setHideItem(true, true); }else{ ocf->setSelected(true); } selectY = ocf->y(); - selectWidgetY = wifiListWidget->y(); }else{ if (ocf->wifiName == hideWiFiConn){ - ocf->setHideSelected(false); + ocf->setHideItem(true, true); }else{ ocf->setSelected(false); } } } - // wifi界面可见部分最下的一个wifi被选中,有近一半被挡住,所有元素上移51或60 - if (selectY + selectWidgetY == 294){ - wifiListWidget->move(wifiListWidget->x(), wifiListWidget->y()-51); - if (selectY == 294){ - QScrollBar *pScrollBar = scrollAreaw->verticalScrollBar(); - pScrollBar->setSliderPosition(51); - } - }else if(selectY + selectWidgetY == 303){ - wifiListWidget->move(wifiListWidget->x(), wifiListWidget->y()-60); - if (selectY == 294){ - QScrollBar *pScrollBar = scrollAreaw->verticalScrollBar(); - pScrollBar->setSliderPosition(60); - } - } - // 选中元素下面的所有元素下移51 + // 选中元素下面的所有元素下移88 for(int i = 0;i < wifiList.size(); i ++){ OneConnForm *ocf = wifiList.at(i); if(ocf->y() > selectY){ - ocf->move(0, ocf->y() + 51); + ocf->move(0, ocf->y() + 88); } } - if(lbWifiList->y() > selectY){ - lbWifiList->move(12, 68 + 51); - } currSelNetName = wifiName; } } +void MainWindow::oneTopWifiFormSelected(QString wifiName) +{ + QList wifiList = topWifiListWidget->findChildren(); + + if (currSelNetName == wifiName){ + // 与上一次选中同一个网络框,缩小当前选项卡 + topWifiListWidget->resize(435, 60 + 46); + lbTopWifiList->move(12, 60); + scrollAreaw->move(41, 158); + + OneConnForm *ocf = wifiList.at(0); + ocf->setTopItem(false); + + currSelNetName = ""; + } else { + // 没有与上一次选中同一个网络框,放大当前选项卡 + topWifiListWidget->resize(435, 60 + 88 + 46); + lbTopWifiList->move(12, 60 + 88); + scrollAreaw->move(41, 158 + 88); + + OneConnForm *ocf = wifiList.at(0); + ocf->setTopItem(true); + + currSelNetName = wifiName; + } +} void MainWindow::activeLanDisconn() { @@ -1603,15 +1894,12 @@ void MainWindow::enNetDone() BackThread *bt = new BackThread(); mwBandWidth = bt->execChkLanWidth(lname); - ui->lbLanImg->setStyleSheet("QLabel{background-image:url(:/res/x/network-line.png);}"); ui->lbBtnNetBG->setStyleSheet(btnOnQss); - ui->lbBtnNetT1->setText(tr("Enabled"));//"已开启" // 打开网络开关时如果Wifi开关是打开的,设置其样式 if(checkWlOn()){ - ui->lbWifiImg->setStyleSheet("QLabel{background-image:url(:/res/x/wifi-line.png);}"); - ui->lbBtnWifiBG->setStyleSheet(btnOnQss); - ui->lbBtnWifiT1->setText(tr("Enabled"));//"已开启" + ui->lbBtnWifiBG->setStyleSheet(btnBgOnQss); + ui->lbBtnWifiBall->move(438, 22); } on_btnNetList_clicked(1); @@ -1623,42 +1911,44 @@ void MainWindow::enNetDone() void MainWindow::disNetDone() { + // 清空top列表 + delete topLanListWidget; + topLanListWidget = new QWidget(ui->centralWidget); + topLanListWidget->move(41, 52); + topLanListWidget->resize(435, 60 + 46); + lbTopLanList = new QLabel(topLanListWidget); + lbTopLanList->setText(tr("Ethernet Networks"));//"可用网络列表" + lbTopLanList->resize(260, 46); + lbTopLanList->move(12, 60); + lbTopLanList->setStyleSheet("QLabel{font-size:16px;color:rgba(255,255,255,0.97);}"); + lbTopLanList->show(); + // 清空lan列表 lanListWidget = new QWidget(scrollAreal); - lanListWidget->resize(314, 8 + 60 + 46 + 51); + lanListWidget->resize(440, 60 + 108); scrollAreal->setWidget(lanListWidget); + scrollAreal->move(41, 158); // 当前连接的lan - OneLancForm *ccf = new OneLancForm(lanListWidget, this, confForm, ksnm); + OneLancForm *ccf = new OneLancForm(topLanListWidget, this, confForm, ksnm); ccf->setName(tr("Not connected"));//"当前未连接任何 以太网" ccf->setIcon(false); - ccf->setConnedString(tr("Disconnected"));//"未连接" - ccf->setBandWidth("--"); - ccf->setShowPoint(true); + ccf->setConnedString(1, tr("Disconnected"));//"未连接" ccf->setAct(true); ccf->move(0, 8); ccf->show(); - // 名为'可用网络列表'一栏 - lbLanList = new QLabel(lanListWidget); - lbLanList->setText(tr("Ethernet Networks"));//"可用网络列表" - lbLanList->resize(260, 46); - lbLanList->move(12, 68); - lbLanList->setStyleSheet("QLabel{font-size:12px;color:white;}"); - lbLanList->show(); - - ui->lbLanImg->setStyleSheet("QLabel{background-image:url(:/res/x/network-offline.png);}"); ui->lbBtnNetBG->setStyleSheet(btnOffQss); - ui->lbBtnNetT1->setText(tr("Disabled"));//"已关闭" - ui->lbWifiImg->setStyleSheet("QLabel{background-image:url(:/res/x/wifi-offline.png);}"); - ui->lbBtnWifiBG->setStyleSheet(btnOffQss); - ui->lbBtnWifiT1->setText(tr("Disabled"));//"已关闭" + ui->lbBtnWifiBG->setStyleSheet(btnBgOffQss); + ui->lbBtnWifiBall->move(412, 22); this->lanListWidget->show(); this->wifiListWidget->hide(); this->scrollAreal->show(); + this->topLanListWidget->show(); this->scrollAreaw->hide(); + this->topWifiListWidget->hide(); on_btnNetList_pressed(); @@ -1670,19 +1960,15 @@ void MainWindow::disNetDone() void MainWindow::launchLanDone() { - ui->lbLanImg->setStyleSheet("QLabel{background-image:url(:/res/x/network-line.png);}"); ui->lbBtnNetBG->setStyleSheet(btnOnQss); - ui->lbBtnNetT1->setText(tr("Enabled"));//"已开启" } void MainWindow::enWifiDone() { - ui->lbWifiImg->setStyleSheet("QLabel{background-image:url(:/res/x/wifi-line.png);}"); - ui->lbBtnWifiBG->setStyleSheet(btnOnQss); - ui->lbBtnWifiT1->setText(tr("Enabled"));//"已开启" + ui->lbBtnWifiBG->setStyleSheet(btnBgOnQss); + ui->lbBtnWifiBall->move(438, 22); is_update_wifi_list = 0; -// on_btnWifiList_clicked(); this->ksnm->execGetWifiList(); qDebug()<<"debug: already turn on the switch of wifi network"; @@ -1691,31 +1977,37 @@ void MainWindow::enWifiDone() void MainWindow::disWifiDone() { - wifiListWidget->resize(314, 8 + 60 + 46 + 51); - QList wifiList = wifiListWidget->findChildren(); + wifiListWidget = new QWidget(scrollAreaw); + wifiListWidget->resize(440, /*60 + */88); + scrollAreaw->setWidget(wifiListWidget); + scrollAreaw->move(41, 158); + + lbTopWifiList->move(12, 60); + topWifiListWidget->resize(435, 60 + 46); + + QList wifiList = topWifiListWidget->findChildren(); for(int i = 0; i < wifiList.size(); i ++){ OneConnForm *ocf = wifiList.at(i); if(ocf->isActive == true){ ocf->setSelected(false); ocf->setName(tr("Not connected"));//"当前未连接任何 Wifi" - ocf->setSafe("--"); - ocf->setSignal("0"); - ocf->setSafeString("--"); - ocf->setConnedString(tr("Disconnected"));//"未连接" - ocf->setShowPoint(false); - disconnect(ocf, SIGNAL(selectedOneWifiForm(QString)), this, SLOT(oneWifiFormSelected(QString))); + ocf->setSignal("0", "--"); + ocf->setConnedString(1, tr("Disconnected"), "");//"未连接" + ocf->isConnected = false; + ocf->setTopItem(false); + disconnect(ocf, SIGNAL(selectedOneWifiForm(QString)), this, SLOT(oneTopWifiFormSelected(QString))); }else{ ocf->deleteLater(); } } - lbWifiList->move(12, 68); - ui->lbWifiImg->setStyleSheet("QLabel{background-image:url(:/res/x/wifi-offline.png);}"); - ui->lbBtnWifiBG->setStyleSheet(btnOffQss); - ui->lbBtnWifiT1->setText(tr("Disabled"));//"已关闭" + ui->lbBtnWifiBG->setStyleSheet(btnBgOffQss); + ui->lbBtnWifiBall->move(412, 22); this->lanListWidget->hide(); + this->topLanListWidget->hide(); this->wifiListWidget->show(); + this->topWifiListWidget->show(); this->scrollAreal->hide(); this->scrollAreaw->show(); @@ -1730,39 +2022,112 @@ void MainWindow::disWifiDone() void MainWindow::keepDisWifiState() { if(this->is_btnNetList_clicked == 1) { - ui->lbWifiImg->setStyleSheet("QLabel{background-image:url(:/res/x/wifi-offline.png);}"); - ui->lbBtnWifiBG->setStyleSheet(btnOffQss); - ui->lbBtnWifiT1->setText(tr("Disabled"));//"已关闭" + ui->lbBtnWifiBG->setStyleSheet(btnBgOffQss); + ui->lbBtnWifiBall->move(412, 22); } if(this->is_btnWifiList_clicked== 1) { - wifiListWidget->resize(314, 8 + 60 + 46 + 51); - QList wifiList = wifiListWidget->findChildren(); + wifiListWidget = new QWidget(scrollAreaw); + wifiListWidget->resize(440, /*60 + */88); + scrollAreaw->setWidget(wifiListWidget); + scrollAreaw->move(41, 158); + + lbTopWifiList->move(12, 60); + topWifiListWidget->resize(435, 60 + 46); + + QList wifiList = topWifiListWidget->findChildren(); for(int i = 0; i < wifiList.size(); i ++){ OneConnForm *ocf = wifiList.at(i); if(ocf->isActive == true){ ocf->setSelected(false); ocf->setName(tr("Not connected"));//"当前未连接任何 Wifi" - ocf->setSafe("--"); - ocf->setSignal("0"); - ocf->setSafeString("--"); - ocf->setConnedString(tr("Disconnected"));//"未连接" - ocf->setShowPoint(true); - disconnect(ocf, SIGNAL(selectedOneWifiForm(QString)), this, SLOT(oneWifiFormSelected(QString))); + ocf->setSignal("0", "--"); + ocf->setConnedString(1, tr("Disconnected"), "");//"未连接" + ocf->isConnected = false; + ocf->setTopItem(false); + disconnect(ocf, SIGNAL(selectedOneWifiForm(QString)), this, SLOT(oneTopWifiFormSelected(QString))); }else{ ocf->deleteLater(); } } - lbWifiList->move(12, 68); - ui->lbWifiImg->setStyleSheet("QLabel{background-image:url(:/res/x/wifi-offline.png);}"); - ui->lbBtnWifiBG->setStyleSheet(btnOffQss); - ui->lbBtnWifiT1->setText(tr("Disabled"));//"已关闭" + ui->lbBtnWifiBG->setStyleSheet(btnBgOffQss); + ui->lbBtnWifiBall->move(412, 22); this->lanListWidget->hide(); this->wifiListWidget->show(); this->scrollAreal->hide(); + this->topLanListWidget->hide(); this->scrollAreaw->show(); + this->topWifiListWidget->show(); // this->stopLoading(); } } + +void MainWindow::on_btnFlyMode_clicked() +{ + if(is_fly_mode_on == 0){ + ui->lbFlyImg->setStyleSheet("QLabel{background-image:url(:/res/x/fly-mode-on.svg);}"); + ui->lbFlyBG->setStyleSheet(btnOnQss); + is_fly_mode_on = 1; + + on_btnWifi_clicked(); + on_btnWifiList_clicked(); + } else { + ui->lbFlyImg->setStyleSheet("QLabel{background-image:url(:/res/x/fly-mode-off.svg);}"); + ui->lbFlyBG->setStyleSheet(btnOffQss); + is_fly_mode_on = 0; + } +} + +void MainWindow::on_btnHotspot_clicked() +{ + if (is_wireless_adapter_ready == 1){ + if(is_hot_sopt_on == 0){ + ui->lbHotImg->setStyleSheet("QLabel{background-image:url(:/res/x/hot-spot-on.svg);}"); + ui->lbHotBG->setStyleSheet(btnOnQss); + is_hot_sopt_on = 1; + + QApplication::setQuitOnLastWindowClosed(false); + DlgHotspotCreate *hotCreate = new DlgHotspotCreate(objKyDBus->dbusWiFiCardName); + connect(hotCreate,SIGNAL(updateHotspotList()),this,SLOT(on_btnWifiList_clicked() )); + connect(hotCreate,SIGNAL(btnHotspotState()),this,SLOT(on_btnHotspotState() )); + hotCreate->show(); + } else { + on_btnHotspotState(); + + QString strSlist; + system("nmcli connection show -active>/tmp/kylin-nm-connshow"); + QFile file("/tmp/kylin-nm-connshow"); + if(!file.open(QIODevice::ReadOnly | QIODevice::Text)){ + syslog(LOG_ERR, "Can't open the file /tmp/kylin-nm-connshow!"); + qDebug()<<"Can't open the file /tmp/kylin-nm-connshow!"; + } + + QString txt = file.readAll(); + QStringList txtLine = txt.split("\n"); + file.close(); + foreach (QString line, txtLine) { + if(line.indexOf("wifi") != -1){ + QStringList subLine = line.split(" "); + if (subLine[1].size() == 1){ + strSlist = subLine[0]+ " " + subLine[1]; + }else { + strSlist = subLine[0]; + } + kylin_network_set_con_down(strSlist.toUtf8().data()); + } + } //end foreach + + sleep(2); + on_btnWifiList_clicked(); + } + } +} + +void MainWindow::on_btnHotspotState() +{ + ui->lbHotImg->setStyleSheet("QLabel{background-image:url(:/res/x/hot-spot-off.svg);}"); + ui->lbHotBG->setStyleSheet(btnOffQss); + is_hot_sopt_on = 0; +} diff --git a/mainwindow.h b/mainwindow.h index ad332b95..6026208a 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -30,6 +30,9 @@ #include #include #include +#include +#include +#include #include #include #include @@ -49,6 +52,7 @@ #include "ksimplenm.h" #include "loadingdiv.h" +#include "networkspeed.h" #include "kylin-dbus-interface.h" #include "kylin-network-interface.h" @@ -77,12 +81,15 @@ public: void changeTimerState(); void checkIsWirelessDeviceOn(); + void init_widget_action(QWidget *wid, QString iconstr, QString textstr); + QIcon iconLanOnline, iconLanOffline; QIcon iconWifiFull, iconWifiHigh, iconWifiMedium, iconWifiLow; QIcon iconConnecting; QList loadIcons; QString mwBandWidth; KylinDBus *objKyDBus; + NetworkSpeed *objNetSpeed; //状态设置,0为假,1为真 int is_update_wifi_list = 0; //是否是update wifi列表,而不是load wifi列表 @@ -93,6 +100,10 @@ public: int is_wireless_adapter_ready = 1; //主机是否插入无线网卡 int is_keep_wifi_turn_on_state = 1; //是否要执行wifi开关变为打开样式 int is_stop_check_net_state = 0; //是否要在进行其他操作时停止检查网络状态 + int is_fly_mode_on = 0; //是否打开飞行模式 + int is_hot_sopt_on = 0; //是否已经打开热点 + + QString currSelNetName = ""; //当前ScrollArea中选中的网络名称 public slots: void onPhysicalCarrierChanged(bool flag); @@ -103,12 +114,20 @@ public slots: void onWirelessDeviceRemoved(QDBusObjectPath objPath); void getLanBandWidth(); + void oneLanFormSelected(QString lanName); + void oneTopLanFormSelected(QString lanName); + void oneWifiFormSelected(QString wifiName); + void oneTopWifiFormSelected(QString wifiName); + + void on_btnHotspot_clicked(); + void on_btnHotspotState(); + private: void checkSingle(); void getActiveInfo(); void initNetwork(); void createTrayIcon(); - void moveBottomRight(); + void handleIconClicked(); bool checkLanOn(); bool checkWlOn(); void getLanList(); @@ -122,32 +141,32 @@ private: QDesktopWidget desktop; KSimpleNM *ksnm; ConfForm *confForm; + QWidget *topLanListWidget; + QWidget *topWifiListWidget; QWidget *lanListWidget; QWidget *wifiListWidget; QWidget *optWifiWidget; + QLabel *lbLoadDown; + QLabel *lbLoadUp; + QScrollArea *scrollAreal, *scrollAreaw; - QLabel *lbLanList, *lbWifiList; + QLabel *lbTopLanList, *lbTopWifiList, *lbLanList, *lbWifiList; QSystemTrayIcon *trayIcon; QMenu *trayIconMenu; + QWidgetAction *mShowWindow; + QWidgetAction *mAdvConf; + QWidget *wid; + QWidget *wid_new; - QAction *m_miniSizeAction; - QAction *m_quitAction; + QString lname, wname; // 以太网卡和无线网卡名称 - // 以太网卡和无线网卡名称 - QString lname, wname; + QString btnOffQss, btnOnQss, btnBgOffQss, btnBgOnQss; // 主界面按钮底色 - //当前ScrollArea中选中的网络名称 - QString currSelNetName = ""; + QStringList oldLanSlist; //上一次获取Lan列表 - // 主界面按钮底色 - QString btnOffQss, btnOnQss; - - //上一次获取Lan列表 - QStringList oldLanSlist; - //上一次获取wifi列表 - QStringList oldWifiSlist; + QStringList oldWifiSlist; //上一次获取wifi列表 //循环检测网络连接状态 QTimer *iconTimer; @@ -158,11 +177,19 @@ private: QTimer *checkIfLanConnect; QTimer *checkIfWifiConnect; QTimer *checkIfNetworkOn; + QTimer *setNetSpeed; int currentIconIndex; + int activeWifiSignalLv; + + long int start_rcv_rates = 0; //保存开始时的流量计数 + long int end_rcv_rates = 0; //保存结束时的流量计数 + long int start_tx_rates = 0; //保存开始时的流量计数 + long int end_tx_rates = 0; //保存结束时的流量计数 private slots: void iconActivated(QSystemTrayIcon::ActivationReason reason); + bool nativeEvent(const QByteArray &eventType, void *message, long *result); void on_btnNet_clicked(); @@ -175,12 +202,11 @@ private slots: void loadWifiListDone(QStringList slist); void updateWifiListDone(QStringList slist); + void on_showWindowAction(); void on_btnAdvConf_clicked(); void on_btnNetList_pressed(); void on_btnWifiList_pressed(); - void oneLanFormSelected(QString lanName); - void oneWifiFormSelected(QString wifiName); void activeLanDisconn(); void activeWifiDisconn(); void activeStartLoading(); @@ -188,6 +214,7 @@ private slots: void on_btnAdvConf_pressed(); void on_btnAdvConf_released(); void on_checkWifiListChanged(); + void on_setNetSpeed(); void on_isLanConnect(); void on_isWifiConnect(); void on_isNetOn(); @@ -203,6 +230,8 @@ private slots: void connWifiDone(int connFlag); void iconStep(); + void on_btnFlyMode_clicked(); + signals: void deleteRedundantNet(); }; diff --git a/mainwindow.ui b/mainwindow.ui index 87236d80..15d2b1ee 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -6,8 +6,8 @@ 0 0 - 316 - 467 + 480 + 515 @@ -19,83 +19,18 @@ 1 1 - 314 - 38 + 41 + 513 - - - - 158 - 8 - 90 - 22 - - - - - - - - - - 67 - 8 - 90 - 22 - - - - - - - 4 - 403 - 90 - 60 - - - - - - - - - - 10 - 410 - 22 - 22 - - - - - - - - - - 40 - 412 - 55 - 18 - - - - - - - - - - 10 - 440 - 55 - 18 + 1 + 200 + 37 + 37 @@ -105,10 +40,10 @@ - 4 - 403 - 90 - 60 + 2 + 200 + 37 + 37 @@ -118,49 +53,10 @@ - 98 - 403 - 90 - 60 - - - - - - - - - - 103 - 410 - 22 - 22 - - - - - - - - - - 132 - 412 - 55 - 18 - - - - - - - - - - 103 - 440 - 55 - 18 + 410 + 20 + 50 + 24 @@ -170,10 +66,10 @@ - 98 - 403 - 90 - 60 + 410 + 20 + 50 + 24 @@ -183,21 +79,21 @@ - 222 - 403 - 90 - 60 + 2 + 460 + 37 + 37 - + - 227 - 410 + 10 + 468 22 22 @@ -206,32 +102,257 @@ - - - - 227 - 440 - 70 - 18 - - - - - - - 222 - 403 - 90 - 60 + 2 + 460 + 37 + 37 + + + + 2 + 348 + 37 + 37 + + + + + + + + + + 2 + 395 + 37 + 37 + + + + + + + + + + 61 + 22 + 80 + 20 + + + + + + + + + + 438 + 22 + 20 + 20 + + + + + + + + + + 11 + 359 + 19 + 19 + + + + + + + + + + 11 + 405 + 19 + 19 + + + + + + + + + + 2 + 10 + 37 + 37 + + + + + + + + + + 1 + 57 + 37 + 37 + + + + + + + + + + 10 + 20 + 19 + 19 + + + + + + + + + + 10 + 67 + 19 + 19 + + + + + + + + + + 2 + 348 + 37 + 37 + + + + + + + + + + 2 + 395 + 37 + 37 + + + + + + + + + + 2 + 10 + 37 + 37 + + + + + + + + + + 2 + 57 + 37 + 37 + + + + + + + + + + 2 + 442 + 35 + 1 + + + + background-color: rgba(255, 255, 255,0.06); + + + Qt::Horizontal + + + + + + 41 + 0 + 1 + 515 + + + + background-color: rgba(255, 255, 255,0.06); + + + Qt::Vertical + + + wdgHead + lbFlyBG + lbHotBG + lbFlyImg + lbHotImg + lbBtnNetBG + btnNet + lbBtnWifiBG + lbBtnConfBG + lbBtnConfImg + btnAdvConf + btnHotspot + btnFlyMode + lbBtnWifiBall + btnWifi + lbNetListBG + lbWifiListBG + lbWifiListImg + lbNetListImg + btnNetList + btnWifiList + lbNetwork + line + line_2 diff --git a/network-speed.cpp b/network-speed.cpp new file mode 100644 index 00000000..3ceebfa3 --- /dev/null +++ b/network-speed.cpp @@ -0,0 +1,71 @@ +#include "networkspeed.h" + +//NetworkSpeed::NetworkSpeed(QObject *parent) :QObject(parent) +//{ +// qDebug()<<"debug: this is creator function of class NetworkSpeed"; +//} + +int NetworkSpeed::getCurrentDownloadRates(char *netname, long *save_rate, long *tx_rate) +{ + FILE * net_dev_file; //文件指针 + char buffer[1024]; //文件中的内容暂存在字符缓冲区里 + size_t bytes_read; //实际读取的内容大小 + char * match; //用以保存所匹配字符串及之后的内容 + int counter = 0; + int i = 0; + char tmp_value[128]; + + if((NULL == netname)||(NULL == save_rate)||(NULL == tx_rate)) + { + printf("bad param\n"); + return -1; + } + + if ( (net_dev_file=fopen("/proc/net/dev", "r")) == NULL ) //打开文件/pro/net/dev/,我们要读取的数据就是它啦 + { + printf("open file /proc/net/dev/ error!\n"); + return -1; + } + memset(buffer,0,sizeof(buffer)); + + while(fgets(buffer,sizeof(buffer),net_dev_file) != NULL) + { + match = strstr(buffer,netname); + + if(NULL == match) + { + //printf("no eth0 keyword to find!\n"); + continue; + } + else + { + //printf("%s\n",buffer); + match = match + strlen(netname) + strlen(":");/*地址偏移到冒号*/ + sscanf(match,"%ld ",save_rate); + memset(tmp_value,0,sizeof(tmp_value)); + sscanf(match,"%s ",tmp_value); + match = match + strlen(tmp_value); + for(i=0;i +#include + +#include +#include +#include +#include + +class NetworkSpeed : public QObject +{ + Q_OBJECT +public: + explicit NetworkSpeed(QObject *parent = nullptr); + + int getCurrentDownloadRates(char *netname,long int * save_rate,long int * tx_rate); //获取当前的流量,参数为将获取到的流量保 +}; + +#endif // NETWORKSPEED_H diff --git a/nmqrc.qrc b/nmqrc.qrc index 72e4a216..3fd80df7 100644 --- a/nmqrc.qrc +++ b/nmqrc.qrc @@ -69,5 +69,27 @@ res/h/no-pwd-wifi.png translations/kylin-nm_bo.qm translations/kylin-nm_zh_CN.qm + res/x/fly-mode-off.svg + res/x/fly-mode-on.svg + res/x/hot-spot-off.svg + res/x/hot-spot-on.svg + res/x/net-list-bg.svg + res/x/wifi-list-bg.svg + res/x/load-down.png + res/x/load-up.png + res/l/network-offline.png + res/l/network-offline.svg + res/l/network-online.png + res/l/network-online.svg + res/w/wifi-full.png + res/w/wifi-full-pwd.png + res/w/wifi-high.png + res/w/wifi-high-pwd.png + res/w/wifi-low.png + res/w/wifi-low-pwd.png + res/w/wifi-medium.png + res/w/wifi-medium-pwd.png + res/w/wifi-none.png + res/w/wifi-none-pwd.png diff --git a/oneconnform.cpp b/oneconnform.cpp index a4391599..c10ace54 100644 --- a/oneconnform.cpp +++ b/oneconnform.cpp @@ -29,49 +29,72 @@ OneConnForm::OneConnForm(QWidget *parent, MainWindow *mainWindow, ConfForm *conf { ui->setupUi(this); - ui->lbPassword->setText(tr("Input password"));//"输入密码:" - ui->btnConf->setText(tr("Config"));//"设置" + ui->btnConnSub->setText(tr("Config"));//"设置" ui->btnConn->setText(tr("Connect"));//"连接" ui->btnConnPWD->setText(tr("Connect"));//"连接" ui->btnDisConn->setText(tr("Disconnect"));//"断开连接" ui->btnHideConn->setText(tr("Connect"));//"连接" + + ui->lbConned->setAlignment(Qt::AlignLeft); + ui->lbLoadUp->setAlignment(Qt::AlignLeft); + ui->lbLoadDown->setAlignment(Qt::AlignLeft); ui->lePassword->setEchoMode(QLineEdit::Password); - ui->wbg->hide(); - ui->lbPassword->hide(); + ui->btnConnPWD->setEnabled(false); + + ui->lbInfo->setStyleSheet("QLabel{font-size:14px;color:rgba(255,255,255,0.57);}"); + ui->wbg->setStyleSheet("#wbg{border-radius:4px;background-color:rgba(255,255,255,0);}"); + // "#wbg:Hover{border-radius:4px;background-color:rgba(255,255,255,0.1);}"); + ui->wbg_2->setStyleSheet("#wbg_2{border-radius:4px;background-color:rgba(255,255,255,0.1);}"); + ui->wbg_3->setStyleSheet("#wbg_3{border-radius:4px;background-color:rgba(255,255,255,0.1);}"); + ui->lbName->setStyleSheet("QLabel{font-size:14px;color:rgba(255,255,255,0.91);}"); + ui->lbConned->setStyleSheet("QLabel{font-size:14px;color:rgba(255,255,255,0.57);}"); + ui->lbLoadUp->setStyleSheet("QLabel{font-size:14px;color:rgba(255,255,255,0.57);}"); + ui->lbLoadDown->setStyleSheet("QLabel{font-size:14px;color:rgba(255,255,255,0.57);}"); + ui->lePassword->setStyleSheet("QLineEdit{border:2px solid rgba(28, 47, 146, 1);border-radius:4px;" + "background:rgba(0,0,0,0.2);color:rgba(255,255,255,0.35);font-size:14px;}"); + ui->checkBoxPwd->setStyleSheet("QCheckBox::indicator {width: 18px; height: 9px;}" + "QCheckBox::indicator:checked {image: url(:/res/h/show-pwd.png);}" + "QCheckBox::indicator:unchecked {image: url(:/res/h/hide-pwd.png);}"); + ui->btnConnSub->setStyleSheet("QPushButton{border:0px;border-radius:4px;background-color:rgba(61,107,229,1);color:white;font-size:14px;}" + "QPushButton:Hover{border:0px solid rgba(255,255,255,0.2);border-radius:4px;background-color:rgba(107,142,235,1);}" + "QPushButton:Pressed{border-radius:4px;background-color:rgba(50,87,202,1);}"); + ui->btnConn->setStyleSheet("QPushButton{border:0px;border-radius:4px;background-color:rgba(61,107,229,1);color:white;font-size:14px;}" + "QPushButton:Hover{border:0px solid rgba(255,255,255,0.2);border-radius:4px;background-color:rgba(107,142,235,1);}" + "QPushButton:Pressed{border-radius:4px;background-color:rgba(50,87,202,1);}"); + ui->btnConnPWD->setStyleSheet("QPushButton{border:0px;border-radius:4px;background-color:rgba(61,107,229,1);color:white;font-size:14px;}" + "QPushButton:Hover{border:0px solid rgba(255,255,255,0.2);border-radius:4px;background-color:rgba(107,142,235,1);}" + "QPushButton:Pressed{border-radius:4px;background-color:rgba(50,87,202,1);}"); + ui->btnDisConn->setStyleSheet("QPushButton{border:0px;border-radius:4px;background-color:rgba(255,255,255,0.12);color:white;font-size:14px;}" + "QPushButton:Hover{border:0px solid rgba(255,255,255,0.2);border-radius:4px;background-color:rgba(255,255,255,0.2);}" + "QPushButton:Pressed{border-radius:4px;background-color:rgba(255,255,255,0.08);}"); + ui->btnHideConn->setStyleSheet("QPushButton{border:0px;border-radius:4px;background-color:rgba(61,107,229,1);color:white;font-size:14px;}" + "QPushButton:Hover{border:0px solid rgba(255,255,255,0.2);border-radius:4px;background-color:rgba(107,142,235,1);}" + "QPushButton:Pressed{border-radius:4px;background-color:rgba(50,87,202,1);}"); + ui->lbLoadDownImg->setStyleSheet("QLabel{background-image:url(:/res/x/load-down.png);}"); + ui->lbLoadUpImg->setStyleSheet("QLabel{background-image:url(:/res/x/load-up.png);}"); + + ui->checkBoxPwd->setFocusPolicy(Qt::NoFocus); + ui->btnConnSub->setFocusPolicy(Qt::NoFocus); + ui->btnConn->setFocusPolicy(Qt::NoFocus); + ui->btnConnPWD->setFocusPolicy(Qt::NoFocus); + ui->btnDisConn->setFocusPolicy(Qt::NoFocus); + ui->btnHideConn->setFocusPolicy(Qt::NoFocus); + + ui->wbg->show(); + ui->wbg_2->hide(); + ui->wbg_3->hide(); + ui->lbName->show(); + ui->lbInfo->hide(); ui->lePassword->hide(); ui->checkBoxPwd->hide(); - ui->btnConf->hide(); + ui->btnConnSub->hide(); ui->btnConn->hide(); ui->btnDisConn->hide(); ui->btnConnPWD->hide(); ui->btnHideConn->hide(); - - ui->lbConned->setAlignment(Qt::AlignRight); - - ui->wbg->setStyleSheet("#wbg{background-color:#3593b5;}"); - ui->lbName->setStyleSheet("QLabel{font-size:13px;color:#ffffff;}"); - ui->lbPassword->setStyleSheet("QLabel{font-size:13px;color:#ffffff;}"); - ui->lbSafe->setStyleSheet("QLabel{font-size:13px;color:#aaaaaa;}"); - ui->lbConned->setStyleSheet("QLabel{font-size:13px;color:#ffffff;}"); - ui->lePassword->setStyleSheet("QLineEdit{border: 1px solid #cccccc;background-color:#ffffff;}"); - ui->checkBoxPwd->setStyleSheet("QCheckBox::indicator {width: 18px; height: 9px;}" - "QCheckBox::indicator:checked {image: url(:/res/h/show-pwd.png);}" - "QCheckBox::indicator:unchecked {image: url(:/res/h/hide-pwd.png);}"); - ui->btnConf->setStyleSheet("QPushButton{border:0px;background-color:rgba(0,0,0,0.4);color:white;font-size:12px;}" - "QPushButton:Hover{border:1px solid rgba(255,255,255,0.2);background-color:rgba(0,0,0,0.2);}" - "QPushButton:Pressed{background-color:rgba(0,0,0,0.6);}"); - ui->btnConn->setStyleSheet("QPushButton{border:0px;background-color:rgba(0,0,0,0.4);color:white;font-size:12px;}" - "QPushButton:Hover{border:1px solid rgba(255,255,255,0.2);background-color:rgba(0,0,0,0.2);}" - "QPushButton:Pressed{background-color:rgba(0,0,0,0.6);}"); - ui->btnConnPWD->setStyleSheet("QPushButton{border:0px;background-color:rgba(0,0,0,0.4);color:white;font-size:12px;}" - "QPushButton:Hover{border:1px solid rgba(255,255,255,0.2);background-color:rgba(0,0,0,0.2);}" - "QPushButton:Pressed{background-color:rgba(0,0,0,0.6);}"); - ui->btnDisConn->setStyleSheet("QPushButton{border:0px;background-color:rgba(0,0,0,0.4);color:white;font-size:12px;}" - "QPushButton:Hover{border:1px solid rgba(255,255,255,0.2);background-color:rgba(0,0,0,0.2);}" - "QPushButton:Pressed{background-color:rgba(0,0,0,0.6);}"); - ui->btnHideConn->setStyleSheet("QPushButton{border:0px;background-color:rgba(0,0,0,0.4);color:white;font-size:12px;}" - "QPushButton:Hover{border:1px solid rgba(255,255,255,0.2);background-color:rgba(0,0,0,0.2);}" - "QPushButton:Pressed{background-color:rgba(0,0,0,0.6);}"); + ui->line->show(); + ui->lbLoadDownImg->hide(); + ui->lbLoadUpImg->hide(); this->mw = mainWindow; this->cf = confForm; @@ -80,9 +103,14 @@ OneConnForm::OneConnForm(QWidget *parent, MainWindow *mainWindow, ConfForm *conf this->isSelected = false; this->isActive = false; + ui->wbg->setAttribute(Qt::WA_Hover,true);//开启悬停事件 + ui->wbg->installEventFilter(this); //安装事件过滤器 + ui->btnConn->setAttribute(Qt::WA_Hover,true);//开启悬停事件 + ui->btnConn->installEventFilter(this); //安装事件过滤器 + connect(ui->lePassword, SIGNAL(returnPressed()), this, SLOT(on_btnConnPWD_clicked())); ui->btnConn->setShortcut(Qt::Key_Return);//将字母区回车键与登录按钮绑定在一起 - ui->btnHideConn->setShortcut(Qt::Key_Return); +// ui->btnHideConn->setShortcut(Qt::Key_Return); } OneConnForm::~OneConnForm() @@ -94,126 +122,151 @@ void OneConnForm::mousePressEvent(QMouseEvent *){ emit selectedOneWifiForm(wifiName); } +//事件过滤器 +bool OneConnForm::eventFilter(QObject *obj, QEvent *event) +{ + if(obj == ui->wbg) { + if(event->type() == QEvent::HoverEnter) { + ui->btnConn->show(); + ui->wbg->setStyleSheet("#wbg{border-radius:4px;background-color:rgba(255,255,255,0.1);}"); + return true; + } else if(event->type() == QEvent::HoverLeave){ + ui->btnConn->hide(); + ui->wbg->setStyleSheet("#wbg{border-radius:4px;background-color:rgba(255,255,255,0);}"); + return true; + } + } + + if(obj == ui->btnConn) { + if(event->type() == QEvent::HoverEnter) { + ui->wbg->hide(); + ui->btnConn->show(); + return true; + } else if(event->type() == QEvent::HoverLeave){ + ui->wbg->show(); + return true; + } + } + + return QWidget::eventFilter(obj,event); +} + // 是否当前连接的网络,字体设置不同 void OneConnForm::setAct(bool isAct){ if(isAct){ ui->lbName->setStyleSheet("QLabel{font-size:14px;color:#ffffff;}"); - ui->lbSafe->setStyleSheet("QLabel{font-size:14px;color:#aaaaaa;}"); ui->lbConned->show(); - ui->btnConf->show(); }else{ - ui->lbName->setStyleSheet("QLabel{font-size:12px;color:#ffffff;}"); - ui->lbSafe->setStyleSheet("QLabel{font-size:12px;color:#aaaaaa;}"); + ui->lbName->setStyleSheet("QLabel{font-size:14px;color:#ffffff;}"); ui->lbConned->hide(); - ui->btnConf->hide(); } isActive = isAct; } -// 是否选中 +//点击窗口最上面的item时 +void OneConnForm::setTopItem(bool isSelected){ + if(isSelected){ + resize(422, 148); + ui->wbg_3->show(); + ui->lbInfo->show(); + + this->isSelected = true; + }else{ + resize(422, 60); + ui->lePassword->setText(""); + ui->wbg_3->hide(); + ui->lbInfo->hide(); + + this->isSelected = false; + } + + ui->wbg->hide(); + ui->wbg_2->hide(); + ui->lbSignal->show(); + ui->lePassword->hide(); + ui->checkBoxPwd->hide(); + ui->line->hide(); + ui->btnConn->hide(); + ui->btnConnPWD->hide(); + ui->btnHideConn->hide(); + ui->lbLoadUpImg->show(); + ui->lbLoadDownImg->show(); + if (isConnected){ + // ui->lbLoadUp->setText("0Kb/s"); + // ui->lbLoadDown->setText("0Kb/s"); + ui->lbLoadUp->hide(); + ui->lbLoadDown->hide(); + ui->btnDisConn->show(); + }else{ + // ui->lbLoadUp->setText("0Kb/s"); + // ui->lbLoadDown->setText("0Kb/s"); + ui->lbLoadUp->hide(); + ui->lbLoadDown->hide(); + ui->btnDisConn->hide(); + } +} +// 点击窗口下面的item时 void OneConnForm::setSelected(bool isSelected){ if(isSelected){ - resize(314, 111); - ui->wbg->show(); -// ui->btnConf->show(); - if(isActive){ - ui->btnHideConn->hide(); - ui->btnDisConn->show(); - }else{ - ui->btnHideConn->hide(); - ui->btnConn->show(); - } + resize(422, 148); + ui->line->hide(); + ui->wbg->hide(); + ui->wbg_2->hide(); + ui->wbg_3->show(); + ui->lbInfo->show(); + ui->btnConn->show(); + ui->btnConnSub->show(); this->isSelected = true; - }else{ - resize(314, 60); + resize(422, 60); ui->lePassword->setText(""); - ui->wbg->hide(); - - if(isActive){ - ui->btnConf->show(); - }else{ - ui->btnConf->hide(); - } - - ui->btnConn->hide(); - ui->btnDisConn->hide(); - ui->btnHideConn->hide(); - - ui->lbPassword->hide(); - ui->lePassword->hide(); - ui->checkBoxPwd->hide(); - ui->btnConnPWD->hide(); - - ui->lbName->show(); - ui->lbSafe->show(); - ui->lbSignal->show(); - ui->lbPoint->show(); - - this->isSelected = false; - } -} -// 是否选中连接隐藏Wifi小窗口 -void OneConnForm::setHideSelected(bool isSelected){ - if(isSelected){ - resize(314, 111); + ui->line->show(); ui->wbg->show(); - - ui->btnConf->hide(); + ui->wbg_2->hide(); + ui->wbg_3->hide(); + ui->lbInfo->hide(); ui->btnConn->hide(); - ui->btnDisConn->hide(); - ui->btnHideConn->show(); - - ui->lbPassword->hide(); - ui->lePassword->hide(); - ui->checkBoxPwd->hide(); - ui->btnConnPWD->hide(); - - ui->lbName->show(); - ui->lbSafe->show(); - ui->lbSignal->show(); - ui->lbPoint->hide(); - - this->isSelected = true; - } else { - resize(314, 60); - ui->wbg->hide(); - - ui->btnConf->hide(); - ui->btnConn->hide(); - ui->btnDisConn->hide(); - ui->btnHideConn->hide(); - - ui->lbPassword->hide(); - ui->lePassword->hide(); - ui->checkBoxPwd->hide(); - ui->btnConnPWD->hide(); - - ui->lbName->show(); - ui->lbSafe->show(); - ui->lbSignal->show(); - ui->lbPoint->hide(); + ui->btnConnSub->hide(); this->isSelected = false; } + ui->lePassword->hide(); + ui->checkBoxPwd->hide(); + ui->btnConnPWD->hide(); + + ui->lbSignal->show(); + ui->btnDisConn->hide(); + ui->btnHideConn->hide(); +} +// 点击连接隐藏wifi的item时 +void OneConnForm::setHideItem(bool isHideItem, bool isShowHideBtn){ + if (isHideItem){ + ui->lbName->move(14, 20); + ui->wbg->hide(); + ui->btnConn->hide(); + } else { + ui->lbName->move(62, 8); + ui->wbg->show(); + ui->btnConn->show(); + } + + if (isShowHideBtn){ + ui->btnHideConn->show(); + } else{ + ui->btnHideConn->hide(); + } } -void OneConnForm::setConnedString(QString str){ - ui->lbConned->setText(str); -} - -void OneConnForm::setSafeString(QString str){ - ui->lbSafe->setText(str); -} - -void OneConnForm::setShowPoint(bool flag){ - if(flag){ - ui->lbPoint->show(); +void OneConnForm::setConnedString(bool showLable, QString str, QString str1){ + if (!showLable){ + ui->lbConned->setText(str1); + ui->lbConned->hide(); + ui->lbName->move(63, 18); }else{ - ui->lbPoint->hide(); + ui->lbConned->setText(str); } } @@ -232,77 +285,71 @@ QString OneConnForm::getName() return ui->lbName->text(); } -void OneConnForm::setSafe(QString safe){ - if(safe == "--"){ - this->isSafe = false; - ui->lbSafe->setText(tr("Public"));//"开放" - }else{ - this->isSafe = true; - ui->lbSafe->setText(tr("Safe"));//"安全" - } -} - void OneConnForm::setRate(QString rate){ QString txt(tr("Rate"));//"速率" this->setToolTip("  " + txt + ": " + rate + "  "); QString rateStr = rate.split(" ").at(0); int rateNum = rateStr.toInt(); - if(rateNum >= 180){ - ui->lbPoint->setStyleSheet("QLabel{background:url(:/res/s/pgood.png);}"); - } - if(rateNum >= 100 && rateNum < 180){ - ui->lbPoint->setStyleSheet("QLabel{background:url(:/res/s/pnormal.png);}"); - } - if(rateNum <100){ - ui->lbPoint->setStyleSheet("QLabel{background:url(:/res/s/pbad.png);}"); - } } -void OneConnForm::setSignal(QString lv){ +void OneConnForm::setSignal(QString lv, QString secu){ int signal = lv.toInt(); + if (secu == "--" || secu == ""){ + hasPwd = false; + }else{ + hasPwd = true; + } + if(signal > 75){ - if(this->isSafe){ - ui->lbSignal->setStyleSheet("QLabel{background:url(:/res/s/wifi-full-secure.png);}"); + if(hasPwd){ + ui->lbSignal->setStyleSheet("QLabel{background:url(:/res/w/wifi-full-pwd.png);}"); }else{ - ui->lbSignal->setStyleSheet("QLabel{background:url(:/res/s/wifi-full.png);}"); + ui->lbSignal->setStyleSheet("QLabel{background:url(:/res/w/wifi-full.png);}"); } signalLv = 1; } if(signal > 55 && signal <= 75){ - if(this->isSafe){ - ui->lbSignal->setStyleSheet("QLabel{background:url(:/res/s/wifi-high-secure.png);}"); + if(hasPwd){ + ui->lbSignal->setStyleSheet("QLabel{background:url(:/res/w/wifi-high-pwd.png);}"); }else{ - ui->lbSignal->setStyleSheet("QLabel{background:url(:/res/s/wifi-high.png);}"); + ui->lbSignal->setStyleSheet("QLabel{background:url(:/res/w/wifi-high.png);}"); } signalLv = 2; } if(signal > 35 && signal <= 55){ - if(this->isSafe){ - ui->lbSignal->setStyleSheet("QLabel{background:url(:/res/s/wifi-medium-secure.png);}"); + if(hasPwd){ + ui->lbSignal->setStyleSheet("QLabel{background:url(:/res/w/wifi-medium-pwd.png);}"); }else{ - ui->lbSignal->setStyleSheet("QLabel{background:url(:/res/s/wifi-medium.png);}"); + ui->lbSignal->setStyleSheet("QLabel{background:url(:/res/w/wifi-medium.png);}"); } signalLv = 3; } if(signal > 15 && signal <= 35){ - if(this->isSafe){ - ui->lbSignal->setStyleSheet("QLabel{background:url(:/res/s/wifi-low-secure.png);}"); + if(hasPwd){ + ui->lbSignal->setStyleSheet("QLabel{background:url(:/res/w/wifi-low-pwd.png);}"); }else{ - ui->lbSignal->setStyleSheet("QLabel{background:url(:/res/s/wifi-low.png);}"); + ui->lbSignal->setStyleSheet("QLabel{background:url(:/res/w/wifi-low.png);}"); } signalLv = 4; } if(signal <= 15){ - if(this->isSafe){ - ui->lbSignal->setStyleSheet("QLabel{background:url(:/res/s/wifi-none-secure.png);}"); + if(hasPwd){ + ui->lbSignal->setStyleSheet("QLabel{background:url(:/res/w/wifi-none-pwd.png);}"); }else{ - ui->lbSignal->setStyleSheet("QLabel{background:url(:/res/s/wifi-none.png);}"); + ui->lbSignal->setStyleSheet("QLabel{background:url(:/res/w/wifi-none.png);}"); } signalLv = 4; } } -void OneConnForm::slotConnWifi(){ +void OneConnForm::setWifiInfo(QString str1, QString str2, QString str3) +{ + QString str = "Wi-Fi安全性:" + str1 + "\n信号强度:" + str2 + "%\n物理地址(MAC):" + str3; + ui->lbInfo->setText(str); +} + +void OneConnForm::slotConnWifi() +{ mw->startLoading(); emit sigConnWifi(ui->lbName->text()); } @@ -311,55 +358,31 @@ void OneConnForm::slotConnWifiPWD(){ emit sigConnWifiPWD(ui->lbName->text(), ui->lePassword->text()); } -//点击后设置wifi网络 -void OneConnForm::on_btnConf_clicked() +void OneConnForm::on_btnConnSub_clicked() { - QPoint pos = QCursor::pos(); - QRect primaryGeometry; - for (QScreen *screen : qApp->screens()) { - if (screen->geometry().contains(pos)) { - primaryGeometry = screen->geometry(); - } - } - - if (primaryGeometry.isEmpty()) { - primaryGeometry = qApp->primaryScreen()->geometry(); + if (ui->lbConned->text() == "--" || ui->lbConned->text() == " "){ + on_btnConnPWD_clicked(); + return; } + mw->is_stop_check_net_state = 1; + QThread *t = new QThread(); BackThread *bt = new BackThread(); - QString connProp = bt->getConnProp(ui->lbName->text()); - QStringList propList = connProp.split("|"); - QString v4method, addr, mask, gateway, dns; - foreach (QString line, propList) { - if(line.startsWith("method:")){ - v4method = line.split(":").at(1); - } - if(line.startsWith("addr:")){ - addr = line.split(":").at(1); - } - if(line.startsWith("mask:")){ - mask = line.split(":").at(1); - } - if(line.startsWith("gateway:")){ - gateway= line.split(":").at(1); - } - if(line.startsWith("dns:")){ - dns = line.split(":").at(1); - } - } -// qDebug()<setProp(ui->lbName->text(), v4method, addr, mask, gateway, dns, this->isActive); - - cf->move(primaryGeometry.width() / 2 - cf->width() / 2, primaryGeometry.height() / 2 - cf->height() / 2); - cf->show(); - cf->raise(); + bt->moveToThread(t); + connect(t, SIGNAL(finished()), t, SLOT(deleteLater())); + connect(t, SIGNAL(started()), this, SLOT(slotConnWifi())); + connect(this, SIGNAL(sigConnWifi(QString)), bt, SLOT(execConnWifi(QString))); + connect(bt, SIGNAL(connDone(int)), mw, SLOT(connWifiDone(int))); + connect(bt, SIGNAL(connDone(int)), this, SLOT(slotConnWifiResult(int))); + connect(bt, SIGNAL(btFinish()), t, SLOT(quit())); + t->start(); } //点击后断开wifi网络 void OneConnForm::on_btnDisConn_clicked() { mw->is_stop_check_net_state = 1; + mw->on_btnHotspotState(); kylin_network_set_con_down(ui->lbName->text().toUtf8().data()); disconnect(this, SIGNAL(selectedOneWifiForm(QString)), mw, SLOT(oneWifiFormSelected(QString))); emit disconnActiveWifi(); @@ -368,6 +391,11 @@ void OneConnForm::on_btnDisConn_clicked() //无需密码的wifi连接 void OneConnForm::on_btnConn_clicked() { + if (ui->lbConned->text() == "--" || ui->lbConned->text() == " "){ + on_btnConnPWD_clicked(); + return; + } + mw->is_stop_check_net_state = 1; QThread *t = new QThread(); BackThread *bt = new BackThread(); @@ -406,24 +434,59 @@ void OneConnForm::on_btnHideConn_clicked() connHidWifi->show(); } +//设置密码隐藏或可见 +void OneConnForm::on_checkBoxPwd_stateChanged(int arg1) +{ + if (arg1 == 0) { + ui->lePassword ->setEchoMode(QLineEdit::Password); + } else { + ui->lePassword->setEchoMode(QLineEdit::Normal); + } +} + +void OneConnForm::on_lePassword_textEdited(const QString &arg1) +{ + if (ui->lePassword->text().size() < 5){ + ui->lePassword->setStyleSheet("QLineEdit{border:2px solid rgba(28, 47, 146, 1);border-radius:4px;" + "background:rgba(0,0,0,0.2);color:rgba(255,255,255,0.35);font-size:14px;}"); + ui->btnConnPWD->setStyleSheet("QPushButton{border:0px;border-radius:4px;background-color:rgba(255,255,255,0.12);color:white;font-size:14px;}" + "QPushButton:Hover{border:0px solid rgba(255,255,255,0.2);border-radius:4px;background-color:rgba(0,0,0,0.2);}" + "QPushButton:Pressed{border-radius:4px;background-color:rgba(0,0,0,0.6);}"); + ui->btnConnPWD->setEnabled(false); + } else { + ui->lePassword->setStyleSheet("QLineEdit{border:2px solid rgba(28, 47, 146, 1);border-radius:4px;" + "background:rgba(0,0,0,0.2);color:rgba(255,255,255,1);font-size:14px;}"); + ui->btnConnPWD->setStyleSheet("QPushButton{border:0px;border-radius:4px;background-color:rgba(61,107,229,1);color:white;font-size:14px;}" + "QPushButton:Hover{border:0px solid rgba(255,255,255,0.2);border-radius:4px;background-color:rgba(107,142,235,1);}" + "QPushButton:Pressed{border-radius:4px;background-color:rgba(50,87,202,1);}"); + ui->btnConnPWD->setEnabled(true); + } +} + // Wifi连接结果,0成功 1失败 2没有配置文件 void OneConnForm::slotConnWifiResult(int connFlag){ qDebug()<<"Function slotConnWifiResult receives a number: "<lbPassword->show(); + mw->currSelNetName = ""; + emit selectedOneWifiForm(ui->lbName->text()); + + resize(422, 118); + ui->wbg->hide(); + ui->wbg_2->show(); + ui->wbg_3->hide(); + ui->lbInfo->hide(); + ui->btnHideConn->hide(); + ui->btnDisConn->hide(); + ui->btnConn->hide(); + ui->btnConnSub->hide(); + ui->lbInfo->hide(); + ui->lePassword->show(); ui->checkBoxPwd->show(); ui->btnConnPWD->show(); - ui->lbName->hide(); - ui->lbSafe->hide(); - ui->lbSignal->hide(); - ui->lbPoint->hide(); - ui->btnConf->hide(); - ui->btnConn->hide(); - ui->btnDisConn->hide(); + this->isSelected = true; } if(connFlag == 1){ @@ -437,15 +500,7 @@ void OneConnForm::slotConnWifiResult(int connFlag){ // 设置全局变量,当前连接Wifi的信号强度 currentActWifiSignalLv = signalLv; - mw->stopLoading(); -} - -//设置密码隐藏或可见 -void OneConnForm::on_checkBoxPwd_stateChanged(int arg1) -{ - if (arg1 == 0) { - ui->lePassword ->setEchoMode(QLineEdit::Password); - } else { - ui->lePassword->setEchoMode(QLineEdit::Normal); + if (connFlag != 0){ + mw->stopLoading(); } } diff --git a/oneconnform.h b/oneconnform.h index 1890bea7..185bc570 100644 --- a/oneconnform.h +++ b/oneconnform.h @@ -46,24 +46,24 @@ public: explicit OneConnForm(QWidget *parent = 0, MainWindow *mw = 0, ConfForm *confForm = 0, KSimpleNM *ksnm = 0); ~OneConnForm(); - void setSignal(QString lv); + void setSignal(QString lv, QString secu); void setName(QString name); void setSpecialName(QString name); QString getName(); - void setSafe(QString safe); void setRate(QString rate); + void setWifiInfo(QString str1, QString str2, QString str3); void setSelected(bool isSelected); - void setHideSelected(bool isSelected); + void setHideItem(bool isHideItem, bool isShowHideBtn); + void setTopItem(bool isSelected); void setAct(bool isAct); - void setSafeString(QString str); - void setConnedString(QString str); - void setShowPoint(bool flag); + void setConnedString(bool showLable, QString str, QString str1); QString wifiName; bool isSelected; bool isActive; + bool isConnected; int signalLv; signals: @@ -76,10 +76,9 @@ signals: protected: void mousePressEvent(QMouseEvent *event); + bool eventFilter(QObject *obj, QEvent *event); private slots: - void on_btnConf_clicked(); - void on_btnConn_clicked(); void on_btnDisConn_clicked(); @@ -93,12 +92,16 @@ private slots: void on_checkBoxPwd_stateChanged(int arg1); + void on_lePassword_textEdited(const QString &arg1); + + void on_btnConnSub_clicked(); + private: Ui::OneConnForm *ui; MainWindow *mw; ConfForm *cf; KSimpleNM *ks; - bool isSafe; + bool hasPwd; }; #endif // ONECONNFORM_H diff --git a/oneconnform.ui b/oneconnform.ui index c26b7cf1..622d93ac 100644 --- a/oneconnform.ui +++ b/oneconnform.ui @@ -6,7 +6,7 @@ 0 0 - 314 + 422 60 @@ -16,7 +16,7 @@ - 62 + 63 8 190 20 @@ -26,13 +26,13 @@ - + - 21 - 70 - 129 - 32 + 316 + 14 + 100 + 34 @@ -42,10 +42,10 @@ - 162 - 70 - 129 - 32 + 316 + 14 + 100 + 34 @@ -55,7 +55,7 @@ - 15 + 14 14 32 32 @@ -65,35 +65,12 @@ - - - - 62 - 31 - 80 - 18 - - - - - - - - - - 100 - 20 - 190 - 30 - - - - 180 - 19 - 90 + 63 + 31 + 140 20 @@ -101,13 +78,137 @@ - + - 280 - 25 - 10 - 10 + 0 + 0 + 422 + 118 + + + + + + 64 + 72 + 352 + 30 + + + + + + + 390 + 83 + 18 + 9 + + + + + + + + + + + 316 + 14 + 100 + 34 + + + + + + + + + + 316 + 14 + 100 + 34 + + + + + + + + + + 316 + 14 + 100 + 34 + + + + + + + + + + 0 + 0 + 422 + 148 + + + + + + 63 + 71 + 230 + 61 + + + + + + + + + + + 0 + 58 + 422 + 1 + + + + background-color: rgba(255, 255, 255,0.06); + + + Qt::Horizontal + + + + + + 115 + 33 + 16 + 16 + + + + + + + + + + 190 + 33 + 16 + 16 @@ -119,90 +220,53 @@ 0 0 - 314 - 111 + 422 + 60 - + - 162 - 70 - 129 - 32 - - - - - - - - - - 25 - 25 - 70 - 18 - - - - - - - - - - 162 - 70 - 129 - 32 - - - - - - - - - - 162 - 70 - 129 - 32 - - - - - - - - - - 260 + 132 31 - 18 - 9 + 65 + 20 - wbg + + + + 207 + 31 + 65 + 20 + + + + + + + lbLoadUp + lbLoadDown + wbg_3 + wbg_2 lbName - btnConf - btnConn lbSignal - lbSafe lbConned - lbPoint - btnDisConn - lbPassword + line + lbLoadDownImg + lbLoadUpImg + wbg + btnConnSub + btnConn btnConnPWD + btnDisConn btnHideConn - lePassword - checkBoxPwd diff --git a/onelancform.cpp b/onelancform.cpp index bb3bc02d..0a9ac7fa 100644 --- a/onelancform.cpp +++ b/onelancform.cpp @@ -28,30 +28,47 @@ OneLancForm::OneLancForm(QWidget *parent, MainWindow *mainWindow, ConfForm *conf { ui->setupUi(this); - ui->btnConf->setText(tr("Config"));//"设置" + ui->btnConnSub->setText(tr("Config"));//"设置" ui->btnConn->setText(tr("Connect"));//"连接" ui->btnDisConn->setText(tr("Disconnect"));//"断开连接" + ui->lbConned->setAlignment(Qt::AlignLeft); + ui->lbLoadUp->setAlignment(Qt::AlignLeft); + ui->lbLoadDown->setAlignment(Qt::AlignLeft); + + ui->lbInfo->setStyleSheet("QLabel{font-size:14px;color:rgba(255,255,255,0.57);}"); + ui->wbg->setStyleSheet("#wbg{border-radius:4px;background-color:rgba(255,255,255,0.1);}"); + ui->wbg_2->setStyleSheet("#wbg_2{border-radius:4px;background-color:rgba(255,255,255,0);}"); + //"#wbg_2:Hover{border-radius:4px;background-color:rgba(255,255,255,0.1);}"); + ui->lbName->setStyleSheet("QLabel{font-size:14px;color:rgba(255,255,255,0.91);}"); + ui->lbConned->setStyleSheet("QLabel{font-size:14px;color:rgba(255,255,255,0.57);}"); + ui->lbLoadUp->setStyleSheet("QLabel{font-size:14px;color:rgba(255,255,255,0.57);}"); + ui->lbLoadDown->setStyleSheet("QLabel{font-size:14px;color:rgba(255,255,255,0.57);}"); + ui->btnConnSub->setStyleSheet("QPushButton{border:0px;border-radius:4px;background-color:rgba(61,107,229,1);color:white;font-size:14px;}" + "QPushButton:Hover{border:0px solid rgba(255,255,255,0.2);border-radius:4px;background-color:rgba(107,142,235,1);}" + "QPushButton:Pressed{border-radius:4px;background-color:rgba(50,87,202,1);}"); + ui->btnConn->setStyleSheet("QPushButton{border:0px;border-radius:4px;background-color:rgba(61,107,229,1);color:white;font-size:14px;}" + "QPushButton:Hover{border:0px solid rgba(255,255,255,0.2);border-radius:4px;background-color:rgba(107,142,235,1);}" + "QPushButton:Pressed{border-radius:4px;background-color:rgba(50,87,202,1);}"); + ui->btnDisConn->setStyleSheet("QPushButton{border:0px;border-radius:4px;background-color:rgba(255,255,255,0.12);color:white;font-size:14px;}" + "QPushButton:Hover{border:0px solid rgba(255,255,255,0.2);border-radius:4px;background-color:rgba(255,255,255,0.2);}" + "QPushButton:Pressed{border-radius:4px;background-color:rgba(255,255,255,0.08);}"); + ui->lbLoadDownImg->setStyleSheet("QLabel{background-image:url(:/res/x/load-down.png);}"); + ui->lbLoadUpImg->setStyleSheet("QLabel{background-image:url(:/res/x/load-up.png);}"); + + ui->btnConnSub->setFocusPolicy(Qt::NoFocus); + ui->btnConn->setFocusPolicy(Qt::NoFocus); + ui->btnDisConn->setFocusPolicy(Qt::NoFocus); + ui->wbg->hide(); - ui->btnConf->hide(); + ui->wbg_2->show(); + ui->lbName->show(); + ui->btnConnSub->hide(); ui->btnConn->hide(); ui->btnDisConn->hide(); - - ui->lbConned->setAlignment(Qt::AlignRight); - - ui->wbg->setStyleSheet("#wbg{background-color:#3593b5;}"); - ui->lbName->setStyleSheet("QLabel{font-size:13px;color:#ffffff;}"); - ui->lbBandWidth->setStyleSheet("QLabel{font-size:12px;color:#aaaaaa;}"); - ui->lbConned->setStyleSheet("QLabel{font-size:13px;color:#ffffff;}"); - ui->btnConf->setStyleSheet("QPushButton{border:0px;background-color:rgba(0,0,0,0.4);color:white;font-size:12px;}" - "QPushButton:Hover{border:1px solid rgba(255,255,255,0.2);background-color:rgba(0,0,0,0.2);}" - "QPushButton:Pressed{background-color:rgba(0,0,0,0.6);}"); - ui->btnConn->setStyleSheet("QPushButton{border:0px;background-color:rgba(0,0,0,0.4);color:white;font-size:12px;}" - "QPushButton:Hover{border:1px solid rgba(255,255,255,0.2);background-color:rgba(0,0,0,0.2);}" - "QPushButton:Pressed{background-color:rgba(0,0,0,0.6);}"); - ui->btnDisConn->setStyleSheet("QPushButton{border:0px;background-color:rgba(0,0,0,0.4);color:white;font-size:12px;}" - "QPushButton:Hover{border:1px solid rgba(255,255,255,0.2);background-color:rgba(0,0,0,0.2);}" - "QPushButton:Pressed{background-color:rgba(0,0,0,0.6);}"); + ui->line->show(); + ui->lbLoadDownImg->hide(); + ui->lbLoadUpImg->hide(); this->mw = mainWindow; this->cf = confForm; @@ -60,6 +77,12 @@ OneLancForm::OneLancForm(QWidget *parent, MainWindow *mainWindow, ConfForm *conf this->isSelected = false; this->isActive = false; + ui->wbg_2->setAttribute(Qt::WA_Hover,true);//开启悬停事件 + ui->wbg_2->installEventFilter(this); //安装事件过滤器 + ui->btnConn->setAttribute(Qt::WA_Hover,true);//开启悬停事件 + ui->btnConn->installEventFilter(this); //安装事件过滤器 + + srand((unsigned)time(NULL)); } @@ -72,44 +95,107 @@ void OneLancForm::mousePressEvent(QMouseEvent *){ emit selectedOneLanForm(lanName); } +//事件过滤器 +bool OneLancForm::eventFilter(QObject *obj, QEvent *event) +{ + if(obj == ui->wbg_2) { + if(event->type() == QEvent::HoverEnter) { + ui->btnConn->show(); + ui->wbg_2->setStyleSheet("#wbg_2{border-radius:4px;background-color:rgba(255,255,255,0.1);}"); + return true; + } else if(event->type() == QEvent::HoverLeave){ + ui->btnConn->hide(); + ui->wbg_2->setStyleSheet("#wbg_2{border-radius:4px;background-color:rgba(255,255,255,0);}"); + return true; + } + } + + if(obj == ui->btnConn) { + if(event->type() == QEvent::HoverEnter) { + ui->wbg_2->hide(); + ui->btnConn->show(); + return true; + } else if(event->type() == QEvent::HoverLeave){ + ui->wbg_2->show(); + return true; + } + } + + return QWidget::eventFilter(obj,event); +} + // 是否当前连接的网络,字体设置不同 void OneLancForm::setAct(bool isAct){ if(isAct){ ui->lbName->setStyleSheet("QLabel{font-size:14px;color:#ffffff;}"); ui->lbConned->show(); - ui->btnConf->show(); + ui->btnConnSub->hide(); }else{ - ui->lbName->setStyleSheet("QLabel{font-size:12px;color:#ffffff;}"); + ui->lbName->setStyleSheet("QLabel{font-size:14px;color:#ffffff;}"); ui->lbConned->hide(); - ui->btnConf->hide(); + ui->btnConnSub->hide(); } isActive = isAct; } // 是否选中 -void OneLancForm::setSelected(bool isSelected){ +void OneLancForm::setSelected(bool isSelected) +{ if(isSelected){ - resize(314, 111); + resize(422, 168); ui->wbg->show(); - ui->btnConf->show(); - if(isActive){ - ui->btnDisConn->show(); - }else{ - ui->btnConn->show(); - } + ui->wbg_2->hide(); + ui->line->hide(); + ui->btnConn->show(); + ui->btnConnSub->show(); this->isSelected = true; - }else{ - resize(314, 60); + resize(422, 60); ui->wbg->hide(); - ui->btnConf->hide(); + ui->wbg_2->show(); + ui->line->show(); ui->btnConn->hide(); - ui->btnDisConn->hide(); - ui->lbName->show(); + ui->btnConnSub->hide(); this->isSelected = false; } + + ui->btnDisConn->hide(); +} + +void OneLancForm::setTopItem(bool isSelected) +{ + if(isSelected){ + resize(422, 168); + ui->wbg->show(); + ui->btnConnSub->hide(); + this->isSelected = true; + }else{ + resize(422, 60); + ui->wbg->hide(); + ui->btnConnSub->hide(); + this->isSelected = false; + } + if (isConnected){ +// ui->lbLoadUp->setText("0Kb/s"); +// ui->lbLoadDown->setText("0Kb/s"); + ui->lbLoadUp->hide(); + ui->lbLoadDown->hide(); + ui->btnDisConn->show(); + } else { +// ui->lbLoadUp->setText("0Kb/s"); +// ui->lbLoadDown->setText("0Kb/s"); + ui->lbLoadUp->hide(); + ui->lbLoadDown->hide(); + ui->btnDisConn->hide(); + } + + ui->btnConn->hide(); + ui->wbg_2->hide(); + ui->line->hide(); + ui->lbLoadUpImg->show(); + ui->lbLoadDownImg->show(); } void OneLancForm::setName(QString name){ @@ -117,91 +203,40 @@ void OneLancForm::setName(QString name){ lanName = name; } -void OneLancForm::setConnedString(QString str){ - ui->lbConned->setText(str); +void OneLancForm::setConnedString(bool showLable, QString str){ + if (!showLable){ + ui->lbConned->hide(); + ui->lbName->move(63, 18); + }else{ + ui->lbConned->setText(str); + } +} + +void OneLancForm::setLanInfo(QString str1, QString str2, QString str3, QString str4) +{ + QString str = "IPv4地址:" + str1 + "\nIPv6地址:" + str2 + "\n带宽:" + str3 + " \n物理地址(MAC):" + str4; + ui->lbInfo->setText(str); } void OneLancForm::setIcon(bool isOn){ if(isOn){ - ui->lbIcon->setStyleSheet("QLabel{background:url(:/res/s/network-line.png);}"); + ui->lbIcon->setStyleSheet("QLabel{background:url(:/res/l/network-online.png);}"); }else{ - ui->lbIcon->setStyleSheet("QLabel{background:url(:/res/s/network-offline.png);}"); + ui->lbIcon->setStyleSheet("QLabel{background:url(:/res/l/network-offline.png);}"); } } -void OneLancForm::setBandWidth(QString bandWidth){ - ui->lbBandWidth->setText(bandWidth); - - if(bandWidth == "--"){ - ui->lbPoint->setStyleSheet("QLabel{background:url(:/res/s/pbad.png);}"); - }else{ - if(bandWidth != ""){ - QString rateStr = bandWidth.mid(0, bandWidth.indexOf("Mb")); - int rateNum = rateStr.toInt(); - - if(rateNum >= 1000){ - ui->lbPoint->setStyleSheet("QLabel{background:url(:/res/s/pgood.png);}"); - } - if(rateNum >= 100 && rateNum < 1000){ - ui->lbPoint->setStyleSheet("QLabel{background:url(:/res/s/pnormal.png);}"); - } - if(rateNum < 100){ - ui->lbPoint->setStyleSheet("QLabel{background:url(:/res/s/pbad.png);}"); - } - } - } -} - -void OneLancForm::setShowPoint(bool flag){ - if(flag){ - ui->lbPoint->show(); - }else{ - ui->lbPoint->hide(); - } -} - -void OneLancForm::on_btnConf_clicked() +void OneLancForm::on_btnConnSub_clicked() { - QPoint pos = QCursor::pos(); - QRect primaryGeometry; - for (QScreen *screen : qApp->screens()) { - if (screen->geometry().contains(pos)) { - primaryGeometry = screen->geometry(); - } - } - - if (primaryGeometry.isEmpty()) { - primaryGeometry = qApp->primaryScreen()->geometry(); - } - + QThread *t = new QThread(); BackThread *bt = new BackThread(); - QString connProp = bt->getConnProp(ui->lbName->text()); - QStringList propList = connProp.split("|"); - QString v4method, addr, mask, gateway, dns; - foreach (QString line, propList) { - if(line.startsWith("method:")){ - v4method = line.split(":").at(1); - } - if(line.startsWith("addr:")){ - addr = line.split(":").at(1); - } - if(line.startsWith("mask:")){ - mask = line.split(":").at(1); - } - if(line.startsWith("gateway:")){ - gateway= line.split(":").at(1); - } - if(line.startsWith("dns:")){ - dns = line.split(":").at(1); - } - } -// qDebug()<setProp(ui->lbName->text(), v4method, addr, mask, gateway, dns, this->isActive); - - cf->move(primaryGeometry.width() / 2 - cf->width() / 2, primaryGeometry.height() / 2 - cf->height() / 2); - cf->show(); - cf->raise(); + bt->moveToThread(t); + connect(t, SIGNAL(finished()), t, SLOT(deleteLater())); + connect(t, SIGNAL(started()), this, SLOT(slotConnLan())); + connect(this, SIGNAL(sigConnLan(QString)), bt, SLOT(execConnLan(QString))); + connect(bt, SIGNAL(connDone(int)), mw, SLOT(connLanDone(int))); + connect(bt, SIGNAL(btFinish()), t, SLOT(quit())); + t->start(); } void OneLancForm::slotConnLan(){ diff --git a/onelancform.h b/onelancform.h index fae26e99..33f44191 100644 --- a/onelancform.h +++ b/onelancform.h @@ -22,6 +22,7 @@ #include #include #include +#include #include "confform.h" #include "kylin-network-interface.h" @@ -44,16 +45,17 @@ public: void setName(QString name); void setIcon(bool isOn); - void setBandWidth(QString bandWidth); + void setLanInfo(QString str1, QString str2, QString str3, QString str4); void setSelected(bool isSelected); + void setTopItem(bool isSelected); void setAct(bool isAct); - void setConnedString(QString str); - void setShowPoint(bool flag); + void setConnedString(bool showLable, QString str); bool isSelected; bool isActive; + bool isConnected; QString lanName; signals: @@ -65,11 +67,11 @@ signals: protected: void mousePressEvent(QMouseEvent *event); + bool eventFilter(QObject *obj, QEvent *event); private slots: - void on_btnConf_clicked(); void on_btnConn_clicked(); - + void on_btnConnSub_clicked(); void on_btnDisConn_clicked(); void slotConnLan(); diff --git a/onelancform.ui b/onelancform.ui index 68194888..7fbe1b24 100644 --- a/onelancform.ui +++ b/onelancform.ui @@ -6,7 +6,7 @@ 0 0 - 314 + 422 60 @@ -16,7 +16,7 @@ - 62 + 63 8 190 20 @@ -29,23 +29,23 @@ - 162 - 70 - 129 - 32 + 316 + 14 + 100 + 34 - + - 21 - 70 - 129 - 32 + 316 + 14 + 100 + 34 @@ -55,10 +55,10 @@ - 162 - 70 - 129 - 32 + 316 + 14 + 100 + 34 @@ -68,9 +68,9 @@ - 180 - 19 - 90 + 63 + 31 + 52 20 @@ -83,15 +83,28 @@ 0 0 - 314 - 111 + 422 + 168 + + + + 63 + 71 + 238 + 85 + + + + + + - 15 + 14 14 32 32 @@ -101,41 +114,97 @@ - + - 62 + 0 + 58 + 422 + 1 + + + + background-color: rgba(255, 255, 255,0.06); + + + Qt::Horizontal + + + + + + 115 + 33 + 16 + 16 + + + + + + + + + + 190 + 33 + 16 + 16 + + + + + + + + + + 132 31 - 80 - 18 + 65 + 20 - + - 280 - 25 - 10 - 10 + 207 + 31 + 65 + 20 - wbg + + + + 0 + 0 + 422 + 60 + + + + lbLoadUp + lbLoadDown lbName - btnConn - btnConf - btnDisConn lbConned lbIcon - lbBandWidth - lbPoint + line + lbLoadDownImg + lbLoadUpImg + wbg + wbg_2 + btnConnSub + btnDisConn + btnConn diff --git a/res/l/network-offline.png b/res/l/network-offline.png new file mode 100644 index 00000000..a288fc32 Binary files /dev/null and b/res/l/network-offline.png differ diff --git a/res/l/network-offline.svg b/res/l/network-offline.svg new file mode 100644 index 00000000..ca9dcea3 --- /dev/null +++ b/res/l/network-offline.svg @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + diff --git a/res/l/network-online.png b/res/l/network-online.png new file mode 100644 index 00000000..b8c5fe4a Binary files /dev/null and b/res/l/network-online.png differ diff --git a/res/l/network-online.svg b/res/l/network-online.svg new file mode 100644 index 00000000..7f10bfdf --- /dev/null +++ b/res/l/network-online.svg @@ -0,0 +1 @@ +gnome-dev-ethernet32 \ No newline at end of file diff --git a/res/w/wifi-full-pwd.png b/res/w/wifi-full-pwd.png new file mode 100644 index 00000000..065f7f8e Binary files /dev/null and b/res/w/wifi-full-pwd.png differ diff --git a/res/w/wifi-full.png b/res/w/wifi-full.png new file mode 100644 index 00000000..48024d04 Binary files /dev/null and b/res/w/wifi-full.png differ diff --git a/res/w/wifi-high-pwd.png b/res/w/wifi-high-pwd.png new file mode 100644 index 00000000..81a4d11e Binary files /dev/null and b/res/w/wifi-high-pwd.png differ diff --git a/res/w/wifi-high.png b/res/w/wifi-high.png new file mode 100644 index 00000000..3ec53052 Binary files /dev/null and b/res/w/wifi-high.png differ diff --git a/res/w/wifi-low-pwd.png b/res/w/wifi-low-pwd.png new file mode 100644 index 00000000..784ad1b2 Binary files /dev/null and b/res/w/wifi-low-pwd.png differ diff --git a/res/w/wifi-low.png b/res/w/wifi-low.png new file mode 100644 index 00000000..3fe8bded Binary files /dev/null and b/res/w/wifi-low.png differ diff --git a/res/w/wifi-medium-pwd.png b/res/w/wifi-medium-pwd.png new file mode 100644 index 00000000..221fdbc1 Binary files /dev/null and b/res/w/wifi-medium-pwd.png differ diff --git a/res/w/wifi-medium.png b/res/w/wifi-medium.png new file mode 100644 index 00000000..3b1683f3 Binary files /dev/null and b/res/w/wifi-medium.png differ diff --git a/res/w/wifi-none-pwd.png b/res/w/wifi-none-pwd.png new file mode 100644 index 00000000..109f19ee Binary files /dev/null and b/res/w/wifi-none-pwd.png differ diff --git a/res/w/wifi-none.png b/res/w/wifi-none.png new file mode 100644 index 00000000..0a3bdd14 Binary files /dev/null and b/res/w/wifi-none.png differ diff --git a/res/x/fly-mode-off.svg b/res/x/fly-mode-off.svg new file mode 100644 index 00000000..408b7b07 --- /dev/null +++ b/res/x/fly-mode-off.svg @@ -0,0 +1,19 @@ + + + + +画板 1 + + + + + diff --git a/res/x/fly-mode-on.svg b/res/x/fly-mode-on.svg new file mode 100644 index 00000000..9f5e543b --- /dev/null +++ b/res/x/fly-mode-on.svg @@ -0,0 +1,14 @@ + + + + +画板 1 + + diff --git a/res/x/hot-spot-off.svg b/res/x/hot-spot-off.svg new file mode 100644 index 00000000..cf39cadb --- /dev/null +++ b/res/x/hot-spot-off.svg @@ -0,0 +1,22 @@ + + + + + + + + + + + + + diff --git a/res/x/hot-spot-on.svg b/res/x/hot-spot-on.svg new file mode 100644 index 00000000..2041db9d --- /dev/null +++ b/res/x/hot-spot-on.svg @@ -0,0 +1,17 @@ + + + + + + + + + + diff --git a/res/x/load-down.png b/res/x/load-down.png new file mode 100644 index 00000000..a96298ac Binary files /dev/null and b/res/x/load-down.png differ diff --git a/res/x/load-up.png b/res/x/load-up.png new file mode 100644 index 00000000..e5ec581b Binary files /dev/null and b/res/x/load-up.png differ diff --git a/res/x/net-list-bg.svg b/res/x/net-list-bg.svg new file mode 100644 index 00000000..c17c1fd8 --- /dev/null +++ b/res/x/net-list-bg.svg @@ -0,0 +1,16 @@ + + + + + + + + + + + + diff --git a/res/x/wifi-list-bg.svg b/res/x/wifi-list-bg.svg new file mode 100644 index 00000000..43f18664 --- /dev/null +++ b/res/x/wifi-list-bg.svg @@ -0,0 +1,15 @@ + + + + +画板 1 + + + + + + + diff --git a/translations/kylin-nm_bo.ts b/translations/kylin-nm_bo.ts index 30be1546..fbfdffa5 100644 --- a/translations/kylin-nm_bo.ts +++ b/translations/kylin-nm_bo.ts @@ -4,7 +4,7 @@ BackThread - + Confirm your Wi-Fi password @@ -1170,124 +1170,173 @@ + + DlgHotspotCreate + + + Dialog + + + + + Create Hotspot + + + + + Network name + + + + + Wi-Fi security + + + + + Password + + + + + Cancel + + + + + Ok + + + + + None + + + + + WPA & WPA2 Personal + + + MainWindow - + kylin-nm - - Network - - - - + + Advanced - + Ethernet - + Wifi - - - - - - - Enabled + + HotSpot - - - - - - - - - Disabled + + FlyMode - - - - - - - + + + + + + + Not connected - - - - - - - + + + + + + + + + + Disconnected - - - + + + + Ethernet Networks - - + + Connected - - + + + Wifi Networks - + + Show MainWindow + + + + + + + None + + + + keep wired network switch is on before turning on wireless switch - + please insert the wireless network adapter - + Abnormal connection exist, program will delete it - + Conn Ethernet Success - + Conn Ethernet Fail - + Conn Wifi Success @@ -1301,48 +1350,33 @@ - Input password - - - - Config + - - + Connect - + Disconnect - + Connect to Hidden Wi-Fi Network - - Public - - - - - Safe - - - - + Rate - + Conn Wifi Failed diff --git a/translations/kylin-nm_zh_CN.qm b/translations/kylin-nm_zh_CN.qm index 31e52a2e..6798a046 100644 Binary files a/translations/kylin-nm_zh_CN.qm and b/translations/kylin-nm_zh_CN.qm differ diff --git a/translations/kylin-nm_zh_CN.ts b/translations/kylin-nm_zh_CN.ts index 51181cf0..eba9f79d 100644 --- a/translations/kylin-nm_zh_CN.ts +++ b/translations/kylin-nm_zh_CN.ts @@ -4,7 +4,7 @@ BackThread - + Confirm your Wi-Fi password 请再次确认Wi-Fi密码 @@ -1170,109 +1170,170 @@ WPA 及 WPA2 企业 + + DlgHotspotCreate + + + Dialog + + + + + Create Hotspot + 创建个人热点 + + + + Network name + 网络名称: + + + + Wi-Fi security + Wi-Fi 安全性: + + + + Password + 密码: + + + + Cancel + 取消 + + + + Ok + 确定 + + + + None + + + + + WPA & WPA2 Personal + WPA 及 WPA2 个人 + + MainWindow - + kylin-nm 网络工具 - Network - 网络 + 网络 - + + Advanced 高级设置 - + Ethernet 有线网络 - + Wifi 无线网络 - - - - - - Enabled - 已开启 + 已开启 - - - - - - - - Disabled - 已关闭 + 已关闭 - - - - - - - + + HotSpot + 个人热点 + + + + FlyMode + 飞行模式 + + + + Show MainWindow + 显示网络连接界面 + + + + + + + + + Not connected 当前未连接任何网络 - - - - - - - + + + + + + + + + + Disconnected 未连接 - - - + + + + Ethernet Networks 可用网络列表 - - + + Connected 已连接 - - + + + Wifi Networks 可用网络列表 - + + + + None + + + + keep wired network switch is on before turning on wireless switch 打开无线网开关前保持有线网开关打开 - + please insert the wireless network adapter 请先插入无线网卡 - + Abnormal connection exist, program will delete it 正在断开异常连接的网络 @@ -1285,17 +1346,17 @@ 正在更新 Wi-Fi列表 - + Conn Ethernet Success 连接有线网络成功 - + Conn Ethernet Fail 连接有线网络失败 - + Conn Wifi Success 连接无线网络成功 @@ -1308,49 +1369,46 @@ -- - Input password - 输入密码 + 输入密码 - + Config 设置 + - - + Connect 连接 - + Disconnect - 断开连接 + 断开 - + Connect to Hidden Wi-Fi Network 连接到隐藏 Wi-Fi 网络 - Public - 开放 + 开放 - Safe - 安全 + 安全 - + Rate 速率 - + Conn Wifi Failed 连接无线网络失败 @@ -1375,7 +1433,7 @@ Disconnect - 断开连接 + 断开