feat: implement custom PageButton for calendar navigation#337
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: wjyrich The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Reviewer's GuideThis PR replaces the standard DToolButton-based calendar navigation with a new custom PageButton QFrame subclass featuring hover/press visual states, custom painting with rounded corners, centralized icon styling/positioning, and consolidated sizing, then updates SidebarCalendarWidget to use PageButton and connect its clicked signal. Class diagram for new PageButton and SidebarCalendarWidget changesclassDiagram
class QFrame
class PageButton {
+PageButton(QWidget *parent)
+~PageButton()
+void setIcon(const QIcon &icon)
+signal void clicked()
-void initUI()
-bool m_hover
-bool m_mousePress
-CommonIconButton *m_iconButton
+bool event(QEvent* e)
+void paintEvent(QPaintEvent* e)
+void mousePressEvent(QMouseEvent* event)
+void mouseReleaseEvent(QMouseEvent* event)
}
PageButton --|> QFrame
class SidebarCalendarWidget {
-PageButton* m_nextPage
-PageButton* m_previousPage
...
}
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey @wjyrich - I've reviewed your changes - here's some feedback:
- Implement keyboard focus and key event handling (e.g. Space/Enter) in PageButton to support accessibility.
- Remove the empty PageButton destructor or mark it as = default to avoid redundant code.
- Extract hardcoded size and corner‐radius values into named constants or style metrics for better maintainability and theming.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Implement keyboard focus and key event handling (e.g. Space/Enter) in PageButton to support accessibility.
- Remove the empty PageButton destructor or mark it as = default to avoid redundant code.
- Extract hardcoded size and corner‐radius values into named constants or style metrics for better maintainability and theming.
## Individual Comments
### Comment 1
<location> `plugins/dde-dock/datetime/calendar/pagebutton.cpp:91` </location>
<code_context>
+ m_mousePress = true;
+ update();
+ }
+ QWidget::mousePressEvent(event);
+}
+
</code_context>
<issue_to_address>
Base class mouse event should call QFrame::mousePressEvent.
Call QFrame::mousePressEvent(event) here to maintain proper event handling and consistency with the base class.
</issue_to_address>
<suggested_fix>
<<<<<<< SEARCH
QWidget::mousePressEvent(event);
=======
QFrame::mousePressEvent(event);
>>>>>>> REPLACE
</suggested_fix>
### Comment 2
<location> `plugins/dde-dock/datetime/calendar/pagebutton.cpp:105` </location>
<code_context>
+ Q_EMIT clicked();
+ }
+
+ QWidget::mouseReleaseEvent(event);
+}
\ No newline at end of file
</code_context>
<issue_to_address>
Base class mouse event should call QFrame::mouseReleaseEvent.
Use QFrame::mouseReleaseEvent(event) instead of QWidget to ensure proper event handling.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| p.setBrush(bgColor); | ||
| p.setRenderHint(QPainter::Antialiasing); | ||
| p.setPen(Qt::NoPen); | ||
| p.drawRoundedRect(rect(), 8, 8); |
There was a problem hiding this comment.
这个圆角值从哪儿来的?可以参照下ToolButton的值,
1. Added new PageButton class inheriting from QFrame with hover/press visual states 2. Replaced DToolButton with PageButton for next/previous navigation in calendar 3. Implemented custom painting with rounded corners and hover effects 4. Added proper event handling for mouse interactions 5. Centralized icon positioning and styling 6. Simplified button sizing by moving fixed dimensions to PageButton class The change was made to provide more consistent and visually appealing navigation buttons in the calendar widget, with better hover/pressed state feedback compared to the standard DToolButton. The custom implementation allows for more control over the visual appearance and behavior. feat: 为日历导航实现自定义 PageButton 1. 新增继承自 QFrame 的 PageButton 类,带有悬停/按下视觉状态 2. 在日历导航中用 PageButton 替换 DToolButton 3. 实现自定义绘制,包括圆角和悬停效果 4. 添加了适当的鼠标交互事件处理 5. 集中处理图标位置和样式 6. 通过将固定尺寸移至 PageButton 类简化按钮尺寸设置 此变更为日历组件提供了更一致且视觉上更吸引人的导航按钮,相比标准 DToolButton 提供了更好的悬停/按下状态反馈。自定义实现可以更好地控制视觉 外观和行为。 Pms: BUG-321969
deepin pr auto review代码审查意见:
以上是代码审查的一些主要意见,希望对你有所帮助。 |
|
/forcemerge |
|
This pr force merged! (status: blocked) |
The change was made to provide more consistent and visually appealing navigation buttons in the calendar widget, with better hover/pressed state feedback compared to the standard DToolButton. The custom implementation allows for more control over the visual appearance and behavior.
feat: 为日历导航实现自定义 PageButton
此变更为日历组件提供了更一致且视觉上更吸引人的导航按钮,相比标准
DToolButton 提供了更好的悬停/按下状态反馈。自定义实现可以更好地控制视觉
外观和行为。
Pms: BUG-321969
Summary by Sourcery
Implement a new PageButton widget to replace DToolButton in calendar navigation, providing consistent sizing, centralized styling, and enhanced hover and press states.
New Features:
Enhancements: