Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
k54kdk
PyQt Fluent Widgets
提交
710e27a1
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看板
提交
710e27a1
编写于
5月 02, 2023
作者:
之一Yo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
添加滚动条,#160
上级
2283b5e3
变更
50
展开全部
隐藏空白更改
内联
并排
Showing
50 changed file
with
262754 addition
and
263249 deletion
+262754
-263249
examples/gallery/app/common/resource.py
examples/gallery/app/common/resource.py
+207627
-207900
examples/gallery/app/components/link_card.py
examples/gallery/app/components/link_card.py
+2
-2
examples/gallery/app/resource/qss/dark/gallery_interface.qss
examples/gallery/app/resource/qss/dark/gallery_interface.qss
+0
-34
examples/gallery/app/resource/qss/dark/home_interface.qss
examples/gallery/app/resource/qss/dark/home_interface.qss
+0
-31
examples/gallery/app/resource/qss/dark/icon_interface.qss
examples/gallery/app/resource/qss/dark/icon_interface.qss
+0
-29
examples/gallery/app/resource/qss/dark/setting_interface.qss
examples/gallery/app/resource/qss/dark/setting_interface.qss
+0
-31
examples/gallery/app/resource/qss/light/gallery_interface.qss
...ples/gallery/app/resource/qss/light/gallery_interface.qss
+0
-34
examples/gallery/app/resource/qss/light/home_interface.qss
examples/gallery/app/resource/qss/light/home_interface.qss
+0
-29
examples/gallery/app/resource/qss/light/icon_interface.qss
examples/gallery/app/resource/qss/light/icon_interface.qss
+0
-30
examples/gallery/app/resource/qss/light/setting_interface.qss
...ples/gallery/app/resource/qss/light/setting_interface.qss
+0
-32
examples/gallery/app/view/home_interface.py
examples/gallery/app/view/home_interface.py
+4
-1
examples/gallery/app/view/scroll_interface.py
examples/gallery/app/view/scroll_interface.py
+4
-4
examples/gallery/demo.py
examples/gallery/demo.py
+6
-0
examples/scroll_area/resource/demo.qss
examples/scroll_area/resource/demo.qss
+2
-39
examples/settings/resource/qss/dark/setting_interface.qss
examples/settings/resource/qss/dark/setting_interface.qss
+0
-31
examples/settings/resource/qss/light/setting_interface.qss
examples/settings/resource/qss/light/setting_interface.qss
+0
-31
examples/tree_view/demo.py
examples/tree_view/demo.py
+1
-1
qfluentwidgets/_rc/images/icons/CareDownSolid_black.svg
qfluentwidgets/_rc/images/icons/CareDownSolid_black.svg
+1
-1
qfluentwidgets/_rc/images/icons/CareDownSolid_white.svg
qfluentwidgets/_rc/images/icons/CareDownSolid_white.svg
+0
-0
qfluentwidgets/_rc/images/icons/CareLeftSolid_black.svg
qfluentwidgets/_rc/images/icons/CareLeftSolid_black.svg
+4
-0
qfluentwidgets/_rc/images/icons/CareLeftSolid_white.svg
qfluentwidgets/_rc/images/icons/CareLeftSolid_white.svg
+4
-0
qfluentwidgets/_rc/images/icons/CareRightSolid_black.svg
qfluentwidgets/_rc/images/icons/CareRightSolid_black.svg
+4
-0
qfluentwidgets/_rc/images/icons/CareRightSolid_white.svg
qfluentwidgets/_rc/images/icons/CareRightSolid_white.svg
+4
-0
qfluentwidgets/_rc/images/icons/CareUpSolid_black.svg
qfluentwidgets/_rc/images/icons/CareUpSolid_black.svg
+1
-1
qfluentwidgets/_rc/images/icons/CareUpSolid_white.svg
qfluentwidgets/_rc/images/icons/CareUpSolid_white.svg
+0
-0
qfluentwidgets/_rc/qss/dark/color_dialog.qss
qfluentwidgets/_rc/qss/dark/color_dialog.qss
+0
-31
qfluentwidgets/_rc/qss/dark/folder_list_dialog.qss
qfluentwidgets/_rc/qss/dark/folder_list_dialog.qss
+0
-29
qfluentwidgets/_rc/qss/dark/line_edit.qss
qfluentwidgets/_rc/qss/dark/line_edit.qss
+0
-46
qfluentwidgets/_rc/qss/dark/table_view.qss
qfluentwidgets/_rc/qss/dark/table_view.qss
+0
-43
qfluentwidgets/_rc/qss/dark/tree_view.qss
qfluentwidgets/_rc/qss/dark/tree_view.qss
+0
-42
qfluentwidgets/_rc/qss/light/color_dialog.qss
qfluentwidgets/_rc/qss/light/color_dialog.qss
+0
-29
qfluentwidgets/_rc/qss/light/folder_list_dialog.qss
qfluentwidgets/_rc/qss/light/folder_list_dialog.qss
+0
-26
qfluentwidgets/_rc/qss/light/line_edit.qss
qfluentwidgets/_rc/qss/light/line_edit.qss
+0
-46
qfluentwidgets/_rc/qss/light/table_view.qss
qfluentwidgets/_rc/qss/light/table_view.qss
+0
-44
qfluentwidgets/_rc/qss/light/tree_view.qss
qfluentwidgets/_rc/qss/light/tree_view.qss
+0
-43
qfluentwidgets/_rc/resource.py
qfluentwidgets/_rc/resource.py
+54502
-54380
qfluentwidgets/_rc/resource.qrc
qfluentwidgets/_rc/resource.qrc
+8
-4
qfluentwidgets/common/icon.py
qfluentwidgets/common/icon.py
+4
-0
qfluentwidgets/components/dialog_box/color_dialog.py
qfluentwidgets/components/dialog_box/color_dialog.py
+2
-2
qfluentwidgets/components/dialog_box/folder_list_dialog.py
qfluentwidgets/components/dialog_box/folder_list_dialog.py
+3
-2
qfluentwidgets/components/navigation/navigation_panel.py
qfluentwidgets/components/navigation/navigation_panel.py
+2
-2
qfluentwidgets/components/widgets/__init__.py
qfluentwidgets/components/widgets/__init__.py
+3
-2
qfluentwidgets/components/widgets/cycle_list_widget.py
qfluentwidgets/components/widgets/cycle_list_widget.py
+13
-21
qfluentwidgets/components/widgets/line_edit.py
qfluentwidgets/components/widgets/line_edit.py
+3
-16
qfluentwidgets/components/widgets/menu.py
qfluentwidgets/components/widgets/menu.py
+1
-0
qfluentwidgets/components/widgets/scroll_area.py
qfluentwidgets/components/widgets/scroll_area.py
+26
-98
qfluentwidgets/components/widgets/scroll_bar.py
qfluentwidgets/components/widgets/scroll_bar.py
+517
-0
qfluentwidgets/components/widgets/table_view.py
qfluentwidgets/components/widgets/table_view.py
+3
-12
qfluentwidgets/components/widgets/three_state_button.py
qfluentwidgets/components/widgets/three_state_button.py
+0
-57
qfluentwidgets/components/widgets/tree_view.py
qfluentwidgets/components/widgets/tree_view.py
+3
-13
未找到文件。
examples/gallery/app/common/resource.py
浏览文件 @
710e27a1
此差异已折叠。
点击以展开。
examples/gallery/app/components/link_card.py
浏览文件 @
710e27a1
...
...
@@ -3,7 +3,7 @@ from PyQt5.QtCore import Qt, QUrl
from
PyQt5.QtGui
import
QPixmap
,
QDesktopServices
from
PyQt5.QtWidgets
import
QFrame
,
QLabel
,
QVBoxLayout
,
QWidget
,
QHBoxLayout
from
qfluentwidgets
import
IconWidget
,
FluentIcon
,
TextWrap
,
ScrollArea
from
qfluentwidgets
import
IconWidget
,
FluentIcon
,
TextWrap
,
S
ingleDirectionS
crollArea
from
..common.style_sheet
import
StyleSheet
...
...
@@ -45,7 +45,7 @@ class LinkCard(QFrame):
QDesktopServices
.
openUrl
(
self
.
url
)
class
LinkCardView
(
ScrollArea
):
class
LinkCardView
(
S
ingleDirectionS
crollArea
):
""" Link card view """
def
__init__
(
self
,
parent
=
None
):
...
...
examples/gallery/app/resource/qss/dark/gallery_interface.qss
浏览文件 @
710e27a1
...
...
@@ -49,37 +49,3 @@ ExampleCard>#titleLabel {
color: white;
font: 14px 'Segoe UI', 'Microsoft YaHei';
}
QScrollBar {
background: transparent;
width: 4px;
margin-top: 132px;
margin-bottom: 0;
padding-right: 2px;
}
#imageViewer QScrollBar {
margin-top: 0px;
}
/*隐藏上箭头*/
QScrollBar::sub-line {
background: transparent;
}
/*隐藏下箭头*/
QScrollBar::add-line {
background: transparent;
}
QScrollBar::handle {
background: rgb(122, 122, 122);
border: 2px solid rgb(128, 128, 128);
border-radius: 1px;
min-height: 32px;
}
QScrollBar::add-page:vertical,
QScrollBar::sub-page:vertical {
background: none;
}
\ No newline at end of file
examples/gallery/app/resource/qss/dark/home_interface.qss
浏览文件 @
710e27a1
...
...
@@ -16,34 +16,3 @@ BannerWidget > #galleryLabel {
color: white;
padding-left: 28px;
}
QScrollBar {
background: transparent;
width: 4px;
margin-top: 32px;
margin-bottom: 0;
padding-right: 2px;
}
/*隐藏上箭头*/
QScrollBar::sub-line {
background: transparent;
}
/*隐藏下箭头*/
QScrollBar::add-line {
background: transparent;
}
QScrollBar::handle {
background: rgb(122, 122, 122);
border: 2px solid rgb(128, 128, 128);
border-radius: 1px;
min-height: 32px;
}
QScrollBar::add-page:vertical,
QScrollBar::sub-page:vertical {
background: none;
}
\ No newline at end of file
examples/gallery/app/resource/qss/dark/icon_interface.qss
浏览文件 @
710e27a1
...
...
@@ -60,32 +60,3 @@ IconInfoPanel>QLabel {
color: rgb(207, 207, 207);
}
QScrollBar {
background: transparent;
width: 4px;
margin-top: 10px;
margin-bottom: 0;
padding-right: 2px;
}
QScrollBar::sub-line {
background: transparent;
}
QScrollBar::add-line {
background: transparent;
}
QScrollBar::handle {
background: rgb(122, 122, 122);
border: 2px solid rgb(128, 128, 128);
border-radius: 1px;
min-height: 32px;
}
QScrollBar::add-page:vertical,
QScrollBar::sub-page:vertical {
background: none;
}
\ No newline at end of file
examples/gallery/app/resource/qss/dark/setting_interface.qss
浏览文件 @
710e27a1
...
...
@@ -15,34 +15,3 @@ QLabel#settingLabel {
color: white;
}
/* 滚动条 */
QScrollBar {
background: transparent;
width: 4px;
margin-top: 32px;
margin-bottom: 0;
padding-right: 2px;
}
/*隐藏上箭头*/
QScrollBar::sub-line {
background: transparent;
}
/*隐藏下箭头*/
QScrollBar::add-line {
background: transparent;
}
QScrollBar::handle {
background: rgb(122, 122, 122);
border: 2px solid rgb(128, 128, 128);
border-radius: 1px;
min-height: 32px;
}
QScrollBar::add-page:vertical,
QScrollBar::sub-page:vertical {
background: none;
}
\ No newline at end of file
examples/gallery/app/resource/qss/light/gallery_interface.qss
浏览文件 @
710e27a1
...
...
@@ -46,37 +46,3 @@ ExampleCard > #titleLabel {
color: black;
font: 14px 'Segoe UI', 'Microsoft YaHei';
}
QScrollBar {
background: transparent;
width: 4px;
margin-top: 132px;
margin-bottom: 0;
padding-right: 2px;
}
#imageViewer QScrollBar {
margin-top: 0px;
}
QScrollBar::sub-line {
background: transparent;
}
QScrollBar::add-line {
background: transparent;
}
QScrollBar::handle {
background: rgb(122, 122, 122);
border: 2px solid rgb(128, 128, 128);
border-radius: 1px;
min-height: 32px;
}
QScrollBar::add-page:vertical,
QScrollBar::sub-page:vertical {
background: none;
}
\ No newline at end of file
examples/gallery/app/resource/qss/light/home_interface.qss
浏览文件 @
710e27a1
...
...
@@ -17,32 +17,3 @@ BannerWidget > #galleryLabel {
}
QScrollBar {
background: transparent;
width: 4px;
margin-top: 32px;
margin-bottom: 0;
padding-right: 2px;
}
/*隐藏上箭头*/
QScrollBar::sub-line {
background: transparent;
}
/*隐藏下箭头*/
QScrollBar::add-line {
background: transparent;
}
QScrollBar::handle {
background: rgb(122, 122, 122);
border: 2px solid rgb(128, 128, 128);
border-radius: 1px;
min-height: 32px;
}
QScrollBar::add-page:vertical,
QScrollBar::sub-page:vertical {
background: none;
}
\ No newline at end of file
examples/gallery/app/resource/qss/light/icon_interface.qss
浏览文件 @
710e27a1
...
...
@@ -61,33 +61,3 @@ IconInfoPanel > QLabel {
background-color: transparent;
color: black;
}
QScrollBar {
background: transparent;
width: 4px;
margin-top: 10px;
margin-bottom: 0;
padding-right: 2px;
}
QScrollBar::sub-line {
background: transparent;
}
QScrollBar::add-line {
background: transparent;
}
QScrollBar::handle {
background: rgb(122, 122, 122);
border: 2px solid rgb(128, 128, 128);
border-radius: 1px;
min-height: 32px;
}
QScrollBar::add-page:vertical,
QScrollBar::sub-page:vertical {
background: none;
}
\ No newline at end of file
examples/gallery/app/resource/qss/light/setting_interface.qss
浏览文件 @
710e27a1
...
...
@@ -13,35 +13,3 @@ QLabel#settingLabel {
font: 33px 'Microsoft YaHei Light';
background-color: transparent;
}
/* 滚动条 */
QScrollBar {
background: transparent;
width: 4px;
margin-top: 32px;
margin-bottom: 0;
padding-right: 2px;
}
/*隐藏上箭头*/
QScrollBar::sub-line {
background: transparent;
}
/*隐藏下箭头*/
QScrollBar::add-line {
background: transparent;
}
QScrollBar::handle {
background: rgb(122, 122, 122);
border: 2px solid rgb(128, 128, 128);
border-radius: 1px;
min-height: 32px;
}
QScrollBar::add-page:vertical,
QScrollBar::sub-page:vertical {
background: none;
}
\ No newline at end of file
examples/gallery/app/view/home_interface.py
浏览文件 @
710e27a1
...
...
@@ -77,7 +77,10 @@ class BannerWidget(QWidget):
path
=
path
.
simplified
()
# draw background color
painter
.
fillPath
(
path
,
QColor
(
206
,
216
,
228
))
if
not
isDarkTheme
():
painter
.
fillPath
(
path
,
QColor
(
206
,
216
,
228
))
else
:
painter
.
fillPath
(
path
,
QColor
(
0
,
0
,
0
))
# draw banner image
pixmap
=
self
.
banner
.
scaled
(
...
...
examples/gallery/app/view/scroll_interface.py
浏览文件 @
710e27a1
...
...
@@ -2,7 +2,7 @@
from
PyQt5.QtCore
import
Qt
,
QEasingCurve
from
PyQt5.QtGui
import
QPixmap
from
PyQt5.QtWidgets
import
QWidget
from
qfluentwidgets
import
ScrollArea
,
SmoothScrollArea
,
ToolTipFilter
,
PixmapLabel
from
qfluentwidgets
import
S
ingleDirectionS
crollArea
,
SmoothScrollArea
,
ToolTipFilter
,
PixmapLabel
from
.gallery_interface
import
GalleryInterface
from
..common.translator
import
Translator
...
...
@@ -19,7 +19,7 @@ class ScrollInterface(GalleryInterface):
parent
=
parent
)
w
=
ScrollArea
()
w
=
S
ingleDirectionS
crollArea
()
label
=
PixmapLabel
(
self
)
label
.
setPixmap
(
QPixmap
(
":/gallery/images/chidanta2.jpg"
).
scaled
(
775
,
1229
,
Qt
.
KeepAspectRatio
,
Qt
.
SmoothTransformation
...
...
@@ -27,7 +27,7 @@ class ScrollInterface(GalleryInterface):
w
.
horizontalScrollBar
().
setValue
(
0
)
w
.
setWidget
(
label
)
w
.
setFixedSize
(
7
80
,
430
)
w
.
setFixedSize
(
7
75
,
430
)
w
.
setObjectName
(
'imageViewer'
)
card
=
self
.
addExampleCard
(
...
...
@@ -44,7 +44,7 @@ class ScrollInterface(GalleryInterface):
label
.
setPixmap
(
QPixmap
(
":/gallery/images/chidanta3.jpg"
))
w
.
setWidget
(
label
)
w
.
setFixedSize
(
65
9
,
540
)
w
.
setFixedSize
(
65
4
,
540
)
w
.
setObjectName
(
'imageViewer'
)
card
=
self
.
addExampleCard
(
...
...
examples/gallery/demo.py
浏览文件 @
710e27a1
...
...
@@ -3,6 +3,7 @@ import os
import
sys
from
PyQt5.QtCore
import
Qt
,
QTranslator
from
PyQt5.QtGui
import
QFont
from
PyQt5.QtWidgets
import
QApplication
from
qfluentwidgets
import
FluentTranslator
...
...
@@ -25,6 +26,11 @@ QApplication.setAttribute(Qt.AA_UseHighDpiPixmaps)
app
=
QApplication
(
sys
.
argv
)
app
.
setAttribute
(
Qt
.
AA_DontCreateNativeWidgetSiblings
)
# font anti aliasing
font
=
app
.
font
()
font
.
setHintingPreference
(
QFont
.
PreferNoHinting
)
app
.
setFont
(
font
)
# internationalization
locale
=
cfg
.
get
(
cfg
.
language
).
value
translator
=
FluentTranslator
(
locale
)
...
...
examples/scroll_area/resource/demo.qss
浏览文件 @
710e27a1
QScrollBar:vertical {
background: transparent;
width: 5px;
padding-right: 2px;
}
QScrollBar:horizontal {
background: transparent;
height: 5px;
padding-bottom: 2px;
}
/*隐藏上箭头*/
QScrollBar::sub-line {
background: transparent;
}
/*隐藏下箭头*/
QScrollBar::add-line {
background: transparent;
}
QScrollBar::handle {
background: rgb(122, 122, 122);
border: 2px solid rgb(128, 128, 128);
border-radius: 1px;
}
QScrollBar::handle:vertical {
min-height: 40px;
}
QScrollBar::handle:horizontal {
min-width: 40px;
}
QScrollBar::add-page,
QScrollBar::sub-page {
background: none;
QScrollArea {
border: none;
}
\ No newline at end of file
examples/settings/resource/qss/dark/setting_interface.qss
浏览文件 @
710e27a1
...
...
@@ -15,34 +15,3 @@ QLabel#settingLabel {
color: white;
}
/* 滚动条 */
QScrollBar {
background: transparent;
width: 4px;
margin-top: 32px;
margin-bottom: 0;
padding-right: 2px;
}
/*隐藏上箭头*/
QScrollBar::sub-line {
background: transparent;
}
/*隐藏下箭头*/
QScrollBar::add-line {
background: transparent;
}
QScrollBar::handle {
background: rgb(122, 122, 122);
border: 2px solid rgb(128, 128, 128);
border-radius: 1px;
min-height: 32px;
}
QScrollBar::add-page:vertical,
QScrollBar::sub-page:vertical {
background: none;
}
\ No newline at end of file
examples/settings/resource/qss/light/setting_interface.qss
浏览文件 @
710e27a1
...
...
@@ -14,34 +14,3 @@ QLabel#settingLabel {
background-color: transparent;
}
/* 滚动条 */
QScrollBar {
background: transparent;
width: 4px;
margin-top: 32px;
margin-bottom: 0;
padding-right: 2px;
}
/*隐藏上箭头*/
QScrollBar::sub-line {
background: transparent;
}
/*隐藏下箭头*/
QScrollBar::add-line {
background: transparent;
}
QScrollBar::handle {
background: rgb(122, 122, 122);
border: 2px solid rgb(128, 128, 128);
border-radius: 1px;
min-height: 32px;
}
QScrollBar::add-page:vertical,
QScrollBar::sub-page:vertical {
background: none;
}
\ No newline at end of file
examples/tree_view/demo.py
浏览文件 @
710e27a1
...
...
@@ -21,7 +21,7 @@ class Demo(QWidget):
self
.
view
.
setModel
(
model
)
self
.
hBoxLayout
.
addWidget
(
self
.
view
)
self
.
hBoxLayout
.
setContentsMargins
(
30
,
30
,
30
,
3
0
)
self
.
hBoxLayout
.
setContentsMargins
(
0
,
0
,
0
,
0
)
self
.
resize
(
700
,
600
)
...
...
qfluentwidgets/_rc/images/
time_picker/Down
_black.svg
→
qfluentwidgets/_rc/images/
icons/CareDownSolid
_black.svg
浏览文件 @
710e27a1
<?xml version="1.0" encoding="utf-8"?>
<svg
id=
""
width=
"16"
height=
"16"
style=
"width:16px;height:16px;"
version=
"1.1"
xmlns=
"http://www.w3.org/2000/svg"
viewBox=
"0 0 2048 2048"
enable-background=
"new 0 0 2048 2048"
xml:space=
"preserve"
><path
fill=
"#5E5E5E"
transform=
"translate(0, 400)"
d=
"M0 184 q0 -37.71 13.71 -70.86 q13.71 -33.14 38.28 -58.29 q24.57 -25.15 57.14 -40 q32.57 -14.86 70.29 -14.86 l1689.14 0 q37.72 0 70.29 14.86 q32.57 14.86 57.14 40 q24.57 25.14 38.28 58.29 q13.72 33.14 13.72 70.86 q0 68.57 -44.57 120 l-790.86 924.57 q-36.57 42.29 -84.57 65.14 q-48 22.86 -104 22.86 q-56 0 -104 -22.86 q-48 -22.86 -84.57 -65.14 l-790.86 -924.57 q-44.57 -51.43 -44.57 -120 Z"
/></svg>
\ No newline at end of file
xml:space=
"preserve"
><path
fill=
"#000000"
transform=
"translate(0, 400)"
d=
"M0 184 q0 -37.71 13.71 -70.86 q13.71 -33.14 38.28 -58.29 q24.57 -25.15 57.14 -40 q32.57 -14.86 70.29 -14.86 l1689.14 0 q37.72 0 70.29 14.86 q32.57 14.86 57.14 40 q24.57 25.14 38.28 58.29 q13.72 33.14 13.72 70.86 q0 68.57 -44.57 120 l-790.86 924.57 q-36.57 42.29 -84.57 65.14 q-48 22.86 -104 22.86 q-56 0 -104 -22.86 q-48 -22.86 -84.57 -65.14 l-790.86 -924.57 q-44.57 -51.43 -44.57 -120 Z"
/></svg>
\ No newline at end of file
qfluentwidgets/_rc/images/
time_picker/Down
_white.svg
→
qfluentwidgets/_rc/images/
icons/CareDownSolid
_white.svg
浏览文件 @
710e27a1
文件已移动
qfluentwidgets/_rc/images/icons/CareLeftSolid_black.svg
0 → 100644
浏览文件 @
710e27a1
<?xml version="1.0" encoding="utf-8"?>
<svg
id=
""
width=
"16"
height=
"16"
style=
"width:16px;height:16px;"
version=
"1.1"
xmlns=
"http://www.w3.org/2000/svg"
viewBox=
"0 0 2048 2048"
enable-background=
"new 0 0 2048 2048"
xml:space=
"preserve"
><path
fill=
"#000000"
d=
"M256 1024 q0 -94 44 -176.5 q44 -82.5 121 -135.5 l969 -666 q34 -23 69 -34.5 q35 -11.5 77 -11.5 q52 0 99 20 q47 20 81.5 54.5 q34.5 34.5 55 80.5 q20.5 46 20.5 99 l0 1540 q0 53 -20.5 99 q-20.5 46 -55 80.5 q-34.5 34.5 -81.5 54.5 q-47 20 -99 20 q-79 0 -146 -46 l-969 -666 q-77 -53 -121 -135.5 q-44 -82.5 -44 -176.5 Z"
/></svg>
\ No newline at end of file
qfluentwidgets/_rc/images/icons/CareLeftSolid_white.svg
0 → 100644
浏览文件 @
710e27a1
<?xml version="1.0" encoding="utf-8"?>
<svg
id=
""
width=
"16"
height=
"16"
style=
"width:16px;height:16px;"
version=
"1.1"
xmlns=
"http://www.w3.org/2000/svg"
viewBox=
"0 0 2048 2048"
enable-background=
"new 0 0 2048 2048"
xml:space=
"preserve"
><path
fill=
"#FFFFFF"
d=
"M256 1024 q0 -94 44 -176.5 q44 -82.5 121 -135.5 l969 -666 q34 -23 69 -34.5 q35 -11.5 77 -11.5 q52 0 99 20 q47 20 81.5 54.5 q34.5 34.5 55 80.5 q20.5 46 20.5 99 l0 1540 q0 53 -20.5 99 q-20.5 46 -55 80.5 q-34.5 34.5 -81.5 54.5 q-47 20 -99 20 q-79 0 -146 -46 l-969 -666 q-77 -53 -121 -135.5 q-44 -82.5 -44 -176.5 Z"
/></svg>
\ No newline at end of file
qfluentwidgets/_rc/images/icons/CareRightSolid_black.svg
0 → 100644
浏览文件 @
710e27a1
<?xml version="1.0" encoding="utf-8"?>
<svg
id=
""
width=
"16"
height=
"16"
style=
"width:16px;height:16px;"
version=
"1.1"
xmlns=
"http://www.w3.org/2000/svg"
viewBox=
"0 0 2048 2048"
enable-background=
"new 0 0 2048 2048"
xml:space=
"preserve"
><path
fill=
"#000000"
d=
"M256 1794 l0 -1540 q0 -53 20.5 -99 q20.5 -46 55 -80.5 q34.5 -34.5 81 -54.5 q46.5 -20 99.5 -20 q79 0 146 46 l969 666 q78 54 121.5 136 q43.5 82 43.5 176 q0 94 -43.5 176 q-43.5 82 -121.5 136 l-969 666 q-67 46 -146 46 q-53 0 -99.5 -20 q-46.5 -20 -81 -54.5 q-34.5 -34.5 -55 -80.5 q-20.5 -46 -20.5 -99 Z"
/></svg>
\ No newline at end of file
qfluentwidgets/_rc/images/icons/CareRightSolid_white.svg
0 → 100644
浏览文件 @
710e27a1
<?xml version="1.0" encoding="utf-8"?>
<svg
id=
""
width=
"16"
height=
"16"
style=
"width:16px;height:16px;"
version=
"1.1"
xmlns=
"http://www.w3.org/2000/svg"
viewBox=
"0 0 2048 2048"
enable-background=
"new 0 0 2048 2048"
xml:space=
"preserve"
><path
fill=
"#FFFFFF"
d=
"M256 1794 l0 -1540 q0 -53 20.5 -99 q20.5 -46 55 -80.5 q34.5 -34.5 81 -54.5 q46.5 -20 99.5 -20 q79 0 146 46 l969 666 q78 54 121.5 136 q43.5 82 43.5 176 q0 94 -43.5 176 q-43.5 82 -121.5 136 l-969 666 q-67 46 -146 46 q-53 0 -99.5 -20 q-46.5 -20 -81 -54.5 q-34.5 -34.5 -55 -80.5 q-20.5 -46 -20.5 -99 Z"
/></svg>
\ No newline at end of file
qfluentwidgets/_rc/images/
time_picker/Up
_black.svg
→
qfluentwidgets/_rc/images/
icons/CareUpSolid
_black.svg
浏览文件 @
710e27a1
<?xml version="1.0" encoding="utf-8"?>
<svg
id=
""
width=
"16"
height=
"16"
style=
"width:16px;height:16px;"
version=
"1.1"
xmlns=
"http://www.w3.org/2000/svg"
viewBox=
"0 0 2048 2048"
enable-background=
"new 0 0 2048 2048"
xml:space=
"preserve"
><path
fill=
"#5E5E5E"
transform=
"translate(0, 350)"
d=
"M179.43 1316.57 q-37.72 0 -70.29 -14.86 q-32.57 -14.86 -57.14 -40 q-24.57 -25.14 -38.28 -58.29 q-13.71 -33.14 -13.71 -70.86 q0 -68.57 44.57 -120 l790.86 -924.57 q36.57 -42.29 84.57 -65.14 q48 -22.86 104 -22.86 q113.14 0 188.57 88 l790.86 924.57 q44.57 51.43 44.57 120 q0 37.72 -13.72 70.86 q-13.71 33.14 -38.28 58.29 q-24.57 25.14 -57.14 40 q-32.57 14.86 -70.29 14.86 l-1689.14 0 Z"
/></svg>
\ No newline at end of file
xml:space=
"preserve"
><path
fill=
"#000000"
transform=
"translate(0, 350)"
d=
"M179.43 1316.57 q-37.72 0 -70.29 -14.86 q-32.57 -14.86 -57.14 -40 q-24.57 -25.14 -38.28 -58.29 q-13.71 -33.14 -13.71 -70.86 q0 -68.57 44.57 -120 l790.86 -924.57 q36.57 -42.29 84.57 -65.14 q48 -22.86 104 -22.86 q113.14 0 188.57 88 l790.86 924.57 q44.57 51.43 44.57 120 q0 37.72 -13.72 70.86 q-13.71 33.14 -38.28 58.29 q-24.57 25.14 -57.14 40 q-32.57 14.86 -70.29 14.86 l-1689.14 0 Z"
/></svg>
\ No newline at end of file
qfluentwidgets/_rc/images/
time_picker/Up
_white.svg
→
qfluentwidgets/_rc/images/
icons/CareUpSolid
_white.svg
浏览文件 @
710e27a1
文件已移动
qfluentwidgets/_rc/qss/dark/color_dialog.qss
浏览文件 @
710e27a1
...
...
@@ -86,37 +86,6 @@ QSlider::handle:horizontal:disabled {
}
/* 滚动条 */
QScrollBar {
background: transparent;
width: 4px;
margin-top: 32px;
padding-right: 1px;
}
/*隐藏上箭头*/
QScrollBar::sub-line {
background: transparent;
}
/*隐藏下箭头*/
QScrollBar::add-line {
background: transparent;
}
QScrollBar::handle {
background: rgb(122, 122, 122);
border: 2px solid rgb(128, 128, 128);
border-radius: 1px;
min-height: 32px;
}
QScrollBar::add-page:vertical,
QScrollBar::sub-page:vertical {
background: none;
}
#cancelButton {
background: rgb(45, 45, 45);
border: 1px solid rgb(48, 48, 48);
...
...
qfluentwidgets/_rc/qss/dark/folder_list_dialog.qss
浏览文件 @
710e27a1
...
...
@@ -50,35 +50,6 @@ QScrollArea{
background-color: rgb(23, 23, 23);
}
/*滚动条*/
QScrollBar:vertical {
background: transparent;
border: none;
width: 3px;
}
/*隐藏上箭头*/
QScrollBar::sub-line {
background: transparent;
}
/*隐藏下箭头*/
QScrollBar::add-line {
background: transparent;
}
QScrollBar::handle {
background: rgb(128, 128, 128);
min-height: 40px;
border: 1px solid transparent;
border-radius: 1px;
}
QScrollBar::add-page:vertical,
QScrollBar::sub-page:vertical {
background: none;
}
#scrollWidget{
border: none;
...
...
qfluentwidgets/_rc/qss/dark/line_edit.qss
浏览文件 @
710e27a1
...
...
@@ -51,49 +51,3 @@ LineEdit:disabled, TextEdit:disabled, PlainTextEdit:disabled {
#lineEditButton:pressed {
background-color: rgba(255, 255, 255, 6);
}
QScrollBar {
background: transparent;
width: 4px;
margin-top: 12px;
margin-bottom: 0;
padding-right: 2px;
}
QScrollBar:horizontal {
background: transparent;
height: 4px;
margin-left: 12px;
margin-right: 12px;
padding-bottom: 2px;
}
QScrollBar::sub-line {
background: transparent;
}
QScrollBar::add-line {
background: transparent;
}
QScrollBar::handle {
background: rgb(122, 122, 122);
border: 2px solid rgb(128, 128, 128);
border-radius: 1px;
}
QScrollBar::handle:vertical {
min-height: 32px;
}
QScrollBar::handle:horizontal {
min-width: 32px;
}
QScrollBar::add-page:vertical,
QScrollBar::sub-page:vertical,
QScrollBar::add-page:horizontal,
QScrollBar::sub-page:horizontal {
background: none;
}
\ No newline at end of file
qfluentwidgets/_rc/qss/dark/table_view.qss
浏览文件 @
710e27a1
...
...
@@ -120,46 +120,3 @@ QHeaderView::up-arrow {
margin-right: 6px;
image: url(:/qfluentwidgets/images/table_view/Up_white.svg);
}
QScrollBar:vertical {
background: transparent;
width: 4px;
margin-top: 50px;
margin-bottom: 0;
padding-right: 2px;
}
QScrollBar:horizontal {
background: transparent;
height: 4px;
padding-bottom: 2px;
}
QScrollBar::sub-line {
background: transparent;
}
QScrollBar::add-line {
background: transparent;
}
QScrollBar::handle {
background: rgb(122, 122, 122);
border: 2px solid rgb(128, 128, 128);
border-radius: 1px;
}
QScrollBar::handle:vertical {
min-height: 32px;
}
QScrollBar::handle:horizontal {
min-width: 32px;
}
QScrollBar::add-page:vertical,
QScrollBar::sub-page:vertical,
QScrollBar::add-page:horizontal,
QScrollBar::sub-page:horizontal {
background: none;
}
\ No newline at end of file
qfluentwidgets/_rc/qss/dark/tree_view.qss
浏览文件 @
710e27a1
...
...
@@ -85,46 +85,4 @@ QTreeView::indicator:checked:disabled,
QTreeView::indicator:indeterminate:disabled {
border: 1px solid rgb(82, 82, 82);
background-color: rgb(82, 82, 82);
}
QScrollBar:vertical {
background: transparent;
width: 4px;
margin-top: 50px;
margin-bottom: 0;
padding-right: 2px;
}
QScrollBar:horizontal {
background: transparent;
height: 4px;
padding-bottom: 2px;
}
QScrollBar::sub-line {
background: transparent;
}
QScrollBar::add-line {
background: transparent;
}
QScrollBar::handle {
background: rgb(122, 122, 122);
border: 2px solid rgb(128, 128, 128);
border-radius: 1px;
}
QScrollBar::handle:vertical {
min-height: 32px;
}
QScrollBar::handle:horizontal {
min-width: 32px;
}
QScrollBar::add-page:vertical,
QScrollBar::sub-page:vertical,
QScrollBar::add-page:horizontal,
QScrollBar::sub-page:horizontal {
background: none;
}
\ No newline at end of file
qfluentwidgets/_rc/qss/light/color_dialog.qss
浏览文件 @
710e27a1
...
...
@@ -84,35 +84,6 @@ QSlider::handle:horizontal:disabled {
}
/* 滚动条 */
QScrollBar {
background: transparent;
width: 4px;
margin-top: 32px;
padding-right: 1px;
}
/*隐藏上箭头*/
QScrollBar::sub-line {
background: transparent;
}
/*隐藏下箭头*/
QScrollBar::add-line {
background: transparent;
}
QScrollBar::handle {
background: rgb(122, 122, 122);
border: 2px solid rgb(128, 128, 128);
border-radius: 1px;
min-height: 32px;
}
QScrollBar::add-page:vertical,
QScrollBar::sub-page:vertical {
background: none;
}
#cancelButton {
color: black;
...
...
qfluentwidgets/_rc/qss/light/folder_list_dialog.qss
浏览文件 @
710e27a1
...
...
@@ -47,32 +47,6 @@ QScrollArea{
border: none;
}
QScrollBar:vertical {
background: white;
border: none;
width: 3px;
}
QScrollBar::sub-line {
background: transparent;
}
QScrollBar::add-line {
background: transparent;
}
QScrollBar::handle {
background: rgb(128, 128, 128);
min-height: 32px;
border: 1px solid transparent;
border-radius: 1px;
}
QScrollBar::add-page:vertical,
QScrollBar::sub-page:vertical {
background: none;
}
#scrollWidget{
border: none;
...
...
qfluentwidgets/_rc/qss/light/line_edit.qss
浏览文件 @
710e27a1
...
...
@@ -52,49 +52,3 @@ PlainTextEdit:disabled {
#lineEditButton:pressed {
background-color: rgba(0, 0, 0, 6);
}
QScrollBar:vertical {
background: transparent;
width: 4px;
margin-top: 12px;
margin-bottom: 12px;
padding-right: 2px;
}
QScrollBar:horizontal {
background: transparent;
height: 4px;
margin-left: 12px;
margin-right: 12px;
padding-bottom: 2px;
}
QScrollBar::sub-line {
background: transparent;
}
QScrollBar::add-line {
background: transparent;
}
QScrollBar::handle {
background: rgb(122, 122, 122);
border: 2px solid rgb(128, 128, 128);
border-radius: 1px;
}
QScrollBar::handle:vertical {
min-height: 32px;
}
QScrollBar::handle:horizontal {
min-width: 32px;
}
QScrollBar::add-page:vertical,
QScrollBar::sub-page:vertical,
QScrollBar::add-page:horizontal,
QScrollBar::sub-page:horizontal {
background: none;
}
\ No newline at end of file
qfluentwidgets/_rc/qss/light/table_view.qss
浏览文件 @
710e27a1
...
...
@@ -120,47 +120,3 @@ QHeaderView::up-arrow {
margin-right: 6px;
image: url(:/qfluentwidgets/images/table_view/Up_black.svg);
}
QScrollBar:vertical {
background: transparent;
width: 4px;
margin-top: 50px;
margin-bottom: 0;
padding-right: 2px;
}
QScrollBar:horizontal {
background: transparent;
height: 4px;
padding-bottom: 2px;
}
QScrollBar::sub-line {
background: transparent;
}
QScrollBar::add-line {
background: transparent;
}
QScrollBar::handle {
background: rgb(122, 122, 122);
border: 2px solid rgb(128, 128, 128);
border-radius: 1px;
}
QScrollBar::handle:vertical {
min-height: 32px;
}
QScrollBar::handle:horizontal {
min-width: 32px;
}
QScrollBar::add-page:vertical,
QScrollBar::sub-page:vertical,
QScrollBar::add-page:horizontal,
QScrollBar::sub-page:horizontal {
background: none;
}
\ No newline at end of file
qfluentwidgets/_rc/qss/light/tree_view.qss
浏览文件 @
710e27a1
...
...
@@ -85,46 +85,3 @@ QTreeView::indicator:indeterminate:disabled {
border: 1px solid rgb(199, 199, 199);
background-color: rgb(199, 199, 199);
}
QScrollBar:vertical {
background: transparent;
width: 4px;
margin-top: 50px;
margin-bottom: 0;
padding-right: 2px;
}
QScrollBar:horizontal {
background: transparent;
height: 4px;
padding-bottom: 2px;
}
QScrollBar::sub-line {
background: transparent;
}
QScrollBar::add-line {
background: transparent;
}
QScrollBar::handle {
background: rgb(122, 122, 122);
border: 2px solid rgb(128, 128, 128);
border-radius: 1px;
}
QScrollBar::handle:vertical {
min-height: 32px;
}
QScrollBar::handle:horizontal {
min-width: 32px;
}
QScrollBar::add-page:vertical,
QScrollBar::sub-page:vertical,
QScrollBar::add-page:horizontal,
QScrollBar::sub-page:horizontal {
background: none;
}
\ No newline at end of file
qfluentwidgets/_rc/resource.py
浏览文件 @
710e27a1
此差异已折叠。
点击以展开。
qfluentwidgets/_rc/resource.qrc
浏览文件 @
710e27a1
...
...
@@ -165,6 +165,14 @@
<file>images/icons/DateTime_white.svg</file>
<file>images/icons/Basketball_black.svg</file>
<file>images/icons/Basketball_white.svg</file>
<file>images/icons/CareDownSolid_black.svg</file>
<file>images/icons/CareDownSolid_white.svg</file>
<file>images/icons/CareUpSolid_black.svg</file>
<file>images/icons/CareUpSolid_white.svg</file>
<file>images/icons/CareLeftSolid_black.svg</file>
<file>images/icons/CareLeftSolid_white.svg</file>
<file>images/icons/CareRightSolid_black.svg</file>
<file>images/icons/CareRightSolid_white.svg</file>
<file>images/acrylic/noise.png</file>
<file>images/folder_list_dialog/Close_white.png</file>
<file>images/folder_list_dialog/Close_black.png</file>
...
...
@@ -190,10 +198,6 @@
<file>images/tree_view/TreeViewOpen_black.svg</file>
<file>images/tree_view/TreeViewClose_white.svg</file>
<file>images/tree_view/TreeViewOpen_white.svg</file>
<file>images/time_picker/Up_white.svg</file>
<file>images/time_picker/Up_black.svg</file>
<file>images/time_picker/Down_white.svg</file>
<file>images/time_picker/Down_black.svg</file>
<file>images/table_view/Up_black.svg</file>
<file>images/table_view/Up_white.svg</file>
<file>images/table_view/Down_black.svg</file>
...
...
qfluentwidgets/common/icon.py
浏览文件 @
710e27a1
...
...
@@ -283,8 +283,12 @@ class FluentIcon(FluentIconBase, Enum):
ARROW_DOWN
=
"ChevronDown"
TRANSPARENT
=
"Transparent"
MUSIC_FOLDER
=
"MusicFolder"
CARE_UP_SOLID
=
"CareUpSolid"
CHEVRON_RIGHT
=
"ChevronRight"
CARE_DOWN_SOLID
=
"CareDownSolid"
CARE_LEFT_SOLID
=
"CareLeftSolid"
BACKGROUND_FILL
=
"BackgroundColor"
CARE_RIGHT_SOLID
=
"CareRightSolid"
def
path
(
self
,
theme
=
Theme
.
AUTO
):
return
f
':/qfluentwidgets/images/icons/
{
self
.
value
}
_
{
getIconColor
(
theme
)
}
.svg'
...
...
qfluentwidgets/components/dialog_box/color_dialog.py
浏览文件 @
710e27a1
...
...
@@ -5,7 +5,7 @@ from PyQt5.QtGui import (QBrush, QColor, QPixmap,
from
PyQt5.QtWidgets
import
QApplication
,
QLabel
,
QWidget
,
QPushButton
,
QFrame
,
QVBoxLayout
from
...common.style_sheet
import
FluentStyleSheet
,
isDarkTheme
from
..widgets
import
Slider
,
ScrollArea
,
PushButton
,
PrimaryPushButton
from
..widgets
import
Slider
,
S
ingleDirectionS
crollArea
,
PushButton
,
PrimaryPushButton
from
..widgets.line_edit
import
LineEdit
from
.mask_dialog_base
import
MaskDialogBase
...
...
@@ -242,7 +242,7 @@ class ColorDialog(MaskDialogBase):
self
.
oldColor
=
QColor
(
color
)
self
.
color
=
QColor
(
color
)
self
.
scrollArea
=
ScrollArea
(
self
.
widget
)
self
.
scrollArea
=
S
ingleDirectionS
crollArea
(
self
.
widget
)
self
.
scrollWidget
=
QWidget
(
self
.
scrollArea
)
self
.
buttonGroup
=
QFrame
(
self
.
widget
)
...
...
qfluentwidgets/components/dialog_box/folder_list_dialog.py
浏览文件 @
710e27a1
...
...
@@ -12,7 +12,7 @@ from ...common.icon import getIconColor
from
...common.style_sheet
import
FluentStyleSheet
from
.dialog
import
Dialog
from
.mask_dialog_base
import
MaskDialogBase
from
..widgets.scroll_area
import
ScrollArea
from
..widgets.scroll_area
import
S
ingleDirectionS
crollArea
class
FolderListDialog
(
MaskDialogBase
):
...
...
@@ -30,7 +30,7 @@ class FolderListDialog(MaskDialogBase):
self
.
vBoxLayout
=
QVBoxLayout
(
self
.
widget
)
self
.
titleLabel
=
QLabel
(
title
,
self
.
widget
)
self
.
contentLabel
=
QLabel
(
content
,
self
.
widget
)
self
.
scrollArea
=
ScrollArea
(
self
.
widget
)
self
.
scrollArea
=
S
ingleDirectionS
crollArea
(
self
.
widget
)
self
.
scrollWidget
=
QWidget
(
self
.
scrollArea
)
self
.
completeButton
=
QPushButton
(
self
.
tr
(
'Done'
),
self
.
widget
)
self
.
addFolderCard
=
AddFolderCard
(
self
.
scrollWidget
)
...
...
@@ -53,6 +53,7 @@ class FolderListDialog(MaskDialogBase):
self
.
scrollArea
.
setWidgetResizable
(
True
)
self
.
scrollArea
.
setWidget
(
self
.
scrollWidget
)
self
.
scrollArea
.
setHorizontalScrollBarPolicy
(
Qt
.
ScrollBarAlwaysOff
)
self
.
scrollArea
.
hScrollBar
.
setForceHidden
(
True
)
self
.
__initLayout
()
# connect signal to slot
...
...
qfluentwidgets/components/navigation/navigation_panel.py
浏览文件 @
710e27a1
...
...
@@ -7,7 +7,7 @@ from PyQt5.QtGui import QResizeEvent, QIcon
from
PyQt5.QtWidgets
import
QWidget
,
QVBoxLayout
,
QFrame
,
QApplication
from
.navigation_widget
import
NavigationPushButton
,
NavigationToolButton
,
NavigationWidget
,
NavigationSeparator
from
..widgets.scroll_area
import
ScrollArea
from
..widgets.scroll_area
import
S
ingleDirectionS
crollArea
from
...common.style_sheet
import
FluentStyleSheet
from
...common.icon
import
FluentIconBase
from
...common.icon
import
FluentIcon
as
FIF
...
...
@@ -39,7 +39,7 @@ class NavigationPanel(QFrame):
self
.
_isMenuButtonVisible
=
True
self
.
_isReturnButtonVisible
=
False
self
.
scrollArea
=
ScrollArea
(
self
)
self
.
scrollArea
=
S
ingleDirectionS
crollArea
(
self
)
self
.
scrollWidget
=
QWidget
()
self
.
menuButton
=
NavigationToolButton
(
FIF
.
MENU
,
self
)
...
...
qfluentwidgets/components/widgets/__init__.py
浏览文件 @
710e27a1
...
...
@@ -8,7 +8,7 @@ from .icon_widget import IconWidget
from
.label
import
PixmapLabel
from
.menu
import
DWMMenu
,
LineEditMenu
,
RoundMenu
from
.info_bar
import
InfoBar
,
InfoBarIcon
,
InfoBarPosition
from
.scroll_area
import
S
crollArea
,
SmoothMode
,
SmoothScrollArea
,
SmoothScrollBar
from
.scroll_area
import
S
ingleDirectionScrollArea
,
SmoothMode
,
SmoothScrollArea
,
ScrollArea
from
.slider
import
Slider
,
HollowHandleStyle
from
.spin_box
import
SpinBox
,
DoubleSpinBox
,
DateEdit
,
DateTimeEdit
,
TimeEdit
from
.stacked_widget
import
PopUpAniStackedWidget
,
OpacityAniStackedWidget
...
...
@@ -17,4 +17,5 @@ from .switch_button import SwitchButton, IndicatorPosition
from
.table_view
import
TableView
,
TableWidget
,
TableItemDelegate
from
.tool_tip
import
ToolTip
,
ToolTipFilter
from
.tree_view
import
TreeWidget
,
TreeView
from
.cycle_list_widget
import
CycleListWidget
\ No newline at end of file
from
.cycle_list_widget
import
CycleListWidget
from
.scroll_bar
import
ScrollBar
,
SmoothScrollBar
,
SmoothScrollDelegate
\ No newline at end of file
qfluentwidgets/components/widgets/cycle_list_widget.py
浏览文件 @
710e27a1
# coding:utf-8
from
enum
import
Enum
from
typing
import
Iterable
from
PyQt5.QtCore
import
Qt
,
pyqtSignal
,
QSize
,
QEvent
,
QRectF
,
QPoint
from
PyQt5.QtCore
import
Qt
,
pyqtSignal
,
QSize
,
QEvent
,
QRectF
from
PyQt5.QtGui
import
QPainter
from
PyQt5.QtWidgets
import
Q
Widget
,
QListWidget
,
QListWidgetItem
,
QToolButton
,
QStyledItemDelegate
from
PyQt5.QtWidgets
import
Q
ListWidget
,
QListWidgetItem
,
QToolButton
from
.scroll_area
import
SmoothScrollBar
from
...common.icon
import
FluentIconBase
,
Theme
,
getIconColor
from
...common.style_sheet
import
themeColor
,
isDarkTheme
class
ScrollIcon
(
FluentIconBase
,
Enum
):
""" Scroll icon """
UP
=
"Up"
DOWN
=
"Down"
def
path
(
self
,
theme
=
Theme
.
AUTO
):
return
f
':/qfluentwidgets/images/time_picker/
{
self
.
value
}
_
{
getIconColor
(
theme
)
}
.svg'
from
...common.icon
import
FluentIcon
,
isDarkTheme
class
ScrollButton
(
QToolButton
):
""" Scroll button """
def
__init__
(
self
,
icon
:
Scroll
Icon
,
parent
=
None
):
def
__init__
(
self
,
icon
:
Fluent
Icon
,
parent
=
None
):
super
().
__init__
(
parent
=
parent
)
self
.
_icon
=
icon
self
.
isPressed
=
False
...
...
@@ -53,7 +41,11 @@ class ScrollButton(QToolButton):
x
=
(
self
.
width
()
-
w
)
/
2
y
=
(
self
.
height
()
-
h
)
/
2
self
.
_icon
.
render
(
painter
,
QRectF
(
x
,
y
,
w
,
h
))
if
not
isDarkTheme
():
self
.
_icon
.
render
(
painter
,
QRectF
(
x
,
y
,
w
,
h
),
fill
=
"#5e5e5e"
)
else
:
self
.
_icon
.
render
(
painter
,
QRectF
(
x
,
y
,
w
,
h
))
class
CycleListWidget
(
QListWidget
):
...
...
@@ -81,20 +73,20 @@ class CycleListWidget(QListWidget):
self
.
itemSize
=
itemSize
self
.
align
=
align
self
.
upButton
=
ScrollButton
(
ScrollIcon
.
UP
,
self
)
self
.
downButton
=
ScrollButton
(
ScrollIcon
.
DOWN
,
self
)
self
.
upButton
=
ScrollButton
(
FluentIcon
.
CARE_UP_SOLID
,
self
)
self
.
downButton
=
ScrollButton
(
FluentIcon
.
CARE_DOWN_SOLID
,
self
)
self
.
scrollDuration
=
250
self
.
originItems
=
list
(
items
)
self
.
vScrollBar
=
SmoothScrollBar
(
self
)
self
.
vScrollBar
=
SmoothScrollBar
(
Qt
.
Vertical
,
self
)
self
.
visibleNumber
=
9
# repeat adding items to achieve circular scrolling
self
.
setItems
(
items
)
self
.
setVerticalScrollMode
(
self
.
ScrollPerPixel
)
self
.
setVerticalScrollBar
(
self
.
vScrollBar
)
self
.
vScrollBar
.
setScrollAnimation
(
self
.
scrollDuration
)
self
.
vScrollBar
.
setForceHidden
(
True
)
self
.
setViewportMargins
(
0
,
0
,
0
,
0
)
self
.
setFixedSize
(
itemSize
.
width
()
+
8
,
...
...
qfluentwidgets/components/widgets/line_edit.py
浏览文件 @
710e27a1
...
...
@@ -7,8 +7,8 @@ from PyQt5.QtWidgets import QHBoxLayout, QLineEdit, QToolButton, QTextEdit, QPla
from
...common.style_sheet
import
FluentStyleSheet
,
themeColor
from
...common.icon
import
isDarkTheme
,
FluentIconBase
,
drawIcon
from
...common.icon
import
FluentIcon
as
FIF
from
...common.smooth_scroll
import
SmoothMode
,
SmoothScroll
from
.menu
import
LineEditMenu
,
TextEditMenu
from
.scroll_bar
import
SmoothScrollDelegate
class
LineEditButton
(
QToolButton
):
...
...
@@ -153,36 +153,23 @@ class TextEdit(QTextEdit):
def
__init__
(
self
,
parent
=
None
):
super
().
__init__
(
parent
=
parent
)
self
.
verticalSmoothScroll
=
SmoothScroll
(
self
,
Qt
.
Vertical
)
self
.
horizonSmoothScroll
=
SmoothScroll
(
self
,
Qt
.
Horizontal
)
self
.
installEventFilter
(
SmoothScrollDelegate
(
self
))
FluentStyleSheet
.
LINE_EDIT
.
apply
(
self
)
def
contextMenuEvent
(
self
,
e
):
menu
=
TextEditMenu
(
self
)
menu
.
exec_
(
e
.
globalPos
())
def
wheelEvent
(
self
,
e
):
if
e
.
modifiers
()
==
Qt
.
NoModifier
:
self
.
verticalSmoothScroll
.
wheelEvent
(
e
)
else
:
self
.
horizonSmoothScroll
.
wheelEvent
(
e
)
class
PlainTextEdit
(
QPlainTextEdit
):
""" Plain text edit """
def
__init__
(
self
,
parent
=
None
):
super
().
__init__
(
parent
=
parent
)
self
.
verticalSmoothScroll
=
SmoothScroll
(
self
,
Qt
.
Vertical
)
self
.
horizonSmoothScroll
=
SmoothScroll
(
self
,
Qt
.
Horizontal
)
self
.
installEventFilter
(
SmoothScrollDelegate
(
self
))
FluentStyleSheet
.
LINE_EDIT
.
apply
(
self
)
def
contextMenuEvent
(
self
,
e
):
menu
=
TextEditMenu
(
self
)
menu
.
exec_
(
e
.
globalPos
())
def
wheelEvent
(
self
,
e
):
if
e
.
modifiers
()
==
Qt
.
NoModifier
:
self
.
verticalSmoothScroll
.
wheelEvent
(
e
)
else
:
self
.
horizonSmoothScroll
.
wheelEvent
(
e
)
qfluentwidgets/components/widgets/menu.py
浏览文件 @
710e27a1
...
...
@@ -131,6 +131,7 @@ class MenuActionListWidget(QListWidget):
def
wheelEvent
(
self
,
e
):
self
.
smoothScroll
.
wheelEvent
(
e
)
e
.
setAccepted
(
True
)
def
insertItem
(
self
,
row
,
item
):
""" inserts menu item at the position in the list given by row """
...
...
qfluentwidgets/components/widgets/scroll_area.py
浏览文件 @
710e27a1
# coding:utf-8
from
PyQt5.QtCore
import
QEasingCurve
,
Qt
,
pyqtSignal
,
QPropertyAnimation
,
QEvent
from
PyQt5.QtGui
import
QWheelEvent
,
QKeyEvent
from
PyQt5.QtWidgets
import
QScrollArea
,
QScrollBar
import
typing
from
PyQt5.QtCore
import
QEasingCurve
,
Qt
from
PyQt5.QtGui
import
QWheelEvent
from
PyQt5.QtWidgets
import
QScrollArea
,
QWidget
from
...common.smooth_scroll
import
SmoothScroll
,
SmoothMode
from
.scroll_bar
import
ScrollBar
,
SmoothScrollBar
,
SmoothScrollDelegate
class
ScrollArea
(
QScrollArea
):
""" A scroll area which can scroll smoothly """
""" Smooth scroll area """
def
__init__
(
self
,
parent
=
None
):
super
().
__init__
(
parent
)
self
.
scrollDelagate
=
SmoothScrollDelegate
(
self
)
class
SingleDirectionScrollArea
(
QScrollArea
):
""" Single direction scroll area"""
def
__init__
(
self
,
parent
=
None
,
orient
=
Qt
.
Vertical
):
"""
...
...
@@ -21,6 +31,16 @@ class ScrollArea(QScrollArea):
"""
super
().
__init__
(
parent
)
self
.
smoothScroll
=
SmoothScroll
(
self
,
orient
)
self
.
vScrollBar
=
SmoothScrollBar
(
Qt
.
Vertical
,
self
)
self
.
hScrollBar
=
SmoothScrollBar
(
Qt
.
Horizontal
,
self
)
def
setVerticalScrollBarPolicy
(
self
,
policy
):
super
().
setVerticalScrollBarPolicy
(
policy
)
self
.
vScrollBar
.
setForceHidden
(
policy
==
Qt
.
ScrollBarAlwaysOff
)
def
setHorizontalScrollBarPolicy
(
self
,
policy
):
super
().
setHorizontalScrollBarPolicy
(
policy
)
self
.
hScrollBar
.
setForceHidden
(
policy
==
Qt
.
ScrollBarAlwaysOff
)
def
setSmoothMode
(
self
,
mode
):
""" set smooth mode
...
...
@@ -37,97 +57,12 @@ class ScrollArea(QScrollArea):
e
.
setAccepted
(
True
)
class
SmoothScrollBar
(
QScrollBar
):
""" Smooth scroll bar """
def
__init__
(
self
,
parent
=
None
):
QScrollBar
.
__init__
(
self
,
parent
)
self
.
duration
=
500
self
.
ani
=
QPropertyAnimation
()
self
.
ani
.
setTargetObject
(
self
)
self
.
ani
.
setPropertyName
(
b
"value"
)
self
.
ani
.
setEasingCurve
(
QEasingCurve
.
OutCubic
)
self
.
ani
.
setDuration
(
self
.
duration
)
self
.
__value
=
self
.
value
()
def
setValue
(
self
,
value
):
if
value
==
self
.
value
():
return
# stop running animation
self
.
ani
.
stop
()
# adjust the duration
dv
=
abs
(
value
-
self
.
value
())
if
dv
<
50
:
self
.
ani
.
setDuration
(
int
(
self
.
duration
*
dv
/
70
))
else
:
self
.
ani
.
setDuration
(
self
.
duration
)
self
.
ani
.
setStartValue
(
self
.
value
())
self
.
ani
.
setEndValue
(
value
)
self
.
ani
.
start
()
def
scrollValue
(
self
,
value
):
""" scroll the specified distance """
self
.
__value
+=
value
self
.
__value
=
max
(
self
.
minimum
(),
self
.
__value
)
self
.
__value
=
min
(
self
.
maximum
(),
self
.
__value
)
self
.
setValue
(
self
.
__value
)
def
scrollTo
(
self
,
value
):
""" scroll to the specified position """
self
.
__value
=
value
self
.
__value
=
max
(
self
.
minimum
(),
self
.
__value
)
self
.
__value
=
min
(
self
.
maximum
(),
self
.
__value
)
self
.
setValue
(
self
.
__value
)
def
resetValue
(
self
,
value
):
self
.
__value
=
value
def
mousePressEvent
(
self
,
e
):
self
.
ani
.
stop
()
super
().
mousePressEvent
(
e
)
self
.
__value
=
self
.
value
()
def
mouseReleaseEvent
(
self
,
e
):
self
.
ani
.
stop
()
super
().
mouseReleaseEvent
(
e
)
self
.
__value
=
self
.
value
()
def
mouseMoveEvent
(
self
,
e
):
self
.
ani
.
stop
()
super
().
mouseMoveEvent
(
e
)
self
.
__value
=
self
.
value
()
def
setScrollAnimation
(
self
,
duration
,
easing
=
QEasingCurve
.
OutCubic
):
""" set scroll animation
Parameters
----------
duration: int
scroll duration
easing: QEasingCurve
animation type
"""
self
.
duration
=
duration
self
.
ani
.
setDuration
(
duration
)
self
.
ani
.
setEasingCurve
(
easing
)
class
SmoothScrollArea
(
QScrollArea
):
""" Smooth scroll area """
def
__init__
(
self
,
parent
=
None
):
super
().
__init__
(
parent
)
self
.
hScrollBar
=
SmoothScrollBar
()
self
.
vScrollBar
=
SmoothScrollBar
()
self
.
hScrollBar
.
setOrientation
(
Qt
.
Horizontal
)
self
.
vScrollBar
.
setOrientation
(
Qt
.
Vertical
)
self
.
setVerticalScrollBar
(
self
.
vScrollBar
)
self
.
setHorizontalScrollBar
(
self
.
hScrollBar
)
self
.
delegate
=
SmoothScrollDelegate
(
self
,
True
)
def
setScrollAnimation
(
self
,
orient
,
duration
,
easing
=
QEasingCurve
.
OutCubic
):
""" set scroll animation
...
...
@@ -143,13 +78,6 @@ class SmoothScrollArea(QScrollArea):
easing: QEasingCurve
animation type
"""
bar
=
self
.
hScrollBar
if
orient
==
Qt
.
Horizontal
else
self
.
vScrollBar
bar
=
self
.
delegate
.
hScrollBar
if
orient
==
Qt
.
Horizontal
else
self
.
delegate
.
vScrollBar
bar
.
setScrollAnimation
(
duration
,
easing
)
def
wheelEvent
(
self
,
e
):
if
e
.
modifiers
()
==
Qt
.
NoModifier
:
self
.
vScrollBar
.
scrollValue
(
-
e
.
angleDelta
().
y
())
else
:
self
.
hScrollBar
.
scrollValue
(
-
e
.
angleDelta
().
x
())
e
.
setAccepted
(
True
)
qfluentwidgets/components/widgets/scroll_bar.py
0 → 100644
浏览文件 @
710e27a1
# coding:utf-8
from
PyQt5.QtCore
import
(
QEvent
,
QEasingCurve
,
Qt
,
pyqtSignal
,
QPropertyAnimation
,
pyqtProperty
,
QRectF
,
QTimer
,
QPoint
,
QObject
)
from
PyQt5.QtGui
import
QPainter
,
QColor
,
QMouseEvent
from
PyQt5.QtWidgets
import
(
QWidget
,
QToolButton
,
QAbstractScrollArea
,
QGraphicsOpacityEffect
,
QHBoxLayout
,
QVBoxLayout
,
QApplication
)
from
...common.icon
import
FluentIcon
from
...common.style_sheet
import
isDarkTheme
from
...common.smooth_scroll
import
SmoothScroll
class
ArrowButton
(
QToolButton
):
""" Arrow button """
def
__init__
(
self
,
icon
:
FluentIcon
,
parent
=
None
):
super
().
__init__
(
parent
=
parent
)
self
.
setFixedSize
(
10
,
10
)
self
.
_icon
=
icon
def
paintEvent
(
self
,
e
):
painter
=
QPainter
(
self
)
painter
.
setRenderHints
(
QPainter
.
Antialiasing
)
s
=
7
if
self
.
isDown
()
else
8
x
=
(
self
.
width
()
-
s
)
/
2
self
.
_icon
.
render
(
painter
,
QRectF
(
x
,
x
,
s
,
s
),
fill
=
"#858789"
)
class
ScrollBarGroove
(
QWidget
):
""" Scroll bar groove """
def
__init__
(
self
,
orient
:
Qt
.
Orientation
,
parent
):
super
().
__init__
(
parent
=
parent
)
if
orient
==
Qt
.
Vertical
:
self
.
setFixedWidth
(
12
)
self
.
upButton
=
ArrowButton
(
FluentIcon
.
CARE_UP_SOLID
,
self
)
self
.
downButton
=
ArrowButton
(
FluentIcon
.
CARE_DOWN_SOLID
,
self
)
self
.
setLayout
(
QVBoxLayout
(
self
))
self
.
layout
().
addWidget
(
self
.
upButton
,
0
,
Qt
.
AlignHCenter
)
self
.
layout
().
addStretch
(
1
)
self
.
layout
().
addWidget
(
self
.
downButton
,
0
,
Qt
.
AlignHCenter
)
self
.
layout
().
setContentsMargins
(
0
,
3
,
0
,
3
)
else
:
self
.
setFixedHeight
(
12
)
self
.
upButton
=
ArrowButton
(
FluentIcon
.
CARE_LEFT_SOLID
,
self
)
self
.
downButton
=
ArrowButton
(
FluentIcon
.
CARE_RIGHT_SOLID
,
self
)
self
.
setLayout
(
QHBoxLayout
(
self
))
self
.
layout
().
addWidget
(
self
.
upButton
,
0
,
Qt
.
AlignVCenter
)
self
.
layout
().
addStretch
(
1
)
self
.
layout
().
addWidget
(
self
.
downButton
,
0
,
Qt
.
AlignVCenter
)
self
.
layout
().
setContentsMargins
(
3
,
0
,
3
,
0
)
self
.
opacityEffect
=
QGraphicsOpacityEffect
(
self
)
self
.
opacityAni
=
QPropertyAnimation
(
self
.
opacityEffect
,
b
'opacity'
,
self
)
self
.
setGraphicsEffect
(
self
.
opacityEffect
)
self
.
opacityEffect
.
setOpacity
(
0
)
def
fadeIn
(
self
):
self
.
opacityAni
.
setEndValue
(
1
)
self
.
opacityAni
.
setDuration
(
150
)
self
.
opacityAni
.
start
()
def
fadeOut
(
self
):
self
.
opacityAni
.
setEndValue
(
0
)
self
.
opacityAni
.
setDuration
(
150
)
self
.
opacityAni
.
start
()
def
paintEvent
(
self
,
e
):
painter
=
QPainter
(
self
)
painter
.
setRenderHints
(
QPainter
.
Antialiasing
)
painter
.
setPen
(
Qt
.
NoPen
)
if
not
isDarkTheme
():
painter
.
setBrush
(
QColor
(
252
,
252
,
252
,
217
))
else
:
painter
.
setBrush
(
QColor
(
44
,
44
,
44
,
245
))
painter
.
drawRoundedRect
(
self
.
rect
(),
6
,
6
)
class
ScrollBarHandle
(
QWidget
):
""" Scroll bar handle """
def
__init__
(
self
,
orient
:
Qt
.
Orientation
,
parent
=
None
):
super
().
__init__
(
parent
)
self
.
orient
=
orient
if
orient
==
Qt
.
Vertical
:
self
.
setFixedWidth
(
3
)
else
:
self
.
setFixedHeight
(
3
)
def
paintEvent
(
self
,
e
):
painter
=
QPainter
(
self
)
painter
.
setRenderHints
(
QPainter
.
Antialiasing
)
painter
.
setPen
(
Qt
.
NoPen
)
r
=
self
.
width
()
/
2
if
self
.
orient
==
Qt
.
Vertical
else
self
.
height
()
/
2
c
=
QColor
(
255
,
255
,
255
,
139
)
if
isDarkTheme
()
else
QColor
(
0
,
0
,
0
,
114
)
painter
.
setBrush
(
c
)
painter
.
drawRoundedRect
(
self
.
rect
(),
r
,
r
)
class
ScrollBar
(
QWidget
):
""" Fluent scroll bar """
rangeChanged
=
pyqtSignal
(
tuple
)
valueChanged
=
pyqtSignal
(
int
)
sliderPressed
=
pyqtSignal
()
sliderReleased
=
pyqtSignal
()
sliderMoved
=
pyqtSignal
()
def
__init__
(
self
,
orient
:
Qt
.
Orientation
,
parent
:
QAbstractScrollArea
):
super
().
__init__
(
parent
)
self
.
groove
=
ScrollBarGroove
(
orient
,
self
)
self
.
handle
=
ScrollBarHandle
(
orient
,
self
)
self
.
timer
=
QTimer
(
self
)
self
.
_orientation
=
orient
self
.
_singleStep
=
1
self
.
_pageStep
=
50
self
.
_padding
=
14
self
.
_minimum
=
0
self
.
_maximum
=
0
self
.
_value
=
0
self
.
_isPressed
=
False
self
.
_isEnter
=
False
self
.
_isExpanded
=
False
self
.
_pressedPos
=
QPoint
()
self
.
_isForceHidden
=
False
if
orient
==
Qt
.
Vertical
:
self
.
partnerBar
=
parent
.
verticalScrollBar
()
QAbstractScrollArea
.
setVerticalScrollBarPolicy
(
parent
,
Qt
.
ScrollBarAlwaysOff
)
else
:
self
.
partnerBar
=
parent
.
horizontalScrollBar
()
QAbstractScrollArea
.
setHorizontalScrollBarPolicy
(
parent
,
Qt
.
ScrollBarAlwaysOff
)
self
.
__initWidget
(
parent
)
def
__initWidget
(
self
,
parent
):
self
.
groove
.
upButton
.
clicked
.
connect
(
self
.
_onPageUp
)
self
.
groove
.
downButton
.
clicked
.
connect
(
self
.
_onPageDown
)
self
.
groove
.
opacityAni
.
valueChanged
.
connect
(
self
.
_onOpacityAniValueChanged
)
self
.
partnerBar
.
rangeChanged
.
connect
(
self
.
setRange
)
self
.
partnerBar
.
valueChanged
.
connect
(
self
.
_onValueChanged
)
self
.
valueChanged
.
connect
(
self
.
partnerBar
.
setValue
)
parent
.
installEventFilter
(
self
)
self
.
setRange
(
self
.
partnerBar
.
minimum
(),
self
.
partnerBar
.
maximum
())
self
.
setVisible
(
self
.
maximum
()
>
0
and
not
self
.
_isForceHidden
)
def
_onPageUp
(
self
):
self
.
setValue
(
self
.
value
()
-
self
.
pageStep
())
def
_onPageDown
(
self
):
self
.
setValue
(
self
.
value
()
+
self
.
pageStep
())
def
_onValueChanged
(
self
,
value
):
self
.
val
=
value
def
value
(
self
):
return
self
.
_value
@
pyqtProperty
(
int
,
notify
=
valueChanged
)
def
val
(
self
):
return
self
.
_value
@
val
.
setter
def
val
(
self
,
value
:
int
):
if
value
==
self
.
value
():
return
value
=
max
(
self
.
minimum
(),
min
(
value
,
self
.
maximum
()))
self
.
_value
=
value
self
.
valueChanged
.
emit
(
value
)
# adjust the position of handle
self
.
_adjustHandlePos
()
def
minimum
(
self
):
return
self
.
_minimum
def
maximum
(
self
):
return
self
.
_maximum
def
orientation
(
self
):
return
self
.
_orientation
def
pageStep
(
self
):
return
self
.
_pageStep
def
singleStep
(
self
):
return
self
.
_singleStep
def
isSliderDown
(
self
):
return
self
.
_isPressed
def
setValue
(
self
,
value
:
int
):
self
.
val
=
value
def
setMinimum
(
self
,
min
:
int
):
if
min
==
self
.
minimum
():
return
self
.
_minimum
=
min
self
.
rangeChanged
.
emit
((
min
,
self
.
maximum
()))
def
setMaximum
(
self
,
max
:
int
):
if
max
==
self
.
maximum
():
return
self
.
_maximum
=
max
self
.
rangeChanged
.
emit
((
self
.
minimum
(),
max
))
def
setRange
(
self
,
min
:
int
,
max
:
int
):
if
min
>
max
or
(
min
==
self
.
minimum
()
and
max
==
self
.
maximum
()):
return
self
.
setMinimum
(
min
)
self
.
setMaximum
(
max
)
self
.
_adjustHandleSize
()
self
.
_adjustHandlePos
()
self
.
setVisible
(
max
>
0
and
not
self
.
_isForceHidden
)
self
.
rangeChanged
.
emit
((
min
,
max
))
def
setPageStep
(
self
,
step
:
int
):
if
step
>=
1
:
self
.
_pageStep
=
step
def
setSingleStep
(
self
,
step
:
int
):
if
step
>=
1
:
self
.
_singleStep
=
step
def
setSliderDown
(
self
,
isDown
:
bool
):
self
.
_isPressed
=
True
if
isDown
:
self
.
sliderPressed
.
emit
()
else
:
self
.
sliderReleased
.
emit
()
def
expand
(
self
):
""" expand scroll bar """
if
self
.
_isExpanded
or
not
self
.
isEnter
:
return
self
.
_isExpanded
=
True
self
.
groove
.
fadeIn
()
def
collapse
(
self
):
""" collapse scroll bar """
if
not
self
.
_isExpanded
or
self
.
isEnter
:
return
self
.
_isExpanded
=
False
self
.
groove
.
fadeOut
()
def
enterEvent
(
self
,
e
):
self
.
isEnter
=
True
self
.
timer
.
stop
()
self
.
timer
.
singleShot
(
200
,
self
.
expand
)
def
leaveEvent
(
self
,
e
):
self
.
isEnter
=
False
self
.
timer
.
stop
()
self
.
timer
.
singleShot
(
200
,
self
.
collapse
)
def
eventFilter
(
self
,
obj
,
e
:
QEvent
):
if
obj
is
not
self
.
parent
():
return
super
().
eventFilter
(
obj
,
e
)
# adjust the position of slider
if
e
.
type
()
==
QEvent
.
Resize
:
self
.
_adjustPos
(
e
.
size
())
return
super
().
eventFilter
(
obj
,
e
)
def
resizeEvent
(
self
,
e
):
self
.
groove
.
resize
(
self
.
size
())
def
mousePressEvent
(
self
,
e
:
QMouseEvent
):
super
().
mousePressEvent
(
e
)
self
.
_isPressed
=
True
self
.
_pressedPos
=
e
.
pos
()
if
self
.
childAt
(
e
.
pos
())
is
self
.
handle
or
not
self
.
_isSlideResion
(
e
.
pos
()):
return
if
self
.
orientation
()
==
Qt
.
Vertical
:
if
e
.
pos
().
y
()
>
self
.
handle
.
geometry
().
bottom
():
value
=
e
.
pos
().
y
()
-
self
.
handle
.
height
()
-
self
.
_padding
else
:
value
=
e
.
pos
().
y
()
-
self
.
_padding
else
:
if
e
.
pos
().
x
()
>
self
.
handle
.
geometry
().
right
():
value
=
e
.
pos
().
x
()
-
self
.
handle
.
width
()
-
self
.
_padding
else
:
value
=
e
.
pos
().
x
()
-
self
.
_padding
self
.
setValue
(
int
(
value
/
self
.
_slideLength
()
*
self
.
maximum
()))
self
.
sliderPressed
.
emit
()
def
mouseReleaseEvent
(
self
,
e
):
super
().
mouseReleaseEvent
(
e
)
self
.
_isPressed
=
False
self
.
sliderReleased
.
emit
()
def
mouseMoveEvent
(
self
,
e
:
QMouseEvent
):
if
self
.
orientation
()
==
Qt
.
Vertical
:
dv
=
e
.
pos
().
y
()
-
self
.
_pressedPos
.
y
()
else
:
dv
=
e
.
pos
().
x
()
-
self
.
_pressedPos
.
x
()
# don't use `self.setValue()`, because it could be reimplemented
dv
=
dv
/
self
.
_slideLength
()
*
(
self
.
maximum
()
-
self
.
minimum
())
ScrollBar
.
setValue
(
self
,
self
.
value
()
+
dv
)
self
.
_pressedPos
=
e
.
pos
()
self
.
sliderMoved
.
emit
()
def
_adjustPos
(
self
,
size
):
if
self
.
orientation
()
==
Qt
.
Vertical
:
self
.
resize
(
12
,
size
.
height
()
-
2
)
self
.
move
(
size
.
width
()
-
13
,
1
)
else
:
self
.
resize
(
size
.
width
()
-
2
,
12
)
self
.
move
(
1
,
size
.
height
()
-
13
)
def
_adjustHandleSize
(
self
):
total
=
self
.
maximum
()
-
self
.
minimum
()
+
self
.
parent
().
height
()
if
total
!=
0
:
s
=
self
.
_grooveLength
()
*
self
.
parent
().
height
()
/
total
else
:
s
=
1
if
self
.
orientation
()
==
Qt
.
Vertical
:
self
.
handle
.
setFixedHeight
(
max
(
40
,
s
))
else
:
self
.
handle
.
setFixedWidth
(
max
(
40
,
s
))
def
_adjustHandlePos
(
self
):
total
=
max
(
self
.
maximum
()
-
self
.
minimum
(),
1
)
delta
=
self
.
value
()
/
total
*
self
.
_slideLength
()
if
self
.
orientation
()
==
Qt
.
Vertical
:
x
=
self
.
width
()
-
self
.
handle
.
width
()
-
3
self
.
handle
.
move
(
x
,
self
.
_padding
+
delta
)
else
:
y
=
self
.
height
()
-
self
.
handle
.
height
()
-
3
self
.
handle
.
move
(
self
.
_padding
+
delta
,
y
)
def
_grooveLength
(
self
):
if
self
.
orientation
()
==
Qt
.
Vertical
:
return
self
.
height
()
-
2
*
self
.
_padding
return
self
.
width
()
-
2
*
self
.
_padding
def
_slideLength
(
self
):
if
self
.
orientation
()
==
Qt
.
Vertical
:
return
self
.
_grooveLength
()
-
self
.
handle
.
height
()
return
self
.
_grooveLength
()
-
self
.
handle
.
width
()
def
_isSlideResion
(
self
,
pos
:
QPoint
):
if
self
.
orientation
()
==
Qt
.
Vertical
:
return
self
.
_padding
<=
pos
.
y
()
<=
self
.
height
()
-
self
.
_padding
return
self
.
_padding
<=
pos
.
x
()
<=
self
.
width
()
-
self
.
_padding
def
_onOpacityAniValueChanged
(
self
):
opacity
=
self
.
groove
.
opacityEffect
.
opacity
()
if
self
.
orientation
()
==
Qt
.
Vertical
:
self
.
handle
.
setFixedWidth
(
int
(
3
+
opacity
*
3
))
else
:
self
.
handle
.
setFixedHeight
(
int
(
3
+
opacity
*
3
))
self
.
_adjustHandlePos
()
def
setForceHidden
(
self
,
isHidden
:
bool
):
""" whether to force the scrollbar to be hidden """
self
.
_isForceHidden
=
isHidden
self
.
setVisible
(
self
.
maximum
()
>
0
and
not
isHidden
)
def
wheelEvent
(
self
,
e
):
QApplication
.
sendEvent
(
self
.
parent
().
viewport
(),
e
)
class
SmoothScrollBar
(
ScrollBar
):
""" Smooth scroll bar """
def
__init__
(
self
,
orient
:
Qt
.
Orientation
,
parent
):
super
().
__init__
(
orient
,
parent
)
self
.
duration
=
500
self
.
ani
=
QPropertyAnimation
()
self
.
ani
.
setTargetObject
(
self
)
self
.
ani
.
setPropertyName
(
b
"val"
)
self
.
ani
.
setEasingCurve
(
QEasingCurve
.
OutCubic
)
self
.
ani
.
setDuration
(
self
.
duration
)
self
.
__value
=
self
.
value
()
def
setValue
(
self
,
value
):
if
value
==
self
.
value
():
return
# stop running animation
self
.
ani
.
stop
()
# adjust the duration
dv
=
abs
(
value
-
self
.
value
())
if
dv
<
50
:
self
.
ani
.
setDuration
(
int
(
self
.
duration
*
dv
/
70
))
else
:
self
.
ani
.
setDuration
(
self
.
duration
)
self
.
ani
.
setStartValue
(
self
.
value
())
self
.
ani
.
setEndValue
(
value
)
self
.
ani
.
start
()
def
scrollValue
(
self
,
value
):
""" scroll the specified distance """
self
.
__value
+=
value
self
.
__value
=
max
(
self
.
minimum
(),
self
.
__value
)
self
.
__value
=
min
(
self
.
maximum
(),
self
.
__value
)
self
.
setValue
(
self
.
__value
)
def
scrollTo
(
self
,
value
):
""" scroll to the specified position """
self
.
__value
=
value
self
.
__value
=
max
(
self
.
minimum
(),
self
.
__value
)
self
.
__value
=
min
(
self
.
maximum
(),
self
.
__value
)
self
.
setValue
(
self
.
__value
)
def
resetValue
(
self
,
value
):
self
.
__value
=
value
def
mousePressEvent
(
self
,
e
):
self
.
ani
.
stop
()
super
().
mousePressEvent
(
e
)
self
.
__value
=
self
.
value
()
def
mouseMoveEvent
(
self
,
e
):
self
.
ani
.
stop
()
super
().
mouseMoveEvent
(
e
)
self
.
__value
=
self
.
value
()
def
setScrollAnimation
(
self
,
duration
,
easing
=
QEasingCurve
.
OutCubic
):
""" set scroll animation
Parameters
----------
duration: int
scroll duration
easing: QEasingCurve
animation type
"""
self
.
duration
=
duration
self
.
ani
.
setDuration
(
duration
)
self
.
ani
.
setEasingCurve
(
easing
)
class
SmoothScrollDelegate
(
QObject
):
""" Smooth scroll delegate """
def
__init__
(
self
,
parent
:
QAbstractScrollArea
,
useAni
=
False
):
"""
Parameters
----------
parent: QAbstractScrollArea
the scrolling area being delegated
useAni: bool
whether to use `QPropertyAnimation` to achieve smooth scrolling
"""
super
().
__init__
(
parent
)
self
.
useAni
=
useAni
self
.
vScrollBar
=
SmoothScrollBar
(
Qt
.
Vertical
,
parent
)
self
.
hScrollBar
=
SmoothScrollBar
(
Qt
.
Horizontal
,
parent
)
self
.
verticalSmoothScroll
=
SmoothScroll
(
parent
,
Qt
.
Vertical
)
self
.
horizonSmoothScroll
=
SmoothScroll
(
parent
,
Qt
.
Horizontal
)
parent
.
viewport
().
installEventFilter
(
self
)
parent
.
setVerticalScrollBarPolicy
=
self
.
setVerticalScrollBarPolicy
parent
.
setHorizontalScrollBarPolicy
=
self
.
setHorizontalScrollBarPolicy
def
eventFilter
(
self
,
obj
,
e
:
QEvent
):
if
e
.
type
()
==
QEvent
.
Wheel
:
if
e
.
angleDelta
().
y
()
!=
0
:
if
not
self
.
useAni
:
self
.
verticalSmoothScroll
.
wheelEvent
(
e
)
else
:
self
.
vScrollBar
.
scrollValue
(
-
e
.
angleDelta
().
y
())
else
:
if
not
self
.
useAni
:
self
.
horizonSmoothScroll
.
wheelEvent
(
e
)
else
:
self
.
hScrollBar
.
scrollValue
(
-
e
.
angleDelta
().
x
())
e
.
setAccepted
(
True
)
return
True
return
super
().
eventFilter
(
obj
,
e
)
def
setVerticalScrollBarPolicy
(
self
,
policy
):
QAbstractScrollArea
.
setVerticalScrollBarPolicy
(
self
.
parent
(),
policy
)
self
.
vScrollBar
.
setForceHidden
(
policy
==
Qt
.
ScrollBarAlwaysOff
)
def
setHorizontalScrollBarPolicy
(
self
,
policy
):
QAbstractScrollArea
.
setHorizontalScrollBarPolicy
(
self
.
parent
(),
policy
)
self
.
hScrollBar
.
setForceHidden
(
policy
==
Qt
.
ScrollBarAlwaysOff
)
qfluentwidgets/components/widgets/table_view.py
浏览文件 @
710e27a1
...
...
@@ -6,9 +6,9 @@ from PyQt5.QtGui import QPainter, QColor, QKeyEvent
from
PyQt5.QtWidgets
import
(
QStyledItemDelegate
,
QApplication
,
QStyleOptionViewItem
,
QTableView
,
QTableWidget
,
QWidget
)
from
...common.smooth_scroll
import
SmoothScroll
from
...common.style_sheet
import
isDarkTheme
,
FluentStyleSheet
,
themeColor
from
.line_edit
import
LineEdit
from
.scroll_bar
import
SmoothScrollDelegate
class
TableItemDelegate
(
QStyledItemDelegate
):
...
...
@@ -126,8 +126,7 @@ class TableBase:
def
__init__
(
self
,
*
args
,
**
kwargs
):
self
.
delegate
=
TableItemDelegate
(
self
)
self
.
verticalSmoothScroll
=
SmoothScroll
(
self
,
Qt
.
Vertical
)
self
.
horizonSmoothScroll
=
SmoothScroll
(
self
,
Qt
.
Horizontal
)
self
.
scrollDelagate
=
SmoothScrollDelegate
(
self
)
# set style sheet
FluentStyleSheet
.
TABLE_VIEW
.
apply
(
self
)
...
...
@@ -170,14 +169,6 @@ class TableBase:
QTableView
.
resizeEvent
(
self
,
e
)
self
.
viewport
().
update
()
def
wheelEvent
(
self
,
e
):
if
e
.
angleDelta
().
y
()
!=
0
:
self
.
verticalSmoothScroll
.
wheelEvent
(
e
)
else
:
self
.
horizonSmoothScroll
.
wheelEvent
(
e
)
e
.
setAccepted
(
True
)
def
keyPressEvent
(
self
,
e
:
QKeyEvent
):
QTableView
.
keyPressEvent
(
self
,
e
)
self
.
setSelectedRows
(
self
.
selectedIndexes
())
...
...
@@ -190,7 +181,7 @@ class TableBase:
def
mouseReleaseEvent
(
self
,
e
):
QTableView
.
mouseReleaseEvent
(
self
,
e
)
row
=
self
.
indexAt
(
e
.
pos
()).
row
()
if
row
>=
0
and
e
.
button
()
!=
Qt
.
RightButton
:
self
.
setSelectedRows
(
self
.
selectedIndexes
())
...
...
qfluentwidgets/components/widgets/three_state_button.py
已删除
100644 → 0
浏览文件 @
2283b5e3
# coding:utf-8
from
enum
import
Enum
from
PyQt5.QtCore
import
QEvent
,
QSize
,
Qt
from
PyQt5.QtGui
import
QIcon
from
PyQt5.QtWidgets
import
QToolButton
class
ButtonState
(
Enum
):
""" Button state """
NORMAL
=
0
HOVER
=
1
PRESSED
=
2
class
ThreeStateButton
(
QToolButton
):
""" Three state tool button class """
def
__init__
(
self
,
iconPaths
,
parent
=
None
,
buttonSize
=
(
40
,
40
),
iconSize
=
None
):
"""
Parameters
----------
iconPaths: Dict[ButtonState, str]
icon path dict
parent:
parent window
button: tuple
button size
iconSize: tuple
icon size
"""
super
().
__init__
(
parent
)
self
.
iconPaths
=
iconPaths
self
.
resize
(
*
buttonSize
)
self
.
setIconSize
(
self
.
size
()
if
not
iconSize
else
QSize
(
*
iconSize
))
self
.
setCursor
(
Qt
.
ArrowCursor
)
self
.
setStyleSheet
(
'border: none; margin: 0px; background: transparent'
)
self
.
setState
(
ButtonState
.
NORMAL
)
self
.
installEventFilter
(
self
)
def
eventFilter
(
self
,
obj
,
e
):
if
obj
is
self
:
if
e
.
type
()
==
QEvent
.
Enter
:
self
.
setState
(
ButtonState
.
HOVER
)
if
e
.
type
()
in
[
QEvent
.
Leave
,
QEvent
.
MouseButtonRelease
]:
self
.
setState
(
ButtonState
.
NORMAL
)
if
e
.
type
()
==
QEvent
.
MouseButtonPress
:
self
.
setState
(
ButtonState
.
PRESSED
)
return
super
().
eventFilter
(
obj
,
e
)
def
setState
(
self
,
state
):
""" set the state of button """
self
.
setIcon
(
QIcon
(
self
.
iconPaths
[
state
]))
\ No newline at end of file
qfluentwidgets/components/widgets/tree_view.py
浏览文件 @
710e27a1
# coding:utf-8
import
typing
from
PyQt5
import
QtCore
from
PyQt5.QtCore
import
Qt
,
QSize
from
PyQt5.QtGui
import
QPainter
,
QColor
from
PyQt5.QtWidgets
import
QWidget
,
QTreeWidget
,
QStyledItemDelegate
,
QStyle
,
QTreeView
from
...common.style_sheet
import
FluentStyleSheet
,
themeColor
,
isDarkTheme
from
.
..common.smooth_scroll
import
SmoothScroll
from
.
scroll_area
import
SmoothScrollDelegate
class
TreeItemDelegate
(
QStyledItemDelegate
):
...
...
@@ -45,9 +44,8 @@ class TreeViewBase:
""" Tree view base class """
def
__init__
(
self
,
*
args
,
**
kwargs
):
self
.
verticalSmoothScroll
=
SmoothScroll
(
self
,
Qt
.
Vertical
)
self
.
horizonSmoothScroll
=
SmoothScroll
(
self
,
Qt
.
Horizontal
)
self
.
scrollDelagate
=
SmoothScrollDelegate
(
self
)
self
.
setHorizontalScrollMode
(
QTreeView
.
ScrollPerPixel
)
self
.
setVerticalScrollMode
(
QTreeView
.
ScrollPerPixel
)
self
.
setItemDelegate
(
TreeItemDelegate
(
self
))
...
...
@@ -61,14 +59,6 @@ class TreeViewBase:
rect
.
moveLeft
(
15
)
return
QTreeView
.
drawBranches
(
self
,
painter
,
rect
,
index
)
def
wheelEvent
(
self
,
e
):
if
e
.
angleDelta
().
y
()
!=
0
:
self
.
verticalSmoothScroll
.
wheelEvent
(
e
)
else
:
self
.
horizonSmoothScroll
.
wheelEvent
(
e
)
e
.
setAccepted
(
True
)
class
TreeWidget
(
QTreeWidget
,
TreeViewBase
):
""" Tree widget """
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录