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

feat: add dock-shell #367

Closed
Closed
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 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
2 changes: 2 additions & 0 deletions frame/containment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ DApplet *DContainment::createApplet(const DAppletData &data)
});

d->m_applets.append(applet);
Q_EMIT appletListChanged();
return applet;
}

Expand All @@ -66,6 +67,7 @@ void DContainment::removeApplet(DApplet *applet)
D_D(DContainment);
if (d->m_applets.contains(applet)) {
d->m_applets.removeOne(applet);
Q_EMIT appletListChanged();
}
if (auto view = applet->rootObject()) {
d->m_model->remove(view);
Expand Down
3 changes: 3 additions & 0 deletions frame/containment.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ class DS_SHARE DContainment : public DApplet
bool load() override;
bool init() override;

Q_SIGNALS:
void appletListChanged();

protected:
explicit DContainment(DContainmentPrivate &dd, QObject *parent = nullptr);
};
Expand Down
37 changes: 32 additions & 5 deletions panels/dock/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ add_library(dockpanel SHARED

target_link_libraries(dockpanel PRIVATE
PkgConfig::WaylandClient
dde-shell-frame
dock-plugin
)

if (BUILD_WITH_X11)
Expand Down Expand Up @@ -93,14 +93,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 +123,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 +150,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 +161,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
}
}
}
6 changes: 2 additions & 4 deletions panels/dock/clipboarditem/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@
add_library(dock-clipboarditem SHARED
clipboarditem.cpp
clipboarditem.h
../dockiteminfo.cpp
../dockiteminfo.h
)

target_link_libraries(dock-clipboarditem PRIVATE
dde-shell-frame
dock-plugin
)

ds_install_package(PACKAGE org.deepin.ds.dock.clipboarditem TARGET dock-clipboarditem)
ds_handle_package_translation(PACKAGE org.deepin.ds.dock.clipboarditem)
ds_handle_package_translation(PACKAGE org.deepin.ds.dock.clipboarditem)
61 changes: 13 additions & 48 deletions panels/dock/clipboarditem/clipboarditem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
//
// SPDX-License-Identifier: GPL-3.0-or-later

#include "applet.h"
#include "clipboarditem.h"
#include "pluginfactory.h"

Expand All @@ -25,64 +24,30 @@
}

ClipboardItem::ClipboardItem(QObject *parent)
: DApplet(parent)
, m_visible(true)
: DDockApplet(parent)
{

setVisible(true);
setIcon("clipboard");
}

void ClipboardItem::toggleClipboard()
QString ClipboardItem::displayName() const
{
clipboardDbus().method("Toggle").call();
return tr("Clipboard");
}

DockItemInfo ClipboardItem::dockItemInfo()
QString ClipboardItem::itemKey() const
{
DockItemInfo info;
info.name = "clipboard";
info.displayName = tr("Clipboard");
info.itemKey = "clipboard";
info.settingKey = "clipboard";
info.visible = m_visible;
{
const auto lightPalette = DGuiApplicationHelper::instance()->applicationPalette(DGuiApplicationHelper::LightType);
auto lightPixmap = DDciIcon::fromTheme("clipboard").pixmap(
qApp->devicePixelRatio(),
30,
DDciIcon::Light,
DDciIcon::Normal,
DDciIconPalette::fromQPalette(lightPalette)
);
QBuffer buffer(&info.iconLight);
if (buffer.open(QIODevice::WriteOnly)) {
lightPixmap.save(&buffer, "png");
}
}
{
const auto darkPalette = DGuiApplicationHelper::instance()->applicationPalette(DGuiApplicationHelper::DarkType);
auto darkPixmap = DDciIcon::fromTheme("clipboard").pixmap(
qApp->devicePixelRatio(),
30,
DDciIcon::Dark,
DDciIcon::Normal,
DDciIconPalette::fromQPalette(darkPalette)
);
QBuffer buffer(&info.iconDark);
if (buffer.open(QIODevice::WriteOnly)) {
darkPixmap.save(&buffer, "png");
}
}

return info;
return QString("clipboard");
}

void ClipboardItem::setVisible(bool visible)
QString ClipboardItem::settingKey() const
{
if (m_visible != visible) {
m_visible = visible;
return QString("clipboard");
}

Q_EMIT visibleChanged(visible);
}
void ClipboardItem::toggleClipboard()

Check warning on line 48 in panels/dock/clipboarditem/clipboarditem.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

The function 'toggleClipboard' is never used.
{
clipboardDbus().method("Toggle").call();
}

D_APPLET_CLASS(ClipboardItem)
Expand Down
21 changes: 6 additions & 15 deletions panels/dock/clipboarditem/clipboarditem.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,22 @@

#pragma once

#include "applet.h"
#include "ddockapplet.h"
#include "dsglobal.h"
#include "../dockiteminfo.h"

namespace dock {

class ClipboardItem : public DS_NAMESPACE::DApplet
class ClipboardItem : public DS_NAMESPACE::DDockApplet
{
Q_OBJECT
Q_PROPERTY(bool visible READ visible WRITE setVisible NOTIFY visibleChanged)
public:
explicit ClipboardItem(QObject *parent = nullptr);

Q_INVOKABLE void toggleClipboard();

Q_INVOKABLE DockItemInfo dockItemInfo();

inline bool visible() const { return m_visible;}
Q_INVOKABLE void setVisible(bool visible);
QString displayName() const override;
QString itemKey() const override;
QString settingKey() const override;

Q_SIGNALS:
void visibleChanged(bool);

private:
bool m_visible;
Q_INVOKABLE void toggleClipboard();
};

}
59 changes: 10 additions & 49 deletions panels/dock/clipboarditem/package/clipboarditem.qml
Original file line number Diff line number Diff line change
Expand Up @@ -2,61 +2,22 @@
//
// 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
import org.deepin.dtk.style 1.0 as DStyle

AppletItem {
id: clipboardItem
DockItem {
dockOrder: 1
shouldVisible: Applet.visible
toolButtonColor: DockPalette.toolButtonColor
toolButtonBorderColor: DockPalette.toolButtonBorderColor
toolTip: qsTr("Clipboard")
icon: Applet.icon

property int dockSize: Panel.rootObject.dockSize
property int dockOrder: 1
implicitWidth: Panel.rootObject.useColumnLayout ? dockSize : 30
implicitHeight: Panel.rootObject.useColumnLayout ? 30 : dockSize
property bool shouldVisible: Applet.visible
property D.Palette toolButtonColor: DockPalette.toolButtonColor
property D.Palette toolButtonBorderColor: DockPalette.toolButtonBorderColor

PanelToolTip {
id: toolTip
text: qsTr("Clipboard")
}
D.ToolButton {
id: button
anchors.centerIn: parent
width: 30
height: 30
icon.name: "clipboard"
icon.width: 16
icon.height: 16

display: D.IconLabel.IconOnly
onClicked: {
Applet.toggleClipboard()
toolTip.close()
}

onHoveredChanged: {
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 {
button: button
color1: clipboardItem.toolButtonColor
color2: clipboardItem.toolButtonColor
outsideBorderColor: clipboardItem.toolButtonBorderColor
insideBorderColor: null
}
onClicked: {
Applet.toggleClipboard()
}
}
Loading
Loading