merge upstream
This commit is contained in:
commit
5f59ac4a61
|
@ -0,0 +1,54 @@
|
|||
# C++ objects and libs
|
||||
*.slo
|
||||
*.lo
|
||||
*.o
|
||||
*.a
|
||||
*.la
|
||||
*.lai
|
||||
*.so
|
||||
*.so.*
|
||||
*.dll
|
||||
*.dylib
|
||||
|
||||
# Qt-es
|
||||
object_script.*.Release
|
||||
object_script.*.Debug
|
||||
*_plugin_import.cpp
|
||||
/.qmake.cache
|
||||
/.qmake.stash
|
||||
*.pro.user
|
||||
*.pro.user.*
|
||||
*.qbs.user
|
||||
*.qbs.user.*
|
||||
*.moc
|
||||
moc_*.cpp
|
||||
moc_*.h
|
||||
qrc_*.cpp
|
||||
ui_*.h
|
||||
*.qmlc
|
||||
*.jsc
|
||||
Makefile*
|
||||
*build-*
|
||||
*.prl
|
||||
|
||||
# Qt unit tests
|
||||
target_wrapper.*
|
||||
|
||||
# QtCreator
|
||||
*.autosave
|
||||
|
||||
# QtCreator Qml
|
||||
*.qmlproject.user
|
||||
*.qmlproject.user.*
|
||||
|
||||
# QtCreator CMake
|
||||
CMakeLists.txt.user*
|
||||
|
||||
# QtCreator 4.8< compilation database
|
||||
compile_commands.json
|
||||
|
||||
# QtCreator local machine specific files for imported projects
|
||||
*creator.user*
|
||||
|
||||
# OS X extra file
|
||||
.DS_Store
|
19
kylin-nm.pro
19
kylin-nm.pro
|
@ -1,13 +1,26 @@
|
|||
TEMPLATE = subdirs
|
||||
|
||||
CONFIG += ordered \
|
||||
|
||||
CONFIG += \
|
||||
ordered \
|
||||
qt
|
||||
|
||||
SUBDIRS = \
|
||||
plugins/plugin.pro \
|
||||
src \
|
||||
src-vpn/src-vpn.pro \
|
||||
src
|
||||
|
||||
TRANSLATIONS += \
|
||||
translations/kylin-nm_zh_CN.ts \
|
||||
translations/kylin-nm_tr.ts \
|
||||
translations/kylin-nm_bo.ts
|
||||
translations/kylin-nm_bo.ts \
|
||||
translations/kylin-nm_bo_CN.ts
|
||||
|
||||
CONFIG(release, debug|release) {
|
||||
!system($$PWD/translate_generation.sh): error("Failed to generate translation")
|
||||
}
|
||||
|
||||
qm_files.path = $${PREFIX}/share/kylin-nm/kylin-nm/
|
||||
qm_files.files = translations/*.qm
|
||||
|
||||
INSTALLS += qm_files \
|
||||
|
|
|
@ -17,9 +17,6 @@
|
|||
<file>res/h/right-pwd.png</file>
|
||||
<file>res/h/show-pwd.png</file>
|
||||
<file>res/h/no-pwd-wifi.png</file>
|
||||
<file>translations/kylin-nm_bo.qm</file>
|
||||
<file>translations/kylin-nm_tr.qm</file>
|
||||
<file>translations/kylin-nm_zh_CN.qm</file>
|
||||
<file>res/x/fly-mode-off.svg</file>
|
||||
<file>res/x/fly-mode-on.svg</file>
|
||||
<file>res/x/hot-spot-off.svg</file>
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "addnetbtn.h"
|
||||
#include <QEvent>
|
||||
#include <QHBoxLayout>
|
||||
#include <QLabel>
|
||||
#include <QVariant>
|
||||
#include <QPainter>
|
||||
#include <QPainterPath>
|
||||
|
@ -33,35 +34,30 @@ AddNetBtn::AddNetBtn(bool isWlan, QWidget *parent) : QPushButton(parent)
|
|||
this->setMaximumSize(QSize(16777215, 60));
|
||||
this->setProperty("useButtonPalette", true);
|
||||
this->setFlat(true);
|
||||
QPalette pal = this->palette();
|
||||
QColor color = pal.color(QPalette::Button);
|
||||
color.setAlphaF(0.5);
|
||||
pal.setColor(QPalette::Button, color);
|
||||
this->setPalette(pal);
|
||||
QHBoxLayout *addLyt = new QHBoxLayout(this);
|
||||
|
||||
QHBoxLayout *addLyt = new QHBoxLayout;
|
||||
|
||||
QLabel *iconLabel = new QLabel(this);
|
||||
textLabel = new QLabel(this);
|
||||
m_textLabel = new QLabel(this);
|
||||
|
||||
if (isWlan) {
|
||||
textLabel->setText(tr("Add Others"));
|
||||
m_textLabel->setText(tr("Add Others"));
|
||||
addLyt->addSpacing(8);
|
||||
addLyt->addWidget(textLabel);
|
||||
addLyt->addWidget(m_textLabel);
|
||||
} else {
|
||||
textLabel->setText(tr("Add WiredNetork"));
|
||||
m_textLabel->setText(tr("Add WiredNetork"));
|
||||
QIcon mAddIcon = QIcon::fromTheme("list-add-symbolic");
|
||||
iconLabel->setPixmap(mAddIcon.pixmap(mAddIcon.actualSize(QSize(24, 24))));
|
||||
iconLabel->setProperty("useIconHighlightEffect", true);
|
||||
iconLabel->setProperty("iconHighlightEffectMode", 1);
|
||||
iconLabel->setPixmap(mAddIcon.pixmap(mAddIcon.actualSize(QSize(16, 16))));
|
||||
iconLabel->setProperty("useIconHighlightEffect", 0x2);
|
||||
// iconLabel->setProperty("iconHighlightEffectMode", 1);
|
||||
|
||||
addLyt->addStretch();
|
||||
addLyt->addWidget(iconLabel);
|
||||
addLyt->addWidget(textLabel);
|
||||
addLyt->addWidget(m_textLabel);
|
||||
}
|
||||
|
||||
addLyt->addStretch();
|
||||
this->setLayout(addLyt);
|
||||
|
||||
}
|
||||
|
||||
AddNetBtn::~AddNetBtn()
|
||||
|
@ -83,12 +79,18 @@ void AddNetBtn::leaveEvent(QEvent *event){
|
|||
|
||||
void AddNetBtn::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
QPalette pal = this->palette();
|
||||
QPalette pal = qApp->palette();
|
||||
|
||||
QPainter painter(this);
|
||||
painter.setRenderHint(QPainter:: Antialiasing, true); //设置渲染,启动反锯齿
|
||||
painter.setPen(Qt::NoPen);
|
||||
painter.setBrush(pal.color(QPalette::Base));
|
||||
|
||||
painter.setBrush(this->palette().base().color());
|
||||
|
||||
QColor color = pal.color(QPalette::Button);
|
||||
color.setAlphaF(0.5);
|
||||
pal.setColor(QPalette::Button, color);
|
||||
this->setPalette(pal);
|
||||
|
||||
QRect rect = this->rect();
|
||||
QPainterPath path;
|
||||
|
|
|
@ -34,8 +34,8 @@ public:
|
|||
AddNetBtn(bool isWlan, QWidget *parent = nullptr);
|
||||
~AddNetBtn();
|
||||
|
||||
void setTextLabel(QString str) {
|
||||
textLabel->setText(str);
|
||||
void setTextLabel(const QString str) {
|
||||
m_textLabel->setText(str);
|
||||
}
|
||||
|
||||
protected:
|
||||
|
@ -44,7 +44,7 @@ protected:
|
|||
void paintEvent(QPaintEvent *event);
|
||||
|
||||
private:
|
||||
QLabel* textLabel;
|
||||
QLabel *m_textLabel;
|
||||
|
||||
Q_SIGNALS:
|
||||
void enterWidget();
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
/* -*- 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 "grayinfobutton.h"
|
||||
|
||||
#include <QVariant>
|
||||
|
||||
#define BUTTON_SIZE 36,36
|
||||
#define ICON_SIZE 16,16
|
||||
|
||||
GrayInfoButton::GrayInfoButton(QWidget *parent): QPushButton(parent)
|
||||
{
|
||||
this->setFixedSize(BUTTON_SIZE);
|
||||
this->setIcon(QIcon::fromTheme("preferences-system-details-symbolic"));
|
||||
this->setProperty("useButtonPalette", true);
|
||||
this->setFlat(true);
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
/* -*- 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 GRAYINFOBUTTON_H
|
||||
#define GRAYINFOBUTTON_H
|
||||
|
||||
#include <QPushButton>
|
||||
#include <QIcon>
|
||||
|
||||
class GrayInfoButton : public QPushButton
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit GrayInfoButton(QWidget * parent = nullptr);
|
||||
~GrayInfoButton() = default;
|
||||
};
|
||||
|
||||
#endif // GRAYINFOBUTTON_H
|
|
@ -1,3 +1,22 @@
|
|||
/* -*- 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 "drownlabel.h"
|
||||
#include "deviceframe.h"
|
||||
|
||||
|
|
|
@ -1,3 +1,23 @@
|
|||
|
||||
/* -*- 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 DROWNLABEL_H
|
||||
#define DROWNLABEL_H
|
||||
|
||||
|
|
|
@ -1,9 +1,28 @@
|
|||
/* -*- 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 "infobutton.h"
|
||||
#include <QEvent>
|
||||
#include <QPainter>
|
||||
#include <QPainterPath>
|
||||
#include <QApplication>
|
||||
#include <QDebug>
|
||||
#include <QPainterPath>
|
||||
|
||||
#define BUTTON_SIZE 36,36
|
||||
#define ICON_SIZE 16,16
|
||||
|
|
|
@ -1,3 +1,22 @@
|
|||
/* -*- 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 INFOBUTTON_H
|
||||
#define INFOBUTTON_H
|
||||
#include <QPushButton>
|
||||
|
|
|
@ -2,8 +2,10 @@
|
|||
|
||||
SOURCES += \
|
||||
$$PWD/AddBtn/addnetbtn.cpp \
|
||||
$$PWD/AddBtn/grayinfobutton.cpp
|
||||
|
||||
HEADERS += \
|
||||
$$PWD/AddBtn/addnetbtn.h \
|
||||
$$PWD/AddBtn/grayinfobutton.h
|
||||
|
||||
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
*/
|
||||
#include "blacklistitem.h"
|
||||
#include <QDebug>
|
||||
|
||||
#define MAIN_LAYOUT_MARGINS 0,0,0,0
|
||||
#define MAIN_LAYOUT_SPACING 0
|
||||
#define ITEM_FRAME_MARGINS 0,0,0,0
|
||||
#define ITEM_FRAME_SPACING 10
|
||||
#define FRAME_WIDTH 395
|
||||
#define INFO_ICON_WIDTH 16
|
||||
#define INFO_ICON_HEIGHT 16
|
||||
#define LIGHT_HOVER_COLOR QColor(240,240,240,255)
|
||||
#define DARK_HOVER_COLOR QColor(15,15,15,255)
|
||||
|
||||
#define FRAME_MIN_SIZE 550, 60
|
||||
#define CONTECT_FRAME_MAX_SIZE 16777215, 60
|
||||
#define LABLE_MIN_WIDTH 188
|
||||
#define ITEM_MARGINS 16, 0, 16, 0
|
||||
|
||||
BlacklistItem::BlacklistItem(QString staMac, QString staName, QWidget *parent) :
|
||||
QFrame(parent),
|
||||
m_mac(staMac),
|
||||
m_hostName(staName)
|
||||
{
|
||||
this->setMinimumHeight(60);
|
||||
this->setFixedHeight(60);
|
||||
|
||||
QHBoxLayout *hItemLayout = new QHBoxLayout(this);
|
||||
hItemLayout->setContentsMargins(ITEM_MARGINS);
|
||||
QLabel *nameLabel = new QLabel(staName, this);
|
||||
m_removeFromBlacklistBtn = new KBorderlessButton(this);
|
||||
m_removeFromBlacklistBtn->setText(tr("Remove"));
|
||||
hItemLayout->setSpacing(0);
|
||||
hItemLayout->addWidget(nameLabel, Qt::AlignLeft);
|
||||
hItemLayout->addStretch();
|
||||
hItemLayout->addWidget(m_removeFromBlacklistBtn, Qt::AlignRight);
|
||||
|
||||
m_removeFromBlacklistBtn->installEventFilter(this);
|
||||
this->setLayout(hItemLayout);
|
||||
}
|
||||
|
||||
bool BlacklistItem::eventFilter(QObject *w, QEvent *e)
|
||||
{
|
||||
if (e->type() == QEvent::MouseButtonRelease) {
|
||||
if (w == m_removeFromBlacklistBtn) {
|
||||
emit onBtnClicked(m_mac, m_hostName);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return QWidget::eventFilter(w,e);
|
||||
}
|
||||
|
|
@ -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 BLACKLISTITEM_H
|
||||
#define BLACKLISTITEM_H
|
||||
#include <QFrame>
|
||||
#include <QEvent>
|
||||
#include <QHBoxLayout>
|
||||
#include <QDebug>
|
||||
#include <QMouseEvent>
|
||||
#include <QMenu>
|
||||
#include <QLabel>
|
||||
#include "kborderlessbutton.h"
|
||||
|
||||
using namespace kdk;
|
||||
|
||||
class BlacklistItem : public QFrame
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
BlacklistItem(QString staMac, QString staName, QWidget *parent = nullptr);
|
||||
|
||||
protected:
|
||||
KBorderlessButton *m_removeFromBlacklistBtn = nullptr;
|
||||
|
||||
QString m_mac;
|
||||
QString m_hostName;
|
||||
bool eventFilter(QObject *w, QEvent *e);
|
||||
|
||||
signals:
|
||||
void onBtnClicked(QString staMac, QString staName);
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif // LISTITEM_H
|
|
@ -0,0 +1,200 @@
|
|||
/* -*- 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 "blacklistpage.h"
|
||||
#include <QDebug>
|
||||
|
||||
#define CONTENTS_MARGINS 0, 0, 0, 0
|
||||
#define FRAME_MIN_SIZE 550, 60
|
||||
#define FRAME_MAX_SIZE 16777215, 16777215
|
||||
#define LINE_MAX_SIZE 16777215, 1
|
||||
#define LINE_MIN_SIZE 0, 1
|
||||
|
||||
#define LOG_HEAD "[BlacklistPage]"
|
||||
|
||||
BlacklistPage::BlacklistPage(QWidget *parent) : QWidget(parent)
|
||||
{
|
||||
QVBoxLayout *Vlayout = new QVBoxLayout(this);
|
||||
Vlayout->setContentsMargins(CONTENTS_MARGINS);
|
||||
Vlayout->setSpacing(0);
|
||||
|
||||
m_blacklistFrame = new QFrame(this);
|
||||
m_blacklistFrame->setMinimumSize(FRAME_MIN_SIZE);
|
||||
m_blacklistFrame->setMaximumSize(FRAME_MAX_SIZE);
|
||||
m_blacklistFrame->setFrameShape(QFrame::Box);
|
||||
|
||||
m_blacklistLayout = new QVBoxLayout(m_blacklistFrame);
|
||||
m_blacklistLayout->setContentsMargins(0, 0, 0, 0);
|
||||
m_blacklistLayout->setSpacing(0);
|
||||
|
||||
m_titleLabel = new TitleLabel(this);
|
||||
m_titleLabel->setText(tr("Blacklist"));
|
||||
|
||||
Vlayout->addWidget(m_titleLabel);
|
||||
Vlayout->addSpacing(8);
|
||||
Vlayout->addWidget(m_blacklistFrame);
|
||||
}
|
||||
|
||||
QFrame* BlacklistPage::myLine()
|
||||
{
|
||||
QFrame *line = new QFrame(this);
|
||||
line->setMinimumSize(QSize(LINE_MIN_SIZE));
|
||||
line->setMaximumSize(QSize(LINE_MAX_SIZE));
|
||||
line->setLineWidth(0);
|
||||
line->setFrameShape(QFrame::HLine);
|
||||
line->setFrameShadow(QFrame::Sunken);
|
||||
|
||||
return line;
|
||||
}
|
||||
|
||||
void BlacklistPage::getBlacklistDevice(QMap<QString, QString> &blacklistMap)
|
||||
{
|
||||
if (m_settingPathInterface == nullptr || !m_settingPathInterface->isValid()) {
|
||||
qDebug() << LOG_HEAD << "dbus interface m_settingPathInterface is invaild";
|
||||
return;
|
||||
}
|
||||
|
||||
QDBusMessage reply = m_settingPathInterface->call("Getblacklist");
|
||||
if(reply.type() == QDBusMessage::ErrorMessage)
|
||||
{
|
||||
qWarning() << LOG_HEAD << "Getblacklist error:" << reply.errorMessage();
|
||||
return;
|
||||
}
|
||||
if (reply.arguments().isEmpty()
|
||||
|| reply.arguments().at(0).toString() == ""
|
||||
|| reply.arguments().at(1).toString() == "") {
|
||||
qDebug() << LOG_HEAD << "Dbus interface call Getblacklist return is empty!";
|
||||
return;
|
||||
}
|
||||
QStringList macList = reply.arguments().at(0).toString().split(";");
|
||||
QStringList hostNameList = reply.arguments().at(1).toString().split(";");
|
||||
for (int index = 0; index < macList.count() && macList.at(index) != nullptr; index ++) {
|
||||
QString macTemp = macList.at(index);
|
||||
macTemp = macTemp.trimmed();
|
||||
if (!blacklistMap.contains(macTemp) && hostNameList.at(index) != nullptr) {
|
||||
blacklistMap[macTemp] = hostNameList.at(index);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void BlacklistPage::initBlacklistDev()
|
||||
{
|
||||
QMap<QString, QString>::const_iterator item = m_blacklistMap.cbegin();
|
||||
while (item != m_blacklistMap.cend()) {
|
||||
addBlacklistDevFrame(item.key(), item.value());
|
||||
item ++;
|
||||
if (item != m_blacklistMap.cend()) {
|
||||
m_blacklistLayout->addWidget(myLine());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void BlacklistPage::onsetStaIntoBlacklist(QString staMac, QString staName)
|
||||
{
|
||||
if (m_settingPathInterface == nullptr || !m_settingPathInterface->isValid()) {
|
||||
qDebug() << LOG_HEAD << LOG_HEAD << "dbus interface m_settingPathInterface is invaild";
|
||||
return;
|
||||
}
|
||||
|
||||
QDBusMessage reply = m_settingPathInterface->call("Addblacklist", staMac, staName);
|
||||
if(reply.type() == QDBusMessage::ErrorMessage)
|
||||
{
|
||||
qWarning() << LOG_HEAD << "Addblacklist error:" << reply.errorMessage();
|
||||
return;
|
||||
}
|
||||
|
||||
refreshBlacklist();
|
||||
}
|
||||
|
||||
void BlacklistPage::addBlacklistDevFrame(QString staMac, QString staName)
|
||||
{
|
||||
BlacklistItem *itemFrame = new BlacklistItem(staMac, staName, m_blacklistLayout->widget());
|
||||
m_blacklistLayout->addWidget(itemFrame);
|
||||
connect(itemFrame, &BlacklistItem::onBtnClicked, this, &BlacklistPage::onRemoveFromBlacklistBtnClicked);
|
||||
}
|
||||
|
||||
void BlacklistPage::clearBlacklistLayout()
|
||||
{
|
||||
if (m_blacklistLayout->layout() != NULL) {
|
||||
QLayoutItem* layoutItem;
|
||||
while ((layoutItem = m_blacklistLayout->layout()->takeAt(0)) != NULL) {
|
||||
delete layoutItem->widget();
|
||||
delete layoutItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool BlacklistPage::removeStaFromBlacklist(QString staMac, QString staName)
|
||||
{
|
||||
if (m_settingPathInterface == nullptr || !m_settingPathInterface->isValid()) {
|
||||
qDebug() << LOG_HEAD << "dbus interface m_settingPathInterface is invaild";
|
||||
return false;
|
||||
}
|
||||
|
||||
QDBusMessage reply = m_settingPathInterface->call("Delblacklist", staMac, staName);
|
||||
if(reply.type() == QDBusMessage::ErrorMessage)
|
||||
{
|
||||
qWarning() << LOG_HEAD << "Delblacklist error:" << reply.errorMessage();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void BlacklistPage::resetLayoutHight()
|
||||
{
|
||||
int height = 0;
|
||||
for (int i = 0; i < m_blacklistLayout->count(); i ++) {
|
||||
QWidget *w = m_blacklistLayout->itemAt(i)->widget();
|
||||
if (w != nullptr) {
|
||||
height += w->height();
|
||||
}
|
||||
}
|
||||
m_blacklistFrame->setFixedHeight(height);
|
||||
|
||||
if (m_blacklistMap.isEmpty()) {
|
||||
this->hide();
|
||||
} else {
|
||||
this->show();
|
||||
}
|
||||
this->update();
|
||||
}
|
||||
|
||||
void BlacklistPage::refreshBlacklist()
|
||||
{
|
||||
m_blacklistMap.clear();
|
||||
getBlacklistDevice(m_blacklistMap);
|
||||
clearBlacklistLayout();
|
||||
initBlacklistDev();
|
||||
resetLayoutHight();
|
||||
}
|
||||
|
||||
void BlacklistPage::onRemoveFromBlacklistBtnClicked(QString staMac, QString staName)
|
||||
{
|
||||
if (staMac.isNull()
|
||||
|| staMac.isEmpty()
|
||||
|| staName.isNull()
|
||||
|| staName.isEmpty()) {
|
||||
qDebug() << LOG_HEAD <<"On remove from blacklist button clicked error! sta mac or name is empty!";
|
||||
return;
|
||||
}
|
||||
removeStaFromBlacklist(staMac, staName);
|
||||
refreshBlacklist();
|
||||
}
|
||||
|
|
@ -0,0 +1,74 @@
|
|||
/* -*- 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 BLACKLISTPAGE_H
|
||||
#define BLACKLISTPAGE_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QLabel>
|
||||
#include <QHBoxLayout>
|
||||
|
||||
#include <QDBusMessage>
|
||||
#include <QDBusObjectPath>
|
||||
#include <QDBusInterface>
|
||||
#include <QDBusReply>
|
||||
#include <QDBusMetaType>
|
||||
|
||||
#include "titlelabel.h"
|
||||
#include "blacklistitem.h"
|
||||
|
||||
using namespace kdk;
|
||||
|
||||
class BlacklistPage : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit BlacklistPage(QWidget *parent = nullptr);
|
||||
|
||||
void refreshBlacklist();
|
||||
bool setStaIntoBlacklist(QString staMac);
|
||||
|
||||
inline void setInterface(QDBusInterface *settingInterface) {
|
||||
m_settingPathInterface = settingInterface;
|
||||
}
|
||||
|
||||
private:
|
||||
QFrame* myLine();
|
||||
|
||||
void getBlacklistDevice(QMap<QString, QString> &blacklistMap);
|
||||
bool removeStaFromBlacklist(QString staMac, QString staName);
|
||||
void initBlacklistDev();
|
||||
void addBlacklistDevFrame(QString staMac, QString staName);
|
||||
void clearBlacklistLayout();
|
||||
void resetLayoutHight();
|
||||
|
||||
private:
|
||||
QFrame *m_blacklistFrame = nullptr;
|
||||
TitleLabel *m_titleLabel = nullptr;
|
||||
QVBoxLayout *m_blacklistLayout = nullptr;
|
||||
QMap<QString, QString> m_blacklistMap;
|
||||
|
||||
QDBusInterface *m_settingPathInterface = nullptr;
|
||||
|
||||
private slots:
|
||||
void onsetStaIntoBlacklist(QString staMac, QString staName);
|
||||
void onRemoveFromBlacklistBtnClicked(QString staMac, QString staName);
|
||||
};
|
||||
|
||||
#endif // MOBILEHOTSPOTWIDGET_H
|
|
@ -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.
|
||||
*
|
||||
*/
|
||||
#include "connectdevlistitem.h"
|
||||
#include <QDebug>
|
||||
|
||||
#define MAIN_LAYOUT_MARGINS 0,0,0,0
|
||||
#define MAIN_LAYOUT_SPACING 0
|
||||
#define ITEM_FRAME_MARGINS 0,0,0,0
|
||||
#define ITEM_FRAME_SPACING 10
|
||||
#define FRAME_WIDTH 395
|
||||
#define INFO_ICON_WIDTH 16
|
||||
#define INFO_ICON_HEIGHT 16
|
||||
#define LIGHT_HOVER_COLOR QColor(240,240,240,255)
|
||||
#define DARK_HOVER_COLOR QColor(15,15,15,255)
|
||||
|
||||
#define FRAME_MIN_SIZE 550, 60
|
||||
#define CONTECT_FRAME_MAX_SIZE 16777215, 60
|
||||
#define LABLE_MIN_WIDTH 188
|
||||
#define ITEM_MARGINS 16, 0, 16, 0
|
||||
|
||||
ConnectDevListItem::ConnectDevListItem(QString staMac, QString staName, QWidget *parent) :
|
||||
QFrame(parent),
|
||||
m_mac(staMac),
|
||||
m_hostName(staName)
|
||||
{
|
||||
this->setMinimumSize(FRAME_MIN_SIZE);
|
||||
this->setFixedHeight(60);
|
||||
|
||||
QHBoxLayout *hItemLayout = new QHBoxLayout(this);
|
||||
hItemLayout->setContentsMargins(ITEM_MARGINS);
|
||||
QLabel *nameLabel = new QLabel(staName, this);
|
||||
m_dragIntoBlackListBtn = new KBorderlessButton(this);
|
||||
m_dragIntoBlackListBtn->setText(tr("drag into blacklist"));
|
||||
hItemLayout->setSpacing(0);
|
||||
hItemLayout->addWidget(nameLabel, Qt::AlignLeft);
|
||||
hItemLayout->addStretch();
|
||||
hItemLayout->addWidget(m_dragIntoBlackListBtn, Qt::AlignRight);
|
||||
|
||||
m_dragIntoBlackListBtn->installEventFilter(this);
|
||||
this->setLayout(hItemLayout);
|
||||
}
|
||||
|
||||
bool ConnectDevListItem::eventFilter(QObject *w, QEvent *e)
|
||||
{
|
||||
if (e->type() == QEvent::MouseButtonRelease) {
|
||||
if (w == m_dragIntoBlackListBtn) {
|
||||
emit onBtnClicked(m_mac, m_hostName);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return QWidget::eventFilter(w,e);
|
||||
}
|
||||
|
|
@ -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 CONNECTDEVLISTITEM_H
|
||||
#define CONNECTDEVLISTITEM_H
|
||||
#include <QFrame>
|
||||
#include <QEvent>
|
||||
#include <QHBoxLayout>
|
||||
#include <QDebug>
|
||||
#include <QMouseEvent>
|
||||
#include <QMenu>
|
||||
#include <QLabel>
|
||||
#include "kborderlessbutton.h"
|
||||
|
||||
using namespace kdk;
|
||||
|
||||
class ConnectDevListItem : public QFrame
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ConnectDevListItem(QString staMac, QString staName, QWidget *parent = nullptr);
|
||||
|
||||
protected:
|
||||
KBorderlessButton *m_dragIntoBlackListBtn = nullptr;
|
||||
|
||||
QString m_mac;
|
||||
QString m_hostName;
|
||||
bool eventFilter(QObject *w, QEvent *e);
|
||||
|
||||
signals:
|
||||
void onBtnClicked(QString staMac, QString staName);
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif // LISTITEM_H
|
|
@ -0,0 +1,191 @@
|
|||
/* -*- 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 "connectdevpage.h"
|
||||
#include <QDebug>
|
||||
|
||||
#define CONTENTS_MARGINS 0, 0, 0, 0
|
||||
#define FRAME_MIN_SIZE 550, 60
|
||||
#define FRAME_MAX_SIZE 16777215, 16777215
|
||||
#define LINE_MAX_SIZE 16777215, 1
|
||||
#define LINE_MIN_SIZE 0, 1
|
||||
|
||||
#define LOG_HEAD "[ConnectdevPage]"
|
||||
|
||||
ConnectdevPage::ConnectdevPage(QWidget *parent) :
|
||||
QWidget(parent)
|
||||
{
|
||||
QVBoxLayout *Vlayout = new QVBoxLayout(this);
|
||||
Vlayout->setContentsMargins(CONTENTS_MARGINS);
|
||||
Vlayout->setSpacing(0);
|
||||
|
||||
m_staistFrame = new QFrame(this);
|
||||
m_staistFrame->setMinimumSize(FRAME_MIN_SIZE);
|
||||
m_staistFrame->setMaximumSize(FRAME_MAX_SIZE);
|
||||
m_staistFrame->setFrameShape(QFrame::Box);
|
||||
|
||||
m_staListLayout = new QVBoxLayout(m_staistFrame);
|
||||
m_staListLayout->setContentsMargins(0, 0, 0, 0);
|
||||
m_staListLayout->setSpacing(0);
|
||||
|
||||
m_titleLabel = new TitleLabel(this);
|
||||
m_titleLabel->setText(tr("Connect device"));
|
||||
|
||||
Vlayout->addWidget(m_titleLabel);
|
||||
Vlayout->addSpacing(8);
|
||||
Vlayout->addWidget(m_staistFrame);
|
||||
}
|
||||
|
||||
QFrame* ConnectdevPage::myLine()
|
||||
{
|
||||
QFrame *line = new QFrame(this);
|
||||
line->setMinimumSize(QSize(LINE_MIN_SIZE));
|
||||
line->setMaximumSize(QSize(LINE_MAX_SIZE));
|
||||
line->setLineWidth(0);
|
||||
line->setFrameShape(QFrame::HLine);
|
||||
line->setFrameShadow(QFrame::Sunken);
|
||||
|
||||
return line;
|
||||
}
|
||||
|
||||
void ConnectdevPage::getConnectStaDevice(QMap<QString, QString> &staMap)
|
||||
{
|
||||
staMap.clear();
|
||||
if (m_activePathInterface == nullptr || !m_activePathInterface->isValid()) {
|
||||
qDebug() << LOG_HEAD << "dbus interface m_activePathInterface is invaild";
|
||||
return;
|
||||
}
|
||||
|
||||
QDBusMessage reply = m_activePathInterface->call("Getstainfo");
|
||||
if(reply.type() == QDBusMessage::ErrorMessage)
|
||||
{
|
||||
qWarning() << LOG_HEAD << "Getstainfo error:" << reply.errorMessage();
|
||||
return;
|
||||
}
|
||||
|
||||
if (reply.arguments().isEmpty()
|
||||
|| reply.arguments().at(0).toString() == ""
|
||||
|| reply.arguments().at(0).toString() == "[Invalid UTF-8]"
|
||||
|| reply.arguments().at(1).toString() == "") {
|
||||
qDebug() << LOG_HEAD << "Dbus interface call Getstainfo return is empty!";
|
||||
return;
|
||||
}
|
||||
|
||||
QStringList macList = reply.arguments().at(0).toString().split(";");
|
||||
QStringList hostNameList = reply.arguments().at(1).toString().split(";");
|
||||
for (int index = 0; index < macList.count() && macList.at(index) != nullptr; index ++) {
|
||||
if (!staMap.contains(macList.at(index)) && hostNameList.at(index) != nullptr) {
|
||||
staMap[macList.at(index)] = hostNameList.at(index);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void ConnectdevPage::initStaDev()
|
||||
{
|
||||
QMap<QString, QString>::const_iterator item = m_staMap.cbegin();
|
||||
while (item != m_staMap.cend()) {
|
||||
addStaDevFrame(item.key(), item.value());
|
||||
item ++;
|
||||
if (item != m_staMap.cend()) {
|
||||
m_staListLayout->addWidget(myLine());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ConnectdevPage::addStaDevFrame(QString staMac, QString staName)
|
||||
{
|
||||
ConnectDevListItem *itemFrame = new ConnectDevListItem(staMac, staName, m_staListLayout->widget());
|
||||
m_staListLayout->addWidget(itemFrame);
|
||||
connect(itemFrame, &ConnectDevListItem::onBtnClicked, this, &ConnectdevPage::onDropIntoBlacklistBtnClicked);
|
||||
}
|
||||
|
||||
void ConnectdevPage::clearStaListLayout()
|
||||
{
|
||||
|
||||
if (m_staListLayout->layout() != NULL) {
|
||||
QLayoutItem* layoutItem;
|
||||
while ((layoutItem = m_staListLayout->layout()->takeAt(0)) != NULL) {
|
||||
delete layoutItem->widget();
|
||||
delete layoutItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ConnectdevPage::onStaDevAdded(bool istrue, QString staMac, QString staName)
|
||||
{
|
||||
if (!m_staMap.contains(staMac)) {
|
||||
m_staMap.insert(staMac, staName);
|
||||
clearStaListLayout();
|
||||
initStaDev();
|
||||
resetLayoutHight();
|
||||
}
|
||||
}
|
||||
|
||||
void ConnectdevPage::onStaDevRemoved(bool istrue, QString staMac, QString staName)
|
||||
{
|
||||
if (m_staMap.contains(staMac)) {
|
||||
if (m_staMap.remove(staMac)) {
|
||||
clearStaListLayout();
|
||||
initStaDev();
|
||||
resetLayoutHight();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ConnectdevPage::resetLayoutHight()
|
||||
{
|
||||
int height = 0;
|
||||
for (int i = 0; i < m_staListLayout->count(); i ++) {
|
||||
QWidget *w = m_staListLayout->itemAt(i)->widget();
|
||||
if (w != nullptr) {
|
||||
height += w->height();
|
||||
}
|
||||
}
|
||||
m_staistFrame->setFixedHeight(height);
|
||||
|
||||
if (m_staMap.isEmpty()) {
|
||||
this->hide();
|
||||
} else {
|
||||
this->show();
|
||||
}
|
||||
this->update();
|
||||
}
|
||||
|
||||
void ConnectdevPage::refreshStalist()
|
||||
{
|
||||
m_staMap.clear();
|
||||
getConnectStaDevice(m_staMap);
|
||||
clearStaListLayout();
|
||||
initStaDev();
|
||||
resetLayoutHight();
|
||||
}
|
||||
|
||||
void ConnectdevPage::onDropIntoBlacklistBtnClicked(QString staMac, QString staName)
|
||||
{
|
||||
if (staMac.isNull()
|
||||
|| staMac.isEmpty()
|
||||
|| staName.isNull()
|
||||
|| staName.isEmpty()) {
|
||||
qDebug() << LOG_HEAD <<"On drop into blacklist button clicked error! sta mac or name is empty!";
|
||||
return;
|
||||
}
|
||||
|
||||
emit setStaIntoBlacklist(staMac, staName);
|
||||
}
|
|
@ -0,0 +1,84 @@
|
|||
/* -*- 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 CONNECTDEVPAGE_H
|
||||
#define CONNECTDEVPAGE_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QLabel>
|
||||
#include <QHBoxLayout>
|
||||
|
||||
#include <QDBusMessage>
|
||||
#include <QDBusObjectPath>
|
||||
#include <QDBusInterface>
|
||||
#include <QDBusReply>
|
||||
#include <QDBusMetaType>
|
||||
|
||||
#include "titlelabel.h"
|
||||
#include "connectdevlistitem.h"
|
||||
|
||||
using namespace kdk;
|
||||
|
||||
class ConnectdevPage : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ConnectdevPage(QWidget *parent = nullptr);
|
||||
|
||||
void refreshStalist();
|
||||
|
||||
inline void setInterface(QDBusInterface *activeInterface) {
|
||||
m_activePathInterface = activeInterface;
|
||||
}
|
||||
|
||||
private:
|
||||
QFrame* myLine();
|
||||
|
||||
void getConnectStaDevice(QMap<QString, QString> &blacklistMap);
|
||||
bool removeStaFromBlacklist(QString staMac);
|
||||
void initStaDev();
|
||||
void addStaDevFrame(QString staMac, QString staName);
|
||||
void clearStaListLayout();
|
||||
QString getActivePathByUuid(QDBusInterface *interface);
|
||||
void initNmDbus(QDBusInterface *interface);
|
||||
|
||||
void onStaDevChanged(bool istrue, QString staMac, QString staName);
|
||||
void resetLayoutHight();
|
||||
|
||||
private:
|
||||
QFrame *m_staistFrame = nullptr;
|
||||
|
||||
TitleLabel *m_titleLabel = nullptr;
|
||||
QVBoxLayout *m_staListLayout = nullptr;
|
||||
QMap<QString, QString> m_staMap;
|
||||
|
||||
QDBusInterface *m_activePathInterface = nullptr;
|
||||
|
||||
signals:
|
||||
void setStaIntoBlacklist(QString staMac, QString staName);
|
||||
|
||||
public slots:
|
||||
void onStaDevAdded(bool istrue, QString staMac, QString staName);
|
||||
void onStaDevRemoved(bool istrue, QString staMac, QString staName);
|
||||
|
||||
private slots:
|
||||
void onDropIntoBlacklistBtnClicked(QString staMac, QString staName);
|
||||
};
|
||||
|
||||
#endif // MOBILEHOTSPOTWIDGET_H
|
|
@ -25,10 +25,18 @@ PKGCONFIG += gsettings-qt \
|
|||
#DEFINES += QT_DEPRECATED_WARNINGS
|
||||
|
||||
SOURCES += \
|
||||
blacklistpage.cpp \
|
||||
blacklistitem.cpp \
|
||||
connectdevpage.cpp \
|
||||
connectdevlistitem.cpp \
|
||||
mobilehotspot.cpp \
|
||||
mobilehotspotwidget.cpp
|
||||
|
||||
HEADERS += \
|
||||
blacklistpage.h \
|
||||
blacklistitem.h \
|
||||
connectdevpage.h \
|
||||
connectdevlistitem.h \
|
||||
mobilehotspot.h \
|
||||
mobilehotspotwidget.h \
|
||||
libukcc_global.h
|
||||
|
@ -40,4 +48,6 @@ INSTALLS += target \
|
|||
TRANSLATIONS += \
|
||||
translations/zh_CN.ts \
|
||||
translations/tr.ts \
|
||||
translations/bo.ts
|
||||
translations/bo.ts\
|
||||
translations/bo_CN.ts \
|
||||
translations/en_US.ts
|
||||
|
|
|
@ -1,5 +1,25 @@
|
|||
/* -*- 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 "mobilehotspotwidget.h"
|
||||
#include <QDebug>
|
||||
#include <QFormLayout>
|
||||
|
||||
#define LABEL_RECT 17, 0, 105, 23
|
||||
#define CONTENTS_MARGINS 0, 0, 0, 0
|
||||
|
@ -7,16 +27,30 @@
|
|||
#define FRAME_MIN_SIZE 550, 60
|
||||
#define FRAME_MAX_SIZE 16777215, 16777215
|
||||
#define CONTECT_FRAME_MAX_SIZE 16777215, 60
|
||||
|
||||
#define HINT_TEXT_MARGINS 8, 0, 0, 0
|
||||
#define FRAME_MIN_SIZE 550, 60
|
||||
|
||||
#define LABLE_MIN_WIDTH 188
|
||||
#define COMBOBOX_MIN_WIDTH 200
|
||||
#define LINE_MAX_SIZE 16777215, 1
|
||||
#define LINE_MIN_SIZE 0, 1
|
||||
#define ICON_SIZE 24,24
|
||||
|
||||
#define PASSWORD_FRAME_MIN_HIGHT 60
|
||||
#define PASSWORD_FRAME_FIX_HIGHT 80
|
||||
#define PASSWORD_FRAME_MIN_SIZE 550, 60
|
||||
#define PASSWORD_FRAME_MAX_SIZE 16777215, 86
|
||||
#define PASSWORD_ITEM_MARGINS 16, 12, 16, 14
|
||||
|
||||
#define WIRELESS 1
|
||||
|
||||
#define AP_NAME_MAX_LENGTH 32
|
||||
|
||||
#define REFRESH_MSEC 20*1000
|
||||
|
||||
#define LOG_HEAD "[MobileHotspotWidget]"
|
||||
|
||||
const QByteArray GSETTINGS_SCHEMA = "org.ukui.kylin-nm.switch";
|
||||
const QString WIRELESS_SWITCH = "wirelessswitch";
|
||||
|
||||
|
@ -29,7 +63,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()
|
||||
|
@ -38,10 +72,13 @@ void MobileHotspotWidget::showDesktopNotify(const QString &message)
|
|||
iface.callWithArgumentList(QDBus::AutoDetect,"Notify",args);
|
||||
}
|
||||
|
||||
#define HOTSPOT_CONTROL
|
||||
|
||||
MobileHotspotWidget::MobileHotspotWidget(QWidget *parent) : QWidget(parent)
|
||||
{
|
||||
mVlayout = new QVBoxLayout(this);
|
||||
mVlayout->setContentsMargins(CONTENTS_MARGINS);
|
||||
m_Vlayout = new QVBoxLayout(this);
|
||||
m_Vlayout->setContentsMargins(CONTENTS_MARGINS);
|
||||
m_Vlayout->setSpacing(0);
|
||||
|
||||
qDBusRegisterMetaType<QMap<QString, bool> >();
|
||||
qDBusRegisterMetaType<QMap<QString, int> >();
|
||||
|
@ -49,12 +86,18 @@ MobileHotspotWidget::MobileHotspotWidget(QWidget *parent) : QWidget(parent)
|
|||
qDBusRegisterMetaType<QMap<QString, QVector<QStringList> >>();
|
||||
|
||||
initUI();
|
||||
|
||||
#ifdef HOTSPOT_CONTROL
|
||||
initConnectDevPage();
|
||||
initBlackListPage();
|
||||
#endif
|
||||
|
||||
m_switchBtn->installEventFilter(this);
|
||||
m_interface = new QDBusInterface("com.kylin.network", "/com/kylin/network",
|
||||
"com.kylin.network",
|
||||
QDBusConnection::sessionBus());
|
||||
if(!m_interface->isValid()) {
|
||||
qDebug() << "dbus interface com.kylin.network is invaild";
|
||||
qDebug() << LOG_HEAD << "dbus interface com.kylin.network is invaild";
|
||||
m_switchBtn->setChecked(false);
|
||||
setUiEnabled(false);
|
||||
}
|
||||
|
@ -66,15 +109,30 @@ MobileHotspotWidget::MobileHotspotWidget(QWidget *parent) : QWidget(parent)
|
|||
initInterfaceInfo();
|
||||
getApInfo();
|
||||
|
||||
#ifdef HOTSPOT_CONTROL
|
||||
initNmDbus();
|
||||
#endif
|
||||
|
||||
this->setLayout(m_Vlayout);
|
||||
m_Vlayout->addStretch();
|
||||
|
||||
connect(m_switchBtn, &KSwitchButton::stateChanged, this, &MobileHotspotWidget::setUiEnabled);
|
||||
connect(m_interfaceComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged), this, [=]() {
|
||||
m_interfaceName = m_interfaceComboBox->currentText();
|
||||
updateBandCombox();
|
||||
});
|
||||
|
||||
#ifdef HOTSPOT_CONTROL
|
||||
m_connectDevPage->refreshStalist();
|
||||
m_blacklistPage->refreshBlacklist();
|
||||
#endif
|
||||
this->update();
|
||||
}
|
||||
|
||||
MobileHotspotWidget::~MobileHotspotWidget()
|
||||
{
|
||||
deleteActivePathInterface();
|
||||
deleteSettingPathInterface();
|
||||
delete m_interface;
|
||||
}
|
||||
|
||||
|
@ -84,8 +142,9 @@ bool MobileHotspotWidget::eventFilter(QObject *watched, QEvent *event)
|
|||
return true;
|
||||
}
|
||||
|
||||
if (event->type() == QEvent::MouseButtonRelease) {
|
||||
|
||||
if (watched == m_switchBtn) {
|
||||
if (event->type() == QEvent::MouseButtonRelease) {
|
||||
if (!m_interface->isValid()) {
|
||||
return true;
|
||||
}
|
||||
|
@ -94,12 +153,19 @@ 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 ";
|
||||
qDebug() << LOG_HEAD << "call deactiveWirelessAp failed ";
|
||||
return true;
|
||||
}
|
||||
#ifdef HOTSPOT_CONTROL
|
||||
deleteActivePathInterface();
|
||||
m_connectDevPage->setInterface(nullptr);
|
||||
m_connectDevPage->refreshStalist();
|
||||
m_blacklistPage->refreshBlacklist();
|
||||
#endif
|
||||
this->update();
|
||||
} else {
|
||||
if (m_apNameLine->text().isEmpty() || m_interfaceName.isEmpty())
|
||||
{
|
||||
|
@ -107,17 +173,17 @@ bool MobileHotspotWidget::eventFilter(QObject *watched, QEvent *event)
|
|||
return true;
|
||||
}
|
||||
if (m_pwdNameLine->text().length() < 8) {
|
||||
showDesktopNotify(tr("can not create hotspot with password length less than eight!"));
|
||||
// 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(),
|
||||
m_freqBandComboBox->currentText(),
|
||||
m_interfaceComboBox->currentText());
|
||||
if (!reply.isValid()) {
|
||||
qDebug() << "[MobileHotspotWidget] call deactiveWirelessAp failed ";
|
||||
qDebug() << LOG_HEAD << "call activeWirelessAp failed ";
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -132,15 +198,28 @@ void MobileHotspotWidget::paintEvent(QPaintEvent *event)
|
|||
QWidget::paintEvent(event);
|
||||
}
|
||||
|
||||
void MobileHotspotWidget::resetFrameSize()
|
||||
{
|
||||
int height = 0;
|
||||
for (int i = 0; i < m_hotspotFrame->layout()->count(); i ++) {
|
||||
QWidget *w = m_hotspotFrame->layout()->itemAt(i)->widget();
|
||||
if (w != nullptr && !w->isHidden()) {
|
||||
height += w->height();
|
||||
}
|
||||
}
|
||||
m_hotspotFrame->setFixedHeight(height);
|
||||
}
|
||||
|
||||
void MobileHotspotWidget::initUI()
|
||||
{
|
||||
QFrame *hotspotFrame = new QFrame(this);
|
||||
hotspotFrame->setMinimumSize(FRAME_MIN_SIZE);
|
||||
hotspotFrame->setMaximumSize(FRAME_MAX_SIZE);
|
||||
hotspotFrame->setFrameShape(QFrame::Box);
|
||||
m_hotspotFrame = new QFrame(this);
|
||||
m_hotspotFrame->setMinimumSize(FRAME_MIN_SIZE);
|
||||
m_hotspotFrame->setMaximumSize(FRAME_MAX_SIZE);
|
||||
m_hotspotFrame->setFrameShape(QFrame::Box);
|
||||
|
||||
QVBoxLayout *hotspotLyt = new QVBoxLayout(hotspotFrame);
|
||||
QVBoxLayout *hotspotLyt = new QVBoxLayout(this);
|
||||
hotspotLyt->setContentsMargins(0, 0, 0, 0);
|
||||
m_hotspotFrame->setLayout(hotspotLyt);
|
||||
|
||||
m_hotspotTitleLabel = new TitleLabel(this);
|
||||
m_hotspotTitleLabel->setText(tr("Hotspot"));
|
||||
|
@ -156,7 +235,6 @@ void MobileHotspotWidget::initUI()
|
|||
pwdAndfreqBandLine = myLine();
|
||||
freqBandAndInterfaceLine = myLine();
|
||||
|
||||
/* add widget */
|
||||
hotspotLyt->addWidget(m_switchFrame);
|
||||
hotspotLyt->addWidget(switchAndApNameLine);
|
||||
hotspotLyt->addWidget(m_ApNameFrame);
|
||||
|
@ -168,10 +246,12 @@ void MobileHotspotWidget::initUI()
|
|||
hotspotLyt->addWidget(m_interfaceFrame);
|
||||
hotspotLyt->setSpacing(0);
|
||||
|
||||
mVlayout->addWidget(m_hotspotTitleLabel);
|
||||
mVlayout->setSpacing(8);
|
||||
mVlayout->addWidget(hotspotFrame);
|
||||
mVlayout->addStretch();
|
||||
resetFrameSize();
|
||||
|
||||
m_Vlayout->addWidget(m_hotspotTitleLabel);
|
||||
m_Vlayout->addSpacing(8);
|
||||
m_Vlayout->addWidget(m_hotspotFrame);
|
||||
|
||||
}
|
||||
|
||||
void MobileHotspotWidget::initDbusConnect()
|
||||
|
@ -182,18 +262,20 @@ void MobileHotspotWidget::initDbusConnect()
|
|||
connect(m_interface,SIGNAL(deviceStatusChanged()), this, SLOT(onDeviceStatusChanged()), Qt::QueuedConnection);
|
||||
connect(m_interface,SIGNAL(deviceNameChanged(QString, QString, int)), this, SLOT(onDeviceNameChanged(QString, QString, int)), Qt::QueuedConnection);
|
||||
connect(m_interface,SIGNAL(hotspotDeactivated(QString, QString)), this, SLOT(onHotspotDeactivated(QString, QString)), Qt::QueuedConnection);
|
||||
connect(m_interface,SIGNAL(hotspotActivated(QString, QString, QString)), this, SLOT(onHotspotActivated(QString, QString, QString)), Qt::QueuedConnection);
|
||||
|
||||
connect(m_interface,SIGNAL(hotspotActivated(QString, QString, QString, QString, QString)), this, SLOT(onHotspotActivated(QString, QString, QString, QString, QString)), Qt::QueuedConnection);
|
||||
|
||||
connect(m_interface, SIGNAL(wlanactiveConnectionStateChanged(QString, QString, QString, int)), this, SLOT(onActiveConnectionChanged(QString, QString, QString, int)), Qt::QueuedConnection);
|
||||
|
||||
connect(m_interface, SIGNAL(wirelessSwitchBtnChanged(bool)), this, SLOT(onWirelessBtnChanged(bool)), Qt::QueuedConnection);
|
||||
}
|
||||
|
||||
if (QGSettings::isSchemaInstalled(GSETTINGS_SCHEMA)) {
|
||||
m_switchGsettings = new QGSettings(GSETTINGS_SCHEMA);
|
||||
onGsettingChanged(WIRELESS_SWITCH);
|
||||
connect(m_switchGsettings, &QGSettings::changed, this, &MobileHotspotWidget::onGsettingChanged, Qt::QueuedConnection);
|
||||
}
|
||||
|
||||
connect(m_apNameLine, &QLineEdit::textEdited, this, &MobileHotspotWidget::onApLineEditTextEdit);
|
||||
#ifdef HOTSPOT_CONTROL
|
||||
connect(m_connectDevPage, SIGNAL(setStaIntoBlacklist(QString, QString)), m_blacklistPage, SLOT(onsetStaIntoBlacklist(QString, QString)));
|
||||
#endif
|
||||
connect(m_pwdNameLine, SIGNAL(textChanged(QString)), this, SLOT(onPwdTextChanged()));
|
||||
}
|
||||
|
||||
void MobileHotspotWidget::onApLineEditTextEdit(QString text)
|
||||
|
@ -211,6 +293,18 @@ void MobileHotspotWidget::onApLineEditTextEdit(QString text)
|
|||
m_apNameLine->setText(text.left(i));
|
||||
}
|
||||
|
||||
void MobileHotspotWidget::onPwdTextChanged()
|
||||
{
|
||||
if (m_pwdNameLine->text().length() < 8) {
|
||||
m_passwordFrame->setFixedHeight(PASSWORD_FRAME_FIX_HIGHT);
|
||||
m_pwdHintLabel->show();
|
||||
} else {
|
||||
m_passwordFrame->setFixedHeight(PASSWORD_FRAME_MIN_HIGHT);
|
||||
m_pwdHintLabel->hide();
|
||||
}
|
||||
resetFrameSize();
|
||||
this->update();
|
||||
}
|
||||
|
||||
void MobileHotspotWidget::onActiveConnectionChanged(QString deviceName, QString ssid, QString uuid, int status)
|
||||
{
|
||||
|
@ -222,30 +316,15 @@ void MobileHotspotWidget::onActiveConnectionChanged(QString deviceName, QString
|
|||
}
|
||||
}
|
||||
|
||||
void MobileHotspotWidget::onGsettingChanged(const QString &key)
|
||||
void MobileHotspotWidget::onWirelessBtnChanged(bool state)
|
||||
{
|
||||
if (key == WIRELESS_SWITCH) {
|
||||
bool status = m_switchGsettings->get(WIRELESS_SWITCH).toBool();
|
||||
if (!status) {
|
||||
// if (m_switchBtn->isChecked()) {
|
||||
// if(m_interface->isValid()) {
|
||||
// QDBusReply<void> reply = m_interface->call("deactiveWirelessAp",
|
||||
// m_apNameLine->text(),
|
||||
// m_pwdNameLine->text(),
|
||||
// m_interfaceComboBox->currentText());
|
||||
// if (!reply.isValid()) {
|
||||
// qDebug() << "[MobileHotspotWidget] call deactiveWirelessAp failed ";
|
||||
// return true;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
m_switchBtn->setChecked(status);
|
||||
if (!state) {
|
||||
m_switchBtn->setChecked(state);
|
||||
m_uuid.clear();
|
||||
m_switchBtn->setCheckable(false);
|
||||
} else {
|
||||
m_switchBtn->setCheckable(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MobileHotspotWidget::initInterfaceInfo()
|
||||
|
@ -257,7 +336,7 @@ void MobileHotspotWidget::initInterfaceInfo()
|
|||
QDBusReply<QMap<QString, bool> > reply = m_interface->call("getDeviceListAndEnabled",WIRELESS);
|
||||
|
||||
if (!reply.isValid()) {
|
||||
qDebug()<<"execute dbus method 'getDeviceListAndEnabled' is invalid in func initInterfaceInfo()";
|
||||
qDebug() << LOG_HEAD <<"execute dbus method 'getDeviceListAndEnabled' is invalid in func initInterfaceInfo()";
|
||||
setWidgetHidden(true);
|
||||
return;
|
||||
}
|
||||
|
@ -265,7 +344,7 @@ void MobileHotspotWidget::initInterfaceInfo()
|
|||
|
||||
QDBusReply<QMap<QString, int> > capReply = m_interface->call("getWirelessDeviceCap");
|
||||
if (!capReply.isValid()) {
|
||||
qDebug()<<"execute dbus method 'getWirelessDeviceCap' is invalid in func initInterfaceInfo()" <<capReply.error().type() ;
|
||||
qDebug() << LOG_HEAD <<"execute dbus method 'getWirelessDeviceCap' is invalid in func initInterfaceInfo()" <<capReply.error().type() ;
|
||||
setWidgetHidden(true);
|
||||
return;
|
||||
}
|
||||
|
@ -273,7 +352,7 @@ void MobileHotspotWidget::initInterfaceInfo()
|
|||
|
||||
|
||||
if (devMap.isEmpty()) {
|
||||
qDebug() << "no wireless device";
|
||||
qDebug() << LOG_HEAD << "no wireless device";
|
||||
setWidgetHidden(true);
|
||||
m_switchBtn->setCheckable(false);
|
||||
} else {
|
||||
|
@ -292,7 +371,7 @@ void MobileHotspotWidget::initInterfaceInfo()
|
|||
updateBandCombox();
|
||||
}
|
||||
} else {
|
||||
qDebug() << "no useable wireless device";
|
||||
qDebug() << LOG_HEAD << "no useable wireless device";
|
||||
setWidgetHidden(true);
|
||||
}
|
||||
}
|
||||
|
@ -307,20 +386,20 @@ void MobileHotspotWidget::getApInfo()
|
|||
if (m_interfaceComboBox->count() <= 0) {
|
||||
m_switchBtn->setChecked(false);
|
||||
setWidgetHidden(true);
|
||||
qWarning() << "getApInfo but interface is empty";
|
||||
qWarning() << LOG_HEAD << "getApInfo but interface is empty";
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
QDBusReply<QStringList> reply = m_interface->call("getStoredApInfo");
|
||||
if (!reply.isValid()) {
|
||||
qDebug()<<"execute dbus method 'getStoredApInfo' is invalid in func getObjectPath()";
|
||||
qDebug() << LOG_HEAD <<"execute dbus method 'getStoredApInfo' is invalid in func getObjectPath()";
|
||||
}
|
||||
|
||||
QStringList apInfo = reply.value();
|
||||
|
||||
if (apInfo.isEmpty()) {
|
||||
qDebug() << "no stored hotspot info";
|
||||
qDebug() << LOG_HEAD << "no stored hotspot info";
|
||||
m_apNameLine->setText(m_hostName);
|
||||
m_pwdNameLine->setText("12345678");
|
||||
return;
|
||||
|
@ -338,9 +417,10 @@ void MobileHotspotWidget::getApInfo()
|
|||
} else {
|
||||
m_switchBtn->setChecked(false);
|
||||
setUiEnabled(false);
|
||||
m_uuid = apInfo.at(4);
|
||||
}
|
||||
} else {
|
||||
qDebug() << "no such interface " << apInfo.at(2);
|
||||
qDebug() << LOG_HEAD << "no such interface " << apInfo.at(2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -353,7 +433,7 @@ void MobileHotspotWidget::setSwitchFrame()
|
|||
m_switchFrame->setMinimumSize(FRAME_MIN_SIZE);
|
||||
m_switchFrame->setMaximumSize(CONTECT_FRAME_MAX_SIZE);
|
||||
|
||||
QHBoxLayout *switchLayout = new QHBoxLayout();
|
||||
QHBoxLayout *switchLayout = new QHBoxLayout(m_switchFrame);
|
||||
|
||||
m_switchLabel = new QLabel(tr("Open"), this);
|
||||
m_switchLabel->setMinimumWidth(LABLE_MIN_WIDTH);
|
||||
|
@ -374,7 +454,7 @@ void MobileHotspotWidget::setApNameFrame()
|
|||
m_ApNameFrame->setMinimumSize(FRAME_MIN_SIZE);
|
||||
m_ApNameFrame->setMaximumSize(CONTECT_FRAME_MAX_SIZE);
|
||||
|
||||
QHBoxLayout *apNameHLayout = new QHBoxLayout();
|
||||
QHBoxLayout *apNameHLayout = new QHBoxLayout(m_ApNameFrame);
|
||||
|
||||
m_apNameLabel = new QLabel(tr("Wi-Fi Name"), this);
|
||||
m_apNameLabel->setMinimumWidth(LABLE_MIN_WIDTH);
|
||||
|
@ -394,22 +474,38 @@ void MobileHotspotWidget::setPasswordFrame()
|
|||
/* Password */
|
||||
m_passwordFrame = new QFrame(this);
|
||||
m_passwordFrame->setFrameShape(QFrame::Shape::NoFrame);
|
||||
m_passwordFrame->setMinimumSize(FRAME_MIN_SIZE);
|
||||
m_passwordFrame->setMaximumSize(CONTECT_FRAME_MAX_SIZE);
|
||||
|
||||
QHBoxLayout *passwordHLayout = new QHBoxLayout();
|
||||
m_passwordFrame->setMinimumSize(PASSWORD_FRAME_MIN_SIZE);
|
||||
m_passwordFrame->setMaximumSize(PASSWORD_FRAME_MAX_SIZE);
|
||||
|
||||
m_pwdLabel = new QLabel(tr("Password"), this);
|
||||
m_pwdLabel->setMinimumWidth(LABLE_MIN_WIDTH);
|
||||
m_pwdNameLine = new KPasswordEdit(this);
|
||||
m_pwdNameLine->setClearButtonEnabled(false);//禁用ClearBtn按钮X
|
||||
m_pwdNameLine->setMinimumWidth(COMBOBOX_MIN_WIDTH);
|
||||
passwordHLayout->setContentsMargins(ITEM_MARGINS);
|
||||
passwordHLayout->setSpacing(0);
|
||||
passwordHLayout->addWidget(m_pwdLabel);
|
||||
passwordHLayout->addWidget(m_pwdNameLine);
|
||||
m_pwdHintLabel= new QLabel(this);
|
||||
m_pwdHintLabel->setFixedHeight(20);
|
||||
m_pwdHintLabel->setContentsMargins(HINT_TEXT_MARGINS);
|
||||
|
||||
m_passwordFrame->setLayout(passwordHLayout);
|
||||
QPalette hintTextColor;
|
||||
hintTextColor.setColor(QPalette::WindowText, Qt::red);
|
||||
m_pwdHintLabel->setPalette(hintTextColor);
|
||||
m_pwdHintLabel->setText(tr("Contains at least 8 characters")); //至少包含8个字符
|
||||
|
||||
QWidget *pwdInputWidget = new QWidget(m_passwordFrame);
|
||||
QVBoxLayout *pwdInputVLayout = new QVBoxLayout(pwdInputWidget);
|
||||
pwdInputVLayout->setContentsMargins(CONTENTS_MARGINS);
|
||||
pwdInputVLayout->setSpacing(0);
|
||||
pwdInputVLayout->addWidget(m_pwdNameLine);
|
||||
pwdInputVLayout->addWidget(m_pwdHintLabel);
|
||||
|
||||
QFormLayout *pwdLayout = new QFormLayout(m_passwordFrame);
|
||||
pwdLayout->setContentsMargins(PASSWORD_ITEM_MARGINS);
|
||||
pwdLayout->setSpacing(0);
|
||||
pwdLayout->addRow(m_pwdLabel, pwdInputWidget);
|
||||
|
||||
m_passwordFrame->setLayout(pwdLayout);
|
||||
|
||||
m_pwdNameLine->installEventFilter(this);
|
||||
}
|
||||
|
||||
void MobileHotspotWidget::setFreqBandFrame()
|
||||
|
@ -420,7 +516,7 @@ void MobileHotspotWidget::setFreqBandFrame()
|
|||
m_freqBandFrame->setMinimumSize(FRAME_MIN_SIZE);
|
||||
m_freqBandFrame->setMaximumSize(CONTECT_FRAME_MAX_SIZE);
|
||||
|
||||
QHBoxLayout *freqBandHLayout = new QHBoxLayout();
|
||||
QHBoxLayout *freqBandHLayout = new QHBoxLayout(m_freqBandFrame);
|
||||
|
||||
m_freqBandLabel = new QLabel(tr("Frequency band"), this);
|
||||
m_freqBandLabel->setMinimumWidth(LABLE_MIN_WIDTH);
|
||||
|
@ -428,8 +524,8 @@ void MobileHotspotWidget::setFreqBandFrame()
|
|||
m_freqBandComboBox->setInsertPolicy(QComboBox::NoInsert);
|
||||
m_freqBandComboBox->setMinimumWidth(COMBOBOX_MIN_WIDTH);
|
||||
m_freqBandComboBox->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed);
|
||||
m_freqBandComboBox->addItem("2.4Ghz");
|
||||
m_freqBandComboBox->addItem("5Ghz");
|
||||
m_freqBandComboBox->addItem("2.4GHz");
|
||||
m_freqBandComboBox->addItem("5GHz");
|
||||
freqBandHLayout->setContentsMargins(ITEM_MARGINS);
|
||||
freqBandHLayout->setSpacing(0);
|
||||
freqBandHLayout->addWidget(m_freqBandLabel);
|
||||
|
@ -446,7 +542,7 @@ void MobileHotspotWidget::setInterFaceFrame()
|
|||
m_interfaceFrame->setMinimumSize(FRAME_MIN_SIZE);
|
||||
m_interfaceFrame->setMaximumSize(CONTECT_FRAME_MAX_SIZE);
|
||||
|
||||
QHBoxLayout *interfaceHLayout = new QHBoxLayout;
|
||||
QHBoxLayout *interfaceHLayout = new QHBoxLayout(m_interfaceFrame);
|
||||
|
||||
m_interfaceLabel = new QLabel(tr("Net card"), this);
|
||||
m_interfaceLabel->setMinimumWidth(LABLE_MIN_WIDTH);
|
||||
|
@ -513,12 +609,26 @@ void MobileHotspotWidget::onHotspotDeactivated(QString devName, QString ssid)
|
|||
}
|
||||
|
||||
//热点连接
|
||||
void MobileHotspotWidget::onHotspotActivated(QString devName, QString ssid, QString uuid)
|
||||
void MobileHotspotWidget::onHotspotActivated(QString devName, QString ssid, QString uuid, QString activePath, QString settingPath)
|
||||
{
|
||||
qDebug() << "onHotspotActivated" <<devName << ssid << uuid;
|
||||
qDebug() << LOG_HEAD << "onHotspotActivated" <<devName << ssid << uuid;
|
||||
if (m_switchBtn->isChecked()) {
|
||||
return;
|
||||
}
|
||||
#ifdef HOTSPOT_CONTROL
|
||||
if (activePath != nullptr) {
|
||||
deleteActivePathInterface();
|
||||
initActivePathInterface(activePath);
|
||||
}
|
||||
if (settingPath != nullptr) {
|
||||
deleteSettingPathInterface();
|
||||
initSettingPathInterface(settingPath);
|
||||
}
|
||||
|
||||
m_connectDevPage->refreshStalist();
|
||||
m_blacklistPage->refreshBlacklist();
|
||||
#endif
|
||||
this->update();
|
||||
|
||||
if (devName == m_interfaceComboBox->currentText() && ssid == m_apNameLine->text()) {
|
||||
m_switchBtn->setChecked(true);
|
||||
|
@ -604,9 +714,11 @@ void MobileHotspotWidget::setWidgetHidden(bool isHidden)
|
|||
m_uuid = "";
|
||||
} else {
|
||||
m_switchBtn->setCheckable(true);
|
||||
onGsettingChanged(WIRELESS_SWITCH);
|
||||
QDBusReply<bool> reply = m_interface->call("getWirelessSwitchBtnState");
|
||||
bool state = reply.value();
|
||||
onWirelessBtnChanged(state);
|
||||
}
|
||||
|
||||
resetFrameSize();
|
||||
}
|
||||
|
||||
void MobileHotspotWidget::updateBandCombox()
|
||||
|
@ -620,10 +732,10 @@ void MobileHotspotWidget::updateBandCombox()
|
|||
}
|
||||
QMap<QString, int> devCapMap = capReply.value();
|
||||
if (devCapMap[m_interfaceName] & 0x02) {
|
||||
m_freqBandComboBox->addItem("2.4Ghz");
|
||||
m_freqBandComboBox->addItem("2.4GHz");
|
||||
}
|
||||
if (devCapMap[m_interfaceName] & 0x04) {
|
||||
m_freqBandComboBox->addItem("5Ghz");
|
||||
m_freqBandComboBox->addItem("5GHz");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -655,3 +767,120 @@ QString MobileHotspotWidget::getHostName()
|
|||
}
|
||||
return "default";
|
||||
}
|
||||
|
||||
QString MobileHotspotWidget::getSettingPathByUuid()
|
||||
{
|
||||
if (!m_interface->isValid()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
QDBusReply<QString> reply = m_interface->call("getApConnectionPath", m_uuid);
|
||||
if (!reply.isValid()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return reply.value();
|
||||
}
|
||||
|
||||
QString MobileHotspotWidget::getActivePathByUuid()
|
||||
{
|
||||
if (!m_interface->isValid()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
QDBusReply<QString> reply = m_interface->call("getActiveConnectionPath", m_uuid);
|
||||
if (!reply.isValid()) {
|
||||
return nullptr;
|
||||
}
|
||||
return reply.value();
|
||||
}
|
||||
|
||||
void MobileHotspotWidget::initNmDbus()
|
||||
{
|
||||
QString activePath = getActivePathByUuid();
|
||||
QString settingPath = getSettingPathByUuid();
|
||||
|
||||
if (activePath != nullptr) {
|
||||
m_activePathInterface = new QDBusInterface("org.freedesktop.NetworkManager",
|
||||
activePath,
|
||||
"org.freedesktop.NetworkManager.Connection.Active",
|
||||
QDBusConnection::systemBus());
|
||||
if (m_activePathInterface->isValid()) {
|
||||
m_connectDevPage->setInterface(m_activePathInterface);
|
||||
|
||||
connect(m_activePathInterface, SIGNAL(NewStaConnected(bool, QString, QString)), m_connectDevPage, SLOT(onStaDevAdded(bool, QString, QString)), Qt::QueuedConnection);
|
||||
connect(m_activePathInterface, SIGNAL(StaRemoved(bool, QString, QString)), m_connectDevPage, SLOT(onStaDevRemoved(bool, QString, QString)), Qt::QueuedConnection);
|
||||
}
|
||||
}
|
||||
|
||||
if (settingPath != nullptr) {
|
||||
m_settingPathInterface = new QDBusInterface("org.freedesktop.NetworkManager",
|
||||
settingPath,
|
||||
"org.freedesktop.NetworkManager.Settings.Connection",
|
||||
QDBusConnection::systemBus());
|
||||
if (m_settingPathInterface->isValid()) {
|
||||
m_blacklistPage->setInterface(m_settingPathInterface);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MobileHotspotWidget::initActivePathInterface(QString path)
|
||||
{
|
||||
if (path != nullptr){
|
||||
m_activePathInterface = new QDBusInterface("org.freedesktop.NetworkManager",
|
||||
path,
|
||||
"org.freedesktop.NetworkManager.Connection.Active",
|
||||
QDBusConnection::systemBus());
|
||||
if (m_activePathInterface->isValid()) {
|
||||
m_connectDevPage->setInterface(m_activePathInterface);
|
||||
|
||||
connect(m_activePathInterface, SIGNAL(NewStaConnected(bool, QString, QString)), m_connectDevPage, SLOT(onStaDevAdded(bool, QString, QString)), Qt::QueuedConnection);
|
||||
connect(m_activePathInterface, SIGNAL(StaRemoved(bool, QString, QString)), m_connectDevPage, SLOT(onStaDevRemoved(bool, QString, QString)), Qt::QueuedConnection);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MobileHotspotWidget::deleteActivePathInterface()
|
||||
{
|
||||
if (m_activePathInterface != nullptr){
|
||||
disconnect(m_activePathInterface);
|
||||
delete m_activePathInterface;
|
||||
m_activePathInterface = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void MobileHotspotWidget::initSettingPathInterface(QString path)
|
||||
{
|
||||
if (path != nullptr){
|
||||
m_settingPathInterface = new QDBusInterface("org.freedesktop.NetworkManager",
|
||||
path,
|
||||
"org.freedesktop.NetworkManager.Settings.Connection",
|
||||
QDBusConnection::systemBus());
|
||||
if (m_settingPathInterface->isValid()) {
|
||||
m_blacklistPage->setInterface(m_settingPathInterface);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MobileHotspotWidget::deleteSettingPathInterface()
|
||||
{
|
||||
if (m_settingPathInterface != nullptr){
|
||||
disconnect(m_settingPathInterface);
|
||||
delete m_settingPathInterface;
|
||||
m_settingPathInterface = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void MobileHotspotWidget::initConnectDevPage()
|
||||
{
|
||||
m_connectDevPage = new ConnectdevPage(this);
|
||||
m_Vlayout->addSpacing(32);
|
||||
m_Vlayout->addWidget(m_connectDevPage);
|
||||
}
|
||||
|
||||
void MobileHotspotWidget::initBlackListPage()
|
||||
{
|
||||
m_blacklistPage = new BlacklistPage(this);
|
||||
m_Vlayout->addSpacing(32);
|
||||
m_Vlayout->addWidget(m_blacklistPage);
|
||||
}
|
||||
|
|
|
@ -1,3 +1,22 @@
|
|||
/* -*- 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 MOBILEHOTSPOTWIDGET_H
|
||||
#define MOBILEHOTSPOTWIDGET_H
|
||||
|
||||
|
@ -11,18 +30,22 @@
|
|||
|
||||
#include <QTranslator>
|
||||
#include <QApplication>
|
||||
|
||||
#include <QTimer>
|
||||
|
||||
#include <QDBusMessage>
|
||||
#include <QDBusObjectPath>
|
||||
#include <QDBusInterface>
|
||||
#include <QDBusReply>
|
||||
#include <QDBusMetaType>
|
||||
#include <QScrollArea>
|
||||
|
||||
#include "titlelabel.h"
|
||||
#include "kwidget.h"
|
||||
#include "kswitchbutton.h"
|
||||
#include "kpasswordedit.h"
|
||||
#include "connectdevlistitem.h"
|
||||
#include "blacklistpage.h"
|
||||
#include "connectdevpage.h"
|
||||
|
||||
using namespace kdk;
|
||||
|
||||
|
@ -34,6 +57,7 @@ public:
|
|||
~MobileHotspotWidget();
|
||||
|
||||
private:
|
||||
QFrame *m_hotspotFrame = nullptr;
|
||||
QFrame *m_switchFrame = nullptr; //开关
|
||||
QFrame *m_ApNameFrame = nullptr; //wifi名称
|
||||
QFrame *m_passwordFrame = nullptr; //密码
|
||||
|
@ -46,6 +70,7 @@ private:
|
|||
QLabel *m_switchLabel;
|
||||
QLabel *m_apNameLabel;
|
||||
QLabel *m_pwdLabel;
|
||||
QLabel *m_pwdHintLabel;
|
||||
QLabel *m_freqBandLabel;
|
||||
QLabel *m_interfaceLabel;
|
||||
|
||||
|
@ -54,7 +79,7 @@ private:
|
|||
QFrame *pwdAndfreqBandLine;
|
||||
QFrame *freqBandAndInterfaceLine;
|
||||
|
||||
QVBoxLayout *mVlayout;
|
||||
QVBoxLayout *m_Vlayout;
|
||||
|
||||
QLineEdit *m_apNameLine;
|
||||
KPasswordEdit *m_pwdNameLine;
|
||||
|
@ -71,6 +96,7 @@ private:
|
|||
QString m_uuid = "";
|
||||
QString m_hostName = "";
|
||||
|
||||
void resetFrameSize();
|
||||
void initUI();
|
||||
void initDbusConnect();
|
||||
void initInterfaceInfo();
|
||||
|
@ -96,6 +122,21 @@ private:
|
|||
|
||||
QFrame* myLine();
|
||||
|
||||
QDBusInterface *m_activePathInterface = nullptr;
|
||||
QDBusInterface *m_settingPathInterface = nullptr;
|
||||
|
||||
ConnectdevPage * m_connectDevPage = nullptr;
|
||||
BlacklistPage *m_blacklistPage = nullptr;
|
||||
|
||||
QString getActivePathByUuid();
|
||||
QString getSettingPathByUuid();
|
||||
void initNmDbus();
|
||||
void initActivePathInterface(QString path);
|
||||
void deleteActivePathInterface();
|
||||
void initSettingPathInterface(QString path);
|
||||
void deleteSettingPathInterface();
|
||||
void initConnectDevPage();
|
||||
void initBlackListPage();
|
||||
signals:
|
||||
|
||||
private slots:
|
||||
|
@ -107,14 +148,15 @@ private slots:
|
|||
//热点断开
|
||||
void onHotspotDeactivated(QString devName, QString ssid);
|
||||
//热点连接
|
||||
void onHotspotActivated(QString devName, QString ssid, QString uuid);
|
||||
void onHotspotActivated(QString devName, QString ssid, QString uuid, QString activePath, QString settingPath);
|
||||
|
||||
void onGsettingChanged(const QString &key);
|
||||
void onWirelessBtnChanged(bool state);
|
||||
|
||||
void onActiveConnectionChanged(QString deviceName, QString ssid, QString uuid, int status);
|
||||
|
||||
void onApLineEditTextEdit(QString text);
|
||||
|
||||
void onPwdTextChanged();
|
||||
};
|
||||
|
||||
#endif // MOBILEHOTSPOTWIDGET_H
|
||||
|
|
|
@ -1,6 +1,38 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE TS>
|
||||
<TS version="2.1">
|
||||
<context>
|
||||
<name>BlacklistItem</name>
|
||||
<message>
|
||||
<location filename="../blacklistitem.cpp" line="50"/>
|
||||
<source>Remove</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>BlacklistPage</name>
|
||||
<message>
|
||||
<location filename="../blacklistpage.cpp" line="47"/>
|
||||
<source>Blacklist</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>ConnectDevListItem</name>
|
||||
<message>
|
||||
<location filename="../connectdevlistitem.cpp" line="50"/>
|
||||
<source>drag into blacklist</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>ConnectdevPage</name>
|
||||
<message>
|
||||
<location filename="../connectdevpage.cpp" line="48"/>
|
||||
<source>Connect device</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>MobileHotspot</name>
|
||||
<message>
|
||||
|
@ -24,79 +56,69 @@
|
|||
<context>
|
||||
<name>MobileHotspotWidget</name>
|
||||
<message>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="30"/>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="61"/>
|
||||
<source>ukui control center</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="33"/>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="64"/>
|
||||
<source>ukui control center desktop message</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="102"/>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="149"/>
|
||||
<source>wirless switch is close or no wireless device</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="106"/>
|
||||
<source>start to close hotspot</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="115"/>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="169"/>
|
||||
<source>hotpots name or device is invalid</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="119"/>
|
||||
<source>can not create hotspot with password length less than eight!</source>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="490"/>
|
||||
<source>Contains at least 8 characters</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="122"/>
|
||||
<source>start to open hotspot </source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="155"/>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="223"/>
|
||||
<source>Hotspot</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="227"/>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="532"/>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="310"/>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="605"/>
|
||||
<source>hotspot already close</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="367"/>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="436"/>
|
||||
<source>Open</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="388"/>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="457"/>
|
||||
<source>Wi-Fi Name</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="410"/>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="478"/>
|
||||
<source>Password</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="448"/>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="519"/>
|
||||
<source>Frequency band</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="473"/>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="545"/>
|
||||
<source>Net card</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="548"/>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="556"/>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="635"/>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="643"/>
|
||||
<source>hotspot already open</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
|
|
Binary file not shown.
|
@ -0,0 +1,138 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE TS>
|
||||
<TS version="2.1" language="bo_CN">
|
||||
<context>
|
||||
<name>BlacklistItem</name>
|
||||
<message>
|
||||
<location filename="../blacklistitem.cpp" line="50"/>
|
||||
<source>Remove</source>
|
||||
<translation>སྤོ་སྐྱོད་བྱས་པ།</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>BlacklistPage</name>
|
||||
<message>
|
||||
<location filename="../blacklistpage.cpp" line="47"/>
|
||||
<source>Blacklist</source>
|
||||
<translation>སྒྲིག་ཆས་ཀྱི་མིང་ཐོ་ནག་པོ།</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>ConnectDevListItem</name>
|
||||
<message>
|
||||
<location filename="../connectdevlistitem.cpp" line="50"/>
|
||||
<source>drag into blacklist</source>
|
||||
<translation>མིང་ཐོ་ནག་པོའི་ཁ་སྣོན་རྒྱག་པ།</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>ConnectdevPage</name>
|
||||
<message>
|
||||
<location filename="../connectdevpage.cpp" line="48"/>
|
||||
<source>Connect device</source>
|
||||
<translation>འབྲེལ་མཐུད་སྒྲིག་ཆས།</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>MobileHotspot</name>
|
||||
<message>
|
||||
<location filename="../mobilehotspot.cpp" line="35"/>
|
||||
<source>MobileHotspot</source>
|
||||
<translation>སྒུལ་བདེའི་ཧའོ་ཚི་ཀུང་སི།</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../mobilehotspot.cpp" line="101"/>
|
||||
<source>mobilehotspot</source>
|
||||
<translation>སྒུལ་བདེའི་འཕྲུལ་ཆས།</translation>
|
||||
<extra-contents_path>/mobilehotspot/mobilehotspot</extra-contents_path>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../mobilehotspot.cpp" line="103"/>
|
||||
<source>mobilehotspot open</source>
|
||||
<translation>སྒུལ་བདེའི་འཕྲུལ་ཆས་ཀྱི་སྒོ་ཕྱེ་བ།</translation>
|
||||
<extra-contents_path>/mobilehotspot/mobilehotspot open</extra-contents_path>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>MobileHotspotWidget</name>
|
||||
<message>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="61"/>
|
||||
<source>ukui control center</source>
|
||||
<translation>ཝུའུ་ཁི་ལན་གྱི་ཚོད་འཛིན་ལྟེ་གནས།</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="64"/>
|
||||
<source>ukui control center desktop message</source>
|
||||
<translation>ukui ཚོད་འཛིན་ལྟེ་གནས་ཀྱི་ཅོག་ངོས་ཆ་འཕྲིན།</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="149"/>
|
||||
<source>wirless switch is close or no wireless device</source>
|
||||
<translation>སྐུད་མེད་གློག་སྒོ་རྒྱག་པའམ་ཡང་ན་སྐུད་མེད་སྒྲིག་ཆས་མེད་པ།</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>start to close hotspot</source>
|
||||
<translation type="vanished">སྒོ་རྒྱག་འགོ་བརྩམས།</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="169"/>
|
||||
<source>hotpots name or device is invalid</source>
|
||||
<translation>ཚ་བ་ཆེ་བའི་མིང་ངམ་སྒྲིག་ཆས་ལ་ནུས་པ་མེད།</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>can not create hotspot with password length less than eight!</source>
|
||||
<translation type="vanished">གསང་གྲངས་ཀྱི་རིང་ཚད་ནི་གླེང་མང་བའི་གནད་དོན་བརྒྱད་ལས་ཆུང་བ་བྱེད་མི་རུང་།!</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>start to open hotspot </source>
|
||||
<translation type="vanished">ཀུན་གྱིས་དོ་སྣང་བྱེད་ཡུལ་གསར་སྐྲུན་བྱེད་འགོ་ </translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="490"/>
|
||||
<source>Contains at least 8 characters</source>
|
||||
<translation>མ་མཐར་ཡང་ཡིག་རྟགས་བརྒྱད་འདུས་ཡོད།</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="223"/>
|
||||
<source>Hotspot</source>
|
||||
<translation>ཚ་བ་ཆེ་བ།</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="310"/>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="605"/>
|
||||
<source>hotspot already close</source>
|
||||
<translation>ཚ་བ་ཆེ་བའི་གནད་དོན་ཐག་ཉེ་རུ་སོང་ཡོད།</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="436"/>
|
||||
<source>Open</source>
|
||||
<translation>སྒོ་ཕྱེ་བ།</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="457"/>
|
||||
<source>Wi-Fi Name</source>
|
||||
<translation>Wi-Fiཡི་མིང་།</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="478"/>
|
||||
<source>Password</source>
|
||||
<translation>གསང་གྲངས།</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="519"/>
|
||||
<source>Frequency band</source>
|
||||
<translation>ཐེངས་གྲངས་ཀྱི་རོལ་ཆའི་རུ་ཁག</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="545"/>
|
||||
<source>Net card</source>
|
||||
<translation>དྲ་རྒྱའི་བྱང་བུ།</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="635"/>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="643"/>
|
||||
<source>hotspot already open</source>
|
||||
<translation>ཚ་བ་ཆེ་བའི་གནད་དོན་དེ་སྒོ་ཕྱེ་ཟིན།</translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
|
@ -0,0 +1,126 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE TS>
|
||||
<TS version="2.1" language="en">
|
||||
<context>
|
||||
<name>BlacklistItem</name>
|
||||
<message>
|
||||
<location filename="../blacklistitem.cpp" line="50"/>
|
||||
<source>Remove</source>
|
||||
<translation>Remove</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>BlacklistPage</name>
|
||||
<message>
|
||||
<location filename="../blacklistpage.cpp" line="47"/>
|
||||
<source>Blacklist</source>
|
||||
<translation>Blacklist</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>ConnectDevListItem</name>
|
||||
<message>
|
||||
<location filename="../connectdevlistitem.cpp" line="50"/>
|
||||
<source>drag into blacklist</source>
|
||||
<translation>drag into blacklist</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>ConnectdevPage</name>
|
||||
<message>
|
||||
<location filename="../connectdevpage.cpp" line="48"/>
|
||||
<source>Connect device</source>
|
||||
<translation>Connect device</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>MobileHotspot</name>
|
||||
<message>
|
||||
<location filename="../mobilehotspot.cpp" line="35"/>
|
||||
<source>MobileHotspot</source>
|
||||
<translation>MobileHotspot</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../mobilehotspot.cpp" line="101"/>
|
||||
<source>mobilehotspot</source>
|
||||
<translation>mobilehotspot</translation>
|
||||
<extra-contents_path>/mobilehotspot/mobilehotspot</extra-contents_path>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../mobilehotspot.cpp" line="103"/>
|
||||
<source>mobilehotspot open</source>
|
||||
<translation>mobilehotspot open</translation>
|
||||
<extra-contents_path>/mobilehotspot/mobilehotspot open</extra-contents_path>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>MobileHotspotWidget</name>
|
||||
<message>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="61"/>
|
||||
<source>ukui control center</source>
|
||||
<translation>ukui control center</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="64"/>
|
||||
<source>ukui control center desktop message</source>
|
||||
<translation>ukui control center desktop message</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="149"/>
|
||||
<source>wirless switch is close or no wireless device</source>
|
||||
<translation>wirless switch is close or no wireless device</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="169"/>
|
||||
<source>hotpots name or device is invalid</source>
|
||||
<translation>hotpots name or device is invalid</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="223"/>
|
||||
<source>Hotspot</source>
|
||||
<translation>Hotspot</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="310"/>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="605"/>
|
||||
<source>hotspot already close</source>
|
||||
<translation>hotspot already close</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="436"/>
|
||||
<source>Open</source>
|
||||
<translation>Open</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="457"/>
|
||||
<source>Wi-Fi Name</source>
|
||||
<translation>Wi-Fi Name</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="478"/>
|
||||
<source>Password</source>
|
||||
<translation>Password</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="490"/>
|
||||
<source>Contains at least 8 characters</source>
|
||||
<translation>Contains at least 8 characters</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="519"/>
|
||||
<source>Frequency band</source>
|
||||
<translation>Frequency band</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="545"/>
|
||||
<source>Net card</source>
|
||||
<translation>Net card</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="635"/>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="643"/>
|
||||
<source>hotspot already open</source>
|
||||
<translation>hotspot already open</translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
|
@ -1,6 +1,38 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE TS>
|
||||
<TS version="2.1">
|
||||
<context>
|
||||
<name>BlacklistItem</name>
|
||||
<message>
|
||||
<location filename="../blacklistitem.cpp" line="50"/>
|
||||
<source>Remove</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>BlacklistPage</name>
|
||||
<message>
|
||||
<location filename="../blacklistpage.cpp" line="47"/>
|
||||
<source>Blacklist</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>ConnectDevListItem</name>
|
||||
<message>
|
||||
<location filename="../connectdevlistitem.cpp" line="50"/>
|
||||
<source>drag into blacklist</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>ConnectdevPage</name>
|
||||
<message>
|
||||
<location filename="../connectdevpage.cpp" line="48"/>
|
||||
<source>Connect device</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>MobileHotspot</name>
|
||||
<message>
|
||||
|
@ -24,79 +56,69 @@
|
|||
<context>
|
||||
<name>MobileHotspotWidget</name>
|
||||
<message>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="30"/>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="61"/>
|
||||
<source>ukui control center</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="33"/>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="64"/>
|
||||
<source>ukui control center desktop message</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="102"/>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="149"/>
|
||||
<source>wirless switch is close or no wireless device</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="106"/>
|
||||
<source>start to close hotspot</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="115"/>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="169"/>
|
||||
<source>hotpots name or device is invalid</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="119"/>
|
||||
<source>can not create hotspot with password length less than eight!</source>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="490"/>
|
||||
<source>Contains at least 8 characters</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="122"/>
|
||||
<source>start to open hotspot </source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="155"/>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="223"/>
|
||||
<source>Hotspot</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="227"/>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="532"/>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="310"/>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="605"/>
|
||||
<source>hotspot already close</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="367"/>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="436"/>
|
||||
<source>Open</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="388"/>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="457"/>
|
||||
<source>Wi-Fi Name</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="410"/>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="478"/>
|
||||
<source>Password</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="448"/>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="519"/>
|
||||
<source>Frequency band</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="473"/>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="545"/>
|
||||
<source>Net card</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="548"/>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="556"/>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="635"/>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="643"/>
|
||||
<source>hotspot already open</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
|
|
Binary file not shown.
|
@ -1,6 +1,38 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE TS>
|
||||
<TS version="2.1" language="zh_CN">
|
||||
<context>
|
||||
<name>BlacklistItem</name>
|
||||
<message>
|
||||
<location filename="../blacklistitem.cpp" line="50"/>
|
||||
<source>Remove</source>
|
||||
<translation>移出</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>BlacklistPage</name>
|
||||
<message>
|
||||
<location filename="../blacklistpage.cpp" line="47"/>
|
||||
<source>Blacklist</source>
|
||||
<translation>设备黑名单</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>ConnectDevListItem</name>
|
||||
<message>
|
||||
<location filename="../connectdevlistitem.cpp" line="50"/>
|
||||
<source>drag into blacklist</source>
|
||||
<translation>添加进黑名单</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>ConnectdevPage</name>
|
||||
<message>
|
||||
<location filename="../connectdevpage.cpp" line="48"/>
|
||||
<source>Connect device</source>
|
||||
<translation>连接设备</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>MobileHotspot</name>
|
||||
<message>
|
||||
|
@ -24,79 +56,81 @@
|
|||
<context>
|
||||
<name>MobileHotspotWidget</name>
|
||||
<message>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="30"/>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="61"/>
|
||||
<source>ukui control center</source>
|
||||
<translation>控制面板</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="33"/>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="64"/>
|
||||
<source>ukui control center desktop message</source>
|
||||
<translation>控制面板桌面通知</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="102"/>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="149"/>
|
||||
<source>wirless switch is close or no wireless device</source>
|
||||
<translation>无线开关已关闭或不存在有热点功能的无线网卡</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="106"/>
|
||||
<source>start to close hotspot</source>
|
||||
<translation>开始关闭热点</translation>
|
||||
<translation type="vanished">开始关闭热点</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="115"/>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="169"/>
|
||||
<source>hotpots name or device is invalid</source>
|
||||
<translation>热点名称或设备错误</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="119"/>
|
||||
<source>can not create hotspot with password length less than eight!</source>
|
||||
<translation>不能创建密码长度小于八位的热点!</translation>
|
||||
<translation type="vanished">不能创建密码长度小于八位的热点!</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="122"/>
|
||||
<source>start to open hotspot </source>
|
||||
<translation>开始创建热点</translation>
|
||||
<translation type="vanished">开始创建热点</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="155"/>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="490"/>
|
||||
<source>Contains at least 8 characters</source>
|
||||
<translation>至少包含8个字符</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="223"/>
|
||||
<source>Hotspot</source>
|
||||
<translation>移动热点</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="227"/>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="532"/>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="310"/>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="605"/>
|
||||
<source>hotspot already close</source>
|
||||
<translation>热点已关闭</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="367"/>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="436"/>
|
||||
<source>Open</source>
|
||||
<translation>开启</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="388"/>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="457"/>
|
||||
<source>Wi-Fi Name</source>
|
||||
<translation>Wi-Fi名称</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="410"/>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="478"/>
|
||||
<source>Password</source>
|
||||
<translation>网络密码</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="448"/>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="519"/>
|
||||
<source>Frequency band</source>
|
||||
<translation>网络频带</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="473"/>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="545"/>
|
||||
<source>Net card</source>
|
||||
<translation>共享网卡端口</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="548"/>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="556"/>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="635"/>
|
||||
<location filename="../mobilehotspotwidget.cpp" line="643"/>
|
||||
<source>hotspot already open</source>
|
||||
<translation>热点已开启</translation>
|
||||
</message>
|
||||
|
|
|
@ -1,8 +1,26 @@
|
|||
/* -*- 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 "deviceframe.h"
|
||||
#include <QPainterPath>
|
||||
#include <QPainter>
|
||||
|
||||
#define LAYOUT_MARGINS 18,0,24,0
|
||||
#define LAYOUT_MARGINS 16,0,16,0
|
||||
#define FRAME_HEIGHT 58
|
||||
#define RADIUS 6.0
|
||||
|
||||
|
@ -17,6 +35,7 @@ DeviceFrame::DeviceFrame(QString devName, QWidget *parent) : QFrame(parent)
|
|||
deviceLabel = new QLabel(this);
|
||||
dropDownLabel = new DrownLabel(devName, this);
|
||||
deviceSwitch = new KSwitchButton(this);
|
||||
deviceSwitch->installEventFilter(this);
|
||||
|
||||
deviceLayout->addWidget(deviceLabel);
|
||||
deviceLayout->addStretch();
|
||||
|
@ -24,9 +43,15 @@ DeviceFrame::DeviceFrame(QString devName, QWidget *parent) : QFrame(parent)
|
|||
deviceLayout->addWidget(deviceSwitch);
|
||||
}
|
||||
|
||||
DeviceFrame::~DeviceFrame()
|
||||
bool DeviceFrame::eventFilter(QObject *w,QEvent *e)
|
||||
{
|
||||
|
||||
if (w == deviceSwitch) {
|
||||
if (e->type() == QEvent::MouseButtonPress) {
|
||||
emit deviceSwitchClicked(!deviceSwitch->isChecked());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return QFrame::eventFilter(w, e);
|
||||
}
|
||||
|
||||
void DeviceFrame::paintEvent(QPaintEvent *event)
|
||||
|
|
|
@ -1,3 +1,22 @@
|
|||
/* -*- 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 DEVICEFRAME_H
|
||||
#define DEVICEFRAME_H
|
||||
#include <QObject>
|
||||
|
@ -16,9 +35,9 @@ using namespace kdk;
|
|||
class DeviceFrame : public QFrame
|
||||
{
|
||||
|
||||
Q_OBJECT
|
||||
public:
|
||||
DeviceFrame(QString devName, QWidget *parent = nullptr);
|
||||
~DeviceFrame();
|
||||
public:
|
||||
QLabel * deviceLabel = nullptr;
|
||||
KSwitchButton * deviceSwitch = nullptr;
|
||||
|
@ -26,11 +45,14 @@ public:
|
|||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *event);
|
||||
bool eventFilter(QObject *w,QEvent *e);
|
||||
|
||||
private:
|
||||
bool isDropDown = false;
|
||||
int frameSize;
|
||||
|
||||
signals:
|
||||
void deviceSwitchClicked(bool);
|
||||
};
|
||||
|
||||
#endif // DEVICEFRAME_H
|
||||
|
|
|
@ -1,3 +1,22 @@
|
|||
/* -*- 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 "itemframe.h"
|
||||
|
||||
#include <QPainter>
|
||||
|
@ -30,11 +49,6 @@ ItemFrame::ItemFrame(QString devName, QWidget *parent) : QFrame(parent)
|
|||
connect(deviceFrame->dropDownLabel, &DrownLabel::labelClicked, this, &ItemFrame::onDrownLabelClicked);
|
||||
}
|
||||
|
||||
ItemFrame::~ItemFrame()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void ItemFrame::onDrownLabelClicked()
|
||||
{
|
||||
if (!deviceFrame->dropDownLabel->isChecked) {
|
||||
|
|
|
@ -1,3 +1,22 @@
|
|||
/* -*- 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 ITEMFRAME_H
|
||||
#define ITEMFRAME_H
|
||||
#include <QFrame>
|
||||
|
@ -12,7 +31,7 @@ class ItemFrame : public QFrame
|
|||
Q_OBJECT
|
||||
public:
|
||||
ItemFrame(QString devName, QWidget *parent = nullptr);
|
||||
~ItemFrame();
|
||||
|
||||
//单设备整体layout
|
||||
QVBoxLayout * deviceLanLayout = nullptr;
|
||||
//单设备名称+下拉按钮Frame+d单设备开关
|
||||
|
|
|
@ -1,4 +1,25 @@
|
|||
/* -*- 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 "lanitem.h"
|
||||
#include <QApplication>
|
||||
|
||||
#define FRAME_SPEED 150
|
||||
#define LIMIT_TIME 60*1000
|
||||
#define TOTAL_PAGE 8
|
||||
|
@ -20,9 +41,11 @@ LanItem::LanItem(bool isAcitve, QWidget *parent)
|
|||
iconLabel->setProperty("useIconHighlightEffect", 0x2);
|
||||
titileLabel = new FixLabel(this);
|
||||
statusLabel = new QLabel(this);
|
||||
statusLabel->setProperty("useIconHighlightEffect", 0x2);
|
||||
statusLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
|
||||
// statusLabel->setMinimumSize(36,36);
|
||||
infoLabel = new InfoButton(this);
|
||||
infoLabel = new GrayInfoButton(this);
|
||||
|
||||
//【更多】菜单
|
||||
m_moreButton = new QToolButton(this);
|
||||
m_moreButton->setProperty("useButtonPalette", true);
|
||||
|
@ -54,7 +77,6 @@ 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);
|
||||
|
@ -121,12 +143,17 @@ void LanItem::onDeletetTriggered()
|
|||
|
||||
void LanItem::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
QPalette pal = this->palette();
|
||||
QPalette pal = qApp->palette();
|
||||
|
||||
QPainter painter(this);
|
||||
painter.setRenderHint(QPainter:: Antialiasing, true); //设置渲染,启动反锯齿
|
||||
painter.setPen(Qt::NoPen);
|
||||
painter.setBrush(pal.color(QPalette::Base));
|
||||
painter.setBrush(this->palette().base().color());
|
||||
|
||||
QColor color = pal.color(QPalette::Button);
|
||||
color.setAlphaF(0.5);
|
||||
pal.setColor(QPalette::Button, color);
|
||||
this->setPalette(pal);
|
||||
|
||||
QRect rect = this->rect();
|
||||
|
||||
|
|
|
@ -1,3 +1,22 @@
|
|||
/* -*- 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 LANITEM_H
|
||||
#define LANITEM_H
|
||||
#include <QWidget>
|
||||
|
@ -14,7 +33,8 @@
|
|||
#include <QMenu>
|
||||
#include <QEvent>
|
||||
#include "fixlabel.h"
|
||||
#include "infobutton.h"
|
||||
//#include "infobutton.h"
|
||||
#include "../component/AddBtn/grayinfobutton.h"
|
||||
|
||||
class LanItem : public QPushButton
|
||||
{
|
||||
|
@ -24,7 +44,7 @@ public:
|
|||
~LanItem();
|
||||
public:
|
||||
QLabel * iconLabel = nullptr;
|
||||
InfoButton * infoLabel = nullptr;
|
||||
GrayInfoButton * infoLabel = nullptr;
|
||||
FixLabel * titileLabel = nullptr;
|
||||
QLabel * statusLabel = nullptr;
|
||||
QToolButton* m_moreButton = nullptr;
|
||||
|
|
|
@ -32,7 +32,9 @@
|
|||
#define ITEMHEIGH 50
|
||||
#define LAN_TYPE 0
|
||||
#define CONTROL_CENTER_WIFI "org.ukui.control-center.wifi.switch"
|
||||
|
||||
#define KYLIN_APP_MANAGER_NAME "com.kylin.AppManager"
|
||||
#define KYLIN_APP_MANAGER_PATH "/com/kylin/AppManager"
|
||||
#define KYLIN_APP_MANAGER_INTERFACE "com.kylin.AppManager"
|
||||
const QString KLanSymbolic = "network-wired-connected-symbolic";
|
||||
const QString NoNetSymbolic = "network-wired-disconnected-symbolic";
|
||||
|
||||
|
@ -78,7 +80,7 @@ NetConnect::NetConnect() : mFirstLoad(true) {
|
|||
translator->load("/usr/share/kylin-nm/netconnect/" + QLocale::system().name());
|
||||
QApplication::installTranslator(translator);
|
||||
|
||||
pluginName = tr("WiredConnect");
|
||||
pluginName = tr("LAN");
|
||||
pluginType = NETWORK;
|
||||
}
|
||||
|
||||
|
@ -150,7 +152,7 @@ QString NetConnect::translationPath() const
|
|||
void NetConnect::initSearchText() {
|
||||
//~ contents_path /netconnect/Advanced settings"
|
||||
ui->detailBtn->setText(tr("Advanced settings"));
|
||||
ui->titleLabel->setText(tr("Wired Network"));
|
||||
ui->titleLabel->setText(tr("LAN"));
|
||||
//~ contents_path /netconnect/open
|
||||
ui->openLabel->setText(tr("open"));
|
||||
}
|
||||
|
@ -168,7 +170,9 @@ bool NetConnect::eventFilter(QObject *w, QEvent *e) {
|
|||
if (!wiredSwitch->isCheckable()) {
|
||||
showDesktopNotify(tr("No ethernet device avaliable"));
|
||||
} else {
|
||||
if (m_interface != nullptr && m_interface->isValid()) {
|
||||
m_interface->call(QStringLiteral("setWiredSwitchEnable"), !wiredSwitch->isChecked());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -180,8 +184,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);
|
||||
|
||||
|
@ -207,8 +213,8 @@ void NetConnect::initComponent() {
|
|||
getDeviceStatusMap(deviceStatusMap);
|
||||
if (deviceStatusMap.isEmpty()) {
|
||||
qDebug() << "[Netconnect] no device exist when init, set switch disable";
|
||||
wiredSwitch->setCheckable(false);
|
||||
wiredSwitch->setChecked(false);
|
||||
wiredSwitch->setCheckable(false);
|
||||
}
|
||||
initNet();
|
||||
|
||||
|
@ -240,7 +246,7 @@ void NetConnect::initComponent() {
|
|||
//获取网卡列表
|
||||
void NetConnect::getDeviceStatusMap(QMap<QString, bool> &map)
|
||||
{
|
||||
if (!m_interface->isValid()) {
|
||||
if (m_interface == nullptr || !m_interface->isValid()) {
|
||||
return;
|
||||
}
|
||||
qDebug() << "[NetConnect]call getDeviceListAndEnabled" << __LINE__;
|
||||
|
@ -347,12 +353,6 @@ void NetConnect::initNet()
|
|||
}
|
||||
}
|
||||
|
||||
void NetConnect::runExternalApp() {
|
||||
QString cmd = "nm-connection-editor";
|
||||
QProcess process(this);
|
||||
process.startDetached(cmd);
|
||||
}
|
||||
|
||||
//刪除
|
||||
void NetConnect::deleteOneLan(QString ssid, int type)
|
||||
{
|
||||
|
@ -361,8 +361,19 @@ void NetConnect::deleteOneLan(QString ssid, int type)
|
|||
qDebug() << "[NetConnect]call deleteConnect respond" << __LINE__;
|
||||
}
|
||||
|
||||
void NetConnect::runExternalApp() {
|
||||
if (!LaunchApp("nm-connection-editor.desktop")){
|
||||
QString cmd = "nm-connection-editor";
|
||||
QProcess process(this);
|
||||
process.startDetached(cmd);
|
||||
}
|
||||
}
|
||||
|
||||
//激活
|
||||
void NetConnect::activeConnect(QString ssid, QString deviceName, int type) {
|
||||
if (m_interface == nullptr || !m_interface->isValid()) {
|
||||
return;
|
||||
}
|
||||
qDebug() << "[NetConnect]call activateConnect" << __LINE__;
|
||||
m_interface->call(QStringLiteral("activateConnect"),type, deviceName, ssid);
|
||||
qDebug() << "[NetConnect]call activateConnect respond" << __LINE__;
|
||||
|
@ -370,6 +381,9 @@ void NetConnect::activeConnect(QString ssid, QString deviceName, int type) {
|
|||
|
||||
//断开
|
||||
void NetConnect::deActiveConnect(QString ssid, QString deviceName, int type) {
|
||||
if (m_interface == nullptr || !m_interface->isValid()) {
|
||||
return;
|
||||
}
|
||||
qDebug() << "[NetConnect]call deActivateConnect" << __LINE__;
|
||||
m_interface->call(QStringLiteral("deActivateConnect"),type, deviceName, ssid);
|
||||
qDebug() << "[NetConnect]call deActivateConnect respond" << __LINE__;
|
||||
|
@ -383,7 +397,7 @@ void NetConnect::initNetListFromDevice(QString deviceName)
|
|||
qDebug() << "[NetConnect]initNetListFromDevice " << deviceName << " not exist";
|
||||
return;
|
||||
}
|
||||
if (!m_interface->isValid()) {
|
||||
if (m_interface == nullptr || !m_interface->isValid()) {
|
||||
return;
|
||||
}
|
||||
qDebug() << "[NetConnect]call getWiredList" << __LINE__;
|
||||
|
@ -446,9 +460,9 @@ void NetConnect::addLanItem(ItemFrame *frame, QString devName, QStringList infoL
|
|||
lanItem->uuid = infoList.at(1);
|
||||
lanItem->dbusPath = infoList.at(2);
|
||||
|
||||
connect(lanItem->infoLabel, &InfoButton::clicked, this, [=]{
|
||||
connect(lanItem->infoLabel, &GrayInfoButton::clicked, this, [=]{
|
||||
// open landetail page
|
||||
if (!m_interface->isValid()) {
|
||||
if (m_interface == nullptr || !m_interface->isValid()) {
|
||||
return;
|
||||
}
|
||||
qDebug() << "[NetConnect]call showPropertyWidget" << __LINE__;
|
||||
|
@ -486,6 +500,9 @@ void NetConnect::addLanItem(ItemFrame *frame, QString devName, QStringList infoL
|
|||
//增加设备
|
||||
void NetConnect::addDeviceFrame(QString devName)
|
||||
{
|
||||
if (m_interface == nullptr || !m_interface->isValid()) {
|
||||
return;
|
||||
}
|
||||
qDebug() << "[NetConnect]addDeviceFrame " << devName;
|
||||
|
||||
qDebug() << "[NetConnect]call getDeviceListAndEnabled" << __LINE__;
|
||||
|
@ -520,26 +537,32 @@ void NetConnect::addDeviceFrame(QString devName)
|
|||
deviceFrameMap.insert(devName, itemFrame);
|
||||
qDebug() << "[NetConnect]deviceFrameMap insert" << devName;
|
||||
|
||||
connect(itemFrame->deviceFrame->deviceSwitch, &KSwitchButton::stateChanged, this, [=] (bool checked) {
|
||||
connect(itemFrame->deviceFrame, &DeviceFrame::deviceSwitchClicked ,this, [=] (bool checked) {
|
||||
qDebug() << "[NetConnect]call setDeviceEnable" << devName << checked << __LINE__;
|
||||
m_interface->call(QStringLiteral("setDeviceEnable"), devName, checked);
|
||||
qDebug() << "[NetConnect]call setDeviceEnable Respond" << __LINE__;
|
||||
});
|
||||
|
||||
connect(itemFrame->deviceFrame->deviceSwitch, &KSwitchButton::stateChanged, this, [=] (bool checked) {
|
||||
|
||||
if (checked) {
|
||||
qDebug() << "[NetConnect]set " << devName << "status" << true;
|
||||
itemFrame->lanItemFrame->show();
|
||||
itemFrame->deviceFrame->dropDownLabel->show();
|
||||
itemFrame->addLanWidget->show();
|
||||
itemFrame->deviceFrame->dropDownLabel->setDropDownStatus(true);
|
||||
deviceStatusMap[devName] = true;
|
||||
} else {
|
||||
qDebug() << "[NetConnect]set " << devName << "status" << false;
|
||||
itemFrame->lanItemFrame->hide();
|
||||
itemFrame->deviceFrame->dropDownLabel->hide();
|
||||
itemFrame->addLanWidget->hide();
|
||||
deviceStatusMap[devName] = false;
|
||||
}
|
||||
});
|
||||
|
||||
connect(itemFrame->addLanWidget, &AddNetBtn::clicked, this, [=](){
|
||||
if (m_interface->isValid()) {
|
||||
if (m_interface != nullptr && m_interface->isValid()) {
|
||||
qDebug() << "[NetConnect]call showCreateWiredConnectWidget" << devName << __LINE__;
|
||||
m_interface->call(QStringLiteral("showCreateWiredConnectWidget"), devName);
|
||||
qDebug() << "[NetConnect]call setDeviceEnable Respond" << __LINE__;
|
||||
|
@ -612,13 +635,21 @@ void NetConnect::onDeviceStatusChanged()
|
|||
}
|
||||
deviceStatusMap = map;
|
||||
if (deviceStatusMap.isEmpty()) {
|
||||
wiredSwitch->setCheckable(false);
|
||||
wiredSwitch->setChecked(false);
|
||||
wiredSwitch->setCheckable(false);
|
||||
} else {
|
||||
wiredSwitch->setCheckable(true);
|
||||
setSwitchStatus();
|
||||
}
|
||||
|
||||
QMap<QString, ItemFrame *>::iterator iter;
|
||||
for (iter = deviceFrameMap.begin(); iter != deviceFrameMap.end(); iter++) {
|
||||
if (deviceStatusMap.contains(iter.key())) {
|
||||
if (iter.value()->deviceFrame->deviceSwitch->isChecked() != deviceStatusMap[iter.key()]) {
|
||||
iter.value()->deviceFrame->deviceSwitch->setChecked(deviceStatusMap[iter.key()]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void NetConnect::onDeviceNameChanged(QString oldName, QString newName, int type)
|
||||
|
@ -726,9 +757,9 @@ void NetConnect::addOneLanFrame(ItemFrame *frame, QString deviceName, QStringLis
|
|||
lanItem->uuid = connUuid;
|
||||
lanItem->dbusPath = connDbusPath;
|
||||
|
||||
connect(lanItem->infoLabel, &InfoButton::clicked, this, [=]{
|
||||
connect(lanItem->infoLabel, &GrayInfoButton::clicked, this, [=]{
|
||||
// open landetail page
|
||||
if (!m_interface->isValid()) {
|
||||
if (m_interface == nullptr || !m_interface->isValid()) {
|
||||
return;
|
||||
}
|
||||
qDebug() << "[NetConnect]call showPropertyWidget" << deviceName << connUuid << __LINE__;
|
||||
|
@ -883,7 +914,7 @@ int NetConnect::getInsertPos(QString connName, QString deviceName)
|
|||
{
|
||||
qDebug() << "[NetConnect]getInsertPos" << connName << deviceName;
|
||||
int index = 0;
|
||||
if(!m_interface->isValid()) {
|
||||
if(m_interface == nullptr || !m_interface->isValid()) {
|
||||
index = 0;
|
||||
} else {
|
||||
qDebug() << "[NetConnect]call getWiredList" << __LINE__;
|
||||
|
@ -914,3 +945,19 @@ int NetConnect::getInsertPos(QString connName, QString deviceName)
|
|||
}
|
||||
return index;
|
||||
}
|
||||
|
||||
bool NetConnect::LaunchApp(QString desktopFile)
|
||||
{
|
||||
QDBusInterface m_appManagerDbusInterface(KYLIN_APP_MANAGER_NAME,
|
||||
KYLIN_APP_MANAGER_PATH,
|
||||
KYLIN_APP_MANAGER_INTERFACE,
|
||||
QDBusConnection::sessionBus());//局部变量
|
||||
|
||||
if (!m_appManagerDbusInterface.isValid()) {
|
||||
qWarning()<<"m_appManagerDbusInterface init error";
|
||||
return false;
|
||||
} else {
|
||||
QDBusReply<bool> reply =m_appManagerDbusInterface.call("LaunchApp",desktopFile);
|
||||
return reply;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -123,6 +123,7 @@ private:
|
|||
//单个lan连接状态变化
|
||||
void itemActiveConnectionStatusChanged(LanItem *item, int status);
|
||||
|
||||
bool LaunchApp(QString desktopFile);
|
||||
protected:
|
||||
bool eventFilter(QObject *w,QEvent *e);
|
||||
|
||||
|
|
|
@ -50,4 +50,6 @@ INSTALLS += target \
|
|||
TRANSLATIONS += \
|
||||
translations/zh_CN.ts \
|
||||
translations/tr.ts \
|
||||
translations/bo.ts
|
||||
translations/bo.ts \
|
||||
translations/bo_CN.ts \
|
||||
translations/en_US.ts
|
||||
|
|
|
@ -4,12 +4,12 @@
|
|||
<context>
|
||||
<name>AddNetBtn</name>
|
||||
<message>
|
||||
<location filename="../../component/AddBtn/addnetbtn.cpp" line="24"/>
|
||||
<location filename="../../component/AddBtn/addnetbtn.cpp" line="44"/>
|
||||
<source>Add Others</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../component/AddBtn/addnetbtn.cpp" line="28"/>
|
||||
<location filename="../../component/AddBtn/addnetbtn.cpp" line="48"/>
|
||||
<source>Add WiredNetork</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
|
@ -17,19 +17,19 @@
|
|||
<context>
|
||||
<name>LanItem</name>
|
||||
<message>
|
||||
<location filename="../lanitem.cpp" line="34"/>
|
||||
<location filename="../lanitem.cpp" line="57"/>
|
||||
<source>Delete</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../lanitem.cpp" line="96"/>
|
||||
<location filename="../lanitem.cpp" line="109"/>
|
||||
<location filename="../lanitem.cpp" line="120"/>
|
||||
<location filename="../lanitem.cpp" line="133"/>
|
||||
<source>Disconnect</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../lanitem.cpp" line="98"/>
|
||||
<location filename="../lanitem.cpp" line="107"/>
|
||||
<location filename="../lanitem.cpp" line="122"/>
|
||||
<location filename="../lanitem.cpp" line="131"/>
|
||||
<source>Connect</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
|
@ -38,59 +38,59 @@
|
|||
<name>NetConnect</name>
|
||||
<message>
|
||||
<location filename="../netconnect.ui" line="50"/>
|
||||
<location filename="../netconnect.cpp" line="153"/>
|
||||
<source>Wired Network</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../netconnect.ui" line="112"/>
|
||||
<location filename="../netconnect.cpp" line="155"/>
|
||||
<location filename="../netconnect.cpp" line="158"/>
|
||||
<source>open</source>
|
||||
<translation type="unfinished"></translation>
|
||||
<extra-contents_path>/netconnect/open</extra-contents_path>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../netconnect.ui" line="198"/>
|
||||
<location filename="../netconnect.cpp" line="152"/>
|
||||
<location filename="../netconnect.cpp" line="155"/>
|
||||
<source>Advanced settings</source>
|
||||
<translation type="unfinished"></translation>
|
||||
<extra-contents_path>/netconnect/Advanced settings"</extra-contents_path>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../netconnect.cpp" line="64"/>
|
||||
<location filename="../netconnect.cpp" line="67"/>
|
||||
<source>ukui control center</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../netconnect.cpp" line="67"/>
|
||||
<location filename="../netconnect.cpp" line="70"/>
|
||||
<source>ukui control center desktop message</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../netconnect.cpp" line="81"/>
|
||||
<source>WiredConnect</source>
|
||||
<location filename="../netconnect.cpp" line="84"/>
|
||||
<location filename="../netconnect.cpp" line="156"/>
|
||||
<source>LAN</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../netconnect.cpp" line="169"/>
|
||||
<location filename="../netconnect.cpp" line="172"/>
|
||||
<source>No ethernet device avaliable</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../netconnect.cpp" line="435"/>
|
||||
<location filename="../netconnect.cpp" line="864"/>
|
||||
<location filename="../netconnect.cpp" line="450"/>
|
||||
<location filename="../netconnect.cpp" line="896"/>
|
||||
<source>connected</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../netconnect.cpp" line="437"/>
|
||||
<location filename="../netconnect.cpp" line="717"/>
|
||||
<location filename="../netconnect.cpp" line="874"/>
|
||||
<location filename="../netconnect.cpp" line="452"/>
|
||||
<location filename="../netconnect.cpp" line="749"/>
|
||||
<location filename="../netconnect.cpp" line="906"/>
|
||||
<source>not connected</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../netconnect.cpp" line="510"/>
|
||||
<location filename="../netconnect.cpp" line="528"/>
|
||||
<source>card</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
|
|
Binary file not shown.
|
@ -0,0 +1,102 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE TS>
|
||||
<TS version="2.1" language="bo_CN">
|
||||
<context>
|
||||
<name>AddNetBtn</name>
|
||||
<message>
|
||||
<location filename="../../component/AddBtn/addnetbtn.cpp" line="44"/>
|
||||
<source>Add Others</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../component/AddBtn/addnetbtn.cpp" line="48"/>
|
||||
<source>Add WiredNetork</source>
|
||||
<translation>སྐུད་ཡོད་བརྙན་འཕྲིན་ཁ་སྣོན་བྱས་ཡོད།</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>LanItem</name>
|
||||
<message>
|
||||
<location filename="../lanitem.cpp" line="57"/>
|
||||
<source>Delete</source>
|
||||
<translation>སུབ་དགོས།</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../lanitem.cpp" line="120"/>
|
||||
<location filename="../lanitem.cpp" line="133"/>
|
||||
<source>Disconnect</source>
|
||||
<translation>བར་མཚམས་ཆད་པ་རེད།</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../lanitem.cpp" line="122"/>
|
||||
<location filename="../lanitem.cpp" line="131"/>
|
||||
<source>Connect</source>
|
||||
<translation>འབྲེལ་མཐུད་བཅས་བྱ་དགོས།</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>NetConnect</name>
|
||||
<message>
|
||||
<location filename="../netconnect.ui" line="50"/>
|
||||
<source>Wired Network</source>
|
||||
<translation>སྐུད་ཡོད་བརྙན་འཕྲིན་དྲ་བ།</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../netconnect.ui" line="112"/>
|
||||
<location filename="../netconnect.cpp" line="158"/>
|
||||
<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="155"/>
|
||||
<source>Advanced settings</source>
|
||||
<translation>སྔོན་ཐོན་གྱི་སྒྲིག་བཀོད།</translation>
|
||||
<extra-contents_path>/netconnect/Advanced settings"</extra-contents_path>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../netconnect.cpp" line="67"/>
|
||||
<source>ukui control center</source>
|
||||
<translation>ཝུའུ་ཁི་ལན་གྱི་ཚོད་འཛིན་ལྟེ་གནས།</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../netconnect.cpp" line="70"/>
|
||||
<source>ukui control center desktop message</source>
|
||||
<translation>ukui ཚོད་འཛིན་ལྟེ་གནས་ཀྱི་ཅོག་ངོས་ཆ་འཕྲིན།</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>WiredConnect</source>
|
||||
<translation type="vanished">སྐུད་ཡོད་སྦྲེལ་མཐུད།</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../netconnect.cpp" line="84"/>
|
||||
<location filename="../netconnect.cpp" line="156"/>
|
||||
<source>LAN</source>
|
||||
<translation>སྐུད་ཡོད་དྲ་བ།</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../netconnect.cpp" line="172"/>
|
||||
<source>No ethernet device avaliable</source>
|
||||
<translation>ཨེ་ཙི་དྲ་རྒྱའི་སྒྲིག་ཆས་ལ་བཙན་འཛུལ་བྱས་མི་ཆོག།</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../netconnect.cpp" line="450"/>
|
||||
<location filename="../netconnect.cpp" line="896"/>
|
||||
<source>connected</source>
|
||||
<translation>འབྲེལ་མཐུད་བྱེད་པ།</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../netconnect.cpp" line="452"/>
|
||||
<location filename="../netconnect.cpp" line="749"/>
|
||||
<location filename="../netconnect.cpp" line="906"/>
|
||||
<source>not connected</source>
|
||||
<translation>འབྲེལ་མཐུད་མ་བྱས་པ།</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../netconnect.cpp" line="528"/>
|
||||
<source>card</source>
|
||||
<translation>བྱང་བུ།</translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
|
@ -0,0 +1,98 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE TS>
|
||||
<TS version="2.1" language="en">
|
||||
<context>
|
||||
<name>AddNetBtn</name>
|
||||
<message>
|
||||
<location filename="../../component/AddBtn/addnetbtn.cpp" line="44"/>
|
||||
<source>Add Others</source>
|
||||
<translation>Add Others</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../component/AddBtn/addnetbtn.cpp" line="48"/>
|
||||
<source>Add WiredNetork</source>
|
||||
<translation>Add WiredNetork</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>LanItem</name>
|
||||
<message>
|
||||
<location filename="../lanitem.cpp" line="57"/>
|
||||
<source>Delete</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../lanitem.cpp" line="120"/>
|
||||
<location filename="../lanitem.cpp" line="133"/>
|
||||
<source>Disconnect</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../lanitem.cpp" line="122"/>
|
||||
<location filename="../lanitem.cpp" line="131"/>
|
||||
<source>Connect</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>NetConnect</name>
|
||||
<message>
|
||||
<location filename="../netconnect.ui" line="50"/>
|
||||
<source>Wired Network</source>
|
||||
<translation>Wired Network</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../netconnect.ui" line="112"/>
|
||||
<location filename="../netconnect.cpp" line="158"/>
|
||||
<source>open</source>
|
||||
<translation>open</translation>
|
||||
<extra-contents_path>/netconnect/open</extra-contents_path>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../netconnect.ui" line="198"/>
|
||||
<location filename="../netconnect.cpp" line="155"/>
|
||||
<source>Advanced settings</source>
|
||||
<translation>Advanced settings</translation>
|
||||
<extra-contents_path>/netconnect/Advanced settings"</extra-contents_path>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../netconnect.cpp" line="67"/>
|
||||
<source>ukui control center</source>
|
||||
<translation>ukui control center</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../netconnect.cpp" line="70"/>
|
||||
<source>ukui control center desktop message</source>
|
||||
<translation>ukui control center desktop message</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../netconnect.cpp" line="84"/>
|
||||
<location filename="../netconnect.cpp" line="156"/>
|
||||
<source>LAN</source>
|
||||
<translation>LAN</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../netconnect.cpp" line="172"/>
|
||||
<source>No ethernet device avaliable</source>
|
||||
<translation>No ethernet device avaliable</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../netconnect.cpp" line="450"/>
|
||||
<location filename="../netconnect.cpp" line="896"/>
|
||||
<source>connected</source>
|
||||
<translation>connected</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../netconnect.cpp" line="452"/>
|
||||
<location filename="../netconnect.cpp" line="749"/>
|
||||
<location filename="../netconnect.cpp" line="906"/>
|
||||
<source>not connected</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../netconnect.cpp" line="528"/>
|
||||
<source>card</source>
|
||||
<translation>card</translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
|
@ -4,12 +4,12 @@
|
|||
<context>
|
||||
<name>AddNetBtn</name>
|
||||
<message>
|
||||
<location filename="../../component/AddBtn/addnetbtn.cpp" line="24"/>
|
||||
<location filename="../../component/AddBtn/addnetbtn.cpp" line="44"/>
|
||||
<source>Add Others</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../component/AddBtn/addnetbtn.cpp" line="28"/>
|
||||
<location filename="../../component/AddBtn/addnetbtn.cpp" line="48"/>
|
||||
<source>Add WiredNetork</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
|
@ -17,19 +17,19 @@
|
|||
<context>
|
||||
<name>LanItem</name>
|
||||
<message>
|
||||
<location filename="../lanitem.cpp" line="34"/>
|
||||
<location filename="../lanitem.cpp" line="57"/>
|
||||
<source>Delete</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../lanitem.cpp" line="96"/>
|
||||
<location filename="../lanitem.cpp" line="109"/>
|
||||
<location filename="../lanitem.cpp" line="120"/>
|
||||
<location filename="../lanitem.cpp" line="133"/>
|
||||
<source>Disconnect</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../lanitem.cpp" line="98"/>
|
||||
<location filename="../lanitem.cpp" line="107"/>
|
||||
<location filename="../lanitem.cpp" line="122"/>
|
||||
<location filename="../lanitem.cpp" line="131"/>
|
||||
<source>Connect</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
|
@ -38,59 +38,59 @@
|
|||
<name>NetConnect</name>
|
||||
<message>
|
||||
<location filename="../netconnect.ui" line="50"/>
|
||||
<location filename="../netconnect.cpp" line="153"/>
|
||||
<source>Wired Network</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../netconnect.ui" line="112"/>
|
||||
<location filename="../netconnect.cpp" line="155"/>
|
||||
<location filename="../netconnect.cpp" line="158"/>
|
||||
<source>open</source>
|
||||
<translation type="unfinished"></translation>
|
||||
<extra-contents_path>/netconnect/open</extra-contents_path>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../netconnect.ui" line="198"/>
|
||||
<location filename="../netconnect.cpp" line="152"/>
|
||||
<location filename="../netconnect.cpp" line="155"/>
|
||||
<source>Advanced settings</source>
|
||||
<translation type="unfinished"></translation>
|
||||
<extra-contents_path>/netconnect/Advanced settings"</extra-contents_path>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../netconnect.cpp" line="64"/>
|
||||
<location filename="../netconnect.cpp" line="67"/>
|
||||
<source>ukui control center</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../netconnect.cpp" line="67"/>
|
||||
<location filename="../netconnect.cpp" line="70"/>
|
||||
<source>ukui control center desktop message</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../netconnect.cpp" line="81"/>
|
||||
<source>WiredConnect</source>
|
||||
<location filename="../netconnect.cpp" line="84"/>
|
||||
<location filename="../netconnect.cpp" line="156"/>
|
||||
<source>LAN</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../netconnect.cpp" line="169"/>
|
||||
<location filename="../netconnect.cpp" line="172"/>
|
||||
<source>No ethernet device avaliable</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../netconnect.cpp" line="435"/>
|
||||
<location filename="../netconnect.cpp" line="864"/>
|
||||
<location filename="../netconnect.cpp" line="450"/>
|
||||
<location filename="../netconnect.cpp" line="896"/>
|
||||
<source>connected</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../netconnect.cpp" line="437"/>
|
||||
<location filename="../netconnect.cpp" line="717"/>
|
||||
<location filename="../netconnect.cpp" line="874"/>
|
||||
<location filename="../netconnect.cpp" line="452"/>
|
||||
<location filename="../netconnect.cpp" line="749"/>
|
||||
<location filename="../netconnect.cpp" line="906"/>
|
||||
<source>not connected</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../netconnect.cpp" line="510"/>
|
||||
<location filename="../netconnect.cpp" line="528"/>
|
||||
<source>card</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
|
|
Binary file not shown.
|
@ -4,12 +4,12 @@
|
|||
<context>
|
||||
<name>AddNetBtn</name>
|
||||
<message>
|
||||
<location filename="../../component/AddBtn/addnetbtn.cpp" line="24"/>
|
||||
<location filename="../../component/AddBtn/addnetbtn.cpp" line="44"/>
|
||||
<source>Add Others</source>
|
||||
<translation>加入其他网络</translation>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../component/AddBtn/addnetbtn.cpp" line="28"/>
|
||||
<location filename="../../component/AddBtn/addnetbtn.cpp" line="48"/>
|
||||
<source>Add WiredNetork</source>
|
||||
<translation>添加有线网络</translation>
|
||||
</message>
|
||||
|
@ -17,19 +17,19 @@
|
|||
<context>
|
||||
<name>LanItem</name>
|
||||
<message>
|
||||
<location filename="../lanitem.cpp" line="34"/>
|
||||
<location filename="../lanitem.cpp" line="57"/>
|
||||
<source>Delete</source>
|
||||
<translation>删除</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../lanitem.cpp" line="96"/>
|
||||
<location filename="../lanitem.cpp" line="109"/>
|
||||
<location filename="../lanitem.cpp" line="120"/>
|
||||
<location filename="../lanitem.cpp" line="133"/>
|
||||
<source>Disconnect</source>
|
||||
<translation>断开</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../lanitem.cpp" line="98"/>
|
||||
<location filename="../lanitem.cpp" line="107"/>
|
||||
<location filename="../lanitem.cpp" line="122"/>
|
||||
<location filename="../lanitem.cpp" line="131"/>
|
||||
<source>Connect</source>
|
||||
<translation>连接</translation>
|
||||
</message>
|
||||
|
@ -38,59 +38,63 @@
|
|||
<name>NetConnect</name>
|
||||
<message>
|
||||
<location filename="../netconnect.ui" line="50"/>
|
||||
<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="155"/>
|
||||
<location filename="../netconnect.cpp" line="158"/>
|
||||
<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="152"/>
|
||||
<location filename="../netconnect.cpp" line="155"/>
|
||||
<source>Advanced settings</source>
|
||||
<translation>高级设置</translation>
|
||||
<extra-contents_path>/netconnect/Advanced settings"</extra-contents_path>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../netconnect.cpp" line="64"/>
|
||||
<location filename="../netconnect.cpp" line="67"/>
|
||||
<source>ukui control center</source>
|
||||
<translation>控制面板</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../netconnect.cpp" line="67"/>
|
||||
<location filename="../netconnect.cpp" line="70"/>
|
||||
<source>ukui control center desktop message</source>
|
||||
<translation>控制面板桌面通知</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../netconnect.cpp" line="81"/>
|
||||
<source>WiredConnect</source>
|
||||
<translation type="vanished">有线网络</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../netconnect.cpp" line="84"/>
|
||||
<location filename="../netconnect.cpp" line="156"/>
|
||||
<source>LAN</source>
|
||||
<translation>有线网络</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../netconnect.cpp" line="169"/>
|
||||
<location filename="../netconnect.cpp" line="172"/>
|
||||
<source>No ethernet device avaliable</source>
|
||||
<translation>未检测到有线设备</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../netconnect.cpp" line="435"/>
|
||||
<location filename="../netconnect.cpp" line="864"/>
|
||||
<location filename="../netconnect.cpp" line="450"/>
|
||||
<location filename="../netconnect.cpp" line="896"/>
|
||||
<source>connected</source>
|
||||
<translation>已连接</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../netconnect.cpp" line="437"/>
|
||||
<location filename="../netconnect.cpp" line="717"/>
|
||||
<location filename="../netconnect.cpp" line="874"/>
|
||||
<location filename="../netconnect.cpp" line="452"/>
|
||||
<location filename="../netconnect.cpp" line="749"/>
|
||||
<location filename="../netconnect.cpp" line="906"/>
|
||||
<source>not connected</source>
|
||||
<translation>未连接</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../netconnect.cpp" line="510"/>
|
||||
<location filename="../netconnect.cpp" line="528"/>
|
||||
<source>card</source>
|
||||
<translation>网卡</translation>
|
||||
</message>
|
||||
|
|
|
@ -4,4 +4,4 @@ SUBDIRS = \
|
|||
wlanconnect \
|
||||
mobilehotspot \
|
||||
proxy \
|
||||
vpn \
|
||||
vpn
|
||||
|
|
|
@ -29,7 +29,7 @@ AppListWidget::AppListWidget(QString path, QWidget *parent)
|
|||
|
||||
AppListWidget::~AppListWidget()
|
||||
{
|
||||
|
||||
delete m_dbusInterface;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -79,8 +79,9 @@ void AppListWidget::onAppCheckStateChanged()
|
|||
*/
|
||||
void AppListWidget::AddAppProxyConfig()
|
||||
{
|
||||
if(!m_dbusInterface->isValid()) {
|
||||
if(m_dbusInterface == nullptr || !m_dbusInterface->isValid()) {
|
||||
qWarning ()<< "init AppProxy dbus error";
|
||||
return;
|
||||
}
|
||||
|
||||
qDebug() << "call QDBusInterface addAppIntoProxy";
|
||||
|
@ -93,8 +94,9 @@ void AppListWidget::AddAppProxyConfig()
|
|||
*/
|
||||
void AppListWidget::RemoveAppProxyConfig()
|
||||
{
|
||||
if(!m_dbusInterface->isValid()) {
|
||||
if(m_dbusInterface == nullptr || !m_dbusInterface->isValid()) {
|
||||
qWarning ()<< "init AppProxy dbus error";
|
||||
return;
|
||||
}
|
||||
|
||||
qDebug() << "call QDBusInterface delAppIntoProxy";
|
||||
|
@ -116,7 +118,6 @@ void AppListWidget::initUI()
|
|||
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);
|
||||
|
@ -135,4 +136,7 @@ void AppListWidget::initDbus()
|
|||
"/org/ukui/SettingsDaemon/AppProxy",
|
||||
"org.ukui.SettingsDaemon.AppProxy",
|
||||
QDBusConnection::sessionBus());
|
||||
if(!m_dbusInterface->isValid()) {
|
||||
qWarning() << qPrintable(QDBusConnection::sessionBus().lastError().message());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@
|
|||
|
||||
#define PROXY_HOST_KEY "host"
|
||||
#define PROXY_PORT_KEY "port"
|
||||
|
||||
#define THEME_SCHAME "org.ukui.style"
|
||||
#define FRAME_LAYOUT_MARGINS 16,0,16,0
|
||||
#define FRAME_LAYOUT_SPACING 8
|
||||
#define LABEL_WIDTH 136
|
||||
|
@ -68,6 +68,7 @@ Proxy::~Proxy()
|
|||
{
|
||||
if (!mFirstLoad) {
|
||||
plugin_leave();
|
||||
delete m_appProxyDbus;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -162,6 +163,11 @@ QIcon Proxy::icon() const
|
|||
return QIcon::fromTheme("ukui-network-agent-symbolic");
|
||||
}
|
||||
|
||||
QString Proxy::translationPath() const
|
||||
{
|
||||
return "/usr/share/kylin-nm/proxy/%1.ts";
|
||||
}
|
||||
|
||||
bool Proxy::isEnable() const
|
||||
{
|
||||
return true;
|
||||
|
@ -702,6 +708,9 @@ void Proxy::initDbus()
|
|||
"/org/ukui/SettingsDaemon/AppProxy",
|
||||
"org.ukui.SettingsDaemon.AppProxy",
|
||||
QDBusConnection::sessionBus());
|
||||
if(!m_appProxyDbus->isValid()) {
|
||||
qWarning() << qPrintable(QDBusConnection::sessionBus().lastError().message());
|
||||
}
|
||||
}
|
||||
|
||||
void Proxy::initAppProxyStatus()
|
||||
|
@ -752,8 +761,11 @@ void Proxy::setAptProxy(QString host, QString port, bool status)
|
|||
"/",
|
||||
"com.control.center.interface",
|
||||
QDBusConnection::systemBus());
|
||||
if (mAptproxyDbus->isValid())
|
||||
if (mAptproxyDbus->isValid()) {
|
||||
QDBusReply<bool> reply = mAptproxyDbus->call("setaptproxy", host, port , status);
|
||||
}
|
||||
delete mAptproxyDbus;
|
||||
mAptproxyDbus = nullptr;
|
||||
}
|
||||
|
||||
QHash<QString, QVariant> Proxy::getAptProxy()
|
||||
|
@ -786,6 +798,8 @@ QHash<QString, QVariant> Proxy::getAptProxy()
|
|||
mAptInfo.insert(it.arg, it.out.variant());
|
||||
}
|
||||
}
|
||||
delete mAptproxyDbus;
|
||||
mAptproxyDbus = nullptr;
|
||||
return mAptInfo;
|
||||
}
|
||||
|
||||
|
@ -814,8 +828,9 @@ void Proxy::reboot()
|
|||
"/org/gnome/SessionManager",
|
||||
"org.gnome.SessionManager",
|
||||
QDBusConnection::sessionBus());
|
||||
|
||||
if (rebootDbus->isValid()) {
|
||||
rebootDbus->call("reboot");
|
||||
}
|
||||
delete rebootDbus;
|
||||
rebootDbus = nullptr;
|
||||
}
|
||||
|
@ -841,8 +856,9 @@ QFrame *Proxy::setLine(QFrame *frame)
|
|||
bool Proxy::getAppProxyState()
|
||||
{
|
||||
bool state = true;
|
||||
if(!m_appProxyDbus->isValid()) {
|
||||
if(m_appProxyDbus == nullptr || !m_appProxyDbus->isValid()) {
|
||||
qWarning ()<< "init AppProxy dbus error";
|
||||
return false;
|
||||
}
|
||||
|
||||
//获取应用代理开启状态
|
||||
|
@ -859,7 +875,7 @@ bool Proxy::getAppProxyState()
|
|||
|
||||
void Proxy::setAppProxyState(bool state)
|
||||
{
|
||||
if(!m_appProxyDbus->isValid()) {
|
||||
if(m_appProxyDbus == nullptr || !m_appProxyDbus->isValid()) {
|
||||
qWarning ()<< "init AppProxy dbus error";
|
||||
return;
|
||||
}
|
||||
|
@ -881,6 +897,7 @@ QStringList Proxy::getAppProxyConf()
|
|||
|
||||
if(!dbusInterface.isValid()) {
|
||||
qWarning ()<< "init AppProxy dbus error";
|
||||
return info;
|
||||
}
|
||||
|
||||
//获取应用代理配置信息
|
||||
|
@ -903,11 +920,12 @@ QStringList Proxy::getAppProxyConf()
|
|||
|
||||
void Proxy::setAppProxyConf(QStringList list)
|
||||
{
|
||||
//AppProxyConf 必填项数量为3
|
||||
if (list.count() < 3) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(!m_appProxyDbus->isValid()) {
|
||||
if(m_appProxyDbus == nullptr || !m_appProxyDbus->isValid()) {
|
||||
qWarning ()<< "init AppProxy dbus error";
|
||||
return;
|
||||
}
|
||||
|
@ -1160,18 +1178,23 @@ void Proxy::setAppListFrameUi(QWidget *widget)
|
|||
m_allowAppProxyLabel->setText(tr("The following applications are allowed to use this configuration:")); //允许以下应用使用该配置:
|
||||
m_appListWidget = new QListWidget(m_appListFrame);
|
||||
m_appListWidget->setMinimumHeight(240);
|
||||
m_appListWidget->setBackgroundRole(QPalette::Base);
|
||||
m_appListWidget->setFocusPolicy(Qt::FocusPolicy::NoFocus);
|
||||
m_appListWidget->setFrameShape(QFrame::Shape::Panel);
|
||||
|
||||
appListLayout->addWidget(m_allowAppProxyLabel);
|
||||
appListLayout->addWidget(m_appListWidget);
|
||||
|
||||
QPalette mpal(m_appListWidget->palette());
|
||||
mpal.setColor(QPalette::Base, qApp->palette().base().color());
|
||||
mpal.setColor(QPalette::AlternateBase, qApp->palette().alternateBase().color());
|
||||
m_appListWidget->setAlternatingRowColors(true);
|
||||
m_appListWidget->setPalette(mpal);
|
||||
|
||||
onPaletteChanged();
|
||||
const QByteArray style_id(THEME_SCHAME);
|
||||
if (QGSettings::isSchemaInstalled(style_id)) {
|
||||
QGSettings * styleGsettings = new QGSettings(style_id, QByteArray(), this);
|
||||
connect(styleGsettings, &QGSettings::changed, this, [=](QString key){
|
||||
if ("styleName" == key) {
|
||||
onPaletteChanged();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void Proxy::appProxyInfoPadding()
|
||||
|
@ -1240,7 +1263,6 @@ void Proxy::onAppProxyConfChanged()
|
|||
{
|
||||
if (!getipEditState(m_ipAddressLineEdit->text()) || m_portLineEdit->text().isEmpty()) {
|
||||
return;
|
||||
qDebug() << "onAppProxyConfChanged return";
|
||||
}
|
||||
|
||||
if (m_ipAddressLineEdit->text().isEmpty()) {
|
||||
|
@ -1257,8 +1279,6 @@ void Proxy::onAppProxyConfChanged()
|
|||
m_appProxyInfo.append("");
|
||||
m_appProxyInfo.append("");
|
||||
}
|
||||
|
||||
qDebug() << m_appProxyInfo << Q_FUNC_INFO << __LINE__;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1269,6 +1289,16 @@ void Proxy::onAppProxyConfEditFinished()
|
|||
}
|
||||
}
|
||||
|
||||
void Proxy::onPaletteChanged()
|
||||
{
|
||||
QPalette mpal(m_appListWidget->palette());
|
||||
mpal.setColor(QPalette::Base, qApp->palette().base().color());
|
||||
mpal.setColor(QPalette::AlternateBase, qApp->palette().alternateBase().color());
|
||||
m_appListWidget->setBackgroundRole(QPalette::Base);
|
||||
m_appListWidget->setAlternatingRowColors(true);
|
||||
m_appListWidget->setPalette(mpal);
|
||||
}
|
||||
|
||||
void Proxy::onappProxyEnableChanged(bool enable)
|
||||
{
|
||||
m_proxyTypeFrame->setVisible(enable);
|
||||
|
|
|
@ -103,6 +103,7 @@ public:
|
|||
bool isShowOnHomePage() const Q_DECL_OVERRIDE;
|
||||
QIcon icon() const Q_DECL_OVERRIDE;
|
||||
bool isEnable() const Q_DECL_OVERRIDE;
|
||||
QString translationPath() const Q_DECL_OVERRIDE;
|
||||
|
||||
public:
|
||||
void initUi(QWidget *widget);
|
||||
|
@ -262,8 +263,8 @@ private:
|
|||
QFileSystemWatcher *mfileWatch_1;
|
||||
QFileSystemWatcher *mfileWatch_2;
|
||||
|
||||
QDBusInterface *mAptproxyDbus;
|
||||
QDBusInterface *m_appProxyDbus;
|
||||
// QDBusInterface *mAptproxyDbus;
|
||||
QDBusInterface *m_appProxyDbus = nullptr;
|
||||
|
||||
bool isExistSettings = false;
|
||||
bool settingsCreate;
|
||||
|
@ -277,6 +278,7 @@ private slots:
|
|||
void onipEditStateChanged(); //IP地址无效提示
|
||||
void onAppProxyConfChanged(); //应用代理配置信息变化
|
||||
void onAppProxyConfEditFinished();
|
||||
void onPaletteChanged();
|
||||
// void onCancelBtnClicked();
|
||||
// void onSaveBtnClicked();
|
||||
// void setBtnEnable();
|
||||
|
|
|
@ -25,36 +25,36 @@
|
|||
ItemFrame::ItemFrame(QWidget *parent)
|
||||
:QFrame(parent)
|
||||
{
|
||||
deviceLanLayout = new QVBoxLayout(this);
|
||||
deviceLanLayout->setContentsMargins(MAIN_LAYOUT_MARGINS);
|
||||
lanItemFrame = new QFrame(this);
|
||||
lanItemFrame->setFrameShape(QFrame::Shape::NoFrame);
|
||||
lanItemFrame->setContentsMargins(LAYOUT_MARGINS);
|
||||
m_mainVLayout = new QVBoxLayout(this);
|
||||
m_mainVLayout->setContentsMargins(MAIN_LAYOUT_MARGINS);
|
||||
m_vpnFrame = new QFrame(this);
|
||||
m_vpnFrame->setFrameShape(QFrame::Shape::NoFrame);
|
||||
m_vpnFrame->setContentsMargins(LAYOUT_MARGINS);
|
||||
|
||||
lanItemLayout = new QVBoxLayout(this);
|
||||
lanItemLayout->setContentsMargins(LAYOUT_MARGINS);
|
||||
lanItemLayout->setSpacing(1);
|
||||
addWlanWidget = new AddNetBtn(false, this);
|
||||
addWlanWidget->setTextLabel(tr("Add Vpn"));
|
||||
m_vpnVLayout = new QVBoxLayout(this);
|
||||
m_vpnVLayout->setContentsMargins(LAYOUT_MARGINS);
|
||||
m_vpnVLayout->setSpacing(1);
|
||||
m_addVpnWidget = new AddNetBtn(false, this);
|
||||
m_addVpnWidget->setTextLabel(tr("Add Vpn"));
|
||||
|
||||
deviceLanLayout->setSpacing(1);
|
||||
setLayout(deviceLanLayout);
|
||||
lanItemFrame->setLayout(lanItemLayout);
|
||||
m_mainVLayout->setSpacing(1);
|
||||
setLayout(m_mainVLayout);
|
||||
m_vpnFrame->setLayout(m_vpnVLayout);
|
||||
|
||||
deviceLanLayout->addWidget(lanItemFrame);
|
||||
deviceLanLayout->addWidget(addWlanWidget);
|
||||
m_mainVLayout->addWidget(m_vpnFrame);
|
||||
m_mainVLayout->addWidget(m_addVpnWidget);
|
||||
}
|
||||
|
||||
void ItemFrame::filletStyleChange()
|
||||
{
|
||||
if (lanItemLayout->isEmpty()) {
|
||||
if (m_vpnVLayout->isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < lanItemLayout->count(); ++i) {
|
||||
QLayoutItem *it = lanItemLayout->itemAt(i);
|
||||
for (int i = 0; i < m_vpnVLayout->count(); ++i) {
|
||||
QLayoutItem *it = m_vpnVLayout->itemAt(i);
|
||||
VpnItem *itemFrame = (VpnItem*)(it->widget());
|
||||
if (i != lanItemLayout->count()-1) {
|
||||
if (i != m_vpnVLayout->count()-1) {
|
||||
itemFrame->setHalfFillet(false);
|
||||
} else {
|
||||
itemFrame->setHalfFillet(true);
|
||||
|
|
|
@ -29,18 +29,18 @@ class ItemFrame : public QFrame
|
|||
Q_OBJECT
|
||||
public:
|
||||
ItemFrame(QWidget *parent = nullptr);
|
||||
//单设备整体layout
|
||||
QVBoxLayout * deviceLanLayout = nullptr;
|
||||
//单设备列表Frame
|
||||
QFrame * lanItemFrame = nullptr;
|
||||
//VPN整体layout
|
||||
QVBoxLayout * m_mainVLayout = nullptr;
|
||||
//vpn列表Frame
|
||||
QFrame * m_vpnFrame = nullptr;
|
||||
//单设备列表layout
|
||||
QVBoxLayout * lanItemLayout = nullptr;
|
||||
QVBoxLayout * m_vpnVLayout = nullptr;
|
||||
//item列表
|
||||
QMap<QString, VpnItem *> itemMap;
|
||||
QMap<QString, VpnItem *> m_itemMap;
|
||||
// //已激活uuid
|
||||
// QString uuid = "";
|
||||
//新建无线连接
|
||||
AddNetBtn * addWlanWidget = nullptr;
|
||||
AddNetBtn * m_addVpnWidget = nullptr;
|
||||
void filletStyleChange();
|
||||
};
|
||||
|
||||
|
|
|
@ -59,19 +59,19 @@
|
|||
const QString VISIBLE = "visible";
|
||||
const QByteArray GSETTINGS_SCHEMA = "org.ukui.kylin-nm.vpnicon";
|
||||
|
||||
Vpn::Vpn() : mFirstLoad(true)
|
||||
Vpn::Vpn() : m_firstLoad(true)
|
||||
{
|
||||
QTranslator* translator = new QTranslator(this);
|
||||
translator->load("/usr/share/kylin-nm/vpn/" + QLocale::system().name());
|
||||
QApplication::installTranslator(translator);
|
||||
|
||||
pluginName = tr("Vpn");
|
||||
pluginType = NETWORK;
|
||||
m_pluginName = tr("Vpn");
|
||||
m_pluginType = NETWORK;
|
||||
}
|
||||
|
||||
Vpn::~Vpn()
|
||||
{
|
||||
if (!mFirstLoad) {
|
||||
if (!m_firstLoad) {
|
||||
delete ui;
|
||||
ui = nullptr;
|
||||
delete m_interface;
|
||||
|
@ -80,25 +80,25 @@ Vpn::~Vpn()
|
|||
}
|
||||
|
||||
QString Vpn::plugini18nName(){
|
||||
return pluginName;
|
||||
return m_pluginName;
|
||||
}
|
||||
|
||||
int Vpn::pluginTypes(){
|
||||
return pluginType;
|
||||
return m_pluginType;
|
||||
}
|
||||
|
||||
QWidget *Vpn::pluginUi(){
|
||||
if (mFirstLoad) {
|
||||
mFirstLoad = false;
|
||||
if (m_firstLoad) {
|
||||
m_firstLoad = false;
|
||||
ui = new Ui::Vpn;
|
||||
pluginWidget = new QWidget;
|
||||
pluginWidget->setAttribute(Qt::WA_DeleteOnClose);
|
||||
ui->setupUi(pluginWidget);
|
||||
m_pluginWidget = new QWidget;
|
||||
m_pluginWidget->setAttribute(Qt::WA_DeleteOnClose);
|
||||
ui->setupUi(m_pluginWidget);
|
||||
|
||||
qDBusRegisterMetaType<QVector<QStringList>>();
|
||||
m_interface = new QDBusInterface("com.kylin.network",
|
||||
"/com/kylin/vpnTool",
|
||||
"com.kylin.vpnTool",
|
||||
m_interface = new QDBusInterface("com.kylin.kylinvpn",
|
||||
"/com/kylin/kylinvpn",
|
||||
"com.kylin.kylinvpn",
|
||||
QDBusConnection::sessionBus());
|
||||
if(!m_interface->isValid()) {
|
||||
qWarning() << qPrintable(QDBusConnection::sessionBus().lastError().message());
|
||||
|
@ -108,7 +108,7 @@ QWidget *Vpn::pluginUi(){
|
|||
initConnect();
|
||||
initNet();
|
||||
}
|
||||
return pluginWidget;
|
||||
return m_pluginWidget;
|
||||
}
|
||||
|
||||
const QString Vpn::name() const {
|
||||
|
@ -134,12 +134,12 @@ bool Vpn::isEnable() const
|
|||
void Vpn::initComponent(){
|
||||
//在任务栏上显示图标
|
||||
//显示已连接时间
|
||||
m_topFrame = new QFrame(pluginWidget);
|
||||
m_topFrame = new QFrame(m_pluginWidget);
|
||||
m_topFrame->setMinimumSize(FRAME_MIN_SIZE);
|
||||
m_topFrame->setMaximumSize(FRAME_MAX_SIZE);
|
||||
m_topFrame->setFrameShape(QFrame::Box);
|
||||
|
||||
QVBoxLayout *hotspotLyt = new QVBoxLayout(pluginWidget);
|
||||
QVBoxLayout *hotspotLyt = new QVBoxLayout(m_pluginWidget);
|
||||
hotspotLyt->setContentsMargins(0, 0, 0, 0);
|
||||
m_topFrame->setLayout(hotspotLyt);
|
||||
|
||||
|
@ -181,12 +181,13 @@ void Vpn::initComponent(){
|
|||
hotspotLyt->setSpacing(0);
|
||||
|
||||
//列表
|
||||
m_listFrame = new ItemFrame(pluginWidget);
|
||||
|
||||
m_listFrame = new ItemFrame(m_pluginWidget);
|
||||
|
||||
ui->verticalLayout_4->addWidget(m_topFrame);
|
||||
ui->verticalLayout_3->addWidget(m_listFrame);
|
||||
|
||||
connect(m_listFrame->addWlanWidget, &AddNetBtn::clicked, this, [=]() {
|
||||
connect(m_listFrame->m_addVpnWidget, &AddNetBtn::clicked, this, [=]() {
|
||||
runExternalApp();
|
||||
});
|
||||
|
||||
|
@ -267,14 +268,18 @@ void Vpn::setShowSwitchStatus()
|
|||
}
|
||||
|
||||
void Vpn::runExternalApp(){
|
||||
QString cmd = "nm-connection-editor";
|
||||
QProcess process(this);
|
||||
process.startDetached(cmd);
|
||||
// QString cmd = "nm-connection-editor";
|
||||
// QProcess process(this);
|
||||
// process.startDetached(cmd);
|
||||
|
||||
if (m_interface->isValid()) {
|
||||
m_interface->call(QStringLiteral("showVpnAddWidget"));
|
||||
}
|
||||
}
|
||||
|
||||
QFrame* Vpn::myLine()
|
||||
{
|
||||
QFrame *line = new QFrame(pluginWidget);
|
||||
QFrame *line = new QFrame(m_pluginWidget);
|
||||
line->setMinimumSize(QSize(LINE_MIN_SIZE));
|
||||
line->setMaximumSize(QSize(LINE_MAX_SIZE));
|
||||
line->setLineWidth(0);
|
||||
|
@ -295,6 +300,11 @@ void Vpn::activeConnect(QString uuid) {
|
|||
m_interface->call(QStringLiteral("activateVpn"), uuid);
|
||||
}
|
||||
|
||||
//详情页
|
||||
void Vpn::showDetailPage(QString uuid) {
|
||||
m_interface->call(QStringLiteral("showDetailPage"), uuid);
|
||||
}
|
||||
|
||||
//断开
|
||||
void Vpn::deActiveConnect(QString uuid) {
|
||||
m_interface->call(QStringLiteral("deactivateVpn"), uuid);
|
||||
|
@ -304,7 +314,12 @@ void Vpn::deActiveConnect(QString uuid) {
|
|||
//增加一项
|
||||
void Vpn::addOneVirtualItem(QStringList infoList)
|
||||
{
|
||||
if (m_listFrame->itemMap.contains(infoList.at(1))) {
|
||||
if (infoList.size() < 4) {
|
||||
qDebug() << "[Vpn]QStringList size less";
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_listFrame->m_itemMap.contains(infoList.at(1))) {
|
||||
qDebug() << "[Vpn]Already exist a virtual " << infoList.at(1);
|
||||
return;
|
||||
}
|
||||
|
@ -314,64 +329,55 @@ void Vpn::addOneVirtualItem(QStringList infoList)
|
|||
QString connUuid = infoList.at(1);
|
||||
QString connDbusPath = infoList.at(2);
|
||||
int status = infoList.at(3).toInt(); //1-连接中 2-已连接 3-断开中 4-已断开
|
||||
VpnItem * item = new VpnItem(pluginWidget);
|
||||
VpnItem * item = new VpnItem(m_pluginWidget);
|
||||
|
||||
QIcon searchIcon = QIcon::fromTheme(KVpnSymbolic);
|
||||
item->iconLabel->setPixmap(searchIcon.pixmap(searchIcon.actualSize(QSize(ICON_SIZE))));
|
||||
item->titileLabel->setText(connName);
|
||||
item->m_iconLabel->setPixmap(searchIcon.pixmap(searchIcon.actualSize(QSize(ICON_SIZE))));
|
||||
item->m_titileLabel->setText(connName);
|
||||
|
||||
item->uuid = connUuid;
|
||||
item->dbusPath = connDbusPath;
|
||||
item->m_uuid = connUuid;
|
||||
item->m_dbusPath = connDbusPath;
|
||||
|
||||
if (status == 1 || status == 3) {
|
||||
item->startLoading();
|
||||
}
|
||||
|
||||
connect(item->infoLabel, &InfoButton::clicked, this, [=]{
|
||||
QDBusInterface appManagerDbusInterface(KYLIN_APP_MANAGER_NAME,
|
||||
KYLIN_APP_MANAGER_PATH,
|
||||
KYLIN_APP_MANAGER_INTERFACE,
|
||||
QDBusConnection::sessionBus());
|
||||
|
||||
if (!appManagerDbusInterface.isValid()) {
|
||||
qWarning()<<"appManagerDbusInterface init error";
|
||||
} else {
|
||||
QDBusReply<bool> reply = appManagerDbusInterface.call("LaunchApp", "nm-connection-editor.desktop");
|
||||
}
|
||||
connect(item->m_infoLabel, &GrayInfoButton::clicked, this, [=]{
|
||||
showDetailPage(item->m_uuid);
|
||||
});
|
||||
|
||||
item->isAcitve = (status == 2);
|
||||
item->setConnectActionText(item->isAcitve);
|
||||
item->m_isAcitve = (status == 2);
|
||||
item->setConnectActionText(item->m_isAcitve);
|
||||
|
||||
if (item->isAcitve) {
|
||||
item->statusLabel->setText(tr("connected"));
|
||||
if (item->m_isAcitve) {
|
||||
item->m_statusLabel->setText(tr("connected"));
|
||||
} else {
|
||||
item->statusLabel->setText(tr("not connected"));
|
||||
item->m_statusLabel->setText(tr("not connected"));
|
||||
}
|
||||
|
||||
connect(item, &QPushButton::clicked, this, [=] {
|
||||
if (item->isAcitve || item->loading) {
|
||||
deActiveConnect(item->uuid);
|
||||
if (item->m_isAcitve || item->m_loading) {
|
||||
deActiveConnect(item->m_uuid);
|
||||
} else {
|
||||
activeConnect(item->uuid);
|
||||
activeConnect(item->m_uuid);
|
||||
}
|
||||
});
|
||||
|
||||
connect(item, &VpnItem::connectActionTriggered, this, [=] {
|
||||
activeConnect(item->uuid);
|
||||
activeConnect(item->m_uuid);
|
||||
});
|
||||
connect(item, &VpnItem::disconnectActionTriggered, this, [=] {
|
||||
deActiveConnect(item->uuid);
|
||||
deActiveConnect(item->m_uuid);
|
||||
});
|
||||
connect(item, &VpnItem::deleteActionTriggered, this, [=] {
|
||||
deleteVpn(item->uuid);
|
||||
deleteVpn(item->m_uuid);
|
||||
});
|
||||
|
||||
//记录到deviceFrame的itemMap中
|
||||
m_listFrame->itemMap.insert(connUuid, item);
|
||||
//记录到deviceFrame的m_itemMap中
|
||||
m_listFrame->m_itemMap.insert(connUuid, item);
|
||||
int index = getInsertPos(connName);
|
||||
qDebug()<<"[Vpn]addOneVirtualItem " << connName << " at pos:" << index;
|
||||
m_listFrame->lanItemLayout->insertWidget(index, item);
|
||||
m_listFrame->m_vpnVLayout->insertWidget(index, item);
|
||||
}
|
||||
|
||||
void Vpn::removeOneVirtualItem(QString dbusPath)
|
||||
|
@ -379,13 +385,13 @@ void Vpn::removeOneVirtualItem(QString dbusPath)
|
|||
qDebug()<<"[Vpn]vpn remove dbus path:" << dbusPath;
|
||||
|
||||
QMap<QString, VpnItem *>::iterator itemIter;
|
||||
for (itemIter = m_listFrame->itemMap.begin(); itemIter != m_listFrame->itemMap.end(); itemIter++) {
|
||||
if (itemIter.value()->dbusPath == dbusPath) {
|
||||
qDebug()<<"[Vpn]vpn remove " << dbusPath << " find in " << itemIter.value()->titileLabel->text();
|
||||
for (itemIter = m_listFrame->m_itemMap.begin(); itemIter != m_listFrame->m_itemMap.end(); itemIter++) {
|
||||
if (itemIter.value()->m_dbusPath == dbusPath) {
|
||||
qDebug()<<"[Vpn]vpn remove " << dbusPath << " find in " << itemIter.value()->m_titileLabel->text();
|
||||
QString key = itemIter.key();
|
||||
m_listFrame->lanItemLayout->removeWidget(itemIter.value());
|
||||
m_listFrame->m_vpnVLayout->removeWidget(itemIter.value());
|
||||
delete itemIter.value();
|
||||
m_listFrame->itemMap.remove(key);
|
||||
m_listFrame->m_itemMap.remove(key);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -398,18 +404,18 @@ void Vpn::onVpnAdd(QStringList infoList)
|
|||
}
|
||||
|
||||
//移出
|
||||
void Vpn::onVpnRemove(QString uuid)
|
||||
void Vpn::onVpnRemove(QString path)
|
||||
{
|
||||
removeOneVirtualItem(uuid);
|
||||
removeOneVirtualItem(path);
|
||||
}
|
||||
|
||||
//名称变化
|
||||
void Vpn::onVpnUpdate(QStringList info)
|
||||
{
|
||||
if (m_listFrame->itemMap.contains(info.at(1))) {
|
||||
qDebug() << "[Vpn]" << m_listFrame->itemMap[info.at(1)]->titileLabel->text() << "change to" << info.at(0);
|
||||
if (m_listFrame->itemMap[info.at(1)]->titileLabel->text() != info.at(0)) {
|
||||
m_listFrame->itemMap[info.at(1)]->titileLabel->setText(info.at(0));
|
||||
if (m_listFrame->m_itemMap.contains(info.at(1))) {
|
||||
qDebug() << "[Vpn]" << m_listFrame->m_itemMap[info.at(1)]->m_titileLabel->text() << "change to" << info.at(0);
|
||||
if (m_listFrame->m_itemMap[info.at(1)]->m_titileLabel->text() != info.at(0)) {
|
||||
m_listFrame->m_itemMap[info.at(1)]->m_titileLabel->setText(info.at(0));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -423,18 +429,18 @@ void Vpn::onVpnActiveConnectionStateChanged(QString uuid, int status)
|
|||
qDebug() << "[Vpn]onActiveConnectionChanged " << uuid << status;
|
||||
VpnItem * item= nullptr;
|
||||
|
||||
if (m_listFrame->itemMap.contains(uuid)) {
|
||||
item = m_listFrame->itemMap[uuid];
|
||||
if (m_listFrame->m_itemMap.contains(uuid)) {
|
||||
item = m_listFrame->m_itemMap[uuid];
|
||||
if (status == ACTIVATED) {
|
||||
//为已连接则放到第一个
|
||||
m_listFrame->lanItemLayout->removeWidget(item);
|
||||
m_listFrame->lanItemLayout->insertWidget(0,item);
|
||||
m_listFrame->m_vpnVLayout->removeWidget(item);
|
||||
m_listFrame->m_vpnVLayout->insertWidget(0,item);
|
||||
} else if (status == DEACTIVATED) {
|
||||
//为断开则重新插入
|
||||
int index = getInsertPos(item->titileLabel->text());
|
||||
qDebug() << "[Vpn]reinsert" << item->titileLabel->text() << "pos" << index << "because status changes to deactive";
|
||||
m_listFrame->lanItemLayout->removeWidget(item);
|
||||
m_listFrame->lanItemLayout->insertWidget(index,item);
|
||||
int index = getInsertPos(item->m_titileLabel->text());
|
||||
qDebug() << "[Vpn]reinsert" << item->m_titileLabel->text() << "pos" << index << "because status changes to deactive";
|
||||
m_listFrame->m_vpnVLayout->removeWidget(item);
|
||||
m_listFrame->m_vpnVLayout->insertWidget(index,item);
|
||||
}
|
||||
itemActiveConnectionStatusChanged(item, status);
|
||||
}
|
||||
|
@ -448,22 +454,22 @@ void Vpn::itemActiveConnectionStatusChanged(VpnItem *item, int status)
|
|||
} else if (status == ACTIVATED) {
|
||||
item->stopLoading();
|
||||
// iconPath = KLanSymbolic;
|
||||
item->statusLabel->clear();
|
||||
item->statusLabel->setMinimumSize(36,36);
|
||||
item->statusLabel->setMaximumSize(16777215,16777215);
|
||||
item->statusLabel->setText(tr("connected"));
|
||||
item->isAcitve = true;
|
||||
item->m_statusLabel->clear();
|
||||
item->m_statusLabel->setMinimumSize(36,36);
|
||||
item->m_statusLabel->setMaximumSize(16777215,16777215);
|
||||
item->m_statusLabel->setText(tr("connected"));
|
||||
item->m_isAcitve = true;
|
||||
} else if (status == DEACTIVATING) {
|
||||
item->startLoading();
|
||||
} else {
|
||||
item->stopLoading();
|
||||
item->statusLabel->setMinimumSize(36,36);
|
||||
item->statusLabel->setMaximumSize(16777215,16777215);
|
||||
item->statusLabel->clear();
|
||||
item->isAcitve = false;
|
||||
item->statusLabel->setText(tr("not connected"));
|
||||
item->m_statusLabel->setMinimumSize(36,36);
|
||||
item->m_statusLabel->setMaximumSize(16777215,16777215);
|
||||
item->m_statusLabel->clear();
|
||||
item->m_isAcitve = false;
|
||||
item->m_statusLabel->setText(tr("not connected"));
|
||||
}
|
||||
item->setConnectActionText(item->isAcitve);
|
||||
item->setConnectActionText(item->m_isAcitve);
|
||||
}
|
||||
|
||||
int Vpn::getInsertPos(QString connName)
|
||||
|
|
|
@ -69,9 +69,9 @@ protected:
|
|||
private:
|
||||
Ui::Vpn *ui;
|
||||
|
||||
QString pluginName;
|
||||
int pluginType;
|
||||
QWidget * pluginWidget;
|
||||
QString m_pluginName;
|
||||
int m_pluginType;
|
||||
QWidget * m_pluginWidget;
|
||||
|
||||
QDBusInterface *m_interface = nullptr;
|
||||
|
||||
|
@ -85,7 +85,7 @@ private:
|
|||
KSwitchButton *m_timeBtn;
|
||||
ItemFrame *m_listFrame;
|
||||
|
||||
bool mFirstLoad;
|
||||
bool m_firstLoad;
|
||||
QGSettings *m_switchGsettings;
|
||||
|
||||
QFrame* myLine();
|
||||
|
@ -95,6 +95,7 @@ private:
|
|||
void deleteVpn(QString uuid);
|
||||
void activeConnect(QString uuid);
|
||||
void deActiveConnect(QString uuid);
|
||||
void showDetailPage(QString uuid);
|
||||
|
||||
//获取设备列表
|
||||
void initNet();
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
#define MODE_QT_KEY "style-name"
|
||||
|
||||
VpnItem::VpnItem(bool bAcitve, QWidget *parent)
|
||||
: isAcitve(bAcitve), QPushButton(parent)
|
||||
: m_isAcitve(bAcitve), QPushButton(parent)
|
||||
{
|
||||
this->setMinimumSize(550, 58);
|
||||
this->setProperty("useButtonPalette", true);
|
||||
|
@ -41,12 +41,12 @@ VpnItem::VpnItem(bool bAcitve, QWidget *parent)
|
|||
QHBoxLayout *mLanLyt = new QHBoxLayout(this);
|
||||
mLanLyt->setContentsMargins(16,0,16,0);
|
||||
mLanLyt->setSpacing(16);
|
||||
iconLabel = new QLabel(this);
|
||||
iconLabel->setProperty("useIconHighlightEffect", 0x2);
|
||||
titileLabel = new FixLabel(this);
|
||||
statusLabel = new QLabel(this);
|
||||
statusLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
|
||||
infoLabel = new InfoButton(this);
|
||||
m_iconLabel = new QLabel(this);
|
||||
m_iconLabel->setProperty("useIconHighlightEffect", 0x2);
|
||||
m_titileLabel = new FixLabel(this);
|
||||
m_statusLabel = new QLabel(this);
|
||||
m_statusLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
|
||||
m_infoLabel = new GrayInfoButton(this);
|
||||
|
||||
m_moreButton = new QToolButton(this);
|
||||
m_moreButton->setProperty("useButtonPalette", true);
|
||||
|
@ -56,29 +56,28 @@ VpnItem::VpnItem(bool bAcitve, QWidget *parent)
|
|||
m_moreMenu = new QMenu(m_moreButton);
|
||||
m_connectAction = new QAction(m_moreMenu);
|
||||
m_deleteAction = new QAction(tr("Delete"), m_moreMenu);
|
||||
setConnectActionText(isAcitve);
|
||||
setConnectActionText(m_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->addWidget(m_iconLabel);
|
||||
mLanLyt->addWidget(m_titileLabel,Qt::AlignLeft);
|
||||
mLanLyt->addStretch();
|
||||
mLanLyt->addWidget(statusLabel);
|
||||
mLanLyt->addWidget(infoLabel);
|
||||
mLanLyt->addWidget(m_statusLabel);
|
||||
mLanLyt->addWidget(m_infoLabel);
|
||||
mLanLyt->addWidget(m_moreButton);
|
||||
|
||||
loadIcons.append(QIcon::fromTheme("ukui-loading-1-symbolic"));
|
||||
loadIcons.append(QIcon::fromTheme("ukui-loading-2-symbolic"));
|
||||
loadIcons.append(QIcon::fromTheme("ukui-loading-3-symbolic"));
|
||||
loadIcons.append(QIcon::fromTheme("ukui-loading-4-symbolic"));
|
||||
loadIcons.append(QIcon::fromTheme("ukui-loading-5-symbolic"));
|
||||
loadIcons.append(QIcon::fromTheme("ukui-loading-6-symbolic"));
|
||||
loadIcons.append(QIcon::fromTheme("ukui-loading-7-symbolic"));
|
||||
m_loadIcons.append(QIcon::fromTheme("ukui-loading-1-symbolic"));
|
||||
m_loadIcons.append(QIcon::fromTheme("ukui-loading-2-symbolic"));
|
||||
m_loadIcons.append(QIcon::fromTheme("ukui-loading-3-symbolic"));
|
||||
m_loadIcons.append(QIcon::fromTheme("ukui-loading-4-symbolic"));
|
||||
m_loadIcons.append(QIcon::fromTheme("ukui-loading-5-symbolic"));
|
||||
m_loadIcons.append(QIcon::fromTheme("ukui-loading-6-symbolic"));
|
||||
m_loadIcons.append(QIcon::fromTheme("ukui-loading-7-symbolic"));
|
||||
|
||||
waitTimer = new QTimer(this);
|
||||
connect(waitTimer, &QTimer::timeout, this, &VpnItem::updateIcon);
|
||||
m_waitTimer = new QTimer(this);
|
||||
connect(m_waitTimer, &QTimer::timeout, this, &VpnItem::updateIcon);
|
||||
|
||||
connect(m_connectAction, &QAction::triggered, this, &VpnItem::onConnectTriggered);
|
||||
connect(m_deleteAction, &QAction::triggered, this, &VpnItem::onDeletetTriggered);
|
||||
|
@ -87,22 +86,22 @@ VpnItem::VpnItem(bool bAcitve, QWidget *parent)
|
|||
|
||||
void VpnItem::updateIcon()
|
||||
{
|
||||
if (currentIconIndex > 6) {
|
||||
currentIconIndex = 0;
|
||||
if (m_currentIconIndex > 6) {
|
||||
m_currentIconIndex = 0;
|
||||
}
|
||||
statusLabel->setPixmap(loadIcons.at(currentIconIndex).pixmap(16,16));
|
||||
currentIconIndex ++;
|
||||
m_statusLabel->setPixmap(m_loadIcons.at(m_currentIconIndex).pixmap(16,16));
|
||||
m_currentIconIndex ++;
|
||||
}
|
||||
|
||||
void VpnItem::startLoading()
|
||||
{
|
||||
waitTimer->start(FRAME_SPEED);
|
||||
loading = true;
|
||||
m_waitTimer->start(FRAME_SPEED);
|
||||
m_loading = true;
|
||||
}
|
||||
|
||||
void VpnItem::stopLoading(){
|
||||
waitTimer->stop();
|
||||
loading = false;
|
||||
m_waitTimer->stop();
|
||||
m_loading = false;
|
||||
}
|
||||
|
||||
void VpnItem::setConnectActionText(bool isAcitve)
|
||||
|
@ -146,7 +145,7 @@ void VpnItem::paintEvent(QPaintEvent *event)
|
|||
QRect rect = this->rect();
|
||||
|
||||
#if 0
|
||||
if (!useHalfFillet) {
|
||||
if (!m_useHalfFillet) {
|
||||
painter.drawRect(rect);
|
||||
} else {
|
||||
QPainterPath path;
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
#include <QMenu>
|
||||
#include <QEvent>
|
||||
#include "fixlabel.h"
|
||||
#include "infobutton.h"
|
||||
#include "../component/AddBtn/grayinfobutton.h"
|
||||
|
||||
class VpnItem : public QPushButton
|
||||
{
|
||||
|
@ -41,37 +41,36 @@ class VpnItem : public QPushButton
|
|||
public:
|
||||
VpnItem(bool bAcitve, QWidget *parent = nullptr);
|
||||
public:
|
||||
QLabel * iconLabel = nullptr;
|
||||
InfoButton * infoLabel = nullptr;
|
||||
FixLabel * titileLabel = nullptr;
|
||||
QLabel * statusLabel = nullptr;
|
||||
QLabel * m_iconLabel = nullptr;
|
||||
GrayInfoButton * m_infoLabel = nullptr;
|
||||
FixLabel * m_titileLabel = nullptr;
|
||||
QLabel * m_statusLabel = nullptr;
|
||||
QToolButton* m_moreButton = nullptr;
|
||||
QMenu* m_moreMenu = nullptr;
|
||||
QAction* m_connectAction = nullptr;
|
||||
QAction* m_deleteAction = nullptr;
|
||||
|
||||
QString uuid = "";
|
||||
QString dbusPath = "";
|
||||
QString m_uuid = "";
|
||||
QString m_dbusPath = "";
|
||||
|
||||
void setHalfFillet(bool flag) {useHalfFillet = flag; repaint();}
|
||||
void setHalfFillet(bool flag) {m_useHalfFillet = flag; repaint();}
|
||||
public:
|
||||
void startLoading();
|
||||
void stopLoading();
|
||||
void setConnectActionText(bool isAcitve);
|
||||
|
||||
bool isAcitve = false;
|
||||
bool loading = false;
|
||||
bool m_isAcitve = false;
|
||||
bool m_loading = false;
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *event);
|
||||
bool eventFilter(QObject *watched, QEvent *event);
|
||||
|
||||
private:
|
||||
QTimer *waitTimer = nullptr;
|
||||
QGSettings *themeGsettings = nullptr;
|
||||
bool useHalfFillet = false;
|
||||
QList<QIcon> loadIcons;
|
||||
int currentIconIndex=0;
|
||||
QTimer *m_waitTimer = nullptr;
|
||||
bool m_useHalfFillet = false;
|
||||
QList<QIcon> m_loadIcons;
|
||||
int m_currentIconIndex=0;
|
||||
|
||||
private slots:
|
||||
void updateIcon();
|
||||
|
|
|
@ -1,3 +1,22 @@
|
|||
/* -*- 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 "deviceframe.h"
|
||||
#include <QPainter>
|
||||
#include <QPainterPath>
|
||||
|
|
|
@ -1,3 +1,22 @@
|
|||
/* -*- 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 DEVICEFRAME_H
|
||||
#define DEVICEFRAME_H
|
||||
#include <QObject>
|
||||
|
|
|
@ -1,3 +1,22 @@
|
|||
/* -*- 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 "itemframe.h"
|
||||
#include <QPainter>
|
||||
|
||||
|
|
|
@ -1,3 +1,22 @@
|
|||
/* -*- 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 ITEMFRAME_H
|
||||
#define ITEMFRAME_H
|
||||
#include <QFrame>
|
||||
|
|
|
@ -4,12 +4,12 @@
|
|||
<context>
|
||||
<name>AddNetBtn</name>
|
||||
<message>
|
||||
<location filename="../../component/AddBtn/addnetbtn.cpp" line="24"/>
|
||||
<location filename="../../component/AddBtn/addnetbtn.cpp" line="44"/>
|
||||
<source>Add Others</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../component/AddBtn/addnetbtn.cpp" line="27"/>
|
||||
<location filename="../../component/AddBtn/addnetbtn.cpp" line="48"/>
|
||||
<source>Add WiredNetork</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
|
@ -18,54 +18,54 @@
|
|||
<name>WlanConnect</name>
|
||||
<message>
|
||||
<location filename="../wlanconnect.ui" line="14"/>
|
||||
<location filename="../wlanconnect.cpp" line="140"/>
|
||||
<source>WlanConnect</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../wlanconnect.ui" line="35"/>
|
||||
<location filename="../wlanconnect.cpp" line="211"/>
|
||||
<location filename="../wlanconnect.cpp" line="144"/>
|
||||
<location filename="../wlanconnect.cpp" line="215"/>
|
||||
<source>WLAN</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../wlanconnect.ui" line="94"/>
|
||||
<location filename="../wlanconnect.cpp" line="213"/>
|
||||
<location filename="../wlanconnect.cpp" line="217"/>
|
||||
<source>open</source>
|
||||
<translation type="unfinished"></translation>
|
||||
<extra-contents_path>/wlanconnect/open</extra-contents_path>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../wlanconnect.ui" line="147"/>
|
||||
<location filename="../wlanconnect.cpp" line="210"/>
|
||||
<location filename="../wlanconnect.cpp" line="214"/>
|
||||
<source>Advanced settings</source>
|
||||
<translation type="unfinished"></translation>
|
||||
<extra-contents_path>/wlanconnect/Advanced settings"</extra-contents_path>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../wlanconnect.cpp" line="123"/>
|
||||
<location filename="../wlanconnect.cpp" line="127"/>
|
||||
<source>ukui control center</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../wlanconnect.cpp" line="126"/>
|
||||
<location filename="../wlanconnect.cpp" line="130"/>
|
||||
<source>ukui control center desktop message</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../wlanconnect.cpp" line="228"/>
|
||||
<location filename="../wlanconnect.cpp" line="232"/>
|
||||
<source>No wireless network card detected</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../wlanconnect.cpp" line="374"/>
|
||||
<location filename="../wlanconnect.cpp" line="1022"/>
|
||||
<location filename="../wlanconnect.cpp" line="1084"/>
|
||||
<location filename="../wlanconnect.cpp" line="368"/>
|
||||
<location filename="../wlanconnect.cpp" line="1039"/>
|
||||
<location filename="../wlanconnect.cpp" line="1101"/>
|
||||
<source>connected</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../wlanconnect.cpp" line="959"/>
|
||||
<location filename="../wlanconnect.cpp" line="976"/>
|
||||
<source>card</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
|
|
Binary file not shown.
|
@ -0,0 +1,73 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE TS>
|
||||
<TS version="2.1" language="bo_CN">
|
||||
<context>
|
||||
<name>AddNetBtn</name>
|
||||
<message>
|
||||
<location filename="../../component/AddBtn/addnetbtn.cpp" line="44"/>
|
||||
<source>Add Others</source>
|
||||
<translation>དྲ་རྒྱ་གཞན་དག་ནང་ཞུགས་དགོས།</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../component/AddBtn/addnetbtn.cpp" line="48"/>
|
||||
<source>Add WiredNetork</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>WlanConnect</name>
|
||||
<message>
|
||||
<location filename="../wlanconnect.ui" line="14"/>
|
||||
<source>WlanConnect</source>
|
||||
<translation>ཝུའུ་ལན་འབྲེལ་མཐུད།</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../wlanconnect.ui" line="35"/>
|
||||
<location filename="../wlanconnect.cpp" line="144"/>
|
||||
<location filename="../wlanconnect.cpp" line="215"/>
|
||||
<source>WLAN</source>
|
||||
<translation>སྐུད་མེད་ཅུས་ཁོངས་ཀྱི་དྲ་བ།</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../wlanconnect.ui" line="94"/>
|
||||
<location filename="../wlanconnect.cpp" line="217"/>
|
||||
<source>open</source>
|
||||
<translation>སྒོ་ཕྱེ་བ།</translation>
|
||||
<extra-contents_path>/wlanconnect/open</extra-contents_path>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../wlanconnect.ui" line="147"/>
|
||||
<location filename="../wlanconnect.cpp" line="214"/>
|
||||
<source>Advanced settings</source>
|
||||
<translation>སྔོན་ཐོན་གྱི་སྒྲིག་བཀོད།</translation>
|
||||
<extra-contents_path>/wlanconnect/Advanced settings"</extra-contents_path>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../wlanconnect.cpp" line="127"/>
|
||||
<source>ukui control center</source>
|
||||
<translation>ཝུའུ་ཁི་ལན་གྱི་ཚོད་འཛིན་ལྟེ་གནས།</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../wlanconnect.cpp" line="130"/>
|
||||
<source>ukui control center desktop message</source>
|
||||
<translation>ངོས་ལེབ་ངོས་ཀྱི་བརྡ་ཐོ་ཚོད་འཛིན་བྱ་དགོས།</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../wlanconnect.cpp" line="232"/>
|
||||
<source>No wireless network card detected</source>
|
||||
<translation>སྐུད་མེད་དྲ་རྒྱའི་བྱང་བུ་མ་རྙེད་པ།</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../wlanconnect.cpp" line="368"/>
|
||||
<location filename="../wlanconnect.cpp" line="1039"/>
|
||||
<location filename="../wlanconnect.cpp" line="1101"/>
|
||||
<source>connected</source>
|
||||
<translation>འབྲེལ་མཐུད་བྱེད་པ།</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../wlanconnect.cpp" line="976"/>
|
||||
<source>card</source>
|
||||
<translation>བྱང་བུ།</translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
|
@ -0,0 +1,73 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE TS>
|
||||
<TS version="2.1" language="zh_CN">
|
||||
<context>
|
||||
<name>AddNetBtn</name>
|
||||
<message>
|
||||
<location filename="../../component/AddBtn/addnetbtn.cpp" line="44"/>
|
||||
<source>Add Others</source>
|
||||
<translation>Add Others</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../component/AddBtn/addnetbtn.cpp" line="48"/>
|
||||
<source>Add WiredNetork</source>
|
||||
<translation>Add WiredNetork</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>WlanConnect</name>
|
||||
<message>
|
||||
<location filename="../wlanconnect.ui" line="14"/>
|
||||
<source>WlanConnect</source>
|
||||
<translation>WlanConnect</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../wlanconnect.ui" line="35"/>
|
||||
<location filename="../wlanconnect.cpp" line="144"/>
|
||||
<location filename="../wlanconnect.cpp" line="215"/>
|
||||
<source>WLAN</source>
|
||||
<translation>WLAN</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../wlanconnect.ui" line="94"/>
|
||||
<location filename="../wlanconnect.cpp" line="217"/>
|
||||
<source>open</source>
|
||||
<translation>open</translation>
|
||||
<extra-contents_path>/wlanconnect/open</extra-contents_path>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../wlanconnect.ui" line="147"/>
|
||||
<location filename="../wlanconnect.cpp" line="214"/>
|
||||
<source>Advanced settings</source>
|
||||
<translation>Advanced settings</translation>
|
||||
<extra-contents_path>/wlanconnect/Advanced settings"</extra-contents_path>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../wlanconnect.cpp" line="127"/>
|
||||
<source>ukui control center</source>
|
||||
<translation>ukui control center</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../wlanconnect.cpp" line="130"/>
|
||||
<source>ukui control center desktop message</source>
|
||||
<translation>ukui control center desktop message</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../wlanconnect.cpp" line="232"/>
|
||||
<source>No wireless network card detected</source>
|
||||
<translation>No wireless network card detected</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../wlanconnect.cpp" line="368"/>
|
||||
<location filename="../wlanconnect.cpp" line="1039"/>
|
||||
<location filename="../wlanconnect.cpp" line="1101"/>
|
||||
<source>connected</source>
|
||||
<translation>connected</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../wlanconnect.cpp" line="976"/>
|
||||
<source>card</source>
|
||||
<translation>card</translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
|
@ -4,12 +4,12 @@
|
|||
<context>
|
||||
<name>AddNetBtn</name>
|
||||
<message>
|
||||
<location filename="../../component/AddBtn/addnetbtn.cpp" line="24"/>
|
||||
<location filename="../../component/AddBtn/addnetbtn.cpp" line="44"/>
|
||||
<source>Add Others</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../component/AddBtn/addnetbtn.cpp" line="27"/>
|
||||
<location filename="../../component/AddBtn/addnetbtn.cpp" line="48"/>
|
||||
<source>Add WiredNetork</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
|
@ -18,54 +18,54 @@
|
|||
<name>WlanConnect</name>
|
||||
<message>
|
||||
<location filename="../wlanconnect.ui" line="14"/>
|
||||
<location filename="../wlanconnect.cpp" line="140"/>
|
||||
<source>WlanConnect</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../wlanconnect.ui" line="35"/>
|
||||
<location filename="../wlanconnect.cpp" line="211"/>
|
||||
<location filename="../wlanconnect.cpp" line="144"/>
|
||||
<location filename="../wlanconnect.cpp" line="215"/>
|
||||
<source>WLAN</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../wlanconnect.ui" line="94"/>
|
||||
<location filename="../wlanconnect.cpp" line="213"/>
|
||||
<location filename="../wlanconnect.cpp" line="217"/>
|
||||
<source>open</source>
|
||||
<translation type="unfinished"></translation>
|
||||
<extra-contents_path>/wlanconnect/open</extra-contents_path>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../wlanconnect.ui" line="147"/>
|
||||
<location filename="../wlanconnect.cpp" line="210"/>
|
||||
<location filename="../wlanconnect.cpp" line="214"/>
|
||||
<source>Advanced settings</source>
|
||||
<translation type="unfinished"></translation>
|
||||
<extra-contents_path>/wlanconnect/Advanced settings"</extra-contents_path>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../wlanconnect.cpp" line="123"/>
|
||||
<location filename="../wlanconnect.cpp" line="127"/>
|
||||
<source>ukui control center</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../wlanconnect.cpp" line="126"/>
|
||||
<location filename="../wlanconnect.cpp" line="130"/>
|
||||
<source>ukui control center desktop message</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../wlanconnect.cpp" line="228"/>
|
||||
<location filename="../wlanconnect.cpp" line="232"/>
|
||||
<source>No wireless network card detected</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../wlanconnect.cpp" line="374"/>
|
||||
<location filename="../wlanconnect.cpp" line="1022"/>
|
||||
<location filename="../wlanconnect.cpp" line="1084"/>
|
||||
<location filename="../wlanconnect.cpp" line="368"/>
|
||||
<location filename="../wlanconnect.cpp" line="1039"/>
|
||||
<location filename="../wlanconnect.cpp" line="1101"/>
|
||||
<source>connected</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../wlanconnect.cpp" line="959"/>
|
||||
<location filename="../wlanconnect.cpp" line="976"/>
|
||||
<source>card</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
|
|
|
@ -4,12 +4,12 @@
|
|||
<context>
|
||||
<name>AddNetBtn</name>
|
||||
<message>
|
||||
<location filename="../../component/AddBtn/addnetbtn.cpp" line="24"/>
|
||||
<location filename="../../component/AddBtn/addnetbtn.cpp" line="44"/>
|
||||
<source>Add Others</source>
|
||||
<translation>加入其它网络</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../component/AddBtn/addnetbtn.cpp" line="27"/>
|
||||
<location filename="../../component/AddBtn/addnetbtn.cpp" line="48"/>
|
||||
<source>Add WiredNetork</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
|
@ -18,54 +18,54 @@
|
|||
<name>WlanConnect</name>
|
||||
<message>
|
||||
<location filename="../wlanconnect.ui" line="14"/>
|
||||
<location filename="../wlanconnect.cpp" line="140"/>
|
||||
<source>WlanConnect</source>
|
||||
<translation>无线局域网</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../wlanconnect.ui" line="35"/>
|
||||
<location filename="../wlanconnect.cpp" line="211"/>
|
||||
<location filename="../wlanconnect.cpp" line="144"/>
|
||||
<location filename="../wlanconnect.cpp" line="215"/>
|
||||
<source>WLAN</source>
|
||||
<translation>无线局域网</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../wlanconnect.ui" line="94"/>
|
||||
<location filename="../wlanconnect.cpp" line="213"/>
|
||||
<location filename="../wlanconnect.cpp" line="217"/>
|
||||
<source>open</source>
|
||||
<translation>开启</translation>
|
||||
<extra-contents_path>/wlanconnect/open</extra-contents_path>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../wlanconnect.ui" line="147"/>
|
||||
<location filename="../wlanconnect.cpp" line="210"/>
|
||||
<location filename="../wlanconnect.cpp" line="214"/>
|
||||
<source>Advanced settings</source>
|
||||
<translation>高级设置</translation>
|
||||
<extra-contents_path>/wlanconnect/Advanced settings"</extra-contents_path>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../wlanconnect.cpp" line="123"/>
|
||||
<location filename="../wlanconnect.cpp" line="127"/>
|
||||
<source>ukui control center</source>
|
||||
<translation>控制面板</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../wlanconnect.cpp" line="126"/>
|
||||
<location filename="../wlanconnect.cpp" line="130"/>
|
||||
<source>ukui control center desktop message</source>
|
||||
<translation>控制面板桌面通知</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../wlanconnect.cpp" line="228"/>
|
||||
<location filename="../wlanconnect.cpp" line="232"/>
|
||||
<source>No wireless network card detected</source>
|
||||
<translation>未检测到无线网卡</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../wlanconnect.cpp" line="374"/>
|
||||
<location filename="../wlanconnect.cpp" line="1022"/>
|
||||
<location filename="../wlanconnect.cpp" line="1084"/>
|
||||
<location filename="../wlanconnect.cpp" line="368"/>
|
||||
<location filename="../wlanconnect.cpp" line="1039"/>
|
||||
<location filename="../wlanconnect.cpp" line="1101"/>
|
||||
<source>connected</source>
|
||||
<translation>已连接</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../wlanconnect.cpp" line="959"/>
|
||||
<location filename="../wlanconnect.cpp" line="976"/>
|
||||
<source>card</source>
|
||||
<translation>网卡</translation>
|
||||
</message>
|
||||
|
|
|
@ -48,6 +48,10 @@
|
|||
#define SIGNAL_NONE 5
|
||||
#define ICON_SIZE 16,16
|
||||
|
||||
#define KYLIN_APP_MANAGER_NAME "com.kylin.AppManager"
|
||||
#define KYLIN_APP_MANAGER_PATH "/com/kylin/AppManager"
|
||||
#define KYLIN_APP_MANAGER_INTERFACE "com.kylin.AppManager"
|
||||
|
||||
const QString WIRELESS_SWITCH = "wirelessswitch";
|
||||
const QByteArray GSETTINGS_SCHEMA = "org.ukui.kylin-nm.switch";
|
||||
|
||||
|
@ -137,7 +141,7 @@ WlanConnect::WlanConnect() : m_firstLoad(true) {
|
|||
translator->load("/usr/share/kylin-nm/wlanconnect/" + QLocale::system().name());
|
||||
QApplication::installTranslator(translator);
|
||||
|
||||
pluginName = tr("WlanConnect");
|
||||
pluginName = tr("WLAN");
|
||||
pluginType = NETWORK;
|
||||
}
|
||||
|
||||
|
@ -148,7 +152,6 @@ WlanConnect::~WlanConnect()
|
|||
ui = nullptr;
|
||||
}
|
||||
delete m_interface;
|
||||
delete m_switchGsettings;
|
||||
}
|
||||
|
||||
QString WlanConnect::plugini18nName() {
|
||||
|
@ -174,6 +177,7 @@ QWidget *WlanConnect::pluginUi() {
|
|||
if(!m_interface->isValid()) {
|
||||
qWarning() << qPrintable(QDBusConnection::sessionBus().lastError().message());
|
||||
}
|
||||
initSearchText();
|
||||
initComponent();
|
||||
}
|
||||
return pluginWidget;
|
||||
|
@ -224,10 +228,12 @@ bool WlanConnect::eventFilter(QObject *w, QEvent *e) {
|
|||
|
||||
if (w == m_wifiSwitch) {
|
||||
if (e->type() == QMouseEvent::MouseButtonRelease) {
|
||||
if (!m_wifiSwitch->isCheckable()) {
|
||||
if (!getSwitchBtnEnable()) {
|
||||
showDesktopNotify(tr("No wireless network card detected"));
|
||||
} else {
|
||||
m_interface->call(QStringLiteral("setWirelessSwitchEnable"), !m_wifiSwitch->isChecked());
|
||||
if (m_interface != nullptr && m_interface->isValid()) {
|
||||
m_interface->call(QStringLiteral("setWirelessSwitchEnable"), !getSwitchBtnState());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -239,40 +245,27 @@ 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);
|
||||
|
||||
//开关
|
||||
if (QGSettings::isSchemaInstalled(GSETTINGS_SCHEMA)) {
|
||||
m_switchGsettings = new QGSettings(GSETTINGS_SCHEMA);
|
||||
|
||||
setSwitchStatus();
|
||||
|
||||
connect(m_switchGsettings, &QGSettings::changed, this, [=] (const QString &key) {
|
||||
if (key == WIRELESS_SWITCH) {
|
||||
setSwitchStatus();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
m_wifiSwitch->blockSignals(true);
|
||||
m_wifiSwitch->setChecked(true);
|
||||
m_wifiSwitch->blockSignals(false);
|
||||
qDebug()<<"[netconnect] org.ukui.kylin-nm.switch is not installed!";
|
||||
}
|
||||
initSwtichState();
|
||||
|
||||
//获取设备列表
|
||||
getDeviceList(deviceList);
|
||||
if (deviceList.isEmpty()) {
|
||||
qDebug() << "[WlanConnect]no device exist when init, set switch disable";
|
||||
m_wifiSwitch->setCheckable(false);
|
||||
m_wifiSwitch->setChecked(false);
|
||||
setSwitchBtnState(false);
|
||||
setSwitchBtnEnable(false);
|
||||
}
|
||||
initNet();
|
||||
|
||||
if (!m_wifiSwitch->isChecked() || deviceList.isEmpty() || !m_interface->isValid()) {
|
||||
if (!getSwitchBtnState() || deviceList.isEmpty() || !m_interface->isValid()) {
|
||||
hideLayout(ui->availableLayout);
|
||||
}
|
||||
|
||||
|
@ -288,7 +281,7 @@ void WlanConnect::initComponent() {
|
|||
// connect(m_interface, SIGNAL(signalStrengthChange(QString, QString, int)), this, SLOT(updateStrengthList(QString, QString, int)));
|
||||
//网卡name处理
|
||||
connect(m_interface, SIGNAL(deviceNameChanged(QString, QString, int)), this, SLOT(onDeviceNameChanged(QString, QString, int)), Qt::QueuedConnection);
|
||||
|
||||
connect(m_interface, SIGNAL(wirelessSwitchBtnChanged(bool)), this, SLOT(onSwitchBtnChanged(bool)), Qt::QueuedConnection);
|
||||
connect(m_interface, SIGNAL(timeToUpdate()), this, SLOT(updateList()), Qt::QueuedConnection);
|
||||
//高级设置
|
||||
connect(ui->detailBtn, &QPushButton::clicked, this, [=](bool checked) {
|
||||
|
@ -310,7 +303,7 @@ void WlanConnect::initComponent() {
|
|||
void WlanConnect::reScan()
|
||||
{
|
||||
qDebug() << "time to rescan wifi";
|
||||
if (m_interface->isValid()) {
|
||||
if (m_interface != nullptr && m_interface->isValid()) {
|
||||
qDebug() << "[WlanConnect]call reScan" << __LINE__;
|
||||
m_interface->call("reScan");
|
||||
qDebug() << "[WlanConnect]call reScan respond" << __LINE__;
|
||||
|
@ -320,11 +313,11 @@ void WlanConnect::reScan()
|
|||
//更新列表顺序
|
||||
void WlanConnect::updateList()
|
||||
{
|
||||
if (!m_wifiSwitch->isChecked()) {
|
||||
if (!getSwitchBtnState()) {
|
||||
return;
|
||||
}
|
||||
qDebug() << "update list";
|
||||
if(m_interface->isValid()) {
|
||||
if(m_interface != nullptr && m_interface->isValid()) {
|
||||
qDebug() << "[WlanConnect]call getWirelessList" << __LINE__;
|
||||
QDBusMessage result = m_interface->call(QStringLiteral("getWirelessList"));
|
||||
qDebug() << "[WlanConnect]call getWirelessList respond" << __LINE__;
|
||||
|
@ -438,9 +431,9 @@ void WlanConnect::updateIcon(WlanItem *item, QString signalStrength, QString sec
|
|||
iconamePath = wifiIcon(isLock, sign, category);
|
||||
}
|
||||
QIcon searchIcon = QIcon::fromTheme(iconamePath);
|
||||
if (iconamePath != KLanSymbolic && iconamePath != NoNetSymbolic) {
|
||||
item->iconLabel->setProperty("useIconHighlightEffect", 0x10);
|
||||
}
|
||||
// if (iconamePath != KLanSymbolic && iconamePath != NoNetSymbolic) {
|
||||
// item->iconLabel->setProperty("useIconHighlightEffect", 0x10);
|
||||
// }
|
||||
item->iconLabel->setPixmap(searchIcon.pixmap(searchIcon.actualSize(QSize(ICON_SIZE))));
|
||||
qDebug() << "updateIcon" << item->titileLabel->text() << " finish";
|
||||
}
|
||||
|
@ -525,11 +518,17 @@ void WlanConnect::onDeviceStatusChanged()
|
|||
}
|
||||
deviceList = list;
|
||||
if (deviceList.isEmpty()) {
|
||||
m_wifiSwitch->setCheckable(false);
|
||||
m_wifiSwitch->setChecked(false);
|
||||
setSwitchBtnState(false);
|
||||
setSwitchBtnEnable(false);
|
||||
} else {
|
||||
m_wifiSwitch->setCheckable(true);
|
||||
setSwitchStatus();
|
||||
setSwitchBtnEnable(true);
|
||||
initSwtichState();
|
||||
}
|
||||
|
||||
if (!getSwitchBtnState()) {
|
||||
hideLayout(ui->availableLayout);
|
||||
} else {
|
||||
showLayout(ui->availableLayout);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -558,10 +557,24 @@ void WlanConnect::onDeviceNameChanged(QString oldName, QString newName, int type
|
|||
}
|
||||
}
|
||||
|
||||
void WlanConnect::onSwitchBtnChanged(bool state)
|
||||
{
|
||||
if (getSwitchBtnState() == state) {
|
||||
return;
|
||||
}
|
||||
setSwitchBtnEnable(true);
|
||||
setSwitchBtnState(state);
|
||||
if (!getSwitchBtnState()) {
|
||||
hideLayout(ui->availableLayout);
|
||||
} else {
|
||||
showLayout(ui->availableLayout);
|
||||
}
|
||||
}
|
||||
|
||||
//activeconnect status change
|
||||
void WlanConnect::onActiveConnectionChanged(QString deviceName, QString ssid, QString uuid, int status)
|
||||
{
|
||||
if (!m_wifiSwitch->isChecked()) {
|
||||
if (!getSwitchBtnState()) {
|
||||
return;
|
||||
}
|
||||
if (uuid.isEmpty()) {
|
||||
|
@ -623,7 +636,7 @@ void WlanConnect::onActiveConnectionChanged(QString deviceName, QString ssid, QS
|
|||
void WlanConnect::onNetworkAdd(QString deviceName, QStringList wlanInfo)
|
||||
{
|
||||
qDebug()<<"[WlanConnect]onNetworkAdd "<< deviceName << " " << wlanInfo;
|
||||
if(!m_wifiSwitch->isChecked() || deviceName.isEmpty()) {
|
||||
if(!getSwitchBtnState() || deviceName.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -676,7 +689,7 @@ void WlanConnect::onNetworkRemove(QString deviceName, QString wlannName)
|
|||
//获取设备列表=======================================================
|
||||
void WlanConnect::getDeviceList(QStringList &list)
|
||||
{
|
||||
if (!m_interface->isValid()) {
|
||||
if (m_interface == nullptr || !m_interface->isValid()) {
|
||||
return;
|
||||
}
|
||||
qDebug() << "[WlanConnect]call getDeviceListAndEnabled" << __LINE__;
|
||||
|
@ -693,25 +706,23 @@ void WlanConnect::getDeviceList(QStringList &list)
|
|||
list = map.keys();
|
||||
}
|
||||
|
||||
//设置开关
|
||||
void WlanConnect::setSwitchStatus()
|
||||
void WlanConnect::initSwtichState()
|
||||
{
|
||||
// if (deviceList.size() == 0) {
|
||||
// m_wifiSwitch->blockSignals(true);
|
||||
// m_wifiSwitch->setChecked(false);
|
||||
// m_wifiSwitch->blockSignals(false);
|
||||
// return;
|
||||
// }
|
||||
bool status = m_switchGsettings->get(WIRELESS_SWITCH).toBool();
|
||||
qDebug() << "[WlanConnect]setSwitchStatus" << status;
|
||||
m_wifiSwitch->blockSignals(true);
|
||||
m_wifiSwitch->setChecked(status);
|
||||
m_wifiSwitch->blockSignals(false);
|
||||
if (!m_wifiSwitch->isChecked()) {
|
||||
hideLayout(ui->availableLayout);
|
||||
} else {
|
||||
showLayout(ui->availableLayout);
|
||||
if (m_interface == nullptr || !m_interface->isValid()) {
|
||||
return;
|
||||
}
|
||||
|
||||
QDBusMessage result = m_interface->call("getWirelessSwitchBtnState");
|
||||
qDebug() << "[WlanConnect]call getWirelessSwitchBtnState respond" << __LINE__;
|
||||
if(result.type() == QDBusMessage::ErrorMessage)
|
||||
{
|
||||
qWarning() << "[WlanConnect]getWirelessSwitchBtnState error:" << result.errorMessage();
|
||||
return;
|
||||
}
|
||||
|
||||
bool state = result.arguments().at(0).toBool();
|
||||
setSwitchBtnEnable(true);
|
||||
setSwitchBtnState(state);
|
||||
}
|
||||
|
||||
//初始化整体列表和单设备列表
|
||||
|
@ -731,7 +742,7 @@ void WlanConnect::initNet() {
|
|||
void WlanConnect::initNetListFromDevice(QString deviceName)
|
||||
{
|
||||
qDebug() << "[WlanConnect]initNetListFromDevice " << deviceName;
|
||||
if (!m_wifiSwitch->isChecked()) {
|
||||
if (!getSwitchBtnState()) {
|
||||
qDebug() << "[WlanConnect]initNetListFromDevice " << deviceName << " switch off";
|
||||
return;
|
||||
}
|
||||
|
@ -739,7 +750,7 @@ void WlanConnect::initNetListFromDevice(QString deviceName)
|
|||
qDebug() << "[WlanConnect]initNetListFromDevice " << deviceName << " not exist";
|
||||
return;
|
||||
}
|
||||
if (!m_interface->isValid()) {
|
||||
if (m_interface == nullptr || !m_interface->isValid()) {
|
||||
return;
|
||||
}
|
||||
qDebug() << "[WlanConnect]call getWirelessList" << __LINE__;
|
||||
|
@ -777,9 +788,11 @@ void WlanConnect::initNetListFromDevice(QString deviceName)
|
|||
|
||||
//高级设置
|
||||
void WlanConnect::runExternalApp() {
|
||||
if (!LaunchApp("nm-connection-editor.desktop")){
|
||||
QString cmd = "nm-connection-editor";
|
||||
QProcess process(this);
|
||||
process.startDetached(cmd);
|
||||
}
|
||||
}
|
||||
|
||||
//根据信号强度分级+安全性分图标
|
||||
|
@ -872,6 +885,9 @@ void WlanConnect::showLayout(QVBoxLayout * layout) {
|
|||
//获取应该插入哪个位置
|
||||
int WlanConnect::sortWlanNet(QString deviceName, QString name, QString signal)
|
||||
{
|
||||
if (m_interface == nullptr || !m_interface->isValid()) {
|
||||
return 0;
|
||||
}
|
||||
qDebug() << "[WlanConnect]call getWirelessList" << __LINE__;
|
||||
QDBusMessage result = m_interface->call(QStringLiteral("getWirelessList"));
|
||||
qDebug() << "[WlanConnect]call getWirelessList respond" << __LINE__;
|
||||
|
@ -898,7 +914,7 @@ int WlanConnect::sortWlanNet(QString deviceName, QString name, QString signal)
|
|||
}
|
||||
|
||||
void WlanConnect::activeConnect(QString netName, QString deviceName, int type) {
|
||||
if (!m_interface->isValid()) {
|
||||
if (m_interface == nullptr || !m_interface->isValid()) {
|
||||
return;
|
||||
}
|
||||
qDebug() << "[WlanConnect]call activateConnect" << __LINE__;
|
||||
|
@ -907,7 +923,7 @@ void WlanConnect::activeConnect(QString netName, QString deviceName, int type) {
|
|||
}
|
||||
|
||||
void WlanConnect::deActiveConnect(QString netName, QString deviceName, int type) {
|
||||
if (!m_interface->isValid()) {
|
||||
if (m_interface == nullptr || !m_interface->isValid()) {
|
||||
return;
|
||||
}
|
||||
qDebug() << "[WlanConnect]call deActivateConnect" << __LINE__;
|
||||
|
@ -960,7 +976,7 @@ void WlanConnect::addDeviceFrame(QString devName)
|
|||
deviceFrameMap.insert(devName, itemFrame);
|
||||
|
||||
connect(itemFrame->addWlanWidget, &AddNetBtn::clicked, this, [=](){
|
||||
if (m_interface->isValid()) {
|
||||
if (m_interface != nullptr && m_interface->isValid()) {
|
||||
qDebug() << "[NetConnect]call showAddOtherWlanWidget" << devName << __LINE__;
|
||||
m_interface->call(QStringLiteral("showAddOtherWlanWidget"), devName);
|
||||
qDebug() << "[NetConnect]call setDeviceEnable Respond" << __LINE__;
|
||||
|
@ -1012,9 +1028,9 @@ void WlanConnect::addOneWlanFrame(ItemFrame *frame, QString deviceName, QString
|
|||
} else {
|
||||
iconamePath = wifiIcon(isLock, sign, category);
|
||||
}
|
||||
if (iconamePath != KLanSymbolic && iconamePath != NoNetSymbolic) {
|
||||
wlanItem->iconLabel->setProperty("useIconHighlightEffect", 0x10);
|
||||
}
|
||||
// if (iconamePath != KLanSymbolic && iconamePath != NoNetSymbolic) {
|
||||
// wlanItem->iconLabel->setProperty("useIconHighlightEffect", 0x10);
|
||||
// }
|
||||
QIcon searchIcon = QIcon::fromTheme(iconamePath);
|
||||
wlanItem->iconLabel->setPixmap(searchIcon.pixmap(searchIcon.actualSize(QSize(ICON_SIZE))));
|
||||
wlanItem->titileLabel->setText(name);
|
||||
|
@ -1026,9 +1042,9 @@ void WlanConnect::addOneWlanFrame(ItemFrame *frame, QString deviceName, QString
|
|||
wlanItem->statusLabel->setText("");
|
||||
}
|
||||
|
||||
connect(wlanItem->infoLabel, &InfoButton::clicked, this, [=]{
|
||||
connect(wlanItem->infoLabel, &GrayInfoButton::clicked, this, [=]{
|
||||
// open detail page
|
||||
if (!m_interface->isValid()) {
|
||||
if (m_interface == nullptr || !m_interface->isValid()) {
|
||||
return;
|
||||
}
|
||||
qDebug() << "[WlanConnect]call showPropertyWidget" << __LINE__;
|
||||
|
@ -1094,3 +1110,18 @@ void WlanConnect::itemActiveConnectionStatusChanged(WlanItem *item, int status)
|
|||
}
|
||||
}
|
||||
|
||||
bool WlanConnect::LaunchApp(QString desktopFile)
|
||||
{
|
||||
QDBusInterface m_appManagerDbusInterface(KYLIN_APP_MANAGER_NAME,
|
||||
KYLIN_APP_MANAGER_PATH,
|
||||
KYLIN_APP_MANAGER_INTERFACE,
|
||||
QDBusConnection::sessionBus());//局部变量
|
||||
|
||||
if (!m_appManagerDbusInterface.isValid()) {
|
||||
qWarning()<<"m_appManagerDbusInterface init error";
|
||||
return false;
|
||||
} else {
|
||||
QDBusReply<bool> reply =m_appManagerDbusInterface.call("LaunchApp",desktopFile);
|
||||
return reply;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -98,7 +98,6 @@ private:
|
|||
|
||||
|
||||
//开关相关
|
||||
void setSwitchStatus();
|
||||
void hideLayout(QVBoxLayout * layout);
|
||||
void showLayout(QVBoxLayout * layout);
|
||||
|
||||
|
@ -124,6 +123,33 @@ private:
|
|||
|
||||
//单个wifi连接状态变化
|
||||
void itemActiveConnectionStatusChanged(WlanItem *item, int status);
|
||||
|
||||
void initSwtichState();
|
||||
inline void setSwitchBtnEnable(bool state) {
|
||||
if (m_wifiSwitch != nullptr) {
|
||||
m_wifiSwitch->setEnabled(state);
|
||||
}
|
||||
}
|
||||
inline bool getSwitchBtnEnable() {
|
||||
if (m_wifiSwitch != nullptr) {
|
||||
return m_wifiSwitch->isEnabled();
|
||||
}
|
||||
}
|
||||
|
||||
inline void setSwitchBtnState(bool state) {
|
||||
if (m_wifiSwitch != nullptr) {
|
||||
m_wifiSwitch->blockSignals(true);
|
||||
m_wifiSwitch->setChecked(state);
|
||||
m_wifiSwitch->blockSignals(false);
|
||||
}
|
||||
}
|
||||
inline bool getSwitchBtnState() {
|
||||
if (m_wifiSwitch != nullptr) {
|
||||
return m_wifiSwitch->isChecked();
|
||||
}
|
||||
}
|
||||
|
||||
bool LaunchApp(QString desktopFile);
|
||||
protected:
|
||||
bool eventFilter(QObject *w,QEvent *e);
|
||||
|
||||
|
@ -136,8 +162,6 @@ private:
|
|||
|
||||
QDBusInterface *m_interface = nullptr;
|
||||
|
||||
QGSettings *m_switchGsettings = nullptr;
|
||||
|
||||
//设备列表
|
||||
QStringList deviceList;
|
||||
//设备名 + 单设备frame
|
||||
|
@ -162,6 +186,8 @@ private slots:
|
|||
void onDeviceStatusChanged();
|
||||
void onDeviceNameChanged(QString, QString, int);
|
||||
|
||||
void onSwitchBtnChanged(bool);
|
||||
|
||||
void reScan();
|
||||
|
||||
|
||||
|
|
|
@ -50,4 +50,6 @@ INSTALLS += target \
|
|||
TRANSLATIONS += \
|
||||
translations/zh_CN.ts \
|
||||
translations/tr.ts \
|
||||
translations/bo.ts
|
||||
translations/bo.ts \
|
||||
translations/bo_CN.ts \
|
||||
translations/en_US.ts
|
||||
|
|
|
@ -1,6 +1,26 @@
|
|||
/* -*- 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 "wlanitem.h"
|
||||
#include <QPainter>
|
||||
#include <QPainterPath>
|
||||
#include <QApplication>
|
||||
#define FRAME_SPEED 150
|
||||
#define LIMIT_TIME 60*1000
|
||||
#define TOTAL_PAGE 8
|
||||
|
@ -15,15 +35,18 @@ WlanItem::WlanItem(bool bAcitve, bool isLock, QWidget *parent)
|
|||
this->setMinimumSize(550, 58);
|
||||
this->setProperty("useButtonPalette", true);
|
||||
this->setFlat(true);
|
||||
|
||||
QHBoxLayout *mLanLyt = new QHBoxLayout(this);
|
||||
mLanLyt->setContentsMargins(16,0,16,0);
|
||||
mLanLyt->setSpacing(16);
|
||||
iconLabel = new QLabel(this);
|
||||
iconLabel->setProperty("useIconHighlightEffect", 0x2);
|
||||
titileLabel = new FixLabel(this);
|
||||
statusLabel = new QLabel(this);
|
||||
statusLabel->setProperty("useIconHighlightEffect", 0x2);
|
||||
statusLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
|
||||
// statusLabel->setMinimumSize(36,36);
|
||||
infoLabel = new InfoButton(this);
|
||||
infoLabel = new GrayInfoButton(this);
|
||||
mLanLyt->addWidget(iconLabel);
|
||||
mLanLyt->addWidget(titileLabel,Qt::AlignLeft);
|
||||
mLanLyt->addStretch();
|
||||
|
@ -40,7 +63,6 @@ WlanItem::WlanItem(bool bAcitve, bool isLock, QWidget *parent)
|
|||
|
||||
waitTimer = new QTimer(this);
|
||||
connect(waitTimer, &QTimer::timeout, this, &WlanItem::updateIcon);
|
||||
|
||||
}
|
||||
|
||||
WlanItem::~WlanItem()
|
||||
|
@ -70,12 +92,17 @@ void WlanItem::stopLoading(){
|
|||
|
||||
void WlanItem::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
QPalette pal = this->palette();
|
||||
QPalette pal = qApp->palette();
|
||||
|
||||
QPainter painter(this);
|
||||
painter.setRenderHint(QPainter:: Antialiasing, true); //设置渲染,启动反锯齿
|
||||
painter.setPen(Qt::NoPen);
|
||||
painter.setBrush(pal.color(QPalette::Base));
|
||||
painter.setBrush(this->palette().base().color());
|
||||
|
||||
QColor color = pal.color(QPalette::Button);
|
||||
color.setAlphaF(0.5);
|
||||
pal.setColor(QPalette::Button, color);
|
||||
this->setPalette(pal);
|
||||
|
||||
QRect rect = this->rect();
|
||||
|
||||
|
|
|
@ -1,3 +1,22 @@
|
|||
/* -*- 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 WLANITEM_H
|
||||
#define WLANITEM_H
|
||||
#include <QWidget>
|
||||
|
@ -10,7 +29,8 @@
|
|||
#include <QGSettings>
|
||||
#include <QImage>
|
||||
#include "fixlabel.h"
|
||||
#include "infobutton.h"
|
||||
//#include "infobutton.h"
|
||||
#include "../component/AddBtn/grayinfobutton.h"
|
||||
|
||||
class WlanItem : public QPushButton
|
||||
{
|
||||
|
@ -19,7 +39,7 @@ public:
|
|||
~WlanItem();
|
||||
public:
|
||||
QLabel * iconLabel = nullptr;
|
||||
InfoButton * infoLabel = nullptr;
|
||||
GrayInfoButton * infoLabel = nullptr;
|
||||
FixLabel * titileLabel = nullptr;
|
||||
QLabel * statusLabel = nullptr;
|
||||
QString uuid = "";
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
INCLUDEPATH += $$PWD
|
||||
include(../../src/backend/dbus-interface/dbus-interface.pri)
|
||||
|
||||
HEADERS += \
|
||||
$$PWD/vpndbusadaptor.h
|
||||
|
||||
SOURCES += \
|
||||
$$PWD/vpndbusadaptor.cpp
|
||||
|
||||
DISTFILES +=
|
|
@ -0,0 +1,78 @@
|
|||
/*
|
||||
* This file was generated by qdbusxml2cpp version 0.8
|
||||
* Command line was: qdbusxml2cpp com.kylin.weather.xml -a VpnDbusAdaptor -c VpnDbusAdaptor -l MainWindow
|
||||
*
|
||||
* qdbusxml2cpp is Copyright (C) 2015 The Qt Company Ltd.
|
||||
*
|
||||
* This is an auto-generated file.
|
||||
* Do not edit! All changes made to it will be lost.
|
||||
*/
|
||||
|
||||
#include "vpndbusadaptor.h"
|
||||
#include <QtCore/QMetaObject>
|
||||
#include <QtCore/QByteArray>
|
||||
#include <QtCore/QList>
|
||||
#include <QtCore/QMap>
|
||||
#include <QtCore/QString>
|
||||
#include <QtCore/QStringList>
|
||||
#include <QtCore/QVariant>
|
||||
|
||||
/*
|
||||
* Implementation of adaptor class VpnDbusAdaptor
|
||||
*/
|
||||
|
||||
VpnDbusAdaptor::VpnDbusAdaptor(vpnObject *parent)
|
||||
: QDBusAbstractAdaptor(parent)
|
||||
{
|
||||
qDBusRegisterMetaType<QMap<QString, bool> >();
|
||||
qDBusRegisterMetaType<QMap<QString, int> >();
|
||||
qDBusRegisterMetaType<QVector<QStringList> >();
|
||||
setAutoRelaySignals(true);
|
||||
}
|
||||
|
||||
//虚拟连接列表
|
||||
QVector<QStringList> VpnDbusAdaptor::getVirtualList()
|
||||
{
|
||||
QVector<QStringList> vector;
|
||||
parent()->getVirtualList(vector);
|
||||
return vector;
|
||||
}
|
||||
|
||||
//删除
|
||||
void VpnDbusAdaptor::deleteVpn(QString uuid)
|
||||
{
|
||||
qDebug() << "delete vpn" << uuid;
|
||||
parent()->deleteVpn(uuid);
|
||||
}
|
||||
|
||||
//连接 根据网卡类型 参数1 0:lan 1:wlan 参数3 为ssid/uuid
|
||||
void VpnDbusAdaptor::activateVpn(const QString& connUuid)
|
||||
{
|
||||
qDebug() << "activate vpn" << connUuid;
|
||||
parent()->activateVpn(connUuid);
|
||||
}
|
||||
|
||||
//断开连接 根据网卡类型 参数1 0:lan 1:wlan 参数3 为ssid/uuid
|
||||
void VpnDbusAdaptor::deactivateVpn(const QString& connUuid)
|
||||
{
|
||||
qDebug() << "deactivate vpn" << connUuid;
|
||||
parent()->deactivateVpn(connUuid);
|
||||
}
|
||||
|
||||
void VpnDbusAdaptor::showKylinVpn()
|
||||
{
|
||||
parent()->onShowMainWindow();
|
||||
}
|
||||
|
||||
void VpnDbusAdaptor::showVpnAddWidget()
|
||||
{
|
||||
qDebug() << "showVpnAddWidget";
|
||||
parent()->showVpnAddWidget();
|
||||
}
|
||||
|
||||
void VpnDbusAdaptor::showDetailPage(const QString& connUuid)
|
||||
{
|
||||
qDebug() << "showDetailPage vpn" << connUuid;
|
||||
parent()->showDetailPage(connUuid);
|
||||
}
|
||||
|
|
@ -0,0 +1,64 @@
|
|||
/*
|
||||
* This file was generated by qdbusxml2cpp version 0.8
|
||||
* Command line was: qdbusxml2cpp com.kylin.weather.xml -a dbusadaptor -c DbusAdaptor -l MainWindow
|
||||
*
|
||||
* qdbusxml2cpp is Copyright (C) 2015 The Qt Company Ltd.
|
||||
*
|
||||
* This is an auto-generated file.
|
||||
* This file may have been hand-edited. Look for HAND-EDIT comments
|
||||
* before re-generating it.
|
||||
*/
|
||||
|
||||
#ifndef VPNDBUSADAPTOR_H
|
||||
#define VPNDBUSADAPTOR_H
|
||||
|
||||
#include <QtCore/QObject>
|
||||
#include <QtDBus/QtDBus>
|
||||
#include <QtDBus/QDBusMetaType>
|
||||
|
||||
#include "singlepage.h"
|
||||
#include "kylinnetworkdeviceresource.h"
|
||||
#include "kyvpnconnectoperation.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QByteArray;
|
||||
template<class Key, class Value> class QMap;
|
||||
class QString;
|
||||
class QStringList;
|
||||
class QVariant;
|
||||
template<class T> class QVector;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#include "vpnobject.h"
|
||||
|
||||
class VpnDbusAdaptor: public QDBusAbstractAdaptor
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_CLASSINFO("D-Bus Interface", "com.kylin.kylinvpn")
|
||||
public:
|
||||
VpnDbusAdaptor(vpnObject *parent);
|
||||
|
||||
inline vpnObject *parent() const
|
||||
{ return static_cast<vpnObject *>(QObject::parent()); }
|
||||
|
||||
public Q_SLOTS:
|
||||
QVector<QStringList> getVirtualList();
|
||||
Q_NOREPLY void deleteVpn(QString uuid);
|
||||
Q_NOREPLY void activateVpn(const QString& connUuid);
|
||||
Q_NOREPLY void deactivateVpn(const QString& connUuid);
|
||||
Q_NOREPLY void showVpnAddWidget();
|
||||
Q_NOREPLY void showDetailPage(const QString& connUuid);
|
||||
|
||||
void showKylinVpn();
|
||||
|
||||
Q_SIGNALS:
|
||||
void vpnAdd(QStringList info);
|
||||
void vpnRemove(QString dbusPath);
|
||||
void vpnUpdate(QStringList info);
|
||||
void vpnActiveConnectionStateChanged(QString uuid, int status);
|
||||
|
||||
void activateFailed(QString errorMessage);
|
||||
void deactivateFailed(QString errorMessage);
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,11 @@
|
|||
INCLUDEPATH += $$PWD
|
||||
include(../../src/frontend/tools/tools.pri)
|
||||
include(list-items/list-items.pri)
|
||||
include(vpndetails/vpndetails.pri)
|
||||
include(single-pages/single-pages.pri)
|
||||
|
||||
HEADERS += \
|
||||
$$PWD/vpnobject.h
|
||||
|
||||
SOURCES += \
|
||||
$$PWD/vpnobject.cpp
|
|
@ -0,0 +1,10 @@
|
|||
INCLUDEPATH += $$PWD
|
||||
|
||||
HEADERS += \
|
||||
$$PWD/listitem.h \
|
||||
$$PWD/vpnlistitem.h
|
||||
|
||||
SOURCES += \
|
||||
$$PWD/listitem.cpp \
|
||||
$$PWD/vpnlistitem.cpp
|
||||
|
|
@ -0,0 +1,151 @@
|
|||
/* -*- 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 "listitem.h"
|
||||
#include <QDebug>
|
||||
|
||||
#define MAIN_LAYOUT_MARGINS 0,0,0,0
|
||||
#define MAIN_LAYOUT_SPACING 0
|
||||
#define ITEM_FRAME_MARGINS 12,6,16,6
|
||||
|
||||
#define ITEM_FRAME_SPACING 8
|
||||
#define FRAME_WIDTH 404
|
||||
#define INFO_ICON_WIDTH 16
|
||||
#define INFO_ICON_HEIGHT 16
|
||||
#define LIGHT_HOVER_COLOR QColor(240,240,240,255)
|
||||
#define DARK_HOVER_COLOR QColor(15,15,15,255)
|
||||
|
||||
ListItem::ListItem(QWidget *parent) : QFrame(parent)
|
||||
{
|
||||
m_connectState = UnknownState;
|
||||
|
||||
initUI();
|
||||
initConnection();
|
||||
connect(qApp, &QApplication::paletteChanged, this, &ListItem::onPaletteChanged);
|
||||
// m_itemFrame->installEventFilter(this);
|
||||
}
|
||||
|
||||
ListItem::~ListItem()
|
||||
{
|
||||
if (nullptr != m_netButton) {
|
||||
delete m_netButton;
|
||||
m_netButton = nullptr;
|
||||
}
|
||||
|
||||
if (nullptr != m_infoButton) {
|
||||
delete m_infoButton;
|
||||
m_infoButton = nullptr;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void ListItem::setName(const QString &name)
|
||||
{
|
||||
m_nameLabel->setText(name);
|
||||
}
|
||||
|
||||
//仅无线调用,有线自己获取
|
||||
void ListItem::setActive(const bool &isActive)
|
||||
{
|
||||
m_netButton->setActive(isActive);
|
||||
m_isActive = isActive;
|
||||
}
|
||||
|
||||
void ListItem::setConnectState(ConnectState state)
|
||||
{
|
||||
m_connectState = state;
|
||||
}
|
||||
|
||||
void ListItem::mousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
qDebug()<<"[ListItem]"<<"mousePressEvent";
|
||||
if (event->button() == Qt::LeftButton) {
|
||||
onNetButtonClicked();
|
||||
} else if (event->button() == Qt::RightButton) {
|
||||
onRightButtonClicked();
|
||||
}
|
||||
return QFrame::mousePressEvent(event);
|
||||
}
|
||||
|
||||
void ListItem::enterEvent(QEvent *event)
|
||||
{
|
||||
}
|
||||
|
||||
void ListItem::leaveEvent(QEvent *event)
|
||||
{
|
||||
}
|
||||
|
||||
void ListItem::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
}
|
||||
|
||||
void ListItem::initUI()
|
||||
{
|
||||
m_menu = new QMenu(this);//右键菜单
|
||||
// m_menu->setStyleSheet("QMenu::item{border:3px; border-radius:3px}");
|
||||
// m_menu->setStyleSheet("QMenu{border-radius:6px; margin:6px 6px 6px 6px}");
|
||||
connect(m_menu, &QMenu::triggered, this, &ListItem::onMenuTriggered);
|
||||
|
||||
m_mainLayout = new QVBoxLayout(this);
|
||||
m_mainLayout->setContentsMargins(MAIN_LAYOUT_MARGINS);
|
||||
m_mainLayout->setSpacing(MAIN_LAYOUT_SPACING);
|
||||
this->setLayout(m_mainLayout);
|
||||
|
||||
m_itemFrame = new QFrame(this);
|
||||
m_itemFrame->setFixedWidth(FRAME_WIDTH);
|
||||
|
||||
m_hItemLayout = new QHBoxLayout(m_itemFrame);
|
||||
m_hItemLayout->setContentsMargins(ITEM_FRAME_MARGINS);
|
||||
m_hItemLayout->setSpacing(ITEM_FRAME_SPACING);
|
||||
m_hItemLayout->setAlignment(Qt::AlignHCenter);
|
||||
|
||||
m_netButton = new RadioItemButton(m_itemFrame);
|
||||
m_nameLabel = new QLabel(m_itemFrame);
|
||||
m_nameLabel->setMinimumWidth(262);
|
||||
m_infoButton = new InfoButton(m_itemFrame);
|
||||
m_infoButton->setIconSize(QSize(INFO_ICON_WIDTH,INFO_ICON_HEIGHT));
|
||||
|
||||
m_hItemLayout->addWidget(m_netButton);
|
||||
m_hItemLayout->addWidget(m_nameLabel);
|
||||
m_hItemLayout->addStretch();
|
||||
m_hItemLayout->addWidget(m_infoButton);
|
||||
|
||||
m_mainLayout->addWidget(m_itemFrame);
|
||||
|
||||
// this->setAutoFillBackground(true);
|
||||
// this->setBackgroundRole(QPalette::Base);
|
||||
// QPalette pal = qApp->palette();
|
||||
// pal.setColor(QPalette::Window, qApp->palette().base().color());
|
||||
// this->setPalette(pal);
|
||||
}
|
||||
|
||||
|
||||
void ListItem::initConnection()
|
||||
{
|
||||
connect(this->m_netButton, &RadioItemButton::clicked, this, &ListItem::onNetButtonClicked);
|
||||
// connect(this->m_infoButton, &InfoButton::clicked, this, &ListItem::onInfoButtonClicked);
|
||||
}
|
||||
|
||||
void ListItem::onPaletteChanged()
|
||||
{
|
||||
// QPalette pal = qApp->palette();
|
||||
// pal.setColor(QPalette::Window, qApp->palette().base().color());
|
||||
// this->setPalette(pal);
|
||||
}
|
||||
|
|
@ -0,0 +1,87 @@
|
|||
/* -*- 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 LISTITEM_H
|
||||
#define LISTITEM_H
|
||||
#include <QFrame>
|
||||
#include <QEvent>
|
||||
#include <QHBoxLayout>
|
||||
#include <QDebug>
|
||||
#include <QMouseEvent>
|
||||
#include <QMenu>
|
||||
#include <QApplication>
|
||||
#include "radioitembutton.h"
|
||||
#include "infobutton.h"
|
||||
|
||||
|
||||
typedef enum{
|
||||
UnknownState = 0, /**< The active connection is in an unknown state */
|
||||
Activating, /**< The connection is activating */
|
||||
Activated, /**< The connection is activated */
|
||||
Deactivating, /**< The connection is being torn down and cleaned up */
|
||||
Deactivated /**< The connection is no longer active */
|
||||
}ConnectState;
|
||||
|
||||
class ListItem : public QFrame
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ListItem(QWidget *parent = nullptr);
|
||||
~ListItem();
|
||||
void setName(const QString &name);
|
||||
void setActive(const bool &isActive);
|
||||
void setConnectState(ConnectState state);
|
||||
static void showDesktopNotify(const QString &message, QString soundName);
|
||||
|
||||
protected:
|
||||
void mousePressEvent(QMouseEvent *event);
|
||||
void enterEvent(QEvent *event);
|
||||
void leaveEvent(QEvent *event);
|
||||
void paintEvent(QPaintEvent *event);
|
||||
virtual void onRightButtonClicked() = 0;
|
||||
|
||||
protected:
|
||||
QFrame * m_itemFrame = nullptr;
|
||||
|
||||
QLabel * m_nameLabel = nullptr;
|
||||
RadioItemButton * m_netButton = nullptr;
|
||||
InfoButton * m_infoButton = nullptr;
|
||||
|
||||
bool m_isActive = false;
|
||||
ConnectState m_connectState;
|
||||
|
||||
QMenu *m_menu = nullptr;
|
||||
public:
|
||||
QVBoxLayout * m_mainLayout = nullptr;
|
||||
QHBoxLayout * m_hItemLayout = nullptr;
|
||||
|
||||
private:
|
||||
void initUI();
|
||||
void initConnection();
|
||||
|
||||
public Q_SLOTS:
|
||||
virtual void onNetButtonClicked() = 0;
|
||||
void onPaletteChanged();
|
||||
virtual void onMenuTriggered(QAction *action)=0;
|
||||
|
||||
Q_SIGNALS:
|
||||
void detailShow(bool isShow);
|
||||
};
|
||||
|
||||
#endif // LISTITEM_H
|
|
@ -0,0 +1,249 @@
|
|||
/* -*- 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 "vpnlistitem.h"
|
||||
#include "kylinconnectitem.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
#define LOG_FLAG "[VpnListItem]"
|
||||
|
||||
VpnListItem::VpnListItem(const KyConnectItem *vpnConnectItem, QWidget *parent):ListItem(parent)
|
||||
{
|
||||
m_connectOperation = new KyVpnConnectOperation(this);
|
||||
m_deviceResource = new KyNetworkDeviceResourse(this);
|
||||
|
||||
connectItemCopy(vpnConnectItem);
|
||||
|
||||
m_nameLabel->setText(m_vpnConnectItem.m_connectName);
|
||||
m_netButton->setButtonIcon(QIcon::fromTheme("ukui-vpn-symbolic"));
|
||||
|
||||
qDebug() << "VpnListItem init:" << m_vpnConnectItem.m_connectName << m_vpnConnectItem.m_connectState << m_vpnConnectItem.m_ifaceName;
|
||||
|
||||
if (Deactivated == m_vpnConnectItem.m_connectState || Activated == m_vpnConnectItem.m_connectState) {
|
||||
m_netButton->stopLoading();
|
||||
if (m_vpnConnectItem.m_connectState == Activated) {
|
||||
setIcon(true);
|
||||
} else {
|
||||
setIcon(false);
|
||||
}
|
||||
} else {
|
||||
m_netButton->startLoading();
|
||||
}
|
||||
|
||||
m_itemFrame->installEventFilter(this);
|
||||
connect(this->m_infoButton, &InfoButton::clicked, this, &VpnListItem::onInfoButtonClicked);
|
||||
connect(m_menu, &QMenu::triggered, this, &VpnListItem::onMenuTriggered);
|
||||
}
|
||||
|
||||
|
||||
VpnListItem::VpnListItem(QWidget *parent) : ListItem(parent)
|
||||
{
|
||||
m_isActive = false;
|
||||
m_netButton->setButtonIcon(QIcon::fromTheme("ukui-vpn-symbolic"));
|
||||
setIcon(false);
|
||||
const QString str=tr("Not connected");
|
||||
m_nameLabel->setText(str);
|
||||
this->m_infoButton->hide();
|
||||
}
|
||||
|
||||
VpnListItem::~VpnListItem()
|
||||
{
|
||||
qDebug()<<"[LanPage] lan list item is deleted." << m_vpnConnectItem.m_connectName;
|
||||
}
|
||||
|
||||
void VpnListItem::setIcon(bool isOn)
|
||||
{
|
||||
if (isOn) {
|
||||
m_netButton->setActive(true); //设置图标显示不同颜色
|
||||
} else {
|
||||
m_netButton->setActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
void VpnListItem::connectItemCopy(const KyConnectItem *vpnConnectItem)
|
||||
{
|
||||
if (vpnConnectItem) {
|
||||
m_vpnConnectItem.m_connectName = vpnConnectItem->m_connectName;
|
||||
m_vpnConnectItem.m_connectPath = vpnConnectItem->m_connectPath;
|
||||
m_vpnConnectItem.m_connectState = vpnConnectItem->m_connectState;
|
||||
m_vpnConnectItem.m_connectUuid = vpnConnectItem->m_connectUuid;
|
||||
m_vpnConnectItem.m_ifaceName = vpnConnectItem->m_ifaceName;
|
||||
m_vpnConnectItem.m_itemType = vpnConnectItem->m_itemType;
|
||||
} else {
|
||||
qDebug() << LOG_FLAG <<"the connect item is nullptr";
|
||||
m_vpnConnectItem.m_connectName = "";
|
||||
m_vpnConnectItem.m_connectPath = "";
|
||||
m_vpnConnectItem.m_connectState = NetworkManager::ActiveConnection::State::Unknown;
|
||||
m_vpnConnectItem.m_connectUuid = "";
|
||||
m_vpnConnectItem.m_ifaceName = "";
|
||||
m_vpnConnectItem.m_itemType = NetworkManager::ConnectionSettings::ConnectionType::Unknown;
|
||||
}
|
||||
}
|
||||
|
||||
void VpnListItem::activeConnection()
|
||||
{
|
||||
if (m_vpnConnectItem.m_connectUuid.isEmpty()) {
|
||||
qDebug() << LOG_FLAG << "connect is empty, so can not connect or disconnect.";
|
||||
return;
|
||||
}
|
||||
|
||||
if (Deactivated == m_vpnConnectItem.m_connectState) {
|
||||
//断开的连接,点击激活连接
|
||||
m_connectOperation->activateVpnConnection(m_vpnConnectItem.m_connectUuid);
|
||||
qDebug() << LOG_FLAG << "it will activate connection" << m_vpnConnectItem.m_connectName;
|
||||
m_netButton->startLoading();
|
||||
} else {
|
||||
qDebug() << LOG_FLAG <<"the connection" << m_vpnConnectItem.m_connectName
|
||||
<< "is not deactived, so it can not be operation.";
|
||||
}
|
||||
}
|
||||
|
||||
void VpnListItem::onNetButtonClicked()
|
||||
{
|
||||
if (m_vpnConnectItem.m_connectUuid.isEmpty()) {
|
||||
qDebug() << LOG_FLAG << "connect is empty, so can not connect or disconnect.";
|
||||
return;
|
||||
}
|
||||
|
||||
if (Deactivated == m_vpnConnectItem.m_connectState) {
|
||||
//断开的连接,点击激活连接
|
||||
m_connectOperation->activateVpnConnection(m_vpnConnectItem.m_connectUuid);
|
||||
qDebug() << LOG_FLAG << "it will activate connection" << m_vpnConnectItem.m_connectName;
|
||||
m_netButton->startLoading();
|
||||
} else {
|
||||
qDebug() << LOG_FLAG <<"the connection" << m_vpnConnectItem.m_connectName
|
||||
<< "is not deactived, so it can not be operation.";
|
||||
}
|
||||
}
|
||||
|
||||
void VpnListItem::onRightButtonClicked()
|
||||
{
|
||||
//右键点击事件
|
||||
qDebug()<< LOG_FLAG <<"onRightButtonClicked";
|
||||
if (!m_menu) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_menu->clear();
|
||||
if (Activated == m_vpnConnectItem.m_connectState || Activating == m_vpnConnectItem.m_connectState) {
|
||||
m_menu->addAction(new QAction(tr("Disconnect"), this));
|
||||
} else if (Deactivated == m_vpnConnectItem.m_connectState) {
|
||||
m_menu->addAction(new QAction(tr("Connect"), this));
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
m_menu->move(cursor().pos());
|
||||
m_menu->show();
|
||||
}
|
||||
|
||||
void VpnListItem::onMenuTriggered(QAction *action)
|
||||
{
|
||||
if (action->text() == tr("Connect")) {
|
||||
this->onNetButtonClicked();
|
||||
} else if (action->text() == tr("Disconnect")) {
|
||||
m_connectOperation->deactivateVpnConnection(m_vpnConnectItem.m_connectName, m_vpnConnectItem.m_connectUuid);
|
||||
qDebug() << LOG_FLAG << "it will disconnect connection" << m_vpnConnectItem.m_connectName;
|
||||
m_netButton->startLoading();
|
||||
}
|
||||
}
|
||||
|
||||
bool VpnListItem::launchApp(QString desktopFile)
|
||||
{
|
||||
QDBusInterface appManagerDbusInterface(KYLIN_APP_MANAGER_NAME,
|
||||
KYLIN_APP_MANAGER_PATH,
|
||||
KYLIN_APP_MANAGER_INTERFACE,
|
||||
QDBusConnection::sessionBus());
|
||||
|
||||
if (!appManagerDbusInterface.isValid()) {
|
||||
qWarning()<<"appManagerDbusInterface init error";
|
||||
return false;
|
||||
} else {
|
||||
QDBusReply<bool> reply = appManagerDbusInterface.call("LaunchApp", desktopFile);
|
||||
return reply;
|
||||
}
|
||||
}
|
||||
|
||||
void VpnListItem::runExternalApp() {
|
||||
if (!launchApp("nm-connection-editor.desktop")){
|
||||
QString cmd = "nm-connection-editor";
|
||||
QProcess process(this);
|
||||
process.startDetached(cmd);
|
||||
}
|
||||
}
|
||||
|
||||
void VpnListItem::onInfoButtonClicked()
|
||||
{
|
||||
if (m_vpnConnectItem.m_itemType != NetworkManager::ConnectionSettings::ConnectionType::Vpn) {
|
||||
runExternalApp();
|
||||
return;
|
||||
}
|
||||
|
||||
if(m_vpnDetail != nullptr){
|
||||
m_vpnDetail->activateWindow();
|
||||
return;
|
||||
}
|
||||
m_vpnDetail = new VpnDetail(m_vpnConnectItem.m_connectUuid, getConnectionName());
|
||||
connect(m_vpnDetail, &VpnDetail::destroyed, [&](){
|
||||
if (m_vpnDetail != nullptr) {
|
||||
m_vpnDetail = nullptr;
|
||||
}
|
||||
});
|
||||
|
||||
m_vpnDetail->show();
|
||||
m_vpnDetail->centerToScreen();
|
||||
}
|
||||
|
||||
void VpnListItem::updateConnectionState(ConnectState state)
|
||||
{
|
||||
m_vpnConnectItem.m_connectState = (NetworkManager::ActiveConnection::State)state;
|
||||
|
||||
if (Deactivated == state || Activated == state) {
|
||||
m_netButton->stopLoading();
|
||||
if (state == Activated) {
|
||||
setIcon(true);
|
||||
} else {
|
||||
setIcon(false);
|
||||
}
|
||||
} else {
|
||||
m_netButton->startLoading();
|
||||
}
|
||||
}
|
||||
|
||||
QString VpnListItem::getConnectionName()
|
||||
{
|
||||
return m_vpnConnectItem.m_connectName;
|
||||
}
|
||||
|
||||
void VpnListItem::updateConnectionName(QString connectionName)
|
||||
{
|
||||
m_vpnConnectItem.m_connectName = connectionName;
|
||||
m_nameLabel->setText(m_vpnConnectItem.m_connectName);
|
||||
}
|
||||
|
||||
QString VpnListItem::getConnectionPath()
|
||||
{
|
||||
return m_vpnConnectItem.m_connectPath;
|
||||
}
|
||||
|
||||
void VpnListItem::updateConnectionPath(QString connectionPath)
|
||||
{
|
||||
m_vpnConnectItem.m_connectPath = connectionPath;
|
||||
}
|
|
@ -0,0 +1,88 @@
|
|||
/* -*- 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 VPNLISTITEM_H
|
||||
#define VPNLISTITEM_H
|
||||
#include "listitem.h"
|
||||
#include "kylinactiveconnectresource.h"
|
||||
|
||||
#include <QDBusInterface>
|
||||
#include <QEvent>
|
||||
#include <QAction>
|
||||
#include <QProcess>
|
||||
|
||||
#include "vpndetails/vpndetail.h"
|
||||
#include "kylinconnectresource.h"
|
||||
//#include "kylinwiredconnectoperation.h"
|
||||
#include "kyvpnconnectoperation.h"
|
||||
|
||||
|
||||
#define KYLIN_APP_MANAGER_NAME "com.kylin.AppManager"
|
||||
#define KYLIN_APP_MANAGER_PATH "/com/kylin/AppManager"
|
||||
#define KYLIN_APP_MANAGER_INTERFACE "com.kylin.AppManager"
|
||||
|
||||
class VpnListItem : public ListItem
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
VpnListItem(const KyConnectItem *vpnConnectItem, QWidget *parent = nullptr);
|
||||
VpnListItem(QWidget *parent = nullptr);
|
||||
|
||||
~VpnListItem();
|
||||
|
||||
public:
|
||||
void updateConnectionState(ConnectState state);
|
||||
|
||||
QString getConnectionName();
|
||||
void updateConnectionName(QString connectionName);
|
||||
|
||||
QString getConnectionPath();
|
||||
void updateConnectionPath(QString connectionPath);
|
||||
|
||||
void activeConnection();
|
||||
|
||||
protected:
|
||||
void setIcon(bool isOn);
|
||||
void onRightButtonClicked();
|
||||
bool launchApp(QString desktopFile);
|
||||
void runExternalApp();
|
||||
|
||||
private:
|
||||
void connectItemCopy(const KyConnectItem *vpnConnectItem);
|
||||
|
||||
public Q_SLOTS:
|
||||
void onInfoButtonClicked();
|
||||
|
||||
private Q_SLOTS:
|
||||
void onNetButtonClicked();
|
||||
void onMenuTriggered(QAction *action);
|
||||
|
||||
private:
|
||||
KyConnectItem m_vpnConnectItem;
|
||||
|
||||
KyVpnConnectOperation *m_connectOperation = nullptr;
|
||||
KyNetworkDeviceResourse *m_deviceResource = nullptr;
|
||||
|
||||
QString m_deviceName = "";
|
||||
|
||||
VpnDetail *m_vpnDetail = nullptr;
|
||||
};
|
||||
|
||||
#endif // VPNLISTITEM_H
|
|
@ -0,0 +1,10 @@
|
|||
INCLUDEPATH += $$PWD
|
||||
|
||||
HEADERS += \
|
||||
$$PWD/vpnpage.h \
|
||||
$$PWD/singlepage.h
|
||||
|
||||
SOURCES += \
|
||||
$$PWD/vpnpage.cpp \
|
||||
$$PWD/singlepage.cpp
|
||||
|
|
@ -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 "singlepage.h"
|
||||
#include <qsettings.h>
|
||||
#include <QDBusInterface>
|
||||
#include <QLabel>
|
||||
#include <QApplication>
|
||||
#include <QDBusReply>
|
||||
|
||||
#include <KWindowEffects>
|
||||
|
||||
SinglePage::SinglePage(QWidget *parent) : QWidget(parent)
|
||||
{
|
||||
initUI();
|
||||
initWindowProperties();
|
||||
initTransparency();
|
||||
}
|
||||
|
||||
SinglePage::~SinglePage()
|
||||
{
|
||||
}
|
||||
|
||||
void SinglePage::initUI()
|
||||
{
|
||||
m_mainLayout = new QVBoxLayout(this);
|
||||
m_mainLayout->setContentsMargins(MAIN_LAYOUT_MARGINS);
|
||||
m_mainLayout->setSpacing(MAIN_LAYOUT_SPACING);
|
||||
this->setLayout(m_mainLayout);
|
||||
|
||||
m_titleFrame = new QFrame(this);
|
||||
m_titleFrame->setFixedHeight(TITLE_FRAME_HEIGHT);
|
||||
m_titleLayout = new QHBoxLayout(m_titleFrame);
|
||||
m_titleLayout->setContentsMargins(TITLE_LAYOUT_MARGINS);
|
||||
m_titleFrame->setLayout(m_titleLayout);
|
||||
m_titleLabel = new QLabel(m_titleFrame);
|
||||
m_titleLayout->addWidget(m_titleLabel);
|
||||
m_titleLayout->addStretch();
|
||||
|
||||
m_netDivider = new Divider(this);
|
||||
|
||||
m_listFrame = new QFrame(this);
|
||||
m_listLayout = new QVBoxLayout(m_listFrame);
|
||||
m_listLayout->setContentsMargins(NET_LAYOUT_MARGINS);
|
||||
m_listFrame->setLayout(m_listLayout);
|
||||
m_listWidget = new QListWidget(m_listFrame);
|
||||
m_listLayout->addWidget(m_listWidget);
|
||||
|
||||
m_setDivider = new Divider(this);
|
||||
|
||||
m_settingsFrame = new QFrame(this);
|
||||
m_settingsFrame->setFixedHeight(TITLE_FRAME_HEIGHT);
|
||||
m_settingsLayout = new QHBoxLayout(m_settingsFrame);
|
||||
m_settingsLayout->setContentsMargins(SETTINGS_LAYOUT_MARGINS);
|
||||
m_settingsLabel = new KyLable(m_settingsFrame);
|
||||
m_settingsLabel->setCursor(Qt::PointingHandCursor);
|
||||
m_settingsLabel->setText(tr("Settings"));
|
||||
m_settingsLabel->setScaledContents(true);
|
||||
m_settingsLayout->addWidget(m_settingsLabel);
|
||||
m_settingsLayout->addStretch();
|
||||
m_settingsFrame->setLayout(m_settingsLayout);
|
||||
|
||||
m_mainLayout->addWidget(m_titleFrame);
|
||||
m_mainLayout->addWidget(m_netDivider);
|
||||
m_mainLayout->addWidget(m_listFrame);
|
||||
m_mainLayout->addWidget(m_setDivider);
|
||||
m_mainLayout->addWidget(m_settingsFrame);
|
||||
}
|
||||
|
||||
void SinglePage::initWindowProperties()
|
||||
{
|
||||
QPalette pal = m_listFrame->palette();
|
||||
pal.setBrush(QPalette::Base, QColor(0,0,0,0)); //背景透明
|
||||
m_listFrame->setPalette(pal);
|
||||
|
||||
this->setFixedWidth(MAX_WIDTH);
|
||||
this->setAttribute(Qt::WA_TranslucentBackground);
|
||||
this->setProperty("useStyleWindowManager", false); //禁用拖动
|
||||
//绘制毛玻璃特效
|
||||
QString platform = QGuiApplication::platformName();
|
||||
if(!platform.startsWith(QLatin1String("wayland"),Qt::CaseInsensitive))
|
||||
{
|
||||
QPainterPath path;
|
||||
auto rect = this->rect();
|
||||
path.addRoundedRect(rect, 12, 12);
|
||||
path.addRect(rect);
|
||||
KWindowEffects::enableBlurBehind(this->winId(), true, QRegion(path.toFillPolygon().toPolygon())); //背景模糊
|
||||
}
|
||||
}
|
||||
|
||||
void SinglePage::showDesktopNotify(const QString &message, QString soundName)
|
||||
{
|
||||
QDBusInterface iface("org.freedesktop.Notifications",
|
||||
"/org/freedesktop/Notifications",
|
||||
"org.freedesktop.Notifications",
|
||||
QDBusConnection::sessionBus());
|
||||
QStringList actions; //跳转动作
|
||||
actions.append("kylin-vpn");
|
||||
actions.append("default"); //默认动作:点击消息体时打开麒麟录音
|
||||
QMap<QString, QVariant> hints;
|
||||
if (!soundName.isEmpty()) {
|
||||
hints.insert("sound-name",soundName); //添加声音
|
||||
}
|
||||
QList<QVariant> args;
|
||||
args<<(tr("Kylin VPN"))
|
||||
<<((unsigned int) 0)
|
||||
<<QString("gnome-dev-ethernet")
|
||||
<<tr("kylin vpn applet desktop message") //显示的是什么类型的信息
|
||||
<<message //显示的具体信息
|
||||
<<actions
|
||||
<<hints
|
||||
<<(int)-1;
|
||||
iface.callWithArgumentList(QDBus::AutoDetect,"Notify",args);
|
||||
}
|
||||
|
||||
void SinglePage::paintEvent(QPaintEvent *event) {
|
||||
Q_UNUSED(event);
|
||||
QPainter painter(this);
|
||||
painter.setRenderHint(QPainter::Antialiasing);
|
||||
painter.setPen(Qt::transparent);
|
||||
QColor col = qApp->palette().window().color();
|
||||
|
||||
QPainterPath rectPath;
|
||||
|
||||
col.setAlphaF(m_transparency);
|
||||
rectPath.addRoundedRect(this->rect(),12,12);
|
||||
|
||||
painter.setBrush(col);
|
||||
painter.drawPath(rectPath);
|
||||
KWindowEffects::enableBlurBehind(this->winId(), true, QRegion(rectPath.toFillPolygon().toPolygon())); //背景模糊
|
||||
}
|
||||
|
||||
void SinglePage::initTransparency()
|
||||
{
|
||||
if(QGSettings::isSchemaInstalled(QByteArray(TRANSPARENCY_GSETTINGS))) {
|
||||
m_transGsettings = new QGSettings(QByteArray(TRANSPARENCY_GSETTINGS));
|
||||
if(m_transGsettings->keys().contains(TRANSPARENCY)) {
|
||||
m_transparency = m_transGsettings->get(TRANSPARENCY).toDouble() + 0.15;
|
||||
m_transparency = (m_transparency > 1) ? 1 : m_transparency;
|
||||
connect(m_transGsettings, &QGSettings::changed, this, &SinglePage::onTransChanged);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SinglePage::onTransChanged()
|
||||
{
|
||||
m_transparency = m_transGsettings->get("transparency").toDouble() + 0.15;
|
||||
m_transparency = (m_transparency > 1) ? 1 : m_transparency;
|
||||
paintWithTrans();
|
||||
}
|
||||
|
||||
void SinglePage::paintWithTrans()
|
||||
{
|
||||
QPalette pal = this->palette();
|
||||
QColor color = qApp->palette().base().color();
|
||||
color.setAlphaF(m_transparency);
|
||||
pal.setColor(QPalette::Window, color);
|
||||
this->setPalette(pal);
|
||||
}
|
||||
|
||||
void SinglePage::keyPressEvent(QKeyEvent *event)
|
||||
{
|
||||
if (event->key() == Qt::Key_Escape) {
|
||||
this->hide();
|
||||
}
|
||||
return QWidget::keyPressEvent(event);
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,112 @@
|
|||
/* -*- 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 SINGLEPAGE_H
|
||||
#define SINGLEPAGE_H
|
||||
|
||||
#include "divider.h"
|
||||
#include "kylable.h"
|
||||
#include <QVBoxLayout>
|
||||
#include <QHBoxLayout>
|
||||
#include <QFormLayout>
|
||||
#include <QLabel>
|
||||
#include <QScrollArea>
|
||||
#include <QListWidget>
|
||||
#include <QDir>
|
||||
#include <QComboBox>
|
||||
#include <QEvent>
|
||||
#include <QProcess>
|
||||
#include <QDebug>
|
||||
#include "kylinnetworkdeviceresource.h"
|
||||
#include "kwidget.h"
|
||||
#include "kswitchbutton.h"
|
||||
|
||||
using namespace kdk;
|
||||
|
||||
#define MAIN_LAYOUT_MARGINS 0,0,0,0
|
||||
#define MAIN_LAYOUT_SPACING 0
|
||||
#define TITLE_FRAME_HEIGHT 60 //TabWidget的tab和widget有间隙,和设计稿看起来一致就不能设为设计稿里的高度
|
||||
#define TITLE_LAYOUT_MARGINS 24,0,24,0
|
||||
#define NET_LAYOUT_MARGINS 8,8,0,8
|
||||
#define TEXT_HEIGHT 20
|
||||
#define SETTINGS_LAYOUT_MARGINS 23,0,24,0
|
||||
|
||||
#define MAX_ITEMS 4
|
||||
#define MAX_WIDTH 412
|
||||
#define MIN_WIDTH 404
|
||||
|
||||
#define SCROLL_STEP 4
|
||||
|
||||
#define TRANSPARENCY "transparency"
|
||||
#define TRANSPARENCY_GSETTINGS "org.ukui.control-center.personalise"
|
||||
|
||||
class SinglePage : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit SinglePage(QWidget *parent = nullptr);
|
||||
~SinglePage();
|
||||
|
||||
static void showDesktopNotify(const QString &message, QString soundName);
|
||||
|
||||
Q_SIGNALS:
|
||||
void activateFailed(QString errorMessage);
|
||||
void deactivateFailed(QString errorMessage);
|
||||
|
||||
private Q_SLOTS:
|
||||
void onTransChanged();
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *event);
|
||||
void keyPressEvent(QKeyEvent *event);
|
||||
|
||||
protected:
|
||||
void initUI();
|
||||
void initTransparency();
|
||||
void paintWithTrans();
|
||||
|
||||
|
||||
private:
|
||||
void initWindowProperties();
|
||||
|
||||
protected:
|
||||
QVBoxLayout * m_mainLayout = nullptr;
|
||||
|
||||
QLabel * m_titleLabel = nullptr;
|
||||
QFrame * m_titleFrame = nullptr;
|
||||
QHBoxLayout * m_titleLayout = nullptr;
|
||||
|
||||
QFrame * m_listFrame = nullptr;
|
||||
QListWidget * m_listWidget = nullptr;
|
||||
QVBoxLayout * m_listLayout = nullptr;
|
||||
|
||||
QFrame * m_settingsFrame = nullptr;
|
||||
QHBoxLayout * m_settingsLayout = nullptr;
|
||||
KyLable * m_settingsLabel = nullptr;
|
||||
|
||||
Divider * m_netDivider = nullptr;
|
||||
Divider * m_setDivider = nullptr;
|
||||
|
||||
|
||||
QGSettings * m_transGsettings = nullptr;
|
||||
double m_transparency = 1.0; //透明度
|
||||
|
||||
};
|
||||
|
||||
#endif // TABPAGE_H
|
|
@ -0,0 +1,690 @@
|
|||
/* -*- 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 "vpnpage.h"
|
||||
#include <QDebug>
|
||||
#include <QScrollBar>
|
||||
#include "windowmanager/windowmanager.h"
|
||||
|
||||
|
||||
VpnPage::VpnPage(QWidget *parent) : SinglePage(parent)
|
||||
{
|
||||
m_activeResourse = new KyActiveConnectResourse(this);
|
||||
m_connectResourse = new KyConnectResourse(this);
|
||||
m_vpnConnectOperation = new KyVpnConnectOperation(this);
|
||||
|
||||
initUI();
|
||||
initVpnArea();
|
||||
installEventFilter(this);
|
||||
|
||||
connect(m_activeResourse, &KyActiveConnectResourse::stateChangeReason, this, &VpnPage::onConnectionStateChange);
|
||||
connect(m_activeResourse, &KyActiveConnectResourse::activeConnectRemove, this, [=] (QString activeConnectUuid) {
|
||||
sendVpnStateChangeSignal(activeConnectUuid,Deactivated);
|
||||
} );
|
||||
|
||||
connect(m_connectResourse, &KyConnectResourse::connectionAdd, this, &VpnPage::onAddConnection);
|
||||
connect(m_connectResourse, &KyConnectResourse::connectionRemove, this, &VpnPage::onRemoveConnection);
|
||||
connect(m_connectResourse, &KyConnectResourse::connectionUpdate, this, &VpnPage::onUpdateConnection);
|
||||
|
||||
connect(m_vpnConnectOperation, &KyVpnConnectOperation::activateConnectionError, this, &VpnPage::activateFailed);
|
||||
connect(m_vpnConnectOperation, &KyVpnConnectOperation::deactivateConnectionError, this, &VpnPage::deactivateFailed);
|
||||
|
||||
connect(KWindowSystem::self(), &KWindowSystem::activeWindowChanged, this, [&](WId activeWindowId){
|
||||
if (activeWindowId != this->winId() && activeWindowId != 0) {
|
||||
hide();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
VpnPage::~VpnPage()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void VpnPage::deleteConnectionMapItem(QMap<QString, QListWidgetItem *> &connectMap,
|
||||
QListWidget *vpnListWidget, QString uuid)
|
||||
{
|
||||
QListWidgetItem *p_listWidgetItem = connectMap.value(uuid);
|
||||
if (p_listWidgetItem) {
|
||||
connectMap.remove(uuid);
|
||||
VpnListItem *p_vpnItem = (VpnListItem *)vpnListWidget->itemWidget(p_listWidgetItem);
|
||||
vpnListWidget->removeItemWidget(p_listWidgetItem);
|
||||
|
||||
delete p_vpnItem;
|
||||
p_vpnItem = nullptr;
|
||||
|
||||
delete p_listWidgetItem;
|
||||
p_listWidgetItem = nullptr;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void VpnPage::clearConnectionMap(QMap<QString, QListWidgetItem *> &connectMap,
|
||||
QListWidget *vpnListWidget)
|
||||
{
|
||||
QMap<QString, QListWidgetItem *>::iterator iter;
|
||||
|
||||
iter = connectMap.begin();
|
||||
while (iter != connectMap.end()) {
|
||||
qDebug()<<"[VpnPage] clear connection map item"<< iter.key();
|
||||
|
||||
QListWidgetItem *p_widgetItem = iter.value();
|
||||
VpnListItem *p_vpnItem = (VpnListItem *)vpnListWidget->itemWidget(p_widgetItem);
|
||||
vpnListWidget->removeItemWidget(p_widgetItem);
|
||||
|
||||
delete p_vpnItem;
|
||||
p_vpnItem = nullptr;
|
||||
|
||||
delete p_widgetItem;
|
||||
p_widgetItem = nullptr;
|
||||
|
||||
iter = connectMap.erase(iter);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void VpnPage::constructItemArea()
|
||||
{
|
||||
QList<KyConnectItem *> activedList;
|
||||
QList<KyConnectItem *> netList;
|
||||
|
||||
activedList.clear();
|
||||
netList.clear();
|
||||
clearConnectionMap(m_activeItemMap, m_listWidget);
|
||||
clearConnectionMap(m_vpnItemMap, m_listWidget);
|
||||
|
||||
m_connectResourse->getVpnAndVirtualConnections(netList);
|
||||
KyConnectItem *p_newItem = nullptr;
|
||||
if (!netList.isEmpty()) {
|
||||
for (int index = 0; index < netList.size(); index++) {
|
||||
KyConnectItem *p_netConnectionItem = netList.at(index);
|
||||
p_newItem = m_activeResourse->getActiveConnectionByUuid(p_netConnectionItem->m_connectUuid);
|
||||
if (p_newItem == nullptr) {
|
||||
if (m_vpnItemMap.contains(p_netConnectionItem->m_connectUuid)) {
|
||||
qDebug()<<LOG_FLAG << "has contain uuid" << p_netConnectionItem->m_connectUuid;
|
||||
}
|
||||
QListWidgetItem *p_listWidgetItem = addNewItem(p_netConnectionItem, m_listWidget);
|
||||
m_vpnItemMap.insert(p_netConnectionItem->m_connectUuid, p_listWidgetItem);
|
||||
} else {
|
||||
if (m_activeItemMap.contains(p_netConnectionItem->m_connectUuid)) {
|
||||
qDebug()<<LOG_FLAG << "has contain uuid" << p_netConnectionItem->m_connectUuid;
|
||||
}
|
||||
QListWidgetItem *p_listWidgetItem = addNewItem(p_newItem, m_listWidget);
|
||||
m_activeItemMap.insert(p_netConnectionItem->m_connectUuid, p_listWidgetItem);
|
||||
}
|
||||
|
||||
delete p_netConnectionItem;
|
||||
p_netConnectionItem = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
if (QGSettings::isSchemaInstalled(GSETTINGS_VPNICON_VISIBLE)) {
|
||||
QGSettings vpnGsettings(GSETTINGS_VPNICON_VISIBLE);
|
||||
if (vpnGsettings.keys().contains(QString(VISIBLE))) {
|
||||
if (!netList.isEmpty()) {
|
||||
vpnGsettings.set(VISIBLE, true);
|
||||
} else {
|
||||
vpnGsettings.set(VISIBLE, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
resetListWidgetWidth();
|
||||
}
|
||||
|
||||
void VpnPage::initVpnArea()
|
||||
{
|
||||
constructItemArea();
|
||||
}
|
||||
|
||||
void VpnPage::resetPageHeight()
|
||||
{
|
||||
int height = 0;
|
||||
int count = m_listWidget->count();
|
||||
m_listFrame->setFixedHeight((count >= 4) ? (MAX_ITEMS * ITEM_HEIGHT + ITEM_SPACE) : (count * ITEM_HEIGHT + ITEM_SPACE));
|
||||
|
||||
if (count == 0) {
|
||||
m_listWidget->setHidden(true);
|
||||
m_listFrame->setHidden(true);
|
||||
m_netDivider->setHidden(true);
|
||||
} else {
|
||||
m_listWidget->show();
|
||||
m_listFrame->show();
|
||||
m_netDivider->show();
|
||||
}
|
||||
}
|
||||
|
||||
bool VpnPage::removeConnectionItem(QMap<QString, QListWidgetItem *> &connectMap,
|
||||
QListWidget *vpnListWidget, QString path)
|
||||
{
|
||||
QMap<QString, QListWidgetItem *>::iterator iter;
|
||||
for (iter = connectMap.begin(); iter != connectMap.end(); ++iter) {
|
||||
QListWidgetItem *p_listWidgetItem = iter.value();
|
||||
VpnListItem *p_vpnItem = (VpnListItem*)vpnListWidget->itemWidget(p_listWidgetItem);
|
||||
if (p_vpnItem->getConnectionPath() == path) {
|
||||
qDebug()<<"[VpnPage] Remove a connection from list";
|
||||
|
||||
vpnListWidget->removeItemWidget(p_listWidgetItem);
|
||||
|
||||
delete p_vpnItem;
|
||||
p_vpnItem = nullptr;
|
||||
|
||||
delete p_listWidgetItem;
|
||||
p_listWidgetItem = nullptr;
|
||||
|
||||
iter = connectMap.erase(iter);
|
||||
resetListWidgetWidth();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void VpnPage::onRemoveConnection(QString path) //删除时后端会自动断开激活,将其从未激活列表中删除
|
||||
{
|
||||
//for dbus
|
||||
qDebug() << "[VpnPage] emit lanRemove because onRemoveConnection " << path;
|
||||
Q_EMIT vpnRemove(path);
|
||||
|
||||
removeConnectionItem(m_vpnItemMap, m_listWidget, path);
|
||||
removeConnectionItem(m_activeItemMap, m_listWidget, path);
|
||||
resetPageHeight();
|
||||
resetWindowPosition();
|
||||
this->update();
|
||||
}
|
||||
|
||||
void VpnPage::onAddConnection(QString uuid) //新增一个有线连接,将其加入到激活列表
|
||||
{
|
||||
if (!m_connectResourse->isVirtualConncection(uuid)) {
|
||||
return;
|
||||
}
|
||||
|
||||
KyConnectItem *p_newItem = nullptr;
|
||||
p_newItem = m_connectResourse->getConnectionItemByUuid(uuid);
|
||||
if (nullptr == p_newItem) {
|
||||
return;
|
||||
}
|
||||
|
||||
sendVpnAddSignal(p_newItem);
|
||||
|
||||
qDebug()<<"[VpnPage] Add a new connection, name:"<<p_newItem->m_connectName;
|
||||
QListWidgetItem *p_listWidgetItem = insertNewItem(p_newItem, m_listWidget);
|
||||
if (m_vpnItemMap.contains(p_newItem->m_connectUuid)) {
|
||||
qDebug()<<LOG_FLAG << "the connection is exist" << p_newItem->m_connectUuid;
|
||||
}
|
||||
m_vpnItemMap.insert(p_newItem->m_connectUuid, p_listWidgetItem);
|
||||
|
||||
delete p_newItem;
|
||||
p_newItem = nullptr;
|
||||
resetListWidgetWidth();
|
||||
resetPageHeight();
|
||||
resetWindowPosition();
|
||||
this->update();
|
||||
return;
|
||||
}
|
||||
|
||||
void VpnPage::onShowControlCenter()
|
||||
{
|
||||
QProcess process;
|
||||
process.startDetached("ukui-control-center -m vpn");
|
||||
}
|
||||
|
||||
void VpnPage::initUI()
|
||||
{
|
||||
m_titleLabel->setText(tr("VPN"));
|
||||
|
||||
// m_listFrame->setMaximumHeight(MAX_ITEMS * ITEM_HEIGHT + ITEM_SPACE);
|
||||
|
||||
m_listWidget->setFrameShape(QFrame::Shape::NoFrame);
|
||||
m_listWidget->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
m_listWidget->setVerticalScrollMode(QAbstractItemView::ScrollMode::ScrollPerPixel);
|
||||
m_listWidget->verticalScrollBar()->setProperty("drawScrollBarGroove",false); //去除滚动条的外侧黑框
|
||||
m_listWidget->verticalScrollBar()->setSingleStep(SCROLL_STEP);
|
||||
m_listWidget->verticalScrollBar()->setContextMenuPolicy(Qt::NoContextMenu);
|
||||
|
||||
m_settingsLabel->setText(tr("VPN Settings"));
|
||||
m_settingsLabel->installEventFilter(this);
|
||||
}
|
||||
|
||||
QListWidgetItem *VpnPage::insertNewItem(KyConnectItem *itemData, QListWidget *listWidget)
|
||||
{
|
||||
int index = 0;
|
||||
|
||||
for(index = 0; index < m_listWidget->count(); index++) {
|
||||
QListWidgetItem *p_listWidgetItem = m_listWidget->item(index);
|
||||
VpnListItem *p_vpnItem = (VpnListItem *)m_listWidget->itemWidget(p_listWidgetItem);
|
||||
QString name1 = p_vpnItem->getConnectionName();
|
||||
QString name2 = itemData->m_connectName;
|
||||
if (QString::compare(name1, name2, Qt::CaseInsensitive) > 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
QListWidgetItem *p_sortListWidgetItem = new QListWidgetItem();
|
||||
p_sortListWidgetItem->setFlags(p_sortListWidgetItem->flags() & (~Qt::ItemIsSelectable)); //设置不可被选中
|
||||
p_sortListWidgetItem->setSizeHint(QSize(listWidget->width(),ITEM_HEIGHT));
|
||||
|
||||
listWidget->insertItem(index, p_sortListWidgetItem);
|
||||
|
||||
VpnListItem *p_sortLanItem = nullptr;
|
||||
p_sortLanItem = new VpnListItem(itemData);
|
||||
listWidget->setItemWidget(p_sortListWidgetItem, p_sortLanItem);
|
||||
|
||||
return p_sortListWidgetItem;
|
||||
}
|
||||
|
||||
QListWidgetItem *VpnPage::addNewItem(KyConnectItem *itemData, QListWidget *listWidget)
|
||||
{
|
||||
QListWidgetItem *p_listWidgetItem = new QListWidgetItem();
|
||||
p_listWidgetItem->setFlags(p_listWidgetItem->flags() & (~Qt::ItemIsSelectable));
|
||||
p_listWidgetItem->setSizeHint(QSize(listWidget->width() - 16, ITEM_HEIGHT));
|
||||
listWidget->addItem(p_listWidgetItem);
|
||||
VpnListItem *p_vpnItem = nullptr;
|
||||
if (itemData != nullptr) {
|
||||
p_vpnItem = new VpnListItem(itemData);
|
||||
qDebug() << "[VpnPage] addNewItem, connection: " << itemData->m_connectName;
|
||||
} else {
|
||||
p_vpnItem = new VpnListItem();
|
||||
qDebug() << "[VpnPage] Add nullItem!";
|
||||
}
|
||||
|
||||
listWidget->setItemWidget(p_listWidgetItem, p_vpnItem);
|
||||
return p_listWidgetItem;
|
||||
}
|
||||
|
||||
void VpnPage::updateActivatedConnectionArea(KyConnectItem *p_newItem)
|
||||
{
|
||||
if (m_activeItemMap.contains(p_newItem->m_connectUuid)) {
|
||||
return;
|
||||
}
|
||||
|
||||
deleteConnectionMapItem(m_vpnItemMap, m_listWidget, p_newItem->m_connectUuid);
|
||||
qDebug()<<"[VpnPage]update active connection item"<<p_newItem->m_connectName;
|
||||
deleteConnectionMapItem(m_activeItemMap, m_listWidget, p_newItem->m_connectUuid);
|
||||
QListWidgetItem *p_listWidgetItem = addNewItem(p_newItem, m_listWidget);
|
||||
m_activeItemMap.insert(p_newItem->m_connectUuid, p_listWidgetItem);
|
||||
|
||||
resetListWidgetWidth();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void VpnPage::updateConnectionArea(KyConnectItem *p_newItem)
|
||||
{
|
||||
if (m_vpnItemMap.contains(p_newItem->m_connectUuid)) {
|
||||
return;
|
||||
}
|
||||
|
||||
deleteConnectionMapItem(m_activeItemMap, m_listWidget, p_newItem->m_connectUuid);
|
||||
qDebug()<<"[VpnPage] update connection item"<<p_newItem->m_connectName;
|
||||
QListWidgetItem *p_listWidgetItem = insertNewItem(p_newItem, m_listWidget);
|
||||
m_vpnItemMap.insert(p_newItem->m_connectUuid, p_listWidgetItem);
|
||||
|
||||
resetListWidgetWidth();
|
||||
}
|
||||
|
||||
void VpnPage::updateConnectionState(QMap<QString, QListWidgetItem *> &connectMap,
|
||||
QListWidget *vpnListWidget, QString uuid, ConnectState state)
|
||||
{
|
||||
qDebug() << LOG_FLAG << "update connection state";
|
||||
|
||||
QListWidgetItem *p_listWidgetItem = connectMap.value(uuid);
|
||||
if (p_listWidgetItem) {
|
||||
VpnListItem *p_vpnItem = (VpnListItem *)vpnListWidget->itemWidget(p_listWidgetItem);
|
||||
p_vpnItem->updateConnectionState(state);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void VpnPage::onConnectionStateChange(QString uuid,
|
||||
NetworkManager::ActiveConnection::State state,
|
||||
NetworkManager::ActiveConnection::Reason reason)
|
||||
{
|
||||
//VpnPage函数内持续监听连接状态的变化并记录供其他函数调用获取状态
|
||||
if (!m_connectResourse->isVirtualConncection(uuid)) {
|
||||
qDebug() << "[VpnPage] connection state change signal but not vpn";
|
||||
return;
|
||||
}
|
||||
|
||||
sendVpnStateChangeSignal(uuid, (ConnectState)state);
|
||||
|
||||
if (m_activeItemMap.keys().contains(uuid) && state == NetworkManager::ActiveConnection::State::Activated) {
|
||||
return;
|
||||
}
|
||||
|
||||
qDebug()<<"[VpnPage] connection uuid"<< uuid
|
||||
<< "state change slot:"<< state;
|
||||
|
||||
KyConnectItem *p_newItem = nullptr;
|
||||
QString deviceName = "";
|
||||
QString ssid = "";
|
||||
|
||||
if (state == NetworkManager::ActiveConnection::State::Activated) {
|
||||
p_newItem = m_activeResourse->getActiveConnectionByUuid(uuid);
|
||||
if (nullptr == p_newItem) {
|
||||
qWarning()<<"[VpnPage] get active connection failed, connection uuid" << uuid;
|
||||
return;
|
||||
}
|
||||
|
||||
ssid = p_newItem->m_connectName;
|
||||
updateActivatedConnectionArea(p_newItem);
|
||||
updateConnectionState(m_activeItemMap, m_listWidget, uuid, (ConnectState)state);
|
||||
} else if (state == NetworkManager::ActiveConnection::State::Deactivated) {
|
||||
p_newItem = m_connectResourse->getConnectionItemByUuid(uuid);
|
||||
qDebug() << "[VpnPage] deactivated reason" << reason;
|
||||
if (nullptr == p_newItem) {
|
||||
qWarning()<<"[VpnPage] get active connection failed, connection uuid" << uuid;
|
||||
return;
|
||||
}
|
||||
|
||||
ssid = p_newItem->m_connectName;
|
||||
updateConnectionArea(p_newItem);
|
||||
updateConnectionState(m_vpnItemMap, m_listWidget, uuid, (ConnectState)state);
|
||||
} else if (state == NetworkManager::ActiveConnection::State::Activating) {
|
||||
updateConnectionState(m_vpnItemMap, m_listWidget, uuid, (ConnectState)state);
|
||||
} else if (state == NetworkManager::ActiveConnection::State::Deactivating) {
|
||||
updateConnectionState(m_activeItemMap, m_listWidget, uuid, (ConnectState)state);
|
||||
}
|
||||
|
||||
Q_EMIT vpnActiveConnectionStateChanged(uuid, state);
|
||||
|
||||
if (p_newItem) {
|
||||
delete p_newItem;
|
||||
p_newItem = nullptr;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void VpnPage::getVirtualList(QVector<QStringList> &vector)
|
||||
{
|
||||
QList<KyConnectItem *> netConnectList;
|
||||
vector.clear();
|
||||
m_connectResourse->getVpnAndVirtualConnections(netConnectList); //未激活列表的显示
|
||||
if (!netConnectList.isEmpty()) {
|
||||
for (int i = 0; i < netConnectList.size(); i++) {
|
||||
KyConnectItem *p_newItem = nullptr;
|
||||
KyConnectItem *p_netConnectionItem = netConnectList.at(i);
|
||||
p_newItem = m_activeResourse->getActiveConnectionByUuid(p_netConnectionItem->m_connectUuid);
|
||||
NetworkManager::ActiveConnection::State state = p_netConnectionItem->m_connectState;
|
||||
if (p_newItem != nullptr) {
|
||||
state = NetworkManager::ActiveConnection::Activated;
|
||||
}
|
||||
vector.append(QStringList() << netConnectList.at(i)->m_connectName
|
||||
<< netConnectList.at(i)->m_connectUuid
|
||||
<< netConnectList.at(i)->m_connectPath
|
||||
<< QString::number(state));
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void VpnPage::sendVpnUpdateSignal(KyConnectItem *p_connectItem)
|
||||
{
|
||||
QStringList info;
|
||||
info << p_connectItem->m_connectName << p_connectItem->m_connectUuid << p_connectItem->m_connectPath;
|
||||
Q_EMIT vpnUpdate(info);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void VpnPage::sendVpnAddSignal(KyConnectItem *p_connectItem)
|
||||
{
|
||||
QStringList info;
|
||||
KyConnectItem *p_newItem = nullptr;
|
||||
p_newItem = m_activeResourse->getActiveConnectionByUuid(p_connectItem->m_connectUuid);
|
||||
NetworkManager::ActiveConnection::State state = p_connectItem->m_connectState;
|
||||
if (p_newItem != nullptr) {
|
||||
state = NetworkManager::ActiveConnection::Activated;
|
||||
}
|
||||
info << p_connectItem->m_connectName
|
||||
<< p_connectItem->m_connectUuid
|
||||
<< p_connectItem->m_connectPath
|
||||
<< QString::number(state);
|
||||
qDebug() << "[VpnPage] emit vpnAdd because addConnection ";
|
||||
Q_EMIT vpnAdd(info);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void VpnPage::sendVpnStateChangeSignal(QString uuid, ConnectState state)
|
||||
{
|
||||
if (state == Activating || state == Deactivating) {
|
||||
if (m_activeResourse->connectionIsVirtual(uuid)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Q_EMIT this->vpnConnectChanged(state);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void VpnPage::updateConnectionProperty(KyConnectItem *p_connectItem)
|
||||
{
|
||||
QString newUuid = p_connectItem->m_connectUuid;
|
||||
|
||||
if (m_vpnItemMap.contains(newUuid)) {
|
||||
QListWidgetItem *p_listWidgetItem = m_vpnItemMap.value(newUuid);
|
||||
VpnListItem *p_vpnItem = (VpnListItem*)m_listWidget->itemWidget(p_listWidgetItem);
|
||||
if (p_connectItem->m_connectName != p_vpnItem->getConnectionName()){
|
||||
//只要名字改变就要删除,重新插入,主要是为了排序
|
||||
deleteConnectionMapItem(m_vpnItemMap, m_listWidget, newUuid);
|
||||
QListWidgetItem *p_sortListWidgetItem = insertNewItem(p_connectItem, m_listWidget);
|
||||
if (m_vpnItemMap.contains(newUuid)) {
|
||||
qDebug()<<LOG_FLAG << "has contained connection" << newUuid;
|
||||
}
|
||||
m_vpnItemMap.insert(newUuid, p_sortListWidgetItem);
|
||||
} else if (p_connectItem->m_connectPath != p_vpnItem->getConnectionPath()) {
|
||||
p_vpnItem->updateConnectionPath(p_connectItem->m_connectPath);
|
||||
}
|
||||
} else if (!m_activeItemMap.contains(newUuid)){
|
||||
if (p_connectItem->m_ifaceName.isEmpty()) {
|
||||
QListWidgetItem *p_listWidgetItem = insertNewItem(p_connectItem, m_listWidget);
|
||||
if (m_vpnItemMap.contains(newUuid)) {
|
||||
qDebug()<<LOG_FLAG << "has contained connection uuid" << newUuid;
|
||||
}
|
||||
m_vpnItemMap.insert(newUuid, p_listWidgetItem);
|
||||
}
|
||||
} else {
|
||||
qWarning() << LOG_FLAG << newUuid <<" is in activemap, so not process.";
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void VpnPage::updateActiveConnectionProperty(KyConnectItem *p_connectItem)
|
||||
{
|
||||
QString newUuid = p_connectItem->m_connectUuid;
|
||||
|
||||
if (m_activeItemMap.contains(newUuid)) {
|
||||
QListWidgetItem *p_listWidgetItem = m_activeItemMap.value(newUuid);
|
||||
VpnListItem *p_vpnItem = (VpnListItem *)m_listWidget->itemWidget(p_listWidgetItem);
|
||||
if (p_vpnItem->getConnectionName() != p_connectItem->m_connectName) {
|
||||
p_vpnItem->updateConnectionName(p_connectItem->m_connectName);
|
||||
}
|
||||
|
||||
if (p_vpnItem->getConnectionName() != p_connectItem->m_connectPath) {
|
||||
p_vpnItem->updateConnectionPath(p_connectItem->m_connectPath);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void VpnPage::onUpdateConnection(QString uuid)
|
||||
{
|
||||
if (!m_connectResourse->isVirtualConncection(uuid)) {
|
||||
return;
|
||||
}
|
||||
|
||||
qDebug() << "[VpnPage]:Connection property Changed." << Q_FUNC_INFO << __LINE__;
|
||||
|
||||
KyConnectItem *p_newItem = nullptr;
|
||||
if (m_connectResourse->isActivatedConnection(uuid)) {
|
||||
p_newItem = m_activeResourse->getActiveConnectionByUuid(uuid);
|
||||
if (nullptr == p_newItem) {
|
||||
qWarning()<<"[VpnPage] get item failed, when update activate connection."
|
||||
<<"connection uuid" << uuid;
|
||||
return;
|
||||
}
|
||||
|
||||
updateActiveConnectionProperty(p_newItem);
|
||||
} else {
|
||||
p_newItem = m_connectResourse->getConnectionItemByUuid(uuid);
|
||||
if (nullptr == p_newItem) {
|
||||
qWarning()<<"[VpnPage] get item failed, when update connection."
|
||||
<<"connection uuid"<<uuid;
|
||||
return;
|
||||
}
|
||||
|
||||
updateConnectionProperty(p_newItem);
|
||||
}
|
||||
|
||||
sendVpnUpdateSignal(p_newItem);
|
||||
|
||||
delete p_newItem;
|
||||
p_newItem = nullptr;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
bool VpnPage::eventFilter(QObject *watched, QEvent *event)
|
||||
{
|
||||
if (watched == m_settingsLabel) {
|
||||
if (event->type() == QEvent::MouseButtonRelease) {
|
||||
onShowControlCenter();
|
||||
}
|
||||
}
|
||||
|
||||
return QWidget::eventFilter(watched, event);
|
||||
}
|
||||
|
||||
void VpnPage::deleteVpn(const QString &connUuid)
|
||||
{
|
||||
qDebug() << "[VpnPage] deleteVpn" << connUuid;
|
||||
if (connUuid == nullptr) {
|
||||
return;
|
||||
}
|
||||
m_vpnConnectOperation->deleteVpnConnect(connUuid);
|
||||
}
|
||||
|
||||
void VpnPage::activateVpn(const QString& connUuid)
|
||||
{
|
||||
if (m_vpnItemMap.contains(connUuid)) {
|
||||
qDebug() << "[VpnPage] activateVpn" << connUuid;
|
||||
m_vpnConnectOperation->activateVpnConnection(connUuid);
|
||||
}
|
||||
}
|
||||
|
||||
void VpnPage::deactivateVpn(const QString& connUuid)
|
||||
{
|
||||
qDebug() << "[VpnPage] deactivateVpn" << connUuid;
|
||||
QString name("");
|
||||
m_vpnConnectOperation->deactivateVpnConnection(name, connUuid);
|
||||
}
|
||||
|
||||
void VpnPage::showDetailPage(QString uuid)
|
||||
{
|
||||
QListWidgetItem * vpnlistItem = m_vpnItemMap.value(uuid);
|
||||
VpnListItem *vpnItem = (VpnListItem *)m_listWidget->itemWidget(vpnlistItem);
|
||||
vpnItem->onInfoButtonClicked();
|
||||
}
|
||||
|
||||
void VpnPage::showUI()
|
||||
{
|
||||
//2209中窗管在hide界面时会刷新属性,需要重新设置无图标属性
|
||||
const KWindowInfo info(this->winId(), NET::WMState);
|
||||
if (!info.hasState(NET::SkipTaskbar) || !info.hasState(NET::SkipPager)) {
|
||||
KWindowSystem::setState(this->winId(), NET::SkipTaskbar | NET::SkipPager);
|
||||
}
|
||||
|
||||
resetPageHeight();
|
||||
|
||||
showNormal();
|
||||
raise();
|
||||
activateWindow();
|
||||
resetWindowPosition();
|
||||
return;
|
||||
}
|
||||
|
||||
void VpnPage::resetWindowPosition()
|
||||
{
|
||||
|
||||
#define MARGIN 4
|
||||
#define PANEL_TOP 1
|
||||
#define PANEL_LEFT 2
|
||||
#define PANEL_RIGHT 3
|
||||
//#define PANEL_BOTTOM 4
|
||||
if (!m_positionInterface) {
|
||||
m_positionInterface = new QDBusInterface("org.ukui.panel",
|
||||
"/panel/position",
|
||||
"org.ukui.panel",
|
||||
QDBusConnection::sessionBus());
|
||||
}
|
||||
QRect rect;
|
||||
QDBusReply<QVariantList> reply = m_positionInterface->call("GetPrimaryScreenGeometry");
|
||||
//reply获取的参数共5个,分别是 主屏可用区域的起点x坐标,主屏可用区域的起点y坐标,主屏可用区域的宽度,主屏可用区域高度,任务栏位置
|
||||
if (!m_positionInterface->isValid() || !reply.isValid() || reply.value().size() < 5) {
|
||||
qCritical() << QDBusConnection::sessionBus().lastError().message();
|
||||
kdk::WindowManager::setGeometry(this->windowHandle(), QRect(0, 0, this->width(), this->height()));
|
||||
return;
|
||||
}
|
||||
QVariantList position_list = reply.value();
|
||||
int position = position_list.at(4).toInt();
|
||||
switch(position){
|
||||
case PANEL_TOP:
|
||||
//任务栏位于上方
|
||||
rect = QRect(position_list.at(0).toInt() + position_list.at(2).toInt() - this->width() - MARGIN,
|
||||
position_list.at(1).toInt() + MARGIN,
|
||||
this->width(), this->height());
|
||||
break;
|
||||
//任务栏位于左边
|
||||
case PANEL_LEFT:
|
||||
rect = QRect(position_list.at(0).toInt() + MARGIN,
|
||||
position_list.at(1).toInt() + reply.value().at(3).toInt() - this->height() - MARGIN,
|
||||
this->width(), this->height());
|
||||
break;
|
||||
//任务栏位于右边
|
||||
case PANEL_RIGHT:
|
||||
rect = QRect(position_list.at(0).toInt() + position_list.at(2).toInt() - this->width() - MARGIN,
|
||||
position_list.at(1).toInt() + reply.value().at(3).toInt() - this->height() - MARGIN,
|
||||
this->width(), this->height());
|
||||
break;
|
||||
//任务栏位于下方
|
||||
default:
|
||||
rect = QRect(position_list.at(0).toInt() + position_list.at(2).toInt() - this->width() - MARGIN,
|
||||
position_list.at(1).toInt() + reply.value().at(3).toInt() - this->height() - MARGIN,
|
||||
this->width(), this->height());
|
||||
break;
|
||||
}
|
||||
kdk::WindowManager::setGeometry(this->windowHandle(), rect);
|
||||
qDebug() << " Position of ukui-panel is " << position << "; Position of mainwindow is " << this->geometry() << "." << Q_FUNC_INFO << __LINE__;
|
||||
}
|
||||
|
||||
void VpnPage::resetListWidgetWidth()
|
||||
{
|
||||
if (m_listWidget->count() <= MAX_ITEMS) {
|
||||
m_listFrame->setFixedWidth(MIN_WIDTH);
|
||||
} else {
|
||||
m_listFrame->setFixedWidth(MAX_WIDTH);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,137 @@
|
|||
/* -*- 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 VPNPAGE_H
|
||||
#define VPNPAGE_H
|
||||
|
||||
#include "divider.h"
|
||||
#include <QVBoxLayout>
|
||||
#include <QHBoxLayout>
|
||||
#include <QLabel>
|
||||
#include <QScrollArea>
|
||||
#include <QListWidget>
|
||||
#include <QMap>
|
||||
#include <QGSettings>
|
||||
|
||||
#include <KWindowSystem>
|
||||
|
||||
#include "list-items/listitem.h"
|
||||
#include "list-items/vpnlistitem.h"
|
||||
#include "single-pages/singlepage.h"
|
||||
|
||||
#define VPNPAGE_LAYOUT_MARGINS 0,0,0,0
|
||||
#define VPN_LIST_SPACING 0
|
||||
#define ITEM_HEIGHT 50
|
||||
#define ITEM_SPACE 16
|
||||
#define PAGE_SPACE 22
|
||||
|
||||
#define LOG_FLAG "[VpnPage]"
|
||||
|
||||
#define VISIBLE "visible"
|
||||
const QByteArray GSETTINGS_VPNICON_VISIBLE = "org.ukui.kylin-nm.vpnicon";
|
||||
|
||||
class VpnListItem;
|
||||
|
||||
class VpnPage : public SinglePage
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit VpnPage(QWidget *parent = nullptr);
|
||||
~VpnPage();
|
||||
|
||||
//for dbus
|
||||
void getVirtualList(QVector<QStringList> &vector);
|
||||
void deleteVpn(const QString &connUuid);
|
||||
void activateVpn(const QString& connUuid);
|
||||
void deactivateVpn(const QString& connUuid);
|
||||
void showDetailPage(QString uuid);
|
||||
|
||||
protected:
|
||||
bool eventFilter(QObject *watched, QEvent *event);
|
||||
|
||||
private:
|
||||
void initUI();
|
||||
void initVpnArea();
|
||||
void resetPageHeight();
|
||||
|
||||
inline void initDeviceCombox() { return; }
|
||||
|
||||
QListWidgetItem *insertNewItem(KyConnectItem *itemData, QListWidget *listWidget);
|
||||
QListWidgetItem *addNewItem(KyConnectItem *itemData, QListWidget *listWidget);
|
||||
bool removeConnectionItem(QMap<QString, QListWidgetItem *> &connectMap,
|
||||
QListWidget *vpnListWidget, QString path);
|
||||
|
||||
void constructItemArea();
|
||||
|
||||
void updateConnectionArea(KyConnectItem *p_newItem);
|
||||
void updateActivatedConnectionArea(KyConnectItem *p_newItem);
|
||||
void updateConnectionState(QMap<QString, QListWidgetItem *> &connectMap,
|
||||
QListWidget *vpnListWidget, QString uuid, ConnectState state);
|
||||
|
||||
void updateActiveConnectionProperty(KyConnectItem *p_connectItem);
|
||||
void updateConnectionProperty(KyConnectItem *p_connectItem);
|
||||
|
||||
void sendVpnUpdateSignal(KyConnectItem *p_connectItem);
|
||||
void sendVpnAddSignal(KyConnectItem *p_connectItem);
|
||||
void sendVpnStateChangeSignal(QString uuid, ConnectState state);
|
||||
|
||||
void clearConnectionMap(QMap<QString, QListWidgetItem *> &connectMap,
|
||||
QListWidget *vpnListWidget);
|
||||
void deleteConnectionMapItem(QMap<QString, QListWidgetItem *> &connectMap,
|
||||
QListWidget *vpnListWidget, QString uuid);
|
||||
|
||||
void resetWindowPosition();
|
||||
void resetListWidgetWidth();
|
||||
|
||||
Q_SIGNALS:
|
||||
void vpnAdd(QStringList info);
|
||||
void vpnRemove(QString dbusPath);
|
||||
void vpnUpdate(QStringList info);
|
||||
|
||||
void vpnActiveConnectionStateChanged(QString uuid, int status);
|
||||
void vpnConnectChanged(int state);
|
||||
|
||||
private Q_SLOTS:
|
||||
void onConnectionStateChange(QString uuid,
|
||||
NetworkManager::ActiveConnection::State state,
|
||||
NetworkManager::ActiveConnection::Reason reason);
|
||||
|
||||
void onAddConnection(QString uuid);
|
||||
void onRemoveConnection(QString path);
|
||||
void onUpdateConnection(QString uuid);
|
||||
|
||||
void onShowControlCenter();
|
||||
|
||||
private:
|
||||
KyVpnConnectOperation *m_vpnConnectOperation = nullptr;
|
||||
KyActiveConnectResourse *m_activeResourse = nullptr; //激活的连接
|
||||
KyConnectResourse *m_connectResourse = nullptr; //未激活的连接
|
||||
|
||||
QMap<QString, QListWidgetItem *> m_vpnItemMap;
|
||||
QMap<QString, QListWidgetItem *> m_activeItemMap;
|
||||
|
||||
QDBusInterface * m_positionInterface = nullptr;
|
||||
|
||||
|
||||
|
||||
public Q_SLOTS:
|
||||
void showUI();
|
||||
};
|
||||
|
||||
#endif // LANPAGE_H
|
|
@ -0,0 +1,234 @@
|
|||
#include "vpnaddpage.h"
|
||||
#include <QDebug>
|
||||
#include "vpnconfigpage.h"
|
||||
|
||||
vpnAddPage::vpnAddPage(QWidget *parent) : QWidget(parent)
|
||||
{
|
||||
m_vpnConnOperation = new KyVpnConnectOperation(this);
|
||||
initWindow();
|
||||
initUI();
|
||||
initConnection();
|
||||
centerToScreen();
|
||||
}
|
||||
|
||||
void vpnAddPage::centerToScreen()
|
||||
{
|
||||
QDesktopWidget* m = QApplication::desktop();
|
||||
QRect desk_rect = m->screenGeometry(m->screenNumber(QCursor::pos()));
|
||||
int desk_x = desk_rect.width();
|
||||
int desk_y = desk_rect.height();
|
||||
int x = this->width();
|
||||
int y = this->height();
|
||||
this->move(desk_x / 2 - x / 2 + desk_rect.left(), desk_y / 2 - y / 2 + desk_rect.top());
|
||||
}
|
||||
|
||||
void vpnAddPage::initWindow()
|
||||
{
|
||||
this->setFixedSize(VPNADDPAGE_SIZE);
|
||||
this->setWindowTitle(tr("create VPN"));
|
||||
this->setWindowFlag(Qt::WindowMinMaxButtonsHint,false);
|
||||
this->setAttribute(Qt::WA_DeleteOnClose);
|
||||
}
|
||||
|
||||
void vpnAddPage::initUI()
|
||||
{
|
||||
QVBoxLayout *mainLayout = new QVBoxLayout(this);
|
||||
mainLayout->setContentsMargins(VPNADDPAGE_MAINLAYOUT_MARGINS);
|
||||
mainLayout->setSpacing(VPNADDPAGE_NULLSPACE);
|
||||
|
||||
initVpnTypeFrame();
|
||||
initVpnNameFrame();
|
||||
initVpnServerFrame();
|
||||
initButtonFrame();
|
||||
onSetConfimBtnEnable();
|
||||
|
||||
mainLayout->addWidget(m_vpnTypeFrame);
|
||||
mainLayout->addWidget(m_vpnNameFrame);
|
||||
mainLayout->addWidget(m_vpnServerFrame);
|
||||
mainLayout->addStretch();
|
||||
mainLayout->addWidget(m_buttonFrame);
|
||||
this->setLayout(mainLayout);
|
||||
}
|
||||
|
||||
void vpnAddPage::initVpnTypeFrame()
|
||||
{
|
||||
m_vpnTypeFrame = new QFrame(this);
|
||||
m_vpnTypeFrame->setFrameShape(QFrame::Shape::NoFrame);
|
||||
m_vpnTypeFrame->setFixedSize(VPNADDPAGE_FRAME_FIXEDSIZE);
|
||||
|
||||
QHBoxLayout *typeLayout = new QHBoxLayout(m_vpnTypeFrame);
|
||||
typeLayout->setContentsMargins(VPNADDPAGE_ITEM_MARGINS);
|
||||
typeLayout->setSpacing(VPNADDPAGE_NULLSPACE);
|
||||
|
||||
QLabel *vpnTypeLabel = new QLabel(tr("VPN Type"), this);
|
||||
vpnTypeLabel->setFixedWidth(VPNADDPAGE_LABLE_FIXEDWIDTH);
|
||||
|
||||
m_vpnTypeComboBox = new QComboBox(this);
|
||||
m_vpnTypeComboBox->setInsertPolicy(QComboBox::NoInsert);
|
||||
m_vpnTypeComboBox->setFixedWidth(VPNADDPAGE_COMBOBOX_FIXEDWIDTH);
|
||||
m_vpnTypeComboBox->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed);
|
||||
|
||||
m_vpnTypeComboBox->addItem("L2TP", L2TP);
|
||||
m_vpnTypeComboBox->addItem("open VPN", OPEN_VPN);
|
||||
m_vpnTypeComboBox->addItem("PPTP", PPTP);
|
||||
m_vpnTypeComboBox->addItem("strong-swan", STRONG_SWAN);
|
||||
|
||||
|
||||
typeLayout->addWidget(vpnTypeLabel);
|
||||
typeLayout->addWidget(m_vpnTypeComboBox);
|
||||
m_vpnTypeFrame->setLayout(typeLayout);
|
||||
}
|
||||
|
||||
void vpnAddPage::initVpnNameFrame()
|
||||
{
|
||||
m_vpnNameFrame = new QFrame(this);
|
||||
m_vpnNameFrame->setFrameShape(QFrame::Shape::NoFrame);
|
||||
m_vpnNameFrame->setFixedSize(VPNADDPAGE_FRAME_FIXEDSIZE);
|
||||
|
||||
QHBoxLayout *nameLayout = new QHBoxLayout(m_vpnNameFrame);
|
||||
nameLayout->setContentsMargins(VPNADDPAGE_ITEM_MARGINS);
|
||||
nameLayout->setSpacing(VPNADDPAGE_NULLSPACE);
|
||||
|
||||
QLabel *vpnNameLabel = new QLabel(tr("VPN Name"), this);
|
||||
vpnNameLabel->setFixedWidth(VPNADDPAGE_LABLE_FIXEDWIDTH);
|
||||
|
||||
m_vpnNameLineEdit = new QLineEdit(this);
|
||||
m_vpnNameLineEdit->setFixedWidth(VPNADDPAGE_INPUTBOX_FIXEDWIDTH);
|
||||
m_vpnNameLineEdit->setMaxLength(VPNADDPAGE_NAME_MAX_LENGTH);
|
||||
m_vpnNameLineEdit->setPlaceholderText(tr("Required")); //必填
|
||||
|
||||
nameLayout->addWidget(vpnNameLabel);
|
||||
nameLayout->addWidget(m_vpnNameLineEdit);
|
||||
m_vpnNameFrame->setLayout(nameLayout);
|
||||
}
|
||||
|
||||
void vpnAddPage::initVpnServerFrame()
|
||||
{
|
||||
m_vpnServerFrame = new QFrame(this);
|
||||
m_vpnServerFrame->setFrameShape(QFrame::Shape::NoFrame);
|
||||
m_vpnServerFrame->setFixedSize(VPNADDPAGE_FRAME_FIXEDSIZE);
|
||||
|
||||
QHBoxLayout *serverLayout = new QHBoxLayout(m_vpnServerFrame);
|
||||
serverLayout->setContentsMargins(VPNADDPAGE_ITEM_MARGINS);
|
||||
serverLayout->setSpacing(VPNADDPAGE_NULLSPACE);
|
||||
|
||||
QLabel *vpnServerLabel = new QLabel(tr("VPN Server"), this);
|
||||
vpnServerLabel->setFixedWidth(VPNADDPAGE_LABLE_FIXEDWIDTH);
|
||||
|
||||
m_vpnServerLineEdit = new QLineEdit(this);
|
||||
m_vpnServerLineEdit->setFixedWidth(VPNADDPAGE_INPUTBOX_FIXEDWIDTH);
|
||||
m_vpnServerLineEdit->setPlaceholderText(tr("Required")); //必填
|
||||
|
||||
serverLayout->addWidget(vpnServerLabel);
|
||||
serverLayout->addWidget(m_vpnServerLineEdit);
|
||||
m_vpnServerFrame->setLayout(serverLayout);
|
||||
|
||||
// IP的正则格式限制
|
||||
QRegExp rxIp("\\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");
|
||||
QRegExpValidator *ipExpVal = new QRegExpValidator(rxIp, this);
|
||||
m_vpnServerLineEdit->setValidator(ipExpVal);
|
||||
}
|
||||
|
||||
void vpnAddPage::initButtonFrame()
|
||||
{
|
||||
m_buttonFrame = new QFrame(this);
|
||||
m_buttonFrame->setFixedSize(VPNDETAILPAGE_FRAME_FIXEDSIZE);
|
||||
|
||||
QHBoxLayout *buttonLayout = new QHBoxLayout(m_buttonFrame);
|
||||
buttonLayout->setContentsMargins(VPNDETAILPAGE_ITEM_MARGINS);
|
||||
buttonLayout->setSpacing(VPNDETAILPAGE_NULLSPACE);
|
||||
|
||||
QLabel *autoConnectLabel = new QLabel(this);
|
||||
m_autoConnectBox = new QCheckBox(this);
|
||||
autoConnectLabel->setText(tr("Auto Connection"));
|
||||
QWidget *autoConWidget = new QWidget(this);
|
||||
QHBoxLayout *autoLayout = new QHBoxLayout(autoConWidget);
|
||||
|
||||
autoLayout->setContentsMargins(VPNDETAILPAGE_NULLMAGINS);
|
||||
autoLayout->setSpacing(VPNDETAILPAGE_NULLSPACE);
|
||||
autoLayout->addWidget(m_autoConnectBox);
|
||||
autoLayout->addWidget(autoConnectLabel);
|
||||
autoConWidget->setLayout(autoLayout);
|
||||
|
||||
m_confimBtn = new QPushButton(this);
|
||||
m_confimBtn->setFixedSize(VPNDETAILPAGE_BUTTON_FIXEDSIZE);
|
||||
m_confimBtn->setText(tr("Confirm"));
|
||||
m_cancelBtn = new QPushButton(this);
|
||||
m_cancelBtn->setFixedSize(VPNDETAILPAGE_BUTTON_FIXEDSIZE);
|
||||
m_cancelBtn->setText(tr("Cancel"));
|
||||
|
||||
buttonLayout->addWidget(autoConWidget);
|
||||
buttonLayout->addStretch();
|
||||
buttonLayout->addWidget(m_cancelBtn);
|
||||
buttonLayout->addSpacing(VPNDETAILPAGE_BUTTON_SPACE);
|
||||
buttonLayout->addWidget(m_confimBtn);
|
||||
m_buttonFrame->setLayout(buttonLayout);
|
||||
}
|
||||
|
||||
void vpnAddPage::initConnection()
|
||||
{
|
||||
if (m_vpnNameLineEdit != nullptr) {
|
||||
connect(m_vpnNameLineEdit, &QLineEdit::textChanged, this, &vpnAddPage::onSetConfimBtnEnable);
|
||||
}
|
||||
|
||||
if (m_vpnServerLineEdit != nullptr) {
|
||||
connect(m_vpnServerLineEdit, &QLineEdit::textChanged, this, &vpnAddPage::onSetConfimBtnEnable);
|
||||
}
|
||||
|
||||
if (m_cancelBtn != nullptr) {
|
||||
connect(m_cancelBtn, &QPushButton::clicked, [&] () {this->close();});
|
||||
}
|
||||
|
||||
if (m_confimBtn != nullptr) {
|
||||
connect(m_confimBtn, &QPushButton::clicked, this, &vpnAddPage::onConfimBtnClicked);
|
||||
}
|
||||
}
|
||||
|
||||
bool vpnAddPage::checkConfimBtnIsEnabled()
|
||||
{
|
||||
if (m_vpnNameLineEdit->text().isEmpty()) {
|
||||
qDebug() << "ipv4address empty or invalid";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (m_vpnServerLineEdit->text().isEmpty()) {
|
||||
qDebug() << "ipv4 netMask empty or invalid";
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void vpnAddPage::onSetConfimBtnEnable()
|
||||
{
|
||||
m_confimBtn->setEnabled(checkConfimBtnIsEnabled());
|
||||
}
|
||||
|
||||
void vpnAddPage::onConfimBtnClicked()
|
||||
{
|
||||
//新建有线连接
|
||||
qDebug() << "Confirm create vpn connect";
|
||||
if (!createVpnConnect()) {
|
||||
// setNetdetailSomeEnable(true);
|
||||
// return;
|
||||
}
|
||||
close();
|
||||
}
|
||||
|
||||
bool vpnAddPage::createVpnConnect()
|
||||
{
|
||||
KyVpnConfig vpnSetting;
|
||||
QString connectName = m_vpnNameLineEdit->text();
|
||||
vpnSetting.m_gateway = m_vpnServerLineEdit->text();
|
||||
vpnSetting.setConnectName(connectName);
|
||||
vpnSetting.m_vpnName = connectName;
|
||||
vpnSetting.m_isAutoConnect = m_autoConnectBox->isChecked();
|
||||
vpnSetting.m_vpnType = (KyVpnType)m_vpnTypeComboBox->currentData().toInt();
|
||||
|
||||
m_vpnConnOperation->createVpnConnect(vpnSetting);
|
||||
return true;
|
||||
}
|
||||
|
||||
vpnAddPage::~vpnAddPage()
|
||||
{
|
||||
Q_EMIT this->closed();
|
||||
}
|
|
@ -0,0 +1,90 @@
|
|||
#ifndef VPNADDPAGE_H
|
||||
#define VPNADDPAGE_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QVBoxLayout>
|
||||
#include <QHBoxLayout>
|
||||
#include <QFrame>
|
||||
#include <QLabel>
|
||||
#include <QLineEdit>
|
||||
#include <QComboBox>
|
||||
#include <QCheckBox>
|
||||
#include <QPushButton>
|
||||
#include <QFormLayout>
|
||||
#include <QDesktopWidget>
|
||||
#include <QApplication>
|
||||
|
||||
#include "kyvpnconnectoperation.h"
|
||||
|
||||
#define VPNADDPAGE_MAINLAYOUT_MARGINS 0, 12, 0, 12
|
||||
#define VPNADDPAGE_ITEM_MARGINS 24, 0, 24, 0
|
||||
#define VPNADDPAGE_NULLMAGINS 0, 0, 0, 0
|
||||
|
||||
#define VPNADDPAGE_SIZE 520,312
|
||||
#define VPNADDPAGE_FRAME_FIXEDSIZE 520, 60
|
||||
#define VPNADDPAGE_BUTTON_FIXEDSIZE 96, 36
|
||||
|
||||
#define VPNADDPAGE_NULLSPACE 0
|
||||
#define VPNADDPAGE_BUTTON_SPACE 16
|
||||
#define VPNADDPAGE_NAME_MAX_LENGTH 32
|
||||
#define VPNADDPAGE_LABLE_FIXEDWIDTH 112
|
||||
#define VPNADDPAGE_COMBOBOX_FIXEDWIDTH 360
|
||||
#define VPNADDPAGE_INPUTBOX_FIXEDWIDTH 360
|
||||
|
||||
#define VPNDETAILPAGE_ITEM_MARGINS 24, 0, 24, 0
|
||||
#define VPNDETAILPAGE_NULLMAGINS 0, 0, 0, 0
|
||||
|
||||
#define VPNDETAILPAGE_FRAME_FIXEDSIZE 520, 60
|
||||
#define VPNDETAILPAGE_BUTTON_FIXEDSIZE 96, 36
|
||||
|
||||
#define VPNDETAILPAGE_NULLSPACE 0
|
||||
#define VPNDETAILPAGE_BUTTON_SPACE 16
|
||||
|
||||
|
||||
|
||||
class vpnAddPage : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit vpnAddPage(QWidget *parent = nullptr);
|
||||
void centerToScreen();
|
||||
~vpnAddPage();
|
||||
|
||||
private:
|
||||
void initWindow();
|
||||
void initUI();
|
||||
void initVpnTypeFrame();
|
||||
void initVpnNameFrame();
|
||||
void initVpnServerFrame();
|
||||
void initButtonFrame();
|
||||
|
||||
void initConnection();
|
||||
|
||||
bool checkConfimBtnIsEnabled();
|
||||
bool createVpnConnect();
|
||||
|
||||
private:
|
||||
QFrame *m_vpnTypeFrame = nullptr;
|
||||
QFrame *m_vpnNameFrame = nullptr;
|
||||
QFrame *m_vpnServerFrame = nullptr;
|
||||
QFrame *m_buttonFrame = nullptr;
|
||||
|
||||
QComboBox *m_vpnTypeComboBox = nullptr;
|
||||
QLineEdit *m_vpnNameLineEdit = nullptr;
|
||||
QLineEdit *m_vpnServerLineEdit = nullptr;
|
||||
|
||||
QPushButton *m_confimBtn = nullptr;
|
||||
QPushButton *m_cancelBtn = nullptr;
|
||||
QCheckBox *m_autoConnectBox = nullptr;
|
||||
|
||||
KyVpnConnectOperation *m_vpnConnOperation = nullptr;
|
||||
|
||||
private Q_SLOTS:
|
||||
void onConfimBtnClicked();
|
||||
void onSetConfimBtnEnable();
|
||||
|
||||
Q_SIGNALS:
|
||||
void closed();
|
||||
};
|
||||
|
||||
#endif // VPNADDPAGE_H
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,197 @@
|
|||
#ifndef VPNADVANCEDPAGE_H
|
||||
#define VPNADVANCEDPAGE_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QFrame>
|
||||
#include <QVBoxLayout>
|
||||
#include <QHBoxLayout>
|
||||
#include <QGridLayout>
|
||||
#include <QFormLayout>
|
||||
#include <QLabel>
|
||||
#include <QLineEdit>
|
||||
#include <QCheckBox>
|
||||
#include <QComboBox>
|
||||
#include <QListWidget>
|
||||
#include "kylable.h"
|
||||
#include "kwidget.h"
|
||||
#include "kpasswordedit.h"
|
||||
#include "vpnconfigpage.h"
|
||||
#include "kyvpnconnectoperation.h"
|
||||
|
||||
using namespace kdk;
|
||||
|
||||
enum TlsMode {
|
||||
NONE = 0,
|
||||
TLS_CERT,
|
||||
TLS_ENCRYPTION
|
||||
};
|
||||
|
||||
enum ProxyType {
|
||||
NO = 0,
|
||||
HTTP,
|
||||
SOCKS
|
||||
};
|
||||
|
||||
class VpnAdvancedPage : public QFrame
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
VpnAdvancedPage(QWidget *parent = nullptr);
|
||||
~VpnAdvancedPage() = default;
|
||||
|
||||
//Adia: Advanced
|
||||
void setL2tpOrPptpAdiaInfo(const KyVpnConfig &vpnInfo);
|
||||
void setOpenVpnAdiaInfo(const KyVpnConfig &vpnInfo);
|
||||
void setStrongSwanAdiaInfo(const KyVpnConfig &vpnInfo);
|
||||
|
||||
bool checkIsChanged(const KyVpnConfig &vpnInfo, VpnType &vpnType);
|
||||
bool checkL2tpIsChanged(const KyVpnConfig &vpnInfo);
|
||||
bool checkPptpIsChanged(const KyVpnConfig &vpnInfo);
|
||||
bool checkOpenVpnIsChanged(const KyVpnConfig &vpnInfo);
|
||||
bool checkStrongSwanIsChanged(const KyVpnConfig &vpnInfo);
|
||||
|
||||
void updateL2tpOrPptpAdiaInfo(KyVpnConfig &vpnInfo);
|
||||
void updateOpenVpnAdiaInfo(KyVpnConfig &vpnInfo);
|
||||
void updateStrongSwanAdiaInfo(KyVpnConfig &vpnInfo);
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *event);
|
||||
|
||||
private:
|
||||
bool m_isOpenVpn;
|
||||
|
||||
QFrame *m_defaultAdiaFrame;
|
||||
QFrame *m_mruFrame;
|
||||
QFrame *m_openVpnAdiaFrame;
|
||||
QFrame *m_sSwanAdiaFrame;
|
||||
|
||||
//L2TP PPTP Encryption(E)
|
||||
QCheckBox *m_mppeECheckbox = nullptr;
|
||||
QCheckBox *m_useStatefulECheckbox = nullptr;
|
||||
QCheckBox *m_sendPppEchoPkgCheckbox = nullptr;
|
||||
|
||||
QLabel *m_authModeLabel;
|
||||
QLabel *m_compModeLabel;
|
||||
QLabel *m_mruLabel;
|
||||
QLabel *m_mtuLabel;
|
||||
QLineEdit *m_mruEdit;
|
||||
QLineEdit *m_mtuEdit;
|
||||
QComboBox *m_mppeECombox = nullptr;
|
||||
//认证方式
|
||||
QListWidget *m_authModeListWidget = nullptr;
|
||||
QCheckBox *m_papAuthCheckbox = nullptr;
|
||||
QCheckBox *m_chapAuthCheckbox = nullptr;
|
||||
QCheckBox *m_mschapAuthCheckbox = nullptr;
|
||||
QCheckBox *m_mschap2AuthCheckbox = nullptr;
|
||||
QCheckBox *m_eapAuthCheckbox = nullptr;
|
||||
//压缩方式
|
||||
QListWidget *m_compModeListWidget = nullptr;
|
||||
QCheckBox *m_bsdCompModeCheckbox = nullptr;
|
||||
QCheckBox *m_defaultCompModeCheckbox = nullptr;
|
||||
QCheckBox *m_tcpCompModeCheckbox = nullptr;
|
||||
QCheckBox *m_protocolCompModeCheckbox = nullptr;
|
||||
QCheckBox *m_addressCompModeCheckbox = nullptr;
|
||||
|
||||
//Open VPN
|
||||
//general
|
||||
QCheckBox *m_customGatewayPortCheckbox = nullptr;
|
||||
QCheckBox *m_customRenegotiaInrCheckbox = nullptr;
|
||||
QCheckBox *m_compressionCheckbox = nullptr;
|
||||
QCheckBox *m_tcpConnCheckbox = nullptr;
|
||||
QCheckBox *m_setVDevTypeCheckbox = nullptr;
|
||||
QCheckBox *m_setVDevNameCheckbox = nullptr;
|
||||
QCheckBox *m_customMtuCheckbox = nullptr;
|
||||
QCheckBox *m_customUdpFragSizeCheckbox = nullptr;
|
||||
QCheckBox *m_tcpMssCheckbox = nullptr;
|
||||
QCheckBox *m_randomRemoteHostCheckbox = nullptr;
|
||||
QCheckBox *m_ipv6TunLinkCheckbox = nullptr;
|
||||
QCheckBox *m_specPingInrCheckbox = nullptr;
|
||||
QCheckBox *m_specExitPingCheckbox = nullptr;
|
||||
QCheckBox *m_acceptAuthedPaksCheckbox = nullptr;
|
||||
QCheckBox *m_specMaxRouteCheckbox = nullptr;
|
||||
|
||||
QLineEdit *m_gatewayPortEdit;
|
||||
QLineEdit *m_renogotiaInrEdit;
|
||||
QLineEdit *m_setVDevNameEdit;
|
||||
QLineEdit *m_customMtuEdit;
|
||||
QLineEdit *m_customUdpFragSizeEdit;
|
||||
QLineEdit *m_specPingInrEdit;
|
||||
QLineEdit *m_specExRePingEdit;
|
||||
QLineEdit *m_specMaxRouteEdit;
|
||||
QComboBox *m_compressionCombox = nullptr;
|
||||
QComboBox *m_setVDevTypeCombox = nullptr;
|
||||
QComboBox *m_specExitRestarCombox = nullptr;
|
||||
FixLabel *m_customRenoInrLabel;
|
||||
FixLabel *m_customMtuLabel;
|
||||
FixLabel *m_customUdpLabel;
|
||||
FixLabel *m_acceptAuthedPaksLabel;
|
||||
//TLS settings
|
||||
QLabel *m_subjectMatchLabel;
|
||||
QLabel *m_keyPathLabel;
|
||||
QLabel *m_keyDirectionLabel;
|
||||
QLineEdit *m_subjectMatchEdit;
|
||||
QLineEdit *m_keyPathEdit;
|
||||
QPushButton *m_keyPathChooseBtn;
|
||||
QCheckBox *m_usePreviousCertCheckbox = nullptr;
|
||||
QCheckBox *m_verifyPeerCertCheckbox = nullptr;
|
||||
QComboBox *m_serverCertCheckCombox = nullptr;
|
||||
QComboBox *m_usePreviousCertCombox = nullptr;
|
||||
QComboBox *m_verifyPeerCertCombox = nullptr;
|
||||
QComboBox *m_tlsModeCombox = nullptr;
|
||||
QComboBox *m_keyDirectionCombox = nullptr;
|
||||
//proxies
|
||||
QLabel *m_proxyServerAddLabel;
|
||||
QLabel *m_proxyPortLabel;
|
||||
QLabel *m_proxyUsernameLabel;
|
||||
QLabel *m_proxyPwdLabel;
|
||||
QComboBox *m_proxyTypeCombox = nullptr;
|
||||
QCheckBox *m_infiniteRetryCheckbox = nullptr;
|
||||
QLineEdit *m_proxyServerAddEdit;
|
||||
QLineEdit *m_proxyPortEdit;
|
||||
QLineEdit *m_proxyUsernameEdit;
|
||||
KPasswordEdit *m_proxyPwdEdit;
|
||||
//security
|
||||
QCheckBox *m_customKeySizeCheckbox = nullptr;
|
||||
QLineEdit *m_customKeySizeEdit;
|
||||
QComboBox *m_hmacAuthCombox = nullptr;
|
||||
|
||||
//strongswan
|
||||
QListWidget *m_optionsListWidget = nullptr;
|
||||
QCheckBox *m_requestInIPCheckbox = nullptr;
|
||||
QCheckBox *m_udpEncapCheckbox = nullptr;
|
||||
QCheckBox *m_ipCompCheckbox = nullptr;
|
||||
QCheckBox *m_enablCustomCheckbox = nullptr;
|
||||
QFrame *m_ikeEspFrame;
|
||||
QLineEdit *m_ikeEdit;
|
||||
QLineEdit *m_espEdit;
|
||||
|
||||
void initUi();
|
||||
void initConnect();
|
||||
void initDefaultAdiaFrame(); //L2TP PPTP
|
||||
void initOpenVpnAdiaFrame(); //Open VPN
|
||||
void initSSwanAdiaFrame(); //strong-swan
|
||||
void initDefalutCheckState();
|
||||
void addListItem(QListWidget *listWidget, QWidget *widget);
|
||||
void initCheckWidget(QCheckBox *checkBox, FixLabel *label, QWidget *widget);
|
||||
|
||||
void showL2tpAdiaPage();
|
||||
void showPptpAdiaPage();
|
||||
void showOpenVpnAdiaPage();
|
||||
void showSSwanAdiaPage();
|
||||
bool checkConfirmBtnIsEnabled();
|
||||
bool getTextEditState(QString text);
|
||||
|
||||
private Q_SLOTS:
|
||||
void onProxyTypeComboxIndexChanged();
|
||||
void onTlsModeComboxIndexChanged();
|
||||
void setEnableOfConfirmBtn();
|
||||
void onKeyPathButtonClicked();
|
||||
|
||||
public Q_SLOTS:
|
||||
void setVpnAdvancedPage(const VpnType &type);
|
||||
|
||||
Q_SIGNALS:
|
||||
void setAdvancedPageState(bool);
|
||||
};
|
||||
|
||||
#endif // VPNADVANCEDPAGE_H
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,198 @@
|
|||
#ifndef VPNCONFIGPAGE_H
|
||||
#define VPNCONFIGPAGE_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QFrame>
|
||||
#include <QLabel>
|
||||
#include <QLineEdit>
|
||||
#include <QComboBox>
|
||||
#include <QPushButton>
|
||||
#include <QVBoxLayout>
|
||||
#include <QHBoxLayout>
|
||||
#include <QGridLayout>
|
||||
|
||||
#include "kylable.h"
|
||||
#include "kwidget.h"
|
||||
#include "kpasswordedit.h"
|
||||
#include "kyvpnconnectoperation.h"
|
||||
|
||||
using namespace kdk;
|
||||
|
||||
#define KEY_DIRECTION_NONE_INDEX 0
|
||||
#define KEY_DIRECTION_ZERO_INDEX 1
|
||||
#define KEY_DIRECTION_ONE_INDEX 2
|
||||
|
||||
#define KEY_DIRECTION_NONE "None"
|
||||
#define KEY_DIRECTION_ZERO "0"
|
||||
#define KEY_DIRECTION_ONE "1"
|
||||
|
||||
enum VpnType {
|
||||
UNKNOW = -1,
|
||||
L2TP = 0,
|
||||
OPEN_VPN,
|
||||
PPTP,
|
||||
STRONG_SWAN
|
||||
};
|
||||
|
||||
enum OpenVpnAuthMethodIndex {
|
||||
CERTIFICATE_INDEX = 0,
|
||||
STATICPASSWD_INDEX,
|
||||
PASSWD_INDEX,
|
||||
CERTIFICATEANDPASSWD_INDEX,
|
||||
};
|
||||
enum StrongSwanAuthMethodIndex {
|
||||
KEY_INDEX = 0,
|
||||
AGENT_INDEX,
|
||||
SMARTCARD_INDEX,
|
||||
EAP_INDEX,
|
||||
};
|
||||
|
||||
class VpnConfigPage : public QFrame
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit VpnConfigPage(QWidget *parent = nullptr);
|
||||
~VpnConfigPage() = default;
|
||||
|
||||
VpnType getVpnType();
|
||||
void setVpnConfigInfo(const KyVpnConfig &vpnInfo);
|
||||
bool checkIsChanged(const KyVpnConfig &vpnInfo);
|
||||
|
||||
void updateVpnConfigInfo(KyVpnConfig &vpnInfo);
|
||||
|
||||
private:
|
||||
QFrame *m_vpnCommunalFrame;
|
||||
QFrame *m_authModeFrame;
|
||||
QFrame *m_caCertFrame;
|
||||
QFrame *m_userCertFrame;
|
||||
QFrame *m_staticKeysFrame;
|
||||
QFrame *m_pinFrame;
|
||||
QFrame *m_PrivateKeysFrame;
|
||||
QFrame *m_usersFrame;
|
||||
QFrame *m_userPwdOpFrame;
|
||||
QFrame *m_ntFrame;
|
||||
|
||||
//公有
|
||||
QLabel *m_vpnTypeLabel;
|
||||
QLabel *m_vpnNameLabel;
|
||||
FixLabel *m_serverAddressLabel;
|
||||
QComboBox *m_vpnTypeComboBox = nullptr;
|
||||
QLineEdit *m_vpnNameEdit = nullptr;
|
||||
QLineEdit *m_serverAddressEdit = nullptr;
|
||||
|
||||
//认证方式 Authentication Mode
|
||||
FixLabel *m_authModeLabel;
|
||||
QComboBox *m_authModeComboBox = nullptr;
|
||||
|
||||
//证书 私钥
|
||||
FixLabel *m_caCertLabel;
|
||||
FixLabel *m_userCertLabel;
|
||||
FixLabel *m_privateKeyLabel;
|
||||
FixLabel *m_privateKeyPwdLabel;
|
||||
FixLabel *m_pwdOptionLabel;
|
||||
|
||||
QLineEdit *m_caCertPathEdit;
|
||||
QLineEdit *m_userCertPathEdit;
|
||||
QLineEdit *m_privateKeyEdit;
|
||||
KPasswordEdit *m_privateKeyPwdEdit;
|
||||
QComboBox *m_pwdOptionCombox;
|
||||
|
||||
QPushButton *m_caCertButton;
|
||||
QPushButton *m_userCertButton;
|
||||
QPushButton *m_privateKeyButton;
|
||||
|
||||
//静态密钥
|
||||
QLabel *m_staticKeyLabel;
|
||||
FixLabel *m_keyDirectionLabel;
|
||||
QLabel *m_noticesLabel;
|
||||
QLabel *m_localIpLabel;
|
||||
QLabel *m_remoteIpLabel;
|
||||
|
||||
QLineEdit *m_staticKeyPathEdit;
|
||||
QPushButton *m_staticKeyButton;
|
||||
QComboBox *m_keyDirectionCombox;
|
||||
QLineEdit *m_localIpEdit;
|
||||
QLineEdit *m_remoteIpEdit;
|
||||
|
||||
//智能卡 PIN码
|
||||
QLabel *m_pinLabel;
|
||||
QLineEdit *m_pinEdit;
|
||||
|
||||
//密码
|
||||
FixLabel *m_usernameLabel;
|
||||
QLabel *m_userPwdLabel;
|
||||
FixLabel *m_userPwdOptionLabel;
|
||||
QLineEdit *m_usernameEdit;
|
||||
KPasswordEdit *m_userPwdEdit;
|
||||
QComboBox *m_userPwdOptionCombox;
|
||||
|
||||
//L2TP PPTP公有
|
||||
QLabel *m_ntDomainLabel;
|
||||
QLineEdit *m_ntDomainEdit;
|
||||
|
||||
|
||||
void initUI();
|
||||
void initConnect();
|
||||
void showL2tpPwd();
|
||||
void showPptpPwd();
|
||||
void showOpenVpnTls();
|
||||
void showOpenVpnPwd();
|
||||
void showOpenVpnPwdTls();
|
||||
void showOpenVpnStaticKey();
|
||||
void showSswanCertPrivteKey();
|
||||
void showSswanCertSsh();
|
||||
void showSswanSmartCard();
|
||||
void showSswanEap();
|
||||
|
||||
bool getTextEditState(QString text);
|
||||
bool checkConfirmBtnIsEnabled();
|
||||
|
||||
|
||||
//填充VPN认证信息
|
||||
void setPwdAuthInfo(const QString &username, const QString &userPwd, const KyPasswdPolicy &userPwdPolicy);
|
||||
void setCaCertAuthInfo(const QString &caCertificate);
|
||||
|
||||
void setKeyAuthInfo(const QString &userCert, const QString &privateKey,
|
||||
const QString &privateKeyPwd, const KyPasswdPolicy &privatePwdPolicy);
|
||||
|
||||
void setStaticKeyAuthInfo(const QString &staticKey, const QString &vpnKeyDirection,
|
||||
const QString &localIp, const QString &remoteIp);
|
||||
|
||||
void setAgentAuthInfo(const QString &userCert);
|
||||
void setSmartCardAuthInfo(const QString &pin);
|
||||
void setEapAuthInfo(const QString &username, const QString &userPwd);
|
||||
void setNtDomain(const QString &ntDomain);
|
||||
|
||||
//set info
|
||||
void setL2tpConfigInfo(const KyVpnConfig &vpnInfo);
|
||||
void setPptpConfigInfo(const KyVpnConfig &vpnInfo);
|
||||
void setOpenVpnConfigInfo(const KyVpnConfig &vpnInfo);
|
||||
void setSSwanVpnConfigInfo(const KyVpnConfig &vpnInfo);
|
||||
|
||||
//check change
|
||||
bool checkL2tpIsChanged(const KyVpnConfig &vpnInfo);
|
||||
bool checkPptpIsChanged(const KyVpnConfig &vpnInfo);
|
||||
bool checkOpenVpnIsChanged(const KyVpnConfig &vpnInfo);
|
||||
bool checkStrongSwanIsChanged(const KyVpnConfig &vpnInfo);
|
||||
|
||||
//update
|
||||
void updateL2tpConfigInfo(KyVpnConfig &vpnInfo);
|
||||
void updatePptpConfigInfo(KyVpnConfig &vpnInfo);
|
||||
void updateOpenVpnConfigInfo(KyVpnConfig &vpnInfo);
|
||||
void updateSSwanVpnConfigInfo(KyVpnConfig &vpnInfo);
|
||||
|
||||
private Q_SLOTS:
|
||||
void onVpnTypeComboxIndexChanged();
|
||||
void onAuthModeComboxIndexChanged();
|
||||
void setEnableOfConfirmBtn();
|
||||
void onCaCertButtonClicked();
|
||||
void onUserCertButtonClicked();
|
||||
void onStaticKeyButtonClicked();
|
||||
void onPrivateKeyButtonClicked();
|
||||
|
||||
Q_SIGNALS:
|
||||
void setConfigPageState(bool);
|
||||
void vpnTypeChanged(VpnType type);
|
||||
};
|
||||
|
||||
#endif // VPNCONFIGPAGE_H
|
|
@ -0,0 +1,439 @@
|
|||
#include "vpndetail.h"
|
||||
|
||||
#define WINDOW_WIDTH 520
|
||||
#define WINDOW_HEIGHT 562
|
||||
#define NO_LAYOUT_MARGINS 0,0,0,0
|
||||
#define HLAYOUT_MARGINS 24,0,24,0
|
||||
#define CENTER_LAYOUT_MARGINS 24,0,0,0
|
||||
#define NO_SPACE 0
|
||||
#define HLAYOUT_SPACING 16
|
||||
#define VLAYOUT_SPACING 24
|
||||
#define BOTTOM_WIDGET_HEIGHT 85
|
||||
#define TAB_HEIGHT 36
|
||||
#define TAB_WIDTH 80
|
||||
#define MAX_TAB_TEXT_LENGTH 44
|
||||
#define VPNTAB_WIDTH 240
|
||||
#define PAGE_WIDTH 472
|
||||
#define SCRO_WIDTH 496
|
||||
#define CONFIG_PAGE_NUM 0
|
||||
#define IPV4_PAGE_NUM 1
|
||||
#define IPV6_PAGE_NUM 2
|
||||
#define ADVANCED_PAGE_NUM 3
|
||||
#define NORMAL_PAGE_COUNT 3
|
||||
#define LOG_FLAG "[VPN Detail]"
|
||||
#define TAB_HEIGHT_TABLET 48
|
||||
|
||||
VpnDetail::VpnDetail(QString vpnUuid, QString vpnName, QWidget *parent) :
|
||||
m_vpnName(vpnName),
|
||||
m_uuid(vpnUuid),
|
||||
QWidget(parent)
|
||||
{
|
||||
initWindow();
|
||||
centerToScreen();
|
||||
getVpnConfig(m_uuid, m_vpnInfo);
|
||||
|
||||
initUI();
|
||||
initConnection();
|
||||
pagePadding(m_isOpenVpn);
|
||||
|
||||
m_isConfigOk = true;
|
||||
m_isIpv4Ok = true;
|
||||
m_isIpv6Ok = true;
|
||||
m_isAdvancedOk = true;
|
||||
setConfirmEnable();
|
||||
}
|
||||
|
||||
void VpnDetail::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
QPalette pal = qApp->palette();
|
||||
QPainter painter(this);
|
||||
painter.setBrush(pal.color(QPalette::Base));
|
||||
painter.drawRect(this->rect());
|
||||
painter.fillRect(rect(), QBrush(pal.color(QPalette::Base)));
|
||||
|
||||
return QWidget::paintEvent(event);
|
||||
}
|
||||
|
||||
|
||||
void VpnDetail::initWindow()
|
||||
{
|
||||
this->setFixedSize(WINDOW_WIDTH, WINDOW_HEIGHT);
|
||||
this->setWindowTitle(tr("VPN"));
|
||||
this->setAttribute(Qt::WA_DeleteOnClose);
|
||||
}
|
||||
|
||||
void VpnDetail::initTabBar()
|
||||
{
|
||||
//文本长度超出显示区域设置tooltip
|
||||
int tabCount = m_vpnTabBar->count();
|
||||
for (int i = 0; i< tabCount; ++i) {
|
||||
QFontMetrics fontMetrics(m_vpnTabBar->font());
|
||||
int fontSize = fontMetrics.width(m_vpnTabBar->tabText(i));
|
||||
if (fontSize > MAX_TAB_TEXT_LENGTH) {
|
||||
m_vpnTabBar->setTabToolTip(i, m_vpnTabBar->tabText(i));
|
||||
} else {
|
||||
m_vpnTabBar->setTabToolTip(i, "");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void VpnDetail::initUI()
|
||||
{
|
||||
//控件
|
||||
m_topWidget = new QWidget(this);
|
||||
m_centerWidget = new QWidget(this);
|
||||
m_bottomWidget = new QWidget(this);
|
||||
m_divider = new Divider(this);
|
||||
m_vpnTabBar = new VpnTabBar(this);
|
||||
m_autoConnectBox = new QCheckBox(this);
|
||||
m_autoConnectLabel = new QLabel(this);
|
||||
m_cancelBtn = new QPushButton(this);
|
||||
m_confimBtn = new QPushButton(this);
|
||||
m_stackWidget = new QStackedWidget(m_centerWidget);
|
||||
|
||||
m_configPage = new VpnConfigPage(this);
|
||||
m_ipv4Page = new VpnIpv4Page(this);
|
||||
m_ipv6Page = new VpnIpv6Page(this);
|
||||
m_advancedPage = new VpnAdvancedPage(this);
|
||||
|
||||
m_configScroArea = new QScrollArea(m_centerWidget);
|
||||
m_configScroArea->setFrameShape(QFrame::NoFrame);
|
||||
m_configScroArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
m_configScroArea->setWidget(m_configPage);
|
||||
m_configScroArea->setWidgetResizable(true);
|
||||
|
||||
m_ipv4ScroArea = new QScrollArea(m_centerWidget);
|
||||
m_ipv4ScroArea->setFrameShape(QFrame::NoFrame);
|
||||
m_ipv4ScroArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
m_ipv4ScroArea->setWidget(m_ipv4Page);
|
||||
m_ipv4ScroArea->setWidgetResizable(true);
|
||||
|
||||
m_ipv6ScroArea = new QScrollArea(m_centerWidget);
|
||||
m_ipv6ScroArea->setFrameShape(QFrame::NoFrame);
|
||||
m_ipv6ScroArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
m_ipv6ScroArea->setWidget(m_ipv6Page);
|
||||
m_ipv6ScroArea->setWidgetResizable(true);
|
||||
|
||||
m_advancedScroArea = new QScrollArea(m_centerWidget);
|
||||
m_advancedScroArea->setFrameShape(QFrame::NoFrame);
|
||||
m_advancedScroArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
m_advancedScroArea->setWidget(m_advancedPage);
|
||||
m_advancedScroArea->setWidgetResizable(true);
|
||||
|
||||
QPalette pal = m_configScroArea->palette();
|
||||
pal.setBrush(QPalette::Window, Qt::transparent);
|
||||
m_configScroArea->setPalette(pal);
|
||||
m_ipv4ScroArea->setPalette(pal);
|
||||
m_ipv6ScroArea->setPalette(pal);
|
||||
m_advancedScroArea->setPalette(pal);
|
||||
|
||||
m_configPage->setFixedWidth(PAGE_WIDTH);
|
||||
m_ipv4Page->setFixedWidth(PAGE_WIDTH);
|
||||
m_ipv6Page->setFixedWidth(PAGE_WIDTH);
|
||||
m_advancedPage->setFixedWidth(PAGE_WIDTH);
|
||||
m_configScroArea->setFixedWidth(SCRO_WIDTH);
|
||||
m_ipv4ScroArea->setFixedWidth(SCRO_WIDTH);
|
||||
m_ipv6ScroArea->setFixedWidth(SCRO_WIDTH);
|
||||
m_advancedScroArea->setFixedWidth(SCRO_WIDTH);
|
||||
|
||||
m_stackWidget->addWidget(m_configScroArea);
|
||||
m_stackWidget->addWidget(m_ipv4ScroArea);
|
||||
m_stackWidget->addWidget(m_ipv6ScroArea);
|
||||
m_stackWidget->addWidget(m_advancedScroArea);
|
||||
|
||||
//控件显示文本
|
||||
m_vpnTabBar->addTab(tr("VPN"));
|
||||
m_vpnTabBar->addTab(tr("IPv4"));
|
||||
if (m_isOpenVpn) {
|
||||
m_vpnTabBar->addTab(tr("IPv6"));
|
||||
m_vpnTabBar->setFixedWidth(VPNTAB_WIDTH + TAB_WIDTH);
|
||||
} else {
|
||||
m_vpnTabBar->setFixedWidth(VPNTAB_WIDTH);
|
||||
}
|
||||
m_vpnTabBar->addTab(tr("Advanced"));
|
||||
m_vpnTabBar->setFixedHeight(TAB_HEIGHT);
|
||||
initTabBar();
|
||||
|
||||
m_autoConnectBox->setChecked(false);
|
||||
m_autoConnectLabel->setText(tr("Auto Connection"));
|
||||
m_cancelBtn->setText(tr("Cancel"));
|
||||
m_confimBtn->setText(tr("Confirm"));
|
||||
|
||||
//布局
|
||||
QVBoxLayout *mainLayout = new QVBoxLayout(this);
|
||||
mainLayout->setContentsMargins(NO_LAYOUT_MARGINS);
|
||||
mainLayout->setSpacing(NO_SPACE);
|
||||
mainLayout->addSpacing(HLAYOUT_SPACING);
|
||||
mainLayout->addWidget(m_topWidget);
|
||||
mainLayout->addSpacing(VLAYOUT_SPACING);
|
||||
mainLayout->addWidget(m_centerWidget);
|
||||
mainLayout->addStretch();
|
||||
mainLayout->addWidget(m_divider);
|
||||
mainLayout->addWidget(m_bottomWidget);
|
||||
m_bottomWidget->setFixedHeight(BOTTOM_WIDGET_HEIGHT);
|
||||
|
||||
QHBoxLayout *topLayout = new QHBoxLayout(m_topWidget);
|
||||
topLayout->setContentsMargins(HLAYOUT_MARGINS);
|
||||
topLayout->addWidget(m_vpnTabBar, Qt::AlignCenter);
|
||||
|
||||
QVBoxLayout *centerlayout = new QVBoxLayout(m_centerWidget);
|
||||
centerlayout->setContentsMargins(CENTER_LAYOUT_MARGINS); // 右边距为0,为安全页滚动区域留出空间
|
||||
centerlayout->addWidget(m_stackWidget);
|
||||
|
||||
QHBoxLayout *bottomLayout = new QHBoxLayout(m_bottomWidget);
|
||||
bottomLayout->setContentsMargins(HLAYOUT_MARGINS);
|
||||
bottomLayout->setSpacing(NO_SPACE);
|
||||
bottomLayout->addWidget(m_autoConnectBox);
|
||||
bottomLayout->addSpacing(8);
|
||||
bottomLayout->addWidget(m_autoConnectLabel);
|
||||
bottomLayout->addStretch();
|
||||
bottomLayout->addWidget(m_cancelBtn);
|
||||
bottomLayout->addSpacing(HLAYOUT_SPACING);
|
||||
bottomLayout->addWidget(m_confimBtn);
|
||||
|
||||
m_advancedPage->setVpnAdvancedPage(m_configPage->getVpnType());
|
||||
}
|
||||
|
||||
void VpnDetail::initConnection()
|
||||
{
|
||||
connect(m_vpnTabBar, &VpnTabBar::currentChanged, this, &VpnDetail::onTabCurrentRowChange);
|
||||
connect(m_cancelBtn, &QPushButton::clicked, [&] () {this->close();});
|
||||
connect(m_confimBtn, &QPushButton::clicked, this, &VpnDetail::onConfimBtnClicked);
|
||||
|
||||
connect(m_configPage, &VpnConfigPage::setConfigPageState, this, [=] (bool state) {
|
||||
m_isConfigOk = state;
|
||||
setConfirmEnable();
|
||||
});
|
||||
connect(m_ipv4Page, &VpnIpv4Page::setIpv4PageState, this, [=] (bool state) {
|
||||
m_isIpv4Ok = state;
|
||||
setConfirmEnable();
|
||||
});
|
||||
connect(m_ipv6Page, &VpnIpv6Page::setIpv6PageState, this, [=] (bool state) {
|
||||
m_isIpv6Ok = state;
|
||||
setConfirmEnable();
|
||||
});
|
||||
connect(m_advancedPage, &VpnAdvancedPage::setAdvancedPageState, this, [=] (bool state) {
|
||||
m_isAdvancedOk = state;
|
||||
setConfirmEnable();
|
||||
});
|
||||
|
||||
connect(m_configPage, &VpnConfigPage::vpnTypeChanged, m_advancedPage, &VpnAdvancedPage::setVpnAdvancedPage);
|
||||
|
||||
connect(m_configPage, &VpnConfigPage::vpnTypeChanged, this, [=](VpnType type) {
|
||||
if (type == OPEN_VPN) {
|
||||
if (m_vpnTabBar->count() == NORMAL_PAGE_COUNT) {
|
||||
m_vpnTabBar->insertTab(IPV6_PAGE_NUM, tr("IPv6"));
|
||||
m_vpnTabBar->setFixedWidth(VPNTAB_WIDTH + TAB_WIDTH);
|
||||
}
|
||||
} else {
|
||||
if (m_vpnTabBar->count() > NORMAL_PAGE_COUNT) {
|
||||
m_vpnTabBar->removeTab(IPV6_PAGE_NUM);
|
||||
m_vpnTabBar->setFixedWidth(VPNTAB_WIDTH);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void VpnDetail::centerToScreen()
|
||||
{
|
||||
QDesktopWidget* m = QApplication::desktop();
|
||||
QRect desk_rect = m->screenGeometry(m->screenNumber(QCursor::pos()));
|
||||
int desk_x = desk_rect.width();
|
||||
int desk_y = desk_rect.height();
|
||||
int x = this->width();
|
||||
int y = this->height();
|
||||
this->move(desk_x / 2 - x / 2 + desk_rect.left(), desk_y / 2 - y / 2 + desk_rect.top());
|
||||
}
|
||||
|
||||
void VpnDetail::setConfirmEnable()
|
||||
{
|
||||
bool isConfirmBtnEnable = false;
|
||||
if (m_isConfigOk && m_isIpv4Ok && m_isAdvancedOk) {
|
||||
if (m_isOpenVpn && !m_isIpv6Ok) {
|
||||
isConfirmBtnEnable = false;
|
||||
} else {
|
||||
isConfirmBtnEnable = true;
|
||||
}
|
||||
}
|
||||
m_confimBtn->setEnabled(isConfirmBtnEnable);
|
||||
}
|
||||
|
||||
void VpnDetail::getVpnConfig(QString connectUuid, KyVpnConfig &vpnInfo)
|
||||
{
|
||||
KyVpnConnectOperation vpnConnect(this);
|
||||
vpnInfo = vpnConnect.getVpnConfig(connectUuid);
|
||||
m_isOpenVpn = m_vpnInfo.m_vpnType == KYVPNTYPE_OPENVPN;
|
||||
}
|
||||
|
||||
void VpnDetail::pagePadding(bool isOpenVpn)
|
||||
{
|
||||
m_autoConnectBox->setChecked(m_vpnInfo.m_isAutoConnect);
|
||||
|
||||
//配置页面填充
|
||||
m_configPage->setVpnConfigInfo(m_vpnInfo);
|
||||
|
||||
//IPv4页面填充
|
||||
m_ipv4Page->setVpnIpv4Info(m_vpnInfo);
|
||||
if (!m_vpnInfo.m_ipv4Dns.isEmpty()) {
|
||||
m_ipv4Page->setDns(m_vpnInfo.m_ipv4Dns.at(0).toString());
|
||||
}
|
||||
if (!m_vpnInfo.m_ipv4DnsSearch.isEmpty()) {
|
||||
m_ipv4Page->setSearchDomain(m_vpnInfo.m_ipv4DnsSearch.at(0));
|
||||
}
|
||||
m_ipv4Page->setDhcpClientId(m_vpnInfo.m_ipv4DhcpClientId);
|
||||
//IPv6页面填充
|
||||
if (isOpenVpn) {
|
||||
m_ipv6Page->setVpnIpv6Info(m_vpnInfo);
|
||||
if (!m_vpnInfo.m_ipv6Dns.isEmpty()) {
|
||||
m_ipv6Page->setDns(m_vpnInfo.m_ipv6Dns.at(0).toString());
|
||||
}
|
||||
if (!m_vpnInfo.m_ipv6DnsSearch.isEmpty()) {
|
||||
m_ipv6Page->setSearchDomain(m_vpnInfo.m_ipv6DnsSearch.at(0));
|
||||
}
|
||||
}
|
||||
|
||||
//高级页面填充
|
||||
if (m_vpnInfo.m_vpnType == KYVPNTYPE_L2TP || m_vpnInfo.m_vpnType == KYVPNTYPE_PPTP) {
|
||||
m_advancedPage->setL2tpOrPptpAdiaInfo(m_vpnInfo);
|
||||
} else if (m_vpnInfo.m_vpnType == KYVPNTYPE_OPENVPN) {
|
||||
m_advancedPage->setOpenVpnAdiaInfo(m_vpnInfo);
|
||||
} else if (m_vpnInfo.m_vpnType == KYVPNTYPE_STRONGSWAN) {
|
||||
m_advancedPage->setStrongSwanAdiaInfo(m_vpnInfo);
|
||||
}
|
||||
}
|
||||
|
||||
bool VpnDetail::updateVpnCnofig()
|
||||
{
|
||||
KyVpnConnectOperation vpnConnect(this);
|
||||
KyVpnConfig vpnConfig = m_vpnInfo;
|
||||
bool needUpdate = false;
|
||||
VpnType vpnType = m_configPage->getVpnType();
|
||||
|
||||
if (m_vpnInfo.m_isAutoConnect != m_autoConnectBox->isChecked()) {
|
||||
vpnConfig.m_isAutoConnect = m_autoConnectBox->isChecked();
|
||||
needUpdate = true;
|
||||
}
|
||||
|
||||
if (m_configPage->checkIsChanged(m_vpnInfo)) {
|
||||
m_configPage->updateVpnConfigInfo(vpnConfig);
|
||||
needUpdate = true;
|
||||
}
|
||||
|
||||
if (m_ipv4Page->checkIsChanged(m_vpnInfo)) {
|
||||
m_ipv4Page->updateVpnIpv4Info(vpnConfig);
|
||||
needUpdate = true;
|
||||
}
|
||||
|
||||
if (vpnType == OPEN_VPN) {
|
||||
if (m_ipv6Page->checkIsChanged(m_vpnInfo)) {
|
||||
m_ipv6Page->updateVpnIpv6Info(vpnConfig);
|
||||
needUpdate = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (m_advancedPage->checkIsChanged(m_vpnInfo, vpnType)) {
|
||||
if (vpnType == L2TP || vpnType == PPTP) {
|
||||
m_advancedPage->updateL2tpOrPptpAdiaInfo(vpnConfig);
|
||||
needUpdate = true;
|
||||
} else if (vpnType == OPEN_VPN) {
|
||||
m_advancedPage->updateOpenVpnAdiaInfo(vpnConfig);
|
||||
needUpdate = true;
|
||||
} else if (vpnType == STRONG_SWAN) {
|
||||
m_advancedPage->updateStrongSwanAdiaInfo(vpnConfig);
|
||||
needUpdate = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (needUpdate) {
|
||||
vpnConnect.setVpnConfig(m_uuid, vpnConfig);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void VpnDetail::setVpndetailSomeEnable(bool on)
|
||||
{
|
||||
m_configPage->setEnabled(on);
|
||||
m_ipv4Page->setEnabled(on);
|
||||
m_ipv6Page->setEnabled(on);
|
||||
m_advancedPage->setEnabled(on);
|
||||
m_cancelBtn->setEnabled(on);
|
||||
m_confimBtn->setEnabled(on);
|
||||
}
|
||||
|
||||
void VpnDetail::onTabCurrentRowChange(int row)
|
||||
{
|
||||
if (row < 2) {
|
||||
m_stackWidget->setCurrentIndex(row);
|
||||
} else {
|
||||
if (m_configPage->getVpnType() == OPEN_VPN) {
|
||||
m_stackWidget->setCurrentIndex(row);
|
||||
} else {
|
||||
m_stackWidget->setCurrentIndex(ADVANCED_PAGE_NUM);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void VpnDetail::onConfimBtnClicked()
|
||||
{
|
||||
qDebug() << "onConfimBtnClicked";
|
||||
setVpndetailSomeEnable(false);
|
||||
//更新连接
|
||||
qDebug() << "Confirm update connect";
|
||||
if (!updateVpnCnofig()) {
|
||||
setVpndetailSomeEnable(true);
|
||||
return;
|
||||
}
|
||||
close();
|
||||
}
|
||||
|
||||
|
||||
VpnTabBar::VpnTabBar(QWidget *parent)
|
||||
:KTabBar(KTabBarStyle::SegmentDark, parent)
|
||||
{
|
||||
//模式切换
|
||||
QDBusConnection::sessionBus().connect(QString("com.kylin.statusmanager.interface"),
|
||||
QString("/"),
|
||||
QString("com.kylin.statusmanager.interface"),
|
||||
QString("mode_change_signal"), this, SLOT(onModeChanged(bool)));
|
||||
//模式获取
|
||||
QDBusInterface interface(QString("com.kylin.statusmanager.interface"),
|
||||
QString("/"),
|
||||
QString("com.kylin.statusmanager.interface"),
|
||||
QDBusConnection::sessionBus());
|
||||
if(!interface.isValid()) {
|
||||
this->setFixedHeight(TAB_HEIGHT);
|
||||
return;
|
||||
}
|
||||
QDBusReply<bool> reply = interface.call("get_current_tabletmode");
|
||||
if (!reply.isValid()) {
|
||||
this->setFixedHeight(TAB_HEIGHT);
|
||||
return;
|
||||
}
|
||||
onModeChanged(reply.value());
|
||||
}
|
||||
|
||||
QSize VpnTabBar::sizeHint() const
|
||||
{
|
||||
QSize size = KTabBar::sizeHint();
|
||||
size.setWidth(TAB_WIDTH);
|
||||
return size;
|
||||
}
|
||||
|
||||
QSize VpnTabBar::minimumTabSizeHint(int index) const
|
||||
{
|
||||
Q_UNUSED(index)
|
||||
QSize size = KTabBar::minimumTabSizeHint(index);
|
||||
size.setWidth(TAB_WIDTH);
|
||||
return size;
|
||||
}
|
||||
|
||||
void VpnTabBar::onModeChanged(bool mode)
|
||||
{
|
||||
if (mode) {
|
||||
this->setFixedHeight(TAB_HEIGHT_TABLET); // 平板模式
|
||||
} else {
|
||||
this->setFixedHeight(TAB_HEIGHT); // PC模式
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,111 @@
|
|||
#ifndef VPNDETAIL_H
|
||||
#define VPNDETAIL_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QStackedWidget>
|
||||
#include <QVBoxLayout>
|
||||
#include <QCheckBox>
|
||||
#include <QScrollArea>
|
||||
#include <QDesktopWidget>
|
||||
#include <QApplication>
|
||||
#include <QPainter>
|
||||
|
||||
#include <QDBusMessage>
|
||||
#include <QDBusObjectPath>
|
||||
#include <QDBusInterface>
|
||||
#include <QDBusReply>
|
||||
|
||||
#include "kwidget.h"
|
||||
#include "ktabbar.h"
|
||||
#include "../tools/divider.h"
|
||||
#include "vpnconfigpage.h"
|
||||
#include "vpnipv4page.h"
|
||||
#include "vpnipv6page.h"
|
||||
#include "vpnadvancedpage.h"
|
||||
|
||||
#include "kyvpnconnectoperation.h"
|
||||
|
||||
|
||||
using namespace kdk;
|
||||
|
||||
class VpnTabBar : public KTabBar
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit VpnTabBar(QWidget *parent = nullptr);
|
||||
~VpnTabBar() = default;
|
||||
|
||||
protected:
|
||||
QSize sizeHint() const;
|
||||
QSize minimumTabSizeHint(int index) const;
|
||||
|
||||
private Q_SLOTS:
|
||||
void onModeChanged(bool mode);
|
||||
|
||||
};
|
||||
|
||||
class VpnDetail : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit VpnDetail(QString vpnUuid, QString vpnName, QWidget *parent = nullptr);
|
||||
void centerToScreen();
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *event);
|
||||
|
||||
private:
|
||||
void initUI();
|
||||
void initWindow();
|
||||
void initTabBar();
|
||||
|
||||
void initConnection();
|
||||
void setConfirmEnable();
|
||||
|
||||
void getVpnConfig(QString connectUuid, KyVpnConfig &vpnInfo);
|
||||
void pagePadding(bool isOpenVpn);
|
||||
|
||||
bool updateVpnCnofig();
|
||||
void setVpndetailSomeEnable(bool on);
|
||||
|
||||
bool m_isOpenVpn = false;
|
||||
QString m_vpnName;
|
||||
QString m_uuid;
|
||||
KyVpnConfig m_vpnInfo;
|
||||
|
||||
QStackedWidget * m_stackWidget;
|
||||
QWidget *m_topWidget;
|
||||
QWidget *m_centerWidget;
|
||||
Divider *m_divider = nullptr;
|
||||
QWidget *m_bottomWidget;
|
||||
|
||||
VpnConfigPage *m_configPage = nullptr;
|
||||
VpnIpv4Page *m_ipv4Page = nullptr;
|
||||
VpnIpv6Page *m_ipv6Page = nullptr;
|
||||
VpnAdvancedPage *m_advancedPage = nullptr;
|
||||
|
||||
QScrollArea *m_configScroArea = nullptr;
|
||||
QScrollArea *m_ipv4ScroArea = nullptr;
|
||||
QScrollArea *m_ipv6ScroArea = nullptr;
|
||||
QScrollArea *m_advancedScroArea = nullptr;
|
||||
VpnTabBar *m_vpnTabBar = nullptr;
|
||||
QCheckBox *m_autoConnectBox = nullptr;
|
||||
QLabel *m_autoConnectLabel;
|
||||
QPushButton *m_cancelBtn;
|
||||
QPushButton *m_confimBtn;
|
||||
|
||||
bool m_isConfigOk = false;
|
||||
bool m_isIpv4Ok = false;
|
||||
bool m_isIpv6Ok = false;
|
||||
bool m_isAdvancedOk = false;
|
||||
|
||||
protected Q_SLOTS:
|
||||
void onTabCurrentRowChange(int row);
|
||||
void onConfimBtnClicked();
|
||||
|
||||
Q_SIGNALS:
|
||||
void currentChanged(int);
|
||||
|
||||
};
|
||||
|
||||
#endif // VPNDETAIL_H
|
|
@ -0,0 +1,17 @@
|
|||
INCLUDEPATH += $$PWD
|
||||
|
||||
HEADERS += \
|
||||
$$PWD/vpnaddpage.h \
|
||||
$$PWD/vpnadvancedpage.h \
|
||||
$$PWD/vpnconfigpage.h \
|
||||
$$PWD/vpndetail.h \
|
||||
$$PWD/vpnipv4page.h \
|
||||
$$PWD/vpnipv6page.h
|
||||
|
||||
SOURCES += \
|
||||
$$PWD/vpnaddpage.cpp \
|
||||
$$PWD/vpnadvancedpage.cpp \
|
||||
$$PWD/vpnconfigpage.cpp \
|
||||
$$PWD/vpndetail.cpp \
|
||||
$$PWD/vpnipv4page.cpp \
|
||||
$$PWD/vpnipv6page.cpp
|
|
@ -0,0 +1,284 @@
|
|||
#include "vpnipv4page.h"
|
||||
#include "math.h"
|
||||
#include <QDebug>
|
||||
|
||||
#define NO_LAYOUT_MARGINS 0, 0, 0, 0
|
||||
#define NO_SPACE 0
|
||||
#define HLAYOUT_SPACING 16
|
||||
#define VLAYOUT_SPACING 24
|
||||
#define AUTO_CONFIG 0
|
||||
#define MANUAL_CONFIG 1
|
||||
#define LOG_FLAG "[VPN IPv4Page]"
|
||||
|
||||
VpnIpv4Page::VpnIpv4Page(QWidget *parent) : QFrame(parent)
|
||||
{
|
||||
initUI();
|
||||
initConnect();
|
||||
}
|
||||
|
||||
void VpnIpv4Page::setVpnIpv4Info(const KyVpnConfig &vpnInfo)
|
||||
{
|
||||
if (vpnInfo.m_ipv4ConfigIpType == CONFIG_IP_DHCP) {
|
||||
m_ipv4ConfigCombox->setCurrentIndex(AUTO_CONFIG);
|
||||
} else {
|
||||
m_ipv4ConfigCombox->setCurrentIndex(MANUAL_CONFIG);
|
||||
if (!vpnInfo.m_ipv4Address.isEmpty()) {
|
||||
m_ipv4addressEdit->setText(vpnInfo.m_ipv4Address.at(0).ip().toString());
|
||||
m_netMaskEdit->setText(vpnInfo.m_ipv4Address.at(0).netmask().toString());
|
||||
m_gateWayEdit->setText(vpnInfo.m_ipv4Address.at(0).gateway().toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void VpnIpv4Page::setDns(const QString &firstDns)
|
||||
{
|
||||
m_dnsServerEdit->setText(firstDns);
|
||||
}
|
||||
|
||||
void VpnIpv4Page::setSearchDomain(const QString &searchDomain)
|
||||
{
|
||||
m_searchDomainEdit->setText(searchDomain);
|
||||
}
|
||||
|
||||
void VpnIpv4Page::setDhcpClientId(const QString &dhcpId)
|
||||
{
|
||||
m_dhcpClientIdEdit->setText(dhcpId);
|
||||
}
|
||||
|
||||
bool VpnIpv4Page::checkIsChanged(const KyVpnConfig &vpnInfo)
|
||||
{
|
||||
bool isChanged = false;
|
||||
|
||||
if (m_ipv4ConfigCombox->currentIndex() == AUTO_CONFIG) {
|
||||
if (vpnInfo.m_ipv4ConfigIpType != CONFIG_IP_DHCP) {
|
||||
qDebug() << LOG_FLAG << "ipv4ConfigType change to Auto";
|
||||
isChanged = true;
|
||||
}
|
||||
} else {
|
||||
if (vpnInfo.m_ipv4ConfigIpType != CONFIG_IP_MANUAL) {
|
||||
qDebug() << LOG_FLAG << "ipv4ConfigType change to Manual";
|
||||
isChanged = true;
|
||||
}
|
||||
|
||||
if (!vpnInfo.m_ipv4Address.isEmpty()) {
|
||||
if(vpnInfo.m_ipv4Address.at(0).ip().toString() != m_ipv4addressEdit->text()
|
||||
|| vpnInfo.m_ipv4Address.at(0).netmask().toString() != getNetMaskText(m_netMaskEdit->text())
|
||||
|| vpnInfo.m_ipv4Address.at(0).gateway().toString() != m_gateWayEdit->text()) {
|
||||
|
||||
isChanged = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!vpnInfo.m_ipv4Dns.isEmpty() && vpnInfo.m_ipv4Dns.at(0).toString() != m_dnsServerEdit->text()) {
|
||||
isChanged = true;
|
||||
}
|
||||
|
||||
if (!vpnInfo.m_ipv4DnsSearch.isEmpty() && vpnInfo.m_ipv4DnsSearch.at(0) != m_searchDomainEdit->text()) {
|
||||
isChanged = true;
|
||||
}
|
||||
if (vpnInfo.m_ipv4DhcpClientId != m_dhcpClientIdEdit->text()){
|
||||
isChanged = true;
|
||||
}
|
||||
return isChanged;
|
||||
}
|
||||
|
||||
void VpnIpv4Page::updateVpnIpv4Info(KyVpnConfig &vpnInfo)
|
||||
{
|
||||
if (m_ipv4ConfigCombox->currentIndex() == AUTO_CONFIG) {
|
||||
QString ipv4address("");
|
||||
QString netMask("");
|
||||
QString gateWay("");
|
||||
vpnInfo.setIpConfigType(IPADDRESS_V4, CONFIG_IP_DHCP);
|
||||
vpnInfo.ipv4AddressConstruct(ipv4address, netMask, gateWay);
|
||||
qDebug() << LOG_FLAG << "IPv4 method" << vpnInfo.m_ipv4ConfigIpType;
|
||||
qDebug() << LOG_FLAG << "Update IPv4 info finished";
|
||||
} else {
|
||||
QString ipv4address =m_ipv4addressEdit->text();
|
||||
QString netMask = getNetMaskText(m_netMaskEdit->text());
|
||||
QString gateWay = m_gateWayEdit->text();
|
||||
qDebug() << ipv4address << netMask << gateWay;
|
||||
vpnInfo.setIpConfigType(IPADDRESS_V4, CONFIG_IP_MANUAL);
|
||||
vpnInfo.ipv4AddressConstruct(ipv4address, netMask, gateWay);
|
||||
vpnInfo.dumpInfo();
|
||||
qDebug() << LOG_FLAG << "Update IPv4 info finished";
|
||||
}
|
||||
|
||||
QList<QHostAddress> ipv4DnsList;
|
||||
ipv4DnsList.clear();
|
||||
if (!m_dnsServerEdit->text().isEmpty()) {
|
||||
ipv4DnsList.append(QHostAddress(m_dnsServerEdit->text()));
|
||||
}
|
||||
vpnInfo.ipv4DnsConstruct(ipv4DnsList);
|
||||
|
||||
vpnInfo.m_ipv4DnsSearch.clear();
|
||||
vpnInfo.m_ipv4DnsSearch.append(m_searchDomainEdit->text());
|
||||
vpnInfo.m_ipv4DhcpClientId = m_dhcpClientIdEdit->text();
|
||||
}
|
||||
|
||||
void VpnIpv4Page::initUI()
|
||||
{
|
||||
/**********控件**********/
|
||||
m_configLabel = new QLabel(this);
|
||||
m_addressLabel = new QLabel(this);
|
||||
m_maskLabel = new QLabel(this);
|
||||
m_gateWayLabel = new QLabel(this);
|
||||
m_dnsServerLabel = new QLabel(this);
|
||||
m_searchDomainLabel = new QLabel(this);
|
||||
m_dhcpClientIdLabel = new QLabel(this);
|
||||
|
||||
m_ipv4ConfigCombox =new QComboBox(this);
|
||||
m_ipv4addressEdit = new QLineEdit(this);
|
||||
m_netMaskEdit = new QLineEdit(this);
|
||||
m_gateWayEdit = new QLineEdit(this);
|
||||
m_dnsServerEdit = new QLineEdit(this);
|
||||
m_searchDomainEdit = new QLineEdit(this);
|
||||
m_dhcpClientIdEdit = new QLineEdit(this);
|
||||
|
||||
|
||||
/**********布局**********/
|
||||
QFormLayout *mainLayout = new QFormLayout(this);
|
||||
mainLayout->setContentsMargins(NO_LAYOUT_MARGINS);
|
||||
mainLayout->setHorizontalSpacing(HLAYOUT_SPACING);
|
||||
mainLayout->setVerticalSpacing(VLAYOUT_SPACING);
|
||||
mainLayout->addRow(m_configLabel, m_ipv4ConfigCombox);
|
||||
mainLayout->addRow(m_addressLabel, m_ipv4addressEdit);
|
||||
mainLayout->addRow(m_maskLabel, m_netMaskEdit);
|
||||
mainLayout->addRow(m_gateWayLabel, m_gateWayEdit);
|
||||
mainLayout->addRow(m_dnsServerLabel, m_dnsServerEdit);
|
||||
mainLayout->addRow(m_searchDomainLabel, m_searchDomainEdit);
|
||||
mainLayout->addRow(m_dhcpClientIdLabel, m_dhcpClientIdEdit);
|
||||
|
||||
|
||||
/**********控件显示**********/
|
||||
m_configLabel->setText(tr("IPv4 Config"));
|
||||
m_addressLabel->setText(tr("Address"));
|
||||
m_maskLabel->setText(tr("Netmask"));
|
||||
m_gateWayLabel->setText(tr("Default Gateway"));
|
||||
m_dnsServerLabel->setText(tr("DNS Server"));
|
||||
m_searchDomainLabel->setText(tr("Search Domain")); //搜索域
|
||||
m_dhcpClientIdLabel->setText(tr("DHCP Client ID")); //DHCP客户端ID
|
||||
|
||||
m_ipv4ConfigCombox->addItem(tr("Auto(DHCP)"), AUTO_CONFIG); //"自动(DHCP)"
|
||||
m_ipv4ConfigCombox->addItem(tr("Manual"), MANUAL_CONFIG); //"手动"
|
||||
|
||||
// IP的正则格式限制
|
||||
QRegExp rxIp("\\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");
|
||||
QRegExpValidator *ipExpVal = new QRegExpValidator(rxIp, this);
|
||||
m_ipv4addressEdit->setValidator(ipExpVal);
|
||||
m_netMaskEdit->setValidator(ipExpVal);
|
||||
m_gateWayEdit->setValidator(ipExpVal);
|
||||
m_dnsServerEdit->setValidator(ipExpVal);
|
||||
}
|
||||
|
||||
void VpnIpv4Page::initConnect()
|
||||
{
|
||||
if (m_ipv4ConfigCombox->currentIndex() == AUTO_CONFIG) {
|
||||
setManualEnabled(false);
|
||||
} else if (m_ipv4ConfigCombox->currentIndex() == MANUAL_CONFIG) {
|
||||
setManualEnabled(true);
|
||||
}
|
||||
connect(m_ipv4ConfigCombox, SIGNAL(currentIndexChanged(int)), this, SLOT(onConfigChanged(int)));
|
||||
connect(m_ipv4ConfigCombox, SIGNAL(currentIndexChanged(int)), this, SLOT(setEnableOfConfirmBtn()));
|
||||
connect(m_ipv4addressEdit, &QLineEdit::textChanged, this, &VpnIpv4Page::setEnableOfConfirmBtn);
|
||||
connect(m_netMaskEdit, &QLineEdit::textChanged, this, &VpnIpv4Page::setEnableOfConfirmBtn);
|
||||
connect(m_gateWayEdit, &QLineEdit::textChanged, this, &VpnIpv4Page::setEnableOfConfirmBtn);
|
||||
connect(m_dnsServerEdit, &QLineEdit::textChanged, this, &VpnIpv4Page::setEnableOfConfirmBtn);
|
||||
connect(m_searchDomainEdit, &QLineEdit::textChanged, this, &VpnIpv4Page::setEnableOfConfirmBtn);
|
||||
connect(m_dhcpClientIdEdit, &QLineEdit::textChanged, this, &VpnIpv4Page::setEnableOfConfirmBtn);
|
||||
}
|
||||
|
||||
void VpnIpv4Page::setManualEnabled(bool state)
|
||||
{
|
||||
m_addressLabel->setEnabled(state);
|
||||
m_maskLabel->setEnabled(state);
|
||||
m_gateWayLabel->setEnabled(state);
|
||||
m_ipv4addressEdit->setEnabled(state);
|
||||
m_netMaskEdit->setEnabled(state);
|
||||
m_gateWayEdit->setEnabled(state);
|
||||
}
|
||||
|
||||
bool VpnIpv4Page::getTextEditState(QString text)
|
||||
{
|
||||
if (text.isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
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");
|
||||
|
||||
bool match = false;
|
||||
match = rx.exactMatch(text);
|
||||
|
||||
return match;
|
||||
}
|
||||
|
||||
bool VpnIpv4Page::netMaskIsValide(QString text)
|
||||
{
|
||||
if (getTextEditState(text)) {
|
||||
return true;
|
||||
} else {
|
||||
if (text.length() > 0 && text.length() < 3) {
|
||||
int num = text.toInt();
|
||||
if (num > 0 && num < 33) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
QString VpnIpv4Page::getNetMaskText(QString text)
|
||||
{
|
||||
if (text.length() > 2) {
|
||||
return text;
|
||||
}
|
||||
|
||||
int num = text.toInt();
|
||||
QStringList list;
|
||||
list << "0" << "0" << "0" << "0";
|
||||
int count = 0;
|
||||
while (num - 8 >= 0) {
|
||||
list[count] = "255";
|
||||
num = num - 8;
|
||||
count ++;
|
||||
}
|
||||
if (num > 0) {
|
||||
int size = pow(2, 8) - pow(2,(8-num));
|
||||
list[count] = QString::number(size);
|
||||
}
|
||||
return QString("%1.%2.%3.%4").arg(list[0],list[1],list[2],list[3]);
|
||||
}
|
||||
|
||||
bool VpnIpv4Page::checkConfirmBtnIsEnabled()
|
||||
{
|
||||
if (m_ipv4ConfigCombox->currentIndex() == AUTO_CONFIG) {
|
||||
return true;
|
||||
} else {
|
||||
if (m_ipv4addressEdit->text().isEmpty() || !getTextEditState(m_ipv4addressEdit->text())) {
|
||||
qDebug() << LOG_FLAG << "IPv4 address empty or invalid";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (m_netMaskEdit->text().isEmpty() || !netMaskIsValide(m_netMaskEdit->text())) {
|
||||
qDebug() << LOG_FLAG << "IPv4 netMask empty or invalid";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void VpnIpv4Page::setEnableOfConfirmBtn()
|
||||
{
|
||||
Q_EMIT setIpv4PageState(checkConfirmBtnIsEnabled());
|
||||
}
|
||||
|
||||
void VpnIpv4Page::onConfigChanged(int index)
|
||||
{
|
||||
if (index == AUTO_CONFIG) {
|
||||
m_ipv4addressEdit->clear();
|
||||
m_netMaskEdit->clear();
|
||||
m_gateWayEdit->clear();
|
||||
setManualEnabled(false);
|
||||
} else if (index == MANUAL_CONFIG) {
|
||||
setManualEnabled(true);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,62 @@
|
|||
#ifndef VPNIPV4PAGE_H
|
||||
#define VPNIPV4PAGE_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QFrame>
|
||||
#include <QLabel>
|
||||
#include <QLineEdit>
|
||||
#include <QComboBox>
|
||||
#include <QFormLayout>
|
||||
|
||||
#include "kyvpnconnectoperation.h"
|
||||
|
||||
class VpnIpv4Page : public QFrame
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
VpnIpv4Page(QWidget *parent = nullptr);
|
||||
~VpnIpv4Page() = default;
|
||||
|
||||
void setVpnIpv4Info(const KyVpnConfig &vpnInfo);
|
||||
void setDns(const QString &firstDns);
|
||||
void setSearchDomain(const QString &searchDomain);
|
||||
void setDhcpClientId(const QString &dhcpId);
|
||||
|
||||
bool checkIsChanged(const KyVpnConfig &vpnInfo);
|
||||
void updateVpnIpv4Info(KyVpnConfig &vpnInfo);
|
||||
|
||||
private:
|
||||
QLabel *m_configLabel;
|
||||
QLabel *m_addressLabel;
|
||||
QLabel *m_maskLabel;
|
||||
QLabel *m_gateWayLabel;
|
||||
QLabel *m_dnsServerLabel;
|
||||
QLabel *m_searchDomainLabel;
|
||||
QLabel *m_dhcpClientIdLabel;
|
||||
|
||||
QComboBox *m_ipv4ConfigCombox;
|
||||
QLineEdit *m_ipv4addressEdit;
|
||||
QLineEdit *m_netMaskEdit;
|
||||
QLineEdit *m_gateWayEdit;
|
||||
QLineEdit *m_dnsServerEdit;
|
||||
QLineEdit *m_searchDomainEdit;
|
||||
QLineEdit *m_dhcpClientIdEdit;
|
||||
|
||||
void initUI();
|
||||
void initConnect();
|
||||
void setManualEnabled(bool state);
|
||||
|
||||
bool getTextEditState(QString text);
|
||||
bool netMaskIsValide(QString text);
|
||||
QString getNetMaskText(QString text);
|
||||
bool checkConfirmBtnIsEnabled();
|
||||
|
||||
private Q_SLOTS:
|
||||
void setEnableOfConfirmBtn();
|
||||
void onConfigChanged(int index);
|
||||
|
||||
Q_SIGNALS:
|
||||
void setIpv4PageState(bool);
|
||||
};
|
||||
|
||||
#endif // VPNIPV4PAGE_H
|
|
@ -0,0 +1,240 @@
|
|||
#include "vpnipv6page.h"
|
||||
#include "math.h"
|
||||
#include <QDebug>
|
||||
|
||||
#define NO_LAYOUT_MARGINS 0, 0, 0, 0
|
||||
#define NO_SPACE 0
|
||||
#define HLAYOUT_SPACING 16
|
||||
#define VLAYOUT_SPACING 24
|
||||
#define AUTO_CONFIG 0
|
||||
#define MANUAL_CONFIG 1
|
||||
#define LOG_FLAG "[VPN IPv6Page]"
|
||||
|
||||
VpnIpv6Page::VpnIpv6Page(QWidget *parent) : QFrame(parent)
|
||||
{
|
||||
initUI();
|
||||
initConnect();
|
||||
}
|
||||
|
||||
void VpnIpv6Page::setVpnIpv6Info(const KyVpnConfig &vpnInfo)
|
||||
{
|
||||
if (vpnInfo.m_ipv6ConfigIpType == CONFIG_IP_DHCP) {
|
||||
m_ipv6ConfigCombox->setCurrentIndex(AUTO_CONFIG);
|
||||
} else {
|
||||
m_ipv6ConfigCombox->setCurrentIndex(MANUAL_CONFIG);
|
||||
if (!vpnInfo.m_ipv6Address.isEmpty()) {
|
||||
m_ipv6addressEdit->setText(vpnInfo.m_ipv6Address.at(0).ip().toString());
|
||||
m_netMaskEdit->setText(vpnInfo.m_ipv6Address.at(0).netmask().toString());
|
||||
m_gateWayEdit->setText(vpnInfo.m_ipv6Address.at(0).gateway().toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void VpnIpv6Page::setDns(const QString &firstDns)
|
||||
{
|
||||
m_dnsServerEdit->setText(firstDns);
|
||||
}
|
||||
|
||||
void VpnIpv6Page::setSearchDomain(const QString &searchDomain)
|
||||
{
|
||||
m_searchDomainEdit->setText(searchDomain);
|
||||
}
|
||||
|
||||
bool VpnIpv6Page::checkIsChanged(const KyVpnConfig &vpnInfo)
|
||||
{
|
||||
bool isChanged = false;
|
||||
|
||||
if (m_ipv6ConfigCombox->currentIndex() == AUTO_CONFIG) {
|
||||
if (vpnInfo.m_ipv6ConfigIpType != CONFIG_IP_DHCP) {
|
||||
qDebug() << LOG_FLAG << "ipv6ConfigType change to Auto";
|
||||
isChanged = true;
|
||||
}
|
||||
} else {
|
||||
if (vpnInfo.m_ipv6ConfigIpType != CONFIG_IP_MANUAL) {
|
||||
qDebug() << LOG_FLAG << "ipv6ConfigType change to Manual";
|
||||
isChanged = true;
|
||||
}
|
||||
|
||||
if (!vpnInfo.m_ipv6Address.isEmpty()) {
|
||||
if(vpnInfo.m_ipv6Address.at(0).ip().toString() != m_ipv6addressEdit->text()
|
||||
|| vpnInfo.m_ipv6Address.at(0).netmask().toString() != m_netMaskEdit->text()
|
||||
|| vpnInfo.m_ipv6Address.at(0).gateway().toString() != m_gateWayEdit->text()) {
|
||||
|
||||
isChanged = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!vpnInfo.m_ipv6Dns.isEmpty() && vpnInfo.m_ipv6Dns.at(0).toString() != m_dnsServerEdit->text()) {
|
||||
isChanged = true;
|
||||
}
|
||||
|
||||
if (!vpnInfo.m_ipv6DnsSearch.isEmpty() && vpnInfo.m_ipv6DnsSearch.at(0) != m_searchDomainEdit->text()) {
|
||||
isChanged = true;
|
||||
}
|
||||
|
||||
return isChanged;
|
||||
}
|
||||
|
||||
void VpnIpv6Page::updateVpnIpv6Info(KyVpnConfig &vpnInfo)
|
||||
{
|
||||
if (m_ipv6ConfigCombox->currentIndex() == AUTO_CONFIG) {
|
||||
QString ipv6address("");
|
||||
QString netMask("");
|
||||
QString gateWay("");
|
||||
vpnInfo.setIpConfigType(IPADDRESS_V6, CONFIG_IP_DHCP);
|
||||
vpnInfo.ipv6AddressConstruct(ipv6address, netMask, gateWay);
|
||||
qDebug() << LOG_FLAG << "IPv6 method" << vpnInfo.m_ipv6ConfigIpType;
|
||||
qDebug() << LOG_FLAG << "Update IPv6 info finished";
|
||||
} else {
|
||||
QString ipv6address =m_ipv6addressEdit->text();
|
||||
QString netMask = m_netMaskEdit->text();
|
||||
QString gateWay = m_gateWayEdit->text();
|
||||
qDebug() << ipv6address << netMask << gateWay;
|
||||
vpnInfo.setIpConfigType(IPADDRESS_V6, CONFIG_IP_MANUAL);
|
||||
vpnInfo.ipv6AddressConstruct(ipv6address, netMask, gateWay);
|
||||
vpnInfo.dumpInfo();
|
||||
qDebug() << LOG_FLAG << "Update IPv6 info finished";
|
||||
}
|
||||
|
||||
QList<QHostAddress> ipv6DnsList;
|
||||
ipv6DnsList.clear();
|
||||
if (!m_dnsServerEdit->text().isEmpty()) {
|
||||
ipv6DnsList.append(QHostAddress(m_dnsServerEdit->text()));
|
||||
}
|
||||
vpnInfo.ipv6DnsConstruct(ipv6DnsList);
|
||||
|
||||
vpnInfo.m_ipv6DnsSearch.clear();
|
||||
vpnInfo.m_ipv6DnsSearch.append(m_searchDomainEdit->text());
|
||||
}
|
||||
|
||||
void VpnIpv6Page::initUI()
|
||||
{
|
||||
/**********控件**********/
|
||||
m_configLabel = new QLabel(this);
|
||||
m_addressLabel = new QLabel(this);
|
||||
m_maskLabel = new QLabel(this);
|
||||
m_gateWayLabel = new QLabel(this);
|
||||
m_dnsServerLabel = new QLabel(this);
|
||||
m_searchDomainLabel = new QLabel(this);
|
||||
|
||||
m_ipv6ConfigCombox =new QComboBox(this);
|
||||
m_ipv6addressEdit = new QLineEdit(this);
|
||||
m_netMaskEdit = new QLineEdit(this);
|
||||
m_gateWayEdit = new QLineEdit(this);
|
||||
m_dnsServerEdit = new QLineEdit(this);
|
||||
m_searchDomainEdit = new QLineEdit(this);
|
||||
|
||||
|
||||
/**********布局**********/
|
||||
QFormLayout *mainLayout = new QFormLayout(this);
|
||||
mainLayout->setContentsMargins(NO_LAYOUT_MARGINS);
|
||||
mainLayout->setHorizontalSpacing(HLAYOUT_SPACING);
|
||||
mainLayout->setVerticalSpacing(VLAYOUT_SPACING);
|
||||
mainLayout->addRow(m_configLabel, m_ipv6ConfigCombox);
|
||||
mainLayout->addRow(m_addressLabel, m_ipv6addressEdit);
|
||||
mainLayout->addRow(m_maskLabel, m_netMaskEdit);
|
||||
mainLayout->addRow(m_gateWayLabel, m_gateWayEdit);
|
||||
mainLayout->addRow(m_dnsServerLabel, m_dnsServerEdit);
|
||||
mainLayout->addRow(m_searchDomainLabel, m_searchDomainEdit);
|
||||
|
||||
|
||||
/**********控件显示**********/
|
||||
m_configLabel->setText(tr("IPv6 Config"));
|
||||
m_addressLabel->setText(tr("Address"));
|
||||
m_maskLabel->setText(tr("Netmask"));
|
||||
m_gateWayLabel->setText(tr("Default Gateway"));
|
||||
m_dnsServerLabel->setText(tr("DNS Server"));
|
||||
m_searchDomainLabel->setText(tr("Search Domain")); //搜索域
|
||||
|
||||
m_ipv6ConfigCombox->addItem(tr("Auto(DHCP)"), AUTO_CONFIG); //"自动(DHCP)"
|
||||
m_ipv6ConfigCombox->addItem(tr("Manual"), MANUAL_CONFIG); //"手动"
|
||||
|
||||
// IP的正则格式限制
|
||||
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*$");
|
||||
QRegExpValidator *ipv6ExpVal = new QRegExpValidator(ipv6_rx, this);
|
||||
m_ipv6addressEdit->setValidator(ipv6ExpVal);
|
||||
m_gateWayEdit->setValidator(ipv6ExpVal);
|
||||
m_dnsServerEdit->setValidator(ipv6ExpVal);
|
||||
|
||||
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");
|
||||
m_netMaskEdit->setValidator(new QRegExpValidator(prefix_rx,this));
|
||||
}
|
||||
|
||||
void VpnIpv6Page::initConnect()
|
||||
{
|
||||
if (m_ipv6ConfigCombox->currentIndex() == AUTO_CONFIG) {
|
||||
setManualEnabled(false);
|
||||
} else if (m_ipv6ConfigCombox->currentIndex() == MANUAL_CONFIG) {
|
||||
setManualEnabled(true);
|
||||
}
|
||||
connect(m_ipv6ConfigCombox, SIGNAL(currentIndexChanged(int)), this, SLOT(onConfigChanged(int)));
|
||||
connect(m_ipv6ConfigCombox, SIGNAL(currentIndexChanged(int)), this, SLOT(setEnableOfConfirmBtn()));
|
||||
connect(m_ipv6addressEdit, &QLineEdit::textChanged, this, &VpnIpv6Page::setEnableOfConfirmBtn);
|
||||
connect(m_netMaskEdit, &QLineEdit::textChanged, this, &VpnIpv6Page::setEnableOfConfirmBtn);
|
||||
connect(m_gateWayEdit, &QLineEdit::textChanged, this, &VpnIpv6Page::setEnableOfConfirmBtn);
|
||||
connect(m_dnsServerEdit, &QLineEdit::textChanged, this, &VpnIpv6Page::setEnableOfConfirmBtn);
|
||||
connect(m_searchDomainEdit, &QLineEdit::textChanged, this, &VpnIpv6Page::setEnableOfConfirmBtn);
|
||||
}
|
||||
|
||||
void VpnIpv6Page::setManualEnabled(bool state)
|
||||
{
|
||||
m_addressLabel->setEnabled(state);
|
||||
m_maskLabel->setEnabled(state);
|
||||
m_gateWayLabel->setEnabled(state);
|
||||
m_ipv6addressEdit->setEnabled(state);
|
||||
m_netMaskEdit->setEnabled(state);
|
||||
m_gateWayEdit->setEnabled(state);
|
||||
}
|
||||
|
||||
bool VpnIpv6Page::getIpv6EditState(QString text)
|
||||
{
|
||||
if (text.isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
QRegExp 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*$");
|
||||
|
||||
bool match = false;
|
||||
match = rx.exactMatch(text);
|
||||
|
||||
return match;
|
||||
}
|
||||
|
||||
bool VpnIpv6Page::checkConfirmBtnIsEnabled()
|
||||
{
|
||||
if (m_ipv6ConfigCombox->currentIndex() == AUTO_CONFIG) {
|
||||
return true;
|
||||
} else {
|
||||
if (m_ipv6addressEdit->text().isEmpty() || !getIpv6EditState(m_ipv6addressEdit->text())) {
|
||||
qDebug() << "IPv6 address empty or invalid";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (m_netMaskEdit->text().isEmpty()) {
|
||||
qDebug() << "IPv6 netMask empty or invalid";
|
||||
return false;
|
||||
}
|
||||
if (m_gateWayEdit->text().isEmpty() || !getIpv6EditState(m_gateWayEdit->text())) {
|
||||
qDebug() << "IPv6 gateway empty or invalid";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void VpnIpv6Page::setEnableOfConfirmBtn()
|
||||
{
|
||||
Q_EMIT setIpv6PageState(checkConfirmBtnIsEnabled());
|
||||
}
|
||||
|
||||
void VpnIpv6Page::onConfigChanged(int index)
|
||||
{
|
||||
if (index == AUTO_CONFIG) {
|
||||
m_ipv6addressEdit->clear();
|
||||
m_netMaskEdit->clear();
|
||||
m_gateWayEdit->clear();
|
||||
setManualEnabled(false);
|
||||
} else if (index == MANUAL_CONFIG) {
|
||||
setManualEnabled(true);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
#ifndef VPNIPV6PAGE_H
|
||||
#define VPNIPV6PAGE_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QFrame>
|
||||
#include <QLabel>
|
||||
#include <QLineEdit>
|
||||
#include <QComboBox>
|
||||
#include <QFormLayout>
|
||||
|
||||
#include "kyvpnconnectoperation.h"
|
||||
|
||||
class VpnIpv6Page : public QFrame
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
VpnIpv6Page(QWidget *parent = nullptr);
|
||||
~VpnIpv6Page() = default;
|
||||
|
||||
void setVpnIpv6Info(const KyVpnConfig &vpnInfo);
|
||||
void setDns(const QString &firstDns);
|
||||
void setSearchDomain(const QString &searchDomain);
|
||||
bool checkIsChanged(const KyVpnConfig &vpnInfo);
|
||||
|
||||
void updateVpnIpv6Info(KyVpnConfig &vpnInfo);
|
||||
|
||||
private:
|
||||
QLabel *m_configLabel;
|
||||
QLabel *m_addressLabel;
|
||||
QLabel *m_maskLabel;
|
||||
QLabel *m_gateWayLabel;
|
||||
QLabel *m_dnsServerLabel;
|
||||
QLabel *m_searchDomainLabel;
|
||||
|
||||
QComboBox *m_ipv6ConfigCombox;
|
||||
QLineEdit *m_ipv6addressEdit;
|
||||
QLineEdit *m_netMaskEdit;
|
||||
QLineEdit *m_gateWayEdit;
|
||||
QLineEdit *m_dnsServerEdit;
|
||||
QLineEdit *m_searchDomainEdit;
|
||||
|
||||
void initUI();
|
||||
void initConnect();
|
||||
void setManualEnabled(bool state);
|
||||
|
||||
bool getIpv6EditState(QString text);
|
||||
bool checkConfirmBtnIsEnabled();
|
||||
|
||||
private Q_SLOTS:
|
||||
void setEnableOfConfirmBtn();
|
||||
void onConfigChanged(int index);
|
||||
|
||||
Q_SIGNALS:
|
||||
void setIpv6PageState(bool);
|
||||
};
|
||||
|
||||
#endif // VPNIPV6PAGE_H
|
|
@ -0,0 +1,138 @@
|
|||
#include "vpnobject.h"
|
||||
#include <QApplication>
|
||||
|
||||
#include "ukuistylehelper/ukuistylehelper.h"
|
||||
|
||||
vpnObject::vpnObject(QMainWindow *parent) : QMainWindow(parent)
|
||||
{
|
||||
initUI();
|
||||
initTrayIcon();
|
||||
initDbusConnnect();
|
||||
}
|
||||
|
||||
vpnObject::~vpnObject()
|
||||
{
|
||||
if (m_vpnGsettings != nullptr) {
|
||||
delete m_vpnGsettings;
|
||||
m_vpnGsettings = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void vpnObject::initUI()
|
||||
{
|
||||
m_vpnPage = new VpnPage(nullptr);
|
||||
m_vpnPage->update();
|
||||
|
||||
}
|
||||
|
||||
void vpnObject::initTrayIcon()
|
||||
{
|
||||
m_vpnTrayIcon = new QSystemTrayIcon(this);
|
||||
m_vpnTrayIcon->setToolTip(QString(tr("vpn tool")));
|
||||
m_vpnTrayIcon->setIcon(QIcon::fromTheme("ukui-vpn-symbolic"));
|
||||
m_vpnTrayIcon->setVisible(true);
|
||||
initVpnIconVisible();
|
||||
connect(m_vpnTrayIcon, &QSystemTrayIcon::activated, this, &vpnObject::onTrayIconActivated);
|
||||
}
|
||||
|
||||
void vpnObject::initVpnIconVisible()
|
||||
{
|
||||
if (QGSettings::isSchemaInstalled(QByteArray(GSETTINGS_VPNICON_VISIBLE))) {
|
||||
m_vpnGsettings = new QGSettings(QByteArray(GSETTINGS_VPNICON_VISIBLE));
|
||||
if (m_vpnGsettings->keys().contains(QString(VISIBLE))) {
|
||||
m_vpnTrayIcon->setVisible(m_vpnGsettings->get(VISIBLE).toBool());
|
||||
connect(m_vpnGsettings, &QGSettings::changed, this, [=]() {
|
||||
m_vpnTrayIcon->setVisible(m_vpnGsettings->get(VISIBLE).toBool());
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief vpnObject::onTrayIconActivated 点击托盘图标的槽函数
|
||||
*/
|
||||
void vpnObject::onTrayIconActivated(QSystemTrayIcon::ActivationReason reason)
|
||||
{
|
||||
switch(reason) {
|
||||
case QSystemTrayIcon::Trigger:
|
||||
if(m_vpnPage->isActiveWindow()) {
|
||||
m_vpnPage->hide();
|
||||
} else {
|
||||
onShowMainWindow();
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void vpnObject::getVirtualList(QVector<QStringList> &vector)
|
||||
{
|
||||
vector.clear();
|
||||
if (nullptr != m_vpnPage) {
|
||||
m_vpnPage->getVirtualList(vector);
|
||||
}
|
||||
}
|
||||
|
||||
//Vpn连接删除
|
||||
void vpnObject::deleteVpn(const QString &connUuid)
|
||||
{
|
||||
m_vpnPage->deleteVpn(connUuid);
|
||||
}
|
||||
|
||||
//Vpn连接断开
|
||||
void vpnObject::activateVpn(const QString& connUuid)
|
||||
{
|
||||
m_vpnPage->activateVpn(connUuid);
|
||||
}
|
||||
void vpnObject::deactivateVpn(const QString& connUuid)
|
||||
{
|
||||
m_vpnPage->deactivateVpn(connUuid);
|
||||
}
|
||||
|
||||
void vpnObject::showDetailPage(const QString& connUuid)
|
||||
{
|
||||
m_vpnPage->showDetailPage(connUuid);
|
||||
}
|
||||
|
||||
|
||||
void vpnObject::onShowMainWindow()
|
||||
{
|
||||
kdk::UkuiStyleHelper::self()->removeHeader(m_vpnPage);
|
||||
m_vpnPage->showUI();
|
||||
}
|
||||
|
||||
void vpnObject::initDbusConnnect()
|
||||
{
|
||||
connect(m_vpnPage, &VpnPage::activateFailed, this, &vpnObject::activateFailed);
|
||||
connect(m_vpnPage, &VpnPage::deactivateFailed, this, &vpnObject::deactivateFailed);
|
||||
|
||||
connect(m_vpnPage, &VpnPage::vpnAdd, this, &vpnObject::vpnAdd);
|
||||
connect(m_vpnPage, &VpnPage::vpnRemove, this, &vpnObject::vpnRemove);
|
||||
connect(m_vpnPage, &VpnPage::vpnUpdate, this, &vpnObject::vpnUpdate);
|
||||
connect(m_vpnPage, &VpnPage::vpnActiveConnectionStateChanged, this, &vpnObject::vpnActiveConnectionStateChanged);
|
||||
//模式切换
|
||||
QDBusConnection::sessionBus().connect(QString("com.kylin.statusmanager.interface"),
|
||||
QString("/"),
|
||||
QString("com.kylin.statusmanager.interface"),
|
||||
QString("mode_change_signal"), this, SLOT(onTabletModeChanged(bool)));
|
||||
}
|
||||
|
||||
void vpnObject::onTabletModeChanged(bool mode)
|
||||
{
|
||||
qDebug() << "TabletMode change" << mode;
|
||||
Q_UNUSED(mode)
|
||||
//模式切换时,隐藏主界面
|
||||
m_vpnPage->hide();
|
||||
}
|
||||
|
||||
void vpnObject::showVpnAddWidget()
|
||||
{
|
||||
if (m_vpnAddPage == nullptr) {
|
||||
m_vpnAddPage = new vpnAddPage();
|
||||
connect(m_vpnAddPage, &vpnAddPage::closed, [&] () {m_vpnAddPage = nullptr;});
|
||||
m_vpnAddPage->show();
|
||||
}
|
||||
m_vpnAddPage->raise();
|
||||
}
|
|
@ -0,0 +1,75 @@
|
|||
#ifndef VPNOBJECT_H
|
||||
#define VPNOBJECT_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QWidget>
|
||||
#include <QScreen>
|
||||
#include <QSystemTrayIcon>
|
||||
#include <QMainWindow>
|
||||
|
||||
#include "vpnpage.h"
|
||||
#include "vpnaddpage.h"
|
||||
class VpnPage;
|
||||
|
||||
#define VISIBLE "visible"
|
||||
#define GSETTINGS_VPNICON_VISIBLE "org.ukui.kylin-nm.vpnicon"
|
||||
//const QByteArray GSETTINGS_VPNICON_VISIBLE = "org.ukui.kylin-nm.vpnicon";
|
||||
|
||||
|
||||
class vpnObject : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit vpnObject(QMainWindow *parent = nullptr);
|
||||
~vpnObject();
|
||||
|
||||
void getVirtualList(QVector<QStringList> &vector);
|
||||
//Vpn连接删除
|
||||
void deleteVpn(const QString &connUuid);
|
||||
//有线连接断开
|
||||
void activateVpn(const QString& connUuid);
|
||||
void deactivateVpn(const QString& connUuid);
|
||||
|
||||
void showDetailPage(const QString& connUuid);
|
||||
|
||||
void showVpnAddWidget();
|
||||
|
||||
private:
|
||||
void initUI();
|
||||
void initTrayIcon();
|
||||
void initVpnIconVisible();
|
||||
void initDbusConnnect();
|
||||
|
||||
|
||||
private:
|
||||
VpnPage *m_vpnPage = nullptr;
|
||||
QSystemTrayIcon * m_vpnTrayIcon = nullptr;
|
||||
QGSettings * m_vpnGsettings; //VPN配置文件
|
||||
double tran =1;
|
||||
QGSettings *StyleSettings = nullptr;
|
||||
QWidget * vpnWidget = nullptr;
|
||||
|
||||
QDBusInterface * m_positionInterface = nullptr;
|
||||
bool m_isShowInCenter = false;
|
||||
|
||||
vpnAddPage *m_vpnAddPage = nullptr;
|
||||
|
||||
public Q_SLOTS:
|
||||
void onShowMainWindow();
|
||||
|
||||
private Q_SLOTS:
|
||||
void onTrayIconActivated(QSystemTrayIcon::ActivationReason reason);
|
||||
void onTabletModeChanged(bool mode);
|
||||
|
||||
|
||||
Q_SIGNALS:
|
||||
void vpnAdd(QStringList info);
|
||||
void vpnRemove(QString dbusPath);
|
||||
void vpnUpdate(QStringList info);
|
||||
void vpnActiveConnectionStateChanged(QString uuid, int status);
|
||||
void activateFailed(QString errorMessage);
|
||||
void deactivateFailed(QString errorMessage);
|
||||
void mainWindowVisibleChanged(const bool &visible);
|
||||
};
|
||||
|
||||
#endif // VPNOBJECT_H
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue