Commit afb9331
committed
fix: centralize relative time formatting logic
Moved relative time formatting logic from BubbleModel and AppNotifyItem
to a common static method in NotifyEntity to eliminate code duplication
and fix incorrect time display issues. Previously, BubbleModel used
a simple minutes calculation while AppNotifyItem used ICU library for
locale-aware formatting, causing inconsistent time display between
notification bubble and center. Now both components use the same unified
formatting logic.
The changes include:
1. Added static method NotifyEntity::formatRelativeTime() that handles
all relative time formatting using ICU library
2. Removed QDateTime include from bubblemodel.cpp as it's no longer
needed
3. Simplified updateBubbleTimeTip() in BubbleModel to use the new common
method
4. Simplified updateTime() in AppNotifyItem to use the new common method
with fallback to "Just now"
5. Updated copyright years to 2024-2026 in modified files
Log: Fixed inconsistent time display between notification bubble and
center
Influence:
1. Test notification time display in both bubble and center views
2. Verify time formatting for different time intervals (just now,
minutes, hours, yesterday, days, weeks)
3. Check locale-specific formatting works correctly
4. Verify time updates dynamically as notifications age
5. Test with notifications from different time periods
fix: 集中相对时间格式化逻辑
将相对时间格式化逻辑从 BubbleModel 和 AppNotifyItem 移动到 NotifyEntity
的公共静态方法中,以消除代码重复并修复时间显示错误问题。之前,
BubbleModel 使用简单的分钟计算,而 AppNotifyItem 使用 ICU 库进行本地化感
知的格式化,导致通知气泡和中心之间的时间显示不一致。现在两个组件都使用相
同的统一格式化逻辑。
变更包括:
1. 添加静态方法 NotifyEntity::formatRelativeTime(),使用 ICU 库处理所有
相对时间格式化
2. 从 bubblemodel.cpp 中移除不再需要的 QDateTime 包含
3. 简化 BubbleModel 中的 updateBubbleTimeTip() 以使用新的公共方法
4. 简化 AppNotifyItem 中的 updateTime() 以使用新的公共方法,并回退到"刚
刚"
5. 在修改的文件中更新版权年份为 2024-2026
Log: 修复通知气泡和中心之间时间显示不一致的问题
Influence:
1. 测试通知气泡和中心视图中的时间显示
2. 验证不同时间间隔(刚刚、分钟、小时、昨天、天数、周数)的时间格式化
3. 检查本地化特定的格式化是否正确工作
4. 验证时间随通知老化而动态更新
5. 测试来自不同时间段的通知
PMS: BUG-355185
Change-Id: I65ddbd0ea5ec943fd7b2c9aa55bc5ed29bd0522b1 parent 8247a0a commit afb9331
4 files changed
Lines changed: 86 additions & 86 deletions
File tree
- panels/notification
- bubble
- center
- common
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
14 | 13 | | |
15 | 14 | | |
16 | 15 | | |
| |||
289 | 288 | | |
290 | 289 | | |
291 | 290 | | |
292 | | - | |
293 | | - | |
294 | | - | |
295 | | - | |
296 | | - | |
| 291 | + | |
| 292 | + | |
297 | 293 | | |
298 | | - | |
| 294 | + | |
299 | 295 | | |
300 | 296 | | |
301 | 297 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
9 | 8 | | |
10 | 9 | | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | 10 | | |
15 | 11 | | |
16 | 12 | | |
| |||
66 | 62 | | |
67 | 63 | | |
68 | 64 | | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | 65 | | |
93 | 66 | | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | | - | |
128 | | - | |
129 | | - | |
130 | | - | |
131 | | - | |
132 | | - | |
133 | | - | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | | - | |
140 | | - | |
141 | | - | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
142 | 72 | | |
143 | | - | |
144 | 73 | | |
145 | 74 | | |
146 | 75 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
11 | 17 | | |
12 | 18 | | |
13 | 19 | | |
| |||
350 | 356 | | |
351 | 357 | | |
352 | 358 | | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
353 | 424 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
93 | 93 | | |
94 | 94 | | |
95 | 95 | | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
96 | 100 | | |
97 | 101 | | |
98 | 102 | | |
| |||
0 commit comments