Skip to content
Open
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
4 changes: 2 additions & 2 deletions panels/dock/MenuHelper.qml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
// SPDX-FileCopyrightText: 2023-2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

Expand All @@ -21,8 +21,8 @@ Item {
if (activeMenu) {
activeMenu.close()
}
menu.open()
activeMenu = menu
menu.open()
}
function closeMenu(menu: Menu) {
menu.close()
Expand Down
15 changes: 15 additions & 0 deletions panels/dock/OverflowContainer.qml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import QtQuick.Layouts 2.15
Item {
id: root
required property bool useColumnLayout
property real trailingExtent: 0
property alias model: listView.model
property alias delegate: listView.delegate
property alias spacing: listView.spacing
Expand All @@ -31,6 +32,11 @@ Item {
}

function calculateImplicitWidth(prev, current) {
// Zero-width delegates are hidden (for example, items moved into the
// overflow popup) and must not leave an extra spacing slot behind.
if (current <= 0) {
return prev
}
if (useColumnLayout) {
return Math.max(prev, current)
} else {
Expand All @@ -42,6 +48,11 @@ Item {
}

function calculateImplicitHeight(prev, current) {
// Keep the vertical layout consistent with the horizontal one: hidden
// delegates contribute neither size nor spacing.
if (current <= 0) {
return prev
}
if (useColumnLayout) {
if (prev == 0) {
return current
Expand All @@ -61,6 +72,8 @@ Item {
for (let child of listView.contentItem.visibleChildren) {
width = calculateImplicitWidth(width, child.implicitWidth)
}
if (!useColumnLayout && trailingExtent > 0)
width = calculateImplicitWidth(width, trailingExtent)
// TODO: abvoe qt6.8 implicitSize to 0 will make size to 0 default.
// so make minimum implicitSize to 1, find why and remove below
return Math.max(width, 1)
Expand All @@ -70,6 +83,8 @@ Item {
for (let child of listView.contentItem.visibleChildren) {
height = calculateImplicitHeight(height, child.implicitHeight)
}
if (useColumnLayout && trailingExtent > 0)
height = calculateImplicitHeight(height, trailingExtent)
return Math.max(height, 1)
}
}
71 changes: 55 additions & 16 deletions panels/dock/dockpositioner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,34 @@ void DockPositioner::setBounding(const QRect &newBounding)
emit boundingChanged();
}

bool DockPositioner::isCrossWindow() const
{
const auto item = qobject_cast<QQuickItem *>(parent());
return item && item->window() && m_panel && m_panel->window()
&& item->window() != m_panel->window();
}

QRect DockPositioner::effectiveBounding() const
{
if (!isCrossWindow())
return m_bounding;

const auto item = qobject_cast<QQuickItem *>(parent());
const auto globalTopLeft = item->window()->mapToGlobal(m_bounding.topLeft());
return QRect(globalTopLeft - dockGeometry().topLeft(), m_bounding.size());
}

QRect DockPositioner::attachedItemRectInDock() const
{
const auto item = qobject_cast<QQuickItem *>(parent());
if (!item)
return {};

const auto globalTopLeft = item->mapToGlobal(QPointF(0, 0));
const auto dockTopLeft = globalTopLeft.toPoint() - dockGeometry().topLeft();
return QRect(dockTopLeft, QSize(qRound(item->width()), qRound(item->height())));
}

int DockPositioner::x() const
{
return m_x;
Expand Down Expand Up @@ -133,27 +161,28 @@ void DockPositioner::update()

void DockPositioner::updatePosition()
{
const auto bounding = effectiveBounding();
int xPosition = 0;
int yPosition = 0;
switch (dockPosition()) {
case dock::Top: {
xPosition = m_bounding.x();
yPosition = m_bounding.y();
xPosition = bounding.x();
yPosition = bounding.y();
break;
}
case dock::Right: {
xPosition = m_bounding.x() - m_bounding.width();
yPosition = m_bounding.y();
xPosition = bounding.x() - bounding.width();
yPosition = bounding.y();
break;
}
case dock::Bottom: {
xPosition = m_bounding.x();
yPosition = m_bounding.y() - m_bounding.height();
xPosition = bounding.x();
yPosition = bounding.y() - bounding.height();
break;
}
case dock::Left: {
xPosition = m_bounding.x();
yPosition = m_bounding.y();
xPosition = bounding.x();
yPosition = bounding.y();
break;
}
default:
Expand Down Expand Up @@ -222,29 +251,39 @@ void DockPanelPositioner::resetVertialOffset()
void DockPanelPositioner::updatePosition()
{
const auto dockWindowRect = dockGeometry();
const auto crossWindow = isCrossWindow();
const auto anchorRect = crossWindow ? attachedItemRectInDock() : QRect();
int xPosition = 0;
int yPosition = 0;
int horizontalOffset = m_horizontalOffset == -1 ? m_bounding.width() / 2 : m_horizontalOffset;
int vertialOffset = m_vertialOffset == -1 ? m_bounding.height() / 2 : m_vertialOffset;
switch (dockPosition()) {
case dock::Top: {
xPosition = m_bounding.x() - horizontalOffset;
yPosition = dockWindowRect.height() + 10;
xPosition = crossWindow ? anchorRect.center().x() - horizontalOffset
: m_bounding.x() - horizontalOffset;
yPosition = crossWindow ? anchorRect.y() + anchorRect.height() + 10
: dockWindowRect.height() + 10;
break;
}
case dock::Right: {
xPosition = -m_bounding.width() - 10;
yPosition = m_bounding.y() - vertialOffset;
xPosition = crossWindow ? anchorRect.left() - m_bounding.width() - 10
: -m_bounding.width() - 10;
yPosition = crossWindow ? anchorRect.center().y() - vertialOffset
: m_bounding.y() - vertialOffset;
break;
}
case dock::Bottom: {
xPosition = m_bounding.x() - horizontalOffset;
yPosition = -m_bounding.height() - 10;
xPosition = crossWindow ? anchorRect.center().x() - horizontalOffset
: m_bounding.x() - horizontalOffset;
yPosition = crossWindow ? anchorRect.top() - m_bounding.height() - 10
: -m_bounding.height() - 10;
break;
}
case dock::Left: {
xPosition = dockWindowRect.width() + 10;
yPosition = m_bounding.y() - vertialOffset;
xPosition = crossWindow ? anchorRect.x() + anchorRect.width() + 10
: dockWindowRect.width() + 10;
yPosition = crossWindow ? anchorRect.center().y() - vertialOffset
: m_bounding.y() - vertialOffset;
break;
}
default:
Expand Down
3 changes: 3 additions & 0 deletions panels/dock/dockpositioner.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ public slots:

protected:
void setScreen(QScreen *screen);
bool isCrossWindow() const;
QRect effectiveBounding() const;
QRect attachedItemRectInDock() const;
QPointer<QScreen> m_screen;
QPointer<DS_NAMESPACE::DPanel> m_panel;
QRect m_bounding {};
Expand Down
23 changes: 18 additions & 5 deletions panels/dock/package/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,13 @@ Window {
}
}
property int dockCenterPartCount: dockCenterPartModel.count
readonly property int centerAlignmentEdgeSpacing: 14

readonly property int dockRawCenterSpace: {
if (useColumnLayout) {
return Screen.height - dockLeftPart.implicitHeight - dockRightPart.implicitHeight;
} else {
let space = Screen.width - dockLeftPart.implicitWidth - dockRightPart.implicitWidth;
let space = Screen.width - dockLeftPart.implicitWidth - dockRightPart.implicitWidth - Math.ceil(gridLayout.columnSpacing);
if (fashionDock.enabled && gridLayout) {
// 时尚模式下,dockRightPart 在 gridLayout 右侧,之间需要扣除 dockSpacing
// 同时保留左右悬浮间距,避免窗口铺满屏幕后圆角边框被屏幕边缘裁剪。
Expand All @@ -62,6 +64,17 @@ Window {
return Math.max(0, space);
}
}
readonly property int dockEffectiveCenterSpace: {
if (Panel.itemAlignment !== Dock.CenterAlignment || fashionDock.enabled) {
return dockRawCenterSpace
}

const screenExtent = useColumnLayout ? Screen.height : Screen.width
const leftExtent = useColumnLayout ? dockLeftPart.implicitHeight : dockLeftPart.implicitWidth
const rightExtent = useColumnLayout ? dockRightPart.implicitHeight : dockRightPart.implicitWidth
return Math.max(0, screenExtent - leftExtent - rightExtent
- centerAlignmentEdgeSpacing * 2)
}

property int dockPartSpacing: gridLayout.columnSpacing
// TODO
Expand Down Expand Up @@ -653,19 +666,19 @@ Window {
implicitHeight: centerLoader.implicitHeight
Accessible.role: Accessible.Grouping
Accessible.name: qsTr("Dock Center Area")
Layout.maximumWidth: useColumnLayout ? -1 : dockRawCenterSpace
Layout.maximumHeight: useColumnLayout ? dockRawCenterSpace : -1
Layout.maximumWidth: useColumnLayout ? -1 : dockEffectiveCenterSpace
Layout.maximumHeight: useColumnLayout ? dockEffectiveCenterSpace : -1
onXChanged: dockCenterPartPosChanged()
onYChanged: dockCenterPartPosChanged()
Layout.leftMargin: {
if (!useColumnLayout && fashionDock.enabled) {
return dockLeftPart.visible ? 0 : Math.max(10, Math.round(dockItemIconSize) / 3)
}
return !useColumnLayout && Panel.itemAlignment === Dock.CenterAlignment ?
Math.max(0, (dock.width - dockCenterPart.implicitWidth) / 2 - (dockLeftPart.implicitWidth + 20) + Math.min((dock.width - dockCenterPart.implicitWidth) / 2 - (dockRightPart.implicitWidth + 20), 0)) : 0
Math.max(0, (dock.width - dockCenterPart.implicitWidth) / 2 - (dockLeftPart.implicitWidth + centerAlignmentEdgeSpacing) + Math.min((dock.width - dockCenterPart.implicitWidth) / 2 - (dockRightPart.implicitWidth + centerAlignmentEdgeSpacing), 0)) : 0
}
Layout.topMargin: useColumnLayout && Panel.itemAlignment === Dock.CenterAlignment ?
Math.max(0, (dock.height - dockCenterPart.implicitHeight) / 2 - (dockLeftPart.implicitHeight + 20) + Math.min((dock.height - dockCenterPart.implicitHeight) / 2 - (dockRightPart.implicitHeight + 20), 0)) : 0
Math.max(0, (dock.height - dockCenterPart.implicitHeight) / 2 - (dockLeftPart.implicitHeight + centerAlignmentEdgeSpacing) + Math.min((dock.height - dockCenterPart.implicitHeight) / 2 - (dockRightPart.implicitHeight + centerAlignmentEdgeSpacing), 0)) : 0

Behavior on Layout.leftMargin {
enabled: !dock.isDragging && !Applet.isResizing
Expand Down
5 changes: 4 additions & 1 deletion panels/dock/taskmanager/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# SPDX-License-Identifier: GPL-3.0-or-later

find_package(Qt${QT_VERSION_MAJOR} ${REQUIRED_QT_VERSION} REQUIRED COMPONENTS DBus WaylandClient)
find_package(Qt${QT_VERSION_MAJOR} ${REQUIRED_QT_VERSION} REQUIRED COMPONENTS DBus Quick WaylandClient)
find_package(yaml-cpp REQUIRED)
find_package(TreelandProtocols 0.9.0 REQUIRED)

Expand Down Expand Up @@ -86,6 +86,8 @@ add_library(dock-taskmanager SHARED ${DBUS_INTERFACES}
treelandwindowmonitor.h
taskmanagersettings.cpp
taskmanagersettings.h
taskoverflowcontroller.cpp
taskoverflowcontroller.h
textcalculator.h
textcalculator.cpp
)
Expand All @@ -100,6 +102,7 @@ target_link_libraries(dock-taskmanager PRIVATE
dde-shell-dock
Qt${QT_VERSION_MAJOR}::WaylandClientPrivate
Qt${QT_VERSION_MAJOR}::Concurrent
Qt${QT_VERSION_MAJOR}::Quick
yaml-cpp
PkgConfig::WaylandClient
)
Expand Down
3 changes: 3 additions & 0 deletions panels/dock/taskmanager/dockglobalelementmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,9 @@ QVariant DockGlobalElementModel::data(const QModelIndex &index, int role) const
return false;
}

case TaskManager::DockedRole:
return model == nullptr || m_dockedElements.contains(std::make_tuple("desktop", id));

case TaskManager::MenusRole: {
return getMenus(index);
}
Expand Down
Loading
Loading