Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add desktop plugin definitions and improve plugin loading #2542

Merged
merged 2 commits into from
Jan 9, 2025
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
1 change: 1 addition & 0 deletions assets/dev/dfm6-base/dfm6-base.pc.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ Name: @BIN_NAME@
Description: @CMAKE_PROJECT_DESCRIPTION@
URL: @CMAKE_PROJECT_HOMEPAGE_URL@
Version: @PROJECT_VERSION@
Requires: dfm6-io dfm6-mount dfm6-burn Qt6Core Qt6Widgets Qt6Gui Qt6Concurrent Qt6DBus Qt6Sql Qt6Network dtkcore6 dtkgui6 dtkwidget6
Cflags: -I"@CMAKE_INSTALL_FULL_INCLUDEDIR@"
Libs: -L"@CMAKE_INSTALL_FULL_LIBDIR@" -l@BIN_NAME@
Libs.private: -L"@CMAKE_INSTALL_FULL_LIBDIR@" -l@BIN_NAME@
14 changes: 13 additions & 1 deletion assets/dev/dfm6-base/dfm6-baseConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
include(CMakeFindDependencyMacro)

# 添加必要的依赖
find_dependency(dfm6-io)
find_dependency(dfm6-mount)
find_dependency(dfm6-burn)
find_dependency(Qt6 COMPONENTS Core Widgets Gui Concurrent DBus Sql Network)
find_dependency(Dtk6 COMPONENTS Core Widget Gui)

set(@BIN_NAME@_INCLUDE_DIR @CMAKE_INSTALL_FULL_INCLUDEDIR@)
set(@BIN_NAME@_LIBRARIES @BIN_NAME@)
include_directories("${@BIN_NAME@_INCLUDE_DIR}")

if(NOT TARGET @BIN_NAME@)
include("${CMAKE_CURRENT_LIST_DIR}/@[email protected]")
endif()
2 changes: 1 addition & 1 deletion debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ Depends:
qtxdg-dev-tools
Conflicts: dde-workspace (<< 2.90.5), dde-file-manager-oem, dde-desktop-plugins
Replaces: dde-file-manager-oem, dde-file-manager (<< 6.0.1), dde-desktop-plugins
Recommends: qt5dxcb-plugin, deepin-screensaver, dcc-wallpapersetting-plugin
Recommends: deepin-screensaver
Description: deepin desktop-environment - desktop module
Deepin Desktop Environment (DDE) - desktop module.

Expand Down
29 changes: 29 additions & 0 deletions include/dfm-base/dfm_plugin_defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

DFMBASE_BEGIN_NAMESPACE

// TODO: auto register

namespace Plugins {
namespace Core {
inline constexpr std::initializer_list<const char *> kCommon {
Expand All @@ -27,6 +29,10 @@ inline constexpr std::initializer_list<const char *> kFileManager {
"dfmplugin-detailspace", "dfmplugin-sidebar", "dfmplugin-titlebar",
"dfmplugin-workspace", "dfmplugin-smbbrowser"
};

inline constexpr std::initializer_list<const char *> kDesktop {
"ddplugin-core", "ddplugin-canvas", "ddplugin-background", "ddplugin-organizer"
};
} // namespace Core

namespace Edge {
Expand All @@ -38,6 +44,10 @@ inline constexpr std::initializer_list<const char *> kFileManager {
"dfmplugin-trash", "dfmplugin-recent", "dfmplugin-avfsbrowser",
"dfmplugin-search", "dfmplugin-myshares", "dfmplugin-vault"
};

inline constexpr std::initializer_list<const char *> kDesktop {
"ddplugin-wallpapersetting"
};
} // namespace Edge

namespace Utils {
Expand All @@ -49,13 +59,32 @@ inline QStringList filemanagerCorePlugins()
std::copy(Plugins::Core::kFileManager.begin(), Plugins::Core::kFileManager.end(), std::back_inserter(result));
return result;
}

inline QStringList filemanagerAllPlugins()
{
QStringList result { filemanagerCorePlugins() };
std::copy(Plugins::Edge::kCommon.begin(), Plugins::Edge::kCommon.end(), std::back_inserter(result));
std::copy(Plugins::Edge::kFileManager.begin(), Plugins::Edge::kFileManager.end(), std::back_inserter(result));
return result;
}

inline QStringList desktopCorePlugins()
{
QStringList result;
std::copy(Plugins::Core::kCommon.begin(), Plugins::Core::kCommon.end(), std::back_inserter(result));
std::copy(Plugins::Core::kCommonVirtual.begin(), Plugins::Core::kCommonVirtual.end(), std::back_inserter(result));
std::copy(Plugins::Core::kDesktop.begin(), Plugins::Core::kDesktop.end(), std::back_inserter(result));
return result;
}

inline QStringList desktopAllPlugins()
{
QStringList result { desktopCorePlugins() };
std::copy(Plugins::Edge::kCommon.begin(), Plugins::Edge::kCommon.end(), std::back_inserter(result));
std::copy(Plugins::Edge::kDesktop.begin(), Plugins::Edge::kDesktop.end(), std::back_inserter(result));
return result;
}

} // namespace Utils
} // namespace Plugins

Expand Down
14 changes: 7 additions & 7 deletions src/apps/dde-file-manager-preview/pluginpreviews/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ if ((NOT ${CMAKE_SYSTEM_PROCESSOR} STREQUAL "sw_64")
AND (NOT ${CMAKE_SYSTEM_PROCESSOR} STREQUAL "loongarch64")
AND (NOT ${CMAKE_SYSTEM_PROCESSOR} STREQUAL "riscv64"))

# find_package(PkgConfig REQUIRED)
# pkg_search_module(libdmr QUIET libdmr)
# if (libdmr_FOUND)
# add_subdirectory(video-preview)
# else()
# message(WARNING "libdmr not found, video-preview plugin will not build!")
# endif()
find_package(PkgConfig REQUIRED)
pkg_search_module(libdmr QUIET libdmr)
if (libdmr_FOUND)
add_subdirectory(video-preview)
else()
message(WARNING "libdmr not found, video-preview plugin will not build!")
endif()
endif()
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.10)

project(deepin-video-preview-plugin)
project(dde-video-preview-plugin)

set(CMAKE_INCLUDE_CURRENT_DIR ON)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ VideoStatusBar::VideoStatusBar(VideoPreview *preview)

QPalette pa_label;

pa_label.setColor(QPalette::Foreground, QColor("#303030"));
pa_label.setColor(QPalette::WindowText, QColor("#303030"));
timeLabel->setPalette(pa_label);

slider->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ VideoWidget::VideoWidget(VideoPreview *preview)
setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);

QPalette pa;
pa.setColor(QPalette::Foreground, Qt::white);
pa.setColor(QPalette::WindowText, Qt::white);

title->setPalette(pa);

Expand All @@ -31,7 +31,7 @@ QSize VideoWidget::sizeHint() const
if (window()->windowHandle()) {
screen_size = window()->windowHandle()->screen()->availableSize();
} else {
screen_size = qApp->desktop()->size();
screen_size = QGuiApplication::primaryScreen()->availableSize();
}

return QSize(p->info.width, p->info.height).scaled(qMin(p->info.width, int(screen_size.width() * 0.5)), qMin(p->info.height, int(screen_size.height() * 0.5)), Qt::KeepAspectRatio);
Expand Down
72 changes: 43 additions & 29 deletions src/dfm-base/dfm-base.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -88,34 +88,37 @@ else()
endif()

# TODO: move Widgets to ${DFM_EXTRA_LIBRARIES}
target_link_libraries(${BIN_NAME} PUBLIC
Qt${QT_VERSION_MAJOR}::Core
Qt${QT_VERSION_MAJOR}::Widgets
Qt${QT_VERSION_MAJOR}::Gui
Qt${QT_VERSION_MAJOR}::Concurrent
Qt${QT_VERSION_MAJOR}::DBus
Qt${QT_VERSION_MAJOR}::Sql
Qt${QT_VERSION_MAJOR}::Network
Dtk${DTK_VERSION_MAJOR}::Core
Dtk${DTK_VERSION_MAJOR}::Widget
Dtk${DTK_VERSION_MAJOR}::Gui
dfm${DTK_VERSION_MAJOR}-io
dfm${DTK_VERSION_MAJOR}-mount
dfm${DTK_VERSION_MAJOR}-burn
PkgConfig::mount
PkgConfig::gio
poppler-cpp
${XCB_LIBRARIES}
xcb-xfixes
${DFM_EXTRA_LIBRARIES}
target_link_libraries(${BIN_NAME}
PUBLIC
Qt${QT_VERSION_MAJOR}::Core
Qt${QT_VERSION_MAJOR}::Widgets
Qt${QT_VERSION_MAJOR}::Gui
Qt${QT_VERSION_MAJOR}::Concurrent
Qt${QT_VERSION_MAJOR}::DBus
Qt${QT_VERSION_MAJOR}::Sql
Qt${QT_VERSION_MAJOR}::Network
Dtk${DTK_VERSION_MAJOR}::Core
Dtk${DTK_VERSION_MAJOR}::Widget
Dtk${DTK_VERSION_MAJOR}::Gui
dfm${DTK_VERSION_MAJOR}-io
dfm${DTK_VERSION_MAJOR}-mount
dfm${DTK_VERSION_MAJOR}-burn
PkgConfig::mount
PkgConfig::gio
poppler-cpp
${XCB_LIBRARIES}
xcb-xfixes
${DFM_EXTRA_LIBRARIES}
)

target_include_directories(${BIN_NAME} PUBLIC
${PROJECT_SOURCE_DIR}/include
${CMAKE_CURRENT_SOURCE_DIR}/..
${DFM_IO_HEADERS}
${DFM_MOUNT_HEADERS}
${DFM_BURN_HEADERS}
target_include_directories(${BIN_NAME}
PUBLIC
"$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>"
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/..>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
${DFM_IO_HEADERS}
${DFM_MOUNT_HEADERS}
${DFM_BURN_HEADERS}
)

set(ShareDir ${CMAKE_INSTALL_PREFIX}/share/dde-file-manager) # also use for install
Expand All @@ -133,12 +136,23 @@ set_target_properties(${BIN_NAME} PROPERTIES
)

# install library file
install(TARGETS ${BIN_NAME} LIBRARY DESTINATION ${LIB_INSTALL_DIR})
install(TARGETS ${BIN_NAME} EXPORT ${BIN_NAME}Targets
LIBRARY DESTINATION ${LIB_INSTALL_DIR}
ARCHIVE DESTINATION ${LIB_INSTALL_DIR}
RUNTIME DESTINATION ${BIN_INSTALL_DIR}
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)

install(EXPORT ${BIN_NAME}Targets
FILE ${BIN_NAME}Targets.cmake
NAMESPACE DFM${DTK_VERSION_MAJOR}::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${BIN_NAME}
)

# for pc file config
set(PC_LIBS_PRIVATE Qt${QT_VERSION_MAJOR}Core)
set(PC_REQ_PRIVATE)
set(PC_REQ_PUBLIC)
set(PC_REQ_PRIVATE "")
set(PC_REQ_PUBLIC "dfm${QT_VERSION_MAJOR}-io dfm${QT_VERSION_MAJOR}-mount dfm${QT_VERSION_MAJOR}-burn Qt${QT_VERSION_MAJOR}Core Qt${QT_VERSION_MAJOR}Widgets Qt${QT_VERSION_MAJOR}Gui Qt${QT_VERSION_MAJOR}Concurrent Qt${QT_VERSION_MAJOR}DBus Qt${QT_VERSION_MAJOR}Sql Qt${QT_VERSION_MAJOR}Network dtk${DTK_VERSION_MAJOR}core dtk${DTK_VERSION_MAJOR}gui dtk${DTK_VERSION_MAJOR}widget")

# config pkgconfig file
configure_file(${PROJECT_SOURCE_DIR}/assets/dev/${BIN_NAME}/${BIN_NAME}.pc.in ${BIN_NAME}.pc @ONLY)
Expand Down
29 changes: 21 additions & 8 deletions src/external/dde-shell-plugins/panel-desktop/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@
#include <dfm-base/utils/sysinfoutils.h>
#include <dfm-base/base/configs/dconfig/dconfigmanager.h>
#include <dfm-base/base/application/application.h>
#include <dfm-base/base/application/settings.h>

Check warning on line 12 in src/external/dde-shell-plugins/panel-desktop/main.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <dfm-base/base/application/settings.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.

Check warning on line 12 in src/external/dde-shell-plugins/panel-desktop/main.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

Include file: <dfm-base/base/application/settings.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <dfm-base/dfm_global_defines.h>

Check warning on line 13 in src/external/dde-shell-plugins/panel-desktop/main.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <dfm-base/dfm_global_defines.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.

Check warning on line 13 in src/external/dde-shell-plugins/panel-desktop/main.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

Include file: <dfm-base/dfm_global_defines.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <dfm-base/utils/windowutils.h>

Check warning on line 14 in src/external/dde-shell-plugins/panel-desktop/main.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <dfm-base/utils/windowutils.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.

Check warning on line 14 in src/external/dde-shell-plugins/panel-desktop/main.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

Include file: <dfm-base/utils/windowutils.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <dfm-base/dfm_plugin_defines.h>

Check warning on line 15 in src/external/dde-shell-plugins/panel-desktop/main.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <dfm-base/dfm_plugin_defines.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.

Check warning on line 15 in src/external/dde-shell-plugins/panel-desktop/main.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

Include file: <dfm-base/dfm_plugin_defines.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.

#include <dfm-framework/dpf.h>

Check warning on line 17 in src/external/dde-shell-plugins/panel-desktop/main.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <dfm-framework/dpf.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.

Check warning on line 17 in src/external/dde-shell-plugins/panel-desktop/main.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

Include file: <dfm-framework/dpf.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.

#include <dde-shell/panel.h>
#include <dde-shell/pluginfactory.h>
Expand Down Expand Up @@ -58,6 +59,24 @@

namespace desktop {

static bool lazyLoadFilter(const QString &name)
{
static const QStringList kLazyLoadPluginNames { "ddplugin-wallpapersetting", "dfmplugin-bookmark", "dfmplugin-propertydialog",
"dfmplugin-tag", "dfmplugin-burn", "dfmplugin-dirshare", "dfmplugin-emblem" };

if (kLazyLoadPluginNames.contains(name))
return true;

static const auto &kAllNames {
DFMBASE_NAMESPACE::Plugins::Utils::desktopCorePlugins()
};

if (!kAllNames.contains(name))
return true;

return false;
}

static bool pluginsLoad()
{
QString msg;
Expand All @@ -79,13 +98,6 @@

qCInfo(logAppDesktop) << "Using plugins dir:" << pluginsDirs;

// TODO(xust): the GVolumeMonitor object MUST be initialized in MAIN thread, so a initialize operation is added in dbusregister::initialize.
// the function `DFMIO::DFMUtils::fileIsRemovable` indirectly initialized the GVolumeMonitor object and the function is invoked everywhere.
// solve the indirectly initialize issue and then push the plugin to lazy list.
static const QStringList kLazyLoadPluginNames { "ddplugin-wallpapersetting", "dfmplugin-bookmark", "dfmplugin-propertydialog",
"dfmplugin-tag", "dfmplugin-burn", "dfmplugin-dirshare", "dfmplugin-emblem",
"dfmplugin-filepreview" };

QStringList blackNames { DConfigManager::instance()->value(kPluginsDConfName, "desktop.blackList").toStringList() };
#ifdef COMPILE_ON_V2X
if (DFMBASE_NAMESPACE::WindowUtils::isWayLand()) {
Expand All @@ -95,7 +107,8 @@
}
}
#endif
DPF_NAMESPACE::LifeCycle::initialize({ kDesktopPluginInterface, kCommonPluginInterface }, pluginsDirs, blackNames, kLazyLoadPluginNames);
DPF_NAMESPACE::LifeCycle::initialize({ kDesktopPluginInterface, kCommonPluginInterface }, pluginsDirs, blackNames);
DPF_NAMESPACE::LifeCycle::setLazyloadFilter(lazyLoadFilter);

qCInfo(logAppDesktop) << "Depend library paths:" << DApplication::libraryPaths();
qCInfo(logAppDesktop) << "Load plugin paths: " << dpf::LifeCycle::pluginPaths();
Expand Down
Loading