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

添加 gallery 主页界面

上级 0c04b4f6
......@@ -22,7 +22,7 @@
</a>
</p>
![Interface](docs/source/_static/Interface.png)
![Interface](docs/source/_static/Interface.jpg)
## Install
......@@ -38,7 +38,7 @@ pip install "PyQt-Fluent-Widgets[full]"
## Run Example
After installing PyQt-Fluent-Widgets package using pip, you can run any demo in the examples directory, for example:
```python
cd examples/settings
cd examples/gallery
python demo.py
```
......
......@@ -34,7 +34,7 @@
</p>
<p align="center">
<img src="./_static/Interface.png" alt="Interface">
<img src="./_static/Interface.jpg" alt="Interface">
</p>
......
......@@ -13,6 +13,6 @@ pip install "PyQt-Fluent-Widgets[full]"
### Run example
After installing PyQt-Fluent-Widgets package using pip, you can run any demo in the examples directory, for example:
```python
cd examples/settings
cd examples/gallery
python demo.py
```
\ No newline at end of file
......@@ -4,7 +4,7 @@ import sys
from PyQt5.QtGui import QColor
from PyQt5.QtWidgets import QApplication
from qfluentwidgets.components.widgets.label import AcrylicLabel
from qfluentwidgets.components.widgets.acrylic_label import AcrylicLabel
app = QApplication(sys.argv)
......
......@@ -42,8 +42,8 @@ YEAR = 2023
AUTHOR = "zhiyiYo"
VERSION = "v0.4.2"
HELP_URL = "https://pyqt-fluent-widgets.readthedocs.io"
REPO_URL = "https://github.com/zhiyiYo/PyQt-Fluent-Widgets"
EXAMPLE_URL = "https://github.com/zhiyiYo/PyQt-Fluent-Widgets/tree/master/examples"
DOCUMENT_URL = "https://github.com/zhiyiYo/PyQt-Fluent-Widgets/issues"
FEEDBACK_URL = "https://github.com/zhiyiYo/PyQt-Fluent-Widgets/issues"
RELEASE_URL = "https://github.com/zhiyiYo/PyQt-Fluent-Widgets/releases/latest"
......
......@@ -8,11 +8,12 @@ class Icon(FluentIconBase, Enum):
HOME = "Home"
CHAT = "Chat"
CODE = "Code"
MENU = "Menu"
ALBUM = "Album"
SCROLL = "Scroll"
LAYOUT = "Layout"
GITHUB = "Github"
GITHUB = "GitHub"
MESSAGE = "Message"
CHECKBOX = "CheckBox"
DOCUMENT = "Document"
......
# coding: utf-8
from PyQt5.QtCore import QObject, pyqtSignal
class SignalBus(QObject):
""" Signal bus """
switchToSampleCard = pyqtSignal(str, int)
signalBus = SignalBus()
\ No newline at end of file
# coding:utf-8
from PyQt5.QtCore import Qt, pyqtSignal, QUrl
from PyQt5.QtGui import QPixmap, QDesktopServices
from PyQt5.QtWidgets import QFrame, QLabel, QVBoxLayout, QWidget, QHBoxLayout
from qfluentwidgets import IconWidget, FluentIcon, TextWrap, isDarkTheme, ScrollArea
from ..common.config import cfg
class LinkCard(QFrame):
def __init__(self, icon, title, content, url, parent=None):
super().__init__(parent=parent)
self.url = QUrl(url)
self.setFixedSize(198, 220)
self.iconWidget = IconWidget(icon, self)
self.titleLabel = QLabel(title, self)
self.contentLabel = QLabel(TextWrap.wrap(content, 28, False)[0], self)
self.urlWidget = IconWidget(FluentIcon.LINK, self)
self.__initWidget()
def __initWidget(self):
self.setCursor(Qt.PointingHandCursor)
self.iconWidget.setFixedSize(54, 54)
self.urlWidget.setFixedSize(16, 16)
self.vBoxLayout = QVBoxLayout(self)
self.vBoxLayout.setSpacing(0)
self.vBoxLayout.setContentsMargins(24, 24, 0, 13)
self.vBoxLayout.addWidget(self.iconWidget)
self.vBoxLayout.addSpacing(16)
self.vBoxLayout.addWidget(self.titleLabel)
self.vBoxLayout.addSpacing(8)
self.vBoxLayout.addWidget(self.contentLabel)
self.vBoxLayout.setAlignment(Qt.AlignLeft | Qt.AlignTop)
self.urlWidget.move(170, 192)
self.titleLabel.setObjectName('titleLabel')
self.contentLabel.setObjectName('contentLabel')
def mouseReleaseEvent(self, e):
super().mouseReleaseEvent(e)
QDesktopServices.openUrl(self.url)
class LinkCardView(ScrollArea):
""" Link card view """
def __init__(self, parent=None):
super().__init__(parent, Qt.Horizontal)
self.view = QWidget(self)
self.hBoxLayout = QHBoxLayout(self.view)
self.hBoxLayout.setContentsMargins(36, 0, 0, 0)
self.hBoxLayout.setSpacing(12)
self.hBoxLayout.setAlignment(Qt.AlignLeft)
self.setWidget(self.view)
self.setWidgetResizable(True)
self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
self.view.setObjectName('view')
self.__setQss()
cfg.themeChanged.connect(self.__setQss)
def addCard(self, icon, title, content, url):
""" add link card """
card = LinkCard(icon, title, content, url, self.view)
self.hBoxLayout.addWidget(card, 0, Qt.AlignLeft)
def __setQss(self):
color = 'dark' if isDarkTheme() else 'light'
with open(f'app/resource/qss/{color}/link_card.qss', encoding='utf-8') as f:
self.setStyleSheet(f.read())
# coding:utf-8
from PyQt5.QtCore import Qt, pyqtSignal
from PyQt5.QtGui import QPixmap
from PyQt5.QtWidgets import QWidget, QFrame, QLabel, QVBoxLayout, QHBoxLayout
from qfluentwidgets import IconWidget, TextWrap, FlowLayout, isDarkTheme
from ..common.signal_bus import signalBus
from ..common.config import cfg
class SampleCard(QFrame):
""" Sample card """
def __init__(self, icon, title, content, routeKey, index, parent=None):
super().__init__(parent=parent)
self.index = index
self.routekey = routeKey
self.iconWidget = IconWidget(icon, self)
self.titleLabel = QLabel(title, self)
self.contentLabel = QLabel(TextWrap.wrap(content, 46, False)[0], self)
self.hBoxLayout = QHBoxLayout(self)
self.vBoxLayout = QVBoxLayout()
self.setFixedSize(360, 90)
self.iconWidget.setFixedSize(48, 48)
self.hBoxLayout.setSpacing(28)
self.hBoxLayout.setContentsMargins(20, 0, 0, 0)
self.vBoxLayout.setSpacing(2)
self.vBoxLayout.setContentsMargins(0, 0, 0, 0)
self.vBoxLayout.setAlignment(Qt.AlignVCenter)
self.hBoxLayout.setAlignment(Qt.AlignVCenter)
self.hBoxLayout.addWidget(self.iconWidget)
self.hBoxLayout.addLayout(self.vBoxLayout)
self.vBoxLayout.addStretch(1)
self.vBoxLayout.addWidget(self.titleLabel)
self.vBoxLayout.addWidget(self.contentLabel)
self.vBoxLayout.addStretch(1)
self.titleLabel.setObjectName('titleLabel')
self.contentLabel.setObjectName('contentLabel')
def mouseReleaseEvent(self, e):
super().mouseReleaseEvent(e)
signalBus.switchToSampleCard.emit(self.routekey, self.index)
class SampleCardView(QWidget):
""" Sample card view """
def __init__(self, title: str, parent=None):
super().__init__(parent=parent)
self.titleLabel = QLabel(title, self)
self.vBoxLayout = QVBoxLayout(self)
self.flowLayout = FlowLayout()
self.vBoxLayout.setContentsMargins(36, 0, 36, 0)
self.vBoxLayout.setSpacing(10)
self.flowLayout.setContentsMargins(0, 0, 0, 0)
self.flowLayout.setHorizontalSpacing(12)
self.flowLayout.setVerticalSpacing(12)
self.vBoxLayout.addWidget(self.titleLabel)
self.vBoxLayout.addLayout(self.flowLayout, 1)
self.titleLabel.setObjectName('viewTitleLabel')
self.__setQss()
cfg.themeChanged.connect(self.__setQss)
def addSampleCard(self, icon, title, content, routeKey, index):
""" add sample card """
card = SampleCard(icon, title, content, routeKey, index, self)
self.flowLayout.addWidget(card)
def __setQss(self):
theme = 'dark' if isDarkTheme() else 'light'
with open(f'app/resource/qss/{theme}/sample_card.qss', encoding='utf-8') as f:
self.setStyleSheet(f.read())
......@@ -218,6 +218,59 @@
<translation>D4C</translation>
</message>
</context>
<context>
<name>MainWindow</name>
<message>
<location filename="../../view/main_window.py" line="116"/>
<source>Home</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../view/main_window.py" line="124"/>
<source>Basic input</source>
<translation type="unfinished">基本輸入</translation>
</message>
<message>
<location filename="../../view/main_window.py" line="131"/>
<source>Dialogs</source>
<translation type="unfinished">對話框</translation>
</message>
<message>
<location filename="../../view/main_window.py" line="138"/>
<source>Layout</source>
<translation type="unfinished">布局</translation>
</message>
<message>
<location filename="../../view/main_window.py" line="145"/>
<source>Menus</source>
<translation type="unfinished">菜單</translation>
</message>
<message>
<location filename="../../view/main_window.py" line="152"/>
<source>Material</source>
<translation type="unfinished">材料</translation>
</message>
<message>
<location filename="../../view/main_window.py" line="159"/>
<source>Scrolling</source>
<translation type="unfinished">滾動</translation>
</message>
<message>
<location filename="../../view/main_window.py" line="166"/>
<source>Status &amp; info</source>
<translation type="unfinished">狀態和信息</translation>
</message>
<message>
<location filename="../../view/main_window.py" line="227"/>
<source>This is a help message</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../view/main_window.py" line="227"/>
<source>You clicked a customized navigation widget. You can add more custom widgets by calling `NavigationInterface.addWidget()` 😉</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>MaterialInterface</name>
<message>
......@@ -297,7 +350,7 @@
<context>
<name>ScrollInterface</name>
<message>
<location filename="../../view/scroll_interface.py" line="35"/>
<location filename="../../view/scroll_interface.py" line="36"/>
<source>Smooth scroll area</source>
<translation>平滑滾動區域</translation>
</message>
......
......@@ -218,6 +218,59 @@
<translation>D4C</translation>
</message>
</context>
<context>
<name>MainWindow</name>
<message>
<location filename="../../view/main_window.py" line="116"/>
<source>Home</source>
<translation>主页</translation>
</message>
<message>
<location filename="../../view/main_window.py" line="124"/>
<source>Basic input</source>
<translation>基本输入</translation>
</message>
<message>
<location filename="../../view/main_window.py" line="131"/>
<source>Dialogs</source>
<translation>对话框</translation>
</message>
<message>
<location filename="../../view/main_window.py" line="138"/>
<source>Layout</source>
<translation>布局</translation>
</message>
<message>
<location filename="../../view/main_window.py" line="145"/>
<source>Menus</source>
<translation>菜单</translation>
</message>
<message>
<location filename="../../view/main_window.py" line="152"/>
<source>Material</source>
<translation>材料</translation>
</message>
<message>
<location filename="../../view/main_window.py" line="159"/>
<source>Scrolling</source>
<translation>滚动</translation>
</message>
<message>
<location filename="../../view/main_window.py" line="166"/>
<source>Status &amp; info</source>
<translation>状态和信息</translation>
</message>
<message>
<location filename="../../view/main_window.py" line="227"/>
<source>This is a help message</source>
<translation>一条友善的提示</translation>
</message>
<message>
<location filename="../../view/main_window.py" line="227"/>
<source>You clicked a customized navigation widget. You can add more custom widgets by calling `NavigationInterface.addWidget()` 😉</source>
<translation>你点击了一个自定义的导航项你可以通过 `NavigationInterface.addWidget()` 添加更多的自定义导航项</translation>
</message>
</context>
<context>
<name>MaterialInterface</name>
<message>
......@@ -297,7 +350,7 @@
<context>
<name>ScrollInterface</name>
<message>
<location filename="../../view/scroll_interface.py" line="35"/>
<location filename="../../view/scroll_interface.py" line="36"/>
<source>Smooth scroll area</source>
<translation>平滑滚动区域</translation>
</message>
......@@ -490,7 +543,7 @@
<message>
<location filename="../../view/status_info_interface.py" line="44"/>
<source>Label with a ToolTip</source>
<translation>标签的工具提示</translation>
<translation>多看一眼就会爆炸</translation>
</message>
<message>
<location filename="../../view/status_info_interface.py" line="47"/>
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册