修改关于界面

This commit is contained in:
2025-06-29 02:27:12 +08:00
parent 06f39aa01b
commit ce9d0b64f2
7 changed files with 799 additions and 48 deletions

View File

@@ -1,14 +1,100 @@
from PySide6.QtGui import QDesktopServices, Qt
from PySide6.QtWidgets import QVBoxLayout, QHBoxLayout
from qfluentwidgets import PrimaryPushSettingCard, FluentIcon, GroupHeaderCardWidget, PushButton, ImageLabel, TitleLabel
from PySide6.QtGui import QDesktopServices, Qt, QColor
from PySide6.QtWidgets import QVBoxLayout, QHBoxLayout, QWidget
from qfluentwidgets import FluentIcon, GroupHeaderCardWidget, PushButton, ImageLabel, \
TitleLabel, HeaderCardWidget, BodyLabel, HyperlinkLabel, SingleDirectionScrollArea
from qfluentwidgets.components.widgets.card_widget import CardSeparator
from module.about.schema import ThirdParty
from ui.components.widget import Widget
from utils.function import DEVELOPMENT_ENV
from utils.function import RELEASE_ENV
if RELEASE_ENV:
from build_info import *
class AboutWidget(Widget):
def __init__(self, key: str, parent=None):
super().__init__(key, parent)
class AboutCard(HeaderCardWidget):
def __init__(self, parent=None):
super().__init__(parent)
self.setTitle('关于本程序')
self.vBoxLayout = QVBoxLayout(self)
self.vBoxLayout.setContentsMargins(0, 0, 0, 0)
self.lineVBoxLayout = QVBoxLayout(self)
self.lineVBoxLayout.setContentsMargins(24, 16, 24, 8)
self.textVBoxLayout = QVBoxLayout(self)
self.textVBoxLayout.setContentsMargins(24, 8, 24, 16)
self.viewLayout.setContentsMargins(0, 0, 0, 0)
self.addLine('程序名称', '教学工具箱')
if RELEASE_ENV:
self.addLine('程序版本', '1.0.0#' + GIT_HASH)
self.addLine('作者', '许方杰')
if RELEASE_ENV:
self.addLine('构建时间', BUILD_TIME)
self.addLine('许可证', 'GNU 通用公共许可证 第三版GPLv3')
self.addLineUseLink('项目主页', 'https://cantyonion.site/git/cantyonion/JITToolBox')
self.addText(
'教学工具箱是自由软件;您可以依据自由软件基金会发布的 GNU 通用公共许可证第三版条款,重新发布或修改它;许可证应使用第三版或(按您的选择)任何其更新的版本。')
self.addText(
'教学工具箱是以希望它有用为目的而发布的,但不附带任何担保;甚至没有适销性或特定用途适用性的隐含担保。请参看 GNU GPL 第三版了解更详细的内容。')
self.addTextWithLink('您应该已收到一份 GNU 通用公共许可证的副本;如果没有,请查看<',
'https://www.gnu.org/licenses/gpl-3.0.html')
self.vBoxLayout.addLayout(self.lineVBoxLayout)
self.vBoxLayout.addWidget(CardSeparator(self))
self.vBoxLayout.addLayout(self.textVBoxLayout)
self.viewLayout.addLayout(self.vBoxLayout)
def addLine(self, title: str, content: str):
hBox = QHBoxLayout(self)
mTitlte = BodyLabel(title, self)
mContent = BodyLabel(content, self)
mContent.setTextColor(QColor(96, 96, 96), QColor(206, 206, 206))
mTitlte.setFixedWidth(100)
hBox.addWidget(mTitlte)
hBox.addWidget(mContent)
self.lineVBoxLayout.addLayout(hBox)
def addLineUseLink(self, title: str, content: str):
hBox = QHBoxLayout(self)
mTitle = BodyLabel(title, self)
mContent = HyperlinkLabel(content, content)
mTitle.setFixedWidth(100)
hBox.addWidget(mTitle)
hBox.addWidget(mContent)
self.lineVBoxLayout.addLayout(hBox)
mContent.clicked.connect(lambda: QDesktopServices.openUrl(content))
def addText(self, text: str):
label = BodyLabel(text, self)
label.setWordWrap(True)
self.textVBoxLayout.addWidget(label)
def addLink(self, text: str, url: str):
link = HyperlinkLabel(url, text)
link.setUrl(url)
self.textVBoxLayout.addWidget(link)
def addTextWithLink(self, text: str, url: str):
hBox = QHBoxLayout(self)
label = BodyLabel(text, self)
link = HyperlinkLabel(url, url)
link.setContentsMargins(0, 0, 0, 0)
hBox.addWidget(label)
hBox.addWidget(link)
hBox.addWidget(BodyLabel(">。", self))
self.textVBoxLayout.addLayout(hBox)
link.clicked.connect(lambda: QDesktopServices.openUrl(url))
class AboutMain(QWidget):
def __init__(self, parent=None):
super().__init__(parent)
self.logoImage = ImageLabel(':/images/logo.png')
self.logoImage.scaledToHeight(100)
@@ -18,48 +104,46 @@ class AboutWidget(Widget):
self.hBox.addWidget(self.logoImage, 0, Qt.AlignLeft)
self.hBox.addWidget(self.appNameLabel, 1, Qt.AlignLeft)
build_time_str = ''
if DEVELOPMENT_ENV:
from build_info import BUILD_TIME
build_time_str = f",构建时间:{BUILD_TIME}"
third_parties = [
ThirdParty("PySide6", "https://qt.io", ":/images/3rd/qt.png"),
ThirdParty("QFluentWidgets", "https://qfluentwidgets.com", ":/images/3rd/qfluentwidgets.png"),
ThirdParty("openpyxl", "https://openpyxl.readthedocs.io/en/stable"),
ThirdParty("python-docx", "https://github.com/python-openxml/python-docx"),
ThirdParty("Matplotlib", "https://matplotlib.org", ":/images/3rd/matplotlib.svg"),
ThirdParty("packaging", "https://github.com/pypa/packaging", ":/images/3rd/packaging.png"),
ThirdParty("pywin32", "https://github.com/mhammond/pywin32")
]
sorted(third_parties, key=lambda item: item.name)
self.version_card = PrimaryPushSettingCard(
text="获取源码",
icon=FluentIcon.INFO,
title="关于",
content=f"作者许方杰。当前版本1.0.0{build_time_str}\n"
f"本软件使用 GPLv3 开源协议进行分发,作者不对使用本软件造成的任何损失负责。"
)
self.button_list = [
PushButton("访问网站"),
PushButton("访问网站"),
PushButton("访问网站"),
PushButton("访问网站"),
]
self.url_list = [
"https://qt.io",
"https://qfluentwidgets.com",
"https://openpyxl.readthedocs.io/en/stable",
"https://github.com/python-openxml/python-docx"
]
self.group_card = GroupHeaderCardWidget(self)
self.group_card.setTitle("第三方框架")
self.vbox = QVBoxLayout(self)
self.vbox.addLayout(self.hBox)
self.vbox.addWidget(self.version_card)
self.vbox.addWidget(AboutCard(self))
self.vbox.addWidget(self.group_card)
self.vbox.addStretch(1)
self.group_card.addGroup(":/images/3rd/qt.png", "PySide6", self.url_list[0], self.button_list[0])
self.group_card.addGroup(":/images/3rd/qfluentwidgets", "QFluentWidgets", self.url_list[1], self.button_list[1])
self.group_card.addGroup(FluentIcon.LAYOUT, "openpyxl", self.url_list[2], self.button_list[2])
self.group_card.addGroup(FluentIcon.LAYOUT, "python-docx", self.url_list[3], self.button_list[3])
[self.addThirdParty(x) for x in third_parties]
self.version_card.clicked.connect(
lambda: QDesktopServices.openUrl("https://cantyonion.site/git/cantyonion/DefenseTopicGenerator")
)
self.button_list[0].clicked.connect(lambda: QDesktopServices.openUrl(self.url_list[0]))
self.button_list[1].clicked.connect(lambda: QDesktopServices.openUrl(self.url_list[1]))
self.button_list[2].clicked.connect(lambda: QDesktopServices.openUrl(self.url_list[2]))
self.button_list[3].clicked.connect(lambda: QDesktopServices.openUrl(self.url_list[3]))
def addThirdParty(self, third_party: ThirdParty):
button = PushButton(FluentIcon.LINK, "访问网站")
button.setFixedWidth(120)
self.group_card.addGroup(third_party.qrc if third_party.qrc else FluentIcon.LAYOUT, third_party.name,
third_party.url, button)
button.clicked.connect(lambda: QDesktopServices.openUrl(third_party.url))
class AboutWidget(Widget):
def __init__(self, key: str, parent=None):
super().__init__(key, parent)
self.scrollArea = SingleDirectionScrollArea(orient=Qt.Vertical)
self.scrollArea.setWidget(AboutMain(self))
self.scrollArea.setWidgetResizable(True)
self.scrollArea.enableTransparentBackground()
self.vBox = QVBoxLayout(self)
self.vBox.setContentsMargins(0, 0, 0, 0)
self.vBox.setSpacing(0)
self.vBox.addWidget(self.scrollArea)

View File

@@ -3,7 +3,7 @@ import sys
from PySide6.QtCore import Signal
from PySide6.QtWidgets import QWidget, QHBoxLayout, QVBoxLayout, QApplication, QGridLayout
from qfluentwidgets import PushButton, SpinBox, PrimaryPushButton, \
BodyLabel, CardWidget, SimpleCardWidget, FluentStyleSheet
BodyLabel, SimpleCardWidget
from qfluentwidgets.components.widgets.card_widget import CardSeparator
from ui.components.widget import RollingTextWidget