Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
k54kdk
PyQt Fluent Widgets
提交
5362613c
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看板
提交
5362613c
编写于
5月 08, 2023
作者:
之一Yo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
修复列表和表格组件的选中问题
上级
0cc60069
变更
7
展开全部
隐藏空白更改
内联
并排
Showing
7 changed file
with
53874 addition
and
53793 deletion
+53874
-53793
qfluentwidgets/__init__.py
qfluentwidgets/__init__.py
+1
-1
qfluentwidgets/_rc/qss/dark/table_view.qss
qfluentwidgets/_rc/qss/dark/table_view.qss
+9
-0
qfluentwidgets/_rc/qss/light/table_view.qss
qfluentwidgets/_rc/qss/light/table_view.qss
+8
-0
qfluentwidgets/_rc/resource.py
qfluentwidgets/_rc/resource.py
+53769
-53765
qfluentwidgets/components/widgets/list_view.py
qfluentwidgets/components/widgets/list_view.py
+39
-13
qfluentwidgets/components/widgets/table_view.py
qfluentwidgets/components/widgets/table_view.py
+47
-13
setup.py
setup.py
+1
-1
未找到文件。
qfluentwidgets/__init__.py
浏览文件 @
5362613c
...
...
@@ -12,7 +12,7 @@ Examples are available at https://github.com/zhiyiYo/PyQt-Fluent-Widgets/tree/ma
:license: GPLv3, see LICENSE for more details.
"""
__version__
=
"0.8.
6
"
__version__
=
"0.8.
7
"
from
.components
import
*
from
.common
import
*
...
...
qfluentwidgets/_rc/qss/dark/table_view.qss
浏览文件 @
5362613c
...
...
@@ -115,3 +115,12 @@ QHeaderView::up-arrow {
margin-right: 6px;
image: url(:/qfluentwidgets/images/table_view/Up_white.svg);
}
QTableCornerButton::section {
background-color: transparent;
border: 1px solid rgba(0, 0, 0, 57);
}
QTableCornerButton::section:pressed {
background-color: rgba(255, 255, 255, 16);
}
\ No newline at end of file
qfluentwidgets/_rc/qss/light/table_view.qss
浏览文件 @
5362613c
...
...
@@ -116,3 +116,11 @@ QHeaderView::up-arrow {
margin-right: 6px;
image: url(:/qfluentwidgets/images/table_view/Up_black.svg);
}
QTableCornerButton::section {
background-color: transparent;
border: 1px solid rgba(0, 0, 0, 19);
}
QTableCornerButton::section:pressed {
background-color: rgba(0, 0, 0, 12);
}
\ No newline at end of file
qfluentwidgets/_rc/resource.py
浏览文件 @
5362613c
此差异已折叠。
点击以展开。
qfluentwidgets/components/widgets/list_view.py
浏览文件 @
5362613c
# coding:utf-8
from
typing
import
List
from
typing
import
List
,
Union
from
PyQt5.QtCore
import
Qt
,
pyqtSignal
,
QModelIndex
from
PyQt5.QtCore
import
Qt
,
pyqtSignal
,
QModelIndex
,
QItemSelectionModel
from
PyQt5.QtGui
import
QPainter
from
PyQt5.QtWidgets
import
QStyleOptionViewItem
,
QListView
,
Q
Widget
,
QListView
,
QListWidget
from
PyQt5.QtWidgets
import
QStyleOptionViewItem
,
QListView
,
Q
ListWidgetItem
,
QListView
,
QListWidget
from
.scroll_bar
import
SmoothScrollDelegate
from
.table_view
import
TableItemDelegate
...
...
@@ -37,26 +37,26 @@ class ListBase:
self
.
setItemDelegate
(
self
.
delegate
)
self
.
setMouseTracking
(
True
)
self
.
entered
.
connect
(
lambda
i
:
self
.
setHoverRow
(
i
.
row
()))
self
.
pressed
.
connect
(
lambda
i
:
self
.
setPressedRow
(
i
.
row
()))
self
.
entered
.
connect
(
lambda
i
:
self
.
_
setHoverRow
(
i
.
row
()))
self
.
pressed
.
connect
(
lambda
i
:
self
.
_
setPressedRow
(
i
.
row
()))
def
setHoverRow
(
self
,
row
:
int
):
def
_
setHoverRow
(
self
,
row
:
int
):
""" set hovered row """
self
.
delegate
.
setHoverRow
(
row
)
self
.
viewport
().
update
()
def
setPressedRow
(
self
,
row
:
int
):
def
_
setPressedRow
(
self
,
row
:
int
):
""" set pressed row """
self
.
delegate
.
setPressedRow
(
row
)
self
.
viewport
().
update
()
def
setSelectedRows
(
self
,
indexes
:
List
[
QModelIndex
]):
def
_
setSelectedRows
(
self
,
indexes
:
List
[
QModelIndex
]):
self
.
delegate
.
setSelectedRows
(
indexes
)
self
.
viewport
().
update
()
def
leaveEvent
(
self
,
e
):
QListView
.
leaveEvent
(
self
,
e
)
self
.
setHoverRow
(
-
1
)
self
.
_
setHoverRow
(
-
1
)
def
resizeEvent
(
self
,
e
):
QListView
.
resizeEvent
(
self
,
e
)
...
...
@@ -64,27 +64,42 @@ class ListBase:
def
keyPressEvent
(
self
,
e
):
QListView
.
keyPressEvent
(
self
,
e
)
self
.
setSelectedRows
(
self
.
selectedIndexes
()
)
self
.
_updateSelectedRows
(
)
def
mousePressEvent
(
self
,
e
):
if
e
.
button
()
==
Qt
.
LeftButton
:
QListView
.
mousePressEvent
(
self
,
e
)
else
:
self
.
setPressedRow
(
self
.
indexAt
(
e
.
pos
()).
row
())
self
.
_
setPressedRow
(
self
.
indexAt
(
e
.
pos
()).
row
())
def
mouseReleaseEvent
(
self
,
e
):
QListView
.
mouseReleaseEvent
(
self
,
e
)
row
=
self
.
indexAt
(
e
.
pos
()).
row
()
if
row
>=
0
and
e
.
button
()
!=
Qt
.
RightButton
:
self
.
setSelectedRows
(
self
.
selectedIndexes
()
)
self
.
_updateSelectedRows
(
)
else
:
self
.
setPressedRow
(
-
1
)
self
.
_
setPressedRow
(
-
1
)
def
setItemDelegate
(
self
,
delegate
:
ListItemDelegate
):
self
.
delegate
=
delegate
super
().
setItemDelegate
(
delegate
)
def
setSelection
(
self
,
rect
,
command
):
QListView
.
setSelection
(
self
,
rect
,
command
)
self
.
_updateSelectedRows
()
def
clearSelection
(
self
):
QListView
.
clearSelection
(
self
)
self
.
_updateSelectedRows
()
def
setCurrentIndex
(
self
,
index
:
QModelIndex
):
QListView
.
setCurrentIndex
(
self
,
index
)
self
.
_updateSelectedRows
()
def
_updateSelectedRows
(
self
):
self
.
_setSelectedRows
(
self
.
selectedIndexes
())
class
ListWidget
(
ListBase
,
QListWidget
):
""" List widget """
...
...
@@ -92,6 +107,17 @@ class ListWidget(ListBase, QListWidget):
def
__init__
(
self
,
parent
=
None
):
super
().
__init__
(
parent
)
def
setCurrentItem
(
self
,
item
:
QListWidgetItem
,
command
:
Union
[
QItemSelectionModel
.
SelectionFlag
,
QItemSelectionModel
.
SelectionFlags
]
=
None
):
self
.
setCurrentRow
(
self
.
row
(
item
),
command
)
def
setCurrentRow
(
self
,
row
:
int
,
command
:
Union
[
QItemSelectionModel
.
SelectionFlag
,
QItemSelectionModel
.
SelectionFlags
]
=
None
):
if
not
command
:
super
().
setCurrentRow
(
row
)
else
:
super
().
setCurrentRow
(
row
,
command
)
self
.
_updateSelectedRows
()
class
ListView
(
ListBase
,
QListView
):
""" List view """
...
...
qfluentwidgets/components/widgets/table_view.py
浏览文件 @
5362613c
# coding: utf-8
from
typing
import
List
from
typing
import
List
,
Union
from
PyQt5.QtCore
import
Qt
,
QMargins
,
QModelIndex
from
PyQt5.QtCore
import
Qt
,
QMargins
,
QModelIndex
,
QItemSelectionModel
from
PyQt5.QtGui
import
QPainter
,
QColor
,
QKeyEvent
,
QPalette
from
PyQt5.QtWidgets
import
(
QStyledItemDelegate
,
QApplication
,
QStyleOptionViewItem
,
QTableView
,
QTableWidget
,
QWidget
)
QTableView
,
QTableWidget
,
QWidget
,
QTableWidgetItem
)
from
...common.style_sheet
import
isDarkTheme
,
FluentStyleSheet
,
themeColor
from
.line_edit
import
LineEdit
...
...
@@ -151,30 +151,30 @@ class TableBase:
self
.
setItemDelegate
(
self
.
delegate
)
self
.
setSelectionBehavior
(
TableWidget
.
SelectRows
)
self
.
entered
.
connect
(
lambda
i
:
self
.
setHoverRow
(
i
.
row
()))
self
.
pressed
.
connect
(
lambda
i
:
self
.
setPressedRow
(
i
.
row
()))
self
.
entered
.
connect
(
lambda
i
:
self
.
_
setHoverRow
(
i
.
row
()))
self
.
pressed
.
connect
(
lambda
i
:
self
.
_
setPressedRow
(
i
.
row
()))
def
showEvent
(
self
,
e
):
QTableView
.
showEvent
(
self
,
e
)
self
.
resizeRowsToContents
()
def
setHoverRow
(
self
,
row
:
int
):
def
_
setHoverRow
(
self
,
row
:
int
):
""" set hovered row """
self
.
delegate
.
setHoverRow
(
row
)
self
.
viewport
().
update
()
def
setPressedRow
(
self
,
row
:
int
):
def
_
setPressedRow
(
self
,
row
:
int
):
""" set pressed row """
self
.
delegate
.
setPressedRow
(
row
)
self
.
viewport
().
update
()
def
setSelectedRows
(
self
,
indexes
:
List
[
QModelIndex
]):
def
_
setSelectedRows
(
self
,
indexes
:
List
[
QModelIndex
]):
self
.
delegate
.
setSelectedRows
(
indexes
)
self
.
viewport
().
update
()
def
leaveEvent
(
self
,
e
):
QTableView
.
leaveEvent
(
self
,
e
)
self
.
setHoverRow
(
-
1
)
self
.
_
setHoverRow
(
-
1
)
def
resizeEvent
(
self
,
e
):
QTableView
.
resizeEvent
(
self
,
e
)
...
...
@@ -182,27 +182,50 @@ class TableBase:
def
keyPressEvent
(
self
,
e
:
QKeyEvent
):
QTableView
.
keyPressEvent
(
self
,
e
)
self
.
setSelectedRows
(
self
.
selectedIndexes
()
)
self
.
_updateSelectedRows
(
)
def
mousePressEvent
(
self
,
e
:
QKeyEvent
):
if
e
.
button
()
==
Qt
.
LeftButton
:
QTableView
.
mousePressEvent
(
self
,
e
)
else
:
self
.
setPressedRow
(
self
.
indexAt
(
e
.
pos
()).
row
())
self
.
_
setPressedRow
(
self
.
indexAt
(
e
.
pos
()).
row
())
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
()
)
self
.
_updateSelectedRows
(
)
else
:
self
.
setPressedRow
(
-
1
)
self
.
_
setPressedRow
(
-
1
)
def
setItemDelegate
(
self
,
delegate
:
TableItemDelegate
):
self
.
delegate
=
delegate
super
().
setItemDelegate
(
delegate
)
def
selectAll
(
self
):
QTableView
.
selectAll
(
self
)
self
.
_updateSelectedRows
()
def
selectRow
(
self
,
row
:
int
):
QTableView
.
selectRow
(
self
,
row
)
self
.
_updateSelectedRows
()
def
setSelection
(
self
,
rect
,
command
):
QTableView
.
setSelection
(
self
,
rect
,
command
)
self
.
_updateSelectedRows
()
def
clearSelection
(
self
):
QTableView
.
clearSelection
(
self
)
self
.
_updateSelectedRows
()
def
setCurrentIndex
(
self
,
index
:
QModelIndex
):
QTableView
.
setCurrentIndex
(
self
,
index
)
self
.
_updateSelectedRows
()
def
_updateSelectedRows
(
self
):
self
.
_setSelectedRows
(
self
.
selectedIndexes
())
class
TableWidget
(
TableBase
,
QTableWidget
):
""" Table widget """
...
...
@@ -210,6 +233,17 @@ class TableWidget(TableBase, QTableWidget):
def
__init__
(
self
,
parent
=
None
):
super
().
__init__
(
parent
)
def
setCurrentCell
(
self
,
row
:
int
,
column
:
int
,
command
:
Union
[
QItemSelectionModel
.
SelectionFlag
,
QItemSelectionModel
.
SelectionFlags
]
=
None
):
self
.
setCurrentItem
(
self
.
item
(
row
,
column
),
command
)
def
setCurrentItem
(
self
,
item
:
QTableWidgetItem
,
command
:
Union
[
QItemSelectionModel
.
SelectionFlag
,
QItemSelectionModel
.
SelectionFlags
]
=
None
):
if
not
command
:
super
().
setCurrentItem
(
item
)
else
:
super
().
setCurrentItem
(
item
,
command
)
self
.
_updateSelectedRows
()
class
TableView
(
TableBase
,
QTableView
):
""" Table view """
...
...
setup.py
浏览文件 @
5362613c
...
...
@@ -6,7 +6,7 @@ with open('README.md', encoding='utf-8') as f:
setuptools
.
setup
(
name
=
"PyQt-Fluent-Widgets"
,
version
=
"0.8.
6
"
,
version
=
"0.8.
7
"
,
keywords
=
"pyqt fluent widgets"
,
author
=
"zhiyiYo"
,
author_email
=
"shokokawaii@outlook.com"
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录