This commit is contained in:
shine 2019-01-14 10:35:52 +08:00
parent e3a2eaa0b6
commit 54eddb5d82
26 changed files with 734 additions and 92 deletions

View File

@ -1,3 +1,21 @@
/*
* Copyright (C) 2019 Tianjin KYLIN Information Technology Co., Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/&gt;.
*
*/
#include "backthread.h"
#include <QFile>
@ -18,6 +36,9 @@ IFace* BackThread::execGetIface(){
QStringList txtList = txt.split("\n");
file.close();
iface->lstate = 2;
iface->wstate = 2;
for(int i = 1; i < txtList.size(); i ++){
QString line = txtList.at(i);
if(line != ""){

View File

@ -1,3 +1,21 @@
/*
* Copyright (C) 2019 Tianjin KYLIN Information Technology Co., Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/&gt;.
*
*/
#ifndef BACKTHREAD_H
#define BACKTHREAD_H

View File

@ -1,3 +1,21 @@
/*
* Copyright (C) 2019 Tianjin KYLIN Information Technology Co., Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/&gt;.
*
*/
#include "confform.h"
#include "ui_confform.h"
#include "kylin-network-interface.h"
@ -13,17 +31,19 @@ ConfForm::ConfForm(QWidget *parent) :
this->setWindowFlags(Qt::FramelessWindowHint);
ui->lbName->hide();
ui->lbTxt1->setText("编辑IP设置");
ui->lbTxt2->setText("IP地址");
ui->lbTxt3->setText("子网掩码:");
ui->lbTxt4->setText("默认网关:");
ui->lbTxt5->setText("首选DNS");
ui->lbTxt6->setText("备选DNS");
this->setWindowTitle(tr("edit network"));//"网络设置"
ui->lbTitle->setText("网络设置");
ui->cbType->addItem("Auto(DHCP)");
ui->cbType->addItem("Manual");
ui->lbName->hide();
ui->lbTxt1->setText(tr("Method: "));//"编辑IP设置"
ui->lbTxt2->setText(tr("Address: "));//"IP地址"
ui->lbTxt3->setText(tr("Netmask: "));//"子网掩码:"
ui->lbTxt4->setText(tr("Gateway: "));//"默认网关:"
ui->lbTxt5->setText(tr("DNS 1: "));//"首选DNS"
ui->lbTxt6->setText(tr("DNS 2: "));//"备选DNS"
ui->lbTitle->setText(tr("Edit Conn"));//"网络设置"
ui->cbType->addItem(tr("Auto(DHCP)"));//"自动(DHCP)"
ui->cbType->addItem(tr("Manual"));//"手动"
connect(ui->cbType, SIGNAL(currentIndexChanged(int)), this, SLOT(cbTypeChanged(int)));
@ -31,8 +51,8 @@ ConfForm::ConfForm(QWidget *parent) :
ui->cbMask->addItem("255.255.0.0");
ui->cbMask->addItem("255.0.0.0");
ui->btnCancel->setText("取消");
ui->btnOk->setText("确定");
ui->btnCancel->setText(tr("Cancel"));//"取消"
ui->btnOk->setText(tr("Save"));//"确定"
ui->centralWidget->setStyleSheet("#centralWidget{border:1px solid #297a97;background-color:#ffffff;}");
ui->lbIcon->setStyleSheet("QLabel{background-image:url(:/res/s/setting.png)}");
@ -164,7 +184,8 @@ void ConfForm::on_btnOk_clicked()
QString cmd = "/usr/share/kylin-nm/shell/connup.sh '" + ui->lbName->text() + "'";
system(cmd.toUtf8().data());
cmd = "export LANG='en_US.UTF-8';export LANGUAGE='en_US';notify-send '新的设置已生效' -t 3800";
QString txt(tr("New settings already effective"));
cmd = "export LANG='en_US.UTF-8';export LANGUAGE='en_US';notify-send '" + txt + "' -t 3800";
system(cmd.toUtf8().data());
}
}

View File

@ -1,3 +1,21 @@
/*
* Copyright (C) 2019 Tianjin KYLIN Information Technology Co., Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/&gt;.
*
*/
#ifndef CONFFORM_H
#define CONFFORM_H

View File

@ -11,7 +11,7 @@
</rect>
</property>
<property name="windowTitle">
<string>网络设置</string>
<string/>
</property>
<widget class="QWidget" name="centralWidget" native="true">
<property name="geometry">

4
debian/changelog vendored
View File

@ -1,9 +1,9 @@
kylin-nm (1.0.1-0ubuntu1) disco; urgency=medium
* Fix some interactive bugs.
* Fix some interactive and logic bugs.
* Internationalization zh_CN.
-- shine <shenghuang@ubuntukylin.com> Mon, 14 Jan 2019 09:29:55 +0800
-- shine <shenghuang@ubuntukylin.com> Mon, 14 Jan 2019 10:30:43 +0800
kylin-nm (1.0.0-0ubuntu1) disco; urgency=medium

View File

@ -1,3 +1,21 @@
/*
* Copyright (C) 2019 Tianjin KYLIN Information Technology Co., Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/&gt;.
*
*/
#include "ksimplenm.h"
#include <stdio.h>
#define MAX_LEN 2048

View File

@ -1,3 +1,21 @@
/*
* Copyright (C) 2019 Tianjin KYLIN Information Technology Co., Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/&gt;.
*
*/
#ifndef KSIMPLENM_H
#define KSIMPLENM_H

View File

@ -1,3 +1,21 @@
/*
* Copyright (C) 2019 Tianjin KYLIN Information Technology Co., Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/&gt;.
*
*/
#include <netinet/in.h>
#include <sys/socket.h>
#include <sys/ioctl.h>

View File

@ -1,3 +1,21 @@
/*
* Copyright (C) 2019 Tianjin KYLIN Information Technology Co., Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/&gt;.
*
*/
#ifndef __KYLINNETWORKINTERFACE_H__
#define __KYLINNETWORKINTERFACE_H__

View File

@ -64,3 +64,5 @@ FORMS += \
RESOURCES += \
nmqrc.qrc
TRANSLATIONS = res/kylin-nm_zh_CN.ts

View File

@ -1,14 +1,27 @@
/*
* Copyright (C) 2019 Tianjin KYLIN Information Technology Co., Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/&gt;.
*
*/
#include "loadingdiv.h"
LoadingDiv::LoadingDiv(QWidget *parent) : QWidget(parent)
{
this->resize(316, 467);
QLabel *aaa = new QLabel(this);
aaa->resize(316, 467);
aaa->move(0, 0);
aaa->setStyleSheet("QLabel{background-color:rgba(0,0,0,0.5);}");
this->loadingGif = new QLabel(this);
this->loadingGif->resize(96, 96);
this->loadingGif->move(this->width() / 2 - 96 / 2, this->height() / 2 - 96 / 2);

View File

@ -1,3 +1,21 @@
/*
* Copyright (C) 2019 Tianjin KYLIN Information Technology Co., Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/&gt;.
*
*/
#ifndef LOADINGDIV_H
#define LOADINGDIV_H

View File

@ -1,4 +1,24 @@
/*
* Copyright (C) 2019 Tianjin KYLIN Information Technology Co., Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/&gt;.
*
*/
#include "mainwindow.h"
#include <QTranslator>
#include <QLocale>
#include <QApplication>
#include <QDebug>
@ -8,6 +28,15 @@
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
// 国际化
QString locale = QLocale::system().name();
QTranslator trans_global;
if(locale == "zh_CN"){
trans_global.load(":/res/kylin-nm_zh_CN.qm");
a.installTranslator(&trans_global);
}
MainWindow w;
return a.exec();
}

View File

@ -1,3 +1,21 @@
/*
* Copyright (C) 2019 Tianjin KYLIN Information Technology Co., Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/&gt;.
*
*/
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "oneconnform.h"
@ -99,9 +117,12 @@ MainWindow::MainWindow(QWidget *parent) :
ui->lbBtnConfT2->setStyleSheet("QLabel{font-size:12px;font-weight:100;color:#ffffff;}");
ui->lbBtnConfBG->setStyleSheet(btnOffQss);
ui->lbBtnNetT2->setText("网络");
ui->lbBtnNetT2->setText(tr("Network"));//"网络"
ui->lbBtnWifiT2->setText("Wifi");
ui->lbBtnConfT2->setText("高级设置");
ui->lbBtnConfT2->setText(tr("Advanced"));//"高级设置"
ui->btnNetList->setText(tr("Ethernet"));//"有线网络"
ui->btnWifiList->setText(tr("Wifi"));//"无线网络"
createTrayIcon();
@ -275,26 +296,26 @@ void MainWindow::getIface(){
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("已开启");
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("已开启");
ui->lbBtnWifiT1->setText(tr("Enabled"));//"已开启"
}else{
ui->lbWifiImg->setStyleSheet("QLabel{background-image:url(:/res/x/wifi-offline.png);}");
ui->lbBtnWifiBG->setStyleSheet(btnOffQss);
ui->lbBtnWifiT1->setText("已关闭");
ui->lbBtnWifiT1->setText(tr("Disabled"));//"已关闭"
}
}else{
ui->lbLanImg->setStyleSheet("QLabel{background-image:url(:/res/x/network-offline.png);}");
ui->lbBtnNetBG->setStyleSheet(btnOffQss);
ui->lbBtnNetT1->setText("已关闭");
ui->lbBtnNetT1->setText(tr("Disabled"));//"已关闭"
ui->lbWifiImg->setStyleSheet("QLabel{background-image:url(:/res/x/wifi-offline.png);}");
ui->lbBtnWifiBG->setStyleSheet(btnOffQss);
ui->lbBtnWifiT1->setText("已关闭");
ui->lbBtnWifiT1->setText(tr("Disabled"));//"已关闭"
}
// 初始化网络列表
@ -309,6 +330,8 @@ void MainWindow::getIface(){
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);}");
}else{
disNetDone();
}
}
}
@ -390,9 +413,9 @@ void MainWindow::getLanListDone(QStringList slist){
// 当前连接的lan
OneLancForm *ccf = new OneLancForm(lanListWidget, this, confForm, ksnm);
if(actLanName == "--"){
ccf->setName("当前未连接任何 以太网");
ccf->setName(tr("Not connected"));//"当前未连接任何 以太网"
ccf->setIcon(false);
ccf->setConnedString("未连接");
ccf->setConnedString(tr("Disconnected"));//"未连接"
ccf->setBandWidth("--");
ccf->setShowPoint(true);
}
@ -402,7 +425,7 @@ void MainWindow::getLanListDone(QStringList slist){
// 可用lan列表
lbLanList = new QLabel(lanListWidget);
lbLanList->setText("可用网络列表");
lbLanList->setText(tr("Ethernet Networks"));//"可用网络列表"
lbLanList->resize(260, 46);
lbLanList->move(12, 68);
lbLanList->setStyleSheet("QLabel{font-size:12px;color:white;}");
@ -428,7 +451,7 @@ void MainWindow::getLanListDone(QStringList slist){
ccf->setIcon(true);
ccf->setBandWidth(bandWidth);
ccf->setShowPoint(true);
ccf->setConnedString("已连接");
ccf->setConnedString(tr("Connected"));//"已连接"
}else{
lanListWidget->resize(314, lanListWidget->height() + 60);
@ -473,11 +496,11 @@ void MainWindow::getWifiListDone(QStringList slist){
// 当前连接的wifi
OneConnForm *ccf = new OneConnForm(wifiListWidget, this, confForm, ksnm);
if(actWifiName == "--"){
ccf->setName("当前未连接任何 Wifi");
ccf->setName(tr("Not connected"));//"当前未连接任何 Wifi"
ccf->setSafe("--");
ccf->setSignal("0");
ccf->setSafeString("--");
ccf->setConnedString("未连接");
ccf->setConnedString(tr("Disconnected"));//"未连接"
}
ccf->setAct(true);
ccf->move(0, 8);
@ -485,7 +508,7 @@ void MainWindow::getWifiListDone(QStringList slist){
// 可用wifi列表
lbWifiList = new QLabel(wifiListWidget);
lbWifiList->setText("可用网络列表");
lbWifiList->setText(tr("Wifi Networks"));//"可用网络列表"
lbWifiList->resize(260, 46);
lbWifiList->move(12, 68);
lbWifiList->setStyleSheet("QLabel{font-size:12px;color:white;}");
@ -527,7 +550,7 @@ void MainWindow::getWifiListDone(QStringList slist){
ccf->setSafe(wsecu);
ccf->setRate(wrate);
ccf->setSignal(wsignal);
ccf->setConnedString("已连接");
ccf->setConnedString(tr("Connected"));//"已连接"
}else{
wifiListWidget->resize(314, wifiListWidget->height() + 60);
@ -607,12 +630,52 @@ void MainWindow::on_btnWifi_clicked()
}
}
void MainWindow::on_btnNetList_clicked()
void MainWindow::on_btnNetList_clicked(int flag)
{
this->startLoading();
// 强行设置为打开
if(flag == 1){
this->startLoading();
this->ksnm->execGetLanList();
this->scrollAreal->show();
this->scrollAreaw->hide();
on_btnNetList_pressed();
return;
}
if(checkLanOn()){
this->startLoading();
this->ksnm->execGetLanList();
}else{
// 清空lan列表
lanListWidget = new QWidget(scrollAreal);
lanListWidget->resize(314, 8 + 60 + 46 + 51);
scrollAreal->setWidget(lanListWidget);
// 当前连接的lan
OneLancForm *ccf = new OneLancForm(lanListWidget, this, confForm, ksnm);
ccf->setName(tr("Not connected"));//"当前未连接任何 以太网"
ccf->setIcon(false);
ccf->setConnedString(tr("Disconnected"));//"未连接"
ccf->setBandWidth("--");
ccf->setShowPoint(true);
ccf->setAct(true);
ccf->move(0, 8);
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->scrollAreaw->hide();
this->ksnm->execGetLanList();
on_btnNetList_pressed();
}
void MainWindow::on_btnWifiList_clicked()
@ -628,17 +691,19 @@ void MainWindow::on_btnWifiList_clicked()
// 当前连接的wifi
OneConnForm *ccf = new OneConnForm(wifiListWidget, this, confForm, ksnm);
ccf->setName("当前未连接任何 Wifi");
ccf->setName(tr("Not connected"));//"当前未连接任何 Wifi"
ccf->setSafe("--");
ccf->setSignal("0");
ccf->setRate("0");
ccf->setSafeString("--");
ccf->setConnedString("未连接");
ccf->setConnedString(tr("Disconnected"));//"未连接"
ccf->setAct(true);
ccf->setShowPoint(true);
ccf->move(0, 8);
ccf->show();
lbWifiList = new QLabel(wifiListWidget);
lbWifiList->setText("可用网络列表");
lbWifiList->setText(tr("Wifi Networks"));//"可用网络列表"
lbWifiList->resize(260, 46);
lbWifiList->move(12, 68);
lbWifiList->setStyleSheet("QLabel{font-size:12px;color:white;}");
@ -656,12 +721,14 @@ void MainWindow::on_btnWifiList_clicked()
void MainWindow::connLanDone(int connFlag){
if(connFlag == 0){
this->ksnm->execGetLanList();
QString cmd = "export LANG='en_US.UTF-8';export LANGUAGE='en_US';notify-send '连接 以太网 成功' -t 3800";
QString txt(tr("Conn Ethernet Success"));
QString cmd = "export LANG='en_US.UTF-8';export LANGUAGE='en_US';notify-send '" + txt + "' -t 3800";
system(cmd.toUtf8().data());
}
if(connFlag == 1){
QString cmd = "export LANG='en_US.UTF-8';export LANGUAGE='en_US';notify-send '连接 以太网 失败...' -t 3800";
QString txt(tr("Conn Ethernet Fail"));
QString cmd = "export LANG='en_US.UTF-8';export LANGUAGE='en_US';notify-send '" + txt + "' -t 3800";
system(cmd.toUtf8().data());
}
@ -672,7 +739,8 @@ void MainWindow::connLanDone(int connFlag){
void MainWindow::connDone(int connFlag){
if(connFlag == 0){
this->ksnm->execGetWifiList();
QString cmd = "export LANG='en_US.UTF-8';export LANGUAGE='en_US';notify-send '连接 Wifi 成功' -t 3800";
QString txt(tr("Conn Wifi Success"));
QString cmd = "export LANG='en_US.UTF-8';export LANGUAGE='en_US';notify-send '" + txt + "' -t 3800";
system(cmd.toUtf8().data());
}
}
@ -802,44 +870,59 @@ void MainWindow::enNetDone(){
ui->lbLanImg->setStyleSheet("QLabel{background-image:url(:/res/x/network-line.png);}");
ui->lbBtnNetBG->setStyleSheet(btnOnQss);
ui->lbBtnNetT1->setText("已开启");
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("已开启");
ui->lbBtnWifiT1->setText(tr("Enabled"));//"已开启"
}
this->stopLoading();
on_btnNetList_clicked();
on_btnNetList_clicked(1);
}
void MainWindow::disNetDone(){
QList<OneLancForm *> lanList = lanListWidget->findChildren<OneLancForm *>();
for(int i = 0; i < lanList.size(); i ++){
OneLancForm *ocf = lanList.at(i);
if(ocf->isActive == true){
ocf->setSelected(false);
ocf->setName("当前未连接任何 以太网");
ocf->setIcon(false);
ocf->setConnedString("未连接");
ocf->setBandWidth("--");
disconnect(ocf, SIGNAL(selectedOneLanForm(QString)), this, SLOT(oneLanFormSelected(QString)));
}else{
ocf->deleteLater();
}
}
// 清空lan列表
lanListWidget = new QWidget(scrollAreal);
lanListWidget->resize(314, 8 + 60 + 46 + 51);
scrollAreal->setWidget(lanListWidget);
// 当前连接的lan
OneLancForm *ccf = new OneLancForm(lanListWidget, this, confForm, ksnm);
ccf->setName(tr("Not connected"));//"当前未连接任何 以太网"
ccf->setIcon(false);
ccf->setConnedString(tr("Disconnected"));//"未连接"
ccf->setBandWidth("--");
ccf->setShowPoint(true);
ccf->setAct(true);
ccf->move(0, 8);
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();
ui->lbLanImg->setStyleSheet("QLabel{background-image:url(:/res/x/network-offline.png);}");
ui->lbBtnNetBG->setStyleSheet(btnOffQss);
ui->lbBtnNetT1->setText("已关闭");
ui->lbBtnNetT1->setText(tr("Disabled"));//"已关闭"
ui->lbWifiImg->setStyleSheet("QLabel{background-image:url(:/res/x/wifi-offline.png);}");
ui->lbBtnWifiBG->setStyleSheet(btnOffQss);
ui->lbBtnWifiT1->setText("已关闭");
ui->lbBtnWifiT1->setText(tr("Disabled"));//"已关闭"
this->lanListWidget->show();
this->wifiListWidget->hide();
this->scrollAreal->show();
this->scrollAreaw->hide();
on_btnNetList_pressed();
this->stopLoading();
}
@ -847,7 +930,7 @@ void MainWindow::disNetDone(){
void MainWindow::enWifiDone(){
ui->lbWifiImg->setStyleSheet("QLabel{background-image:url(:/res/x/wifi-line.png);}");
ui->lbBtnWifiBG->setStyleSheet(btnOnQss);
ui->lbBtnWifiT1->setText("已开启");
ui->lbBtnWifiT1->setText(tr("Enabled"));//"已开启"
this->stopLoading();
@ -860,11 +943,11 @@ void MainWindow::disWifiDone(){
OneConnForm *ocf = wifiList.at(i);
if(ocf->isActive == true){
ocf->setSelected(false);
ocf->setName("当前未连接任何 Wifi");
ocf->setName(tr("Not connected"));//"当前未连接任何 Wifi"
ocf->setSafe("--");
ocf->setSignal("0");
ocf->setSafeString("--");
ocf->setConnedString("未连接");
ocf->setConnedString(tr("Disconnected"));//"未连接"
ocf->setShowPoint(false);
disconnect(ocf, SIGNAL(selectedOneWifiForm(QString)), this, SLOT(oneWifiFormSelected(QString)));
}else{
@ -875,7 +958,12 @@ void MainWindow::disWifiDone(){
ui->lbWifiImg->setStyleSheet("QLabel{background-image:url(:/res/x/wifi-offline.png);}");
ui->lbBtnWifiBG->setStyleSheet(btnOffQss);
ui->lbBtnWifiT1->setText("已关闭");
ui->lbBtnWifiT1->setText(tr("Disabled"));//"已关闭"
this->lanListWidget->hide();
this->wifiListWidget->show();
this->scrollAreal->hide();
this->scrollAreaw->show();
this->stopLoading();
}

View File

@ -1,3 +1,21 @@
/*
* Copyright (C) 2019 Tianjin KYLIN Information Technology Co., Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/&gt;.
*
*/
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
@ -89,7 +107,7 @@ private slots:
void on_btnNet_clicked();
void on_btnWifi_clicked();
void on_btnNetList_clicked();
void on_btnNetList_clicked(int flag=0);
void on_btnWifiList_clicked();
void getLanListDone(QStringList slist);

View File

@ -33,7 +33,7 @@
</rect>
</property>
<property name="text">
<string>无线网络</string>
<string/>
</property>
</widget>
<widget class="QPushButton" name="btnNetList">
@ -46,7 +46,7 @@
</rect>
</property>
<property name="text">
<string>有线网络</string>
<string/>
</property>
</widget>
</widget>
@ -81,7 +81,7 @@
<rect>
<x>40</x>
<y>412</y>
<width>50</width>
<width>55</width>
<height>18</height>
</rect>
</property>
@ -146,7 +146,7 @@
<rect>
<x>132</x>
<y>412</y>
<width>50</width>
<width>55</width>
<height>18</height>
</rect>
</property>
@ -211,7 +211,7 @@
<rect>
<x>227</x>
<y>440</y>
<width>55</width>
<width>70</width>
<height>18</height>
</rect>
</property>

View File

@ -61,5 +61,6 @@
<file>res/s/rescan/10.png</file>
<file>res/s/rescan/11.png</file>
<file>res/s/rescan/12.png</file>
<file>res/kylin-nm_zh_CN.qm</file>
</qresource>
</RCC>

View File

@ -1,3 +1,21 @@
/*
* Copyright (C) 2019 Tianjin KYLIN Information Technology Co., Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/&gt;.
*
*/
#include "oneconnform.h"
#include "ui_oneconnform.h"
#include "mainwindow.h"
@ -10,11 +28,11 @@ OneConnForm::OneConnForm(QWidget *parent, MainWindow *mainWindow, ConfForm *conf
{
ui->setupUi(this);
ui->lbPassword->setText("输入密码:");
ui->btnConf->setText("设置");
ui->btnConn->setText("连接");
ui->btnConnPWD->setText("连接");
ui->btnDisConn->setText("断开连接");
ui->lbPassword->setText(tr("Input password"));//"输入密码:"
ui->btnConf->setText(tr("Config"));//"设置"
ui->btnConn->setText(tr("Connect"));//"连接"
ui->btnConnPWD->setText(tr("Connect"));//"连接"
ui->btnDisConn->setText(tr("Disconnect"));//"断开连接"
ui->lePassword->setEchoMode(QLineEdit::Password);
ui->wbg->hide();
@ -25,6 +43,8 @@ OneConnForm::OneConnForm(QWidget *parent, MainWindow *mainWindow, ConfForm *conf
ui->btnDisConn->hide();
ui->btnConnPWD->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;}");
@ -150,15 +170,16 @@ void OneConnForm::setName(QString name){
void OneConnForm::setSafe(QString safe){
if(safe == "--"){
this->isSafe = false;
ui->lbSafe->setText("开放");
ui->lbSafe->setText(tr("Public"));//"开放"
}else{
this->isSafe = true;
ui->lbSafe->setText("安全");
ui->lbSafe->setText(tr("Safe"));//"安全"
}
}
void OneConnForm::setRate(QString rate){
this->setToolTip("<span style=\"font-size:13px;border:0px;background-color:#3593b5;color:white;\">&nbsp; 速率: " + rate + " &nbsp;</span>");
QString txt(tr("Rate"));//"速率"
this->setToolTip("<span style=\"font-size:13px;border:0px;background-color:#3593b5;color:white;\">&nbsp; " + txt + ": " + rate + " &nbsp;</span>");
QString rateStr = rate.split(" ").at(0);
int rateNum = rateStr.toInt();
if(rateNum >= 180){
@ -315,8 +336,9 @@ void OneConnForm::slotConnDone(int connFlag){
ui->btnDisConn->hide();
}
// 使用配置文件连接失败,需要删除该配置文件
QString txt(tr("Conn Wifi Failed"));//"连接 Wifi 失败"
if(connFlag == 1){
QString cmd = "export LANG='en_US.UTF-8';export LANGUAGE='en_US';nmcli connection delete '" + ui->lbName->text() + "';notify-send '连接 Wifi 失败...' -t 3800";
QString cmd = "export LANG='en_US.UTF-8';export LANGUAGE='en_US';nmcli connection delete '" + ui->lbName->text() + "';notify-send '" + txt + "...' -t 3800";
system(cmd.toUtf8().data());
}

View File

@ -1,3 +1,21 @@
/*
* Copyright (C) 2019 Tianjin KYLIN Information Technology Co., Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/&gt;.
*
*/
#ifndef ONECONNFORM_H
#define ONECONNFORM_H

View File

@ -91,9 +91,9 @@
<widget class="QLabel" name="lbConned">
<property name="geometry">
<rect>
<x>225</x>
<x>180</x>
<y>19</y>
<width>55</width>
<width>90</width>
<height>20</height>
</rect>
</property>

View File

@ -1,3 +1,21 @@
/*
* Copyright (C) 2019 Tianjin KYLIN Information Technology Co., Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/&gt;.
*
*/
#include "onelancform.h"
#include "ui_onelancform.h"
#include "mainwindow.h"
@ -8,15 +26,17 @@ OneLancForm::OneLancForm(QWidget *parent, MainWindow *mainWindow, ConfForm *conf
{
ui->setupUi(this);
ui->btnConf->setText("设置");
ui->btnConn->setText("连接");
ui->btnDisConn->setText("断开连接");
ui->btnConf->setText(tr("Config"));//"设置"
ui->btnConn->setText(tr("Connect"));//"连接"
ui->btnDisConn->setText(tr("Disconnect"));//"断开连接"
ui->wbg->hide();
ui->btnConf->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;}");

View File

@ -1,3 +1,21 @@
/*
* Copyright (C) 2019 Tianjin KYLIN Information Technology Co., Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/&gt;.
*
*/
#ifndef ONELANCFORM_H
#define ONELANCFORM_H

View File

@ -36,7 +36,7 @@
</rect>
</property>
<property name="text">
<string>连接</string>
<string/>
</property>
</widget>
<widget class="QPushButton" name="btnConf">
@ -49,7 +49,7 @@
</rect>
</property>
<property name="text">
<string>设置</string>
<string/>
</property>
</widget>
<widget class="QPushButton" name="btnDisConn">
@ -68,9 +68,9 @@
<widget class="QLabel" name="lbConned">
<property name="geometry">
<rect>
<x>225</x>
<x>180</x>
<y>19</y>
<width>55</width>
<width>90</width>
<height>20</height>
</rect>
</property>

BIN
res/kylin-nm_zh_CN.qm Normal file

Binary file not shown.

245
res/kylin-nm_zh_CN.ts Normal file
View File

@ -0,0 +1,245 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1" language="zh_CN">
<context>
<name>ConfForm</name>
<message>
<location filename="../confform.cpp" line="16"/>
<source>edit network</source>
<translation></translation>
</message>
<message>
<location filename="../confform.cpp" line="19"/>
<source>Method: </source>
<translation>IP设置: </translation>
</message>
<message>
<location filename="../confform.cpp" line="20"/>
<source>Address: </source>
<translation>IP地址: </translation>
</message>
<message>
<location filename="../confform.cpp" line="21"/>
<source>Netmask: </source>
<translation>: </translation>
</message>
<message>
<location filename="../confform.cpp" line="22"/>
<source>Gateway: </source>
<translation>: </translation>
</message>
<message>
<location filename="../confform.cpp" line="23"/>
<source>DNS 1: </source>
<translation>DNS: </translation>
</message>
<message>
<location filename="../confform.cpp" line="24"/>
<source>DNS 2: </source>
<translation>DNS: </translation>
</message>
<message>
<location filename="../confform.cpp" line="26"/>
<source>Edit Conn</source>
<translation></translation>
</message>
<message>
<location filename="../confform.cpp" line="27"/>
<source>Auto(DHCP)</source>
<translation>(DHCP)</translation>
</message>
<message>
<location filename="../confform.cpp" line="28"/>
<source>Manual</source>
<translation></translation>
</message>
<message>
<location filename="../confform.cpp" line="36"/>
<source>Cancel</source>
<translation></translation>
</message>
<message>
<location filename="../confform.cpp" line="37"/>
<source>Save</source>
<translation></translation>
</message>
<message>
<location filename="../confform.cpp" line="169"/>
<source>New settings already effective</source>
<translation></translation>
</message>
</context>
<context>
<name>MainWindow</name>
<message>
<location filename="../mainwindow.ui" line="14"/>
<source>kylin-nm</source>
<translation></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="102"/>
<source>Network</source>
<translation></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="104"/>
<source>Advanced</source>
<translation></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="106"/>
<source>Ethernet</source>
<translation>线</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="107"/>
<source>Wifi</source>
<translation>线</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="281"/>
<location filename="../mainwindow.cpp" line="286"/>
<location filename="../mainwindow.cpp" line="855"/>
<location filename="../mainwindow.cpp" line="861"/>
<location filename="../mainwindow.cpp" line="915"/>
<source>Enabled</source>
<translation></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="290"/>
<location filename="../mainwindow.cpp" line="296"/>
<location filename="../mainwindow.cpp" line="300"/>
<location filename="../mainwindow.cpp" line="896"/>
<location filename="../mainwindow.cpp" line="900"/>
<location filename="../mainwindow.cpp" line="943"/>
<source>Disabled</source>
<translation></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="398"/>
<location filename="../mainwindow.cpp" line="481"/>
<location filename="../mainwindow.cpp" line="638"/>
<location filename="../mainwindow.cpp" line="676"/>
<location filename="../mainwindow.cpp" line="877"/>
<location filename="../mainwindow.cpp" line="928"/>
<source>Not connected</source>
<translation></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="400"/>
<location filename="../mainwindow.cpp" line="485"/>
<location filename="../mainwindow.cpp" line="640"/>
<location filename="../mainwindow.cpp" line="681"/>
<location filename="../mainwindow.cpp" line="879"/>
<location filename="../mainwindow.cpp" line="932"/>
<source>Disconnected</source>
<translation></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="410"/>
<location filename="../mainwindow.cpp" line="649"/>
<location filename="../mainwindow.cpp" line="888"/>
<source>Ethernet Networks</source>
<translation></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="436"/>
<location filename="../mainwindow.cpp" line="535"/>
<source>Connected</source>
<translation></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="493"/>
<location filename="../mainwindow.cpp" line="688"/>
<source>Wifi Networks</source>
<translation></translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="706"/>
<source>Conn Ethernet Success</source>
<translation>线</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="712"/>
<source>Conn Ethernet Fail</source>
<translation>线</translation>
</message>
<message>
<location filename="../mainwindow.cpp" line="724"/>
<source>Conn Wifi Success</source>
<translation>线</translation>
</message>
</context>
<context>
<name>OneConnForm</name>
<message>
<location filename="../oneconnform.ui" line="14"/>
<source>Form</source>
<translation>--</translation>
</message>
<message>
<location filename="../oneconnform.cpp" line="13"/>
<source>Input password</source>
<translation></translation>
</message>
<message>
<location filename="../oneconnform.cpp" line="14"/>
<source>Config</source>
<translation></translation>
</message>
<message>
<location filename="../oneconnform.cpp" line="15"/>
<location filename="../oneconnform.cpp" line="16"/>
<source>Connect</source>
<translation></translation>
</message>
<message>
<location filename="../oneconnform.cpp" line="17"/>
<source>Disconnect</source>
<translation></translation>
</message>
<message>
<location filename="../oneconnform.cpp" line="155"/>
<source>Public</source>
<translation></translation>
</message>
<message>
<location filename="../oneconnform.cpp" line="158"/>
<source>Safe</source>
<translation></translation>
</message>
<message>
<location filename="../oneconnform.cpp" line="163"/>
<source>Rate</source>
<translation></translation>
</message>
<message>
<location filename="../oneconnform.cpp" line="321"/>
<source>Conn Wifi Failed</source>
<translation>线</translation>
</message>
</context>
<context>
<name>OneLancForm</name>
<message>
<location filename="../onelancform.ui" line="14"/>
<source>Form</source>
<translation>--</translation>
</message>
<message>
<location filename="../onelancform.cpp" line="11"/>
<source>Config</source>
<translation></translation>
</message>
<message>
<location filename="../onelancform.cpp" line="12"/>
<source>Connect</source>
<translation></translation>
</message>
<message>
<location filename="../onelancform.cpp" line="13"/>
<source>Disconnect</source>
<translation></translation>
</message>
</context>
</TS>