Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
k54kdk
PyQt Fluent Widgets
提交
6e031d35
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
6e031d35
编写于
8月 16, 2023
作者:
之一Yo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
添加 `FlipView` 设置圆角的功能
上级
bcbf3051
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
33 addition
and
8 deletion
+33
-8
examples/flip_view/demo.py
examples/flip_view/demo.py
+5
-0
qfluentwidgets/components/widgets/button.py
qfluentwidgets/components/widgets/button.py
+5
-1
qfluentwidgets/components/widgets/flip_view.py
qfluentwidgets/components/widgets/flip_view.py
+23
-7
未找到文件。
examples/flip_view/demo.py
浏览文件 @
6e031d35
...
...
@@ -54,6 +54,11 @@ class Demo(QWidget):
self
.
flipView
.
addImages
([
str
(
i
)
for
i
in
Path
(
'./resource'
).
glob
(
'*'
)])
self
.
pager
.
setPageNumber
(
self
.
flipView
.
count
())
# adjust border radius
# self.flipView.setBorderRadius(15)
# self.flipView.setFixedSize(QSize(710, 270))
# self.flipView.setSpacing(15)
self
.
pager
.
currentIndexChanged
.
connect
(
self
.
flipView
.
setCurrentIndex
)
self
.
flipView
.
currentIndexChanged
.
connect
(
self
.
pager
.
setCurrentIndex
)
...
...
qfluentwidgets/components/widgets/button.py
浏览文件 @
6e031d35
...
...
@@ -148,7 +148,7 @@ class HyperlinkButton(PushButton):
FluentStyleSheet
.
BUTTON
.
apply
(
self
)
self
.
setCursor
(
Qt
.
PointingHandCursor
)
setFont
(
self
)
self
.
clicked
.
connect
(
lambda
i
:
QDesktopServices
.
openUrl
(
self
.
getUrl
())
)
self
.
clicked
.
connect
(
self
.
_onClicked
)
@
__init__
.
register
def
_
(
self
,
url
:
str
,
text
:
str
,
parent
:
QWidget
=
None
,
icon
:
Union
[
QIcon
,
FluentIconBase
,
str
]
=
None
):
...
...
@@ -163,6 +163,10 @@ class HyperlinkButton(PushButton):
def
setUrl
(
self
,
url
:
Union
[
str
,
QUrl
]):
self
.
_url
=
QUrl
(
url
)
def
_onClicked
(
self
):
if
self
.
getUrl
().
isValid
():
QDesktopServices
.
openUrl
(
self
.
getUrl
())
def
_drawIcon
(
self
,
icon
,
painter
,
rect
,
state
=
QIcon
.
Off
):
if
isinstance
(
icon
,
FluentIconBase
)
and
self
.
isEnabled
():
icon
=
icon
.
icon
(
color
=
themeColor
())
...
...
qfluentwidgets/components/widgets/flip_view.py
浏览文件 @
6e031d35
...
...
@@ -2,8 +2,8 @@
from
typing
import
List
,
Union
from
PyQt5.QtCore
import
Qt
,
pyqtSignal
,
QModelIndex
,
QSize
,
pyqtProperty
,
QRectF
,
QPropertyAnimation
from
PyQt5.QtGui
import
QPixmap
,
QPainter
,
QColor
,
QImage
,
QWheelEvent
from
PyQt5.QtWidgets
import
QStyleOptionViewItem
,
Q
Widget
,
Q
ListWidget
,
QStyledItemDelegate
,
QListWidgetItem
from
PyQt5.QtGui
import
QPixmap
,
QPainter
,
QColor
,
QImage
,
QWheelEvent
,
QPainterPath
from
PyQt5.QtWidgets
import
QStyleOptionViewItem
,
QListWidget
,
QStyledItemDelegate
,
QListWidgetItem
from
...common.overload
import
singledispatchmethod
from
...common.style_sheet
import
isDarkTheme
,
FluentStyleSheet
...
...
@@ -77,10 +77,15 @@ class FlipImageDelegate(QStyledItemDelegate):
def
__init__
(
self
,
parent
=
None
):
super
().
__init__
(
parent
)
self
.
borderRadius
=
0
def
itemSize
(
self
):
return
self
.
parent
().
itemSize
def
setBorderRadius
(
self
,
radius
:
int
):
self
.
borderRadius
=
radius
self
.
parent
().
viewport
().
update
()
def
paint
(
self
,
painter
:
QPainter
,
option
:
QStyleOptionViewItem
,
index
:
QModelIndex
):
painter
.
save
()
painter
.
setRenderHints
(
QPainter
.
Antialiasing
)
...
...
@@ -94,12 +99,17 @@ class FlipImageDelegate(QStyledItemDelegate):
if
image
is
None
:
return
painter
.
restore
()
image
=
image
.
scaled
(
size
*
r
,
Qt
.
KeepAspectRatio
,
Qt
.
SmoothTransformation
)
x
=
option
.
rect
.
x
()
+
int
((
option
.
rect
.
width
()
-
size
.
width
())
/
2
)
y
=
option
.
rect
.
y
()
+
int
((
option
.
rect
.
height
()
-
size
.
height
())
/
2
)
painter
.
drawImage
(
QRectF
(
x
,
y
,
size
.
width
(),
size
.
height
()),
image
)
rect
=
QRectF
(
x
,
y
,
size
.
width
(),
size
.
height
())
# clipped path
path
=
QPainterPath
()
path
.
addRoundedRect
(
rect
,
self
.
borderRadius
,
self
.
borderRadius
)
image
=
image
.
scaled
(
size
*
r
,
Qt
.
KeepAspectRatio
,
Qt
.
SmoothTransformation
)
painter
.
setClipPath
(
path
)
painter
.
drawImage
(
rect
,
image
)
painter
.
restore
()
...
...
@@ -132,7 +142,6 @@ class FlipView(QListWidget):
self
.
scrollBar
.
setForceHidden
(
True
)
self
.
setUniformItemSizes
(
True
)
self
.
setGridSize
(
self
.
itemSize
)
self
.
setFixedSize
(
self
.
itemSize
)
self
.
setItemDelegate
(
self
.
delegate
)
self
.
setMovement
(
QListWidget
.
Static
)
...
...
@@ -167,7 +176,6 @@ class FlipView(QListWidget):
return
self
.
_itemSize
=
size
self
.
setGridSize
(
size
)
for
i
in
range
(
self
.
count
()):
item
=
self
.
item
(
i
)
...
...
@@ -179,6 +187,13 @@ class FlipView(QListWidget):
""" get the size of item """
return
self
.
_itemSize
def
setBorderRadius
(
self
,
radius
:
int
):
""" set the border radius of item """
self
.
delegate
.
setBorderRadius
(
radius
)
def
getBorderRadius
(
self
):
return
self
.
delegate
.
borderRadius
def
scrollPrevious
(
self
):
""" scroll to previous item """
self
.
setCurrentIndex
(
self
.
currentIndex
()
-
1
)
...
...
@@ -315,6 +330,7 @@ class FlipView(QListWidget):
self
.
scrollPrevious
()
itemSize
=
pyqtProperty
(
QSize
,
getItemSize
,
setItemSize
)
borderRadius
=
pyqtProperty
(
int
,
getBorderRadius
,
setBorderRadius
)
class
HorizontalFlipView
(
FlipView
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录