Skip to content

Commit 8fb0eb7

Browse files
committed
fix: adjust notification center width calculation
Changed width calculation from hardcoded values to use NotifyStyle.contentItem.width for consistent styling Added proper scrollbar width calculation in NotifyCenter to account for scrollbar presence Updated main window width calculation to include proper padding handling Fixed anchor margins and right constraints to ensure proper layout with dynamic width Added contentPadding property for better maintainability of spacing values Log: Fixed notification center layout issues with dynamic width calculation Influence: 1. Test notification center display with different content widths 2. Verify scrollbar appears correctly and doesn't cause layout issues 3. Check that all notification items maintain consistent width 4. Test window resizing behavior and content alignment 5. Verify margins and padding are applied correctly on all sides fix: 调整通知中心宽度计算方式 将硬编码的宽度值改为使用 NotifyStyle.contentItem.width 以确保样式一致性 在 NotifyCenter 中添加了正确的滚动条宽度计算以考虑滚动条的存在 更新了主窗口宽度计算以包含正确的内边距处理 修复了锚点边距和右侧约束以确保动态宽度下的正确布局 添加了 contentPadding 属性以便更好地维护间距值 Log: 修复了通知中心动态宽度计算导致的布局问题 Influence: 1. 测试不同内容宽度下通知中心的显示效果 2. 验证滚动条正确显示且不会导致布局问题 3. 检查所有通知项是否保持一致的宽度 4. 测试窗口调整大小行为和内容对齐 5. 验证边距和内边距在所有边上是否正确应用 PMS: BUG-325871
1 parent c691532 commit 8fb0eb7

4 files changed

Lines changed: 16 additions & 10 deletions

File tree

panels/notification/center/NotifyCenter.qml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import QtQuick
66
import QtQuick.Controls
77
import QtQuick.Layouts
88
import org.deepin.dtk 1.0
9+
import org.deepin.dtk.style 1.0 as DS
910
import org.deepin.ds.notification
1011
import org.deepin.ds.notificationcenter
1112

@@ -32,7 +33,7 @@ FocusScope {
3233
left: parent.left
3334
}
3435
height: 40
35-
width: parent.width
36+
width: NotifyStyle.contentItem.width
3637
notifyModel: notifyModel
3738
z: 1
3839
}
@@ -46,7 +47,7 @@ FocusScope {
4647
bottom: parent.bottom
4748
}
4849

49-
width: parent.width
50+
width: NotifyStyle.contentItem.width + DS.Style.scrollBar.padding + DS.Style.scrollBar.width + NotifyStyle.scrollBarPadding
5051
height: Math.min(maxViewHeight, viewHeight)
5152
notifyModel: notifyModel
5253
}

panels/notification/center/NotifyViewDelegate.qml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ DelegateChooser {
2323
GroupNotify {
2424
id: groupNotify
2525
objectName: "group-" + model.appName
26-
width: 360
26+
width: NotifyStyle.contentItem.width
2727
appName: model.appName
2828
activeFocusOnTab: true
2929

@@ -61,7 +61,7 @@ DelegateChooser {
6161
NormalNotify {
6262
id: normalNotify
6363
objectName: "normal-" + model.appName
64-
width: 360
64+
width: NotifyStyle.contentItem.width
6565
activeFocusOnTab: true
6666

6767
appName: model.appName
@@ -120,7 +120,7 @@ DelegateChooser {
120120
OverlapNotify {
121121
id: overlapNotify
122122
objectName: "overlap-" + model.appName
123-
width: 360
123+
width: NotifyStyle.contentItem.width
124124
activeFocusOnTab: true
125125

126126
count: model.overlapCount

panels/notification/center/package/main.qml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import QtQuick.Controls
77
import QtQuick.Layouts
88
import org.deepin.dtk 1.0
99
import org.deepin.ds 1.0
10+
import org.deepin.ds.notification
1011
import org.deepin.ds.notificationcenter
1112

1213
Window {
@@ -33,7 +34,8 @@ Window {
3334
visible: Panel.visible
3435
flags: Qt.Tool
3536

36-
width: 360 + view.anchors.leftMargin + view.anchors.rightMargin
37+
property int contentPadding: 20
38+
width: NotifyStyle.contentItem.width + contentPadding * 2
3739
// height: 800
3840
DLayerShellWindow.layer: DLayerShellWindow.LayerOverlay
3941
DLayerShellWindow.anchors: DLayerShellWindow.AnchorRight | DLayerShellWindow.AnchorTop | DLayerShellWindow.AnchorBottom
@@ -80,13 +82,13 @@ Window {
8082

8183
Item {
8284
id: view
83-
width: parent.width
8485
// clear focus when NotificationCenter is closed.
8586
focus: root.visible
8687
anchors {
8788
top: parent.top
8889
left: parent.left
89-
margins: 20
90+
leftMargin: contentPadding
91+
right: parent.right
9092
bottom: parent.bottom
9193
}
9294

@@ -95,8 +97,9 @@ Window {
9597
anchors {
9698
top: parent.top
9799
left: parent.left
100+
right: parent.right
101+
rightMargin: contentPadding
98102
}
99-
implicitWidth: 360
100103
Connections {
101104
target: Panel
102105
function onVisibleChanged() {
@@ -114,6 +117,7 @@ Window {
114117
anchors {
115118
top: notifyStaging.bottom
116119
left: parent.left
120+
right: parent.right
117121
bottom: parent.bottom
118122
}
119123

@@ -128,7 +132,6 @@ Window {
128132
}
129133
}
130134

131-
implicitWidth: 360
132135
maxViewHeight: root.height
133136
stagingViewCount: notifyStaging.viewCount
134137
}

panels/notification/plugin/NotifyStyle.qml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,7 @@ QtObject {
1212
property int topMargin: 4
1313
property int bottomMargin: 8
1414
property int miniHeight: 40
15+
property int width: 360
1516
}
17+
property int scrollBarPadding: 2
1618
}

0 commit comments

Comments
 (0)