Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
yixinshark authored Jul 11, 2024
2 parents 1af9ba5 + 57544a2 commit ed7d6c9
Show file tree
Hide file tree
Showing 32 changed files with 219 additions and 128 deletions.
14 changes: 0 additions & 14 deletions frame/panel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,6 @@ void DPanelPrivate::ensurePopupWindow() const
if (m_popupWindow) {
qCDebug(dsLog) << "Create PopupWidow successfully.";
m_popupWindow->setTransientParent(q->window());
QObject::connect(m_popupWindow, &QWindow::visibleChanged, q, [this] (bool arg) {
if (arg)
closeWindow(m_toolTipWindow);
});
Q_EMIT const_cast<DPanel *>(q)->popupWindowChanged();
}
}
Expand All @@ -134,18 +130,8 @@ void DPanelPrivate::ensureToolTipWindow() const
if (m_toolTipWindow) {
qCDebug(dsLog) << "Create ToolTipWindow successfully.";
m_toolTipWindow->setTransientParent(q->window());
QObject::connect(m_toolTipWindow, &QWindow::visibleChanged, q, [this] (bool arg) {
if (arg)
closeWindow(m_popupWindow);
});
Q_EMIT const_cast<DPanel *>(q)->toolTipWindowChanged();
}
}

void DPanelPrivate::closeWindow(QWindow *window)
{
if (window && window->isVisible())
window->close();
}

DS_END_NAMESPACE
1 change: 0 additions & 1 deletion frame/private/panel_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ class DPanelPrivate : public DContainmentPrivate
void initDciSearchPaths();
void ensurePopupWindow() const;
void ensureToolTipWindow() const;
static void closeWindow(QWindow *window);

DQmlEngine *m_engine = nullptr;
QQuickWindow *m_popupWindow = nullptr;
Expand Down
7 changes: 7 additions & 0 deletions panels/dock/DockCompositor.qml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ Item {
return ret
}

function closeShellSurface(shellSurface)
{
if (shellSurface) {
shellSurface.close()
}
}

WaylandCompositor {
id: waylandCompositor
socketName: "dockplugin"
Expand Down
55 changes: 14 additions & 41 deletions panels/dock/OverflowContainer.qml
Original file line number Diff line number Diff line change
Expand Up @@ -7,50 +7,12 @@ import QtQuick.Layouts 2.15

Item {
id: root
// NOTE: if the value is assigned, and not -1, it will use this value as implicitWidth
property int assignedWidth: -1
property int assignedHeight: -1
required property bool useColumnLayout
property alias model: listView.model
property alias delegate: listView.delegate
property alias spacing: listView.spacing
property alias count: listView.count
property alias displaced: listView.displaced

// NOTE: the width calculated by contentItems
property int suggestedWidth: {
let width = 0
for (let child of listView.contentItem.visibleChildren) {
width = calculateImplicitWidth(width, child.implicitWidth)
}
return width
}

// NOTE: the height calculated by contentItems
property int suggestedHeight: {
let height = 0
for (let child of listView.contentItem.visibleChildren) {
height = calculateImplicitHeight(height, child.implicitHeight)
}
return height
}

// NOTE: provide width value for other objects
property int suggestedImplicitWidth : {
if (root.assignedWidth !== -1) {
return root.assignedWidth
}
return root.suggestedWidth
}

// NOTE: provide height value for other objects
property int suggestedImplicitHeight : {
if (root.assignedHeight !== -1) {
return root.assignedHeight
}
return root.suggestedHeight
}

ListView {
id: listView
anchors.fill: parent
Expand All @@ -76,7 +38,18 @@ Item {
}
}

// FIXME: find 2 * root.spacing comes from where
implicitWidth: root.suggestedImplicitWidth - (useColumnLayout ? 0 : 2 * root.spacing)
implicitHeight: root.suggestedImplicitHeight - (useColumnLayout ? 2 * root.spacing : 0)
implicitWidth: {
let width = 0
for (let child of listView.contentItem.visibleChildren) {
width = calculateImplicitWidth(width, child.implicitWidth)
}
return width
}
implicitHeight: {
let height = 0
for (let child of listView.contentItem.visibleChildren) {
height = calculateImplicitHeight(height, child.implicitHeight)
}
return height
}
}
29 changes: 15 additions & 14 deletions panels/dock/package/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ Window {
}
}

// TODO: remove GridLayout and use delegatechosser manager all items
GridLayout {
id: gridLayout
anchors.fill: parent
Expand Down Expand Up @@ -329,21 +330,21 @@ Window {
Layout.fillWidth: true
Layout.fillHeight: true
}
}

Item {
id: dockRightPart
implicitWidth: rightLoader.implicitWidth
implicitHeight: rightLoader.implicitHeight
Layout.alignment: Qt.AlignRight | Qt.AlignBottom
OverflowContainer {
id: rightLoader
anchors.fill: parent
useColumnLayout: dock.useColumnLayout
model: DockPartAppletModel {
id: dockRightPartModel
leftDockOrder: 20
rightDockOrder: 30
}
Item {
id: dockRightPart
implicitWidth: rightLoader.implicitWidth
implicitHeight: rightLoader.implicitHeight
anchors.right: parent.right
OverflowContainer {
id: rightLoader
anchors.fill: parent
useColumnLayout: dock.useColumnLayout
model: DockPartAppletModel {
id: dockRightPartModel
leftDockOrder: 20
rightDockOrder: 30
}
}
}
Expand Down
10 changes: 10 additions & 0 deletions panels/dock/taskmanager/package/AppItem.qml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,13 @@ Item {
windowIndicator.anchors.rightMargin = 0
windowIndicator.anchors.horizontalCenter = undefined
windowIndicator.anchors.verticalCenter = undefined

let fixedDistance = 2
if (Panel.position === Dock.Top || Panel.position === Dock.Bottom) {
fixedDistance = (root.height - Dock.MAX_DOCK_TASKMANAGER_ICON_SIZE * iconScale) / 2 / 3
} else {
fixedDistance = (root.width - Dock.MAX_DOCK_TASKMANAGER_ICON_SIZE * iconScale) / 2 / 3
}

switch(Panel.position) {
case Dock.Top: {
Expand Down Expand Up @@ -339,4 +345,8 @@ Item {
onIconGlobalPointChanged: {
updateWindowIconGeometryTimer.start()
}

onIconScaleChanged: {
windowIndicator.updateIndicatorAnchors()
}
}
1 change: 1 addition & 0 deletions panels/dock/tray/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ qt_add_qml_module(dock-tray
ksortfilterproxymodel.h
QML_FILES
SurfacePopup.qml
ShellSurfaceItemProxy.qml

OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/plugins/org/deepin/ds/dock/tray/
)
Expand Down
24 changes: 24 additions & 0 deletions panels/dock/tray/ShellSurfaceItemProxy.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

import QtQuick
import QtQuick.Controls
import QtWayland.Compositor
import org.deepin.ds.dock 1.0

ShellSurfaceItem {
property bool autoClose: false
onVisibleChanged: function () {
if (autoClose && !visible) {
// surface is valid but client's shellSurface maybe invalid.
Qt.callLater(closeShellSurface)
}
}
function closeShellSurface()
{
if (surface && shellSurface) {
DockCompositor.closeShellSurface(shellSurface)
}
}
}
6 changes: 4 additions & 2 deletions panels/dock/tray/SurfacePopup.qml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@ Item {
toolTipWindow: toolTipWindow

property alias shellSurface: surfaceLayer.shellSurface
ShellSurfaceItem {
ShellSurfaceItemProxy {
id: surfaceLayer
anchors.centerIn: parent
autoClose: true
onSurfaceDestroyed: function () {
toolTip.close()
}
Expand Down Expand Up @@ -66,9 +67,10 @@ Item {
popupWindow: popupWindow

property alias shellSurface: popupSurfaceLayer.shellSurface
ShellSurfaceItem {
ShellSurfaceItemProxy {
id: popupSurfaceLayer
anchors.centerIn: parent
autoClose: true
onSurfaceDestroyed: function () {
popup.close()
}
Expand Down
34 changes: 31 additions & 3 deletions panels/dock/tray/package/ActionLegacyTrayPluginDelegate.qml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import QtQuick.Layouts
import QtWayland.Compositor
import Qt.labs.platform 1.1 as LP
import org.deepin.dtk 1.0 as D
import org.deepin.dtk.private 1.0 as DP

import org.deepin.ds 1.0
import org.deepin.ds.dock 1.0
Expand All @@ -16,13 +17,17 @@ import org.deepin.ds.dock.tray 1.0 as DDT
Button {
property alias inputEventsEnabled: surfaceItem.inputEventsEnabled

x: isHorizontal ? (model.visualIndex * (16 + 10)) : 0
y: !isHorizontal ? (model.visualIndex * (16 + 10)) : 0

property size visualSize: Qt.size(pluginItem.implicitWidth, pluginItem.implicitHeight)

readonly property int itemWidth: isHorizontal ? 0 : DDT.TrayItemPositionManager.dockHeight
readonly property int itemHeight: isHorizontal ? DDT.TrayItemPositionManager.dockHeight : 0
readonly property int inset: 4

topInset: -inset
bottomInset: -inset
leftInset: -inset
rightInset: -inset
padding: inset

contentItem: Item {
id: pluginItem
Expand Down Expand Up @@ -61,10 +66,16 @@ Button {
return Qt.point(x, y)
}

HoverHandler {
id: hoverHandler
parent: surfaceItem
}

ShellSurfaceItem {
id: surfaceItem
anchors.centerIn: parent
shellSurface: pluginItem.plugin
inputEventsEnabled: !DDT.TraySortOrderModel.collapsed
}

Component.onCompleted: {
Expand All @@ -78,6 +89,8 @@ Button {
running: false
repeat: false
onTriggered: {
if (!pluginItem.plugin)
return
if (pluginItem.itemGlobalPoint.x > 0 && pluginItem.itemGlobalPoint.y > 0) {
pluginItem.plugin.updatePluginGeometry(Qt.rect(pluginItem.itemGlobalPoint.x, pluginItem.itemGlobalPoint.y, 0, 0))
}
Expand All @@ -90,6 +103,8 @@ Button {
running: false
repeat: false
onTriggered: {
if (!pluginItem.plugin)
return
pluginItem.plugin.setGlobalPos(pluginItem.itemGlobalPos)
}
}
Expand All @@ -103,10 +118,23 @@ Button {
}

onVisibleChanged: {
if (!pluginItem.plugin)
return
pluginItem.plugin.setGlobalPos(pluginItem.itemGlobalPos)
}
}

D.ColorSelector.hovered: (pluginItem.plugin.isItemActive ?? false) || hoverHandler.hovered
background: D.BoxPanel {
property D.Palette backgroundPalette: DockPalette.backgroundPalette

color2: color1
color1: backgroundPalette

outsideBorderColor: null
insideBorderColor: null
}

property Component overlayWindow: QuickDragWindow {
height: parent.visualSize.height
width: parent.visualSize.width
Expand Down
25 changes: 25 additions & 0 deletions panels/dock/tray/package/ActionShowStashDelegate.qml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,31 @@ D.ToolButton {
icon.height: height
display: D.IconLabel.IconOnly

states: [
State {
name: "opened"
PropertyChanges { target: root; rotation: 180 }
},

State {
name: "closed"
PropertyChanges { target: root; rotation: 0 }
}
]

transitions: [
Transition {
RotationAnimation { duration: 200; }
}
]

Binding {
target: root
property: "state"
value: stashedPopup.popupVisible ? "opened" : "closed"
when: stashedPopup.popupVisibleChanged
}

onClicked: {
var point = root.mapToItem(null, root.width / 2, 0)
stashedPopup.popupX = Qt.binding(function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ import org.deepin.ds 1.0
import org.deepin.ds.dock.tray.quickpanel 1.0

QuickPanel {
id: root
property bool isHorizontal: false
useColumnLayout: !isHorizontal
trayItemPluginId: Applet.rootObject.quickpanelTrayItemPluginId
Component.onCompleted: function () {
Applet.rootObject.quickPanelIsOpened = Qt.binding(function () {
return root.isOpened
})
}

}
Binary file added panels/dock/tray/package/icons/arrow-down.dci
Binary file not shown.
Binary file added panels/dock/tray/package/icons/arrow-left.dci
Binary file not shown.
Binary file added panels/dock/tray/package/icons/arrow-right.dci
Binary file not shown.
Binary file added panels/dock/tray/package/icons/arrow-up.dci
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit ed7d6c9

Please sign in to comment.