feat(navigation): add NavigationUserCard component #1085
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
NavigationUserCard - 导航用户信息卡片组件
为 PyQt-Fluent-Widgets 的导航组件添加用户信息卡片功能,支持显示头像/图标、标题和副标题信息。
2025-11-1721-24-27-ezgif.com-gif-maker.mp4
演示
功能特性
双状态显示
过渡动画
行为
EXPAND: 紧凑模式下展开导航栏(默认)CALLBACK: 触发自定义回调函数EXPAND_AND_CALLBACK: 同时展开并触发回调自定义选项
主要改动
navigation_user_card.py: 新增 NavigationUserCard 组件
NavigationUserCard类:用户信息卡片组件NavigationUserCardClickBehavior枚举:点击行为配置setCompacted(): 响应紧凑/展开模式切换mouseReleaseEvent(): 根据配置处理点击行为_drawAvatar(): 绘制圆形头像(支持图片裁剪和图标)_drawText(): 绘制标题和副标题(支持透明度渐变)setAvatar(),setTitle(),setSubtitle(),setCompactClickBehavior()navigation_interface.py: 添加用户卡片支持
addUserCard(): 添加用户卡片到导航面板aboveMenuButton参数控制卡片位置API
NavigationInterface.addUserCard()
routeKey: 用户卡片的唯一标识avatar: 头像图片路径、QIcon 或 FluentIconBasetitle: 用户名或主标题文字subtitle: 副标题文字(如邮箱、状态)onClick: 点击回调函数position: 添加位置(TOP/SCROLL/BOTTOM)aboveMenuButton: 是否放置在菜单按钮上方NavigationUserCard 方法
NavigationUserCardClickBehavior 枚举
完整的演示代码位于
examples/navigation/navigation_user_card/demo.py