Skip to content

Commit a82eccc

Browse files
committed
fix(dock): align aibar in fashion mode
1 parent 755908e commit a82eccc

2 files changed

Lines changed: 41 additions & 8 deletions

File tree

panels/dock/package/DockPartAppletModel.qml

Lines changed: 40 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,21 +47,56 @@ D.SortFilterModel {
4747
property var appletItem: model.data
4848
property var attachedAppletItem: null
4949
readonly property string pluginId: appletItem && appletItem.applet ? appletItem.applet.pluginId : ""
50+
readonly property bool isAiBarApplet: pluginId === "org.deepin.ds.dock.aibar"
51+
readonly property bool horizontalAiBarApplet: isAiBarApplet
52+
&& Panel.viewMode === Dock.FashionMode
53+
&& !(Panel.rootObject && Panel.rootObject.useColumnLayout)
54+
readonly property int hoverInset: 4
5055
readonly property bool useUnifiedDockHoverBackground: [
5156
"org.deepin.ds.dock.launcherapplet",
5257
"org.deepin.ds.dock.aibar",
5358
"org.deepin.ds.dock.searchitem",
5459
"org.deepin.ds.dock.multitaskview"
5560
].indexOf(pluginId) >= 0
56-
readonly property int unifiedHoverBackgroundSize: Math.round((Panel.rootObject ? Panel.rootObject.dockItemMaxSize * 9 / 14 : 0) + 8)
57-
implicitWidth: appletItem ? appletItem.implicitWidth : 0
61+
readonly property real aiBarIconSize: appletItem && appletItem.iconWidth !== undefined ? appletItem.iconWidth : 0
62+
readonly property real hoverTargetWidth: isAiBarApplet && aiBarIconSize > 0
63+
? aiBarIconSize
64+
: (Panel.rootObject ? Panel.rootObject.dockItemMaxSize * 9 / 14 : 0)
65+
readonly property real hoverTargetHeight: hoverTargetWidth
66+
readonly property real unifiedHoverBackgroundWidth: Math.round(hoverTargetWidth + hoverInset * 2)
67+
readonly property real unifiedHoverBackgroundHeight: Math.round(hoverTargetHeight + hoverInset * 2)
68+
readonly property real aiBarEdgeMargin: Panel.rootObject
69+
? Math.max(0, (Panel.rootObject.dockSize - hoverTargetHeight) / 2)
70+
: 0
71+
readonly property real aiBarTrailingInset: Panel.rootObject ? Panel.rootObject.fashionVerticalPadding + 1 : 0
72+
readonly property real aiBarContentWidth: appletItem ? appletItem.implicitWidth : 0
73+
readonly property real aiBarLayoutWidth: horizontalAiBarApplet
74+
? Math.max(aiBarContentWidth, hoverTargetWidth + aiBarEdgeMargin * 2 - aiBarTrailingInset)
75+
: aiBarContentWidth
76+
readonly property int aiBarHorizontalOffset: horizontalAiBarApplet
77+
? Math.round(aiBarEdgeMargin)
78+
: 0
79+
readonly property real aiBarRightPadding: horizontalAiBarApplet
80+
? Math.max(0, aiBarLayoutWidth - aiBarContentWidth)
81+
: 0
82+
implicitWidth: appletItem ? aiBarLayoutWidth : 0
5883
implicitHeight: appletItem ? appletItem.implicitHeight : 0
84+
rightPadding: aiBarRightPadding
85+
86+
transform: Translate {
87+
x: delegateRoot.aiBarHorizontalOffset
88+
}
5989

6090
contentItem: appletItem
6191
background: AppletItemBackground {
62-
anchors.centerIn: parent
63-
width: delegateRoot.unifiedHoverBackgroundSize
64-
height: delegateRoot.unifiedHoverBackgroundSize
92+
x: Math.round(!delegateRoot.isAiBarApplet || (Panel.rootObject && Panel.rootObject.useColumnLayout)
93+
? (delegateRoot.width - width) / 2
94+
: delegateRoot.hoverInset * -1)
95+
y: Math.round(!delegateRoot.isAiBarApplet || !(Panel.rootObject && Panel.rootObject.useColumnLayout)
96+
? (delegateRoot.height - height) / 2
97+
: delegateRoot.hoverInset * -1)
98+
width: delegateRoot.unifiedHoverBackgroundWidth
99+
height: delegateRoot.unifiedHoverBackgroundHeight
65100
radius: height / 5
66101
enabled: false
67102
visible: delegateRoot.useUnifiedDockHoverBackground

panels/dock/package/main.qml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Window {
3131
readonly property bool adaptiveFashionUsesDirectWindowGeometry: adaptiveFashionMode && Qt.platform.pluginName === "xcb"
3232
readonly property bool useWindowMarginBasedHideAnimation: adaptiveFashionMode
3333
readonly property bool useTransformBasedHideAnimation: Qt.platform.pluginName === "xcb" && !useWindowMarginBasedHideAnimation
34-
readonly property var promotedCenterPluginIds: ["org.deepin.ds.dock.aibar", "org.deepin.ds.dock.searchitem"]
34+
readonly property var promotedCenterPluginIds: ["org.deepin.ds.dock.searchitem"]
3535
readonly property int fashionDockSpacing: Math.round(dockItemIconSize * 0.75)
3636
readonly property real fashionPartSpacing: adaptiveFashionMode
3737
? dock.roundToPhysicalPixel(fashionDockSpacing)
@@ -401,8 +401,6 @@ Window {
401401
switch (pluginId) {
402402
case "org.deepin.ds.dock.launcherapplet":
403403
return 1200
404-
case "org.deepin.ds.dock.aibar":
405-
return 1300
406404
case "org.deepin.ds.dock.searchitem":
407405
return 1400
408406
default: {

0 commit comments

Comments
 (0)