Merge branch 'zdbus-ui-bysdk' into 'dbus-interface'
将目前实现的ui替换为sdk See merge request kylin-desktop/kylin-nm!595
This commit is contained in:
commit
efb08d43c8
|
@ -174,7 +174,7 @@ void WlanListItem::leaveEvent(QEvent *event)
|
||||||
|
|
||||||
bool WlanListItem::eventFilter(QObject *watched, QEvent *event)
|
bool WlanListItem::eventFilter(QObject *watched, QEvent *event)
|
||||||
{
|
{
|
||||||
if (watched == m_showPwdButton || watched == m_autoConnectCheckBox) {
|
if (watched == m_autoConnectCheckBox) {
|
||||||
if (event->type() == QEvent::FocusIn) {
|
if (event->type() == QEvent::FocusIn) {
|
||||||
m_pwdLineEdit->setFocus();
|
m_pwdLineEdit->setFocus();
|
||||||
}
|
}
|
||||||
|
@ -230,10 +230,11 @@ void WlanListItem::initWlanUI()
|
||||||
m_pwdFrameLyt->setSpacing(FRAME_SPACING);
|
m_pwdFrameLyt->setSpacing(FRAME_SPACING);
|
||||||
m_pwdFrame->setLayout(m_pwdFrameLyt);
|
m_pwdFrame->setLayout(m_pwdFrameLyt);
|
||||||
|
|
||||||
m_pwdLineEdit = new QLineEdit(m_pwdFrame);
|
m_pwdLineEdit = new KPasswordEdit(m_pwdFrame);
|
||||||
m_pwdLineEdit->setFixedWidth(LINEEDIT_WIDTH);
|
m_pwdLineEdit->setFixedWidth(LINEEDIT_WIDTH);
|
||||||
|
m_pwdLineEdit->setClearButtonEnabled(false); //禁用ClearBtn按钮
|
||||||
// m_pwdLineEdit->setAttribute(Qt::WA_InputMethodEnabled, false);
|
// m_pwdLineEdit->setAttribute(Qt::WA_InputMethodEnabled, false);
|
||||||
m_pwdLineEdit->setContextMenuPolicy(Qt::NoContextMenu);
|
// m_pwdLineEdit->setContextMenuPolicy(Qt::NoContextMenu);
|
||||||
|
|
||||||
QRegExp rx("^[A-Za-z0-9`~!@#$%^&*()_-+=<>,.\\\/]+$");
|
QRegExp rx("^[A-Za-z0-9`~!@#$%^&*()_-+=<>,.\\\/]+$");
|
||||||
QRegExpValidator *latitude = new QRegExpValidator(rx, this);
|
QRegExpValidator *latitude = new QRegExpValidator(rx, this);
|
||||||
|
@ -242,24 +243,8 @@ void WlanListItem::initWlanUI()
|
||||||
m_pwdLineEdit->installEventFilter(this);
|
m_pwdLineEdit->installEventFilter(this);
|
||||||
connect(m_pwdLineEdit, &QLineEdit::textChanged, this, &WlanListItem::onPwdEditorTextChanged);
|
connect(m_pwdLineEdit, &QLineEdit::textChanged, this, &WlanListItem::onPwdEditorTextChanged);
|
||||||
m_pwdLineEdit->setFixedHeight(PWD_AREA_HEIGHT);
|
m_pwdLineEdit->setFixedHeight(PWD_AREA_HEIGHT);
|
||||||
m_pwdLineEdit->setEchoMode(QLineEdit::EchoMode::Password);
|
|
||||||
m_pwdLineEdit->setTextMargins(PWD_CONTENT_MARGINS);
|
|
||||||
m_pwdFrameLyt->addWidget(m_pwdLineEdit);
|
m_pwdFrameLyt->addWidget(m_pwdLineEdit);
|
||||||
|
|
||||||
m_pwdLineEditLyt = new QHBoxLayout(m_pwdLineEdit);
|
|
||||||
m_pwdLineEditLyt->setContentsMargins(PWD_LAYOUT_MARGINS);
|
|
||||||
m_pwdLineEdit->setLayout(m_pwdLineEditLyt);
|
|
||||||
|
|
||||||
m_showPwdButton = new QPushButton(m_pwdLineEdit);
|
|
||||||
m_showPwdButton->setFlat(true); //去除边框
|
|
||||||
m_showPwdButton->installEventFilter(this);
|
|
||||||
m_showPwdButton->setFixedSize(SHOW_PWD_BUTTON_SIZE);
|
|
||||||
m_showPwdButton->setIcon(QIcon::fromTheme("ukui-eye-hidden-symbolic"));
|
|
||||||
m_showPwdButton->setCursor(Qt::PointingHandCursor);
|
|
||||||
connect(m_showPwdButton, &QPushButton::clicked, this, &WlanListItem::onShowPwdButtonClicked);
|
|
||||||
m_pwdLineEditLyt->addStretch();
|
|
||||||
m_pwdLineEditLyt->addWidget(m_showPwdButton);
|
|
||||||
|
|
||||||
m_connectButton = new QPushButton(m_pwdFrame);
|
m_connectButton = new QPushButton(m_pwdFrame);
|
||||||
m_connectButton->setFixedSize(CONNECT_BUTTON_WIDTH, PWD_AREA_HEIGHT);
|
m_connectButton->setFixedSize(CONNECT_BUTTON_WIDTH, PWD_AREA_HEIGHT);
|
||||||
m_connectButton->setText(tr("Connect"));
|
m_connectButton->setText(tr("Connect"));
|
||||||
|
@ -512,24 +497,6 @@ void WlanListItem::onPwdEditorTextChanged()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WlanListItem::onShowPwdButtonClicked()
|
|
||||||
{
|
|
||||||
qDebug()<< LOG_FLAG << "onShowPwdButtonClicked";
|
|
||||||
if (!m_pwdLineEdit) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_pwdLineEdit->echoMode() == QLineEdit::EchoMode::Password) {
|
|
||||||
m_showPwdButton->setIcon(QIcon::fromTheme("ukui-eye-display-symbolic"));
|
|
||||||
m_pwdLineEdit->setEchoMode(QLineEdit::EchoMode::Normal);
|
|
||||||
} else {
|
|
||||||
m_showPwdButton->setIcon(QIcon::fromTheme("ukui-eye-hidden-symbolic"));
|
|
||||||
m_pwdLineEdit->setEchoMode(QLineEdit::EchoMode::Password);
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
void WlanListItem::onConnectButtonClicked()
|
void WlanListItem::onConnectButtonClicked()
|
||||||
{
|
{
|
||||||
qDebug()<< LOG_FLAG << "onConnectButtonClicked";
|
qDebug()<< LOG_FLAG << "onConnectButtonClicked";
|
||||||
|
|
|
@ -12,6 +12,11 @@
|
||||||
|
|
||||||
#include <networkmanagerqt/wirelesssecuritysetting.h>
|
#include <networkmanagerqt/wirelesssecuritysetting.h>
|
||||||
|
|
||||||
|
#include "kwidget.h"
|
||||||
|
#include "kpasswordedit.h"
|
||||||
|
|
||||||
|
using namespace kdk;
|
||||||
|
|
||||||
#define PSK_SETTING_NAME "802-11-wireless-security"
|
#define PSK_SETTING_NAME "802-11-wireless-security"
|
||||||
|
|
||||||
#define NORMAL_HEIGHT 48
|
#define NORMAL_HEIGHT 48
|
||||||
|
@ -81,10 +86,7 @@ private:
|
||||||
//密码输入区域的UI
|
//密码输入区域的UI
|
||||||
QFrame *m_pwdFrame = nullptr;
|
QFrame *m_pwdFrame = nullptr;
|
||||||
QHBoxLayout *m_pwdFrameLyt = nullptr;
|
QHBoxLayout *m_pwdFrameLyt = nullptr;
|
||||||
|
KPasswordEdit *m_pwdLineEdit = nullptr;
|
||||||
QLineEdit * m_pwdLineEdit = nullptr;
|
|
||||||
QHBoxLayout *m_pwdLineEditLyt = nullptr;
|
|
||||||
QPushButton *m_showPwdButton = nullptr;
|
|
||||||
QPushButton *m_connectButton = nullptr;
|
QPushButton *m_connectButton = nullptr;
|
||||||
|
|
||||||
//自动连接选择区域UI
|
//自动连接选择区域UI
|
||||||
|
@ -105,7 +107,6 @@ protected slots:
|
||||||
private slots:
|
private slots:
|
||||||
void onNetButtonClicked();
|
void onNetButtonClicked();
|
||||||
void onPwdEditorTextChanged();
|
void onPwdEditorTextChanged();
|
||||||
void onShowPwdButtonClicked();
|
|
||||||
void onConnectButtonClicked();
|
void onConnectButtonClicked();
|
||||||
void onMenuTriggered(QAction *action);
|
void onMenuTriggered(QAction *action);
|
||||||
void onEnterpriseWlanDialogClose(bool isShow);
|
void onEnterpriseWlanDialogClose(bool isShow);
|
||||||
|
|
|
@ -25,6 +25,8 @@
|
||||||
#define SECURITY_PAGE_NUM 3
|
#define SECURITY_PAGE_NUM 3
|
||||||
#define CREATE_NET_PAGE_NUM 4
|
#define CREATE_NET_PAGE_NUM 4
|
||||||
#define PAGE_MIN_HEIGHT 40
|
#define PAGE_MIN_HEIGHT 40
|
||||||
|
#define LAN_TAB_WIDTH 300
|
||||||
|
#define WLAN_TAB_WIDTH 400
|
||||||
|
|
||||||
//extern void qt_blurImage(QImage &blurImage, qreal radius, bool quality, int transposed);
|
//extern void qt_blurImage(QImage &blurImage, qreal radius, bool quality, int transposed);
|
||||||
|
|
||||||
|
@ -162,6 +164,14 @@ void NetDetail::onPaletteChanged()
|
||||||
delete styleGsettings;
|
delete styleGsettings;
|
||||||
styleGsettings = nullptr;
|
styleGsettings = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QColor colorTabBar = pal.color(QPalette::Disabled, QPalette::Highlight);
|
||||||
|
m_netTabBar->setBackgroundColor(colorTabBar);
|
||||||
|
}
|
||||||
|
|
||||||
|
void NetDetail::currentRowChangeSlot(int row)
|
||||||
|
{
|
||||||
|
stackWidget->setCurrentIndex(row);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NetDetail::paintEvent(QPaintEvent *event)
|
void NetDetail::paintEvent(QPaintEvent *event)
|
||||||
|
@ -217,42 +227,29 @@ void NetDetail::initUI()
|
||||||
bottomWidget->setMinimumHeight(PAGE_MIN_HEIGHT);
|
bottomWidget->setMinimumHeight(PAGE_MIN_HEIGHT);
|
||||||
|
|
||||||
pageFrame = new QFrame(this);
|
pageFrame = new QFrame(this);
|
||||||
|
|
||||||
QHBoxLayout *pageLayout = new QHBoxLayout(pageFrame);
|
QHBoxLayout *pageLayout = new QHBoxLayout(pageFrame);
|
||||||
pageLayout->setSpacing(PAGE_LAYOUT_SPACING);
|
pageLayout->setSpacing(PAGE_LAYOUT_SPACING);
|
||||||
|
|
||||||
detailBtn = new QPushButton(this);
|
// TabBar
|
||||||
detailBtn->setText(tr("Detail"));
|
m_netTabBar = new KTabBar(KTabBarStyle::SegmentDark, this);
|
||||||
detailBtn->setCheckable(true);
|
m_netTabBar->addTab(tr("Detail")); //详情
|
||||||
detailBtn->setChecked(true);
|
m_netTabBar->addTab(tr("Ipv4"));//Ipv4
|
||||||
|
m_netTabBar->addTab(tr("Ipv6"));//Ipv6
|
||||||
ipv4Btn = new QPushButton(this);
|
|
||||||
ipv4Btn->setText(tr("Ipv4"));
|
|
||||||
ipv4Btn->setCheckable(true);
|
|
||||||
|
|
||||||
ipv6Btn = new QPushButton(this);
|
|
||||||
ipv6Btn->setText(tr("Ipv6"));
|
|
||||||
ipv6Btn->setCheckable(true);
|
|
||||||
|
|
||||||
securityBtn = new QPushButton(this);
|
|
||||||
securityBtn->setText(tr("Security"));
|
|
||||||
securityBtn->setCheckable(true);
|
|
||||||
|
|
||||||
m_group = new QButtonGroup(this);
|
|
||||||
m_group->addButton(detailBtn);
|
|
||||||
m_group->addButton(ipv4Btn);
|
|
||||||
m_group->addButton(ipv6Btn);
|
|
||||||
if (isWlan) {
|
if (isWlan) {
|
||||||
m_group->addButton(securityBtn);
|
m_netTabBar->addTab(tr("Security"));//安全
|
||||||
|
m_netTabBar->setFixedWidth(WLAN_TAB_WIDTH);
|
||||||
|
} else {
|
||||||
|
m_netTabBar->setFixedWidth(LAN_TAB_WIDTH);
|
||||||
}
|
}
|
||||||
|
|
||||||
pageLayout->addStretch();
|
pageLayout->addStretch();
|
||||||
pageLayout->addWidget(detailBtn);
|
pageLayout->addWidget(m_netTabBar);
|
||||||
pageLayout->addWidget(ipv4Btn);
|
|
||||||
pageLayout->addWidget(ipv6Btn);
|
|
||||||
pageLayout->addWidget(securityBtn);
|
|
||||||
pageLayout->addStretch();
|
pageLayout->addStretch();
|
||||||
|
|
||||||
|
// TabBar关联选项卡页面
|
||||||
|
connect(m_netTabBar, SIGNAL(currentChanged(int)), this, SLOT(currentRowChangeSlot(int)));
|
||||||
|
|
||||||
|
|
||||||
confimBtn = new QPushButton(this);
|
confimBtn = new QPushButton(this);
|
||||||
confimBtn->setText(tr("Confirm"));
|
confimBtn->setText(tr("Confirm"));
|
||||||
|
|
||||||
|
@ -281,7 +278,7 @@ void NetDetail::initUI()
|
||||||
// pal.setColor(QPalette::Background, qApp->palette().base().color());
|
// pal.setColor(QPalette::Background, qApp->palette().base().color());
|
||||||
this->setAutoFillBackground(true);
|
this->setAutoFillBackground(true);
|
||||||
// this->setPalette(pal);
|
// this->setPalette(pal);
|
||||||
onPaletteChanged();
|
onPaletteChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void NetDetail::loadPage()
|
void NetDetail::loadPage()
|
||||||
|
@ -294,13 +291,8 @@ void NetDetail::loadPage()
|
||||||
} else {
|
} else {
|
||||||
stackWidget->setCurrentIndex(DETAIL_PAGE_NUM);
|
stackWidget->setCurrentIndex(DETAIL_PAGE_NUM);
|
||||||
this->setWindowTitle(m_name);
|
this->setWindowTitle(m_name);
|
||||||
if (!isWlan) {
|
if (isWlan && m_name.isEmpty()) {
|
||||||
securityBtn->hide();
|
this->setWindowTitle(tr("connect hiddin wlan"));
|
||||||
} else {
|
|
||||||
securityBtn->show();
|
|
||||||
if (m_name.isEmpty()) {
|
|
||||||
this->setWindowTitle(tr("connect hiddin wlan"));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -310,18 +302,7 @@ void NetDetail::initComponent()
|
||||||
connect(cancelBtn, &QPushButton::clicked, this, [=] {
|
connect(cancelBtn, &QPushButton::clicked, this, [=] {
|
||||||
close();
|
close();
|
||||||
});
|
});
|
||||||
connect(detailBtn, &QPushButton::clicked, this, [=] {
|
|
||||||
stackWidget->setCurrentIndex(DETAIL_PAGE_NUM);
|
|
||||||
});
|
|
||||||
connect(ipv4Btn, &QPushButton::clicked, this, [=] {
|
|
||||||
stackWidget->setCurrentIndex(IPV4_PAGE_NUM);
|
|
||||||
});
|
|
||||||
connect(ipv6Btn, &QPushButton::clicked, this, [=] {
|
|
||||||
stackWidget->setCurrentIndex(IPV6_PAGE_NUM);
|
|
||||||
});
|
|
||||||
connect(securityBtn, &QPushButton::clicked, this, [=] {
|
|
||||||
stackWidget->setCurrentIndex(SECURITY_PAGE_NUM);
|
|
||||||
});
|
|
||||||
connect(confimBtn, SIGNAL(clicked()), this, SLOT(on_btnConfirm_clicked()));
|
connect(confimBtn, SIGNAL(clicked()), this, SLOT(on_btnConfirm_clicked()));
|
||||||
if (isWlan && !m_uuid.isEmpty()) {
|
if (isWlan && !m_uuid.isEmpty()) {
|
||||||
forgetBtn->show();
|
forgetBtn->show();
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QButtonGroup>
|
|
||||||
|
|
||||||
#include <QDBusMessage>
|
#include <QDBusMessage>
|
||||||
#include <QDBusObjectPath>
|
#include <QDBusObjectPath>
|
||||||
|
@ -28,6 +27,10 @@
|
||||||
#include "creatnetpage.h"
|
#include "creatnetpage.h"
|
||||||
#include "coninfo.h"
|
#include "coninfo.h"
|
||||||
#include "tab-pages/tabpage.h"
|
#include "tab-pages/tabpage.h"
|
||||||
|
#include "kwidget.h"
|
||||||
|
#include "ktabbar.h"
|
||||||
|
|
||||||
|
using namespace kdk;
|
||||||
|
|
||||||
class NetDetail : public QWidget
|
class NetDetail : public QWidget
|
||||||
{
|
{
|
||||||
|
@ -100,11 +103,8 @@ private:
|
||||||
QPushButton * forgetBtn;
|
QPushButton * forgetBtn;
|
||||||
QPushButton * confimBtn;
|
QPushButton * confimBtn;
|
||||||
|
|
||||||
QPushButton * detailBtn;
|
|
||||||
QPushButton * ipv4Btn;
|
|
||||||
QPushButton * ipv6Btn;
|
|
||||||
QPushButton * securityBtn;
|
|
||||||
QFrame * pageFrame;
|
QFrame * pageFrame;
|
||||||
|
KTabBar *m_netTabBar = nullptr;
|
||||||
|
|
||||||
QString m_name;
|
QString m_name;
|
||||||
QString m_uuid;
|
QString m_uuid;
|
||||||
|
@ -124,16 +124,18 @@ private:
|
||||||
|
|
||||||
ConInfo m_info;
|
ConInfo m_info;
|
||||||
|
|
||||||
QButtonGroup *m_group;
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void on_btnConfirm_clicked();
|
void on_btnConfirm_clicked();
|
||||||
void on_btnForget_clicked();
|
void on_btnForget_clicked();
|
||||||
void onPaletteChanged();
|
void onPaletteChanged();
|
||||||
|
|
||||||
|
protected slots:
|
||||||
|
void currentRowChangeSlot(int row);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void detailPageClose(bool on);
|
void detailPageClose(bool on);
|
||||||
void createPageClose(QString);
|
void createPageClose(QString);
|
||||||
|
void currentChanged(int);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@ void SecurityPage::initUI()
|
||||||
userPwdFlagLabel = new QLabel(this);
|
userPwdFlagLabel = new QLabel(this);
|
||||||
|
|
||||||
secuTypeCombox = new QComboBox(this);
|
secuTypeCombox = new QComboBox(this);
|
||||||
pwdEdit = new LineEdit(this);
|
pwdEdit = new KPasswordEdit(this);
|
||||||
eapTypeCombox = new QComboBox(this);
|
eapTypeCombox = new QComboBox(this);
|
||||||
//TLS
|
//TLS
|
||||||
identityEdit = new LineEdit(this);
|
identityEdit = new LineEdit(this);
|
||||||
|
@ -42,12 +42,12 @@ void SecurityPage::initUI()
|
||||||
caNeedBox = new QCheckBox(this);
|
caNeedBox = new QCheckBox(this);
|
||||||
clientCertPathCombox = new QComboBox(this);
|
clientCertPathCombox = new QComboBox(this);
|
||||||
clientPrivateKeyCombox = new QComboBox(this);
|
clientPrivateKeyCombox = new QComboBox(this);
|
||||||
clientPrivateKeyPwdEdit = new LineEdit(this);
|
clientPrivateKeyPwdEdit = new KPasswordEdit(this);
|
||||||
|
|
||||||
//PEAP && TTLS
|
//PEAP && TTLS
|
||||||
eapMethodCombox = new QComboBox(this);
|
eapMethodCombox = new QComboBox(this);
|
||||||
userNameEdit = new LineEdit(this);
|
userNameEdit = new LineEdit(this);
|
||||||
userPwdEdit = new LineEdit(this);
|
userPwdEdit = new KPasswordEdit(this);
|
||||||
userPwdFlagBox = new QCheckBox(this);
|
userPwdFlagBox = new QCheckBox(this);
|
||||||
|
|
||||||
|
|
||||||
|
@ -106,59 +106,10 @@ void SecurityPage::initUI()
|
||||||
clientPrivateKeyCombox->addItem(tr("None"), QString(tr("None"))); //无
|
clientPrivateKeyCombox->addItem(tr("None"), QString(tr("None"))); //无
|
||||||
clientPrivateKeyCombox->addItem(tr("Choose from file..."), QString(tr("Choose from file..."))); //从文件中选择...
|
clientPrivateKeyCombox->addItem(tr("Choose from file..."), QString(tr("Choose from file..."))); //从文件中选择...
|
||||||
|
|
||||||
pwdBox = new QCheckBox(this);
|
//禁用ClearBtn按钮
|
||||||
pwdBox->setStyleSheet("QCheckBox::indicator {width: 18px; height: 9px;}"
|
pwdEdit->setClearButtonEnabled(false);
|
||||||
"QCheckBox::indicator:checked {image: url(:/res/h/show-pwd.png);}"
|
clientPrivateKeyPwdEdit->setClearButtonEnabled(false);
|
||||||
"QCheckBox::indicator:unchecked {image: url(:/res/h/hide-pwd.png);}");
|
userPwdEdit->setClearButtonEnabled(false);
|
||||||
pwdBox->setCursor(Qt::PointingHandCursor);
|
|
||||||
pwdBox->setFixedSize(30, pwdEdit->height());
|
|
||||||
//防止文本框输入内容位于按钮之下
|
|
||||||
QMargins margins = pwdEdit->textMargins();
|
|
||||||
pwdEdit->setTextMargins(margins.left(), margins.top(), pwdBox->width(), margins.bottom());
|
|
||||||
QHBoxLayout *pPwdLayout = new QHBoxLayout();
|
|
||||||
pPwdLayout->addStretch();
|
|
||||||
pPwdLayout->addWidget(pwdBox);
|
|
||||||
pPwdLayout->setSpacing(0);
|
|
||||||
pPwdLayout->setContentsMargins(0, 0, 0, 0);
|
|
||||||
pwdEdit->setLayout(pPwdLayout);
|
|
||||||
pwdEdit->setEchoMode(QLineEdit::Password);
|
|
||||||
|
|
||||||
userPwdBox = new QCheckBox(this);
|
|
||||||
userPwdBox->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);}");
|
|
||||||
userPwdBox->setCursor(Qt::PointingHandCursor);
|
|
||||||
userPwdBox->setFixedSize(30, userPwdEdit->height());
|
|
||||||
userPwdBox->setFocusPolicy(Qt::NoFocus);
|
|
||||||
//防止文本框输入内容位于按钮之下
|
|
||||||
userPwdEdit->setTextMargins(margins.left(), margins.top(), userPwdBox->width(), margins.bottom());
|
|
||||||
QHBoxLayout *puserPwdLayout = new QHBoxLayout();
|
|
||||||
puserPwdLayout->addStretch();
|
|
||||||
puserPwdLayout->addWidget(userPwdBox);
|
|
||||||
puserPwdLayout->setSpacing(0);
|
|
||||||
puserPwdLayout->setContentsMargins(0, 0, 0, 0);
|
|
||||||
userPwdEdit->setLayout(puserPwdLayout);
|
|
||||||
userPwdEdit->setEchoMode(QLineEdit::Password);
|
|
||||||
|
|
||||||
privateKeyBox = new QCheckBox(this);
|
|
||||||
privateKeyBox->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);}");
|
|
||||||
privateKeyBox->setCursor(Qt::PointingHandCursor);
|
|
||||||
privateKeyBox->setFixedSize(30, clientPrivateKeyPwdEdit->height());
|
|
||||||
//防止文本框输入内容位于按钮之下
|
|
||||||
clientPrivateKeyPwdEdit->setTextMargins(margins.left(), margins.top(), privateKeyBox->width(), margins.bottom());
|
|
||||||
QHBoxLayout *pPrivateKeyPwdLayout = new QHBoxLayout();
|
|
||||||
pPrivateKeyPwdLayout->addStretch();
|
|
||||||
pPrivateKeyPwdLayout->addWidget(privateKeyBox);
|
|
||||||
pPrivateKeyPwdLayout->setSpacing(0);
|
|
||||||
pPrivateKeyPwdLayout->setContentsMargins(0, 0, 0, 0);
|
|
||||||
clientPrivateKeyPwdEdit->setLayout(pPrivateKeyPwdLayout);
|
|
||||||
clientPrivateKeyPwdEdit->setEchoMode(QLineEdit::Password);
|
|
||||||
|
|
||||||
pwdEdit->setContextMenuPolicy(Qt::NoContextMenu);
|
|
||||||
clientPrivateKeyPwdEdit->setContextMenuPolicy(Qt::NoContextMenu);
|
|
||||||
userPwdEdit->setContextMenuPolicy(Qt::NoContextMenu);
|
|
||||||
|
|
||||||
QRegExp rx("^[A-Za-z0-9`~!@#$%^&*()_-+=<>,.\\\/]+$");
|
QRegExp rx("^[A-Za-z0-9`~!@#$%^&*()_-+=<>,.\\\/]+$");
|
||||||
QRegExpValidator *latitude = new QRegExpValidator(rx, this);
|
QRegExpValidator *latitude = new QRegExpValidator(rx, this);
|
||||||
|
@ -180,10 +131,6 @@ void SecurityPage::initConnect()
|
||||||
|
|
||||||
connect(caNeedBox, &QCheckBox::clicked, this, &SecurityPage::onCaNeedBoxClicked);
|
connect(caNeedBox, &QCheckBox::clicked, this, &SecurityPage::onCaNeedBoxClicked);
|
||||||
|
|
||||||
connect(pwdBox, &QCheckBox::clicked, this, &SecurityPage::onPwdBoxClicked);
|
|
||||||
connect(userPwdBox, &QCheckBox::clicked, this, &SecurityPage::onUserPwdBox);
|
|
||||||
connect(privateKeyBox, &QCheckBox::clicked, this, &SecurityPage::onPrivateKeyBoxClicked);
|
|
||||||
|
|
||||||
connect(caCertPathCombox, static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged),
|
connect(caCertPathCombox, static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged),
|
||||||
this, &SecurityPage::onCaCertPathComboxIndexChanged);
|
this, &SecurityPage::onCaCertPathComboxIndexChanged);
|
||||||
|
|
||||||
|
@ -731,40 +678,6 @@ void SecurityPage::onCaNeedBoxClicked()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SecurityPage::onPwdBoxClicked()
|
|
||||||
{
|
|
||||||
if (pwdEdit->echoMode() == QLineEdit::Password) {
|
|
||||||
pwdBox->setChecked(true);
|
|
||||||
pwdEdit->setEchoMode(QLineEdit::Normal);
|
|
||||||
} else {
|
|
||||||
pwdBox->setChecked(false);
|
|
||||||
pwdEdit->setEchoMode(QLineEdit::Password);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void SecurityPage::onUserPwdBox()
|
|
||||||
{
|
|
||||||
if (userPwdEdit->echoMode() == QLineEdit::Password) {
|
|
||||||
userPwdBox->setChecked(true);
|
|
||||||
userPwdEdit->setEchoMode(QLineEdit::Normal);
|
|
||||||
} else {
|
|
||||||
userPwdBox->setChecked(false);
|
|
||||||
userPwdEdit->setEchoMode(QLineEdit::Password);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void SecurityPage::onPrivateKeyBoxClicked()
|
|
||||||
{
|
|
||||||
if (clientPrivateKeyPwdEdit->echoMode() == QLineEdit::Password) {
|
|
||||||
privateKeyBox->setChecked(true);
|
|
||||||
clientPrivateKeyPwdEdit->setEchoMode(QLineEdit::Normal);
|
|
||||||
} else {
|
|
||||||
privateKeyBox->setChecked(false);
|
|
||||||
clientPrivateKeyPwdEdit->setEchoMode(QLineEdit::Password);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void SecurityPage::onCaCertPathComboxIndexChanged(QString str)
|
void SecurityPage::onCaCertPathComboxIndexChanged(QString str)
|
||||||
{
|
{
|
||||||
if (str.contains("Choose from file...") || str.contains("从文件选择..."))
|
if (str.contains("Choose from file...") || str.contains("从文件选择..."))
|
||||||
|
|
|
@ -9,6 +9,10 @@
|
||||||
#include <QCheckBox>
|
#include <QCheckBox>
|
||||||
|
|
||||||
#include "coninfo.h"
|
#include "coninfo.h"
|
||||||
|
#include "kwidget.h"
|
||||||
|
#include "kpasswordedit.h"
|
||||||
|
|
||||||
|
using namespace kdk;
|
||||||
|
|
||||||
class SecurityPage : public QFrame
|
class SecurityPage : public QFrame
|
||||||
{
|
{
|
||||||
|
@ -56,7 +60,7 @@ private:
|
||||||
QLabel *userPwdFlagLabel;
|
QLabel *userPwdFlagLabel;
|
||||||
|
|
||||||
QComboBox *secuTypeCombox;
|
QComboBox *secuTypeCombox;
|
||||||
LineEdit *pwdEdit;
|
KPasswordEdit *pwdEdit = nullptr;
|
||||||
QComboBox *eapTypeCombox;
|
QComboBox *eapTypeCombox;
|
||||||
//TLS
|
//TLS
|
||||||
LineEdit *identityEdit;
|
LineEdit *identityEdit;
|
||||||
|
@ -65,18 +69,14 @@ private:
|
||||||
QCheckBox *caNeedBox;
|
QCheckBox *caNeedBox;
|
||||||
QComboBox *clientCertPathCombox;
|
QComboBox *clientCertPathCombox;
|
||||||
QComboBox *clientPrivateKeyCombox;
|
QComboBox *clientPrivateKeyCombox;
|
||||||
LineEdit *clientPrivateKeyPwdEdit;
|
KPasswordEdit *clientPrivateKeyPwdEdit = nullptr;
|
||||||
|
|
||||||
//PEAP && TTLS
|
//PEAP && TTLS
|
||||||
QComboBox *eapMethodCombox;
|
QComboBox *eapMethodCombox;
|
||||||
LineEdit *userNameEdit;
|
LineEdit *userNameEdit;
|
||||||
LineEdit *userPwdEdit;
|
KPasswordEdit *userPwdEdit = nullptr;
|
||||||
QCheckBox *userPwdFlagBox;
|
QCheckBox *userPwdFlagBox;
|
||||||
|
|
||||||
QCheckBox *pwdBox;
|
|
||||||
QCheckBox *userPwdBox;
|
|
||||||
QCheckBox *privateKeyBox;
|
|
||||||
|
|
||||||
void showNone();
|
void showNone();
|
||||||
void showPsk();
|
void showPsk();
|
||||||
void showTls();
|
void showTls();
|
||||||
|
@ -97,9 +97,6 @@ private slots:
|
||||||
void setEnableOfSaveBtn();
|
void setEnableOfSaveBtn();
|
||||||
|
|
||||||
void onCaNeedBoxClicked();
|
void onCaNeedBoxClicked();
|
||||||
void onPwdBoxClicked();
|
|
||||||
void onUserPwdBox();
|
|
||||||
void onPrivateKeyBoxClicked();
|
|
||||||
|
|
||||||
void onCaCertPathComboxIndexChanged(QString str);
|
void onCaCertPathComboxIndexChanged(QString str);
|
||||||
void onClientCertPathComboxIndexChanged(QString str);
|
void onClientCertPathComboxIndexChanged(QString str);
|
||||||
|
|
|
@ -120,7 +120,7 @@ void LanPage::initLanDeviceState()
|
||||||
}
|
}
|
||||||
|
|
||||||
KyWiredConnectOperation wiredOperation;
|
KyWiredConnectOperation wiredOperation;
|
||||||
if (m_wiredSwitch) {
|
if (m_netSwitch->isChecked()) {
|
||||||
for (int index = 0; index < disableDeviceList.count(); ++index) {
|
for (int index = 0; index < disableDeviceList.count(); ++index) {
|
||||||
wiredOperation.closeWiredNetworkWithDevice(disableDeviceList.at(index));
|
wiredOperation.closeWiredNetworkWithDevice(disableDeviceList.at(index));
|
||||||
}
|
}
|
||||||
|
@ -135,12 +135,12 @@ void LanPage::initLanDeviceState()
|
||||||
|
|
||||||
void LanPage::initNetSwitch()
|
void LanPage::initNetSwitch()
|
||||||
{
|
{
|
||||||
m_wiredSwitch = true;
|
bool wiredSwitch = true;
|
||||||
|
|
||||||
if (QGSettings::isSchemaInstalled(GSETTINGS_SCHEMA)) {
|
if (QGSettings::isSchemaInstalled(GSETTINGS_SCHEMA)) {
|
||||||
m_switchGsettings = new QGSettings(GSETTINGS_SCHEMA);
|
m_switchGsettings = new QGSettings(GSETTINGS_SCHEMA);
|
||||||
if (m_switchGsettings->keys().contains(WIRED_SWITCH)) {
|
if (m_switchGsettings->keys().contains(WIRED_SWITCH)) {
|
||||||
m_wiredSwitch = m_switchGsettings->get(WIRED_SWITCH).toBool();
|
wiredSwitch = m_switchGsettings->get(WIRED_SWITCH).toBool();
|
||||||
connect(m_switchGsettings, &QGSettings::changed, this, &LanPage::onSwithGsettingsChanged);
|
connect(m_switchGsettings, &QGSettings::changed, this, &LanPage::onSwithGsettingsChanged);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -149,16 +149,13 @@ void LanPage::initNetSwitch()
|
||||||
|
|
||||||
if (m_devList.count() == 0) {
|
if (m_devList.count() == 0) {
|
||||||
qDebug() << "[wiredSwitch]:init not enable when no device";
|
qDebug() << "[wiredSwitch]:init not enable when no device";
|
||||||
m_wiredSwitch = false;
|
m_netSwitch->setChecked(false);
|
||||||
m_netSwitch->setSwitchStatus(m_wiredSwitch);
|
m_netSwitch->setCheckable(false);
|
||||||
m_netSwitch->setEnabled(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
qDebug() << "[wiredSwitch]:init state:" << m_wiredSwitch;
|
qDebug() << "[wiredSwitch]:init state:" << wiredSwitch;
|
||||||
|
|
||||||
m_netSwitch->setSwitchStatus(m_wiredSwitch);
|
m_netSwitch->setChecked(wiredSwitch);
|
||||||
|
|
||||||
connect(m_netSwitch, &SwitchButton::clicked, this, &LanPage::onLanSwitchClicked);
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -166,13 +163,16 @@ void LanPage::initNetSwitch()
|
||||||
void LanPage::onSwithGsettingsChanged(const QString &key)
|
void LanPage::onSwithGsettingsChanged(const QString &key)
|
||||||
{
|
{
|
||||||
if (key == WIRED_SWITCH) {
|
if (key == WIRED_SWITCH) {
|
||||||
m_netSwitch->blockSignals(true);
|
|
||||||
|
|
||||||
m_wiredSwitch = m_switchGsettings->get(WIRED_SWITCH).toBool();
|
bool wiredSwitch = m_switchGsettings->get(WIRED_SWITCH).toBool();
|
||||||
qDebug()<<"[LanPage] SwitchButton statue changed to:" << m_wiredSwitch;
|
qDebug()<<"[LanPage] SwitchButton statue changed to:" << wiredSwitch << m_netSwitch->isChecked();
|
||||||
|
|
||||||
|
if (wiredSwitch == m_netSwitch->isChecked()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
KyWiredConnectOperation wiredOperation;
|
KyWiredConnectOperation wiredOperation;
|
||||||
if (m_wiredSwitch) {
|
if (wiredSwitch) {
|
||||||
for (int index = 0; index < m_enableDeviceList.size(); ++index) {
|
for (int index = 0; index < m_enableDeviceList.size(); ++index) {
|
||||||
qDebug()<<"[LanPage] open wired device "<< m_enableDeviceList.at(index);
|
qDebug()<<"[LanPage] open wired device "<< m_enableDeviceList.at(index);
|
||||||
wiredOperation.openWiredNetworkWithDevice(m_enableDeviceList.at(index));
|
wiredOperation.openWiredNetworkWithDevice(m_enableDeviceList.at(index));
|
||||||
|
@ -184,30 +184,10 @@ void LanPage::onSwithGsettingsChanged(const QString &key)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_netSwitch->setChecked(wiredSwitch);
|
||||||
|
|
||||||
initDeviceCombox();
|
initDeviceCombox();
|
||||||
initLanArea();
|
initLanArea();
|
||||||
|
|
||||||
m_netSwitch->setSwitchStatus(m_wiredSwitch);
|
|
||||||
|
|
||||||
m_netSwitch->blockSignals(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void LanPage::onLanSwitchClicked()
|
|
||||||
{
|
|
||||||
qDebug()<<"[LanPage] On lan switch button clicked! Status:" <<m_netSwitch->getSwitchStatus()
|
|
||||||
<<"devices count:"<<m_devList.count();
|
|
||||||
|
|
||||||
if (m_devList.count() == 0) {
|
|
||||||
this->showDesktopNotify(tr("No ethernet device avaliable"), "networkwrong");
|
|
||||||
} else {
|
|
||||||
if (m_netSwitch->getSwitchStatus()) {
|
|
||||||
//qDebug() << "[wiredSwitch]set true after clicked";
|
|
||||||
m_switchGsettings->set(WIRED_SWITCH, true);
|
|
||||||
} else {
|
|
||||||
//qDebug() << "[wiredSwitch]set false after clicked";
|
|
||||||
m_switchGsettings->set(WIRED_SWITCH,false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -266,7 +246,7 @@ void LanPage::initDeviceCombox()
|
||||||
|
|
||||||
m_deviceComboBox->clear();
|
m_deviceComboBox->clear();
|
||||||
|
|
||||||
if (m_wiredSwitch) {
|
if (m_netSwitch->isChecked()) {
|
||||||
int enableDeviceCount = m_enableDeviceList.count();
|
int enableDeviceCount = m_enableDeviceList.count();
|
||||||
if (enableDeviceCount > 1) {
|
if (enableDeviceCount > 1) {
|
||||||
for (int index = 0; index < enableDeviceCount; ++index) {
|
for (int index = 0; index < enableDeviceCount; ++index) {
|
||||||
|
@ -426,7 +406,7 @@ void LanPage::constructConnectionArea()
|
||||||
|
|
||||||
void LanPage::initLanArea()
|
void LanPage::initLanArea()
|
||||||
{
|
{
|
||||||
if (!m_wiredSwitch || m_currentDeviceName.isEmpty()) {
|
if (!m_netSwitch->isChecked() || m_currentDeviceName.isEmpty()) {
|
||||||
m_activatedNetDivider->hide();
|
m_activatedNetDivider->hide();
|
||||||
m_activatedNetFrame->hide();
|
m_activatedNetFrame->hide();
|
||||||
|
|
||||||
|
@ -526,7 +506,7 @@ void LanPage::addDeviceForCombox(QString deviceName)
|
||||||
disconnect(m_deviceComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged),
|
disconnect(m_deviceComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged),
|
||||||
this, &LanPage::onDeviceComboxIndexChanged);
|
this, &LanPage::onDeviceComboxIndexChanged);
|
||||||
|
|
||||||
if (m_wiredSwitch) {
|
if (m_netSwitch->isChecked()) {
|
||||||
if (1 == m_enableDeviceList.count()) {
|
if (1 == m_enableDeviceList.count()) {
|
||||||
//1、从无到有添加第一块有线网卡
|
//1、从无到有添加第一块有线网卡
|
||||||
//2、有多快网卡,但是没有使能
|
//2、有多快网卡,但是没有使能
|
||||||
|
@ -564,9 +544,9 @@ void LanPage::onDeviceAdd(QString deviceName, NetworkManager::Device::Type devic
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_devList.count() == 0) {// 有线网卡从无到有,打开开关
|
if (m_devList.count() == 0) {// 有线网卡从无到有,打开开关
|
||||||
m_netSwitch->setEnabled(true);
|
bool wiredSwitch = m_switchGsettings->get(WIRED_SWITCH).toBool();
|
||||||
m_wiredSwitch = m_switchGsettings->get(WIRED_SWITCH).toBool();
|
m_netSwitch->setCheckable(true);
|
||||||
m_netSwitch->setSwitchStatus(m_wiredSwitch);
|
m_netSwitch->setChecked(wiredSwitch);
|
||||||
}
|
}
|
||||||
|
|
||||||
qDebug() << "[LanPage] Begin add device:" << deviceName;
|
qDebug() << "[LanPage] Begin add device:" << deviceName;
|
||||||
|
@ -590,7 +570,7 @@ void LanPage::deleteDeviceFromCombox(QString deviceName)
|
||||||
disconnect(m_deviceComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged),
|
disconnect(m_deviceComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged),
|
||||||
this, &LanPage::onDeviceComboxIndexChanged);
|
this, &LanPage::onDeviceComboxIndexChanged);
|
||||||
|
|
||||||
if (m_wiredSwitch) {
|
if (m_netSwitch->isChecked()) {
|
||||||
if (0 == m_enableDeviceList.count()) {
|
if (0 == m_enableDeviceList.count()) {
|
||||||
//1、没有使能任何网卡
|
//1、没有使能任何网卡
|
||||||
goto l_out;
|
goto l_out;
|
||||||
|
@ -649,9 +629,8 @@ void LanPage::onDeviceRemove(QString deviceName)
|
||||||
|
|
||||||
m_devList.removeOne(deviceName);
|
m_devList.removeOne(deviceName);
|
||||||
if (m_devList.count() == 0) {
|
if (m_devList.count() == 0) {
|
||||||
m_wiredSwitch = false;
|
m_netSwitch->setCheckable(false);
|
||||||
m_netSwitch->setSwitchStatus(m_wiredSwitch);
|
m_netSwitch->setChecked(false);
|
||||||
m_netSwitch->setEnabled(false);
|
|
||||||
qDebug() << "[wiredSwitch]set not enable after device remove";
|
qDebug() << "[wiredSwitch]set not enable after device remove";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -727,7 +706,7 @@ void LanPage::onDeviceActiveChanage(QString deviceName, bool deviceActive)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (deviceActive) {
|
if (deviceActive) {
|
||||||
if (!m_wiredSwitch || !m_enableDeviceList.contains(deviceName)) {
|
if (!m_netSwitch->isChecked() || !m_enableDeviceList.contains(deviceName)) {
|
||||||
qDebug()<< LOG_FLAG << "close disabled device";
|
qDebug()<< LOG_FLAG << "close disabled device";
|
||||||
m_wiredConnectOperation->closeWiredNetworkWithDevice(deviceName);
|
m_wiredConnectOperation->closeWiredNetworkWithDevice(deviceName);
|
||||||
}
|
}
|
||||||
|
@ -780,7 +759,8 @@ void LanPage::initUI()
|
||||||
m_activatedLanListWidget->setPalette(pal);
|
m_activatedLanListWidget->setPalette(pal);
|
||||||
m_inactivatedLanListWidget->setPalette(pal);
|
m_inactivatedLanListWidget->setPalette(pal);
|
||||||
|
|
||||||
m_settingsLabel->installEventFilter(this);
|
m_settingsBtn->installEventFilter(this);
|
||||||
|
m_netSwitch->installEventFilter(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
QListWidgetItem *LanPage::insertNewItem(KyConnectItem *itemData, QListWidget *listWidget)
|
QListWidgetItem *LanPage::insertNewItem(KyConnectItem *itemData, QListWidget *listWidget)
|
||||||
|
@ -1192,10 +1172,30 @@ void LanPage::setWiredDeviceEnable(const QString& devName, bool enable)
|
||||||
|
|
||||||
bool LanPage::eventFilter(QObject *watched, QEvent *event)
|
bool LanPage::eventFilter(QObject *watched, QEvent *event)
|
||||||
{
|
{
|
||||||
if (watched == m_settingsLabel) {
|
if (watched == m_settingsBtn) {
|
||||||
if (event->type() == QEvent::MouseButtonRelease) {
|
if (event->type() == QEvent::MouseButtonRelease) {
|
||||||
onShowControlCenter();
|
onShowControlCenter();
|
||||||
}
|
}
|
||||||
|
} else if(watched == m_netSwitch){
|
||||||
|
if (event->type() == QEvent::MouseButtonRelease) {
|
||||||
|
qDebug()<<"[LanPage] On lan switch button clicked! Status:" <<m_netSwitch->isChecked()
|
||||||
|
<<"devices count:"<<m_devList.count();
|
||||||
|
|
||||||
|
if (m_devList.count() == 0) {
|
||||||
|
this->showDesktopNotify(tr("No ethernet device avaliable"), "networkwrong");
|
||||||
|
m_netSwitch->setCheckable(false);
|
||||||
|
m_netSwitch->setChecked(false);
|
||||||
|
} else {
|
||||||
|
m_netSwitch->setCheckable(true);
|
||||||
|
if (m_netSwitch->isChecked()) {
|
||||||
|
m_switchGsettings->set(WIRED_SWITCH, false);
|
||||||
|
} else {
|
||||||
|
m_switchGsettings->set(WIRED_SWITCH,true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return QWidget::eventFilter(watched, event);
|
return QWidget::eventFilter(watched, event);
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
#define LANPAGE_H
|
#define LANPAGE_H
|
||||||
|
|
||||||
#include "divider.h"
|
#include "divider.h"
|
||||||
#include "switchbutton.h"
|
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
|
@ -98,7 +97,6 @@ private slots:
|
||||||
void onUpdateConnection(QString uuid);
|
void onUpdateConnection(QString uuid);
|
||||||
|
|
||||||
void onSwithGsettingsChanged(const QString &key);
|
void onSwithGsettingsChanged(const QString &key);
|
||||||
void onLanSwitchClicked();
|
|
||||||
|
|
||||||
void onDeviceAdd(QString deviceName, NetworkManager::Device::Type deviceType);
|
void onDeviceAdd(QString deviceName, NetworkManager::Device::Type deviceType);
|
||||||
void onDeviceRemove(QString deviceName);
|
void onDeviceRemove(QString deviceName);
|
||||||
|
@ -129,7 +127,6 @@ private:
|
||||||
|
|
||||||
QGSettings *m_switchGsettings = nullptr;
|
QGSettings *m_switchGsettings = nullptr;
|
||||||
|
|
||||||
bool m_wiredSwitch = true;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // LANPAGE_H
|
#endif // LANPAGE_H
|
||||||
|
|
|
@ -29,7 +29,7 @@ void TabPage::initUI()
|
||||||
m_titleLayout = new QHBoxLayout(m_titleFrame);
|
m_titleLayout = new QHBoxLayout(m_titleFrame);
|
||||||
m_titleLayout->setContentsMargins(TITLE_LAYOUT_MARGINS);
|
m_titleLayout->setContentsMargins(TITLE_LAYOUT_MARGINS);
|
||||||
m_titleLabel = new QLabel(m_titleFrame);
|
m_titleLabel = new QLabel(m_titleFrame);
|
||||||
m_netSwitch = new SwitchButton(m_titleFrame);
|
m_netSwitch = new KSwitchButton(m_titleFrame);
|
||||||
m_titleLayout->addWidget(m_titleLabel);
|
m_titleLayout->addWidget(m_titleLabel);
|
||||||
m_titleLayout->addStretch();
|
m_titleLayout->addStretch();
|
||||||
m_titleLayout->addWidget(m_netSwitch);
|
m_titleLayout->addWidget(m_netSwitch);
|
||||||
|
@ -94,12 +94,11 @@ void TabPage::initUI()
|
||||||
|
|
||||||
m_settingsLayout = new QHBoxLayout(m_settingsFrame);
|
m_settingsLayout = new QHBoxLayout(m_settingsFrame);
|
||||||
m_settingsLayout->setContentsMargins(SETTINGS_LAYOUT_MARGINS);
|
m_settingsLayout->setContentsMargins(SETTINGS_LAYOUT_MARGINS);
|
||||||
m_settingsLabel = new KyLable(m_settingsFrame);
|
|
||||||
m_settingsLabel->setCursor(Qt::PointingHandCursor);
|
|
||||||
m_settingsLabel->setText(tr("Settings"));
|
|
||||||
m_settingsLabel->setScaledContents(true);
|
|
||||||
|
|
||||||
m_settingsLayout->addWidget(m_settingsLabel);
|
m_settingsBtn = new KBorderlessButton(m_settingsFrame);
|
||||||
|
m_settingsBtn->setText(tr("Settings"));
|
||||||
|
|
||||||
|
m_settingsLayout->addWidget(m_settingsBtn);
|
||||||
m_settingsLayout->addStretch();
|
m_settingsLayout->addStretch();
|
||||||
m_settingsFrame->setLayout(m_settingsLayout);
|
m_settingsFrame->setLayout(m_settingsLayout);
|
||||||
|
|
||||||
|
|
|
@ -2,8 +2,6 @@
|
||||||
#define TABPAGE_H
|
#define TABPAGE_H
|
||||||
|
|
||||||
#include "divider.h"
|
#include "divider.h"
|
||||||
#include "switchbutton.h"
|
|
||||||
#include "kylable.h"
|
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
|
@ -15,6 +13,11 @@
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include "kylinnetworkdeviceresource.h"
|
#include "kylinnetworkdeviceresource.h"
|
||||||
|
#include "kwidget.h"
|
||||||
|
#include "kswitchbutton.h"
|
||||||
|
#include "kborderlessbutton.h"
|
||||||
|
|
||||||
|
using namespace kdk;
|
||||||
|
|
||||||
#define MAIN_LAYOUT_MARGINS 0,0,0,0
|
#define MAIN_LAYOUT_MARGINS 0,0,0,0
|
||||||
#define MAIN_LAYOUT_SPACING 0
|
#define MAIN_LAYOUT_SPACING 0
|
||||||
|
@ -93,7 +96,7 @@ protected:
|
||||||
QFrame * m_titleFrame = nullptr;
|
QFrame * m_titleFrame = nullptr;
|
||||||
QHBoxLayout * m_titleLayout = nullptr;
|
QHBoxLayout * m_titleLayout = nullptr;
|
||||||
QLabel * m_titleLabel = nullptr;
|
QLabel * m_titleLabel = nullptr;
|
||||||
SwitchButton * m_netSwitch = nullptr;
|
KSwitchButton * m_netSwitch = nullptr;
|
||||||
Divider * m_titleDivider = nullptr;
|
Divider * m_titleDivider = nullptr;
|
||||||
|
|
||||||
QFrame * m_activatedNetFrame = nullptr;
|
QFrame * m_activatedNetFrame = nullptr;
|
||||||
|
@ -111,7 +114,7 @@ protected:
|
||||||
|
|
||||||
QFrame * m_settingsFrame = nullptr;
|
QFrame * m_settingsFrame = nullptr;
|
||||||
QHBoxLayout * m_settingsLayout = nullptr;
|
QHBoxLayout * m_settingsLayout = nullptr;
|
||||||
KyLable * m_settingsLabel = nullptr;
|
KBorderlessButton *m_settingsBtn = nullptr;
|
||||||
|
|
||||||
//临时增加的下拉框选择网卡区域
|
//临时增加的下拉框选择网卡区域
|
||||||
QFrame * m_deviceFrame = nullptr;
|
QFrame * m_deviceFrame = nullptr;
|
||||||
|
@ -120,8 +123,6 @@ protected:
|
||||||
QComboBox * m_deviceComboBox = nullptr;
|
QComboBox * m_deviceComboBox = nullptr;
|
||||||
QLabel * m_tipsLabel = nullptr;
|
QLabel * m_tipsLabel = nullptr;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
virtual void onDeviceComboxIndexChanged(int currentIndex) = 0;
|
virtual void onDeviceComboxIndexChanged(int currentIndex) = 0;
|
||||||
void onPaletteChanged();
|
void onPaletteChanged();
|
||||||
|
|
|
@ -59,10 +59,20 @@ WlanPage::WlanPage(QWidget *parent) : TabPage(parent)
|
||||||
bool WlanPage::eventFilter(QObject *w, QEvent *e)
|
bool WlanPage::eventFilter(QObject *w, QEvent *e)
|
||||||
{
|
{
|
||||||
if (e->type() == QEvent::MouseButtonRelease) {
|
if (e->type() == QEvent::MouseButtonRelease) {
|
||||||
if (w == m_settingsLabel) {
|
if (w == m_settingsBtn) {
|
||||||
//ZJP_TODO 打开控制面板
|
//ZJP_TODO 打开控制面板
|
||||||
qDebug() << LOG_FLAG <<"recive event show control center";
|
qDebug() << LOG_FLAG <<"recive event show control center";
|
||||||
showControlCenter();
|
showControlCenter();
|
||||||
|
} else if (w == m_netSwitch) {
|
||||||
|
if (m_devList.isEmpty()) {
|
||||||
|
showDesktopNotify(tr("No wireless network card detected"), "networkwrong");
|
||||||
|
//检测不到无线网卡不再触发click信号
|
||||||
|
m_netSwitch->setCheckable(false);
|
||||||
|
m_netSwitch->setChecked(false);
|
||||||
|
} else {
|
||||||
|
m_wirelessConnectOpreation->setWirelessEnabled(!m_netSwitch->isChecked());
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,7 +111,8 @@ void WlanPage::initWlanUI()
|
||||||
m_activatedNetListWidget->setPalette(pal);
|
m_activatedNetListWidget->setPalette(pal);
|
||||||
m_inactivatedNetListWidget->setPalette(pal);
|
m_inactivatedNetListWidget->setPalette(pal);
|
||||||
|
|
||||||
m_settingsLabel->installEventFilter(this);
|
m_settingsBtn->installEventFilter(this);
|
||||||
|
m_netSwitch->installEventFilter(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -110,7 +121,9 @@ void WlanPage::onWlanSwithGsettingsChanged(const QString &key)
|
||||||
if (key == WIRELESS_SWITCH) {
|
if (key == WIRELESS_SWITCH) {
|
||||||
m_wlanSwitchEnable = m_switchGsettings->get(WIRELESS_SWITCH).toBool();
|
m_wlanSwitchEnable = m_switchGsettings->get(WIRELESS_SWITCH).toBool();
|
||||||
qDebug() << LOG_FLAG << "wlan switch state" << m_wlanSwitchEnable;
|
qDebug() << LOG_FLAG << "wlan switch state" << m_wlanSwitchEnable;
|
||||||
m_netSwitch->setSwitchStatus(m_wlanSwitchEnable);
|
|
||||||
|
m_netSwitch->setChecked(m_wlanSwitchEnable);
|
||||||
|
|
||||||
initDeviceCombox();
|
initDeviceCombox();
|
||||||
initWlanArea();
|
initWlanArea();
|
||||||
}
|
}
|
||||||
|
@ -118,57 +131,26 @@ void WlanPage::onWlanSwithGsettingsChanged(const QString &key)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief WlanPage::onWlanSwitchClicked 点击无线网开关
|
|
||||||
*/
|
|
||||||
void WlanPage::onWlanSwitchClicked()
|
|
||||||
{
|
|
||||||
if (m_devList.isEmpty()) {
|
|
||||||
showDesktopNotify(tr("No wireless network card detected"), "networkwrong");
|
|
||||||
//检测不到无线网卡不再触发click信号
|
|
||||||
m_netSwitch->setSwitchStatus(false);
|
|
||||||
m_netSwitch->setEnabled(false);
|
|
||||||
} else {
|
|
||||||
bool switchEnable = m_netSwitch->getSwitchStatus();
|
|
||||||
if (m_wlanSwitchEnable != switchEnable) {
|
|
||||||
qDebug()<< LOG_FLAG << "wlan switch state " << switchEnable;
|
|
||||||
m_wirelessConnectOpreation->setWirelessEnabled(switchEnable);
|
|
||||||
if (!switchEnable) {
|
|
||||||
m_netSwitch->setEnabled(false);
|
|
||||||
m_activatedNetFrame->hide();
|
|
||||||
m_activatedNetDivider->hide();
|
|
||||||
m_inactivatedNetFrame->hide();
|
|
||||||
m_deviceFrame->hide();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
void WlanPage::initWlanSwitchState()
|
void WlanPage::initWlanSwitchState()
|
||||||
{
|
{
|
||||||
m_wlanSwitchEnable = m_wirelessConnectOpreation->getWirelessEnabled();
|
|
||||||
|
|
||||||
if (QGSettings::isSchemaInstalled(GSETTINGS_SCHEMA)) {
|
if (QGSettings::isSchemaInstalled(GSETTINGS_SCHEMA)) {
|
||||||
m_switchGsettings = new QGSettings(GSETTINGS_SCHEMA);
|
m_switchGsettings = new QGSettings(GSETTINGS_SCHEMA);
|
||||||
if (m_switchGsettings->keys().contains(WIRELESS_SWITCH)) {
|
if (m_switchGsettings->keys().contains(WIRELESS_SWITCH)) {
|
||||||
if (m_devList.isEmpty()) {
|
if (m_devList.isEmpty()) {
|
||||||
m_wlanSwitchEnable = false;
|
m_netSwitch->setCheckable(false);
|
||||||
m_netSwitch->setSwitchStatus(m_wlanSwitchEnable);
|
m_netSwitch->setChecked(false);
|
||||||
m_netSwitch->setEnabled(false);
|
|
||||||
} else {
|
} else {
|
||||||
m_wlanSwitchEnable = m_switchGsettings->get(WIRELESS_SWITCH).toBool();
|
bool wiredGsetting = m_switchGsettings->get(WIRELESS_SWITCH).toBool();
|
||||||
|
if (m_wirelessConnectOpreation->getWirelessEnabled()
|
||||||
|
!= wiredGsetting) {
|
||||||
|
//以gsetting为准
|
||||||
|
m_wirelessConnectOpreation->setWirelessEnabled(wiredGsetting);
|
||||||
|
}
|
||||||
|
m_netSwitch->setChecked(wiredGsetting);
|
||||||
}
|
}
|
||||||
connect(m_switchGsettings, &QGSettings::changed, this, &WlanPage::onWlanSwithGsettingsChanged);
|
connect(m_switchGsettings, &QGSettings::changed, this, &WlanPage::onWlanSwithGsettingsChanged);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_netSwitch->setSwitchStatus(m_wlanSwitchEnable);
|
|
||||||
|
|
||||||
|
|
||||||
connect(m_netSwitch, &SwitchButton::clicked, this, &WlanPage::onWlanSwitchClicked);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WlanPage::initTimer()
|
void WlanPage::initTimer()
|
||||||
|
@ -200,7 +182,7 @@ void WlanPage::initDeviceCombox()
|
||||||
this, &WlanPage::onDeviceComboxIndexChanged);
|
this, &WlanPage::onDeviceComboxIndexChanged);
|
||||||
m_deviceComboBox->clear();
|
m_deviceComboBox->clear();
|
||||||
|
|
||||||
if (m_wlanSwitchEnable) {
|
if (m_netSwitch->isChecked()) {
|
||||||
if (0 == m_devList.count()) {
|
if (0 == m_devList.count()) {
|
||||||
m_deviceFrame->show();
|
m_deviceFrame->show();
|
||||||
m_tipsLabel->show();
|
m_tipsLabel->show();
|
||||||
|
@ -472,7 +454,7 @@ void WlanPage::constructWirelessNetArea()
|
||||||
|
|
||||||
void WlanPage::initWlanArea()
|
void WlanPage::initWlanArea()
|
||||||
{
|
{
|
||||||
if (m_wlanSwitchEnable) {
|
if (m_netSwitch->isChecked()) {
|
||||||
m_activatedNetFrame->show();
|
m_activatedNetFrame->show();
|
||||||
m_activatedNetDivider->show();
|
m_activatedNetDivider->show();
|
||||||
constructActivateConnectionArea();
|
constructActivateConnectionArea();
|
||||||
|
@ -634,7 +616,7 @@ void WlanPage::addDeviceToCombox(QString deviceName)
|
||||||
{
|
{
|
||||||
disconnect(m_deviceComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged),
|
disconnect(m_deviceComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged),
|
||||||
this, &WlanPage::onDeviceComboxIndexChanged);
|
this, &WlanPage::onDeviceComboxIndexChanged);
|
||||||
if (m_wlanSwitchEnable) {
|
if (m_netSwitch->isChecked()) {
|
||||||
if (m_currentDevice.isEmpty()){
|
if (m_currentDevice.isEmpty()){
|
||||||
m_deviceFrame->hide();
|
m_deviceFrame->hide();
|
||||||
m_currentDevice = deviceName;
|
m_currentDevice = deviceName;
|
||||||
|
@ -667,9 +649,9 @@ void WlanPage::onDeviceAdd(QString deviceName, NetworkManager::Device::Type devi
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_devList.isEmpty()) {
|
if (m_devList.isEmpty()) {
|
||||||
m_wlanSwitchEnable = m_switchGsettings->get(WIRELESS_SWITCH).toBool();
|
bool wlanSwitch = m_switchGsettings->get(WIRELESS_SWITCH).toBool();
|
||||||
m_netSwitch->setEnabled(true);
|
m_netSwitch->setCheckable(true);
|
||||||
m_netSwitch->setSwitchStatus(m_wlanSwitchEnable);
|
m_netSwitch->setChecked(wlanSwitch);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_devList << deviceName;
|
m_devList << deviceName;
|
||||||
|
@ -688,7 +670,7 @@ void WlanPage::deleteDeviceFromCombox(QString deviceName)
|
||||||
disconnect(m_deviceComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged),
|
disconnect(m_deviceComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged),
|
||||||
this, &WlanPage::onDeviceComboxIndexChanged);
|
this, &WlanPage::onDeviceComboxIndexChanged);
|
||||||
|
|
||||||
if (m_wlanSwitchEnable) {
|
if (m_netSwitch->isChecked()) {
|
||||||
if (0 == m_devList.count()) {
|
if (0 == m_devList.count()) {
|
||||||
m_deviceFrame->hide();
|
m_deviceFrame->hide();
|
||||||
//m_tipsLabel->show();
|
//m_tipsLabel->show();
|
||||||
|
@ -729,9 +711,8 @@ void WlanPage::onDeviceRemove(QString deviceName)
|
||||||
deleteDeviceFromCombox(deviceName);
|
deleteDeviceFromCombox(deviceName);
|
||||||
|
|
||||||
if (m_devList.isEmpty()) {
|
if (m_devList.isEmpty()) {
|
||||||
m_wlanSwitchEnable = false;
|
m_netSwitch->setCheckable(false);
|
||||||
m_netSwitch->setSwitchStatus(m_wlanSwitchEnable);
|
m_netSwitch->setChecked(false);
|
||||||
m_netSwitch->setEnabled(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (originalDeviceName == deviceName) {
|
if (originalDeviceName == deviceName) {
|
||||||
|
@ -1043,8 +1024,8 @@ void WlanPage::onWifiEnabledChanged(bool isWifiOn)
|
||||||
if (m_wlanSwitchEnable == isWifiOn) {
|
if (m_wlanSwitchEnable == isWifiOn) {
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
if (!m_netSwitch->getEnabled()) {
|
if (!m_netSwitch->isChecked()) {
|
||||||
m_netSwitch->setEnabled(true);
|
m_netSwitch->setChecked(true);
|
||||||
}
|
}
|
||||||
m_switchGsettings->set(WIRELESS_SWITCH, isWifiOn);
|
m_switchGsettings->set(WIRELESS_SWITCH, isWifiOn);
|
||||||
}
|
}
|
||||||
|
@ -1404,12 +1385,13 @@ void WlanPage::setWirelessSwitchEnable(bool enable)
|
||||||
if (m_devList.isEmpty()) {
|
if (m_devList.isEmpty()) {
|
||||||
qDebug() << "have no device to use " << Q_FUNC_INFO << __LINE__;
|
qDebug() << "have no device to use " << Q_FUNC_INFO << __LINE__;
|
||||||
//检测不到无线网卡不再触发click信号
|
//检测不到无线网卡不再触发click信号
|
||||||
m_netSwitch->setSwitchStatus(false);
|
// m_netSwitch->setSwitchStatus(false);
|
||||||
//m_netSwitch->setEnabled(false);
|
m_netSwitch->setEnabled(false);
|
||||||
}else{
|
}else{
|
||||||
m_wirelessConnectOpreation->setWirelessEnabled(enable);
|
m_wirelessConnectOpreation->setWirelessEnabled(enable);
|
||||||
if (!enable) {
|
if (!enable) {
|
||||||
m_netSwitch->setEnabled(false);
|
// m_netSwitch->setEnabled(false);
|
||||||
|
m_netSwitch->setChecked(false);
|
||||||
m_activatedNetFrame->hide();
|
m_activatedNetFrame->hide();
|
||||||
m_activatedNetDivider->hide();
|
m_activatedNetDivider->hide();
|
||||||
m_inactivatedNetFrame->hide();
|
m_inactivatedNetFrame->hide();
|
||||||
|
|
|
@ -93,7 +93,6 @@ private slots:
|
||||||
NetworkManager::ActiveConnection::Reason reason);
|
NetworkManager::ActiveConnection::Reason reason);
|
||||||
void onItemHeightChanged(const bool isExpanded, const QString &ssid);
|
void onItemHeightChanged(const bool isExpanded, const QString &ssid);
|
||||||
|
|
||||||
void onWlanSwitchClicked();
|
|
||||||
void onWlanSwithGsettingsChanged(const QString &key);
|
void onWlanSwithGsettingsChanged(const QString &key);
|
||||||
|
|
||||||
void onDeviceComboxIndexChanged(int currentIndex);
|
void onDeviceComboxIndexChanged(int currentIndex);
|
||||||
|
|
Loading…
Reference in New Issue