-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add plugin framework structure and example
Add basic functions and an example. TODO: rename class name of those element, e.g: applet, containment corona, which is plasma's element. Issue: linuxdeepin/developer-center#5810
- Loading branch information
1 parent
9f6c7a7
commit a9348de
Showing
63 changed files
with
2,473 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. | ||
# | ||
# SPDX-License-Identifier: CC0-1.0 | ||
|
||
CMAKE_MINIMUM_REQUIRED(VERSION 3.10) | ||
|
||
set(DS_VERSION "1.0.0" CACHE STRING "Define project version") | ||
project(DDEShell | ||
VERSION "${DS_VERSION}" | ||
DESCRIPTION "dde-shell" | ||
HOMEPAGE_URL "https://github.com/linuxdeepin/dde-shell" | ||
LANGUAGES CXX | ||
) | ||
|
||
set(CMAKE_CXX_STANDARD 17) | ||
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) | ||
set(CMAKE_INSTALL_PREFIX /usr) | ||
endif () | ||
|
||
set(CMAKE_CXX_STANDARD 11) | ||
set(CMAKE_CXX_STANDARD_REQUIRED ON) | ||
set(CMAKE_AUTORCC ON) | ||
set(CMAKE_AUTOMOC ON) | ||
set(CMAKE_INCLUDE_CURRENT_DIR ON) | ||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON) | ||
|
||
set(DS_BUILD_WITH_QT6 ON CACHE BOOL "Build dde-shell with Qt6") | ||
|
||
if (DS_BUILD_WITH_QT6) | ||
set(QT_VERSION_MAJOR 6) | ||
set(DTK_VERSION_MAJOR 6) | ||
else() | ||
set(QT_VERSION_MAJOR 5) | ||
set(DTK_VERSION_MAJOR "") | ||
endif() | ||
|
||
include(GNUInstallDirs) | ||
include(CMakePackageConfigHelpers) | ||
|
||
set(LIB_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}" CACHE STRING "Library install path") | ||
set(DDE_SHELL_PACKAGE_INSTALL_DIR ${CMAKE_INSTALL_DATADIR}/dde-shell CACHE STRING "Package install path") | ||
set(DDE_SHELL_PLUGIN_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR}/dde-shell CACHE STRING "Plugin install path") | ||
set(INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_INCLUDEDIR}/dde-shell" CACHE STRING "Headers install path") | ||
set(CONFIG_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/DDEShell" CACHE STRING "CMake config file install directory") | ||
set(QML_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}/qt${QT_VERSION_MAJOR}/qml" CACHE STRING "Qml plugin install directory") | ||
|
||
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake") | ||
include(DDEShellPackageMacros) | ||
|
||
find_package(Qt${QT_VERSION_MAJOR} ${REQUIRED_QT_VERSION} REQUIRED COMPONENTS Core Gui Concurrent Quick) | ||
find_package(Dtk${DTK_VERSION_MAJOR} REQUIRED COMPONENTS Core Gui) | ||
|
||
add_subdirectory(frame) | ||
add_subdirectory(shell) | ||
add_subdirectory(example) | ||
|
||
configure_package_config_file( | ||
"${CMAKE_CURRENT_LIST_DIR}/misc/DDEShellConfig.cmake.in" | ||
"${CMAKE_CURRENT_BINARY_DIR}/DDEShellConfig.cmake" | ||
INSTALL_DESTINATION "${CONFIG_INSTALL_DIR}" | ||
) | ||
write_basic_package_version_file( | ||
"${CMAKE_CURRENT_BINARY_DIR}/DDEShellConfigVersion.cmake" | ||
VERSION ${VERSION} | ||
COMPATIBILITY SameMajorVersion | ||
) | ||
# Install cmake config file | ||
install(FILES "${PROJECT_SOURCE_DIR}/cmake/DDEShellPackageMacros.cmake" DESTINATION "${CONFIG_INSTALL_DIR}") | ||
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/DDEShellConfig.cmake" DESTINATION "${CONFIG_INSTALL_DIR}") | ||
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/DDEShellConfigVersion.cmake" DESTINATION "${CONFIG_INSTALL_DIR}") |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
include(CMakeParseArguments) | ||
|
||
macro(ds_build_package) | ||
set(oneValueArgs PACKAGE TARGET PACKAGE_ROOT_DIR) | ||
cmake_parse_arguments(_config "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) | ||
|
||
set(package_root_dir ${CMAKE_CURRENT_SOURCE_DIR}/package) | ||
if (DEFINED _config_PACKAGE_ROOT_DIR) | ||
set(package_root_dir ${_config_PACKAGE_ROOT_DIR}) | ||
endif() | ||
file(GLOB_RECURSE package_files ${package_root_dir}/*) | ||
add_custom_target(${_config_PACKAGE}_package ALL | ||
SOURCES ${package_files} | ||
) | ||
set(package_dirs ${PROJECT_BINARY_DIR}/packages/${_config_PACKAGE}/) | ||
add_custom_command(TARGET ${_config_PACKAGE}_package | ||
COMMAND ${CMAKE_COMMAND} -E copy_directory ${package_root_dir} ${package_dirs} | ||
) | ||
|
||
if (DEFINED _config_TARGET) | ||
set_target_properties(${_config_TARGET} PROPERTIES | ||
PREFIX "" | ||
OUTPUT_NAME ${_config_PACKAGE} | ||
LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/plugins/ | ||
) | ||
endif() | ||
endmacro() | ||
|
||
function(ds_install_package) | ||
ds_build_package(${ARGN}) | ||
install(DIRECTORY ${package_dirs} DESTINATION ${DDE_SHELL_PACKAGE_INSTALL_DIR}/${_config_PACKAGE}) | ||
|
||
if (DEFINED _config_TARGET) | ||
install(TARGETS ${_config_TARGET} DESTINATION ${DDE_SHELL_PLUGIN_INSTALL_DIR}/) | ||
endif() | ||
endfunction() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
Source: dde-shell | ||
Section: unknown | ||
Priority: optional | ||
Maintainer: Deepin Packages Builder <[email protected]> | ||
Build-Depends: | ||
debhelper-compat ( =12), | ||
cmake, | ||
qt6-base-dev, | ||
qt6-declarative-dev, | ||
qt6-base-dev-tools, | ||
qt6-tools-dev, | ||
libdtk6gui-dev, | ||
libdtk6core-dev, | ||
libdtkcommon-dev, | ||
Standards-Version: 3.9.8 | ||
Homepage: http://www.deepin.org | ||
|
||
Package: libdde-shell | ||
Architecture: any | ||
Depends: ${shlibs:Depends}, ${misc:Depends}, | ||
libdtkcore5 | ||
Multi-Arch: same | ||
Description: DDE Shell library | ||
DDE Shell is a plugin system that integrates plugins developed based on this plugin system into DDE. | ||
|
||
Package: libdde-shell-dev | ||
Architecture: any | ||
Depends: ${misc:Depends}, libdde-shell( =${binary:Version}) | ||
Description: DDE Shell devel library | ||
DDE Shell is a plugin system that integrates plugins developed based on this plugin system into DDE. | ||
|
||
Package: dde-shell | ||
Architecture: any | ||
Depends: ${shlibs:Depends}, ${misc:Depends}, libdde-shell( =${binary:Version}) | ||
Multi-Arch: same | ||
Description: An wrapper for developed based on dde-shell plugin system | ||
|
||
Package: dde-shell-example | ||
Architecture: any | ||
Depends: ${shlibs:Depends}, ${misc:Depends}, libdde-shell( =${binary:Version}) | ||
Multi-Arch: same | ||
Description: DDE Shell example | ||
This package contains some plugins based on dde-shell plugin system. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
usr/lib/*/*dde-shell/* | ||
usr/share/dde-shell/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
usr/bin/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
usr/lib/*/lib*.so | ||
usr/include | ||
usr/lib/*/cmake/*/*.cmake |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
usr/lib/*/lib*.so.* | ||
usr/lib/*/qt6/qml/org/deepin/ds/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/usr/bin/make -f | ||
DPKG_EXPORT_BUILDFLAGS = 1 | ||
include /usr/share/dpkg/default.mk | ||
|
||
DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH) | ||
|
||
VERSION = $(DEB_VERSION_UPSTREAM) | ||
PACK_VER = $(shell echo $(VERSION) | awk -F'[+_~-]' '{print $$1}') | ||
# Fix: invalid digit "8" in octal constant. e.g. u008 ==> 008 ==> 8 | ||
BUILD_VER = $(shell echo $(VERSION) | awk -F'[+_~-]' '{print $$2}' | sed 's/[^0-9]//g' | awk '{print int($$1)}') | ||
|
||
%: | ||
dh $@ | ||
|
||
override_dh_auto_configure: | ||
dh_auto_configure -- -DDS_VERSION=${PACK_VER} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. | ||
# | ||
# SPDX-License-Identifier: GPL-3.0-or-later | ||
|
||
find_package(Qt${QT_VERSION_MAJOR} ${REQUIRED_QT_VERSION} REQUIRED COMPONENTS Core Gui Quick) | ||
|
||
add_subdirectory(applet-example) | ||
add_subdirectory(applet-example-data) | ||
add_subdirectory(containment-example) | ||
add_subdirectory(corona-example) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. | ||
# | ||
# SPDX-License-Identifier: GPL-3.0-or-later | ||
|
||
add_library(ds-example-applet-data SHARED | ||
exampleapplet.h | ||
exampleapplet.cpp | ||
) | ||
|
||
target_link_libraries(ds-example-applet-data PRIVATE | ||
dde-shell-frame | ||
) | ||
|
||
ds_install_package(PACKAGE org.deepin.ds.applet-example-data TARGET ds-example-applet-data) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. | ||
// | ||
// SPDX-License-Identifier: GPL-3.0-or-later | ||
|
||
#include "exampleapplet.h" | ||
|
||
#include "pluginfactory.h" | ||
|
||
ExampleApplet::ExampleApplet(QObject *parent) | ||
: DApplet(parent) | ||
, m_mainText("Custom Applet") | ||
{ | ||
|
||
} | ||
|
||
QString ExampleApplet::mainText() const | ||
{ | ||
return m_mainText; | ||
} | ||
|
||
D_APPLET_CLASS(ExampleApplet) | ||
|
||
#include "exampleapplet.moc" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. | ||
// | ||
// SPDX-License-Identifier: GPL-3.0-or-later | ||
|
||
#pragma once | ||
|
||
#include "applet.h" | ||
|
||
DS_USE_NAMESPACE | ||
|
||
class Q_DECL_EXPORT ExampleApplet : public DApplet | ||
{ | ||
Q_OBJECT | ||
Q_PROPERTY(QString mainText READ mainText CONSTANT) | ||
public: | ||
ExampleApplet(QObject *parent = nullptr); | ||
|
||
QString mainText() const; | ||
private: | ||
QString m_mainText; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. | ||
// | ||
// SPDX-License-Identifier: LGPL-3.0-or-later | ||
|
||
import QtQuick 2.11 | ||
import QtQuick.Controls 2.15 | ||
|
||
import org.deepin.ds 1.0 | ||
|
||
AppletItem { | ||
objectName: "appplet data" | ||
implicitWidth: 200 | ||
implicitHeight: 100 | ||
Rectangle { | ||
anchors.fill: parent | ||
color: "gray" | ||
Text { | ||
anchors.centerIn: parent | ||
text: Applet.mainText | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"Plugin": { | ||
"Version": "1.0", | ||
"Id": "org.deepin.ds.applet-example-data", | ||
"Url": "main.qml", | ||
"Parent": "org.deepin.ds.containment-example" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. | ||
# | ||
# SPDX-License-Identifier: GPL-3.0-or-later | ||
|
||
ds_install_package(PACKAGE org.deepin.ds.applet-example) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. | ||
// | ||
// SPDX-License-Identifier: LGPL-3.0-or-later | ||
|
||
import QtQuick 2.11 | ||
import QtQuick.Controls 2.4 | ||
|
||
Text { | ||
color: "cyan" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. | ||
// | ||
// SPDX-License-Identifier: LGPL-3.0-or-later | ||
|
||
import QtQuick 2.11 | ||
import QtQuick.Controls 2.4 | ||
|
||
import org.deepin.ds 1.0 | ||
import "control" | ||
|
||
AppletItem { | ||
objectName: "appplet item" | ||
implicitWidth: 100 | ||
implicitHeight: 100 | ||
Rectangle { | ||
anchors.fill: parent | ||
color: "green" | ||
TextEx { | ||
anchors.centerIn: parent | ||
text: "Hello world" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"Plugin": { | ||
"Version": "1.0", | ||
"Id": "org.deepin.ds.applet-example", | ||
"Url": "main.qml", | ||
"Parent": "org.deepin.ds.containment-example" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. | ||
# | ||
# SPDX-License-Identifier: GPL-3.0-or-later | ||
|
||
ds_install_package(PACKAGE org.deepin.ds.containment-example) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. | ||
// | ||
// SPDX-License-Identifier: LGPL-3.0-or-later | ||
|
||
import QtQuick 2.15 | ||
import QtQuick.Controls 2.4 | ||
import QtQuick.Layouts 1.11 | ||
|
||
import org.deepin.ds 1.0 | ||
|
||
ContainmentItem { | ||
id: root | ||
objectName: "containment item" | ||
RowLayout { | ||
Repeater { | ||
model: Applet.appletItems | ||
delegate: Control { | ||
contentItem: modelData | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"Plugin": { | ||
"Version": "1.0", | ||
"Id": "org.deepin.ds.containment-example", | ||
"Url": "main.qml", | ||
"Parent": "org.deepin.ds.corona-example", | ||
"ContainmentType": "Containment" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. | ||
# | ||
# SPDX-License-Identifier: GPL-3.0-or-later | ||
|
||
add_library(ds-corona-example SHARED | ||
examplecorona.cpp | ||
examplecorona.h | ||
) | ||
|
||
target_link_libraries(ds-corona-example PRIVATE | ||
dde-shell-frame | ||
) | ||
|
||
ds_install_package(PACKAGE org.deepin.ds.corona-example TARGET ds-corona-example) |
Oops, something went wrong.