提交 d2ccfcda 编写于 作者: 之一Yo's avatar 之一Yo

添加列表组件

上级 751ff1a9
......@@ -360,6 +360,189 @@
<translation>搜索图标</translation>
</message>
</context>
<context>
<name>ListFrame</name>
<message>
<location filename="../../view/view_interface.py" line="75"/>
<source>Star Platinum</source>
<translation>白金之星</translation>
</message>
<message>
<location filename="../../view/view_interface.py" line="75"/>
<source>Hierophant Green</source>
<translation>法皇之绿</translation>
</message>
<message>
<location filename="../../view/view_interface.py" line="76"/>
<source>Made in Haven</source>
<translation>天堂制造</translation>
</message>
<message>
<location filename="../../view/view_interface.py" line="76"/>
<source>King Crimson</source>
<translation>绯红之王</translation>
</message>
<message>
<location filename="../../view/view_interface.py" line="77"/>
<source>Silver Chariot</source>
<translation>银色战车</translation>
</message>
<message>
<location filename="../../view/view_interface.py" line="77"/>
<source>Crazy diamond</source>
<translation>疯狂钻石</translation>
</message>
<message>
<location filename="../../view/view_interface.py" line="78"/>
<source>Metallica</source>
<translation>金属制品</translation>
</message>
<message>
<location filename="../../view/view_interface.py" line="78"/>
<source>Another One Bites The Dust</source>
<translation>败者食尘</translation>
</message>
<message>
<location filename="../../view/view_interface.py" line="79"/>
<source>Heaven&apos;s Door</source>
<translation>黑蚊子多</translation>
</message>
<message>
<location filename="../../view/view_interface.py" line="80"/>
<source>The Grateful Dead</source>
<translation>壮烈成仁</translation>
</message>
<message>
<location filename="../../view/view_interface.py" line="80"/>
<source>Stone Free</source>
<translation>石之自由</translation>
</message>
<message>
<location filename="../../view/view_interface.py" line="81"/>
<source>The World</source>
<translation>砸瓦鲁多</translation>
</message>
<message>
<location filename="../../view/view_interface.py" line="81"/>
<source>Sticky Fingers</source>
<translation>钢链手指</translation>
</message>
<message>
<location filename="../../view/view_interface.py" line="82"/>
<source>Ozone Baby</source>
<translation>臭氧宝宝</translation>
</message>
<message>
<location filename="../../view/view_interface.py" line="82"/>
<source>Love Love Deluxe</source>
<translation>华丽挚爱</translation>
</message>
<message>
<location filename="../../view/view_interface.py" line="83"/>
<source>Hermit Purple</source>
<translation>隐者之紫</translation>
</message>
<message>
<location filename="../../view/view_interface.py" line="83"/>
<source>Gold Experience</source>
<translation>黄金体验</translation>
</message>
<message>
<location filename="../../view/view_interface.py" line="84"/>
<source>King Nothing</source>
<translation>虚无之王</translation>
</message>
<message>
<location filename="../../view/view_interface.py" line="84"/>
<source>Paper Moon King</source>
<translation>纸月之王</translation>
</message>
<message>
<location filename="../../view/view_interface.py" line="85"/>
<source>Scary Monster</source>
<translation>骇人恶兽</translation>
</message>
<message>
<location filename="../../view/view_interface.py" line="85"/>
<source>Mandom</source>
<translation>男子领域</translation>
</message>
<message>
<location filename="../../view/view_interface.py" line="86"/>
<source>20th Century Boy</source>
<translation>20世纪男孩</translation>
</message>
<message>
<location filename="../../view/view_interface.py" line="86"/>
<source>Tusk Act 4</source>
<translation> Act 4</translation>
</message>
<message>
<location filename="../../view/view_interface.py" line="87"/>
<source>Ball Breaker</source>
<translation>铁球破坏者</translation>
</message>
<message>
<location filename="../../view/view_interface.py" line="87"/>
<source>Sex Pistols</source>
<translation>性感手枪</translation>
</message>
<message>
<location filename="../../view/view_interface.py" line="88"/>
<source>D4C Love Train</source>
<translation>D4C 爱之列车</translation>
</message>
<message>
<location filename="../../view/view_interface.py" line="88"/>
<source>Born This Way</source>
<translation>天生完美</translation>
</message>
<message>
<location filename="../../view/view_interface.py" line="89"/>
<source>SOFT &amp; WET</source>
<translation>软又湿</translation>
</message>
<message>
<location filename="../../view/view_interface.py" line="89"/>
<source>Paisley Park</source>
<translation>佩斯利公园</translation>
</message>
<message>
<location filename="../../view/view_interface.py" line="90"/>
<source>Wonder of U</source>
<translation>奇迹于你</translation>
</message>
<message>
<location filename="../../view/view_interface.py" line="90"/>
<source>Walking Heart</source>
<translation>行走的心</translation>
</message>
<message>
<location filename="../../view/view_interface.py" line="91"/>
<source>Cream Starter</source>
<translation>护霜旅行者</translation>
</message>
<message>
<location filename="../../view/view_interface.py" line="91"/>
<source>November Rain</source>
<translation>十一月雨</translation>
</message>
<message>
<location filename="../../view/view_interface.py" line="92"/>
<source>Smooth Operators</source>
<translation>调情圣手</translation>
</message>
<message>
<location filename="../../view/view_interface.py" line="92"/>
<source>The Matte Kudasai</source>
<translation>片刻静候</translation>
</message>
<message>
<location filename="../../view/view_interface.py" line="79"/>
<source>Killer Queen</source>
<translation>杀手皇后💀</translation>
</message>
</context>
<context>
<name>MainWindow</name>
<message>
......@@ -921,27 +1104,27 @@
<context>
<name>TableFrame</name>
<message>
<location filename="../../view/view_interface.py" line="107"/>
<location filename="../../view/view_interface.py" line="146"/>
<source>Title</source>
<translation>标题</translation>
</message>
<message>
<location filename="../../view/view_interface.py" line="107"/>
<location filename="../../view/view_interface.py" line="146"/>
<source>Artist</source>
<translation>歌手</translation>
</message>
<message>
<location filename="../../view/view_interface.py" line="107"/>
<location filename="../../view/view_interface.py" line="146"/>
<source>Album</source>
<translation>专辑</translation>
</message>
<message>
<location filename="../../view/view_interface.py" line="107"/>
<location filename="../../view/view_interface.py" line="146"/>
<source>Year</source>
<translation>年份</translation>
</message>
<message>
<location filename="../../view/view_interface.py" line="107"/>
<location filename="../../view/view_interface.py" line="146"/>
<source>Duration</source>
<translation>时长</translation>
</message>
......@@ -1073,32 +1256,32 @@
<context>
<name>TreeFrame</name>
<message>
<location filename="../../view/view_interface.py" line="66"/>
<location filename="../../view/view_interface.py" line="105"/>
<source>JoJo 1 - Phantom Blood</source>
<translation>JoJo 1 - 幻影之血</translation>
</message>
<message>
<location filename="../../view/view_interface.py" line="67"/>
<location filename="../../view/view_interface.py" line="106"/>
<source>Jonathan Joestar</source>
<translation>乔纳森·乔斯达</translation>
</message>
<message>
<location filename="../../view/view_interface.py" line="67"/>
<location filename="../../view/view_interface.py" line="106"/>
<source>Dio Brando</source>
<translation>迪奥·布兰度</translation>
</message>
<message>
<location filename="../../view/view_interface.py" line="67"/>
<location filename="../../view/view_interface.py" line="106"/>
<source>Will A. Zeppeli</source>
<translation>威廉·A·齐贝林</translation>
</message>
<message>
<location filename="../../view/view_interface.py" line="74"/>
<location filename="../../view/view_interface.py" line="113"/>
<source>JoJo 3 - Stardust Crusaders</source>
<translation>JoJo3 - 星尘斗士</translation>
</message>
<message>
<location filename="../../view/view_interface.py" line="75"/>
<location filename="../../view/view_interface.py" line="114"/>
<source>Jotaro Kujo</source>
<translation></translation>
</message>
......@@ -1106,19 +1289,24 @@
<context>
<name>ViewInterface</name>
<message>
<location filename="../../view/view_interface.py" line="31"/>
<location filename="../../view/view_interface.py" line="39"/>
<source>A simple TreeView</source>
<translation>简单的树状组件</translation>
</message>
<message>
<location filename="../../view/view_interface.py" line="38"/>
<location filename="../../view/view_interface.py" line="46"/>
<source>A TreeView with Multi-selection enabled</source>
<translation>启用复选框的树状组件</translation>
</message>
<message>
<location filename="../../view/view_interface.py" line="23"/>
<location filename="../../view/view_interface.py" line="31"/>
<source>A simple TableView</source>
<translation>简单的表格组件</translation>
</message>
<message>
<location filename="../../view/view_interface.py" line="24"/>
<source>A simple ListView</source>
<translation>简单的列表组件</translation>
</message>
</context>
</TS>
......@@ -360,6 +360,189 @@
<translation>搜索圖標</translation>
</message>
</context>
<context>
<name>ListFrame</name>
<message>
<location filename="../../view/view_interface.py" line="75"/>
<source>Star Platinum</source>
<translation>白金之星</translation>
</message>
<message>
<location filename="../../view/view_interface.py" line="75"/>
<source>Hierophant Green</source>
<translation>法皇之綠</translation>
</message>
<message>
<location filename="../../view/view_interface.py" line="76"/>
<source>Made in Haven</source>
<translation>天堂製造</translation>
</message>
<message>
<location filename="../../view/view_interface.py" line="76"/>
<source>King Crimson</source>
<translation>緋紅之王</translation>
</message>
<message>
<location filename="../../view/view_interface.py" line="77"/>
<source>Silver Chariot</source>
<translation>銀色戰車</translation>
</message>
<message>
<location filename="../../view/view_interface.py" line="77"/>
<source>Crazy diamond</source>
<translation>瘋狂鑽石</translation>
</message>
<message>
<location filename="../../view/view_interface.py" line="78"/>
<source>Metallica</source>
<translation>金屬製品</translation>
</message>
<message>
<location filename="../../view/view_interface.py" line="78"/>
<source>Another One Bites The Dust</source>
<translation>敗者食塵</translation>
</message>
<message>
<location filename="../../view/view_interface.py" line="79"/>
<source>Heaven&apos;s Door</source>
<translation>黑蚊子多</translation>
</message>
<message>
<location filename="../../view/view_interface.py" line="80"/>
<source>The Grateful Dead</source>
<translation>壯烈成仁</translation>
</message>
<message>
<location filename="../../view/view_interface.py" line="80"/>
<source>Stone Free</source>
<translation>石之自由</translation>
</message>
<message>
<location filename="../../view/view_interface.py" line="81"/>
<source>The World</source>
<translation>砸瓦魯多</translation>
</message>
<message>
<location filename="../../view/view_interface.py" line="81"/>
<source>Sticky Fingers</source>
<translation>鋼鏈手指</translation>
</message>
<message>
<location filename="../../view/view_interface.py" line="82"/>
<source>Ozone Baby</source>
<translation>臭氧寶寶</translation>
</message>
<message>
<location filename="../../view/view_interface.py" line="82"/>
<source>Love Love Deluxe</source>
<translation>華麗摯愛</translation>
</message>
<message>
<location filename="../../view/view_interface.py" line="83"/>
<source>Hermit Purple</source>
<translation>隱者之紫</translation>
</message>
<message>
<location filename="../../view/view_interface.py" line="83"/>
<source>Gold Experience</source>
<translation>黃金體驗</translation>
</message>
<message>
<location filename="../../view/view_interface.py" line="84"/>
<source>King Nothing</source>
<translation>虛無之王</translation>
</message>
<message>
<location filename="../../view/view_interface.py" line="84"/>
<source>Paper Moon King</source>
<translation>紙月之王</translation>
</message>
<message>
<location filename="../../view/view_interface.py" line="85"/>
<source>Scary Monster</source>
<translation>駭人惡獸</translation>
</message>
<message>
<location filename="../../view/view_interface.py" line="85"/>
<source>Mandom</source>
<translation>男子領域</translation>
</message>
<message>
<location filename="../../view/view_interface.py" line="86"/>
<source>20th Century Boy</source>
<translation>20世紀男孩</translation>
</message>
<message>
<location filename="../../view/view_interface.py" line="86"/>
<source>Tusk Act 4</source>
<translation> Act 4</translation>
</message>
<message>
<location filename="../../view/view_interface.py" line="87"/>
<source>Ball Breaker</source>
<translation>鐵球破壞者</translation>
</message>
<message>
<location filename="../../view/view_interface.py" line="87"/>
<source>Sex Pistols</source>
<translation>性感手槍</translation>
</message>
<message>
<location filename="../../view/view_interface.py" line="88"/>
<source>D4C Love Train</source>
<translation>D4C 愛之列車</translation>
</message>
<message>
<location filename="../../view/view_interface.py" line="88"/>
<source>Born This Way</source>
<translation>天生完美</translation>
</message>
<message>
<location filename="../../view/view_interface.py" line="89"/>
<source>SOFT &amp; WET</source>
<translation>軟又濕</translation>
</message>
<message>
<location filename="../../view/view_interface.py" line="89"/>
<source>Paisley Park</source>
<translation>佩斯利公園</translation>
</message>
<message>
<location filename="../../view/view_interface.py" line="90"/>
<source>Wonder of U</source>
<translation>奇蹟於你</translation>
</message>
<message>
<location filename="../../view/view_interface.py" line="90"/>
<source>Walking Heart</source>
<translation>行走的心</translation>
</message>
<message>
<location filename="../../view/view_interface.py" line="91"/>
<source>Cream Starter</source>
<translation>護霜旅行者</translation>
</message>
<message>
<location filename="../../view/view_interface.py" line="91"/>
<source>November Rain</source>
<translation>十一月雨</translation>
</message>
<message>
<location filename="../../view/view_interface.py" line="92"/>
<source>Smooth Operators</source>
<translation>調情聖手</translation>
</message>
<message>
<location filename="../../view/view_interface.py" line="92"/>
<source>The Matte Kudasai</source>
<translation>片刻靜候</translation>
</message>
<message>
<location filename="../../view/view_interface.py" line="79"/>
<source>Killer Queen</source>
<translation>殺手皇后💀</translation>
</message>
</context>
<context>
<name>MainWindow</name>
<message>
......@@ -921,27 +1104,27 @@
<context>
<name>TableFrame</name>
<message>
<location filename="../../view/view_interface.py" line="107"/>
<location filename="../../view/view_interface.py" line="146"/>
<source>Title</source>
<translation>標題</translation>
</message>
<message>
<location filename="../../view/view_interface.py" line="107"/>
<location filename="../../view/view_interface.py" line="146"/>
<source>Artist</source>
<translation>歌手</translation>
</message>
<message>
<location filename="../../view/view_interface.py" line="107"/>
<location filename="../../view/view_interface.py" line="146"/>
<source>Album</source>
<translation>專輯</translation>
</message>
<message>
<location filename="../../view/view_interface.py" line="107"/>
<location filename="../../view/view_interface.py" line="146"/>
<source>Year</source>
<translation>年份</translation>
</message>
<message>
<location filename="../../view/view_interface.py" line="107"/>
<location filename="../../view/view_interface.py" line="146"/>
<source>Duration</source>
<translation>時長</translation>
</message>
......@@ -1073,32 +1256,32 @@
<context>
<name>TreeFrame</name>
<message>
<location filename="../../view/view_interface.py" line="66"/>
<location filename="../../view/view_interface.py" line="105"/>
<source>JoJo 1 - Phantom Blood</source>
<translation>JoJo 1 - 幻影之血</translation>
</message>
<message>
<location filename="../../view/view_interface.py" line="67"/>
<location filename="../../view/view_interface.py" line="106"/>
<source>Jonathan Joestar</source>
<translation>喬納森·喬斯達</translation>
</message>
<message>
<location filename="../../view/view_interface.py" line="67"/>
<location filename="../../view/view_interface.py" line="106"/>
<source>Dio Brando</source>
<translation>迪奧·布蘭度</translation>
</message>
<message>
<location filename="../../view/view_interface.py" line="67"/>
<location filename="../../view/view_interface.py" line="106"/>
<source>Will A. Zeppeli</source>
<translation>威廉·A·齊貝林</translation>
</message>
<message>
<location filename="../../view/view_interface.py" line="74"/>
<location filename="../../view/view_interface.py" line="113"/>
<source>JoJo 3 - Stardust Crusaders</source>
<translation>JoJo3 - 星塵鬥士</translation>
</message>
<message>
<location filename="../../view/view_interface.py" line="75"/>
<location filename="../../view/view_interface.py" line="114"/>
<source>Jotaro Kujo</source>
<translation></translation>
</message>
......@@ -1106,19 +1289,24 @@
<context>
<name>ViewInterface</name>
<message>
<location filename="../../view/view_interface.py" line="31"/>
<location filename="../../view/view_interface.py" line="39"/>
<source>A simple TreeView</source>
<translation>簡單的樹狀組件</translation>
</message>
<message>
<location filename="../../view/view_interface.py" line="38"/>
<location filename="../../view/view_interface.py" line="46"/>
<source>A TreeView with Multi-selection enabled</source>
<translation>啓用複選框的樹狀組件</translation>
</message>
<message>
<location filename="../../view/view_interface.py" line="23"/>
<location filename="../../view/view_interface.py" line="31"/>
<source>A simple TableView</source>
<translation>簡單的表格組件</translation>
</message>
<message>
<location filename="../../view/view_interface.py" line="24"/>
<source>A simple ListView</source>
<translation>簡單的列表組件</translation>
</message>
</context>
</TS>
......@@ -341,13 +341,21 @@ class HomeInterface(ScrollArea):
# view samples
collectionView = SampleCardView(self.tr('View samples'), self.view)
collectionView.addSampleCard(
icon=":/gallery/images/controls/ListView.png",
title="ListView",
content=self.tr(
"A control that presents a collection of items in a vertical list."),
routeKey="viewInterface",
index=0
)
collectionView.addSampleCard(
icon=":/gallery/images/controls/DataGrid.png",
title="TableView",
content=self.tr(
"The DataGrid control provides a flexible way to display a collection of data in rows and columns."),
routeKey="viewInterface",
index=0
index=1
)
collectionView.addSampleCard(
icon=":/gallery/images/controls/TreeView.png",
......@@ -355,6 +363,6 @@ class HomeInterface(ScrollArea):
content=self.tr(
"The TreeView control is a hierarchical list pattern with expanding and collapsing nodes that contain nested items."),
routeKey="viewInterface",
index=1
index=2
)
self.vBoxLayout.addWidget(collectionView)
......@@ -44,7 +44,7 @@ class ScrollInterface(GalleryInterface):
label.setPixmap(QPixmap(":/gallery/images/chidanta3.jpg"))
w.setWidget(label)
w.setFixedSize(654, 540)
w.setFixedSize(660, 540)
w.setObjectName('imageViewer')
card = self.addExampleCard(
......
# coding:utf-8
from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import QWidget, QFrame, QTreeWidgetItem, QHBoxLayout, QTreeWidgetItemIterator, QTableWidgetItem
from qfluentwidgets import TreeWidget, TableWidget
from PyQt5.QtWidgets import (QListWidgetItem, QFrame, QTreeWidgetItem, QHBoxLayout,
QTreeWidgetItemIterator, QTableWidgetItem)
from qfluentwidgets import TreeWidget, TableWidget, ListWidget
from .gallery_interface import GalleryInterface
from ..common.translator import Translator
......@@ -19,6 +20,13 @@ class ViewInterface(GalleryInterface):
parent=parent
)
# list view
self.addExampleCard(
title=self.tr('A simple ListView'),
widget=ListFrame(self),
sourcePath='https://github.com/zhiyiYo/PyQt-Fluent-Widgets/blob/master/examples/list_view/demo.py'
)
# table view
self.addExampleCard(
title=self.tr('A simple TableView'),
......@@ -56,6 +64,39 @@ class Frame(QFrame):
self.hBoxLayout.addWidget(widget)
class ListFrame(Frame):
def __init__(self, parent=None):
super().__init__(parent)
self.listWidget = ListWidget(self)
self.addWidget(self.listWidget)
stands = [
self.tr("Star Platinum"), self.tr("Hierophant Green"),
self.tr("Made in Haven"), self.tr("King Crimson"),
self.tr("Silver Chariot"), self.tr("Crazy diamond"),
self.tr("Metallica"), self.tr("Another One Bites The Dust"),
self.tr("Heaven's Door"), self.tr("Killer Queen"),
self.tr("The Grateful Dead"), self.tr("Stone Free"),
self.tr("The World"), self.tr("Sticky Fingers"),
self.tr("Ozone Baby"), self.tr("Love Love Deluxe"),
self.tr("Hermit Purple"), self.tr("Gold Experience"),
self.tr("King Nothing"), self.tr("Paper Moon King"),
self.tr("Scary Monster"), self.tr("Mandom"),
self.tr("20th Century Boy"), self.tr("Tusk Act 4"),
self.tr("Ball Breaker"), self.tr("Sex Pistols"),
self.tr("D4C • Love Train"), self.tr("Born This Way"),
self.tr("SOFT & WET"), self.tr("Paisley Park"),
self.tr("Wonder of U"), self.tr("Walking Heart"),
self.tr("Cream Starter"), self.tr("November Rain"),
self.tr("Smooth Operators"), self.tr("The Matte Kudasai")
]
for stand in stands:
self.listWidget.addItem(QListWidgetItem(stand))
self.setFixedSize(300, 380)
class TreeFrame(Frame):
def __init__(self, parent=None, enableCheck=False):
......@@ -147,4 +188,4 @@ class TableFrame(Frame):
self.table.setItem(i, j, QTableWidgetItem(songInfo[j]))
self.setFixedSize(650, 440)
self.table.resizeColumnsToContents()
\ No newline at end of file
self.table.resizeColumnsToContents()
# coding: utf-8
import sys
from PyQt5.QtCore import Qt
from PyQt5.QtGui import QIcon
from PyQt5.QtWidgets import QApplication, QListWidgetItem, QListWidget, QWidget, QHBoxLayout
from qfluentwidgets import ListView, setTheme, Theme, ListWidget
class Demo(QWidget):
def __init__(self):
super().__init__()
# setTheme(Theme.DARK)
self.hBoxLayout = QHBoxLayout(self)
self.listWidget = ListWidget(self)
# self.listWidget.setAlternatingRowColors(True)
stands = [
'白金之星', '绿色法皇', "天堂制造", "绯红之王",
'银色战车', '疯狂钻石', "壮烈成仁", "败者食尘",
"黑蚊子多", '杀手皇后', "金属制品", "石之自由",
"砸瓦鲁多", '钢链手指', "臭氧宝宝", "华丽挚爱",
"隐者之紫", "黄金体验", "虚无之王", "纸月之王",
"骇人恶兽", "男子领域", "20世纪男孩", "牙 Act 4",
"铁球破坏者", "性感手枪", 'D4C • 爱之列车', "天生完美",
"软又湿", "佩斯利公园", "奇迹于你", "行走的心",
"护霜旅行者", "十一月雨", "调情圣手", "片刻静候"
]
for stand in stands:
item = QListWidgetItem(stand)
# item.setIcon(QIcon('docs/source/_static/logo.png'))
# item.setCheckState(Qt.Unchecked)
self.listWidget.addItem(item)
self.setStyleSheet("Demo{background: rgb(249, 249, 249)} ")
self.hBoxLayout.setContentsMargins(0, 0, 0, 0)
self.hBoxLayout.addWidget(self.listWidget)
self.resize(300, 400)
if __name__ == "__main__":
# enable dpi scale
QApplication.setHighDpiScaleFactorRoundingPolicy(
Qt.HighDpiScaleFactorRoundingPolicy.PassThrough)
QApplication.setAttribute(Qt.AA_EnableHighDpiScaling)
QApplication.setAttribute(Qt.AA_UseHighDpiPixmaps)
app = QApplication(sys.argv)
w = Demo()
w.show()
app.exec()
QListView {
background: transparent;
outline: none;
border: none;
font: 13px 'Segoe UI', 'Microsoft YaHei';
selection-background-color: transparent;
alternate-background-color: transparent;
padding-left: 4px;
padding-right: 4px;
}
QListView::item {
background: transparent;
border: 0px;
padding-left: 11px;
padding-right: 11px;
height: 35px;
}
QListView::indicator {
width: 18px;
height: 18px;
border-radius: 5px;
border: 1px solid rgba(255, 255, 255, 0.5547);
background-color: rgba(0, 0, 0, 0.1);
margin-right: 4px;
}
QListView::indicator:hover {
border: 1px solid rgba(255, 255, 255, 0.5547);
background-color: rgba(255, 255, 255, 0.0419);
}
QListView::indicator:pressed {
border: 1px solid rgba(255, 255, 255, 0.1581);
background-color: rgba(255, 255, 255, 0.0698);
}
QListView::indicator:checked,
QListView::indicator:indeterminate {
border: 1px solid --ThemeColorPrimary;
background-color: --ThemeColorPrimary;
}
QListView::indicator:checked {
image: url(:/qfluentwidgets/images/check_box/Accept_black.svg);
}
QListView::indicator:indeterminate {
image: url(:/qfluentwidgets/images/check_box/PartialAccept_black.svg);
}
QListView::indicator:checked:hover,
QListView::indicator:indeterminate:hover {
border: 1px solid --ThemeColorLight1;
background-color: --ThemeColorLight1;
}
QListView::indicator:checked:pressed,
QListView::indicator:indeterminate:pressed {
border: 1px solid --ThemeColorLight3;
background-color: --ThemeColorLight3;
}
QListView::indicator:disabled {
border: 1px solid rgba(255, 255, 255, 0.1581);
background-color: transparent
}
QListView::indicator:checked:disabled,
QListView::indicator:indeterminate:disabled {
border: 1px solid rgb(82, 82, 82);
background-color: rgb(82, 82, 82);
}
\ No newline at end of file
......@@ -4,6 +4,7 @@ QTableView {
border: none;
font: 13px 'Segoe UI', 'Microsoft YaHei';
selection-background-color: transparent;
alternate-background-color: transparent;
}
QTableView::item {
......
QListView {
background: transparent;
outline: none;
border: none;
font: 13px 'Segoe UI', 'Microsoft YaHei';
selection-background-color: transparent;
alternate-background-color: transparent;
padding-left: 4px;
padding-right: 4px;
}
QListView::item {
background: transparent;
border: 0px;
padding-left: 11px;
padding-right: 11px;
height: 35px;
}
QListView::indicator {
width: 18px;
height: 18px;
border-radius: 5px;
border: 1px solid rgba(0, 0, 0, 0.48);
background-color: rgba(0, 0, 0, 0.022);
margin-right: 4px;
}
QListView::indicator:hover {
border: 1px solid rgba(0, 0, 0, 0.56);
background-color: rgba(0, 0, 0, 0.05);
}
QListView::indicator:pressed {
border: 1px solid rgba(0, 0, 0, 0.27);
background-color: rgba(0, 0, 0, 0.12);
}
QListView::indicator:checked,
QListView::indicator:indeterminate {
border: 1px solid --ThemeColorPrimary;
background-color: --ThemeColorPrimary;
}
QListView::indicator:checked {
image: url(:/qfluentwidgets/images/check_box/Accept_white.svg);
}
QListView::indicator:indeterminate {
image: url(:/qfluentwidgets/images/check_box/PartialAccept_white.svg);
}
QListView::indicator:checked:hover,
QListView::indicator:indeterminate:hover {
border: 1px solid --ThemeColorLight1;
background-color: --ThemeColorLight1;
}
QListView::indicator:checked:pressed,
QListView::indicator:indeterminate:pressed {
border: 1px solid --ThemeColorLight3;
background-color: --ThemeColorLight3;
}
QListView::indicator:disabled {
border: 1px solid rgba(0, 0, 0, 0.27);
background-color: transparent;
}
QListView::indicator:checked:disabled,
QListView::indicator:indeterminate:disabled {
border: 1px solid rgb(199, 199, 199);
background-color: rgb(199, 199, 199);
}
......@@ -4,6 +4,7 @@ QTableView {
border: none;
font: 13px 'Segoe UI', 'Microsoft YaHei';
selection-background-color: transparent;
alternate-background-color: transparent;
}
QTableView::item {
......
此差异已折叠。
......@@ -222,6 +222,7 @@
<file>qss/dark/check_box.qss</file>
<file>qss/dark/info_bar.qss</file>
<file>qss/dark/spin_box.qss</file>
<file>qss/dark/list_view.qss</file>
<file>qss/dark/tree_view.qss</file>
<file>qss/dark/table_view.qss</file>
<file>qss/dark/time_picker.qss</file>
......@@ -245,6 +246,7 @@
<file>qss/light/check_box.qss</file>
<file>qss/light/info_bar.qss</file>
<file>qss/light/spin_box.qss</file>
<file>qss/light/list_view.qss</file>
<file>qss/light/table_view.qss</file>
<file>qss/light/tree_view.qss</file>
<file>qss/light/time_picker.qss</file>
......
......@@ -96,6 +96,7 @@ class FluentStyleSheet(StyleSheetBase, Enum):
CHECK_BOX = "check_box"
COMBO_BOX = "combo_box"
LINE_EDIT = "line_edit"
LIST_VIEW = "list_view"
TREE_VIEW = "tree_view"
TABLE_VIEW = "table_view"
TIME_PICKER = "time_picker"
......
......@@ -6,6 +6,7 @@ from .combo_box import ComboBox, EditableComboBox
from .line_edit import LineEdit, TextEdit, PlainTextEdit, LineEditButton, SearchLineEdit
from .icon_widget import IconWidget
from .label import PixmapLabel
from .list_view import ListWidget, ListView, ListItemDelegate
from .menu import DWMMenu, LineEditMenu, RoundMenu
from .info_bar import InfoBar, InfoBarIcon, InfoBarPosition
from .scroll_area import SingleDirectionScrollArea, SmoothMode, SmoothScrollArea, ScrollArea
......
# coding:utf-8
from typing import List
from PyQt5.QtCore import Qt, pyqtSignal, QModelIndex
from PyQt5.QtGui import QPainter
from PyQt5.QtWidgets import QStyleOptionViewItem, QListView, QWidget, QListView, QListWidget
from .scroll_bar import SmoothScrollDelegate
from .table_view import TableItemDelegate
from ...common.style_sheet import FluentStyleSheet, themeColor
class ListItemDelegate(TableItemDelegate):
""" List item delegate """
def __init__(self, parent: QListView):
super().__init__(parent)
def _drawBackground(self, painter: QPainter, option: QStyleOptionViewItem, index: QModelIndex):
painter.drawRoundedRect(option.rect, 5, 5)
def _drawIndicator(self, painter: QPainter, option: QStyleOptionViewItem, index: QModelIndex):
y, h = option.rect.y(), option.rect.height()
ph = round(0.35*h if self.pressedRow == index.row() else 0.257*h)
painter.setBrush(themeColor())
painter.drawRoundedRect(0, ph + y, 3, h - 2*ph, 1.5, 1.5)
class ListBase:
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.delegate = ListItemDelegate(self)
self.scrollDelegate = SmoothScrollDelegate(self)
FluentStyleSheet.LIST_VIEW.apply(self)
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()))
def setHoverRow(self, row: int):
""" set hovered row """
self.delegate.setHoverRow(row)
self.viewport().update()
def setPressedRow(self, row: int):
""" set pressed row """
self.delegate.setPressedRow(row)
self.viewport().update()
def setSelectedRows(self, indexes: List[QModelIndex]):
self.delegate.setSelectedRows(indexes)
self.viewport().update()
def leaveEvent(self, e):
QListView.leaveEvent(self, e)
self.setHoverRow(-1)
def resizeEvent(self, e):
QListView.resizeEvent(self, e)
self.viewport().update()
def keyPressEvent(self, e):
QListView.keyPressEvent(self, e)
self.setSelectedRows(self.selectedIndexes())
def mousePressEvent(self, e):
if e.button() == Qt.LeftButton:
QListView.mousePressEvent(self, e)
else:
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())
else:
self.setPressedRow(-1)
def setItemDelegate(self, delegate: ListItemDelegate):
self.delegate = delegate
super().setItemDelegate(delegate)
class ListWidget(ListBase, QListWidget):
""" List widget """
def __init__(self, parent=None):
super().__init__(parent)
class ListView(ListBase, QListView):
""" List view """
def __init__(self, parent=None):
super().__init__(parent)
\ No newline at end of file
......@@ -152,6 +152,7 @@ class ScrollBar(QWidget):
self.setRange(self.partnerBar.minimum(), self.partnerBar.maximum())
self.setVisible(self.maximum() > 0 and not self._isForceHidden)
self._adjustPos(self.parent().size())
def _onPageUp(self):
self.setValue(self.value() - self.pageStep())
......
......@@ -70,6 +70,13 @@ class TableItemDelegate(QStyledItemDelegate):
rect = option.rect.adjusted(-1, 0, 1, 0)
painter.drawRect(rect)
def _drawIndicator(self, painter: QPainter, option: QStyleOptionViewItem, index: QModelIndex):
""" draw indicator """
y, h = option.rect.y(), option.rect.height()
ph = round(0.35*h if self.pressedRow == index.row() else 0.257*h)
painter.setBrush(themeColor())
painter.drawRoundedRect(4, ph + y, 3, h - 2*ph, 1.5, 1.5)
def initStyleOption(self, option: QStyleOptionViewItem, index: QModelIndex):
super().initStyleOption(option, index)
if isDarkTheme():
......@@ -94,7 +101,7 @@ class TableItemDelegate(QStyledItemDelegate):
# draw highlight background
isHover = self.hoverRow == index.row()
isPressed = self.pressedRow == index.row()
isAlternate = index.row() % 2 == 0
isAlternate = index.row() % 2 == 0 and self.parent().alternatingRowColors()
isDark = isDarkTheme()
c = 255 if isDark else 0
......@@ -117,10 +124,7 @@ class TableItemDelegate(QStyledItemDelegate):
# draw indicator
if index.column() == 0 and self.parent().horizontalScrollBar().value() == 0:
y, h = option.rect.y() ,option.rect.height()
ph = round(0.35*h if isPressed else 0.257*h)
painter.setBrush(themeColor())
painter.drawRoundedRect(4, ph + y, 3, h - 2*ph, 1.5, 1.5)
self._drawIndicator(painter, option, index)
painter.setBrush(QColor(c, c, c, alpha))
self._drawBackground(painter, option, index)
......@@ -143,6 +147,7 @@ class TableBase:
self.setShowGrid(False)
self.setMouseTracking(True)
self.setAlternatingRowColors(True)
self.setItemDelegate(self.delegate)
self.setSelectionBehavior(TableWidget.SelectRows)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册