3.22需求&&同步主线代码

This commit is contained in:
zhaoshixu 2022-10-19 10:36:35 +08:00
commit 04b48ec43f
63 changed files with 4087 additions and 160 deletions

11
debian/changelog vendored
View File

@ -1,3 +1,14 @@
kylin-nm (3.20.1.6-ok2) v101; urgency=medium
* BUG号
-#143364 【网络设置】任务栏点击网络图标,网络设置窗口显示在屏幕中央
* 需求号:
-#14187 【控制面板】网络状态显示、网络常用功能入口优化
* 其他改动:无
* 影响域: 控制面板 详情页dns
-- zhaoshixu <zhaoshixu@kylinos.cn> Wed, 19 Oct 2022 10:25:47 +0800
kylin-nm (3.20.1.6-ok1) v101; urgency=medium
* re upload

2
debian/control vendored
View File

@ -35,7 +35,7 @@ Vcs-Browser: https://github.com/ukui/kylin-nm
Package: kylin-nm
Architecture: any
Depends: network-manager (>= 1.22.10-1kylin29k3.5),
Depends: network-manager (>= 1.22.10-1kylin29k3.6),
ukui-control-center (>= 3.1.1+1217),
libkysdk-qtwidgets(>= 1.2.0),
libkysdk-waylandhelper(>= 1.2.0kylin2),

3
debian/kylin-nm.preinst vendored Normal file → Executable file
View File

@ -4,3 +4,6 @@ set -e
path="/usr/lib/`/usr/bin/dpkg-architecture -qDEB_TARGET_MULTIARCH`/ukui-control-center/libnetconnect.so"
dpkg-divert --package kylin-nm --rename --divert "$path"".old" --add $path
path2="/usr/lib/`/usr/bin/dpkg-architecture -qDEB_TARGET_MULTIARCH`/ukui-control-center/libproxy.so"
dpkg-divert --package kylin-nm --rename --divert "$path2"".old" --add $path2

View File

@ -58,7 +58,7 @@ void MobileHotspotWidget::showDesktopNotify(const QString &message)
QList<QVariant> args;
args<<(tr("ukui control center"))
<<((unsigned int) 0)
<<QString("gnome-dev-ethernet")
<<QString("ukui-control-center")
<<tr("ukui control center desktop message") //显示的是什么类型的信息
<<message //显示的具体信息
<<QStringList()
@ -148,7 +148,7 @@ bool MobileHotspotWidget::eventFilter(QObject *watched, QEvent *event)
return true;
}
if (m_switchBtn->isChecked()) {
showDesktopNotify(tr("start to close hotspot"));
// showDesktopNotify(tr("start to close hotspot"));
QDBusReply<void> reply = m_interface->call("deactiveWirelessAp", m_apNameLine->text(), m_uuid);
if (!reply.isValid()) {
qDebug() << "[MobileHotspotWidget] call deactiveWirelessAp failed ";
@ -171,7 +171,7 @@ bool MobileHotspotWidget::eventFilter(QObject *watched, QEvent *event)
// showDesktopNotify(tr("can not create hotspot with password length less than eight!"));
return true;
}
showDesktopNotify(tr("start to open hotspot ") + m_apNameLine->text());
// showDesktopNotify(tr("start to open hotspot ") + m_apNameLine->text());
QDBusReply<void> reply = m_interface->call("activeWirelessAp",
m_apNameLine->text(),
m_pwdNameLine->text(),

View File

@ -19,7 +19,7 @@
*/
#include "deviceframe.h"
#define LAYOUT_MARGINS 18,0,24,0
#define LAYOUT_MARGINS 16,0,16,0
#define FRAME_HEIGHT 58
#define RADIUS 6.0

View File

@ -47,11 +47,28 @@ LanItem::LanItem(bool isAcitve, QWidget *parent)
statusLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
// statusLabel->setMinimumSize(36,36);
infoLabel = new GrayInfoButton(this);
//【更多】菜单
m_moreButton = new QToolButton(this);
m_moreButton->setProperty("useButtonPalette", true);
m_moreButton->setPopupMode(QToolButton::InstantPopup);
m_moreButton->setAutoRaise(true);
m_moreButton->setIcon(QIcon::fromTheme("view-more-horizontal-symbolic"));
m_moreMenu = new QMenu(m_moreButton);
m_connectAction = new QAction(m_moreMenu);
m_deleteAction = new QAction(tr("Delete"), m_moreMenu);
setConnectActionText(isAcitve);
m_moreMenu->addAction(m_connectAction);
m_moreMenu->addAction(m_deleteAction);
m_moreButton->setMenu(m_moreMenu);
mLanLyt->addWidget(iconLabel);
mLanLyt->addWidget(titileLabel,Qt::AlignLeft);
mLanLyt->addStretch();
mLanLyt->addWidget(statusLabel);
mLanLyt->addWidget(infoLabel);
mLanLyt->addWidget(m_moreButton);
loadIcons.append(QIcon::fromTheme("ukui-loading-1-symbolic"));
loadIcons.append(QIcon::fromTheme("ukui-loading-2-symbolic"));
@ -62,6 +79,10 @@ LanItem::LanItem(bool isAcitve, QWidget *parent)
loadIcons.append(QIcon::fromTheme("ukui-loading-7-symbolic"));
waitTimer = new QTimer(this);
connect(waitTimer, &QTimer::timeout, this, &LanItem::updateIcon);
connect(m_connectAction, &QAction::triggered, this, &LanItem::onConnectTriggered);
connect(m_deleteAction, &QAction::triggered, this, &LanItem::onDeletetTriggered);
m_moreMenu->installEventFilter(this);
}
LanItem::~LanItem()
@ -89,6 +110,40 @@ void LanItem::stopLoading(){
loading = false;
}
/**
* @brief LanItem::setConnectActionText
* /
* @param isAcitve
*/
void LanItem::setConnectActionText(bool isAcitve)
{
if (isAcitve) {
m_connectAction->setText(tr("Disconnect"));
} else {
m_connectAction->setText(tr("Connect"));
}
}
void LanItem::onConnectTriggered()
{
if (!m_connectAction) {
return;
}
if (m_connectAction->text() == tr("Connect")) {
Q_EMIT connectActionTriggered();
} else if (m_connectAction->text() == tr("Disconnect")) {
Q_EMIT disconnectActionTriggered();
}
}
void LanItem::onDeletetTriggered()
{
if (!m_deleteAction) {
return;
}
Q_EMIT deleteActionTriggered();
}
void LanItem::paintEvent(QPaintEvent *event)
{
QPalette pal = this->palette();
@ -104,3 +159,18 @@ void LanItem::paintEvent(QPaintEvent *event)
QPushButton::paintEvent(event);
}
bool LanItem::eventFilter(QObject *watched, QEvent *event)
{
//菜单右边界与按钮右边界对齐
if (event->type() == QEvent::Show && watched == m_moreMenu) {
int menuXPos = m_moreMenu->pos().x();
int menuWidth = m_moreMenu->size().width();
int btnWidth = m_moreButton->size().width();
QPoint pos = QPoint (menuXPos - menuWidth + btnWidth, m_moreMenu->pos().y());
m_moreMenu->move(pos);
return true;
}
return false;
}

View File

@ -29,12 +29,16 @@
#include <QDebug>
#include <QImage>
#include <QPainter>
#include <QToolButton>
#include <QMenu>
#include <QEvent>
#include "fixlabel.h"
//#include "infobutton.h"
#include "../component/AddBtn/grayinfobutton.h"
class LanItem : public QPushButton
{
Q_OBJECT
public:
LanItem(bool isAcitve, QWidget *parent = nullptr);
~LanItem();
@ -43,10 +47,15 @@ public:
GrayInfoButton * infoLabel = nullptr;
FixLabel * titileLabel = nullptr;
QLabel * statusLabel = nullptr;
QToolButton* m_moreButton = nullptr;
QMenu* m_moreMenu = nullptr;
QAction* m_connectAction = nullptr;
QAction* m_deleteAction = nullptr;
public:
void startLoading();
void stopLoading();
void setConnectActionText(bool isAcitve);
bool loading = false;
bool isAcitve = false;
@ -56,15 +65,23 @@ public:
protected:
void paintEvent(QPaintEvent *);
bool eventFilter(QObject *watched, QEvent *event);
private:
QTimer *waitTimer = nullptr;
QGSettings *themeGsettings = nullptr;
QList<QIcon> loadIcons;
int currentIconIndex=0;
int currentIconIndex=0;
private slots:
void updateIcon();
void updateIcon();
void onConnectTriggered();
void onDeletetTriggered();
Q_SIGNALS:
void connectActionTriggered();
void disconnectActionTriggered();
void deleteActionTriggered();
};

View File

@ -180,8 +180,10 @@ bool NetConnect::eventFilter(QObject *w, QEvent *e) {
void NetConnect::initComponent() {
wiredSwitch = new KSwitchButton(pluginWidget);
ui->openWIifLayout->addWidget(wiredSwitch);
ui->openWIifLayout->setContentsMargins(0,0,8,0);
ui->detailLayOut->setContentsMargins(MAIN_LAYOUT_MARGINS);
ui->verticalLayout_3->setContentsMargins(NO_MARGINS);
ui->verticalLayout_3->setSpacing(8);
ui->availableLayout->setSpacing(SPACING);
ui->horizontalLayout->setContentsMargins(TOP_MARGINS);
@ -353,6 +355,14 @@ void NetConnect::runExternalApp() {
process.startDetached(cmd);
}
//刪除
void NetConnect::deleteOneLan(QString ssid, int type)
{
qDebug() << "[NetConnect]call deleteConnect" << __LINE__;
m_interface->call(QStringLiteral("deleteConnect"), type, ssid);
qDebug() << "[NetConnect]call deleteConnect respond" << __LINE__;
}
//激活
void NetConnect::activeConnect(QString ssid, QString deviceName, int type) {
qDebug() << "[NetConnect]call activateConnect" << __LINE__;
@ -421,12 +431,12 @@ void NetConnect::addLanItem(ItemFrame *frame, QString devName, QStringList infoL
return;
}
LanItem * lanItem = new LanItem(pluginWidget);
LanItem * lanItem = new LanItem(isActived, pluginWidget);
QString iconPath = KLanSymbolic;
if (isActived) {
lanItem->statusLabel->setText(tr("connected"));
} else {
lanItem->statusLabel->setText("");
lanItem->statusLabel->setText(tr("not connected"));
}
QIcon searchIcon = QIcon::fromTheme(iconPath);
// if (iconPath != KLanSymbolic && iconPath != NoNetSymbolic) {
@ -449,6 +459,7 @@ void NetConnect::addLanItem(ItemFrame *frame, QString devName, QStringList infoL
});
lanItem->isAcitve = isActived;
lanItem->setConnectActionText(lanItem->isAcitve);
connect(lanItem, &QPushButton::clicked, this, [=] {
if (lanItem->isAcitve || lanItem->loading) {
@ -458,6 +469,16 @@ void NetConnect::addLanItem(ItemFrame *frame, QString devName, QStringList infoL
}
});
connect(lanItem, &LanItem::connectActionTriggered, this, [=] {
activeConnect(lanItem->uuid, devName, WIRED_TYPE);
});
connect(lanItem, &LanItem::disconnectActionTriggered, this, [=] {
deActiveConnect(lanItem->uuid, devName, WIRED_TYPE);
});
connect(lanItem, &LanItem::deleteActionTriggered, this, [=] {
deleteOneLan(lanItem->uuid, WIRED_TYPE);
});
//记录到deviceFrame的itemMap中
deviceFrameMap[devName]->itemMap.insert(infoList.at(1), lanItem);
qDebug()<<"insert " << infoList.at(1) << " to " << devName << " list";
@ -707,7 +728,7 @@ void NetConnect::addOneLanFrame(ItemFrame *frame, QString deviceName, QStringLis
QString iconPath;
iconPath = KLanSymbolic;
lanItem->statusLabel->setText("");
lanItem->statusLabel->setText(tr("not connected"));
QIcon searchIcon = QIcon::fromTheme(iconPath);
// if (iconPath != KLanSymbolic && iconPath != NoNetSymbolic) {
@ -730,6 +751,7 @@ void NetConnect::addOneLanFrame(ItemFrame *frame, QString deviceName, QStringLis
});
lanItem->isAcitve = false;
lanItem->setConnectActionText(lanItem->isAcitve);
connect(lanItem, &QPushButton::clicked, this, [=] {
if (lanItem->isAcitve || lanItem->loading) {
@ -739,6 +761,16 @@ void NetConnect::addOneLanFrame(ItemFrame *frame, QString deviceName, QStringLis
}
});
connect(lanItem, &LanItem::connectActionTriggered, this, [=] {
activeConnect(lanItem->uuid, deviceName, WIRED_TYPE);
});
connect(lanItem, &LanItem::disconnectActionTriggered, this, [=] {
deActiveConnect(lanItem->uuid, deviceName, WIRED_TYPE);
});
connect(lanItem, &LanItem::deleteActionTriggered, this, [=] {
deleteOneLan(lanItem->uuid, WIRED_TYPE);
});
//记录到deviceFrame的itemMap中
deviceFrameMap[deviceName]->itemMap.insert(connUuid, lanItem);
int index = getInsertPos(connName, deviceName);
@ -853,7 +885,9 @@ void NetConnect::itemActiveConnectionStatusChanged(LanItem *item, int status)
item->statusLabel->setMaximumSize(16777215,16777215);
item->statusLabel->clear();
item->isAcitve = false;
item->statusLabel->setText(tr("not connected"));
}
item->setConnectActionText(item->isAcitve);
// QIcon searchIcon = QIcon::fromTheme(iconPath);
// item->iconLabel->setPixmap(searchIcon.pixmap(searchIcon.actualSize(QSize(24, 24))));

View File

@ -101,7 +101,7 @@ private:
int getInsertPos(QString connName, QString deviceName);
void deleteOneLan(QString ssid);
void deleteOneLan(QString ssid, int type);
void activeConnect(QString ssid, QString deviceName, int type);
void deActiveConnect(QString ssid, QString deviceName, int type);
@ -152,6 +152,7 @@ private slots:
void onDeviceStatusChanged();
void onDeviceNameChanged(QString, QString, int);
};
Q_DECLARE_METATYPE(QList<QDBusObjectPath>);

View File

@ -4,63 +4,94 @@
<context>
<name>AddNetBtn</name>
<message>
<location filename="../addnetbtn.cpp" line="22"/>
<location filename="../../component/AddBtn/addnetbtn.cpp" line="48"/>
<source>Add Others</source>
<translation></translation>
</message>
<message>
<location filename="../../component/AddBtn/addnetbtn.cpp" line="52"/>
<source>Add WiredNetork</source>
<translation></translation>
</message>
</context>
<context>
<name>LanItem</name>
<message>
<location filename="../lanitem.cpp" line="59"/>
<source>Delete</source>
<translation></translation>
</message>
<message>
<location filename="../lanitem.cpp" line="121"/>
<location filename="../lanitem.cpp" line="134"/>
<source>Disconnect</source>
<translation></translation>
</message>
<message>
<location filename="../lanitem.cpp" line="123"/>
<location filename="../lanitem.cpp" line="132"/>
<source>Connect</source>
<translation></translation>
</message>
</context>
<context>
<name>NetConnect</name>
<message>
<location filename="../netconnect.ui" line="50"/>
<location filename="../netconnect.cpp" line="152"/>
<location filename="../netconnect.cpp" line="153"/>
<source>Wired Network</source>
<translation></translation>
</message>
<message>
<location filename="../netconnect.ui" line="112"/>
<location filename="../netconnect.cpp" line="154"/>
<location filename="../netconnect.cpp" line="155"/>
<source>open</source>
<translation></translation>
<extra-contents_path>/netconnect/open</extra-contents_path>
</message>
<message>
<location filename="../netconnect.ui" line="198"/>
<location filename="../netconnect.cpp" line="151"/>
<location filename="../netconnect.cpp" line="152"/>
<source>Advanced settings</source>
<translation></translation>
<extra-contents_path>/netconnect/Advanced settings&quot;</extra-contents_path>
</message>
<message>
<location filename="../netconnect.cpp" line="63"/>
<location filename="../netconnect.cpp" line="64"/>
<source>ukui control center</source>
<translation></translation>
</message>
<message>
<location filename="../netconnect.cpp" line="66"/>
<location filename="../netconnect.cpp" line="67"/>
<source>ukui control center desktop message</source>
<translation>ukui </translation>
</message>
<message>
<location filename="../netconnect.cpp" line="80"/>
<location filename="../netconnect.cpp" line="81"/>
<source>WiredConnect</source>
<translation></translation>
</message>
<message>
<location filename="../netconnect.cpp" line="177"/>
<location filename="../netconnect.cpp" line="169"/>
<source>No ethernet device avaliable</source>
<translation></translation>
</message>
<message>
<location filename="../netconnect.cpp" line="426"/>
<location filename="../netconnect.cpp" line="833"/>
<location filename="../netconnect.cpp" line="437"/>
<location filename="../netconnect.cpp" line="866"/>
<source>connected</source>
<translation></translation>
</message>
<message>
<location filename="../netconnect.cpp" line="490"/>
<location filename="../netconnect.cpp" line="512"/>
<source>card</source>
<translation></translation>
</message>
<message>
<location filename="../netconnect.cpp" line="439"/>
<location filename="../netconnect.cpp" line="876"/>
<source>not connected</source>
<translation></translation>
</message>
</context>
</TS>

View File

@ -4,63 +4,94 @@
<context>
<name>AddNetBtn</name>
<message>
<location filename="../addnetbtn.cpp" line="22"/>
<location filename="../../component/AddBtn/addnetbtn.cpp" line="48"/>
<source>Add Others</source>
<translation></translation>
</message>
<message>
<location filename="../../component/AddBtn/addnetbtn.cpp" line="52"/>
<source>Add WiredNetork</source>
<translation>线</translation>
</message>
</context>
<context>
<name>LanItem</name>
<message>
<location filename="../lanitem.cpp" line="59"/>
<source>Delete</source>
<translation></translation>
</message>
<message>
<location filename="../lanitem.cpp" line="121"/>
<location filename="../lanitem.cpp" line="134"/>
<source>Disconnect</source>
<translation></translation>
</message>
<message>
<location filename="../lanitem.cpp" line="123"/>
<location filename="../lanitem.cpp" line="132"/>
<source>Connect</source>
<translation></translation>
</message>
</context>
<context>
<name>NetConnect</name>
<message>
<location filename="../netconnect.ui" line="50"/>
<location filename="../netconnect.cpp" line="152"/>
<location filename="../netconnect.cpp" line="153"/>
<source>Wired Network</source>
<translation>线</translation>
</message>
<message>
<location filename="../netconnect.ui" line="112"/>
<location filename="../netconnect.cpp" line="154"/>
<location filename="../netconnect.cpp" line="155"/>
<source>open</source>
<translation></translation>
<extra-contents_path>/netconnect/open</extra-contents_path>
</message>
<message>
<location filename="../netconnect.ui" line="198"/>
<location filename="../netconnect.cpp" line="151"/>
<location filename="../netconnect.cpp" line="152"/>
<source>Advanced settings</source>
<translation></translation>
<extra-contents_path>/netconnect/Advanced settings&quot;</extra-contents_path>
</message>
<message>
<location filename="../netconnect.cpp" line="63"/>
<location filename="../netconnect.cpp" line="64"/>
<source>ukui control center</source>
<translation></translation>
</message>
<message>
<location filename="../netconnect.cpp" line="66"/>
<location filename="../netconnect.cpp" line="67"/>
<source>ukui control center desktop message</source>
<translation></translation>
</message>
<message>
<location filename="../netconnect.cpp" line="80"/>
<location filename="../netconnect.cpp" line="81"/>
<source>WiredConnect</source>
<translation>线</translation>
</message>
<message>
<location filename="../netconnect.cpp" line="177"/>
<location filename="../netconnect.cpp" line="169"/>
<source>No ethernet device avaliable</source>
<translation>线</translation>
</message>
<message>
<location filename="../netconnect.cpp" line="426"/>
<location filename="../netconnect.cpp" line="833"/>
<location filename="../netconnect.cpp" line="437"/>
<location filename="../netconnect.cpp" line="866"/>
<source>connected</source>
<translation></translation>
</message>
<message>
<location filename="../netconnect.cpp" line="490"/>
<location filename="../netconnect.cpp" line="512"/>
<source>card</source>
<translation></translation>
</message>
<message>
<location filename="../netconnect.cpp" line="439"/>
<location filename="../netconnect.cpp" line="876"/>
<source>not connected</source>
<translation></translation>
</message>
</context>
</TS>

View File

@ -2,4 +2,5 @@ TEMPLATE = subdirs
SUBDIRS = \
netconnect \
wlanconnect \
mobilehotspot
mobilehotspot \
proxy

View File

@ -0,0 +1,138 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* 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 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#include "applistwidget.h"
#include <QDebug>
AppListWidget::AppListWidget(QString path, QWidget *parent)
: m_path(path), QWidget(parent)
{
initUI();
initDbus();
}
AppListWidget::~AppListWidget()
{
}
/**
* @brief AppListWidget::setAppChecked
* @param flag 使
*/
void AppListWidget::setAppChecked(bool flag)
{
m_checkBox->setChecked(flag);
}
/**
* @brief AppListWidget::setAppIcon
* @param icon
*/
void AppListWidget::setAppIcon(const QPixmap &icon)
{
m_iconLabel->setAlignment(Qt::AlignCenter);
m_iconLabel->setPixmap(icon);
}
/**
* @brief AppListWidget::setAppName
* @param text
*/
void AppListWidget::setAppName(const QString &text)
{
m_nameLabel->setText(text);
}
/**
* @brief AppListWidget::onAppCheckStateChanged
* checkBox是否选中
*/
void AppListWidget::onAppCheckStateChanged()
{
if (m_checkBox->isChecked()) {
AddAppProxyConfig();
} else {
RemoveAppProxyConfig();
}
}
/**
* @brief AppListWidget::AddAppProxyConfig
*
*/
void AppListWidget::AddAppProxyConfig()
{
if(!m_dbusInterface->isValid()) {
qWarning ()<< "init AppProxy dbus error";
}
qDebug() << "call QDBusInterface addAppIntoProxy";
m_dbusInterface->call("addAppIntoProxy", m_path);
}
/**
* @brief AppListWidget::RemoveAppProxyConfig
*
*/
void AppListWidget::RemoveAppProxyConfig()
{
if(!m_dbusInterface->isValid()) {
qWarning ()<< "init AppProxy dbus error";
}
qDebug() << "call QDBusInterface delAppIntoProxy";
m_dbusInterface->call("delAppIntoProxy", m_path);
}
void AppListWidget::mousePressEvent(QMouseEvent *event)
{
if (event->button() == Qt::LeftButton) {
m_checkBox->setChecked(!m_checkBox->isChecked());
onAppCheckStateChanged();
}
return QWidget::mousePressEvent(event);
}
void AppListWidget::initUI()
{
QHBoxLayout *mainLayout = new QHBoxLayout(this);
mainLayout->setContentsMargins(17, 0, 17, 0);
mainLayout->setSpacing(8);
m_checkBox = new QCheckBox(this);
m_checkBox->setFixedSize(16, 16);
m_checkBox->setAttribute(Qt::WA_TransparentForMouseEvents, true); //m_checkBox不响应鼠标事件,将其传递给父窗口
m_iconLabel = new QLabel(this);
m_iconLabel->setFixedSize(24, 24);
m_nameLabel = new QLabel(this);
mainLayout->addWidget(m_checkBox);
mainLayout->addSpacing(8);
mainLayout->addWidget(m_iconLabel);
mainLayout->addWidget(m_nameLabel);
mainLayout->addStretch();
}
void AppListWidget::initDbus()
{
m_dbusInterface = new QDBusInterface("org.ukui.SettingsDaemon",
"/org/ukui/SettingsDaemon/AppProxy",
"org.ukui.SettingsDaemon.AppProxy",
QDBusConnection::sessionBus());
}

View File

@ -0,0 +1,60 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* 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 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#ifndef APPLISTWIDGET_H
#define APPLISTWIDGET_H
#include <QObject>
#include <QWidget>
#include <QMouseEvent>
#include <QCheckBox>
#include <QLabel>
#include <QHBoxLayout>
#include <QDBusInterface>
#include <QDBusReply>
class AppListWidget : public QWidget
{
Q_OBJECT
public:
explicit AppListWidget(QString path, QWidget *parent = nullptr);
~AppListWidget();
void setAppChecked(bool flag);
void setAppIcon(const QPixmap &icon);
void setAppName(const QString &text);
void onAppCheckStateChanged();
void AddAppProxyConfig();
void RemoveAppProxyConfig();
protected:
void mousePressEvent(QMouseEvent *event);
private:
void initUI();
void initDbus();
QCheckBox *m_checkBox = nullptr;
QLabel *m_iconLabel = nullptr;
QLabel *m_nameLabel = nullptr;
QString m_path = nullptr;
QDBusInterface *m_dbusInterface = nullptr;
};
#endif // APPLISTWIDGET_H

32
plugins/proxy/aptinfo.h Normal file
View File

@ -0,0 +1,32 @@
#ifndef APTINFO_H
#define APTINFO_H
#include <QHash>
#include <QVariant>
#include <QString>
#include <QDBusArgument>
struct AptInfo
{
QString arg;
QDBusVariant out;
};
QDBusArgument &operator<<(QDBusArgument &argument, const AptInfo &mystruct)
{
argument.beginStructure();
argument << mystruct.arg << mystruct.out;
argument.endStructure();
return argument;
}
const QDBusArgument &operator>>(const QDBusArgument &argument, AptInfo &mystruct)
{
argument.beginStructure();
argument >> mystruct.arg >> mystruct.out;
argument.endStructure();
return argument;
}
Q_DECLARE_METATYPE(AptInfo)
#endif // APTINFO_H

View File

@ -0,0 +1,127 @@
#include "aptproxydialog.h"
#include <QDebug>
#include <QLineEdit>
#include <QSpacerItem>
#include <QLabel>
#include <QPushButton>
#include "proxy.h"
AptProxyDialog::AptProxyDialog(QWidget *parent ):
QDialog(parent)
{
initUi();
setupComponent();
initConnect();
}
AptProxyDialog::~AptProxyDialog()
{
}
void AptProxyDialog::initUi()
{
setWindowTitle(tr("Set Apt Proxy"));
this->setFixedSize(480, 200);
QVBoxLayout *mAptProxyLyt = new QVBoxLayout(this);
mAptProxyLyt->setContentsMargins(24, 24, 24, 24);
mAptProxyLyt->setSpacing(16);
QFrame *mHostFrame = new QFrame(this);
mHostFrame->setFixedSize(432, 36);
mHostFrame->setFrameShape(QFrame::NoFrame);
QHBoxLayout *mLyt_1= new QHBoxLayout(mHostFrame);
mLyt_1->setContentsMargins(0, 0, 0, 0);
mLyt_1->setSpacing(8);
FixLabel *mSetHostLabel = new FixLabel(mHostFrame);
mSetHostLabel->setFixedSize(92, 36);
mSetHostLabel->setText(tr("Server Address"));
mHostEdit = new QLineEdit(mHostFrame);
mHostEdit->setAttribute(Qt::WA_InputMethodEnabled, false); //限制中文输入法
mHostEdit->setFixedSize(332, 36);
mHostEdit->installEventFilter(this);
mLyt_1->addWidget(mSetHostLabel);
mLyt_1->addWidget(mHostEdit);
QFrame *mPortFrame = new QFrame(this);
mPortFrame->setFixedSize(432, 36);
mPortFrame->setFrameShape(QFrame::NoFrame);
QHBoxLayout *mLyt_2= new QHBoxLayout(mPortFrame);
mLyt_2->setContentsMargins(0, 0, 0, 0);
mLyt_2->setSpacing(8);
QLabel *mSetPortLabel = new QLabel(tr("Port") ,mPortFrame);
mSetPortLabel->setFixedSize(92, 36);
mPortEdit = new QLineEdit(mPortFrame);
mPortEdit->setAttribute(Qt::WA_InputMethodEnabled, false); //限制中文输入法
mPortEdit->setFixedSize(332, 36);
mPortEdit->installEventFilter(this);
mLyt_2->addWidget(mSetPortLabel);
mLyt_2->addWidget(mPortEdit);
QFrame *mChooseFrame = new QFrame(this);
mChooseFrame->setFixedWidth(432);
mChooseFrame->setFrameShape(QFrame::NoFrame);
QHBoxLayout *mLyt_3= new QHBoxLayout(mChooseFrame);
mLyt_3->setContentsMargins(0, 0, 0, 0);
mLyt_3->setSpacing(16);
mCancelBtn = new QPushButton(mChooseFrame);
mCancelBtn->setMinimumWidth(96);
mCancelBtn->setText(tr("Cancel"));
mConfirmBtn = new QPushButton(mChooseFrame);
mConfirmBtn->setMinimumWidth(96);
mConfirmBtn->setText(tr("Confirm"));
mLyt_3->addStretch();
mLyt_3->addWidget(mCancelBtn);
mLyt_3->addWidget(mConfirmBtn);
mAptProxyLyt->addWidget(mHostFrame);
mAptProxyLyt->addWidget(mPortFrame);
mAptProxyLyt->addSpacing(16);
mAptProxyLyt->addWidget(mChooseFrame);
}
void AptProxyDialog::initConnect()
{
connect(mHostEdit, &QLineEdit::textEdited, this, [=]() {
if (mHostEdit->text().isEmpty()) {
mConfirmBtn->setEnabled(false);
} else {
mConfirmBtn->setEnabled(true);
}
});
connect(mCancelBtn, &QPushButton::clicked, this, [=]() {
this->close();
});
connect(mConfirmBtn, &QPushButton::clicked, this, [=]() {
Proxy::setAptProxy(mHostEdit->text() , mPortEdit->text() , true);
this->close();
});
}
void AptProxyDialog::setupComponent()
{
QString host = Proxy::getAptProxy()["ip"].toString();
QString port = Proxy::getAptProxy()["port"].toString();;
mHostEdit->setText(host);
mPortEdit->setText(port);
if (host.isEmpty()) {
mConfirmBtn->setEnabled(false);
}
}

View File

@ -0,0 +1,38 @@
#ifndef APTPROXYDIALOG_H
#define APTPROXYDIALOG_H
#include <QObject>
#include <QWidget>
#include <QVBoxLayout>
#include <QGSettings>
#include <QLabel>
#include <QLineEdit>
#include <QDialog>
#include "fixlabel.h"
#define APT_PROXY_SCHEMA "org.ukui.control-center.apt.proxy"
#define APT_PROXY_ENABLED "enabled"
#define APT_PROXY_HOST_KEY "host"
#define APT_PROXY_PORT_KEY "port"
class AptProxyDialog : public QDialog
{
Q_OBJECT
public:
AptProxyDialog(QWidget *parent = nullptr);
~AptProxyDialog();
void initUi();
private:
QLineEdit *mHostEdit;
QLineEdit *mPortEdit;
QPushButton *mCancelBtn;
QPushButton *mConfirmBtn;
private:
void initConnect();
void setupComponent();
};
#endif // APTPROXYDIALOG_H

View File

@ -0,0 +1,31 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* 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 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#ifndef CERTIFICATIONDIALOG_H
#define CERTIFICATIONDIALOG_H
#include <QDialog>
#define HTTP_PROXY_SCHEMA "org.gnome.system.proxy.http"
#define HTTP_AUTH_KEY "use-authentication"
#define HTTP_AUTH_USER_KEY "authentication-user"
#define HTTP_AUTH_PASSWD_KEY "authentication-password"
#endif // CERTIFICATIONDIALOG_H

View File

@ -0,0 +1,342 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CertificationDialog</class>
<widget class="QDialog" name="CertificationDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>500</width>
<height>246</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>500</width>
<height>246</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>500</width>
<height>246</height>
</size>
</property>
<property name="windowTitle">
<string>UserCertification</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>20</number>
</property>
<property name="leftMargin">
<number>20</number>
</property>
<property name="topMargin">
<number>25</number>
</property>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>10</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QHBoxLayout" name="activeHLayout" stretch="0">
<property name="spacing">
<number>10</number>
</property>
<property name="leftMargin">
<number>20</number>
</property>
<item>
<widget class="QLabel" name="label_3">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>UserCertification</string>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QWidget" name="widget" native="true">
<layout class="QVBoxLayout" name="verticalLayout_4">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<property name="spacing">
<number>0</number>
</property>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>60</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>60</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>60</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>User:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="userLineEdit">
<property name="minimumSize">
<size>
<width>180</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>180</width>
<height>16777215</height>
</size>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<property name="spacing">
<number>0</number>
</property>
<item>
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>60</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>60</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>60</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>Passwd:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="pwdLineEdit">
<property name="minimumSize">
<size>
<width>180</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>180</width>
<height>16777215</height>
</size>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<spacer name="horizontalSpacer_6">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="closePushBtn">
<property name="text">
<string>Close</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_7">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>80</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

1367
plugins/proxy/proxy.cpp Normal file

File diff suppressed because it is too large Load Diff

285
plugins/proxy/proxy.h Normal file
View File

@ -0,0 +1,285 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* 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 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#ifndef PROXY_H
#define PROXY_H
#include <QObject>
#include <QtPlugin>
#include <QFileSystemWatcher>
#include <QDialog>
#include <QLineEdit>
#include "certificationdialog.h"
#include <QGSettings>
#include <QRadioButton>
#include <QLineEdit>
#include <QCheckBox>
#include <QTextEdit>
#include <QButtonGroup>
#include <QComboBox>
#include <QListWidget>
#include <QFormLayout>
#include <QDBusInterface>
#include <QDBusConnection>
#include <QDBusError>
#include <QDBusReply>
#include <QMessageBox>
#include <QtDBus/QDBusMetaType>
#include "interface.h"
#include "titlelabel.h"
#include "hoverwidget.h"
#include "applistwidget.h"
#include "kswitchbutton.h"
#include "kpasswordedit.h"
using namespace kdk;
/* qt会将glib里的signals成员识别为宏所以取消该宏
* signals时使Q_SIGNALS代替即可
**/
#ifdef signals
#undef signals
#endif
#include <glib.h>
#include <gio/gio.h>
struct GSData
{
QString key;
QString schema;
};
typedef enum{
NONE,
MANUAL,
AUTO
}ProxyMode;
//自定义类型使用QVariant需要使用 Q_DECLARE_METATYPE 注册
Q_DECLARE_METATYPE(ProxyMode)
Q_DECLARE_METATYPE(GSData)
namespace Ui {
class Proxy;
}
class Proxy : public QObject, CommonInterface
{
Q_OBJECT
Q_PLUGIN_METADATA(IID "org.ukcc.CommonInterface")
Q_INTERFACES(CommonInterface)
public:
Proxy();
~Proxy();
QString plugini18nName() Q_DECL_OVERRIDE;
int pluginTypes() Q_DECL_OVERRIDE;
QWidget * pluginUi() Q_DECL_OVERRIDE;
void plugin_leave()Q_DECL_OVERRIDE;
const QString name() const Q_DECL_OVERRIDE;
bool isShowOnHomePage() const Q_DECL_OVERRIDE;
QIcon icon() const Q_DECL_OVERRIDE;
bool isEnable() const Q_DECL_OVERRIDE;
public:
void initUi(QWidget *widget);
void initSearchText();
void retranslateUi();
void setupComponent();
void setupConnect();
void initProxyModeStatus();
void initAutoProxyStatus();
void initManualProxyStatus();
void initIgnoreHostStatus();
void initDbus();
void initAppProxyStatus();
void manualProxyTextChanged(QString txt);
int _getCurrentProxyMode();
void _setSensitivity();
bool getAptProxyInfo(bool status);
static void setAptProxy(QString host ,QString port ,bool status); // apt代理对应的配置文件的写入或删除
static QHash<QString, QVariant> getAptProxy();
void setAptInfo();
void reboot(); // 调用重启接口
void setFrame_Noframe(QFrame *frame);
QFrame *setLine(QFrame *frame);
bool getAppProxyState(); //获取应用代理开启状态--调用Dbus
void setAppProxyState(bool state); //设置应用代理开启状态--调用Dbus
static QStringList getAppProxyConf(); //获取应用代理配置信息--调用Dbus
void setAppProxyConf(QStringList list); //设置应用代理配置信息--调用Dbus
static QMap<QString, QStringList> getAppListProxy();
// bool checkIsChanged(QStringList info);
private:
void setAppProxyFrameUi(QWidget *widget);
void setAppListFrameUi(QWidget *widget);
void appProxyInfoPadding();
void appListPadding();
bool getipEditState(QString text);
QString pluginName;
int pluginType;
QWidget * pluginWidget;
TitleLabel *mTitleLabel;
TitleLabel *m_appProxyLabel;
TitleLabel *mAptProxyLabel;
QLabel *mUrlLabel;
QLabel *mHTTPLabel;
QLabel *mHTTPPortLabel;
QLabel *mHTTPSLabel;
QLabel *mHTTPSPortLabel;
QLabel *mFTPLabel;
QLabel *mFTPPortLabel;
QLabel *mSOCKSLabel;
QLabel *mSOCKSPortLabel;
QLabel *mIgnoreLabel;
QLabel *mAptLabel;
QLabel *mAPTHostLabel_1;
QLabel *mAPTHostLabel_2;
QLabel *mAPTPortLabel_1;
QLabel *mAPTPortLabel_2;
QLabel *mCertificationLabel;
QLabel *mUserNameLabel;
QLabel *mPwdLabel;
QLabel *m_appEnableLabel;
QLabel *m_proxyTypeLabel;
QLabel *m_ipAddressLabel;
QLabel *m_ipHintsLabel;
QLabel *m_portLabel;
QLabel *m_userNameLabel;
QLabel *m_pwdLabel;
QLabel *m_allowAppProxyLabel;
QFrame *mProxyFrame;
QFrame *mEnableFrame;
QFrame *mSelectFrame;
QFrame *mUrlFrame;
QFrame *mHTTPFrame;
QFrame *mHTTPSFrame;
QFrame *mFTPFrame;
QFrame *mSOCKSFrame;
QFrame *mIgnoreFrame;
QFrame *mCertificationFrame_1;
QFrame *m_appEnableFrame;
QFrame *m_appProxyFrame;
QFrame *m_proxyTypeFrame;
QFrame *m_ipAddressFrame;
QFrame *m_portFrame;
QFrame *m_userNameFrame;
QFrame *m_pwdFrame;
// QFrame *m_appBtnFrame;
QFrame *m_appListFrame;
QFrame *mAPTFrame;
QFrame *mAPTFrame_1;
QFrame *mAPTFrame_2;
QFrame *line_1;
QFrame *line_2;
QFrame *line_3;
QFrame *line_4;
QFrame *line_5;
QFrame *line_6;
QFrame *line_7;
QFrame *line_8;
QFrame *m_appLine1;
QFrame *m_appLine2;
QFrame *m_appLine3;
QFrame *m_appLine4;
QFrame *m_appLine5;
QRadioButton *mAutoBtn;
QRadioButton *mManualBtn;
KSwitchButton *mEnableBtn;
KSwitchButton *mAptBtn;
QPushButton *mEditBtn;
QCheckBox *mCertificationBtn;
QButtonGroup *mProxyBtnGroup;
QLineEdit *mUrlLineEdit;
QLineEdit *mHTTPLineEdit_1;
QLineEdit *mHTTPLineEdit_2;
QLineEdit *mHTTPSLineEdit_1;
QLineEdit *mHTTPSLineEdit_2;
QLineEdit *mFTPLineEdit_1;
QLineEdit *mFTPLineEdit_2;
QLineEdit *mSOCKSLineEdit_1;
QLineEdit *mSOCKSLineEdit_2;
QLineEdit *mUserNameLineEdit;
QLineEdit *mPwdLineEdit;
QLineEdit *m_ipAddressLineEdit;
QLineEdit *m_portLineEdit;
QLineEdit *m_userNameLineEdit;
KSwitchButton *m_appEnableBtn;
QComboBox *m_proxyTypeComboBox;
KPasswordEdit *m_pwdLineEdit = nullptr;
// QPushButton *m_cancelBtn;
// QPushButton *m_saveBtn;
QListWidget *m_appListWidget = nullptr;
QTextEdit *mIgnoreLineEdit;
QGSettings * proxysettings;
QGSettings * httpsettings;
QGSettings * securesettings;
QGSettings * ftpsettings;
QGSettings * sockssettings;
QGSettings * aptsettings;
QFileSystemWatcher *mfileWatch_1;
QFileSystemWatcher *mfileWatch_2;
QDBusInterface *mAptproxyDbus;
QDBusInterface *m_appProxyDbus;
bool isExistSettings = false;
bool settingsCreate;
bool mFirstLoad;
QStringList m_appProxyInfo;
QStringList m_appCheckedList;
private slots:
void setAptProxySlot(); //处理apt代理前端交互逻辑
void onappProxyEnableChanged(bool enable); //IP地址无效提示
void onipEditStateChanged(); //IP地址无效提示
void onAppProxyConfChanged(); //应用代理配置信息变化
void onAppProxyConfEditFinished();
// void onCancelBtnClicked();
// void onSaveBtnClicked();
// void setBtnEnable();
};
#endif // PROXY_H

52
plugins/proxy/proxy.pro Normal file
View File

@ -0,0 +1,52 @@
#include(../../../env.pri)
QT += widgets dbus
TEMPLATE = lib
CONFIG += plugin
TARGET = $$qtLibraryTarget(proxy)
DESTDIR = ../..
target.path = $$[QT_INSTALL_LIBS]/ukui-control-center
trans.files = translations/*
trans.path = /usr/share/kylin-nm/proxy/
INCLUDEPATH += \
$$PROJECT_COMPONENTSOURCE \
$$PROJECT_ROOTDIR \
/usr/include/ukcc/interface \
/usr/include/ukcc/widgets
LIBS += -L$$[QT_INSTALL_LIBS] -lgsettings-qt -lukcc
##加载gio库和gio-unix库用于获取和设置enum类型的gsettings
CONFIG += link_pkgconfig \
C++11
PKGCONFIG += gio-2.0 \
gio-unix-2.0 \
gsettings-qt \
kysdk-qtwidgets
#DEFINES += QT_DEPRECATED_WARNINGS
SOURCES += \
applistwidget.cpp \
aptproxydialog.cpp \
proxy.cpp
HEADERS += \
applistwidget.h \
aptinfo.h \
aptproxydialog.h \
proxy.h \
certificationdialog.h
FORMS +=
INSTALLS += target \
trans
TRANSLATIONS += \
translations/zh_CN.ts \
translations/tr.ts \
translations/bo_CN.ts

Binary file not shown.

View File

@ -0,0 +1,227 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1" language="bo_CN">
<context>
<name>AptProxyDialog</name>
<message>
<location filename="../aptproxydialog.cpp" line="24"/>
<source>Set Apt Proxy</source>
<translation>Apt </translation>
</message>
<message>
<location filename="../aptproxydialog.cpp" line="41"/>
<source>Server Address</source>
<translation></translation>
</message>
<message>
<location filename="../aptproxydialog.cpp" line="59"/>
<source>Port</source>
<translation></translation>
</message>
<message>
<location filename="../aptproxydialog.cpp" line="80"/>
<source>Cancel</source>
<translation></translation>
</message>
<message>
<location filename="../aptproxydialog.cpp" line="84"/>
<source>Confirm</source>
<translation></translation>
</message>
</context>
<context>
<name>Proxy</name>
<message>
<location filename="../proxy.cpp" line="63"/>
<source>Proxy</source>
<translation></translation>
</message>
<message>
<location filename="../proxy.cpp" line="194"/>
<source>Start using</source>
<translation></translation>
</message>
<message>
<location filename="../proxy.cpp" line="207"/>
<source>Proxy mode</source>
<translation></translation>
</message>
<message>
<location filename="../proxy.cpp" line="211"/>
<source>Auto</source>
<translation></translation>
</message>
<message>
<location filename="../proxy.cpp" line="214"/>
<source>Manual</source>
<translation></translation>
</message>
<message>
<location filename="../proxy.cpp" line="369"/>
<source>Application Proxy</source>
<translation></translation>
</message>
<message>
<location filename="../proxy.cpp" line="444"/>
<source>System Proxy</source>
<translation></translation>
</message>
<message>
<location filename="../proxy.cpp" line="446"/>
<source>Auto url</source>
<translation></translation>
<extra-contents_path>/Proxy/Auto url</extra-contents_path>
</message>
<message>
<location filename="../proxy.cpp" line="448"/>
<source>Http Proxy</source>
<translation>HTTP </translation>
<extra-contents_path>/Proxy/Http Proxy</extra-contents_path>
</message>
<message>
<location filename="../proxy.cpp" line="450"/>
<source>Https Proxy</source>
<translation>HTTPS </translation>
<extra-contents_path>/Proxy/Https Proxy</extra-contents_path>
</message>
<message>
<location filename="../proxy.cpp" line="452"/>
<source>Ftp Proxy</source>
<translation>FTP </translation>
<extra-contents_path>/Proxy/Ftp Proxy</extra-contents_path>
</message>
<message>
<location filename="../proxy.cpp" line="454"/>
<source>Socks Proxy</source>
<translation>SOCKS </translation>
<extra-contents_path>/Proxy/Socks Proxy</extra-contents_path>
</message>
<message>
<location filename="../proxy.cpp" line="455"/>
<location filename="../proxy.cpp" line="456"/>
<location filename="../proxy.cpp" line="457"/>
<location filename="../proxy.cpp" line="458"/>
<location filename="../proxy.cpp" line="1047"/>
<source>Port</source>
<translation></translation>
</message>
<message>
<location filename="../proxy.cpp" line="459"/>
<source>List of ignored hosts. more than one entry, please separate with english semicolon(;)</source>
<translation> (;)</translation>
</message>
<message>
<location filename="../proxy.cpp" line="462"/>
<source>Apt Proxy</source>
<translation>APT </translation>
<extra-contents_path>/Proxy/Apt Proxy</extra-contents_path>
</message>
<message>
<location filename="../proxy.cpp" line="463"/>
<location filename="../proxy.cpp" line="984"/>
<source>Open</source>
<translation></translation>
</message>
<message>
<location filename="../proxy.cpp" line="464"/>
<source>Server Address : </source>
<translation> </translation>
</message>
<message>
<location filename="../proxy.cpp" line="465"/>
<source>Port : </source>
<translation> </translation>
</message>
<message>
<location filename="../proxy.cpp" line="466"/>
<source>Edit</source>
<translation></translation>
</message>
<message>
<location filename="../proxy.cpp" line="564"/>
<source>The apt proxy has been turned off and needs to be restarted to take effect</source>
<translation></translation>
</message>
<message>
<location filename="../proxy.cpp" line="565"/>
<location filename="../proxy.cpp" line="797"/>
<source>Reboot Later</source>
<translation></translation>
</message>
<message>
<location filename="../proxy.cpp" line="566"/>
<location filename="../proxy.cpp" line="798"/>
<source>Reboot Now</source>
<translation></translation>
</message>
<message>
<location filename="../proxy.cpp" line="796"/>
<source>The system needs to be restarted to set the Apt proxy, whether to reboot</source>
<translation>Aptཡི </translation>
</message>
<message>
<location filename="../proxy.cpp" line="996"/>
<source>Proxy type</source>
<translation></translation>
</message>
<message>
<source>HTTP</source>
<translation type="vanished">HTTP</translation>
</message>
<message>
<source>socks4</source>
<translation type="vanished">4</translation>
</message>
<message>
<source>socks5</source>
<translation type="vanished">5</translation>
</message>
<message>
<location filename="../proxy.cpp" line="1013"/>
<source>IP address</source>
<translation>IPས</translation>
</message>
<message>
<location filename="../proxy.cpp" line="1019"/>
<location filename="../proxy.cpp" line="1050"/>
<source>Required</source>
<translation></translation>
</message>
<message>
<location filename="../proxy.cpp" line="1040"/>
<source>Invalid IP Address</source>
<translation>IPས</translation>
</message>
<message>
<location filename="../proxy.cpp" line="1061"/>
<source>Username</source>
<translation></translation>
</message>
<message>
<location filename="../proxy.cpp" line="1064"/>
<location filename="../proxy.cpp" line="1078"/>
<source>Optional</source>
<translation></translation>
</message>
<message>
<location filename="../proxy.cpp" line="1074"/>
<source>Password</source>
<translation></translation>
</message>
<message>
<location filename="../proxy.cpp" line="1097"/>
<source>Cancel</source>
<translation></translation>
</message>
<message>
<location filename="../proxy.cpp" line="1098"/>
<source>Save</source>
<translation></translation>
</message>
<message>
<location filename="../proxy.cpp" line="1160"/>
<source>The following applications are allowed to use this configuration:</source>
<translation></translation>
</message>
</context>
</TS>

View File

@ -0,0 +1,215 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1">
<context>
<name>AptProxyDialog</name>
<message>
<location filename="../aptproxydialog.cpp" line="24"/>
<source>Set Apt Proxy</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../aptproxydialog.cpp" line="41"/>
<source>Server Address</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../aptproxydialog.cpp" line="59"/>
<source>Port</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../aptproxydialog.cpp" line="80"/>
<source>Cancel</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../aptproxydialog.cpp" line="84"/>
<source>Confirm</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>Proxy</name>
<message>
<location filename="../proxy.cpp" line="63"/>
<source>Proxy</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../proxy.cpp" line="194"/>
<source>Start using</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../proxy.cpp" line="207"/>
<source>Proxy mode</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../proxy.cpp" line="211"/>
<source>Auto</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../proxy.cpp" line="214"/>
<source>Manual</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../proxy.cpp" line="369"/>
<source>Application Proxy</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../proxy.cpp" line="444"/>
<source>System Proxy</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../proxy.cpp" line="446"/>
<source>Auto url</source>
<translation type="unfinished"></translation>
<extra-contents_path>/Proxy/Auto url</extra-contents_path>
</message>
<message>
<location filename="../proxy.cpp" line="448"/>
<source>Http Proxy</source>
<translation type="unfinished"></translation>
<extra-contents_path>/Proxy/Http Proxy</extra-contents_path>
</message>
<message>
<location filename="../proxy.cpp" line="450"/>
<source>Https Proxy</source>
<translation type="unfinished"></translation>
<extra-contents_path>/Proxy/Https Proxy</extra-contents_path>
</message>
<message>
<location filename="../proxy.cpp" line="452"/>
<source>Ftp Proxy</source>
<translation type="unfinished"></translation>
<extra-contents_path>/Proxy/Ftp Proxy</extra-contents_path>
</message>
<message>
<location filename="../proxy.cpp" line="454"/>
<source>Socks Proxy</source>
<translation type="unfinished"></translation>
<extra-contents_path>/Proxy/Socks Proxy</extra-contents_path>
</message>
<message>
<location filename="../proxy.cpp" line="455"/>
<location filename="../proxy.cpp" line="456"/>
<location filename="../proxy.cpp" line="457"/>
<location filename="../proxy.cpp" line="458"/>
<location filename="../proxy.cpp" line="1047"/>
<source>Port</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../proxy.cpp" line="459"/>
<source>List of ignored hosts. more than one entry, please separate with english semicolon(;)</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../proxy.cpp" line="462"/>
<source>Apt Proxy</source>
<translation type="unfinished"></translation>
<extra-contents_path>/Proxy/Apt Proxy</extra-contents_path>
</message>
<message>
<location filename="../proxy.cpp" line="463"/>
<location filename="../proxy.cpp" line="984"/>
<source>Open</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../proxy.cpp" line="464"/>
<source>Server Address : </source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../proxy.cpp" line="465"/>
<source>Port : </source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../proxy.cpp" line="466"/>
<source>Edit</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../proxy.cpp" line="564"/>
<source>The apt proxy has been turned off and needs to be restarted to take effect</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../proxy.cpp" line="565"/>
<location filename="../proxy.cpp" line="797"/>
<source>Reboot Later</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../proxy.cpp" line="566"/>
<location filename="../proxy.cpp" line="798"/>
<source>Reboot Now</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../proxy.cpp" line="796"/>
<source>The system needs to be restarted to set the Apt proxy, whether to reboot</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../proxy.cpp" line="996"/>
<source>Proxy type</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../proxy.cpp" line="1013"/>
<source>IP address</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../proxy.cpp" line="1019"/>
<location filename="../proxy.cpp" line="1050"/>
<source>Required</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../proxy.cpp" line="1040"/>
<source>Invalid IP Address</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../proxy.cpp" line="1061"/>
<source>Username</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../proxy.cpp" line="1064"/>
<location filename="../proxy.cpp" line="1078"/>
<source>Optional</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../proxy.cpp" line="1074"/>
<source>Password</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../proxy.cpp" line="1097"/>
<source>Cancel</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../proxy.cpp" line="1098"/>
<source>Save</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../proxy.cpp" line="1160"/>
<source>The following applications are allowed to use this configuration:</source>
<translation type="unfinished"></translation>
</message>
</context>
</TS>

Binary file not shown.

View File

@ -0,0 +1,215 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1" language="zh_CN">
<context>
<name>AptProxyDialog</name>
<message>
<location filename="../aptproxydialog.cpp" line="24"/>
<source>Set Apt Proxy</source>
<translation>APT代理</translation>
</message>
<message>
<location filename="../aptproxydialog.cpp" line="41"/>
<source>Server Address</source>
<translation></translation>
</message>
<message>
<location filename="../aptproxydialog.cpp" line="59"/>
<source>Port</source>
<translation></translation>
</message>
<message>
<location filename="../aptproxydialog.cpp" line="80"/>
<source>Cancel</source>
<translation></translation>
</message>
<message>
<location filename="../aptproxydialog.cpp" line="84"/>
<source>Confirm</source>
<translation></translation>
</message>
</context>
<context>
<name>Proxy</name>
<message>
<location filename="../proxy.cpp" line="63"/>
<source>Proxy</source>
<translation></translation>
</message>
<message>
<location filename="../proxy.cpp" line="194"/>
<source>Start using</source>
<translation></translation>
</message>
<message>
<location filename="../proxy.cpp" line="207"/>
<source>Proxy mode</source>
<translation></translation>
</message>
<message>
<location filename="../proxy.cpp" line="211"/>
<source>Auto</source>
<translation></translation>
</message>
<message>
<location filename="../proxy.cpp" line="214"/>
<source>Manual</source>
<translation></translation>
</message>
<message>
<location filename="../proxy.cpp" line="369"/>
<source>Application Proxy</source>
<translation></translation>
</message>
<message>
<location filename="../proxy.cpp" line="444"/>
<source>System Proxy</source>
<translation></translation>
</message>
<message>
<location filename="../proxy.cpp" line="446"/>
<source>Auto url</source>
<translation>URL</translation>
<extra-contents_path>/Proxy/Auto url</extra-contents_path>
</message>
<message>
<location filename="../proxy.cpp" line="448"/>
<source>Http Proxy</source>
<translation>HTTP代理</translation>
<extra-contents_path>/Proxy/Http Proxy</extra-contents_path>
</message>
<message>
<location filename="../proxy.cpp" line="450"/>
<source>Https Proxy</source>
<translation>HTTPS代理</translation>
<extra-contents_path>/Proxy/Https Proxy</extra-contents_path>
</message>
<message>
<location filename="../proxy.cpp" line="452"/>
<source>Ftp Proxy</source>
<translation>FTP代理</translation>
<extra-contents_path>/Proxy/Ftp Proxy</extra-contents_path>
</message>
<message>
<location filename="../proxy.cpp" line="454"/>
<source>Socks Proxy</source>
<translation>SOCKS代理</translation>
<extra-contents_path>/Proxy/Socks Proxy</extra-contents_path>
</message>
<message>
<location filename="../proxy.cpp" line="455"/>
<location filename="../proxy.cpp" line="456"/>
<location filename="../proxy.cpp" line="457"/>
<location filename="../proxy.cpp" line="458"/>
<location filename="../proxy.cpp" line="1047"/>
<source>Port</source>
<translation></translation>
</message>
<message>
<location filename="../proxy.cpp" line="459"/>
<source>List of ignored hosts. more than one entry, please separate with english semicolon(;)</source>
<translation>使;</translation>
</message>
<message>
<location filename="../proxy.cpp" line="462"/>
<source>Apt Proxy</source>
<translation>APT代理</translation>
<extra-contents_path>/Proxy/Apt Proxy</extra-contents_path>
</message>
<message>
<location filename="../proxy.cpp" line="463"/>
<location filename="../proxy.cpp" line="984"/>
<source>Open</source>
<translation></translation>
</message>
<message>
<location filename="../proxy.cpp" line="464"/>
<source>Server Address : </source>
<translation> </translation>
</message>
<message>
<location filename="../proxy.cpp" line="465"/>
<source>Port : </source>
<translation> </translation>
</message>
<message>
<location filename="../proxy.cpp" line="466"/>
<source>Edit</source>
<translation></translation>
</message>
<message>
<location filename="../proxy.cpp" line="564"/>
<source>The apt proxy has been turned off and needs to be restarted to take effect</source>
<translation>APT代理已关闭</translation>
</message>
<message>
<location filename="../proxy.cpp" line="565"/>
<location filename="../proxy.cpp" line="797"/>
<source>Reboot Later</source>
<translation></translation>
</message>
<message>
<location filename="../proxy.cpp" line="566"/>
<location filename="../proxy.cpp" line="798"/>
<source>Reboot Now</source>
<translation></translation>
</message>
<message>
<location filename="../proxy.cpp" line="796"/>
<source>The system needs to be restarted to set the Apt proxy, whether to reboot</source>
<translation>APT代理需要重启系统后生效</translation>
</message>
<message>
<location filename="../proxy.cpp" line="996"/>
<source>Proxy type</source>
<translation></translation>
</message>
<message>
<location filename="../proxy.cpp" line="1013"/>
<source>IP address</source>
<translation>IP地址</translation>
</message>
<message>
<location filename="../proxy.cpp" line="1019"/>
<location filename="../proxy.cpp" line="1050"/>
<source>Required</source>
<translation></translation>
</message>
<message>
<location filename="../proxy.cpp" line="1040"/>
<source>Invalid IP Address</source>
<translation>IP地址</translation>
</message>
<message>
<location filename="../proxy.cpp" line="1061"/>
<source>Username</source>
<translation></translation>
</message>
<message>
<location filename="../proxy.cpp" line="1064"/>
<location filename="../proxy.cpp" line="1078"/>
<source>Optional</source>
<translation></translation>
</message>
<message>
<location filename="../proxy.cpp" line="1074"/>
<source>Password</source>
<translation></translation>
</message>
<message>
<location filename="../proxy.cpp" line="1097"/>
<source>Cancel</source>
<translation></translation>
</message>
<message>
<location filename="../proxy.cpp" line="1098"/>
<source>Save</source>
<translation></translation>
</message>
<message>
<location filename="../proxy.cpp" line="1160"/>
<source>The following applications are allowed to use this configuration:</source>
<translation>使</translation>
</message>
</context>
</TS>

View File

@ -173,6 +173,7 @@ QWidget *WlanConnect::pluginUi() {
if(!m_interface->isValid()) {
qWarning() << qPrintable(QDBusConnection::sessionBus().lastError().message());
}
initSearchText();
initComponent();
}
return pluginWidget;
@ -238,8 +239,10 @@ bool WlanConnect::eventFilter(QObject *w, QEvent *e) {
void WlanConnect::initComponent() {
m_wifiSwitch = new KSwitchButton(pluginWidget);
ui->openWIifLayout->addWidget(m_wifiSwitch);
ui->openWIifLayout->setContentsMargins(0,0,8,0);
ui->detailLayOut_3->setContentsMargins(MAIN_LAYOUT_MARGINS);
ui->verticalLayout_3->setContentsMargins(NO_MARGINS);
ui->verticalLayout_3->setSpacing(8);
ui->availableLayout->setSpacing(SPACING);
m_wifiSwitch->installEventFilter(this);

View File

@ -149,6 +149,25 @@ KyConnectItem * KyConnectResourse::getConnectionItemByUuid(QString connectUuid)
return nullptr;
}
KyConnectItem * KyConnectResourse::getConnectionItemByUuidWithoutActivateChecking(QString connectUuid)
{
NetworkManager::Connection::Ptr connectPtr =
m_networkResourceInstance->getConnect(connectUuid);
if (nullptr == connectPtr) {
qWarning()<< "[KyConnectResourse]" <<"get connect failed, connect uuid"<<connectUuid;
return nullptr;
}
KyConnectItem *connectItem = getConnectionItem(connectPtr, "");
if (nullptr != connectItem) {
//connectItem->dumpInfo();
return connectItem;
}
return nullptr;
}
KyConnectItem * KyConnectResourse::getConnectionItemByUuid(QString connectUuid, QString deviceName)
{
NetworkManager::Connection::Ptr connectPtr =

View File

@ -38,6 +38,7 @@ public:
public:
KyConnectItem *getConnectionItemByUuid(QString connectUuid);
KyConnectItem *getConnectionItemByUuidWithoutActivateChecking(QString connectUuid);
KyConnectItem *getConnectionItemByUuid(QString connectUuid, QString deviceName);
void getConnectionList(QString deviceName,
NetworkManager::ConnectionSettings::ConnectionType connectionType,

View File

@ -147,6 +147,18 @@ void DbusAdaptor::setDeviceEnable(QString devName, bool enable)
// return deviceName;
//}
//删除
void DbusAdaptor::deleteConnect(int type, QString ssid)
{
if (type == WIRED) {
parent()->deleteWired(ssid);
} else if (type == WIRELESS) {
//待实现
} else {
qDebug() << "[DbusAdaptor] deleteConnect type is invalid";
}
}
//连接 根据网卡类型 参数1 0:lan 1:wlan 参数3 为ssid/uuid
void DbusAdaptor::activateConnect(int type, QString devName, QString ssid)
{

View File

@ -62,6 +62,8 @@ public Q_SLOTS: // METHODS
// QString getDefaultWiredDevice();
// Q_NOREPLY void setDefaultWirelessDevice(QString deviceName);
// QString getDefaultWirelessDevice();
//刪除 根据网络名称 参数1 0:lan 1:wlan 参数2 为ssid/uuid
Q_NOREPLY void deleteConnect(int type, QString ssid);
//连接 根据网卡类型 参数1 0:lan 1:wlan 参数3 为ssid/uuid
Q_NOREPLY void activateConnect(int type, QString devName, QString ssid);
//断开连接 根据网卡类型 参数1 0:lan 1:wlan 参数3 为ssid/uuid

View File

@ -22,7 +22,7 @@
#define MAIN_LAYOUT_MARGINS 0,0,0,0
#define MAIN_LAYOUT_SPACING 0
#define ITEM_FRAME_MARGINS 12,4,16,4
#define ITEM_FRAME_MARGINS 12,6,16,6
#define ITEM_FRAME_SPACING 8
#define FRAME_WIDTH 404

View File

@ -43,6 +43,10 @@
const QString v10Sp1 = "V10SP1";
const QString intel = "V10SP1-edu";
#define LANPAGE 0
#define WLANPAGE 1
#define AUTOSELET 2
#define KEY_PRODUCT_FEATURES "PRODUCT_FEATURES"
#include <kwindowsystem.h>
@ -257,6 +261,7 @@ void MainWindow::initUI()
m_centralWidget = new QTabWidget(this);
this->setCentralWidget(m_centralWidget);
m_centralWidget->tabBar()->setFixedWidth(this->width()+1);
m_centralWidget->tabBar()->setProperty("setRadius", 12);
// m_centralWidget->tabBar()->setStyleSheet("QTabBar::tab{min-height:40px}");
m_lanWidget = new LanPage(m_centralWidget);
m_wlanWidget = new WlanPage(m_centralWidget);
@ -645,10 +650,16 @@ void MainWindow::onTabletModeChanged(bool mode)
void MainWindow::onShowMainWindow(int type)
{
m_centralWidget->setCurrentIndex(type);
if (type == LANPAGE || type == WLANPAGE) {
m_centralWidget->setCurrentIndex(type);
if(QApplication::activeWindow() != this) {
this->showMainwindow();
if(QApplication::activeWindow() != this) {
this->showMainwindow();
}
} else if (type == AUTOSELET) {
onTrayIconActivated(QSystemTrayIcon::ActivationReason::Trigger);
} else {
qWarning() << "unsupport parameter";
}
}
@ -868,6 +879,12 @@ void MainWindow::getWirelessDeviceCap(QMap<QString, int> &map)
m_wlanWidget->getWirelessDeviceCap(map);
}
//有线连接删除
void MainWindow::deleteWired(const QString &connUuid)
{
m_lanWidget->deleteWired(connUuid);
}
//有线连接断开
void MainWindow::activateWired(const QString& devName, const QString& connUuid)
{

View File

@ -81,6 +81,8 @@ public:
void getApConnectionPath(QString &path, QString uuid);
//获取热点ActivePath
void getActiveConnectionPath(QString &path, QString uuid);
//删除有线连接
void deleteWired(const QString& connUuid);
//有线连接断开
void activateWired(const QString& devName, const QString& connUuid);
void deactivateWired(const QString& devName, const QString& connUuid);

View File

@ -93,6 +93,7 @@ public:
QString strIPV4FirDns;
QString strIPV4SecDns;
QString strIPV4GateWay;
QList<QHostAddress> ipv4DnsList;
KyIpConfigType ipv6ConfigType = CONFIG_IP_DHCP;
QString strIPV6Address;
@ -100,6 +101,7 @@ public:
QString strIPV6FirDns;
QString strIPV6SecDns;
QString strIPV6GateWay;
QList<QHostAddress> ipv6DnsList;
KyEapMethodType enterpriseType;
KyEapMethodTlsInfo tlsInfo;

View File

@ -36,46 +36,49 @@ void CreatNetPage::initUI()
ipv4addressEdit = new LineEdit(this);
netMaskEdit = new LineEdit(this);
gateWayEdit = new LineEdit(this);
firstDnsEdit = new LineEdit(this);
secondDnsEdit = new LineEdit(this);
// firstDnsEdit = new LineEdit(this);
// secondDnsEdit = new LineEdit(this);
m_connNameLabel = new QLabel(this);
m_configLabel = new QLabel(this);
m_addressLabel = new QLabel(this);
m_maskLabel = new QLabel(this);
m_gateWayLabel = new QLabel(this);
m_dnsLabel = new QLabel(this);
m_secDnsLabel = new QLabel(this);
// m_dnsLabel = new QLabel(this);
// m_secDnsLabel = new QLabel(this);
// IP的正则格式限制
QRegExp rx("\\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\b");
m_dnsWidget = new MultipleDnsWidget(rx, this);
m_connNameLabel->setText(tr("Connection Name"));
m_configLabel->setText(tr("IPv4Config"));
m_addressLabel->setText(tr("Address"));
m_maskLabel->setText(tr("Netmask"));
m_gateWayLabel->setText(tr("Default Gateway"));
m_dnsLabel->setText(tr("Prefs DNS"));
m_secDnsLabel->setText(tr("Alternative DNS"));
// m_dnsLabel->setText(tr("Prefs DNS"));
// m_secDnsLabel->setText(tr("Alternative DNS"));
m_detailLayout = new QFormLayout(this);
m_detailLayout->setContentsMargins(0, 0, 0, 0);
m_detailLayout->setSpacing(24);
m_detailLayout->addRow(m_connNameLabel,connNameEdit);
m_detailLayout->addRow(m_configLabel,ipv4ConfigCombox);
m_detailLayout->addRow(m_addressLabel,ipv4addressEdit);
m_detailLayout->addRow(m_maskLabel,netMaskEdit);
m_detailLayout->addRow(m_gateWayLabel,gateWayEdit);
m_detailLayout->addRow(m_dnsLabel,firstDnsEdit);
m_detailLayout->addRow(m_secDnsLabel,secondDnsEdit);
// m_detailLayout->addRow(m_dnsLabel,firstDnsEdit);
// m_detailLayout->addRow(m_secDnsLabel,secondDnsEdit);
m_detailLayout->addRow(m_dnsWidget);
ipv4ConfigCombox->addItem(tr("Auto(DHCP)"), AUTO_CONFIG); //"自动(DHCP)"
ipv4ConfigCombox->addItem(tr("Manual"), MANUAL_CONFIG); //"手动"
// IP的正则格式限制
QRegExp rx("\\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\b");
ipv4addressEdit->setValidator(new QRegExpValidator(rx, this));
gateWayEdit->setValidator(new QRegExpValidator(rx, this));
netMaskEdit->setValidator(new QRegExpValidator(rx, this));
firstDnsEdit->setValidator(new QRegExpValidator(rx, this));
secondDnsEdit->setValidator(new QRegExpValidator(rx, this));
// firstDnsEdit->setValidator(new QRegExpValidator(rx, this));
// secondDnsEdit->setValidator(new QRegExpValidator(rx, this));
}
void CreatNetPage::initComponent() {
@ -90,8 +93,14 @@ void CreatNetPage::initComponent() {
connect(ipv4ConfigCombox, SIGNAL(currentIndexChanged(int)), this, SLOT(setEnableOfSaveBtn()));
connect(netMaskEdit, SIGNAL(textChanged(QString)), this, SLOT(setEnableOfSaveBtn()));
connect(gateWayEdit, SIGNAL(textChanged(QString)), this, SLOT(setEnableOfSaveBtn()));
connect(firstDnsEdit, SIGNAL(textChanged(QString)), this, SLOT(setEnableOfSaveBtn()));
connect(secondDnsEdit, SIGNAL(textChanged(QString)), this, SLOT(setEnableOfSaveBtn()));
// connect(firstDnsEdit, SIGNAL(textChanged(QString)), this, SLOT(setEnableOfSaveBtn()));
// connect(secondDnsEdit, SIGNAL(textChanged(QString)), this, SLOT(setEnableOfSaveBtn()));
connect(m_dnsWidget, &MultipleDnsWidget::dnsTextChanged, this, [=]() {
setCreatePageState(false);
});
connect(m_dnsWidget, &MultipleDnsWidget::dnsEditingFinished, this, [=]() {
setCreatePageState(true);
});
}
bool CreatNetPage::checkConnectBtnIsEnabled()
@ -113,7 +122,7 @@ bool CreatNetPage::checkConnectBtnIsEnabled()
qDebug() << "create ipv4 netMask empty or invalid";
return false;
}
#if 0
if (gateWayEdit->text().isEmpty() || !getTextEditState(gateWayEdit->text())) {
qDebug() << "create ipv4 gateway empty or invalid";
return false;
@ -133,6 +142,8 @@ bool CreatNetPage::checkConnectBtnIsEnabled()
qDebug() << "create ipv4 second dns invalid";
return false;
}
#endif
}
return true;
}
@ -151,15 +162,22 @@ void CreatNetPage::setLineEnabled(bool check) {
ipv4addressEdit->setEnabled(check);
netMaskEdit->setEnabled(check);
gateWayEdit->setEnabled(check);
firstDnsEdit->setEnabled(check);
secondDnsEdit->setEnabled(check);
// firstDnsEdit->setEnabled(check);
// secondDnsEdit->setEnabled(check);
m_dnsWidget->setEditEnabled(check);
if (!check) {
ipv4addressEdit->clear();
netMaskEdit->clear();
gateWayEdit->clear();
firstDnsEdit->clear();
secondDnsEdit->clear();
// firstDnsEdit->clear();
// secondDnsEdit->clear();
ipv4addressEdit->setPlaceholderText(" ");
netMaskEdit->setPlaceholderText(" ");
} else {
ipv4addressEdit->setPlaceholderText(tr("Required")); //必填
netMaskEdit->setPlaceholderText(tr("Required")); //必填
}
}
@ -191,13 +209,23 @@ void CreatNetPage::constructIpv4Info(KyConnectSetting &setting)
<< " gateWay " << gateWay;
QStringList dnsList;
dnsList.empty();
dnsList.clear();
#if 0
if (!firstDnsEdit->text().isEmpty()) {
dnsList << firstDnsEdit->text();
if (!secondDnsEdit->text().isEmpty()) {
dnsList << secondDnsEdit->text();
}
}
#endif
QList<QHostAddress> ipv4dnsList;
ipv4dnsList.clear();
ipv4dnsList = m_dnsWidget->getDns();
for (QHostAddress str: ipv4dnsList) {
dnsList << str.toString();
}
if (ipv4ConfigCombox->currentData() == AUTO_CONFIG) {
setting.setIpConfigType(IPADDRESS_V4, CONFIG_IP_DHCP);
} else {

View File

@ -32,6 +32,7 @@
#include <QDebug>
#include "coninfo.h"
#include "multiplednswidget.h"
class CreatNetPage : public QFrame
{
@ -46,10 +47,9 @@ private:
LineEdit *ipv4addressEdit;
LineEdit *netMaskEdit;
LineEdit *gateWayEdit;
LineEdit *firstDnsEdit;
LineEdit *secondDnsEdit;
// LineEdit *firstDnsEdit;
// LineEdit *secondDnsEdit;
private:
QFormLayout *m_detailLayout;
QVBoxLayout *mvBoxLayout;
QLabel *m_connNameLabel;
@ -57,8 +57,10 @@ private:
QLabel *m_addressLabel;
QLabel *m_maskLabel;
QLabel *m_gateWayLabel;
QLabel *m_dnsLabel;
QLabel *m_secDnsLabel;
// QLabel *m_dnsLabel;
// QLabel *m_secDnsLabel;
MultipleDnsWidget *m_dnsWidget = nullptr;
private:
void initUI();
void initComponent();

View File

@ -23,6 +23,7 @@
#define MAX_NAME_LENGTH 32
#define MAX_LABEL_WIDTH 250
#define MAX_SSID_WIDTH 133
extern void qt_blurImage(QImage &blurImage, qreal radius, bool quality, int transposed);
@ -50,10 +51,10 @@ void DetailPage::setSSID(const QString &ssid) {
return;
}
m_formerSSID = ssid;
QFontMetrics fontMetrics(this->font());
QFontMetrics fontMetrics(m_SSIDLabel->font());
int fontSize = fontMetrics.width(ssid);
if (fontSize > this->width()) {
this->m_SSIDLabel->setText(fontMetrics.elidedText(ssid, Qt::ElideRight, this->width()));
if (fontSize > MAX_SSID_WIDTH) {
this->m_SSIDLabel->setText(fontMetrics.elidedText(ssid, Qt::ElideRight, MAX_SSID_WIDTH));
this->setToolTip(ssid);
} else {
this->m_SSIDLabel->setText(ssid);

View File

@ -33,11 +33,13 @@ FixLabel::FixLabel(QWidget *parent) :
{
const QByteArray id("org.ukui.style");
QGSettings * fontSetting = new QGSettings(id, QByteArray(), this);
connect(fontSetting, &QGSettings::changed,[=](QString key) {
if ("systemFont" == key || "systemFontSize" ==key) {
changedLabelSlot();
}
});
if(QGSettings::isSchemaInstalled(id)){
connect(fontSetting, &QGSettings::changed,[=](QString key) {
if ("systemFont" == key || "systemFontSize" ==key) {
changedLabelSlot();
}
});
}
}

View File

@ -39,15 +39,15 @@ void Ipv4Page::initUI() {
ipv4addressEdit = new LineEdit(this);
netMaskEdit = new LineEdit(this);
gateWayEdit = new LineEdit(this);
firstDnsEdit = new LineEdit(this);
secondDnsEdit = new LineEdit(this);
// firstDnsEdit = new LineEdit(this);
// secondDnsEdit = new LineEdit(this);
m_configLabel = new QLabel(this);
m_addressLabel = new QLabel(this);
m_maskLabel = new QLabel(this);
m_gateWayLabel = new QLabel(this);
m_dnsLabel = new QLabel(this);
m_secDnsLabel = new QLabel(this);
// m_dnsLabel = new QLabel(this);
// m_secDnsLabel = new QLabel(this);
m_configEmptyLabel = new QLabel(this);
m_configEmptyLabel->setFixedHeight(LABEL_HEIGHT);
@ -64,16 +64,12 @@ void Ipv4Page::initUI() {
m_gateWayEmptyLabel = new QLabel(this);
m_gateWayEmptyLabel->setFixedHeight(LABEL_HEIGHT);
m_firstDnsEmptyLabel = new QLabel(this);
m_firstDnsEmptyLabel->setFixedHeight(LABEL_HEIGHT);
m_configLabel->setText(tr("IPv4Config"));
m_addressLabel->setText(tr("Address"));
m_maskLabel->setText(tr("Netmask"));
m_gateWayLabel->setText(tr("Default Gateway"));
m_dnsLabel->setText(tr("Prefs DNS"));
m_secDnsLabel->setText(tr("Alternative DNS"));
// m_dnsLabel->setText(tr("Prefs DNS"));
// m_secDnsLabel->setText(tr("Alternative DNS"));
m_statusLabel = new QLabel(this);
m_statusLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
@ -100,6 +96,10 @@ void Ipv4Page::initUI() {
maskLayout->addWidget(netMaskEdit);
maskLayout->addWidget(m_maskHintLabel);
// IP的正则格式限制
QRegExp rx("\\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\b");
m_dnsWidget = new MultipleDnsWidget(rx, this);
m_detailLayout = new QFormLayout(this);
m_detailLayout->setVerticalSpacing(0);
m_detailLayout->setContentsMargins(LAYOUT_MARGINS);
@ -109,9 +109,9 @@ void Ipv4Page::initUI() {
m_detailLayout->addRow(m_maskLabel,maskWidget);
m_detailLayout->addRow(m_gateWayLabel,gateWayEdit);
m_detailLayout->addRow(m_gateWayEmptyLabel);
m_detailLayout->addRow(m_dnsLabel,firstDnsEdit);
m_detailLayout->addRow(m_firstDnsEmptyLabel);
m_detailLayout->addRow(m_secDnsLabel,secondDnsEdit);
// m_detailLayout->addRow(m_dnsLabel,firstDnsEdit);
// m_detailLayout->addRow(m_secDnsLabel,secondDnsEdit);
m_detailLayout->addRow(m_dnsWidget);
ipv4ConfigCombox->addItem(tr("Auto(DHCP)")); //"自动(DHCP)"
ipv4ConfigCombox->addItem(tr("Manual")); //"手动"
@ -124,14 +124,11 @@ void Ipv4Page::initUI() {
// netMaskCombox->addItem("255.0.0.0"); //8
// IP的正则格式限制
QRegExp rx("\\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\b");
ipv4addressEdit->setValidator(new QRegExpValidator(rx, this));
gateWayEdit->setValidator(new QRegExpValidator(rx, this));
netMaskEdit->setValidator(new QRegExpValidator(rx, this));
firstDnsEdit->setValidator(new QRegExpValidator(rx, this));
secondDnsEdit->setValidator(new QRegExpValidator(rx, this));
// firstDnsEdit->setValidator(new QRegExpValidator(rx, this));
// secondDnsEdit->setValidator(new QRegExpValidator(rx, this));
initLoadingIcon();
}
@ -152,8 +149,14 @@ void Ipv4Page::initComponent() {
connect(ipv4addressEdit, SIGNAL(textChanged(QString)), this, SLOT(setEnableOfSaveBtn()));
connect(netMaskEdit, SIGNAL(textChanged(QString)), this, SLOT(setEnableOfSaveBtn()));
connect(gateWayEdit, SIGNAL(textChanged(QString)), this, SLOT(setEnableOfSaveBtn()));
connect(firstDnsEdit, SIGNAL(textChanged(QString)), this, SLOT(setEnableOfSaveBtn()));
connect(secondDnsEdit, SIGNAL(textChanged(QString)), this, SLOT(setEnableOfSaveBtn()));
// connect(firstDnsEdit, SIGNAL(textChanged(QString)), this, SLOT(setEnableOfSaveBtn()));
// connect(secondDnsEdit, SIGNAL(textChanged(QString)), this, SLOT(setEnableOfSaveBtn()));
connect(m_dnsWidget, &MultipleDnsWidget::dnsTextChanged, this, [=]() {
setIpv4PageState(false);
});
connect(m_dnsWidget, &MultipleDnsWidget::dnsEditingFinished, this, [=]() {
setIpv4PageState(true);
});
}
void Ipv4Page::setIpv4Config(KyIpConfigType ipv4Config)
@ -175,6 +178,12 @@ void Ipv4Page::setNetMask(const QString &netMask)
netMaskEdit->setText(netMask);
}
void Ipv4Page::setMulDns(const QList<QHostAddress> &dns)
{
m_dnsWidget->setDnsListText(dns);
}
#if 0
void Ipv4Page::setIpv4FirDns(const QString &ipv4FirDns)
{
firstDnsEdit->setText(ipv4FirDns);
@ -184,6 +193,7 @@ void Ipv4Page::setIpv4SecDns(const QString &ipv4SecDns)
{
secondDnsEdit->setText(ipv4SecDns);
}
#endif
void Ipv4Page::setGateWay(const QString &gateWay)
{
@ -213,22 +223,32 @@ bool Ipv4Page::checkIsChanged(const ConInfo info, KyConnectSetting &setting)
isChanged = true;
}
qDebug() << "ipv4 netmask " << getNetMaskText(netMaskEdit->text());
QList<QHostAddress> ipv4dnsList;
ipv4dnsList.clear();
ipv4dnsList = m_dnsWidget->getDns();
if(info.strIPV4Address != ipv4addressEdit->text()
|| info.strIPV4NetMask != /*netMaskEdit->text()*/getNetMaskText(netMaskEdit->text())
|| info.strIPV4GateWay != gateWayEdit->text()
|| info.strIPV4FirDns != firstDnsEdit->text()
|| info.strIPV4SecDns != secondDnsEdit->text()) {
// || info.strIPV4FirDns != firstDnsEdit->text()
// || info.strIPV4SecDns != secondDnsEdit->text()
|| info.ipv4DnsList != ipv4dnsList) {
qDebug() << "ipv4 info changed";
QStringList dnsList;
dnsList.empty();
dnsList.clear();
for (QHostAddress str: ipv4dnsList) {
dnsList << str.toString();
}
#if 0
if (!firstDnsEdit->text().isEmpty()) {
dnsList << firstDnsEdit->text();
if (!secondDnsEdit->text().isEmpty()) {
dnsList << secondDnsEdit->text();
}
}
#endif
QString ipv4address =ipv4addressEdit->text();
QString netMask = getNetMaskText(netMaskEdit->text());
QString gateWay = gateWayEdit->text();
@ -261,7 +281,7 @@ bool Ipv4Page::checkConnectBtnIsEnabled()
// qDebug() << "ipv4 gateway empty or invalid";
// return false;
// }
#if 0
if (firstDnsEdit->text().isEmpty() && !secondDnsEdit->text().isEmpty()) {
qDebug() << "ipv4 dns sort invalid";
return false;
@ -276,6 +296,8 @@ bool Ipv4Page::checkConnectBtnIsEnabled()
qDebug() << "ipv4 second dns invalid";
return false;
}
#endif
}
return true;
}
@ -325,8 +347,8 @@ void Ipv4Page::setLineEnabled(bool check) {
ipv4addressEdit->clear();
netMaskEdit->clear();
gateWayEdit->clear();
firstDnsEdit->clear();
secondDnsEdit->clear();
// firstDnsEdit->clear();
// secondDnsEdit->clear();
ipv4addressEdit->setPlaceholderText(" ");
netMaskEdit->setPlaceholderText(" ");
@ -339,8 +361,9 @@ void Ipv4Page::setLineEnabled(bool check) {
ipv4addressEdit->setEnabled(check);
netMaskEdit->setEnabled(check);
gateWayEdit->setEnabled(check);
firstDnsEdit->setEnabled(check);
secondDnsEdit->setEnabled(check);
// firstDnsEdit->setEnabled(check);
// secondDnsEdit->setEnabled(check);
m_dnsWidget->setEditEnabled(check);
}
void Ipv4Page::setEnableOfSaveBtn() {

View File

@ -33,6 +33,7 @@
//#include "kylinconnectsetting.h"
#include "coninfo.h"
#include "multiplednswidget.h"
class Ipv4Page : public QFrame
{
@ -42,8 +43,9 @@ public:
void setIpv4Config(KyIpConfigType ipv4Config);
void setIpv4(const QString &ipv4);
void setNetMask(const QString &netMask);
void setIpv4FirDns(const QString &ipv4FirDns);
void setIpv4SecDns(const QString &ipv4SecDns);
// void setIpv4FirDns(const QString &ipv4FirDns);
// void setIpv4SecDns(const QString &ipv4SecDns);
void setMulDns(const QList<QHostAddress> &dns);
void setGateWay(const QString &gateWay);
bool checkIsChanged(const ConInfo info, KyConnectSetting &setting);
@ -57,8 +59,8 @@ private:
LineEdit *ipv4addressEdit;
LineEdit *netMaskEdit;
LineEdit *gateWayEdit;
LineEdit *firstDnsEdit;
LineEdit *secondDnsEdit;
// LineEdit *firstDnsEdit;
// LineEdit *secondDnsEdit;
QFormLayout *m_detailLayout;
QVBoxLayout *mvBoxLayout;
@ -66,14 +68,15 @@ private:
QLabel *m_addressLabel;
QLabel *m_maskLabel;
QLabel *m_gateWayLabel;
QLabel *m_dnsLabel;
QLabel *m_secDnsLabel;
// QLabel *m_dnsLabel;
// QLabel *m_secDnsLabel;
QLabel *m_configEmptyLabel;
QLabel *m_addressHintLabel;
QLabel *m_maskHintLabel;
QLabel *m_gateWayEmptyLabel;
QLabel *m_firstDnsEmptyLabel;
MultipleDnsWidget *m_dnsWidget = nullptr;
QLabel *m_statusLabel = nullptr;
QList<QIcon> m_loadIcons;

View File

@ -52,6 +52,12 @@ void Ipv6Page::setIpv6Perfix(const int &ipv6Perfix)
lengthEdit->setText(QString::number(ipv6Perfix));
}
void Ipv6Page::setMulDns(const QList<QHostAddress> &dns)
{
m_dnsWidget->setDnsListText(dns);
}
#if 0
void Ipv6Page::setIpv6FirDns(const QString &ipv6FirDns)
{
firstDnsEdit->setText(ipv6FirDns);
@ -61,6 +67,7 @@ void Ipv6Page::setIpv6SecDns(const QString &ipv6SecDns)
{
secondDnsEdit->setText(ipv6SecDns);
}
#endif
void Ipv6Page::setGateWay(const QString &gateWay)
{
@ -88,22 +95,31 @@ bool Ipv6Page::checkIsChanged(const ConInfo info, KyConnectSetting &setting)
setting.setIpConfigType(IPADDRESS_V6, CONFIG_IP_MANUAL);
isChanged = true;
}
QList<QHostAddress> ipv6dnsList;
ipv6dnsList.clear();
ipv6dnsList = m_dnsWidget->getDns();
if(info.strIPV6Address != ipv6AddressEdit->text()
|| info.iIPV6Prefix != lengthEdit->text().toInt()
|| info.strIPV6GateWay != gateWayEdit->text()
|| info.strIPV6FirDns != firstDnsEdit->text()
|| info.strIPV6SecDns != secondDnsEdit->text()) {
// || info.strIPV6FirDns != firstDnsEdit->text()
// || info.strIPV6SecDns != secondDnsEdit->text()
|| info.ipv6DnsList != ipv6dnsList) {
qDebug() << "ipv6 info changed";
QStringList dnsList;
dnsList.empty();
dnsList.clear();
for (QHostAddress str: ipv6dnsList) {
dnsList << str.toString();
}
#if 0
if (!firstDnsEdit->text().isEmpty()) {
dnsList << firstDnsEdit->text();
if (!secondDnsEdit->text().isEmpty()) {
dnsList << secondDnsEdit->text();
}
}
#endif
QString ipv6address =ipv6AddressEdit->text();
QString prefix = lengthEdit->text();
QString gateWay = gateWayEdit->text();
@ -120,15 +136,15 @@ void Ipv6Page::initUI() {
ipv6AddressEdit = new LineEdit(this);
lengthEdit = new LineEdit(this);
gateWayEdit = new LineEdit(this);
firstDnsEdit = new LineEdit(this);
secondDnsEdit = new LineEdit(this);
// firstDnsEdit = new LineEdit(this);
// secondDnsEdit = new LineEdit(this);
m_configLabel = new QLabel(this);
m_addressLabel = new QLabel(this);
m_subnetLabel = new QLabel(this);
m_gateWayLabel = new QLabel(this);
m_dnsLabel = new QLabel(this);
m_secDnsLabel = new QLabel(this);
// m_dnsLabel = new QLabel(this);
// m_secDnsLabel = new QLabel(this);
m_configEmptyLabel = new QLabel(this);
m_configEmptyLabel->setFixedHeight(LABEL_HEIGHT);
@ -145,16 +161,12 @@ void Ipv6Page::initUI() {
m_subnetEmptyLabel = new QLabel(this);
m_subnetEmptyLabel->setFixedHeight(LABEL_HEIGHT);
m_firstDnsEmptyLabel = new QLabel(this);
m_firstDnsEmptyLabel->setFixedHeight(LABEL_HEIGHT);
m_configLabel->setText(tr("IPv6Config"));
m_addressLabel->setText(tr("Address"));
m_subnetLabel->setText(tr("Subnet prefix Length"));
m_gateWayLabel->setText(tr("Default Gateway"));
m_dnsLabel->setText(tr("Prefs DNS"));
m_secDnsLabel->setText(tr("Alternative DNS"));
// m_dnsLabel->setText(tr("Prefs DNS"));
// m_secDnsLabel->setText(tr("Alternative DNS"));
m_statusLabel = new QLabel(this);
m_statusLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
@ -181,6 +193,9 @@ void Ipv6Page::initUI() {
gateWayLayout->addWidget(gateWayEdit);
gateWayLayout->addWidget(m_gateWayHintLabel);
QRegExp ipv6_rx("^\\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:)))(%.+)?\\s*$");
m_dnsWidget = new MultipleDnsWidget(ipv6_rx, this);
m_detailLayout = new QFormLayout(this);
m_detailLayout->setContentsMargins(0, 0, 0, 0);
m_detailLayout->setVerticalSpacing(0);
@ -190,18 +205,17 @@ void Ipv6Page::initUI() {
m_detailLayout->addRow(m_subnetLabel,lengthEdit);
m_detailLayout->addRow(m_subnetEmptyLabel);
m_detailLayout->addRow(m_gateWayLabel,gateWayWidget);
m_detailLayout->addRow(m_dnsLabel,firstDnsEdit);
m_detailLayout->addRow(m_firstDnsEmptyLabel);
m_detailLayout->addRow(m_secDnsLabel,secondDnsEdit);
// m_detailLayout->addRow(m_dnsLabel,firstDnsEdit);
// m_detailLayout->addRow(m_secDnsLabel,secondDnsEdit);
m_detailLayout->addRow(m_dnsWidget);
ipv6ConfigCombox->addItem(tr("Auto(DHCP)")); //"自动(DHCP)"
ipv6ConfigCombox->addItem(tr("Manual")); //"手动"
QRegExp ipv6_rx("^\\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:)))(%.+)?\\s*$");
ipv6AddressEdit->setValidator(new QRegExpValidator(ipv6_rx, this));
gateWayEdit->setValidator(new QRegExpValidator(ipv6_rx, this));
firstDnsEdit->setValidator(new QRegExpValidator(ipv6_rx, this));
secondDnsEdit->setValidator(new QRegExpValidator(ipv6_rx, this));
// firstDnsEdit->setValidator(new QRegExpValidator(ipv6_rx, this));
// secondDnsEdit->setValidator(new QRegExpValidator(ipv6_rx, this));
QRegExp prefix_rx("\\b(?:(?:12[0-8]|1[0-1][0-9]|^[1-9][0-9]?$)\\.){3}(?:12[0-8]|1[0-1][0-9]|^[1-9][0-9]?$)\\b");
lengthEdit->setValidator(new QRegExpValidator(prefix_rx,this));
@ -225,8 +239,14 @@ void Ipv6Page::initComponent() {
connect(ipv6AddressEdit, SIGNAL(textChanged(QString)), this, SLOT(setEnableOfSaveBtn()));
connect(lengthEdit, SIGNAL(textChanged(QString)), this, SLOT(setEnableOfSaveBtn()));
connect(gateWayEdit, SIGNAL(textChanged(QString)), this, SLOT(setEnableOfSaveBtn()));
connect(firstDnsEdit, SIGNAL(textChanged(QString)), this, SLOT(setEnableOfSaveBtn()));
connect(secondDnsEdit, SIGNAL(textChanged(QString)), this, SLOT(setEnableOfSaveBtn()));
// connect(firstDnsEdit, SIGNAL(textChanged(QString)), this, SLOT(setEnableOfSaveBtn()));
// connect(secondDnsEdit, SIGNAL(textChanged(QString)), this, SLOT(setEnableOfSaveBtn()));
connect(m_dnsWidget, &MultipleDnsWidget::dnsTextChanged, this, [=]() {
setIpv6PageState(false);
});
connect(m_dnsWidget, &MultipleDnsWidget::dnsEditingFinished, this, [=]() {
setIpv6PageState(true);
});
}
void Ipv6Page::configChanged(int index) {
@ -244,8 +264,8 @@ void Ipv6Page::setControlEnabled(bool check)
ipv6AddressEdit->clear();
lengthEdit->clear();
gateWayEdit->clear();
firstDnsEdit->clear();
secondDnsEdit->clear();
// firstDnsEdit->clear();
// secondDnsEdit->clear();
ipv6AddressEdit->setPlaceholderText(" ");
lengthEdit->setPlaceholderText(" ");
@ -259,8 +279,9 @@ void Ipv6Page::setControlEnabled(bool check)
ipv6AddressEdit->setEnabled(check);
lengthEdit->setEnabled(check);
gateWayEdit->setEnabled(check);
firstDnsEdit->setEnabled(check);
secondDnsEdit->setEnabled(check);
// firstDnsEdit->setEnabled(check);
// secondDnsEdit->setEnabled(check);
m_dnsWidget->setEditEnabled(check);
}
void Ipv6Page::setEnableOfSaveBtn()
@ -317,7 +338,7 @@ bool Ipv6Page::checkConnectBtnIsEnabled()
qDebug() << "ipv6 gateway empty or invalid";
return false;
}
#if 0
if (firstDnsEdit->text().isEmpty() && !secondDnsEdit->text().isEmpty()) {
qDebug() << "ipv6 dns sort invalid";
return false;
@ -332,6 +353,7 @@ bool Ipv6Page::checkConnectBtnIsEnabled()
qDebug() << "ipv6 second dns invalid";
return false;
}
#endif
}
return true;
}

View File

@ -33,6 +33,7 @@
//#include "kylinconnectsetting.h"
#include "coninfo.h"
#include "multiplednswidget.h"
class Ipv6Page : public QFrame
{
@ -42,8 +43,9 @@ public:
void setIpv6Config(KyIpConfigType ipv6Config);
void setIpv6(const QString &ipv4);
void setIpv6Perfix(const int &ipv6Perfix);
void setIpv6FirDns(const QString &ipv6FirDns);
void setIpv6SecDns(const QString &ipv6SecDns);
// void setIpv6FirDns(const QString &ipv6FirDns);
// void setIpv6SecDns(const QString &ipv6SecDns);
void setMulDns(const QList<QHostAddress> &dns);
void setGateWay(const QString &gateWay);
bool checkIsChanged(const ConInfo info, KyConnectSetting &setting);
@ -54,27 +56,28 @@ public:
void stopLoading();
void showIpv6AddressConflict(bool isConflict);
public:
private:
QComboBox *ipv6ConfigCombox;
LineEdit *ipv6AddressEdit;
LineEdit *lengthEdit;
LineEdit *gateWayEdit;
LineEdit *firstDnsEdit;
LineEdit *secondDnsEdit;
private:
// LineEdit *firstDnsEdit;
// LineEdit *secondDnsEdit;
QFormLayout *m_detailLayout;
QLabel *m_configLabel;
QLabel *m_addressLabel;
QLabel *m_subnetLabel;
QLabel *m_gateWayLabel;
QLabel *m_dnsLabel;
QLabel *m_secDnsLabel;
// QLabel *m_dnsLabel;
// QLabel *m_secDnsLabel;
QLabel *m_configEmptyLabel;
QLabel *m_addressHintLabel;
QLabel *m_subnetEmptyLabel;
QLabel *m_gateWayHintLabel;
QLabel *m_firstDnsEmptyLabel;
MultipleDnsWidget *m_dnsWidget = nullptr;
QLabel *m_statusLabel = nullptr;
QList<QIcon> m_loadIcons;
@ -83,6 +86,7 @@ private:
QLabel *m_iconLabel;
QLabel *m_textLabel;
private:
void initUI();
void initComponent();

View File

@ -0,0 +1,185 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright (C) 2022 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 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#include "multiplednswidget.h"
#include <QApplication>
#define DNS_LISTWIDGET_HEIGHT 76
#define BUTTON_SIZE 36,36
#define ITEM_HEIGHT 36
MultipleDnsWidget::MultipleDnsWidget(const QRegExp &rx, QWidget *parent)
: m_regExp(rx),
QWidget(parent)
{
initUI();
initComponent();
}
void MultipleDnsWidget::initUI()
{
QVBoxLayout *mulDnsVLayout = new QVBoxLayout(this);
mulDnsVLayout->setContentsMargins(0, 0, 0, 0);
m_mulDnsLabel = new QLabel(this);
m_mulDnsLabel->setText(tr("DNS server:")); //DNS服务器
m_dnsListWidget = new QListWidget(this);
m_dnsListWidget->setFixedHeight(DNS_LISTWIDGET_HEIGHT);
m_dnsListWidget->setBackgroundRole(QPalette::Base);
m_dnsListWidget->setFocusPolicy(Qt::FocusPolicy::NoFocus);
m_dnsListWidget->setFrameShape(QFrame::Shape::StyledPanel);
m_dnsListWidget->setEditTriggers(QAbstractItemView::DoubleClicked);
setDnsListWidgetStyle();
m_addDnsBtn = new QPushButton(this);
m_addDnsBtn->setFixedSize(BUTTON_SIZE);
m_addDnsBtn->setProperty("useButtonPalette", true);
m_addDnsBtn->setIcon(QIcon::fromTheme("list-add-symbolic"));
m_removeDnsBtn = new QPushButton(this);
m_removeDnsBtn->setFixedSize(BUTTON_SIZE);
m_removeDnsBtn->setProperty("useButtonPalette", true);
m_removeDnsBtn->setIcon(QIcon::fromTheme("list-remove-symbolic"));
m_removeDnsBtn->setEnabled(false);
QHBoxLayout *btnHLayout = new QHBoxLayout();
btnHLayout->setContentsMargins(0, 0, 0, 0);
btnHLayout->setSpacing(1);
btnHLayout->setAlignment(Qt::AlignLeft);
btnHLayout->addWidget(m_addDnsBtn);
btnHLayout->addWidget(m_removeDnsBtn);
mulDnsVLayout->addWidget(m_mulDnsLabel, Qt::AlignLeft);
mulDnsVLayout->addWidget(m_dnsListWidget);
mulDnsVLayout->addLayout(btnHLayout);
}
void MultipleDnsWidget::initComponent()
{
connect(qApp, &QApplication::paletteChanged, this, &MultipleDnsWidget::setDnsListWidgetStyle);
connect(m_addDnsBtn, &QPushButton::clicked, this, &MultipleDnsWidget::onAddBtnClicked);
connect(m_removeDnsBtn, &QPushButton::clicked, this, &MultipleDnsWidget::onRemoveBtnClicked);
connect(m_dnsListWidget, &QListWidget::itemClicked, this, [=]() {
if (m_dnsListWidget->count() < 1) {
m_removeDnsBtn->setEnabled(false);
} else {
m_removeDnsBtn->setEnabled(true);
}
});
connect(m_dnsListWidget, &QListWidget::itemDoubleClicked, this, [=](QListWidgetItem *item) {
m_dnsListWidget->edit(m_dnsListWidget->currentIndex());
item->setFlags(item->flags() | Qt::ItemIsEditable);
});
}
void MultipleDnsWidget::setEditEnabled(bool state)
{
m_addDnsBtn->setEnabled(state);
if (!state) {
m_dnsListWidget->clear();
}
}
QList<QHostAddress> MultipleDnsWidget::getDns() const
{
QStringList dnsList;
dnsList.clear();
QList<QHostAddress> ipv4dnsList;
ipv4dnsList.clear();
int row = 0;
QString aDns;
while (m_dnsListWidget->count() > row) {
aDns = m_dnsListWidget->item(row)->text();
if (!dnsList.contains(aDns)) {
dnsList << aDns;
ipv4dnsList << QHostAddress(aDns);
}
row ++;
}
return ipv4dnsList;
}
void MultipleDnsWidget::setDnsListText(const QList<QHostAddress> &dns)
{
m_dnsListWidget->clear();
for (QHostAddress str: dns) {
QListWidgetItem *dnsListWidgetItem = new QListWidgetItem(m_dnsListWidget);
dnsListWidgetItem->setSizeHint(QSize(0,ITEM_HEIGHT));
dnsListWidgetItem->setText(str.toString());
}
}
void MultipleDnsWidget::AddOneDnsItem(QListWidget *listWidget)
{
QListWidgetItem *dnsListWidgetItem = new QListWidgetItem(listWidget);
dnsListWidgetItem->setSizeHint(QSize(0,ITEM_HEIGHT));
dnsListWidgetItem->setFlags(dnsListWidgetItem->flags() | Qt::ItemIsEditable);
listWidget->addItem(dnsListWidgetItem);
listWidget->setCurrentItem(dnsListWidgetItem);
ListItemEdit *dnsListItemEdit = new ListItemEdit(m_regExp);
listWidget->setItemDelegateForRow(listWidget->currentIndex().row() , dnsListItemEdit);
listWidget->editItem(dnsListWidgetItem);
connect(dnsListItemEdit, SIGNAL(textChanged(QString)), this, SIGNAL(dnsTextChanged(QString)));
connect(dnsListItemEdit, SIGNAL(editingFinished()), this, SIGNAL(dnsEditingFinished()));
}
void MultipleDnsWidget::RemoveOneDnsItem(QListWidgetItem *aItem, QListWidget *listWidget)
{
if (aItem) {
listWidget->removeItemWidget(aItem);
delete aItem;
}
}
void MultipleDnsWidget::setDnsListWidgetStyle()
{
QPalette mpal(m_dnsListWidget->palette());
mpal.setColor(QPalette::Base, qApp->palette().base().color());
mpal.setColor(QPalette::AlternateBase, qApp->palette().alternateBase().color());
m_dnsListWidget->setAlternatingRowColors(true);
m_dnsListWidget->setPalette(mpal);
}
void MultipleDnsWidget::onAddBtnClicked()
{
//避免重复添加空白项
if (m_dnsListWidget->currentItem()) {
if (m_dnsListWidget->currentItem()->text().isEmpty()) {
m_dnsListWidget->removeItemWidget(m_dnsListWidget->currentItem());
delete m_dnsListWidget->currentItem();
}
}
AddOneDnsItem(m_dnsListWidget);
m_removeDnsBtn->setEnabled(true);
}
void MultipleDnsWidget::onRemoveBtnClicked()
{
QListWidgetItem *aItem = m_dnsListWidget->currentItem();
if (!aItem) {
return;
}
RemoveOneDnsItem(aItem, m_dnsListWidget);
if (m_dnsListWidget->count()< 1) {
m_removeDnsBtn->setEnabled(false);
}
}

View File

@ -0,0 +1,70 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright (C) 2022 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 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#ifndef MULTIPLEDNSWIDGET_H
#define MULTIPLEDNSWIDGET_H
#include <QWidget>
#include <QLabel>
#include <QLayout>
#include <QLineEdit>
#include <QListWidget>
#include <QPushButton>
#include <QAbstractItemView>
#include <QString>
#include <QList>
#include <QHostAddress>
#include <QDebug>
#include "listitemedit.h"
class MultipleDnsWidget: public QWidget
{
Q_OBJECT
public:
MultipleDnsWidget(const QRegExp &rx, QWidget *parent = nullptr);
~MultipleDnsWidget() = default;
void setEditEnabled(bool state);
QList<QHostAddress> getDns() const;
void setDnsListText(const QList<QHostAddress> &dns);
private:
void initUI();
void initComponent();
void AddOneDnsItem(QListWidget *listWidget);
void RemoveOneDnsItem(QListWidgetItem *aItem, QListWidget *listWidget);
QLabel *m_mulDnsLabel;
QListWidget *m_dnsListWidget = nullptr;
QPushButton *m_addDnsBtn;
QPushButton *m_removeDnsBtn;
QRegExp m_regExp;
private Q_SLOTS:
void setDnsListWidgetStyle();
void onAddBtnClicked();
void onRemoveBtnClicked();
Q_SIGNALS:
void dnsTextChanged(const QString &);
void dnsEditingFinished();
};
#endif // MULTIPLEDNSWIDGET_H

View File

@ -30,6 +30,7 @@
#include <QEvent>
#include <QMenu>
#include <QToolTip>
#include <QFontMetrics>
#include "windowmanager/windowmanager.h"
@ -37,7 +38,7 @@
#define WINDOW_HEIGHT 602
#define ICON_SIZE 22,22
#define TITLE_LAYOUT_MARGINS 9,9,0,0
#define CENTER_LAYOUT_MARGINS 24,0,24,0
#define CENTER_LAYOUT_MARGINS 24,0,0,0
#define BOTTOM_LAYOUT_MARGINS 24,0,24,0
#define BOTTOM_LAYOUT_SPACING 16
#define PAGE_LAYOUT_SPACING 1
@ -53,6 +54,7 @@
#define SCRO_WIDTH 472
#define PEAP_SCRO_HEIGHT 300
#define TLS_SCRO_HEIGHT 480
#define MAX_TAB_TEXT_LENGTH 44
//extern void qt_blurImage(QImage &blurImage, qreal radius, bool quality, int transposed);
@ -355,10 +357,11 @@ void NetDetail::initUI()
}
pageLayout->addWidget(m_netTabBar, Qt::AlignCenter);
pageLayout->addSpacing(24);
// TabBar关联选项卡页面
connect(m_netTabBar, SIGNAL(currentChanged(int)), this, SLOT(currentRowChangeSlot(int)));
setNetTabToolTip();
confimBtn = new QPushButton(this);
confimBtn->setText(tr("Confirm"));
@ -367,10 +370,9 @@ void NetDetail::initUI()
cancelBtn->setText(tr("Cancel"));
forgetBtn = new QPushButton(this);
forgetBtn->setText(tr("Forget this network"));
QVBoxLayout *centerlayout = new QVBoxLayout(centerWidget);
centerlayout->setContentsMargins(CENTER_LAYOUT_MARGINS);
centerlayout->setContentsMargins(CENTER_LAYOUT_MARGINS); // 右边距为0为安全页滚动区域留出空间
centerlayout->addWidget(pageFrame);
centerlayout->addSpacing(4);
centerlayout->addWidget(stackWidget);
@ -413,7 +415,12 @@ void NetDetail::initComponent()
});
connect(confimBtn, SIGNAL(clicked()), this, SLOT(on_btnConfirm_clicked()));
if (isWlan && !m_uuid.isEmpty()) {
if (!m_uuid.isEmpty()) {
if (isWlan) {
forgetBtn->setText(tr("Forget this network"));
} else {
forgetBtn->setText(tr("Delete this network"));
}
forgetBtn->show();
connect(forgetBtn, SIGNAL(clicked()), this, SLOT(on_btnForget_clicked()));
} else {
@ -451,6 +458,16 @@ void NetDetail::initComponent()
connect(securityPage, &SecurityPage::eapTypeChanged, this, [=]() {
setSecuPageHeight();
});
const QByteArray id(THEME_SCHAME);
if(QGSettings::isSchemaInstalled(id)){
QGSettings * fontSetting = new QGSettings(id, QByteArray(), this);
connect(fontSetting, &QGSettings::changed,[=](QString key) {
if ("systemFont" == key || "systemFontSize" ==key) {
setNetTabToolTip();
}
});
}
}
void NetDetail::pagePadding(QString netName, bool isWlan)
@ -478,8 +495,9 @@ void NetDetail::pagePadding(QString netName, bool isWlan)
ipv4Page->setIpv4Config(m_info.ipv4ConfigType);
ipv4Page->setIpv4(m_info.strIPV4Address);
ipv4Page->setNetMask(m_info.strIPV4NetMask);
ipv4Page->setIpv4FirDns(m_info.strIPV4FirDns);
ipv4Page->setIpv4SecDns(m_info.strIPV4SecDns);
// ipv4Page->setIpv4FirDns(m_info.strIPV4FirDns);
// ipv4Page->setIpv4SecDns(m_info.strIPV4SecDns);
ipv4Page->setMulDns(m_info.ipv4DnsList);
ipv4Page->setGateWay(m_info.strIPV4GateWay);
} else {
ipv4Page->setIpv4Config(m_info.ipv4ConfigType);
@ -490,8 +508,9 @@ void NetDetail::pagePadding(QString netName, bool isWlan)
ipv6Page->setIpv6Config(m_info.ipv6ConfigType);
ipv6Page->setIpv6(m_info.strIPV6Address);
ipv6Page->setIpv6Perfix(m_info.iIPV6Prefix);
ipv6Page->setIpv6FirDns(m_info.strIPV6FirDns);
ipv6Page->setIpv6SecDns(m_info.strIPV6SecDns);
// ipv6Page->setIpv6FirDns(m_info.strIPV6FirDns);
// ipv6Page->setIpv6SecDns(m_info.strIPV6SecDns);
ipv6Page->setMulDns(m_info.ipv6DnsList);
ipv6Page->setGateWay(m_info.strIPV6GateWay);
} else {
ipv6Page->setIpv6Config(m_info.ipv6ConfigType);
@ -648,12 +667,16 @@ void NetDetail::getStaticIpInfo(ConInfo &conInfo, bool bActived)
conInfo.strIPV4NetMask = connetSetting.m_ipv4Address.at(0).netmask().toString();
conInfo.strIPV4GateWay = connetSetting.m_ipv4Address.at(0).gateway().toString();
}
#if 0
if (connetSetting.m_ipv4Dns.size() == 1) {
conInfo.strIPV4FirDns = connetSetting.m_ipv4Dns.at(0).toString();
} else if (connetSetting.m_ipv4Dns.size() > 1) {
conInfo.strIPV4FirDns = connetSetting.m_ipv4Dns.at(0).toString();
conInfo.strIPV4SecDns = connetSetting.m_ipv4Dns.at(1).toString();
}
#endif
conInfo.ipv4DnsList = connetSetting.m_ipv4Dns;
}
if (connetSetting.m_ipv6ConfigIpType == CONFIG_IP_MANUAL) {
@ -662,13 +685,16 @@ void NetDetail::getStaticIpInfo(ConInfo &conInfo, bool bActived)
conInfo.iIPV6Prefix = ipv6Page->getPerfixLength(connetSetting.m_ipv6Address.at(0).netmask().toString());
conInfo.strIPV6GateWay = connetSetting.m_ipv6Address.at(0).gateway().toString();
}
#if 0
if (connetSetting.m_ipv6Dns.size() == 1) {
conInfo.strIPV6FirDns = connetSetting.m_ipv6Dns.at(0).toString();
} else if (connetSetting.m_ipv4Dns.size() > 1) {
conInfo.strIPV6FirDns = connetSetting.m_ipv6Dns.at(0).toString();
conInfo.strIPV6SecDns = connetSetting.m_ipv6Dns.at(1).toString();
}
#endif
conInfo.ipv6DnsList = connetSetting.m_ipv6Dns;
}
if (!bActived) {
@ -1105,6 +1131,20 @@ bool NetDetail::eventFilter(QObject *w, QEvent *event)
return QWidget::eventFilter(w, event);
}
void NetDetail::setNetTabToolTip()
{
int tabCount = m_netTabBar->count();
for (int i = 0; i< tabCount; ++i) {
QFontMetrics fontMetrics(m_netTabBar->font());
int fontSize = fontMetrics.width(m_netTabBar->tabText(i));
if (fontSize > MAX_TAB_TEXT_LENGTH) {
m_netTabBar->setTabToolTip(i, m_netTabBar->tabText(i));
} else {
m_netTabBar->setTabToolTip(i, "");
}
}
}
NetTabBar::NetTabBar(QWidget *parent)
{

View File

@ -137,6 +137,7 @@ private:
void setNetdetailSomeEnable(bool on);
void startObjectThread();
void setNetTabToolTip();
private:
KyNetworkDeviceResourse *m_netDeviceResource = nullptr;

View File

@ -10,6 +10,7 @@ HEADERS += \
$$PWD/ipv4page.h \
$$PWD/ipv6page.h \
$$PWD/joinhiddenwifipage.h \
$$PWD/multiplednswidget.h \
$$PWD/netdetail.h \
$$PWD/securitypage.h
@ -22,5 +23,6 @@ SOURCES += \
$$PWD/ipv4page.cpp \
$$PWD/ipv6page.cpp \
$$PWD/joinhiddenwifipage.cpp \
$$PWD/multiplednswidget.cpp \
$$PWD/netdetail.cpp \
$$PWD/securitypage.cpp

View File

@ -21,13 +21,13 @@
#define ICON_SIZE 16,16
FirewallDialog::FirewallDialog(KDialog *parent)
FirewallDialog::FirewallDialog(QWidget *parent): KDialog(parent)
{
initUI();
this->setWindowIcon(QIcon::fromTheme("kylin-network"));
this->setFixedSize(480, 204);
setAttribute(Qt::WA_DeleteOnClose);
centerToScreen();
// centerToScreen();
}
FirewallDialog::~FirewallDialog()

View File

@ -35,15 +35,17 @@ class FirewallDialog : public KDialog
{
Q_OBJECT
public:
explicit FirewallDialog(KDialog *parent = nullptr);
FirewallDialog(QWidget *parent = nullptr);
~FirewallDialog();
void setUuid(QString uuid) {
m_uuid = uuid;
}
void centerToScreen();
private:
void initUI();
void centerToScreen();
QString m_uuid;
QLabel * m_iconLabel = nullptr;
QLabel * m_contentLabel = nullptr;

View File

@ -938,6 +938,8 @@ void LanPage::onConnectionStateChange(QString uuid,
connect(m_activeResourse, &KyActiveConnectResourse::stateChangeReason, fireWallDialog, &FirewallDialog::closeMyself);
fireWallDialog->show();
fireWallDialog->centerToScreen();
} else if (configType == KSC_FIREWALL_PUBLIC) {
NetworkModeConfig::getInstance()->setNetworkModeConfig(uuid, deviceName, ssid, KSC_FIREWALL_PUBLIC);
} else if (configType == KSC_FIREWALL_PRIVATE) {
@ -947,7 +949,7 @@ void LanPage::onConnectionStateChange(QString uuid,
updateActivatedConnectionArea(p_newItem);
updateConnectionState(m_activeConnectionMap, m_activatedLanListWidget, uuid, (ConnectState)state);
} else if (state == NetworkManager::ActiveConnection::State::Deactivated) {
p_newItem = m_connectResourse->getConnectionItemByUuid(uuid);
p_newItem = m_connectResourse->getConnectionItemByUuidWithoutActivateChecking(uuid);
qDebug() << "[LanPage] deactivated reason" << reason;
if (nullptr == p_newItem) {
qWarning()<<"[LanPage] get active connection failed, connection uuid" << uuid;
@ -1200,6 +1202,15 @@ bool LanPage::eventFilter(QObject *watched, QEvent *event)
return QWidget::eventFilter(watched, event);
}
void LanPage::deleteWired(const QString &connUuid)
{
qDebug() << "[LanPage] deleteWired" << connUuid;
if (connUuid == nullptr) {
return;
}
m_wiredConnectOperation->deleteWiredConnect(connUuid);
}
void LanPage::onWiredEnabledChanged(bool enabled)
{
if (m_devList.isEmpty()) {

View File

@ -44,6 +44,7 @@ public:
//for dbus
void getWiredList(QMap<QString, QVector<QStringList> > &map);
void deleteWired(const QString& connUuid);
void activateWired(const QString& devName, const QString& connUuid);
void deactivateWired(const QString& devName, const QString& connUuid);
void showDetailPage(QString devName, QString uuid);

View File

@ -992,6 +992,7 @@ void WlanPage::onConnectionStateChanged(QString uuid,
connect(m_activatedConnectResource, &KyActiveConnectResourse::stateChangeReason, fireWallDialog, &FirewallDialog::closeMyself);
fireWallDialog->show();
fireWallDialog->centerToScreen();
} else if (configType == KSC_FIREWALL_PUBLIC) {
NetworkModeConfig::getInstance()->setNetworkModeConfig(uuid, devName, ssid, KSC_FIREWALL_PUBLIC);

View File

@ -0,0 +1,55 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright (C) 2022 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 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#include "listitemedit.h"
ListItemEdit::ListItemEdit(const QRegExp &rx, QObject *parent)
: m_regExp(rx),
QStyledItemDelegate(parent)
{
}
QWidget *ListItemEdit::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
QLineEdit *editor = new QLineEdit(parent);
editor->setValidator(new QRegExpValidator(m_regExp, parent));
connect(editor, SIGNAL(textChanged(QString)), this, SIGNAL(textChanged(QString)));
connect(editor, SIGNAL(editingFinished()), this, SIGNAL(editingFinished()));
return editor;
}
void ListItemEdit::setEditorData(QWidget *editor, const QModelIndex &index) const
{
QLineEdit *lineEdit = static_cast <QLineEdit*>(editor);
QString text = index.model()->data(index, Qt::EditRole).toString();
lineEdit->setText(text);
}
void ListItemEdit::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const
{
QLineEdit *lineEdit = static_cast <QLineEdit*>(editor);
QString text = lineEdit->text();
model->setData(index, text, Qt::EditRole);
}
void ListItemEdit::updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
editor->setGeometry(option.rect);
}

View File

@ -0,0 +1,52 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright (C) 2022 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 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#ifndef LISTITEMEDIT_H
#define LISTITEMEDIT_H
#include <QWidget>
#include <QStyledItemDelegate>
#include <QLineEdit>
class ListItemEdit: public QStyledItemDelegate
{
Q_OBJECT
public:
ListItemEdit(const QRegExp &rx, QObject *parent = nullptr);
~ListItemEdit() = default;
//创建一个控件
virtual QWidget *createEditor (QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const;
//将数据设置到控件中
virtual void setEditorData (QWidget *editor, const QModelIndex &index) const;
//将控件中的数据更新到对应的model中
virtual void setModelData (QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const;
//更新控件位置
void updateEditorGeometry(QWidget *editor,
const QStyleOptionViewItem &option,
const QModelIndex &index) const override;
private:
QRegExp m_regExp;
Q_SIGNALS:
void textChanged(const QString &);
void editingFinished();
};
#endif // LISTITEMEDIT_H

View File

@ -3,6 +3,7 @@ INCLUDEPATH += $$PWD
HEADERS += \
$$PWD/divider.h \
$$PWD/infobutton.h \
$$PWD/listitemedit.h \
$$PWD/loadingdiv.h \
$$PWD/radioitembutton.h \
$$PWD/switchbutton.h \
@ -12,6 +13,7 @@ HEADERS += \
SOURCES += \
$$PWD/divider.cpp \
$$PWD/infobutton.cpp \
$$PWD/listitemedit.cpp \
$$PWD/loadingdiv.cpp \
$$PWD/radioitembutton.cpp \
$$PWD/switchbutton.cpp \

Binary file not shown.

View File

@ -32,6 +32,14 @@
<translation type="obsolete">ip地址冲突ip {6 ?}</translation>
</message>
</context>
<context>
<name>MultipleDnsWidget</name>
<message>
<location filename="../src/frontend/netdetails/multiplednswidget.cpp" line="42"/>
<source>DNS server:</source>
<translation>DNSཞབས:</translation>
</message>
</context>
<context>
<name>ConfigPage</name>
<message>
@ -125,6 +133,11 @@
<source>Manual</source>
<translation></translation>
</message>
<message>
<location filename="../src/frontend/netdetails/creatnetpage.cpp" line="173"/>
<source>Required</source>
<translation></translation>
</message>
</context>
<context>
<name>DetailPage</name>
@ -852,6 +865,10 @@
<source>Forget this network</source>
<translation></translation>
</message>
<message>
<source>Delete this network</source>
<translation></translation>
</message>
<message>
<location filename="../src/frontend/netdetails/netdetail.cpp" line="403"/>
<source>Add Lan Connect</source>

Binary file not shown.

View File

@ -32,6 +32,14 @@
<translation type="obsolete">ip地址冲突ip {6 ?}</translation>
</message>
</context>
<context>
<name>MultipleDnsWidget</name>
<message>
<location filename="../src/frontend/netdetails/multiplednswidget.cpp" line="42"/>
<source>DNS server:</source>
<translation>DNS服务器</translation>
</message>
</context>
<context>
<name>ConfigPage</name>
<message>
@ -125,6 +133,11 @@
<source>Manual</source>
<translation></translation>
</message>
<message>
<location filename="../src/frontend/netdetails/creatnetpage.cpp" line="173"/>
<source>Required</source>
<translation></translation>
</message>
</context>
<context>
<name>DetailPage</name>
@ -851,6 +864,10 @@
<location filename="../src/frontend/netdetails/netdetail.cpp" line="372"/>
<source>Forget this network</source>
<translation></translation>
</message>
<message>
<source>Delete this network</source>
<translation></translation>
</message>
<message>
<location filename="../src/frontend/netdetails/netdetail.cpp" line="403"/>