Skip to content

Commit

Permalink
refactor: add desktop plugin definitions and improve plugin loading
Browse files Browse the repository at this point in the history
- Added desktop plugin definitions in dfm_plugin_defines.h:
  * Added Core::kDesktop for core desktop plugins
  * Added Edge::kDesktop for edge desktop plugins
  * Added desktopCorePlugins() and desktopAllPlugins() utility functions
- Improved plugin loading mechanism:
  * Replaced static lazy load list with dynamic filter function
  * Added plugin filter based on desktop core plugins list
  * Removed hardcoded plugin names from lazy loading list
- Updated package dependencies:
  * Removed qt5dxcb-plugin and dcc-wallpapersetting-plugin from Recommends

Log:
  • Loading branch information
Johnson-zs committed Jan 8, 2025
1 parent 515251f commit e8fec5c
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 9 deletions.
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
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 @@ -12,6 +12,7 @@
#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.

Expand Down Expand Up @@ -58,6 +59,24 @@ static const char *const kLibCore = "libdd-core-plugin.so";

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 @@ static bool pluginsLoad()

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 @@ static bool pluginsLoad()
}
}
#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

0 comments on commit e8fec5c

Please sign in to comment.