Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
k54kdk
PyQt Fluent Widgets
提交
34df2528
P
PyQt Fluent Widgets
项目概览
k54kdk
/
PyQt Fluent Widgets
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PyQt Fluent Widgets
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
34df2528
编写于
5月 23, 2023
作者:
之一Yo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
修复移除导航菜单项的问题
上级
92b0ca45
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
34 addition
and
3 deletion
+34
-3
qfluentwidgets/common/router.py
qfluentwidgets/common/router.py
+3
-0
qfluentwidgets/components/navigation/navigation_panel.py
qfluentwidgets/components/navigation/navigation_panel.py
+10
-0
qfluentwidgets/components/navigation/navigation_widget.py
qfluentwidgets/components/navigation/navigation_widget.py
+21
-3
未找到文件。
qfluentwidgets/common/router.py
浏览文件 @
34df2528
# coding:utf-8
# coding:utf-8
from
typing
import
Dict
,
List
from
typing
import
Dict
,
List
from
itertools
import
groupby
from
PyQt5.QtCore
import
Qt
,
QObject
,
pyqtSignal
from
PyQt5.QtCore
import
Qt
,
QObject
,
pyqtSignal
from
PyQt5.QtWidgets
import
QWidget
,
QStackedWidget
from
PyQt5.QtWidgets
import
QWidget
,
QStackedWidget
...
@@ -52,6 +53,7 @@ class StackedHistory:
...
@@ -52,6 +53,7 @@ class StackedHistory:
return
return
self
.
history
[
1
:]
=
[
i
for
i
in
self
.
history
[
1
:]
if
i
!=
routeKey
]
self
.
history
[
1
:]
=
[
i
for
i
in
self
.
history
[
1
:]
if
i
!=
routeKey
]
self
.
history
=
[
k
for
k
,
g
in
groupby
(
self
.
history
)]
self
.
goToTop
()
self
.
goToTop
()
def
top
(
self
):
def
top
(
self
):
...
@@ -119,6 +121,7 @@ class Router(QObject):
...
@@ -119,6 +121,7 @@ class Router(QObject):
def
remove
(
self
,
routeKey
:
str
):
def
remove
(
self
,
routeKey
:
str
):
""" remove history """
""" remove history """
self
.
history
=
[
i
for
i
in
self
.
history
if
i
.
routeKey
!=
routeKey
]
self
.
history
=
[
i
for
i
in
self
.
history
if
i
.
routeKey
!=
routeKey
]
self
.
history
=
[
list
(
g
)[
0
]
for
k
,
g
in
groupby
(
self
.
history
,
lambda
i
:
i
.
routeKey
)]
self
.
emptyChanged
.
emit
(
not
bool
(
self
.
history
))
self
.
emptyChanged
.
emit
(
not
bool
(
self
.
history
))
for
stacked
,
history
in
self
.
stackHistories
.
items
():
for
stacked
,
history
in
self
.
stackHistories
.
items
():
...
...
qfluentwidgets/components/navigation/navigation_panel.py
浏览文件 @
34df2528
...
@@ -357,6 +357,16 @@ class NavigationPanel(QFrame):
...
@@ -357,6 +357,16 @@ class NavigationPanel(QFrame):
if
item
.
parentRouteKey
is
not
None
:
if
item
.
parentRouteKey
is
not
None
:
self
.
widget
(
item
.
parentRouteKey
).
removeChild
(
item
.
widget
)
self
.
widget
(
item
.
parentRouteKey
).
removeChild
(
item
.
widget
)
if
isinstance
(
item
.
widget
,
NavigationTreeWidgetBase
):
for
child
in
item
.
widget
.
findChildren
(
NavigationWidget
,
options
=
Qt
.
FindChildrenRecursively
):
key
=
child
.
property
(
'routeKey'
)
if
key
is
None
:
continue
self
.
items
.
pop
(
key
)
child
.
deleteLater
()
self
.
history
.
remove
(
key
)
item
.
widget
.
deleteLater
()
item
.
widget
.
deleteLater
()
self
.
history
.
remove
(
routeKey
)
self
.
history
.
remove
(
routeKey
)
...
...
qfluentwidgets/components/navigation/navigation_widget.py
浏览文件 @
34df2528
...
@@ -8,7 +8,7 @@ from PyQt5.QtWidgets import QWidget, QVBoxLayout
...
@@ -8,7 +8,7 @@ from PyQt5.QtWidgets import QWidget, QVBoxLayout
from
...common.config
import
isDarkTheme
from
...common.config
import
isDarkTheme
from
...common.style_sheet
import
themeColor
from
...common.style_sheet
import
themeColor
from
...common.icon
import
drawIcon
from
...common.icon
import
drawIcon
,
toQIcon
from
...common.icon
import
FluentIcon
as
FIF
from
...common.icon
import
FluentIcon
as
FIF
...
@@ -90,7 +90,7 @@ class NavigationPushButton(NavigationWidget):
...
@@ -90,7 +90,7 @@ class NavigationPushButton(NavigationWidget):
"""
"""
super
().
__init__
(
isSelectable
=
isSelectable
,
parent
=
parent
)
super
().
__init__
(
isSelectable
=
isSelectable
,
parent
=
parent
)
self
.
icon
=
icon
self
.
_
icon
=
icon
self
.
_text
=
text
self
.
_text
=
text
self
.
setStyleSheet
(
self
.
setStyleSheet
(
...
@@ -99,6 +99,17 @@ class NavigationPushButton(NavigationWidget):
...
@@ -99,6 +99,17 @@ class NavigationPushButton(NavigationWidget):
def
text
(
self
):
def
text
(
self
):
return
self
.
_text
return
self
.
_text
def
setText
(
self
,
text
:
str
):
self
.
_text
=
text
self
.
update
()
def
icon
(
self
):
return
toQIcon
(
self
.
_icon
)
def
setIcon
(
self
,
icon
:
Union
[
str
,
QIcon
,
FIF
]):
self
.
_icon
=
icon
self
.
update
()
def
_margins
(
self
):
def
_margins
(
self
):
return
QMargins
(
0
,
0
,
0
,
0
)
return
QMargins
(
0
,
0
,
0
,
0
)
...
@@ -133,7 +144,7 @@ class NavigationPushButton(NavigationWidget):
...
@@ -133,7 +144,7 @@ class NavigationPushButton(NavigationWidget):
painter
.
setBrush
(
QColor
(
c
,
c
,
c
,
10
))
painter
.
setBrush
(
QColor
(
c
,
c
,
c
,
10
))
painter
.
drawRoundedRect
(
self
.
rect
(),
5
,
5
)
painter
.
drawRoundedRect
(
self
.
rect
(),
5
,
5
)
drawIcon
(
self
.
icon
,
painter
,
QRectF
(
11.5
+
pl
,
10
,
16
,
16
))
drawIcon
(
self
.
_
icon
,
painter
,
QRectF
(
11.5
+
pl
,
10
,
16
,
16
))
# draw text
# draw text
if
self
.
isCompacted
:
if
self
.
isCompacted
:
...
@@ -295,6 +306,10 @@ class NavigationTreeWidgetBase(NavigationWidget):
...
@@ -295,6 +306,10 @@ class NavigationTreeWidgetBase(NavigationWidget):
"""
"""
raise
NotImplementedError
raise
NotImplementedError
def
childItems
(
self
)
->
list
:
""" return child items """
raise
NotImplementedError
class
NavigationTreeWidget
(
NavigationTreeWidgetBase
):
class
NavigationTreeWidget
(
NavigationTreeWidgetBase
):
""" Navigation tree widget """
""" Navigation tree widget """
...
@@ -346,6 +361,9 @@ class NavigationTreeWidget(NavigationTreeWidgetBase):
...
@@ -346,6 +361,9 @@ class NavigationTreeWidget(NavigationTreeWidgetBase):
self
.
treeChildren
.
remove
(
child
)
self
.
treeChildren
.
remove
(
child
)
self
.
vBoxLayout
.
removeWidget
(
child
)
self
.
vBoxLayout
.
removeWidget
(
child
)
def
childItems
(
self
)
->
list
:
return
self
.
treeChildren
def
setExpanded
(
self
,
isExpanded
:
bool
,
ani
=
False
):
def
setExpanded
(
self
,
isExpanded
:
bool
,
ani
=
False
):
""" set the expanded status """
""" set the expanded status """
if
isExpanded
==
self
.
isExpanded
:
if
isExpanded
==
self
.
isExpanded
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录