Skip to content

Commit

Permalink
feat: add dock-shell
Browse files Browse the repository at this point in the history
增加DDockApplet类型,dock的子插件应统一继承此类,方便统一管理
增加DDockItem类型,导出qml组件,提供统一视觉的的tips,icon,...

log: as title
  • Loading branch information
ssk-wh committed May 17, 2024
1 parent 0300899 commit 2177af5
Show file tree
Hide file tree
Showing 11 changed files with 398 additions and 4 deletions.
1 change: 1 addition & 0 deletions debian/dde-shell.install
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ usr/share/dde-shell/org.deepin.ds.dde-am*/
usr/libexec/dockplugin-loader
usr/lib/*/qt5/plugins/wayland-shell-integration
usr/lib/*/libdde-dockplugin-interface.so.*
usr/lib/*/libdock-plugin.so.*
usr/share/dsg/configs/org.deepin.ds.dock/
usr/lib/dde-dock/tmp/plugins
usr/lib/dde-dock/tmp/plugins/quick-trays
Expand Down
40 changes: 36 additions & 4 deletions panels/dock/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ endif(BUILD_WITH_X11)
ds_install_package(PACKAGE org.deepin.ds.dock TARGET dockpanel)
ds_handle_package_translation(PACKAGE org.deepin.ds.dock)

# dock shell
if ((${CMAKE_BUILD_TYPE} MATCHES "Debug"))
add_subdirectory(dock-shell-example)
endif ()

# sub plugins
add_subdirectory(clipboarditem)
add_subdirectory(workspaceitem)
Expand All @@ -93,14 +98,20 @@ add_subdirectory(dockplugin)

# dock qml element(include Dock.xx defines and DockCompositor)
file(
GLOB dock_plugin_sources
GLOB dock_plugin_headers
constants.h
ddockapplet.h
)
file(
GLOB dock_plugin_sources
# dockfilterproxymodel.cpp
# dockfilterproxymodel.h
dockpluginmanagerextension_p.h
dockpluginmanagerextension.cpp
dockpluginmanagerintegration_p.h
dockpluginmanagerintegration.cpp
private/ddockapplet_p.h
ddockapplet.cpp
)

set_source_files_properties(DockCompositor.qml PROPERTIES
Expand All @@ -117,15 +128,22 @@ set_source_files_properties(DockPalette.qml PROPERTIES

qt_policy(SET QTP0001 OLD)
qt_add_qml_module(dock-plugin
PLUGIN_TARGET dock-plugin
PLUGIN_TARGET dock-qml-plugin
URI "org.deepin.ds.dock"
VERSION "1.0"
SHARED
SOURCES ${dock_plugin_sources}
QML_FILES DockCompositor.qml OverflowContainer.qml MenuHelper.qml DockPalette.qml
SOURCES ${dock_plugin_headers} ${dock_plugin_sources}
QML_FILES DockCompositor.qml OverflowContainer.qml MenuHelper.qml DockPalette.qml DockItem.qml
OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/plugins/org/deepin/ds/dock/
)

set_target_properties(dock-plugin PROPERTIES
VERSION ${CMAKE_PROJECT_VERSION}
SOVERSION ${CMAKE_PROJECT_VERSION_MAJOR}
OUTPUT_NAME dock-plugin
EXPORT_NAME DockShell
)

qt_generate_wayland_protocol_server_sources(dock-plugin
FILES
${CMAKE_CURRENT_SOURCE_DIR}/dockplugin/protocol/dock-plugin-manager-v1.xml
Expand All @@ -137,6 +155,7 @@ target_link_libraries(dock-plugin PUBLIC
Qt${QT_VERSION_MAJOR}::Qml
Qt${QT_VERSION_MAJOR}::Widgets
Qt${QT_VERSION_MAJOR}::WaylandCompositor
dde-shell-frame
PRIVATE
PkgConfig::WaylandClient
Qt${QT_VERSION_MAJOR}::WaylandCompositorPrivate
Expand All @@ -147,6 +166,19 @@ target_include_directories(dock-plugin
$<TARGET_PROPERTY:dde-shell-frame,INTERFACE_INCLUDE_DIRECTORIES>
)

target_include_directories(dock-plugin INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}>
$<INSTALL_INTERFACE:${INCLUDE_INSTALL_DIR}/dockshell>
)

target_link_directories(dock-plugin INTERFACE
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/plugins/org/deepin/ds/dock/>
$<INSTALL_INTERFACE:${LIB_INSTALL_DIR}>
)

install(FILES ${dock_plugin_headers} DESTINATION "${INCLUDE_INSTALL_DIR}/dockshell")
install(TARGETS dock-plugin DESTINATION "${LIB_INSTALL_DIR}")
install(DIRECTORY "${PROJECT_BINARY_DIR}/plugins/org/deepin/ds/dock/" DESTINATION "${QML_INSTALL_DIR}/org/deepin/ds/dock/")
dtk_add_config_meta_files(APPID org.deepin.ds.dock FILES dconfig/org.deepin.ds.dock.json)
dtk_add_config_meta_files(APPID org.deepin.ds.dock FILES dconfig/org.deepin.ds.dock.power.json)
63 changes: 63 additions & 0 deletions panels/dock/DockItem.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

import QtQuick 2.15
import QtQuick.Controls 2.15

import org.deepin.ds 1.0
import org.deepin.dtk 1.0 as D
import org.deepin.dtk.private 1.0 as DP
import org.deepin.ds.dock 1.0

AppletItem {
id: root
property int dockOrder
property bool shouldVisible
property alias toolButtonColor: backgroundButton.color1
property alias toolButtonBorderColor: backgroundButton.outsideBorderColor
property alias toolTip: toolTip.text
property alias icon: button.icon.name

signal clicked

PanelToolTip {
id: toolTip
}
D.ToolButton {
id: button
anchors.centerIn: parent
width: 30
height: 30
icon.width: 16
icon.height: 16

display: D.IconLabel.IconOnly
onClicked: {
toolTip.close()
root.clicked()
}

onHoveredChanged: {
if (toolTip.text === "")
return

if (hovered) {
var point = Applet.rootObject.mapToItem(null, Applet.rootObject.width / 2, 0)
toolTip.toolTipX = point.x
toolTip.toolTipY = point.y
toolTip.open()
} else {
toolTip.close()
}
}

background: DP.ButtonPanel {
id: backgroundButton

button: button
color2: color1
insideBorderColor: null
}
}
}
109 changes: 109 additions & 0 deletions panels/dock/ddockapplet.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

#include "ddockapplet.h"
#include "private/ddockapplet_p.h"

#include <QLoggingCategory>

DS_BEGIN_NAMESPACE

DCORE_USE_NAMESPACE

Q_DECLARE_LOGGING_CATEGORY(dsLog)

DDockAppletPrivate::DDockAppletPrivate(DDockApplet *qq)
: DAppletPrivate(qq)
{

}

DDockAppletPrivate::~DDockAppletPrivate()
{

}

DDockApplet::DDockApplet(QObject *parent)
: DDockApplet(*new DDockAppletPrivate(this), parent)
{

}

DDockApplet::DDockApplet(DDockAppletPrivate &dd, QObject *parent)
: DApplet(dd, parent)
{

}

DDockApplet::~DDockApplet()
{
qDebug(dsLog) << "Destroyed DDockApplet:" << pluginId() << id();
}

/*!
A unique name that identifies the plug-in. The default implementation is `pluginId`.
*/
QString DDockApplet::name() const
{
return DApplet::pluginId();
}

/*!
A name that displays a name that matches the current locale
*/
/**
* @brief DDockApplet::displayName
* @return
*/

/**
* @brief DDockApplet::itemKey
* @return
*/

/**
* @brief DDockApplet::settingKey
* @return
*/

/*!
A dci icon for display
*/
QString DDockApplet::icon() const
{
D_DC(DDockApplet);

return d->icon;
}

void DDockApplet::setIcon(const QString &icon)
{
D_D(DDockApplet);

d->icon = icon;
Q_EMIT iconChanged(icon);
}

/*!
Whether the plug-in is displayed on the panel
*/
bool DDockApplet::visible() const
{
D_DC(DDockApplet);

return d->visible;
}

void DDockApplet::setVisible(bool visible)
{
D_D(DDockApplet);

if (d->visible == visible)
return;

d->visible = visible;
Q_EMIT visibleChanged(visible);
}

DS_END_NAMESPACE
54 changes: 54 additions & 0 deletions panels/dock/ddockapplet.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

#pragma once

#include "applet.h"
#include "dsglobal.h"

#include <DObject>

#include <QVariant>

DS_BEGIN_NAMESPACE
/**
* @brief You Can Used As Dock Plugins Sub Class
*/
class DDockAppletPrivate;
class DS_SHARE DDockApplet : public DApplet
{
Q_OBJECT
Q_PROPERTY(QString name READ name CONSTANT FINAL)
Q_PROPERTY(QString displayName READ displayName CONSTANT FINAL)
Q_PROPERTY(QString itemKey READ itemKey CONSTANT FINAL)
Q_PROPERTY(QString settingKey READ settingKey CONSTANT FINAL)
Q_PROPERTY(QString icon READ icon NOTIFY iconChanged FINAL)
Q_PROPERTY(bool visible READ visible WRITE setVisible NOTIFY visibleChanged FINAL);

D_DECLARE_PRIVATE(DDockApplet);

public:
explicit DDockApplet(QObject *parent = nullptr);
virtual ~DDockApplet() override;

virtual QString name() const;
virtual QString displayName() const = 0;
virtual QString itemKey() const = 0;
virtual QString settingKey() const = 0;

QString icon() const;
void setIcon(const QString &icon);

bool visible() const;
void setVisible(bool visible);

Q_SIGNALS:
void iconChanged(const QString &);
void visibleChanged(bool);

protected:
explicit DDockApplet(DDockAppletPrivate &dd, QObject *parent = nullptr);
};

DS_END_NAMESPACE
14 changes: 14 additions & 0 deletions panels/dock/dock-shell-example/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd.
#
# SPDX-License-Identifier: GPL-3.0-or-later

add_library(dock-shell-example SHARED
item.cpp
item.h
)

target_link_libraries(dock-shell-example PRIVATE
dock-plugin
)

ds_install_package(PACKAGE org.deepin.ds.dock.dock-shell-example TARGET dock-shell-example)
41 changes: 41 additions & 0 deletions panels/dock/dock-shell-example/item.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

#include "item.h"
#include "pluginfactory.h"

namespace dock {

Item::Item(QObject *parent)
: DDockApplet(parent)
{
// for debug
setVisible(true);
}

void Item::activate()
{
qDebug() << "item clicked";
}

QString Item::displayName() const
{
return "dock-shell-example";
}

QString Item::itemKey() const
{
return "dock-shell-example";
}

QString Item::settingKey() const
{
return "dock-shell-example";
}

D_APPLET_CLASS(Item)
}


#include "item.moc"
Loading

0 comments on commit 2177af5

Please sign in to comment.