Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ add_subdirectory("src")
add_subdirectory("dcc-network")
add_subdirectory("tests")
# add_subdirectory("example")
#add_subdirectory("dock-network-plugin")
add_subdirectory("dock-network-plugin")
add_subdirectory("dss-network-plugin")
add_subdirectory("dss_example")
# add_subdirectory("dss_example")
#add_subdirectory("dock-example")
add_subdirectory("network-service-plugin")
7 changes: 7 additions & 0 deletions debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Build-Depends: debhelper-compat (= 12),
pkg-config,
libgtest-dev,
dde-control-center-dev,
dde-tray-loader-dev,
dde-session-shell-dev,
libudev-dev,
qt6-base-dev,
Expand Down Expand Up @@ -39,6 +40,12 @@ Depends: ${misc:Depends},${shlibs:Depends},network-manager-integration-plugins,l
Description: the plugin of network for dde control center
dcc-network-plugin module

Package: dock-network-plugin
Architecture: any
Depends: ${misc:Depends},${shlibs:Depends},libdde-network-core (= ${binary:Version})
Description: the plugin of network for dde-dock
dock-plugin module

Package: dss-network-plugin
Architecture: any
Depends: ${misc:Depends},${shlibs:Depends},libdde-network-core (= ${binary:Version})
Expand Down
3 changes: 3 additions & 0 deletions debian/dock-network-plugin.install
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
usr/lib/dde-dock/plugins/system-trays/libdock-network-plugin.so
usr/share/dock-network-plugin/translations
usr/share/dde-dock/icons/dcc-setting
2 changes: 1 addition & 1 deletion debian/dss-network-plugin.install
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
usr/lib/dde-session-shell/modules/libdss-network-plugin.so
usr/share/dss-network-plugin/translations
usr/share/polkit-1/rules.d/50-dss-network-plugin.rules
var/lib/polkit-1/localauthority/10-vendor.d/10-network-manager.pkla
90 changes: 48 additions & 42 deletions dock-network-plugin/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,70 +1,76 @@
cmake_minimum_required(VERSION 3.7)
# SPDX-FileCopyrightText: 2025 UnionTech Software Technology Co., Ltd.
#
# SPDX-License-Identifier: CC0-1.0

set(PLUGIN_NAME "dock-network-plugin")

set(QT_NS Qt6)
set(DTK_NS Dtk6)

project(${PLUGIN_NAME})
include(GNUInstallDirs)
# 启用 qt moc 的支持
set(CMAKE_AUTOMOC ON)
# 启用 qrc 资源文件的支持
set(CMAKE_AUTORCC ON)

file(GLOB_RECURSE SRCS "*.h" "*.cpp" "item/*.h" "item/*.cpp" "../common-plugin/*.h" "../common-plugin/*.cpp")
file(GLOB_RECURSE SRCS
"networkplugin.h"
"networkplugin.cpp"
"quickpanelwidget.h"
"quickpanelwidget.cpp"
"dockcontentwidget.h"
"../net-view/*.h"
"../net-view/*.cpp"
"widget/jumpsettingbutton.h"
"widget/jumpsettingbutton.cpp"
"widget/commoniconbutton.h"
"widget/commoniconbutton.cpp"
)

find_package(Qt5 COMPONENTS Core Widgets DBus Network LinguistTools REQUIRED)
find_package(${QT_NS} COMPONENTS Core Widgets DBus Network LinguistTools REQUIRED)
find_package(PkgConfig REQUIRED)
find_package(Qt5Svg REQUIRED)
find_package(DtkCore REQUIRED)
find_package(DtkWidget REQUIRED)

set(DTKCORE_INCLUDE_DIR DTKCORE_INCLUDE_DIRS)

find_package(${DTK_NS} REQUIRED COMPONENTS Widget)
find_package(KF6NetworkManagerQt REQUIRED)
find_package(DdeDock REQUIRED)
find_package(KF5NetworkManagerQt REQUIRED)

pkg_check_modules(QGSettings REQUIRED gsettings-qt)
pkg_check_modules(DDE-Dock REQUIRED dde-dock)
#if (CMAKE_BUILD_TYPE STREQUAL "Debug")
# set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -fsanitize=address -O0")
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -fsanitize=address -O0")
#endif()

file(GLOB TS_FILES "translations/*.ts")
qt5_add_translation(QM_FILES ${TS_FILES})
qt_add_translation(QM_FILES ${TS_FILES})
add_custom_target(language ALL DEPENDS ${QM_FILES})

add_definitions("${QT_DEFINITIONS} -DQT_PLUGIN")
add_library(${PLUGIN_NAME} SHARED ${SRCS} ../common-plugin/network.qrc)

get_target_property(KF5_QT_INCLUDE_DIRS KF5::NetworkManagerQt INTERFACE_INCLUDE_DIRECTORIES)

set(TRY_KF5_LIBRARIES
IMPORTED_LOCATION_DEBIAN
IMPORTED_LOCATION_NOCONFIG
)
add_library(${PLUGIN_NAME} SHARED ${SRCS} ../net-view/window/qrc/network.qrc)
set_target_properties(${PLUGIN_NAME} PROPERTIES LIBRARY_OUTPUT_DIRECTORY ../../dde-dock)

if (NOT KF5_QT_LIBRARIES)
find_library(KF5_QT_LIBRARIES libKF5NetworkManagerQt.so)
endif()
# get_target_property(KF6_QT_INCLUDE_DIRS KF6::NetworkManagerQt INTERFACE_INCLUDE_DIRECTORIES)

target_include_directories(${PLUGIN_NAME} PUBLIC
${DtkWidget_INCLUDE_DIRS}
${Qt5DBus_INCLUDE_DIRS}
${QGSettings_INCLUDE_DIRS}
${DDE-Network-Core_INCLUDE_DIRS}
${DDE_DOCK_INCLUDE_DIR}
${Qt5Network_INCLUDE_DIRS}
${KF5_QT_INCLUDE_DIRS}
${NETINTERFACEINCLUDE}
"../common-plugin/"
${DTK_NS}::Widget
${QT_NS}::Dbus
${QT_NS}::Network
KF6::NetworkManagerQt
# "../../../interfaces"
"../net-view/operation"
"../net-view/window"
"../src"
)

target_link_libraries(${PLUGIN_NAME} PRIVATE
${DtkWidget_LIBRARIES}
${Qt5Widgets_LIBRARIES}
${Qt5Svg_LIBRARIES}
${Qt5DBus_LIBRARIES}
${QGSettings_LIBRARIES}
${DDE-Network-Core_LIBRARIES}
${KF5_QT_LIBRARIES}
${Qt5Network_LIBRARIES}
${QT_NS}::Widgets
${QT_NS}::DBus
${QT_NS}::Network
${DTK_NS}::Widget
KF6::NetworkManagerQt
dde-network-core6
)

install(TARGETS ${PLUGIN_NAME} LIBRARY DESTINATION lib/dde-dock/plugins/quick-trays)
install(TARGETS ${PLUGIN_NAME} LIBRARY DESTINATION lib/dde-dock/plugins/system-trays)
# 安装 .qm 文件
install(FILES ${QM_FILES} DESTINATION ${CMAKE_INSTALL_DATADIR}/${PLUGIN_NAME}/translations)
# 安装显示在控制中心-个性化-任务栏-插件区域的图标
install(FILES "resources/dcc-network.dci" DESTINATION share/dde-dock/icons/dcc-setting)
103 changes: 103 additions & 0 deletions dock-network-plugin/dockcontentwidget.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
// SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: LGPL-3.0-or-later

#ifndef DOCKCONTENTWIDGET_H
#define DOCKCONTENTWIDGET_H

#include "netmanager.h"

Check warning on line 8 in dock-network-plugin/dockcontentwidget.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "netmanager.h" not found.
#include "netview.h"

Check warning on line 9 in dock-network-plugin/dockcontentwidget.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "netview.h" not found.
#include "widget/jumpsettingbutton.h"
#include "constants.h"

Check warning on line 11 in dock-network-plugin/dockcontentwidget.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "constants.h" not found.

#include <QDebug>

Check warning on line 13 in dock-network-plugin/dockcontentwidget.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QDebug> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QEvent>

Check warning on line 14 in dock-network-plugin/dockcontentwidget.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QEvent> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QStyleOption>

Check warning on line 15 in dock-network-plugin/dockcontentwidget.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QStyleOption> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QStylePainter>

Check warning on line 16 in dock-network-plugin/dockcontentwidget.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QStylePainter> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QToolButton>

Check warning on line 17 in dock-network-plugin/dockcontentwidget.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QToolButton> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QTreeView>

Check warning on line 18 in dock-network-plugin/dockcontentwidget.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QTreeView> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QVBoxLayout>

Check warning on line 19 in dock-network-plugin/dockcontentwidget.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QVBoxLayout> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QWidget>

namespace dde {
namespace network {

class DockContentWidget : public QWidget
{
Q_OBJECT
public:
explicit DockContentWidget(NetView *netView, NetManager *netManager, QWidget *parent = nullptr)
: QWidget(parent)
, m_mainLayout(new QVBoxLayout(this))
, m_netView(netView)
, m_minHeight(-1)
{
m_netView->installEventFilter(this);
m_netView->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
connect(m_netView, &NetView::updateSize, this, &DockContentWidget::updateSize);

m_netSetBtn = new JumpSettingButton(this);
m_netSetBtn->setIcon(QIcon::fromTheme("network-setting"));
m_netSetBtn->setDescription(tr("Network settings"));
connect(m_netSetBtn, &JumpSettingButton::clicked, netManager, &NetManager::gotoControlCenter);

m_netCheckBtn = new JumpSettingButton(this);
m_netCheckBtn->setIcon(QIcon::fromTheme("network-check"));
m_netCheckBtn->setDescription(tr("Network Detection"));
connect(m_netCheckBtn, &JumpSettingButton::clicked, netManager, &NetManager::gotoCheckNet);

QWidget *buttonWidget = new QWidget(this);
QVBoxLayout *buttonLayout = new QVBoxLayout;
buttonLayout->setContentsMargins(10, 10, 10, 10);
buttonLayout->setSpacing(10);
buttonLayout->addWidget(m_netCheckBtn);
buttonLayout->addWidget(m_netSetBtn);
buttonWidget->setLayout(buttonLayout);

m_mainLayout->setContentsMargins(0, 10, 0, 0);
m_mainLayout->addWidget(m_netView, 0, Qt::AlignTop | Qt::AlignHCenter);
m_mainLayout->addStretch();
m_mainLayout->addSpacing(10);
m_mainLayout->addWidget(buttonWidget, 0, Qt::AlignBottom);
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
setMaximumHeight(Dock::DOCK_POPUP_WIDGET_MAX_HEIGHT);
}

~DockContentWidget() override { }

void setMainLayoutMargins(const QMargins &margin) {
m_mainLayout->setContentsMargins(margin);
}
void setMinHeight(int minHeight) { m_minHeight = minHeight; }
void updateSize() {
auto h = Dock::DOCK_POPUP_WIDGET_MAX_HEIGHT - 20 - m_mainLayout->contentsMargins().top() - (m_netCheckBtn->isVisible() ? (m_netSetBtn->height() + m_netCheckBtn->height() + 10) : m_netSetBtn->height());
m_netView->setMaxHeight(h);
if (m_netView->height() > h)
m_netView->setFixedHeight(h);
setFixedSize(m_netView->width(), qMax(m_minHeight, m_netView->height() + 20 + m_mainLayout->contentsMargins().top() + (m_netCheckBtn->isVisible() ? (m_netSetBtn->height() + m_netCheckBtn->height() + 10) : m_netSetBtn->height())));
}
void setNetCheckBtnVisible(bool visible) {
m_netCheckBtn->setVisible(visible);
updateSize();
}

protected:
bool eventFilter(QObject *watch, QEvent *event) override
{
if ((watch == m_netView && event->type() == QEvent::Resize) || event->type() == QEvent::Show) {
updateSize();
}
return QWidget::eventFilter(watch, event);
}

private:
QVBoxLayout *m_mainLayout;
NetView *m_netView;
int m_minHeight;
JumpSettingButton *m_netSetBtn;
JumpSettingButton *m_netCheckBtn;
};

} // namespace network
} // namespace dde
#endif // DOCKCONTENTWIDGET_H
6 changes: 2 additions & 4 deletions dock-network-plugin/lupdate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ if [ ! -d "translations/" ];then
mkdir translations
fi
cd ./translations
rm -f dock-hotspot-plugin_en_US.ts
lupdate ../ ../../src ../../common-plugin -ts -no-ui-lines -locations none -no-obsolete dock-network-plugin_en_US.ts
rm -f dock-network-plugin.ts
lupdate ../ ../../net-view/ -ts -no-ui-lines -locations none -no-obsolete dock-network-plugin.ts
cd ../

tx push -s --branch m23
3 changes: 1 addition & 2 deletions dock-network-plugin/network.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"api": "2.0.0",
"primary" : true,
"api": "1.1.1",
"depends-daemon-dbus-service": "org.deepin.dde.Network1"
}
4 changes: 4 additions & 0 deletions dock-network-plugin/network_v2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"api": "2.0.0",
"depends-daemon-dbus-service": "org.deepin.dde.Network1"
}
Loading
Loading