-
Notifications
You must be signed in to change notification settings - Fork 75
feat: add card-type plugin support to dock panel #1659
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
Open
wjyrich
wants to merge
2
commits into
linuxdeepin:master
Choose a base branch
from
wjyrich:CardPlugin
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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: 2026 UnionTech Software Technology Co., Ltd. | ||
| # | ||
| # SPDX-License-Identifier: GPL-3.0-or-later | ||
|
|
||
| ds_install_package(PACKAGE org.deepin.ds.dock.cardleft) |
This file contains hidden or 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,216 @@ | ||
| // SPDX-FileCopyrightText: 2026 UnionTech Software Technology Co., Ltd. | ||
| // | ||
| // SPDX-License-Identifier: GPL-3.0-or-later | ||
|
|
||
| import QtQuick 2.15 | ||
| import QtQuick.Controls 2.15 | ||
| import QtQuick.Window 2.15 | ||
| import QtWayland.Compositor | ||
|
|
||
| import org.deepin.ds 1.0 | ||
| import org.deepin.ds.dock 1.0 | ||
| import org.deepin.dtk 1.0 as D | ||
|
|
||
| AppletDockItem { | ||
| id: root | ||
|
|
||
| readonly property bool fashionMode: Panel.fashionMode | ||
| readonly property int dockSize: Panel.rootObject.dockSize | ||
| readonly property int hoverInset: 3 | ||
| readonly property real taskbarRadius: Panel.rootObject.fashionDock.backgroundRadius | ||
| readonly property real hoverBackgroundRadius: taskbarRadius - hoverInset | ||
| readonly property int adaptiveCardLeftWidth: 150 + Math.max(0, dockSize / 4) | ||
| readonly property int rightContentPadding: Math.max(10, Math.round(adaptiveCardLeftWidth * 0.07)) | ||
| readonly property int verticalInset: Math.max(5, Math.round(dockSize * 0.16)) | ||
| readonly property int pageContentHeight: Math.max(24, dockSize - verticalInset * 2) | ||
|
|
||
| readonly property color primaryTextColor: Panel.colorTheme === Dock.Dark | ||
| ? Qt.rgba(1, 1, 1, 0.96) | ||
| : Qt.rgba(0, 0, 0, 0.92) | ||
|
|
||
| dockOrder: 5 | ||
| shouldVisible: fashionMode && pageCount > 0 | ||
| readonly property int pageCount: DockCompositor.cardPluginSurfaces.count | ||
| property bool contentHovered: false | ||
| readonly property bool effectiveHovered: rootHoverHandler.hovered || contentHovered | ||
|
|
||
| visible: shouldVisible | ||
| implicitWidth: adaptiveCardLeftWidth | ||
| implicitHeight: dockSize | ||
| clip: true | ||
|
|
||
| function updateContentHovered() { | ||
| const item = swipeView.currentItem | ||
| contentHovered = !!item && item.surfaceHovered | ||
| } | ||
|
|
||
| HoverHandler { | ||
| id: rootHoverHandler | ||
| acceptedDevices: PointerDevice.Mouse | PointerDevice.TouchPad | PointerDevice.Stylus | ||
| } | ||
|
|
||
| AppletItemBackground { | ||
| x: root.hoverInset | ||
| y: root.hoverInset | ||
| width: parent.width - root.hoverInset | ||
| height: parent.height - root.hoverInset * 2 | ||
| radius: root.hoverBackgroundRadius | ||
| enabled: false | ||
| opacity: root.effectiveHovered ? 1 : 0 | ||
| D.ColorSelector.hovered: root.effectiveHovered | ||
|
|
||
| Behavior on opacity { | ||
| NumberAnimation { | ||
| duration: 150 | ||
| easing.type: Easing.OutCubic | ||
| } | ||
| } | ||
| } | ||
|
|
||
| Item { | ||
| anchors.right: parent.right | ||
| anchors.rightMargin: 8 | ||
| anchors.verticalCenter: parent.verticalCenter | ||
| visible: root.effectiveHovered && root.pageCount > 1 | ||
| width: pageIndicator.implicitHeight | ||
| height: pageIndicator.implicitWidth | ||
|
|
||
| PageIndicator { | ||
| id: pageIndicator | ||
|
|
||
| anchors.centerIn: parent | ||
| rotation: 90 | ||
| count: swipeView.count | ||
| currentIndex: swipeView.currentIndex | ||
| padding: 0 | ||
| spacing: 4 | ||
|
|
||
| delegate: Rectangle { | ||
| required property int index | ||
|
|
||
| implicitWidth: 2 | ||
| implicitHeight: 2 | ||
| radius: width / 2 | ||
| color: root.primaryTextColor | ||
| opacity: index === pageIndicator.currentIndex ? 1 : 0.35 | ||
| } | ||
| } | ||
| } | ||
|
|
||
| SwipeView { | ||
| id: swipeView | ||
|
|
||
| anchors.left: parent.left | ||
| anchors.right: parent.right | ||
| anchors.verticalCenter: parent.verticalCenter | ||
| anchors.leftMargin: 8 | ||
| anchors.rightMargin: root.rightContentPadding | ||
| height: root.pageContentHeight | ||
| orientation: Qt.Vertical | ||
| interactive: count > 1 | ||
| clip: true | ||
|
|
||
| onCurrentItemChanged: { | ||
| root.updateContentHovered() | ||
| surfaceGeometryUpdateTimer.restart() | ||
| } | ||
|
|
||
| Repeater { | ||
| model: DockCompositor.cardPluginSurfaces | ||
|
|
||
| delegate: Item { | ||
| id: surfaceHost | ||
|
|
||
| property var plugin: model.shellSurface | ||
| readonly property bool surfaceHovered: SwipeView.isCurrentItem && surfaceItem.hovered | ||
|
|
||
| ShellSurfaceItemProxy { | ||
| id: surfaceItem | ||
| width: parent.width | ||
| height: parent.height | ||
| shellSurface: surfaceHost.plugin | ||
| } | ||
|
|
||
| function updateSurfaceGeometry() { | ||
| if (!plugin || !SwipeView.isCurrentItem || !surfaceHost.Window.window) { | ||
| return | ||
| } | ||
|
|
||
| const window = surfaceHost.Window.window | ||
| const windowPosition = surfaceHost.mapToItem(window.contentItem, 0, 0) | ||
| const globalPosition = Qt.point(windowPosition.x + window.x, | ||
| windowPosition.y + window.y) | ||
|
|
||
| plugin.updatePluginGeometry(Qt.rect(Math.round(windowPosition.x), | ||
| Math.round(windowPosition.y), | ||
| Math.round(width), | ||
| Math.round(height))) | ||
| plugin.setGlobalPos(Qt.point(Math.round(globalPosition.x), | ||
| Math.round(globalPosition.y))) | ||
| surfaceItem.fixPosition() | ||
| } | ||
|
|
||
| Component.onCompleted: updateSurfaceGeometry() | ||
| onWidthChanged: geometryUpdateTimer.restart() | ||
| onHeightChanged: geometryUpdateTimer.restart() | ||
| onVisibleChanged: { | ||
| geometryUpdateTimer.restart() | ||
| root.updateContentHovered() | ||
| } | ||
| onSurfaceHoveredChanged: root.updateContentHovered() | ||
|
|
||
| Timer { | ||
| id: geometryUpdateTimer | ||
| interval: 50 | ||
| repeat: false | ||
| onTriggered: surfaceHost.updateSurfaceGeometry() | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| Item { | ||
| anchors.fill: parent | ||
| z: 1 | ||
|
|
||
| WheelHandler { | ||
| target: null | ||
| enabled: swipeView.count > 1 | ||
| acceptedDevices: PointerDevice.Mouse | PointerDevice.TouchPad | ||
|
|
||
| onWheel: function(wheel) { | ||
| const deltaY = wheel.angleDelta.y !== 0 ? wheel.angleDelta.y : wheel.pixelDelta.y | ||
| if (deltaY === 0) { | ||
| return | ||
| } | ||
|
|
||
| const step = deltaY < 0 ? 1 : -1 | ||
| const nextIndex = (swipeView.currentIndex + step + swipeView.count) % swipeView.count | ||
| swipeView.setCurrentIndex(nextIndex) | ||
| wheel.accepted = true | ||
| } | ||
| } | ||
| } | ||
|
|
||
| Connections { | ||
| target: swipeView.contentItem | ||
| ignoreUnknownSignals: true | ||
|
|
||
| function onContentYChanged() { | ||
| surfaceGeometryUpdateTimer.restart() | ||
| } | ||
| } | ||
|
|
||
| Timer { | ||
| id: surfaceGeometryUpdateTimer | ||
|
|
||
| interval: 50 | ||
| repeat: false | ||
| onTriggered: { | ||
| const item = swipeView.currentItem | ||
| if (item) { | ||
| item.updateSurfaceGeometry() | ||
| } | ||
| } | ||
| } | ||
| } |
This file contains hidden or 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.dock.cardleft", | ||
| "Url": "CardLeftDockArea.qml", | ||
| "Parent": "org.deepin.ds.dock" | ||
| } | ||
| } | ||
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.