diff --git a/kylin-nm.pro b/kylin-nm.pro index 5994a951..d8ab0764 100644 --- a/kylin-nm.pro +++ b/kylin-nm.pro @@ -59,6 +59,7 @@ SOURCES += \ src/onelancform.cpp \ src/switchbutton.cpp \ src/utils.cpp \ + src/wpawifidialog.cpp \ wireless-security/dlghidewifi.cpp \ wireless-security/dlghidewifieapfast.cpp \ wireless-security/dlghidewifieapleap.cpp \ @@ -85,6 +86,7 @@ HEADERS += \ src/onelancform.h \ src/switchbutton.h \ src/utils.h \ + src/wpawifidialog.h \ wireless-security/dlghidewifi.h \ wireless-security/dlghidewifieapfast.h \ wireless-security/dlghidewifieapleap.h \ @@ -104,6 +106,7 @@ FORMS += \ src/oneconnform.ui \ src/onelancform.ui \ hot-spot/dlghotspotcreate.ui \ + src/wpawifidialog.ui \ wireless-security/dlghidewifi.ui \ wireless-security/dlghidewifieapfast.ui \ wireless-security/dlghidewifieapleap.ui \ diff --git a/src/kylin-dbus-interface.cpp b/src/kylin-dbus-interface.cpp index bf61195d..61ccb965 100644 --- a/src/kylin-dbus-interface.cpp +++ b/src/kylin-dbus-interface.cpp @@ -107,7 +107,9 @@ KylinDBus::KylinDBus(MainWindow *mainWindow, QObject *parent) :QObject(parent) time->setTimerType(Qt::PreciseTimer); QObject::connect(time, SIGNAL(timeout()), this, SLOT(slot_timeout())); - QObject::connect(this, SIGNAL(updateWiredList(int)), mw, SLOT(onBtnNetListClicked(int))); + if (mw) { + QObject::connect(this, SIGNAL(updateWiredList(int)), mw, SLOT(onBtnNetListClicked(int))); + } mUtils = new Utils(); mUtilsThread = new QThread(this); diff --git a/src/wpawifidialog.cpp b/src/wpawifidialog.cpp new file mode 100644 index 00000000..9d6fc262 --- /dev/null +++ b/src/wpawifidialog.cpp @@ -0,0 +1,265 @@ +#include "wpawifidialog.h" +#include "ui_wpawifidialog.h" +#include "kylin-network-interface.h" +#include "backthread.h" +#include "utils.h" +#include + +WpaWifiDialog::WpaWifiDialog(QWidget *parent, QString conname) : + QDialog(parent), + ui(new Ui::WpaWifiDialog) +{ + ui->setupUi(this); + this->setWindowFlags(Qt::FramelessWindowHint | Qt::Popup); + this->setAttribute(Qt::WA_TranslucentBackground); + this->setWindowIcon(QIcon::fromTheme("kylin-network", QIcon(":/res/x/setup.png")) ); +// this->setAttribute(Qt::WA_DeleteOnClose); + + connection_name = conname; + + QPainterPath path; + auto rect = this->rect(); + rect.adjust(1, 1, -1, -1); + path.addRoundedRect(rect, 6, 6); + setProperty("blurRegion", QRegion(path.toFillPolygon().toPolygon())); + KWindowEffects::enableBlurBehind(this->winId(), true, QRegion(path.toFillPolygon().toPolygon())); + + initUI(); + initCombox(); + initConnect(); +} + +WpaWifiDialog::~WpaWifiDialog() +{ + delete ui; +} + +void WpaWifiDialog::initUI() { + mainWidget = new QWidget(this); + mainLyt = new QVBoxLayout(mainWidget); + mainWidget->setFixedSize(360, 504); + + titleFrame = new QFrame(mainWidget); //标题栏 + titleFrame->setFixedHeight(48); + titleLyt = new QHBoxLayout(titleFrame); + titleLabel = new QLabel(titleFrame); + titleLabel->setText(tr("Connect Wifi")); + titleLyt->addWidget(titleLabel); + titleLyt->addStretch(); + titleFrame->setLayout(titleLyt); + + nameFrame = new QFrame(mainWidget); //网络名称 + nameFrame->setFixedHeight(48); + nameLyt = new QHBoxLayout(nameFrame); + nameLyt->setContentsMargins(24, 0, 24, 0); + nameLabel = new QLabel(nameFrame); + nameEditor = new QLineEdit(nameFrame); + nameEditor->setFixedHeight(48); + nameLabel->setFixedWidth(100); + nameLabel->setText(tr("Connection name")); + nameEditor->setText(connection_name); + nameEditor->setEnabled(false);//不允许编辑wifi名 + nameLyt->addWidget(nameLabel); + nameLyt->addWidget(nameEditor); + nameFrame->setLayout(nameLyt); + + securityFrame = new QFrame(mainWidget); //网络安全性 + securityFrame->setFixedHeight(48); + securityLyt = new QHBoxLayout(securityFrame); + securityLyt->setContentsMargins(24, 0, 24, 0); + securityLabel = new QLabel(securityFrame); + securityCombox = new QComboBox(securityFrame); + securityCombox->setFixedHeight(48); + securityLabel->setFixedWidth(100); + securityLabel->setText(tr("Security")); + securityLyt->addWidget(securityLabel); + securityLyt->addWidget(securityCombox); + securityFrame->setLayout(securityLyt); + + hLine = new QFrame(mainWidget); //分割线 + hLine->setFrameShape(QFrame::Shape::HLine); + hLine->setLineWidth(0); + hLine->setFixedHeight(1); + hLine->setStyleSheet("QFrame{background-color: palette(base);}"); + + eapFrame = new QFrame(mainWidget); //EAP方法 + eapFrame->setFixedHeight(48); + eapLyt = new QHBoxLayout(eapFrame); + eapLyt->setContentsMargins(24, 0, 24, 0); + eapLabel = new QLabel(eapFrame); + eapCombox = new QComboBox(eapFrame); + eapCombox->setFixedHeight(48); + eapLabel->setFixedWidth(100); + eapLabel->setText(tr("EAP type")); + eapLyt->addWidget(eapLabel); + eapLyt->addWidget(eapCombox); + eapFrame->setLayout(eapLyt); + + innerFrame = new QFrame(mainWidget); //阶段2身份认证 + innerFrame->setFixedHeight(48); + innerLyt = new QHBoxLayout(innerFrame); + innerLyt->setContentsMargins(24, 0, 24, 0); + innerLabel = new QLabel(innerFrame); + innerCombox = new QComboBox(innerFrame); + innerCombox->setFixedHeight(48); + innerLabel->setFixedWidth(100); + innerLabel->setText(tr("inner authentication")); + innerLyt->addWidget(innerLabel); + innerLyt->addWidget(innerCombox); + innerFrame->setLayout(innerLyt); + + userFrame = new QFrame(mainWidget); //用户名 + userFrame->setFixedHeight(48); + userLyt = new QHBoxLayout(userFrame); + userLyt->setContentsMargins(24, 0, 24, 0); + userLabel = new QLabel(userFrame); + userEditor = new QLineEdit(userFrame); + userEditor->setFixedHeight(48); + userLabel->setFixedWidth(100); + userLabel->setText(tr("Username")); + userLyt->addWidget(userLabel); + userLyt->addWidget(userEditor); + userFrame->setLayout(userLyt); + + pwdFrame = new QFrame(mainWidget); //密码 + pwdFrame->setFixedHeight(72); + pwdLyt = new QVBoxLayout(pwdFrame); + pwdLyt->setContentsMargins(0, 0, 0, 0); + pwdLyt->setSpacing(0); + pwdEditFrame = new QFrame(pwdFrame); //输入密码 + pwdEditFrame->setFixedHeight(48); + pwdEditLyt = new QHBoxLayout(pwdEditFrame); + pwdEditLyt->setContentsMargins(24, 0, 24, 0); + pwdLabel = new QLabel(pwdEditFrame); + pwdEditor = new QLineEdit(pwdEditFrame); + pwdEditor->setEchoMode(QLineEdit::Password); + pwdLabel->setText(tr("Password")); + pwdLabel->setFixedWidth(100); + pwdEditor->setFixedHeight(48); + pwdEditLyt->addWidget(pwdLabel); + pwdEditLyt->addWidget(pwdEditor); + pwdEditFrame->setLayout(pwdEditLyt); + pwdShowFrame = new QFrame(pwdFrame); //显示密码 + pwdShowFrame->setFixedHeight(24); + pwdShowLyt = new QHBoxLayout(pwdShowFrame); + pwdShowLyt->setContentsMargins(130, 0, 0, 0); + pwdShowBtn = new QCheckBox(pwdShowFrame); + pwdShowLabel = new QLabel(pwdShowFrame); + pwdShowLabel->setFixedWidth(120); + pwdShowBtn->setFixedSize(16, 16); + pwdShowLabel->setText(tr("Show password")); + pwdShowLyt->addWidget(pwdShowBtn); + pwdShowLyt->addWidget(pwdShowLabel); + pwdShowLyt->addStretch(); + pwdShowFrame->setLayout(pwdShowLyt); + pwdLyt->addWidget(pwdEditFrame); + pwdLyt->addWidget(pwdShowFrame); + pwdFrame->setLayout(pwdLyt); + + buttonFrame = new QFrame(mainWidget); //按钮 + buttonLyt = new QHBoxLayout(buttonFrame); + cancelBtn = new QPushButton(buttonFrame); //取消 + connectBtn = new QPushButton(buttonFrame); //连接 + cancelBtn->setFixedSize(72, 36); + connectBtn->setFixedSize(72, 36); + cancelBtn->setText(tr("Cancel")); + connectBtn->setText(tr("Connect")); + buttonLyt->addStretch(); + buttonLyt->addWidget(cancelBtn); + buttonLyt->addWidget(connectBtn); + buttonFrame->setLayout(buttonLyt); + + mainLyt->addWidget(titleFrame); + mainLyt->addWidget(nameFrame); + mainLyt->addWidget(securityFrame); + mainLyt->addWidget(hLine); + mainLyt->addWidget(eapFrame); + mainLyt->addWidget(innerFrame); + mainLyt->addWidget(userFrame); + mainLyt->addWidget(pwdFrame); + mainLyt->addWidget(buttonFrame); + mainLyt->setSpacing(8); + mainLyt->setContentsMargins(8, 16, 8, 16); + mainWidget->setLayout(mainLyt); +} + +void WpaWifiDialog::initCombox() { + //wifi安全性 + securityCombox->addItem(tr("WPA & WPA2")); +// securityCombox->setEnabled(false); + //EAP方法 + QStringList eapStringList; + eapStringList<< "PEAP" << "TLS" << "TTLS" << "PWD" << "SIM" << "AKA" << "AKA'"; + for (int i = 0; i < eapStringList.length(); i++) { + eapCombox->addItem(eapStringList.at(i), eapStringList.at(i)); + } + //阶段2认证方式 + QStringList innerStringList; + innerStringList<< tr("None") << "MSCHAPv2" << "GTC" << "SIM" << "AKA" << "AKA'"; + innerCombox->addItem(innerStringList.at(0), "None"); + for (int i = 1; i < innerStringList.length(); i++) { + innerCombox->addItem(innerStringList.at(i), innerStringList.at(i)); + } +} +void WpaWifiDialog::initConnect() { + //取消按钮 + connect(cancelBtn, &QPushButton::clicked, this, [ = ]() { + this->close(); + }); + //连接按钮 + connect(connectBtn, &QPushButton::clicked, this, &WpaWifiDialog::slot_on_connectBtn_clicked); + //显示密码 + connect(pwdShowBtn, &QCheckBox::clicked, this, [ = ]() { + if (pwdShowBtn->isChecked()) { + pwdEditor->setEchoMode(QLineEdit::Normal); + } else { + pwdEditor->setEchoMode(QLineEdit::Password); + } + }); +} + +void WpaWifiDialog::slot_on_connectBtn_clicked() { + qDebug()<<"Clicked on connect Btn!"; +} + +void WpaWifiDialog::mousePressEvent(QMouseEvent *event) +{ + if (event->button() == Qt::LeftButton) { + this->isPress = true; + this->winPos = this->pos(); + this->dragPos = event->globalPos(); + event->accept(); + } + return QDialog::mousePressEvent(event); +} +void WpaWifiDialog::mouseReleaseEvent(QMouseEvent *event) +{ + this->isPress = false; +} +void WpaWifiDialog::mouseMoveEvent(QMouseEvent *event) +{ + if (this->isPress) { + this->move(this->winPos - (this->dragPos - event->globalPos())); + event->accept(); + } + return QDialog::mouseMoveEvent(event); +} + +void WpaWifiDialog::paintEvent(QPaintEvent *event) +{ + KylinDBus mkylindbus; + double trans = mkylindbus.getTransparentData(); + + QStyleOption opt; + opt.init(this); + QPainter p(this); + style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this); + + QRect rect = this->rect(); + p.setRenderHint(QPainter::Antialiasing); // 反锯齿; + p.setBrush(opt.palette.color(QPalette::Base)); + p.setOpacity(trans); + p.setPen(Qt::NoPen); + p.drawRoundedRect(rect, 6, 6); + QWidget::paintEvent(event); +} diff --git a/src/wpawifidialog.h b/src/wpawifidialog.h new file mode 100644 index 00000000..dbfdd0ed --- /dev/null +++ b/src/wpawifidialog.h @@ -0,0 +1,103 @@ +#ifndef WPAWIFIDIALOG_H +#define WPAWIFIDIALOG_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace Ui { +class WpaWifiDialog; +} + +class WpaWifiDialog : public QDialog +{ + Q_OBJECT + +public: + explicit WpaWifiDialog(QWidget *parent = nullptr, QString conname = 0); + ~WpaWifiDialog(); + +private: + Ui::WpaWifiDialog *ui; + void initUI(); //初始化UI界面 + void initCombox(); //初始化所有下拉框 + void initConnect(); //初始化连接 + +protected: + void paintEvent(QPaintEvent *event); + +private: + QString connection_name; + void mousePressEvent(QMouseEvent *event); + void mouseReleaseEvent(QMouseEvent *event); + void mouseMoveEvent(QMouseEvent *event); + + bool isPress; + QPoint winPos; + QPoint dragPos; + +private: + QWidget * mainWidget = nullptr; + QVBoxLayout * mainLyt = nullptr; //弹窗整体布局 + + QFrame * titleFrame = nullptr; //标题栏 + QHBoxLayout * titleLyt = nullptr; + QLabel * titleLabel = nullptr; + + QFrame * nameFrame = nullptr; //网络名称 + QHBoxLayout * nameLyt = nullptr; + QLabel * nameLabel = nullptr; + QLineEdit * nameEditor = nullptr; + + QFrame * securityFrame = nullptr; //网络安全性 + QHBoxLayout * securityLyt = nullptr; + QLabel * securityLabel = nullptr; + QComboBox * securityCombox = nullptr; + + QFrame * hLine = nullptr; //分割线 + + QFrame * eapFrame = nullptr; //EAP方法 + QHBoxLayout * eapLyt = nullptr; + QLabel * eapLabel = nullptr; + QComboBox * eapCombox = nullptr; + + QFrame * innerFrame = nullptr; //阶段2身份认证 + QHBoxLayout * innerLyt = nullptr; + QLabel * innerLabel = nullptr; + QComboBox * innerCombox = nullptr; + + QFrame * userFrame = nullptr; //用户名 + QHBoxLayout * userLyt = nullptr; + QLabel * userLabel = nullptr; + QLineEdit * userEditor = nullptr; + + QFrame * pwdFrame = nullptr; //密码 + QVBoxLayout * pwdLyt = nullptr; + QFrame * pwdEditFrame = nullptr; //输入密码 + QHBoxLayout * pwdEditLyt = nullptr; + QLabel * pwdLabel = nullptr; + QLineEdit * pwdEditor = nullptr; + QFrame * pwdShowFrame = nullptr; //显示密码 + QHBoxLayout * pwdShowLyt = nullptr; + QCheckBox * pwdShowBtn = nullptr; + QLabel * pwdShowLabel = nullptr; + + QFrame * buttonFrame = nullptr; //按钮 + QHBoxLayout * buttonLyt = nullptr; + QPushButton * cancelBtn = nullptr; //取消 + QPushButton * connectBtn = nullptr; //连接 + +private slots: + void slot_on_connectBtn_clicked(); +}; + +#endif // WPAWIFIDIALOG_H diff --git a/src/wpawifidialog.ui b/src/wpawifidialog.ui new file mode 100644 index 00000000..0d02ef08 --- /dev/null +++ b/src/wpawifidialog.ui @@ -0,0 +1,31 @@ + + + WpaWifiDialog + + + + 0 + 0 + 360 + 504 + + + + + 360 + 504 + + + + + 360 + 504 + + + + Dialog + + + + + diff --git a/translations/kylin-nm_bo.ts b/translations/kylin-nm_bo.ts index 15d54998..bab9d7c4 100644 --- a/translations/kylin-nm_bo.ts +++ b/translations/kylin-nm_bo.ts @@ -1195,155 +1195,155 @@ MainWindow - + kylin-nm - - + + Advanced - - - + + + Ethernet - + New LAN - + Hide WiFi - - + + Wifi - + HotSpot - + FlyMode - + No wireless card detected - - - - - + + + + + Not connected - - - + + - - - - - + + + + + + Disconnected - + Ethernet Networks - + Wifi Networks - + No usable network in the list - + Show MainWindow - + No Other Wired Network Scheme - + No Other Wireless Network Scheme - - - - + + + + Wired connection - - - - + + + + Ethernet connection - + Confirm your Wi-Fi password or usable of wireless card - - + + NetOn, - + Wired net is disconnected - + Wi-Fi is disconnected - + Conn Ethernet Success - + Conn Ethernet Fail - + Conn Wifi Success @@ -1458,4 +1458,72 @@ + + WpaWifiDialog + + + Dialog + + + + + Connect Wifi + + + + + Connection name + + + + + Security + + + + + EAP type + + + + + inner authentication + + + + + Username + + + + + Password + + + + + Show password + + + + + Cancel + + + + + Connect + + + + + WPA & WPA2 + + + + + None + + + diff --git a/translations/kylin-nm_tr.qm b/translations/kylin-nm_tr.qm index 614f1eb2..85cbbf38 100644 Binary files a/translations/kylin-nm_tr.qm and b/translations/kylin-nm_tr.qm differ diff --git a/translations/kylin-nm_tr.ts b/translations/kylin-nm_tr.ts index b0e5f677..575161a8 100644 --- a/translations/kylin-nm_tr.ts +++ b/translations/kylin-nm_tr.ts @@ -1349,7 +1349,7 @@ MainWindow - + kylin-nm @@ -1358,15 +1358,15 @@ - - + + Advanced Gelişmiş - - - + + + Ethernet Kablolu Ağ @@ -1375,8 +1375,8 @@ Gizli Ağı Bağlan - - + + Wifi Wi-Fi @@ -1389,116 +1389,116 @@ Pasif - + HotSpot HotSpot - + FlyMode - + Show MainWindow Ana Pencereyi Göster - + No wireless card detected - - - - - + + + + + Not connected Bağlanamadı - - - + + - - - - - + + + + + + Disconnected Bağlantı Kesildi - + No Other Wired Network Scheme Başka Kablolu Ağ Düzeni Yok - + No Other Wireless Network Scheme Başka Kablosuz Ağ Düzeni Yok - - - - + + + + Wired connection - - - - + + + + Ethernet connection - + Wired net is disconnected Kablolu ağ bağlantısı kesildi - + Wi-Fi is disconnected Kablosuz bağlantı kesildi - + Confirm your Wi-Fi password or usable of wireless card Kablosuz şifrenizi veya kablosuz kart kullanılabilirliğini onaylayın - + Ethernet Networks Ethernet Ağları - + New LAN Yeni LAN - + Hide WiFi Gizli Wi-Fi - + No usable network in the list Listede kullanılabilir ağ yok - - + + NetOn, - + Wifi Networks Wi-Fi Ağları @@ -1527,17 +1527,17 @@ Kablosuz listesini şimdi güncelle - + Conn Ethernet Success Ethernet Bağlantısı Başarılı - + Conn Ethernet Fail Ethernet Bağlantısı Hatası - + Conn Wifi Success Wi-Fi Bağlantısı Başarılı @@ -1691,4 +1691,72 @@ Kylin ağ uygulaması masaüstü mesajı + + WpaWifiDialog + + + Dialog + + + + + Connect Wifi + + + + + Connection name + + + + + Security + + + + + EAP type + + + + + inner authentication + + + + + Username + + + + + Password + + + + + Show password + + + + + Cancel + + + + + Connect + + + + + WPA & WPA2 + + + + + None + Yok + + diff --git a/translations/kylin-nm_zh_CN.qm b/translations/kylin-nm_zh_CN.qm index 6c7305e9..030673bb 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 1a2504e3..69462191 100644 --- a/translations/kylin-nm_zh_CN.ts +++ b/translations/kylin-nm_zh_CN.ts @@ -1309,7 +1309,7 @@ MainWindow - + kylin-nm 网络工具 @@ -1318,15 +1318,15 @@ 网络 - - + + Advanced 设置网络 - - - + + + Ethernet 有线网络 @@ -1335,8 +1335,8 @@ 加入网络 - - + + Wifi 无线网络 @@ -1349,116 +1349,116 @@ 已关闭 - + HotSpot 个人热点 - + FlyMode 飞行模式 - + Show MainWindow 显示网络连接界面 - + No wireless card detected 未检测到无线网卡 - - - - - + + + + + Not connected 当前未连接任何网络 - - - + + - - - - - + + + + + + Disconnected 未连接 - + No Other Wired Network Scheme 列表中无其他有线网络 - + No Other Wireless Network Scheme 未检测到其他无线网络 - - - - + + + + Wired connection 有线连接 - - - - + + + + Ethernet connection 以太网连接 - + Wired net is disconnected 断开有线网络 - + Wi-Fi is disconnected 断开无线网络 - + Confirm your Wi-Fi password or usable of wireless card 请确认Wi-Fi密码或无线设备 - + Ethernet Networks 可用有线网络列表 - + New LAN 新建网络 - + Hide WiFi 加入网络 - + No usable network in the list 列表暂无可连接网络 - - + + NetOn, 已连接, - + Wifi Networks 可用无线网络列表 @@ -1487,17 +1487,17 @@ 正在更新 Wi-Fi列表 - + Conn Ethernet Success 连接有线网络成功 - + Conn Ethernet Fail 连接有线网络失败 - + Conn Wifi Success 连接无线网络成功 @@ -1647,4 +1647,72 @@ 麒麟网络工具信息提示 + + WpaWifiDialog + + + Dialog + + + + + Connect Wifi + 连接网络 + + + + Connection name + 连接名称 + + + + Security + 安全性 + + + + EAP type + EAP方法 + + + + inner authentication + 阶段2身份验证 + + + + Username + 用户名: + + + + Password + 密码: + + + + Show password + 显示密码 + + + + Cancel + 取消 + + + + Connect + 连接 + + + + WPA & WPA2 + WPA 及 WPA2企业 + + + + None + + +