initial fluent-widgets ui
80
examples/window/clock/demo.py
Normal file
@ -0,0 +1,80 @@
|
||||
# coding:utf-8
|
||||
import sys
|
||||
|
||||
from PySide6.QtCore import Qt, QUrl
|
||||
from PySide6.QtGui import QIcon, QDesktopServices
|
||||
from PySide6.QtWidgets import QApplication
|
||||
from qfluentwidgets import (NavigationItemPosition, MessageBox, setTheme, Theme,
|
||||
NavigationAvatarWidget, SplitFluentWindow, FluentTranslator)
|
||||
from qfluentwidgets import FluentIcon as FIF
|
||||
|
||||
from view.focus_interface import FocusInterface
|
||||
from view.stop_watch_interface import StopWatchInterface
|
||||
|
||||
|
||||
class Window(SplitFluentWindow):
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
|
||||
# create sub interface
|
||||
self.focusInterface = FocusInterface(self)
|
||||
self.stopWatchInterface = StopWatchInterface(self)
|
||||
|
||||
self.initNavigation()
|
||||
self.initWindow()
|
||||
|
||||
def initNavigation(self):
|
||||
# add sub interface
|
||||
self.addSubInterface(self.focusInterface, FIF.RINGER, '专注时段')
|
||||
self.addSubInterface(self.stopWatchInterface, FIF.STOP_WATCH, '秒表')
|
||||
|
||||
self.navigationInterface.addWidget(
|
||||
routeKey='avatar',
|
||||
widget=NavigationAvatarWidget('zhiyiYo', 'resource/images/shoko.png'),
|
||||
onClick=self.showMessageBox,
|
||||
position=NavigationItemPosition.BOTTOM,
|
||||
)
|
||||
self.navigationInterface.addItem(
|
||||
routeKey='settingInterface',
|
||||
icon=FIF.SETTING,
|
||||
text='设置',
|
||||
position=NavigationItemPosition.BOTTOM,
|
||||
)
|
||||
|
||||
self.navigationInterface.setExpandWidth(280)
|
||||
|
||||
def initWindow(self):
|
||||
self.resize(900, 700)
|
||||
self.setWindowIcon(QIcon(':/qfluentwidgets/images/logo.png'))
|
||||
self.setWindowTitle('PyQt-Fluent-Widgets')
|
||||
|
||||
desktop = QApplication.screens()[0].availableGeometry()
|
||||
w, h = desktop.width(), desktop.height()
|
||||
self.move(w//2 - self.width()//2, h//2 - self.height()//2)
|
||||
|
||||
def showMessageBox(self):
|
||||
w = MessageBox(
|
||||
'支持作者🥰',
|
||||
'个人开发不易,如果这个项目帮助到了您,可以考虑请作者喝一瓶快乐水🥤。您的支持就是作者开发和维护项目的动力🚀',
|
||||
self
|
||||
)
|
||||
w.yesButton.setText('来啦老弟')
|
||||
w.cancelButton.setText('下次一定')
|
||||
|
||||
if w.exec():
|
||||
QDesktopServices.openUrl(QUrl("https://afdian.net/a/zhiyiYo"))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
setTheme(Theme.DARK)
|
||||
|
||||
app = QApplication(sys.argv)
|
||||
|
||||
# install translator
|
||||
translator = FluentTranslator()
|
||||
app.installTranslator(translator)
|
||||
|
||||
w = Window()
|
||||
w.show()
|
||||
app.exec()
|
||||
BIN
examples/window/clock/resource/images/alarms.png
Normal file
|
After Width: | Height: | Size: 2.4 KiB |
BIN
examples/window/clock/resource/images/shoko.png
Normal file
|
After Width: | Height: | Size: 262 KiB |
BIN
examples/window/clock/resource/images/tips.png
Normal file
|
After Width: | Height: | Size: 18 KiB |
BIN
examples/window/clock/resource/images/todo.png
Normal file
|
After Width: | Height: | Size: 698 B |
7
examples/window/clock/resource/resource.qrc
Normal file
@ -0,0 +1,7 @@
|
||||
<RCC>
|
||||
<qresource>
|
||||
<file>images/todo.png</file>
|
||||
<file>images/alarms.png</file>
|
||||
<file>images/tips.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
1088
examples/window/clock/resource/ui/FocusInterface.ui
Normal file
336
examples/window/clock/resource/ui/StopWatchInterface.ui
Normal file
@ -0,0 +1,336 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>StopWatchInterface</class>
|
||||
<widget class="QWidget" name="StopWatchInterface">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>867</width>
|
||||
<height>781</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item alignment="Qt::AlignHCenter">
|
||||
<widget class="BodyLabel" name="timeLabel">
|
||||
<property name="text">
|
||||
<string>00:00:00</string>
|
||||
</property>
|
||||
<property name="lightColor" stdset="0">
|
||||
<color>
|
||||
<red>96</red>
|
||||
<green>96</green>
|
||||
<blue>96</blue>
|
||||
</color>
|
||||
</property>
|
||||
<property name="darkColor" stdset="0">
|
||||
<color>
|
||||
<red>206</red>
|
||||
<green>206</green>
|
||||
<blue>206</blue>
|
||||
</color>
|
||||
</property>
|
||||
<property name="pixelFontSize" stdset="0">
|
||||
<number>100</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_4">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="TitleLabel" name="hourLabel">
|
||||
<property name="text">
|
||||
<string>小时</string>
|
||||
</property>
|
||||
<property name="lightColor" stdset="0">
|
||||
<color>
|
||||
<red>96</red>
|
||||
<green>96</green>
|
||||
<blue>96</blue>
|
||||
</color>
|
||||
</property>
|
||||
<property name="darkColor" stdset="0">
|
||||
<color>
|
||||
<red>206</red>
|
||||
<green>206</green>
|
||||
<blue>206</blue>
|
||||
</color>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_6">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>60</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="TitleLabel" name="minuteLabel">
|
||||
<property name="text">
|
||||
<string>分钟</string>
|
||||
</property>
|
||||
<property name="lightColor" stdset="0">
|
||||
<color>
|
||||
<red>96</red>
|
||||
<green>96</green>
|
||||
<blue>96</blue>
|
||||
</color>
|
||||
</property>
|
||||
<property name="darkColor" stdset="0">
|
||||
<color>
|
||||
<red>206</red>
|
||||
<green>206</green>
|
||||
<blue>206</blue>
|
||||
</color>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_7">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>90</width>
|
||||
<height>17</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="TitleLabel" name="secondLabel">
|
||||
<property name="text">
|
||||
<string>秒</string>
|
||||
</property>
|
||||
<property name="lightColor" stdset="0">
|
||||
<color>
|
||||
<red>96</red>
|
||||
<green>96</green>
|
||||
<blue>96</blue>
|
||||
</color>
|
||||
</property>
|
||||
<property name="darkColor" stdset="0">
|
||||
<color>
|
||||
<red>206</red>
|
||||
<green>206</green>
|
||||
<blue>206</blue>
|
||||
</color>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_5">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>50</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<property name="spacing">
|
||||
<number>24</number>
|
||||
</property>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="PillToolButton" name="startButton">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>68</width>
|
||||
<height>68</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>21</width>
|
||||
<height>21</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="PillToolButton" name="flagButton">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>68</width>
|
||||
<height>68</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>21</width>
|
||||
<height>21</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="PillToolButton" name="restartButton">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>68</width>
|
||||
<height>68</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>21</width>
|
||||
<height>21</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>ToolButton</class>
|
||||
<extends>QToolButton</extends>
|
||||
<header>qfluentwidgets</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>PillToolButton</class>
|
||||
<extends>ToggleToolButton</extends>
|
||||
<header>qfluentwidgets</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>ToggleToolButton</class>
|
||||
<extends>ToolButton</extends>
|
||||
<header>qfluentwidgets</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>BodyLabel</class>
|
||||
<extends>QLabel</extends>
|
||||
<header>qfluentwidgets</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>TitleLabel</class>
|
||||
<extends>QLabel</extends>
|
||||
<header>qfluentwidgets</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
1408
examples/window/clock/resource_rc.py
Normal file
556
examples/window/clock/view/Ui_FocusInterface.py
Normal file
@ -0,0 +1,556 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
################################################################################
|
||||
## Form generated from reading UI file 'FocusInterface.ui'
|
||||
##
|
||||
## Created by: Qt User Interface Compiler version 6.4.2
|
||||
##
|
||||
## WARNING! All changes made in this file will be lost when recompiling UI file!
|
||||
################################################################################
|
||||
|
||||
from PySide6.QtCore import (QCoreApplication, QDate, QDateTime, QLocale,
|
||||
QMetaObject, QObject, QPoint, QRect,
|
||||
QSize, QTime, QUrl, Qt)
|
||||
from PySide6.QtGui import (QBrush, QColor, QConicalGradient, QCursor,
|
||||
QFont, QFontDatabase, QGradient, QIcon,
|
||||
QImage, QKeySequence, QLinearGradient, QPainter,
|
||||
QPalette, QPixmap, QRadialGradient, QTransform)
|
||||
from PySide6.QtWidgets import (QApplication, QGridLayout, QHBoxLayout, QLayout,
|
||||
QProgressBar, QSizePolicy, QSpacerItem, QVBoxLayout,
|
||||
QWidget)
|
||||
|
||||
from qfluentwidgets import (BodyLabel, CardWidget, CheckBox, IconWidget,
|
||||
LargeTitleLabel, PrimaryPushButton, ProgressBar, ProgressRing,
|
||||
PushButton, StrongBodyLabel, SubtitleLabel, TimePicker,
|
||||
ToolButton, TransparentToolButton)
|
||||
import resource_rc
|
||||
|
||||
class Ui_FocusInterface(object):
|
||||
def setupUi(self, FocusInterface):
|
||||
if not FocusInterface.objectName():
|
||||
FocusInterface.setObjectName(u"FocusInterface")
|
||||
FocusInterface.resize(911, 807)
|
||||
self.horizontalLayout_3 = QHBoxLayout(FocusInterface)
|
||||
self.horizontalLayout_3.setObjectName(u"horizontalLayout_3")
|
||||
self.gridLayout = QGridLayout()
|
||||
self.gridLayout.setSpacing(12)
|
||||
self.gridLayout.setObjectName(u"gridLayout")
|
||||
self.gridLayout.setSizeConstraint(QLayout.SetDefaultConstraint)
|
||||
self.gridLayout.setContentsMargins(20, 40, 20, 20)
|
||||
self.progressCard = CardWidget(FocusInterface)
|
||||
self.progressCard.setObjectName(u"progressCard")
|
||||
sizePolicy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
|
||||
sizePolicy.setHorizontalStretch(0)
|
||||
sizePolicy.setVerticalStretch(0)
|
||||
sizePolicy.setHeightForWidth(self.progressCard.sizePolicy().hasHeightForWidth())
|
||||
self.progressCard.setSizePolicy(sizePolicy)
|
||||
self.progressCard.setMinimumSize(QSize(380, 410))
|
||||
self.progressCard.setMaximumSize(QSize(600, 410))
|
||||
self.verticalLayout_4 = QVBoxLayout(self.progressCard)
|
||||
self.verticalLayout_4.setObjectName(u"verticalLayout_4")
|
||||
self.verticalLayout_4.setSizeConstraint(QLayout.SetDefaultConstraint)
|
||||
self.verticalLayout_2 = QVBoxLayout()
|
||||
self.verticalLayout_2.setObjectName(u"verticalLayout_2")
|
||||
self.verticalLayout_2.setSizeConstraint(QLayout.SetMinAndMaxSize)
|
||||
self.horizontalLayout_4 = QHBoxLayout()
|
||||
self.horizontalLayout_4.setObjectName(u"horizontalLayout_4")
|
||||
self.horizontalLayout_4.setContentsMargins(5, -1, -1, -1)
|
||||
self.progressIcon = IconWidget(self.progressCard)
|
||||
self.progressIcon.setObjectName(u"progressIcon")
|
||||
self.progressIcon.setMinimumSize(QSize(18, 18))
|
||||
self.progressIcon.setMaximumSize(QSize(18, 18))
|
||||
icon = QIcon()
|
||||
icon.addFile(u":/images/tips.png", QSize(), QIcon.Normal, QIcon.Off)
|
||||
self.progressIcon.setIcon(icon)
|
||||
|
||||
self.horizontalLayout_4.addWidget(self.progressIcon)
|
||||
|
||||
self.horizontalSpacer_8 = QSpacerItem(2, 20, QSizePolicy.Fixed, QSizePolicy.Minimum)
|
||||
|
||||
self.horizontalLayout_4.addItem(self.horizontalSpacer_8)
|
||||
|
||||
self.dailyProgressLabel = StrongBodyLabel(self.progressCard)
|
||||
self.dailyProgressLabel.setObjectName(u"dailyProgressLabel")
|
||||
|
||||
self.horizontalLayout_4.addWidget(self.dailyProgressLabel)
|
||||
|
||||
self.horizontalSpacer_9 = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)
|
||||
|
||||
self.horizontalLayout_4.addItem(self.horizontalSpacer_9)
|
||||
|
||||
self.editButton = TransparentToolButton(self.progressCard)
|
||||
self.editButton.setObjectName(u"editButton")
|
||||
|
||||
self.horizontalLayout_4.addWidget(self.editButton, 0, Qt.AlignRight)
|
||||
|
||||
|
||||
self.verticalLayout_2.addLayout(self.horizontalLayout_4)
|
||||
|
||||
self.horizontalLayout_5 = QHBoxLayout()
|
||||
self.horizontalLayout_5.setObjectName(u"horizontalLayout_5")
|
||||
self.horizontalLayout_5.setSizeConstraint(QLayout.SetMinAndMaxSize)
|
||||
self.verticalLayout_5 = QVBoxLayout()
|
||||
self.verticalLayout_5.setObjectName(u"verticalLayout_5")
|
||||
self.verticalSpacer_5 = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding)
|
||||
|
||||
self.verticalLayout_5.addItem(self.verticalSpacer_5)
|
||||
|
||||
self.yesterdayLabel = BodyLabel(self.progressCard)
|
||||
self.yesterdayLabel.setObjectName(u"yesterdayLabel")
|
||||
|
||||
self.verticalLayout_5.addWidget(self.yesterdayLabel, 0, Qt.AlignHCenter|Qt.AlignVCenter)
|
||||
|
||||
self.yesterdayTimeLabel = LargeTitleLabel(self.progressCard)
|
||||
self.yesterdayTimeLabel.setObjectName(u"yesterdayTimeLabel")
|
||||
|
||||
self.verticalLayout_5.addWidget(self.yesterdayTimeLabel, 0, Qt.AlignHCenter|Qt.AlignVCenter)
|
||||
|
||||
self.minuteLabel1 = BodyLabel(self.progressCard)
|
||||
self.minuteLabel1.setObjectName(u"minuteLabel1")
|
||||
|
||||
self.verticalLayout_5.addWidget(self.minuteLabel1, 0, Qt.AlignHCenter|Qt.AlignVCenter)
|
||||
|
||||
self.verticalSpacer_6 = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding)
|
||||
|
||||
self.verticalLayout_5.addItem(self.verticalSpacer_6)
|
||||
|
||||
|
||||
self.horizontalLayout_5.addLayout(self.verticalLayout_5)
|
||||
|
||||
self.verticalLayout_10 = QVBoxLayout()
|
||||
self.verticalLayout_10.setObjectName(u"verticalLayout_10")
|
||||
self.verticalSpacer_15 = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding)
|
||||
|
||||
self.verticalLayout_10.addItem(self.verticalSpacer_15)
|
||||
|
||||
self.targetLabel = SubtitleLabel(self.progressCard)
|
||||
self.targetLabel.setObjectName(u"targetLabel")
|
||||
self.targetLabel.setAlignment(Qt.AlignCenter)
|
||||
|
||||
self.verticalLayout_10.addWidget(self.targetLabel)
|
||||
|
||||
self.progressRing = ProgressRing(self.progressCard)
|
||||
self.progressRing.setObjectName(u"progressRing")
|
||||
sizePolicy1 = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
|
||||
sizePolicy1.setHorizontalStretch(1)
|
||||
sizePolicy1.setVerticalStretch(1)
|
||||
sizePolicy1.setHeightForWidth(self.progressRing.sizePolicy().hasHeightForWidth())
|
||||
self.progressRing.setSizePolicy(sizePolicy1)
|
||||
self.progressRing.setMinimumSize(QSize(150, 150))
|
||||
self.progressRing.setMaximumSize(QSize(220, 220))
|
||||
font = QFont()
|
||||
font.setFamilies([u"Microsoft YaHei UI"])
|
||||
font.setPointSize(10)
|
||||
font.setBold(False)
|
||||
self.progressRing.setFont(font)
|
||||
self.progressRing.setMaximum(24)
|
||||
self.progressRing.setValue(10)
|
||||
self.progressRing.setAlignment(Qt.AlignCenter)
|
||||
self.progressRing.setTextVisible(True)
|
||||
self.progressRing.setOrientation(Qt.Horizontal)
|
||||
self.progressRing.setTextDirection(QProgressBar.TopToBottom)
|
||||
self.progressRing.setUseAni(False)
|
||||
self.progressRing.setVal(10.000000000000000)
|
||||
self.progressRing.setStrokeWidth(15)
|
||||
|
||||
self.verticalLayout_10.addWidget(self.progressRing)
|
||||
|
||||
self.verticalSpacer_16 = QSpacerItem(20, 3, QSizePolicy.Minimum, QSizePolicy.Fixed)
|
||||
|
||||
self.verticalLayout_10.addItem(self.verticalSpacer_16)
|
||||
|
||||
self.finishTimeLabel = BodyLabel(self.progressCard)
|
||||
self.finishTimeLabel.setObjectName(u"finishTimeLabel")
|
||||
|
||||
self.verticalLayout_10.addWidget(self.finishTimeLabel, 0, Qt.AlignHCenter)
|
||||
|
||||
self.verticalSpacer_13 = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding)
|
||||
|
||||
self.verticalLayout_10.addItem(self.verticalSpacer_13)
|
||||
|
||||
self.verticalLayout_10.setStretch(2, 1)
|
||||
|
||||
self.horizontalLayout_5.addLayout(self.verticalLayout_10)
|
||||
|
||||
self.verticalLayout_6 = QVBoxLayout()
|
||||
self.verticalLayout_6.setObjectName(u"verticalLayout_6")
|
||||
self.verticalSpacer_9 = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding)
|
||||
|
||||
self.verticalLayout_6.addItem(self.verticalSpacer_9)
|
||||
|
||||
self.continousComplianceDayLabel = BodyLabel(self.progressCard)
|
||||
self.continousComplianceDayLabel.setObjectName(u"continousComplianceDayLabel")
|
||||
|
||||
self.verticalLayout_6.addWidget(self.continousComplianceDayLabel, 0, Qt.AlignHCenter|Qt.AlignVCenter)
|
||||
|
||||
self.compianceDayLabel = LargeTitleLabel(self.progressCard)
|
||||
self.compianceDayLabel.setObjectName(u"compianceDayLabel")
|
||||
|
||||
self.verticalLayout_6.addWidget(self.compianceDayLabel, 0, Qt.AlignHCenter)
|
||||
|
||||
self.dayLabel = BodyLabel(self.progressCard)
|
||||
self.dayLabel.setObjectName(u"dayLabel")
|
||||
|
||||
self.verticalLayout_6.addWidget(self.dayLabel, 0, Qt.AlignHCenter)
|
||||
|
||||
self.verticalSpacer_10 = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding)
|
||||
|
||||
self.verticalLayout_6.addItem(self.verticalSpacer_10)
|
||||
|
||||
|
||||
self.horizontalLayout_5.addLayout(self.verticalLayout_6)
|
||||
|
||||
self.horizontalLayout_5.setStretch(0, 1)
|
||||
self.horizontalLayout_5.setStretch(1, 2)
|
||||
self.horizontalLayout_5.setStretch(2, 1)
|
||||
|
||||
self.verticalLayout_2.addLayout(self.horizontalLayout_5)
|
||||
|
||||
|
||||
self.verticalLayout_4.addLayout(self.verticalLayout_2)
|
||||
|
||||
|
||||
self.gridLayout.addWidget(self.progressCard, 0, 1, 1, 1)
|
||||
|
||||
self.focusCard = CardWidget(FocusInterface)
|
||||
self.focusCard.setObjectName(u"focusCard")
|
||||
sizePolicy.setHeightForWidth(self.focusCard.sizePolicy().hasHeightForWidth())
|
||||
self.focusCard.setSizePolicy(sizePolicy)
|
||||
self.focusCard.setMinimumSize(QSize(380, 410))
|
||||
self.focusCard.setMaximumSize(QSize(600, 410))
|
||||
self.focusCard.setStyleSheet(u"")
|
||||
self.verticalLayout_3 = QVBoxLayout(self.focusCard)
|
||||
self.verticalLayout_3.setObjectName(u"verticalLayout_3")
|
||||
self.verticalLayout_3.setSizeConstraint(QLayout.SetDefaultConstraint)
|
||||
self.verticalLayout = QVBoxLayout()
|
||||
self.verticalLayout.setObjectName(u"verticalLayout")
|
||||
self.verticalLayout.setSizeConstraint(QLayout.SetDefaultConstraint)
|
||||
self.horizontalLayout_2 = QHBoxLayout()
|
||||
self.horizontalLayout_2.setObjectName(u"horizontalLayout_2")
|
||||
self.horizontalLayout_2.setContentsMargins(5, -1, -1, -1)
|
||||
self.focusCardIcon = IconWidget(self.focusCard)
|
||||
self.focusCardIcon.setObjectName(u"focusCardIcon")
|
||||
self.focusCardIcon.setMinimumSize(QSize(20, 20))
|
||||
self.focusCardIcon.setMaximumSize(QSize(20, 20))
|
||||
icon1 = QIcon()
|
||||
icon1.addFile(u":/images/alarms.png", QSize(), QIcon.Normal, QIcon.Off)
|
||||
self.focusCardIcon.setIcon(icon1)
|
||||
|
||||
self.horizontalLayout_2.addWidget(self.focusCardIcon)
|
||||
|
||||
self.focusPeriodLabel = StrongBodyLabel(self.focusCard)
|
||||
self.focusPeriodLabel.setObjectName(u"focusPeriodLabel")
|
||||
|
||||
self.horizontalLayout_2.addWidget(self.focusPeriodLabel)
|
||||
|
||||
self.horizontalSpacer = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)
|
||||
|
||||
self.horizontalLayout_2.addItem(self.horizontalSpacer)
|
||||
|
||||
self.pinButton = TransparentToolButton(self.focusCard)
|
||||
self.pinButton.setObjectName(u"pinButton")
|
||||
|
||||
self.horizontalLayout_2.addWidget(self.pinButton)
|
||||
|
||||
self.moreButton = TransparentToolButton(self.focusCard)
|
||||
self.moreButton.setObjectName(u"moreButton")
|
||||
|
||||
self.horizontalLayout_2.addWidget(self.moreButton)
|
||||
|
||||
|
||||
self.verticalLayout.addLayout(self.horizontalLayout_2)
|
||||
|
||||
self.verticalSpacer_12 = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding)
|
||||
|
||||
self.verticalLayout.addItem(self.verticalSpacer_12)
|
||||
|
||||
self.prepareFocusLabel = SubtitleLabel(self.focusCard)
|
||||
self.prepareFocusLabel.setObjectName(u"prepareFocusLabel")
|
||||
self.prepareFocusLabel.setAlignment(Qt.AlignCenter)
|
||||
|
||||
self.verticalLayout.addWidget(self.prepareFocusLabel)
|
||||
|
||||
self.horizontalLayout_6 = QHBoxLayout()
|
||||
self.horizontalLayout_6.setObjectName(u"horizontalLayout_6")
|
||||
self.horizontalLayout_6.setContentsMargins(15, 10, 15, -1)
|
||||
self.hintLabel = BodyLabel(self.focusCard)
|
||||
self.hintLabel.setObjectName(u"hintLabel")
|
||||
self.hintLabel.setAlignment(Qt.AlignCenter)
|
||||
self.hintLabel.setWordWrap(True)
|
||||
self.hintLabel.setMargin(0)
|
||||
self.hintLabel.setProperty("lightColor", QColor(96, 96, 96))
|
||||
self.hintLabel.setProperty("darkColor", QColor(206, 206, 206))
|
||||
|
||||
self.horizontalLayout_6.addWidget(self.hintLabel)
|
||||
|
||||
|
||||
self.verticalLayout.addLayout(self.horizontalLayout_6)
|
||||
|
||||
self.verticalSpacer_2 = QSpacerItem(20, 20, QSizePolicy.Minimum, QSizePolicy.Fixed)
|
||||
|
||||
self.verticalLayout.addItem(self.verticalSpacer_2)
|
||||
|
||||
self.timePicker = TimePicker(self.focusCard)
|
||||
self.timePicker.setObjectName(u"timePicker")
|
||||
self.timePicker.setSecondVisible(True)
|
||||
|
||||
self.verticalLayout.addWidget(self.timePicker, 0, Qt.AlignHCenter)
|
||||
|
||||
self.verticalSpacer_3 = QSpacerItem(20, 10, QSizePolicy.Minimum, QSizePolicy.Fixed)
|
||||
|
||||
self.verticalLayout.addItem(self.verticalSpacer_3)
|
||||
|
||||
self.bottomHintLabel = BodyLabel(self.focusCard)
|
||||
self.bottomHintLabel.setObjectName(u"bottomHintLabel")
|
||||
self.bottomHintLabel.setAlignment(Qt.AlignCenter)
|
||||
|
||||
self.verticalLayout.addWidget(self.bottomHintLabel, 0, Qt.AlignHCenter)
|
||||
|
||||
self.verticalSpacer_11 = QSpacerItem(20, 10, QSizePolicy.Minimum, QSizePolicy.Fixed)
|
||||
|
||||
self.verticalLayout.addItem(self.verticalSpacer_11)
|
||||
|
||||
self.skipRelaxCheckBox = CheckBox(self.focusCard)
|
||||
self.skipRelaxCheckBox.setObjectName(u"skipRelaxCheckBox")
|
||||
self.skipRelaxCheckBox.setEnabled(True)
|
||||
|
||||
self.verticalLayout.addWidget(self.skipRelaxCheckBox, 0, Qt.AlignHCenter)
|
||||
|
||||
self.verticalSpacer_4 = QSpacerItem(20, 20, QSizePolicy.Minimum, QSizePolicy.Fixed)
|
||||
|
||||
self.verticalLayout.addItem(self.verticalSpacer_4)
|
||||
|
||||
self.startFocusButton = PrimaryPushButton(self.focusCard)
|
||||
self.startFocusButton.setObjectName(u"startFocusButton")
|
||||
self.startFocusButton.setAutoDefault(True)
|
||||
|
||||
self.verticalLayout.addWidget(self.startFocusButton, 0, Qt.AlignHCenter)
|
||||
|
||||
self.verticalSpacer = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding)
|
||||
|
||||
self.verticalLayout.addItem(self.verticalSpacer)
|
||||
|
||||
|
||||
self.verticalLayout_3.addLayout(self.verticalLayout)
|
||||
|
||||
|
||||
self.gridLayout.addWidget(self.focusCard, 0, 0, 1, 1)
|
||||
|
||||
self.taskCard = CardWidget(FocusInterface)
|
||||
self.taskCard.setObjectName(u"taskCard")
|
||||
self.taskCard.setMinimumSize(QSize(370, 0))
|
||||
self.taskCard.setMaximumSize(QSize(600, 395))
|
||||
self.verticalLayout_8 = QVBoxLayout(self.taskCard)
|
||||
self.verticalLayout_8.setObjectName(u"verticalLayout_8")
|
||||
self.verticalLayout_7 = QVBoxLayout()
|
||||
self.verticalLayout_7.setObjectName(u"verticalLayout_7")
|
||||
self.verticalLayout_7.setContentsMargins(8, -1, -1, -1)
|
||||
self.horizontalLayout_7 = QHBoxLayout()
|
||||
self.horizontalLayout_7.setObjectName(u"horizontalLayout_7")
|
||||
self.taskCardIcon = IconWidget(self.taskCard)
|
||||
self.taskCardIcon.setObjectName(u"taskCardIcon")
|
||||
self.taskCardIcon.setMinimumSize(QSize(18, 18))
|
||||
self.taskCardIcon.setMaximumSize(QSize(18, 18))
|
||||
icon2 = QIcon()
|
||||
icon2.addFile(u":/images/todo.png", QSize(), QIcon.Normal, QIcon.Off)
|
||||
self.taskCardIcon.setIcon(icon2)
|
||||
|
||||
self.horizontalLayout_7.addWidget(self.taskCardIcon)
|
||||
|
||||
self.horizontalSpacer_7 = QSpacerItem(2, 2, QSizePolicy.Fixed, QSizePolicy.Minimum)
|
||||
|
||||
self.horizontalLayout_7.addItem(self.horizontalSpacer_7)
|
||||
|
||||
self.taskLabel = StrongBodyLabel(self.taskCard)
|
||||
self.taskLabel.setObjectName(u"taskLabel")
|
||||
|
||||
self.horizontalLayout_7.addWidget(self.taskLabel)
|
||||
|
||||
self.horizontalSpacer_3 = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)
|
||||
|
||||
self.horizontalLayout_7.addItem(self.horizontalSpacer_3)
|
||||
|
||||
self.addTaskButton = TransparentToolButton(self.taskCard)
|
||||
self.addTaskButton.setObjectName(u"addTaskButton")
|
||||
|
||||
self.horizontalLayout_7.addWidget(self.addTaskButton)
|
||||
|
||||
self.moreTaskButton = TransparentToolButton(self.taskCard)
|
||||
self.moreTaskButton.setObjectName(u"moreTaskButton")
|
||||
|
||||
self.horizontalLayout_7.addWidget(self.moreTaskButton)
|
||||
|
||||
|
||||
self.verticalLayout_7.addLayout(self.horizontalLayout_7)
|
||||
|
||||
self.verticalSpacer_8 = QSpacerItem(20, 3, QSizePolicy.Minimum, QSizePolicy.Fixed)
|
||||
|
||||
self.verticalLayout_7.addItem(self.verticalSpacer_8)
|
||||
|
||||
self.hintLabel_2 = BodyLabel(self.taskCard)
|
||||
self.hintLabel_2.setObjectName(u"hintLabel_2")
|
||||
self.hintLabel_2.setProperty("lightColor", QColor(96, 96, 96))
|
||||
self.hintLabel_2.setProperty("darkColor", QColor(206, 206, 206))
|
||||
|
||||
self.verticalLayout_7.addWidget(self.hintLabel_2)
|
||||
|
||||
self.verticalLayout_9 = QVBoxLayout()
|
||||
self.verticalLayout_9.setObjectName(u"verticalLayout_9")
|
||||
self.verticalLayout_9.setContentsMargins(-1, -1, 7, -1)
|
||||
self.taskCard1 = CardWidget(self.taskCard)
|
||||
self.taskCard1.setObjectName(u"taskCard1")
|
||||
self.taskCard1.setMinimumSize(QSize(0, 44))
|
||||
self.taskCard1.setMaximumSize(QSize(16777215, 44))
|
||||
self.horizontalLayout_9 = QHBoxLayout(self.taskCard1)
|
||||
self.horizontalLayout_9.setObjectName(u"horizontalLayout_9")
|
||||
self.horizontalLayout_9.setContentsMargins(15, -1, -1, -1)
|
||||
self.horizontalLayout_8 = QHBoxLayout()
|
||||
self.horizontalLayout_8.setObjectName(u"horizontalLayout_8")
|
||||
self.taskIcon1 = IconWidget(self.taskCard1)
|
||||
self.taskIcon1.setObjectName(u"taskIcon1")
|
||||
sizePolicy2 = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)
|
||||
sizePolicy2.setHorizontalStretch(16)
|
||||
sizePolicy2.setVerticalStretch(16)
|
||||
sizePolicy2.setHeightForWidth(self.taskIcon1.sizePolicy().hasHeightForWidth())
|
||||
self.taskIcon1.setSizePolicy(sizePolicy2)
|
||||
self.taskIcon1.setMinimumSize(QSize(16, 16))
|
||||
self.taskIcon1.setMaximumSize(QSize(16, 16))
|
||||
|
||||
self.horizontalLayout_8.addWidget(self.taskIcon1)
|
||||
|
||||
|
||||
self.horizontalLayout_9.addLayout(self.horizontalLayout_8)
|
||||
|
||||
self.taskLabel1 = BodyLabel(self.taskCard1)
|
||||
self.taskLabel1.setObjectName(u"taskLabel1")
|
||||
self.taskLabel1.setProperty("pixelFontSize", 14)
|
||||
self.taskLabel1.setProperty("strikeOut", True)
|
||||
|
||||
self.horizontalLayout_9.addWidget(self.taskLabel1)
|
||||
|
||||
self.horizontalSpacer_4 = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)
|
||||
|
||||
self.horizontalLayout_9.addItem(self.horizontalSpacer_4)
|
||||
|
||||
|
||||
self.verticalLayout_9.addWidget(self.taskCard1)
|
||||
|
||||
self.taskCard2 = CardWidget(self.taskCard)
|
||||
self.taskCard2.setObjectName(u"taskCard2")
|
||||
self.taskCard2.setMinimumSize(QSize(0, 44))
|
||||
self.taskCard2.setMaximumSize(QSize(16777215, 44))
|
||||
self.horizontalLayout_12 = QHBoxLayout(self.taskCard2)
|
||||
self.horizontalLayout_12.setObjectName(u"horizontalLayout_12")
|
||||
self.horizontalLayout_12.setContentsMargins(15, -1, -1, -1)
|
||||
self.horizontalLayout_13 = QHBoxLayout()
|
||||
self.horizontalLayout_13.setObjectName(u"horizontalLayout_13")
|
||||
self.taskIcon2 = IconWidget(self.taskCard2)
|
||||
self.taskIcon2.setObjectName(u"taskIcon2")
|
||||
sizePolicy2.setHeightForWidth(self.taskIcon2.sizePolicy().hasHeightForWidth())
|
||||
self.taskIcon2.setSizePolicy(sizePolicy2)
|
||||
self.taskIcon2.setMinimumSize(QSize(16, 16))
|
||||
self.taskIcon2.setMaximumSize(QSize(16, 16))
|
||||
|
||||
self.horizontalLayout_13.addWidget(self.taskIcon2)
|
||||
|
||||
|
||||
self.horizontalLayout_12.addLayout(self.horizontalLayout_13)
|
||||
|
||||
self.taskLabel2 = BodyLabel(self.taskCard2)
|
||||
self.taskLabel2.setObjectName(u"taskLabel2")
|
||||
|
||||
self.horizontalLayout_12.addWidget(self.taskLabel2)
|
||||
|
||||
self.horizontalSpacer_6 = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)
|
||||
|
||||
self.horizontalLayout_12.addItem(self.horizontalSpacer_6)
|
||||
|
||||
|
||||
self.verticalLayout_9.addWidget(self.taskCard2)
|
||||
|
||||
self.taskCard3 = CardWidget(self.taskCard)
|
||||
self.taskCard3.setObjectName(u"taskCard3")
|
||||
self.taskCard3.setMinimumSize(QSize(0, 44))
|
||||
self.taskCard3.setMaximumSize(QSize(16777215, 44))
|
||||
self.horizontalLayout_10 = QHBoxLayout(self.taskCard3)
|
||||
self.horizontalLayout_10.setObjectName(u"horizontalLayout_10")
|
||||
self.horizontalLayout_10.setContentsMargins(15, -1, -1, -1)
|
||||
self.horizontalLayout_11 = QHBoxLayout()
|
||||
self.horizontalLayout_11.setObjectName(u"horizontalLayout_11")
|
||||
self.taskIcon3 = IconWidget(self.taskCard3)
|
||||
self.taskIcon3.setObjectName(u"taskIcon3")
|
||||
sizePolicy2.setHeightForWidth(self.taskIcon3.sizePolicy().hasHeightForWidth())
|
||||
self.taskIcon3.setSizePolicy(sizePolicy2)
|
||||
self.taskIcon3.setMinimumSize(QSize(16, 16))
|
||||
self.taskIcon3.setMaximumSize(QSize(16, 16))
|
||||
|
||||
self.horizontalLayout_11.addWidget(self.taskIcon3)
|
||||
|
||||
|
||||
self.horizontalLayout_10.addLayout(self.horizontalLayout_11)
|
||||
|
||||
self.taskLabel3 = BodyLabel(self.taskCard3)
|
||||
self.taskLabel3.setObjectName(u"taskLabel3")
|
||||
|
||||
self.horizontalLayout_10.addWidget(self.taskLabel3)
|
||||
|
||||
self.horizontalSpacer_5 = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)
|
||||
|
||||
self.horizontalLayout_10.addItem(self.horizontalSpacer_5)
|
||||
|
||||
|
||||
self.verticalLayout_9.addWidget(self.taskCard3)
|
||||
|
||||
|
||||
self.verticalLayout_7.addLayout(self.verticalLayout_9)
|
||||
|
||||
self.verticalSpacer_7 = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding)
|
||||
|
||||
self.verticalLayout_7.addItem(self.verticalSpacer_7)
|
||||
|
||||
|
||||
self.verticalLayout_8.addLayout(self.verticalLayout_7)
|
||||
|
||||
|
||||
self.gridLayout.addWidget(self.taskCard, 1, 0, 1, 1)
|
||||
|
||||
self.horizontalSpacer_2 = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)
|
||||
|
||||
self.gridLayout.addItem(self.horizontalSpacer_2, 0, 2, 1, 1)
|
||||
|
||||
self.gridLayout.setColumnStretch(0, 1)
|
||||
self.gridLayout.setColumnStretch(1, 1)
|
||||
|
||||
self.horizontalLayout_3.addLayout(self.gridLayout)
|
||||
|
||||
|
||||
self.retranslateUi(FocusInterface)
|
||||
|
||||
QMetaObject.connectSlotsByName(FocusInterface)
|
||||
# setupUi
|
||||
|
||||
def retranslateUi(self, FocusInterface):
|
||||
FocusInterface.setWindowTitle(QCoreApplication.translate("FocusInterface", u"Form", None))
|
||||
self.dailyProgressLabel.setText(QCoreApplication.translate("FocusInterface", u"\u6bcf\u65e5\u8fdb\u5ea6", None))
|
||||
self.yesterdayLabel.setText(QCoreApplication.translate("FocusInterface", u"\u6628\u5929", None))
|
||||
self.yesterdayTimeLabel.setText(QCoreApplication.translate("FocusInterface", u"3", None))
|
||||
self.minuteLabel1.setText(QCoreApplication.translate("FocusInterface", u"\u5206\u949f", None))
|
||||
self.targetLabel.setText(QCoreApplication.translate("FocusInterface", u"\u4eca\u65e5\u8ba1\u5212", None))
|
||||
self.progressRing.setFormat(QCoreApplication.translate("FocusInterface", u"\u76ee\u6807 %v \u5c0f\u65f6", None))
|
||||
self.finishTimeLabel.setText(QCoreApplication.translate("FocusInterface", u"\u5df2\u5b8c\u6210\uff1a0 \u5206\u949f", None))
|
||||
self.continousComplianceDayLabel.setText(QCoreApplication.translate("FocusInterface", u"\u8fde\u7eed\u8fbe\u6807\u65e5", None))
|
||||
self.compianceDayLabel.setText(QCoreApplication.translate("FocusInterface", u"5", None))
|
||||
self.dayLabel.setText(QCoreApplication.translate("FocusInterface", u"\u5929", None))
|
||||
self.focusPeriodLabel.setText(QCoreApplication.translate("FocusInterface", u"\u4e13\u6ce8\u65f6\u6bb5", None))
|
||||
self.prepareFocusLabel.setText(QCoreApplication.translate("FocusInterface", u"\u51c6\u5907\u4e13\u6ce8", None))
|
||||
self.hintLabel.setText(QCoreApplication.translate("FocusInterface", u"\u6211\u4eec\u5c06\u5728\u6bcf\u4e2a\u4f1a\u8bdd\u671f\u95f4\u5173\u95ed\u901a\u77e5\u548c\u5e94\u7528\u8b66\u62a5\u3002\u5bf9\u4e8e\u8f83\u957f\u7684\u4f1a\u8bdd\uff0c\u6211\u4eec\u5c06\u6dfb\u52a0\u7b80\u77ed\u7684\u4f11\u606f\u65f6\u95f4\uff0c\u4ee5\u4fbf\u4f60\u53ef\u4ee5\u6062\u590d\u7cbe\u529b\u3002", None))
|
||||
self.bottomHintLabel.setText(QCoreApplication.translate("FocusInterface", u"\u4f60\u5c06\u6ca1\u6709\u4f11\u606f\u65f6\u95f4\u3002", None))
|
||||
self.skipRelaxCheckBox.setText(QCoreApplication.translate("FocusInterface", u"\u8df3\u8fc7\u4f11\u606f", None))
|
||||
self.startFocusButton.setText(QCoreApplication.translate("FocusInterface", u"\u542f\u52a8\u4e13\u6ce8\u65f6\u6bb5", None))
|
||||
self.taskLabel.setText(QCoreApplication.translate("FocusInterface", u"\u4efb\u52a1", None))
|
||||
self.hintLabel_2.setText(QCoreApplication.translate("FocusInterface", u"\u4e3a\u4f1a\u8bdd\u9009\u62e9\u4efb\u52a1", None))
|
||||
self.taskLabel1.setText(QCoreApplication.translate("FocusInterface", u"\u5168\u519b\u51fa\u9e21\uff0c\u8a93\u6b7b\u4fdd\u536b\u9e3d\u9e3d\uff01\uff01", None))
|
||||
self.taskLabel2.setText(QCoreApplication.translate("FocusInterface", u"\u4e0a\u4f20\u6211\u5bb6 aiko \u7684 MV\u300e\u30b7\u30a2\u30ef\u30bb\u300f", None))
|
||||
self.taskLabel3.setText(QCoreApplication.translate("FocusInterface", u"\u4e0b\u8f7d\u6211\u5bb6 aiko \u7684\u65b0\u6b4c\u300e\u8352\u308c\u305f\u5507\u306f\u604b\u3092\u5931\u304f\u3059\u300f", None))
|
||||
# retranslateUi
|
||||
|
||||
150
examples/window/clock/view/Ui_StopWatchInterface.py
Normal file
@ -0,0 +1,150 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
################################################################################
|
||||
## Form generated from reading UI file 'StopWatchInterface.ui'
|
||||
##
|
||||
## Created by: Qt User Interface Compiler version 6.4.2
|
||||
##
|
||||
## WARNING! All changes made in this file will be lost when recompiling UI file!
|
||||
################################################################################
|
||||
|
||||
from PySide6.QtCore import (QCoreApplication, QDate, QDateTime, QLocale,
|
||||
QMetaObject, QObject, QPoint, QRect,
|
||||
QSize, QTime, QUrl, Qt)
|
||||
from PySide6.QtGui import (QBrush, QColor, QConicalGradient, QCursor,
|
||||
QFont, QFontDatabase, QGradient, QIcon,
|
||||
QImage, QKeySequence, QLinearGradient, QPainter,
|
||||
QPalette, QPixmap, QRadialGradient, QTransform)
|
||||
from PySide6.QtWidgets import (QApplication, QHBoxLayout, QSizePolicy, QSpacerItem,
|
||||
QVBoxLayout, QWidget)
|
||||
|
||||
from qfluentwidgets import (BodyLabel, PillToolButton, TitleLabel, ToggleToolButton,
|
||||
ToolButton)
|
||||
|
||||
class Ui_StopWatchInterface(object):
|
||||
def setupUi(self, StopWatchInterface):
|
||||
if not StopWatchInterface.objectName():
|
||||
StopWatchInterface.setObjectName(u"StopWatchInterface")
|
||||
StopWatchInterface.resize(867, 781)
|
||||
self.verticalLayout_2 = QVBoxLayout(StopWatchInterface)
|
||||
self.verticalLayout_2.setObjectName(u"verticalLayout_2")
|
||||
self.verticalLayout = QVBoxLayout()
|
||||
self.verticalLayout.setSpacing(0)
|
||||
self.verticalLayout.setObjectName(u"verticalLayout")
|
||||
self.verticalSpacer = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding)
|
||||
|
||||
self.verticalLayout.addItem(self.verticalSpacer)
|
||||
|
||||
self.timeLabel = BodyLabel(StopWatchInterface)
|
||||
self.timeLabel.setObjectName(u"timeLabel")
|
||||
self.timeLabel.setProperty("lightColor", QColor(96, 96, 96))
|
||||
self.timeLabel.setProperty("darkColor", QColor(206, 206, 206))
|
||||
self.timeLabel.setProperty("pixelFontSize", 100)
|
||||
|
||||
self.verticalLayout.addWidget(self.timeLabel, 0, Qt.AlignHCenter)
|
||||
|
||||
self.horizontalLayout_3 = QHBoxLayout()
|
||||
self.horizontalLayout_3.setObjectName(u"horizontalLayout_3")
|
||||
self.horizontalSpacer_4 = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)
|
||||
|
||||
self.horizontalLayout_3.addItem(self.horizontalSpacer_4)
|
||||
|
||||
self.hourLabel = TitleLabel(StopWatchInterface)
|
||||
self.hourLabel.setObjectName(u"hourLabel")
|
||||
self.hourLabel.setProperty("lightColor", QColor(96, 96, 96))
|
||||
self.hourLabel.setProperty("darkColor", QColor(206, 206, 206))
|
||||
|
||||
self.horizontalLayout_3.addWidget(self.hourLabel)
|
||||
|
||||
self.horizontalSpacer_6 = QSpacerItem(60, 20, QSizePolicy.Fixed, QSizePolicy.Minimum)
|
||||
|
||||
self.horizontalLayout_3.addItem(self.horizontalSpacer_6)
|
||||
|
||||
self.minuteLabel = TitleLabel(StopWatchInterface)
|
||||
self.minuteLabel.setObjectName(u"minuteLabel")
|
||||
self.minuteLabel.setProperty("lightColor", QColor(96, 96, 96))
|
||||
self.minuteLabel.setProperty("darkColor", QColor(206, 206, 206))
|
||||
|
||||
self.horizontalLayout_3.addWidget(self.minuteLabel)
|
||||
|
||||
self.horizontalSpacer_7 = QSpacerItem(90, 17, QSizePolicy.Fixed, QSizePolicy.Minimum)
|
||||
|
||||
self.horizontalLayout_3.addItem(self.horizontalSpacer_7)
|
||||
|
||||
self.secondLabel = TitleLabel(StopWatchInterface)
|
||||
self.secondLabel.setObjectName(u"secondLabel")
|
||||
self.secondLabel.setProperty("lightColor", QColor(96, 96, 96))
|
||||
self.secondLabel.setProperty("darkColor", QColor(206, 206, 206))
|
||||
|
||||
self.horizontalLayout_3.addWidget(self.secondLabel)
|
||||
|
||||
self.horizontalSpacer_5 = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)
|
||||
|
||||
self.horizontalLayout_3.addItem(self.horizontalSpacer_5)
|
||||
|
||||
|
||||
self.verticalLayout.addLayout(self.horizontalLayout_3)
|
||||
|
||||
self.verticalSpacer_3 = QSpacerItem(20, 50, QSizePolicy.Minimum, QSizePolicy.Fixed)
|
||||
|
||||
self.verticalLayout.addItem(self.verticalSpacer_3)
|
||||
|
||||
self.horizontalLayout_2 = QHBoxLayout()
|
||||
self.horizontalLayout_2.setSpacing(24)
|
||||
self.horizontalLayout_2.setObjectName(u"horizontalLayout_2")
|
||||
self.horizontalSpacer = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)
|
||||
|
||||
self.horizontalLayout_2.addItem(self.horizontalSpacer)
|
||||
|
||||
self.startButton = PillToolButton(StopWatchInterface)
|
||||
self.startButton.setObjectName(u"startButton")
|
||||
self.startButton.setMinimumSize(QSize(68, 68))
|
||||
self.startButton.setIconSize(QSize(21, 21))
|
||||
self.startButton.setChecked(True)
|
||||
|
||||
self.horizontalLayout_2.addWidget(self.startButton)
|
||||
|
||||
self.flagButton = PillToolButton(StopWatchInterface)
|
||||
self.flagButton.setObjectName(u"flagButton")
|
||||
self.flagButton.setEnabled(False)
|
||||
self.flagButton.setMinimumSize(QSize(68, 68))
|
||||
self.flagButton.setIconSize(QSize(21, 21))
|
||||
|
||||
self.horizontalLayout_2.addWidget(self.flagButton)
|
||||
|
||||
self.restartButton = PillToolButton(StopWatchInterface)
|
||||
self.restartButton.setObjectName(u"restartButton")
|
||||
self.restartButton.setEnabled(False)
|
||||
self.restartButton.setMinimumSize(QSize(68, 68))
|
||||
self.restartButton.setIconSize(QSize(21, 21))
|
||||
|
||||
self.horizontalLayout_2.addWidget(self.restartButton)
|
||||
|
||||
self.horizontalSpacer_2 = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)
|
||||
|
||||
self.horizontalLayout_2.addItem(self.horizontalSpacer_2)
|
||||
|
||||
|
||||
self.verticalLayout.addLayout(self.horizontalLayout_2)
|
||||
|
||||
self.verticalSpacer_2 = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding)
|
||||
|
||||
self.verticalLayout.addItem(self.verticalSpacer_2)
|
||||
|
||||
|
||||
self.verticalLayout_2.addLayout(self.verticalLayout)
|
||||
|
||||
|
||||
self.retranslateUi(StopWatchInterface)
|
||||
|
||||
QMetaObject.connectSlotsByName(StopWatchInterface)
|
||||
# setupUi
|
||||
|
||||
def retranslateUi(self, StopWatchInterface):
|
||||
StopWatchInterface.setWindowTitle(QCoreApplication.translate("StopWatchInterface", u"Form", None))
|
||||
self.timeLabel.setText(QCoreApplication.translate("StopWatchInterface", u"00:00:00", None))
|
||||
self.hourLabel.setText(QCoreApplication.translate("StopWatchInterface", u"\u5c0f\u65f6", None))
|
||||
self.minuteLabel.setText(QCoreApplication.translate("StopWatchInterface", u"\u5206\u949f", None))
|
||||
self.secondLabel.setText(QCoreApplication.translate("StopWatchInterface", u"\u79d2", None))
|
||||
# retranslateUi
|
||||
|
||||
38
examples/window/clock/view/focus_interface.py
Normal file
@ -0,0 +1,38 @@
|
||||
# coding:utf-8
|
||||
from PySide6.QtGui import QColor
|
||||
from PySide6.QtWidgets import QWidget, QGraphicsDropShadowEffect
|
||||
from qfluentwidgets import FluentIcon, setFont, InfoBarIcon
|
||||
|
||||
from view.Ui_FocusInterface import Ui_FocusInterface
|
||||
|
||||
|
||||
class FocusInterface(Ui_FocusInterface, QWidget):
|
||||
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(parent=parent)
|
||||
self.setupUi(self)
|
||||
|
||||
# set the icon of button
|
||||
self.pinButton.setIcon(FluentIcon.PIN)
|
||||
self.moreButton.setIcon(FluentIcon.MORE)
|
||||
self.startFocusButton.setIcon(FluentIcon.POWER_BUTTON)
|
||||
self.editButton.setIcon(FluentIcon.EDIT)
|
||||
self.addTaskButton.setIcon(FluentIcon.ADD)
|
||||
self.moreTaskButton.setIcon(FluentIcon.MORE)
|
||||
self.taskIcon1.setIcon(InfoBarIcon.SUCCESS)
|
||||
self.taskIcon2.setIcon(InfoBarIcon.WARNING)
|
||||
self.taskIcon3.setIcon(InfoBarIcon.WARNING)
|
||||
|
||||
setFont(self.progressRing, 16)
|
||||
|
||||
# add shadow effect to card
|
||||
self.setShadowEffect(self.focusCard)
|
||||
self.setShadowEffect(self.progressCard)
|
||||
self.setShadowEffect(self.taskCard)
|
||||
|
||||
def setShadowEffect(self, card: QWidget):
|
||||
shadowEffect = QGraphicsDropShadowEffect(self)
|
||||
shadowEffect.setColor(QColor(0, 0, 0, 15))
|
||||
shadowEffect.setBlurRadius(10)
|
||||
shadowEffect.setOffset(0, 0)
|
||||
card.setGraphicsEffect(shadowEffect)
|
||||
16
examples/window/clock/view/stop_watch_interface.py
Normal file
@ -0,0 +1,16 @@
|
||||
# coding:utf-8
|
||||
from PySide6.QtWidgets import QWidget
|
||||
|
||||
from qfluentwidgets import FluentIcon
|
||||
from view.Ui_StopWatchInterface import Ui_StopWatchInterface
|
||||
|
||||
|
||||
class StopWatchInterface(Ui_StopWatchInterface, QWidget):
|
||||
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(parent=parent)
|
||||
self.setupUi(self)
|
||||
|
||||
self.startButton.setIcon(FluentIcon.POWER_BUTTON)
|
||||
self.flagButton.setIcon(FluentIcon.FLAG)
|
||||
self.restartButton.setIcon(FluentIcon.CANCEL)
|
||||
115
examples/window/fluent_window/demo.py
Normal file
@ -0,0 +1,115 @@
|
||||
# coding:utf-8
|
||||
import sys
|
||||
|
||||
from PySide6.QtCore import Qt, QUrl
|
||||
from PySide6.QtGui import QIcon, QDesktopServices
|
||||
from PySide6.QtWidgets import QApplication, QFrame, QHBoxLayout
|
||||
from qfluentwidgets import (NavigationItemPosition, MessageBox, setTheme, Theme, FluentWindow,
|
||||
NavigationAvatarWidget, qrouter, SubtitleLabel, setFont, InfoBadge,
|
||||
InfoBadgePosition, FluentBackgroundTheme)
|
||||
from qfluentwidgets import FluentIcon as FIF
|
||||
|
||||
|
||||
class Widget(QFrame):
|
||||
|
||||
def __init__(self, text: str, parent=None):
|
||||
super().__init__(parent=parent)
|
||||
self.label = SubtitleLabel(text, self)
|
||||
self.hBoxLayout = QHBoxLayout(self)
|
||||
|
||||
setFont(self.label, 24)
|
||||
self.label.setAlignment(Qt.AlignCenter)
|
||||
self.hBoxLayout.addWidget(self.label, 1, Qt.AlignCenter)
|
||||
self.setObjectName(text.replace(' ', '-'))
|
||||
|
||||
|
||||
class Window(FluentWindow):
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
|
||||
# create sub interface
|
||||
self.homeInterface = Widget('Search Interface', self)
|
||||
self.musicInterface = Widget('Music Interface', self)
|
||||
self.videoInterface = Widget('Video Interface', self)
|
||||
self.folderInterface = Widget('Folder Interface', self)
|
||||
self.settingInterface = Widget('Setting Interface', self)
|
||||
self.albumInterface = Widget('Album Interface', self)
|
||||
self.albumInterface1 = Widget('Album Interface 1', self)
|
||||
self.albumInterface2 = Widget('Album Interface 2', self)
|
||||
self.albumInterface1_1 = Widget('Album Interface 1-1', self)
|
||||
|
||||
self.initNavigation()
|
||||
self.initWindow()
|
||||
|
||||
def initNavigation(self):
|
||||
self.addSubInterface(self.homeInterface, FIF.HOME, 'Home')
|
||||
self.addSubInterface(self.musicInterface, FIF.MUSIC, 'Music library')
|
||||
self.addSubInterface(self.videoInterface, FIF.VIDEO, 'Video library')
|
||||
|
||||
self.navigationInterface.addSeparator()
|
||||
|
||||
self.addSubInterface(self.albumInterface, FIF.ALBUM, 'Albums', NavigationItemPosition.SCROLL)
|
||||
self.addSubInterface(self.albumInterface1, FIF.ALBUM, 'Album 1', parent=self.albumInterface)
|
||||
self.addSubInterface(self.albumInterface1_1, FIF.ALBUM, 'Album 1.1', parent=self.albumInterface1)
|
||||
self.addSubInterface(self.albumInterface2, FIF.ALBUM, 'Album 2', parent=self.albumInterface)
|
||||
self.addSubInterface(self.folderInterface, FIF.FOLDER, 'Folder library', NavigationItemPosition.SCROLL)
|
||||
|
||||
# add custom widget to bottom
|
||||
self.navigationInterface.addWidget(
|
||||
routeKey='avatar',
|
||||
widget=NavigationAvatarWidget('zhiyiYo', 'resource/shoko.png'),
|
||||
onClick=self.showMessageBox,
|
||||
position=NavigationItemPosition.BOTTOM,
|
||||
)
|
||||
|
||||
self.addSubInterface(self.settingInterface, FIF.SETTING, 'Settings', NavigationItemPosition.BOTTOM)
|
||||
|
||||
# add badge to navigation item
|
||||
item = self.navigationInterface.widget(self.videoInterface.objectName())
|
||||
InfoBadge.attension(
|
||||
text=9,
|
||||
parent=item.parent(),
|
||||
target=item,
|
||||
position=InfoBadgePosition.NAVIGATION_ITEM
|
||||
)
|
||||
|
||||
# NOTE: enable acrylic effect
|
||||
# self.navigationInterface.setAcrylicEnabled(True)
|
||||
|
||||
# disable pop animation
|
||||
# self.stackedWidget.setAnimationEnabled(False)
|
||||
|
||||
def initWindow(self):
|
||||
self.resize(900, 700)
|
||||
self.setWindowIcon(QIcon(':/qfluentwidgets/images/logo.png'))
|
||||
self.setWindowTitle('PyQt-Fluent-Widgets')
|
||||
|
||||
desktop = QApplication.screens()[0].availableGeometry()
|
||||
w, h = desktop.width(), desktop.height()
|
||||
self.move(w//2 - self.width()//2, h//2 - self.height()//2)
|
||||
|
||||
# set the minimum window width that allows the navigation panel to be expanded
|
||||
# self.navigationInterface.setMinimumExpandWidth(900)
|
||||
# self.navigationInterface.expand(useAni=False)
|
||||
|
||||
def showMessageBox(self):
|
||||
w = MessageBox(
|
||||
'支持作者🥰',
|
||||
'个人开发不易,如果这个项目帮助到了您,可以考虑请作者喝一瓶快乐水🥤。您的支持就是作者开发和维护项目的动力🚀',
|
||||
self
|
||||
)
|
||||
w.yesButton.setText('来啦老弟')
|
||||
w.cancelButton.setText('下次一定')
|
||||
|
||||
if w.exec():
|
||||
QDesktopServices.openUrl(QUrl("https://afdian.net/a/zhiyiYo"))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
# setTheme(Theme.DARK)
|
||||
|
||||
app = QApplication(sys.argv)
|
||||
w = Window()
|
||||
w.show()
|
||||
app.exec()
|
||||
BIN
examples/window/fluent_window/resource/shoko.png
Normal file
|
After Width: | Height: | Size: 262 KiB |
138
examples/window/login/Ui_LoginWindow.py
Normal file
@ -0,0 +1,138 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Form implementation generated from reading ui file 'd:\Python_Study\Github_Repositories\PyQt-Fluent-Widgets\resource\ui\LoginWindow.ui'
|
||||
#
|
||||
# Created by: PyQt5 UI code generator 5.15.9
|
||||
#
|
||||
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
|
||||
# run again. Do not edit this file unless you know what you are doing.
|
||||
|
||||
|
||||
from PySide6 import QtCore, QtGui, QtWidgets
|
||||
|
||||
|
||||
class Ui_Form(object):
|
||||
def setupUi(self, Form):
|
||||
Form.setObjectName("Form")
|
||||
Form.resize(1250, 809)
|
||||
Form.setMinimumSize(QtCore.QSize(700, 500))
|
||||
self.horizontalLayout = QtWidgets.QHBoxLayout(Form)
|
||||
self.horizontalLayout.setContentsMargins(0, 0, 0, 0)
|
||||
self.horizontalLayout.setSpacing(0)
|
||||
self.horizontalLayout.setObjectName("horizontalLayout")
|
||||
self.label = QtWidgets.QLabel(Form)
|
||||
self.label.setText("")
|
||||
self.label.setPixmap(QtGui.QPixmap(":/images/background.jpg"))
|
||||
self.label.setScaledContents(True)
|
||||
self.label.setObjectName("label")
|
||||
self.horizontalLayout.addWidget(self.label)
|
||||
self.widget = QtWidgets.QWidget(Form)
|
||||
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred)
|
||||
sizePolicy.setHorizontalStretch(0)
|
||||
sizePolicy.setVerticalStretch(0)
|
||||
sizePolicy.setHeightForWidth(self.widget.sizePolicy().hasHeightForWidth())
|
||||
self.widget.setSizePolicy(sizePolicy)
|
||||
self.widget.setMinimumSize(QtCore.QSize(360, 0))
|
||||
self.widget.setMaximumSize(QtCore.QSize(360, 16777215))
|
||||
self.widget.setStyleSheet("QLabel{\n"
|
||||
" font: 13px \'Microsoft YaHei\'\n"
|
||||
"}")
|
||||
self.widget.setObjectName("widget")
|
||||
self.verticalLayout_2 = QtWidgets.QVBoxLayout(self.widget)
|
||||
self.verticalLayout_2.setContentsMargins(20, 20, 20, 20)
|
||||
self.verticalLayout_2.setSpacing(9)
|
||||
self.verticalLayout_2.setObjectName("verticalLayout_2")
|
||||
spacerItem = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
|
||||
self.verticalLayout_2.addItem(spacerItem)
|
||||
self.label_2 = QtWidgets.QLabel(self.widget)
|
||||
self.label_2.setEnabled(True)
|
||||
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Expanding)
|
||||
sizePolicy.setHorizontalStretch(0)
|
||||
sizePolicy.setVerticalStretch(0)
|
||||
sizePolicy.setHeightForWidth(self.label_2.sizePolicy().hasHeightForWidth())
|
||||
self.label_2.setSizePolicy(sizePolicy)
|
||||
self.label_2.setMinimumSize(QtCore.QSize(100, 100))
|
||||
self.label_2.setMaximumSize(QtCore.QSize(100, 100))
|
||||
self.label_2.setText("")
|
||||
self.label_2.setPixmap(QtGui.QPixmap(":/images/logo.png"))
|
||||
self.label_2.setScaledContents(True)
|
||||
self.label_2.setObjectName("label_2")
|
||||
self.verticalLayout_2.addWidget(self.label_2, 0, QtCore.Qt.AlignHCenter)
|
||||
spacerItem1 = QtWidgets.QSpacerItem(20, 15, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Fixed)
|
||||
self.verticalLayout_2.addItem(spacerItem1)
|
||||
self.gridLayout = QtWidgets.QGridLayout()
|
||||
self.gridLayout.setHorizontalSpacing(4)
|
||||
self.gridLayout.setVerticalSpacing(9)
|
||||
self.gridLayout.setObjectName("gridLayout")
|
||||
self.lineEdit = LineEdit(self.widget)
|
||||
self.lineEdit.setClearButtonEnabled(True)
|
||||
self.lineEdit.setObjectName("lineEdit")
|
||||
self.gridLayout.addWidget(self.lineEdit, 1, 0, 1, 1)
|
||||
self.label_3 = BodyLabel(self.widget)
|
||||
self.label_3.setObjectName("label_3")
|
||||
self.gridLayout.addWidget(self.label_3, 0, 0, 1, 1)
|
||||
self.lineEdit_2 = LineEdit(self.widget)
|
||||
self.lineEdit_2.setPlaceholderText("")
|
||||
self.lineEdit_2.setClearButtonEnabled(True)
|
||||
self.lineEdit_2.setObjectName("lineEdit_2")
|
||||
self.gridLayout.addWidget(self.lineEdit_2, 1, 1, 1, 1)
|
||||
self.label_4 = BodyLabel(self.widget)
|
||||
self.label_4.setObjectName("label_4")
|
||||
self.gridLayout.addWidget(self.label_4, 0, 1, 1, 1)
|
||||
self.gridLayout.setColumnStretch(0, 2)
|
||||
self.gridLayout.setColumnStretch(1, 1)
|
||||
self.verticalLayout_2.addLayout(self.gridLayout)
|
||||
self.label_5 = BodyLabel(self.widget)
|
||||
self.label_5.setObjectName("label_5")
|
||||
self.verticalLayout_2.addWidget(self.label_5)
|
||||
self.lineEdit_3 = LineEdit(self.widget)
|
||||
self.lineEdit_3.setClearButtonEnabled(True)
|
||||
self.lineEdit_3.setObjectName("lineEdit_3")
|
||||
self.verticalLayout_2.addWidget(self.lineEdit_3)
|
||||
self.label_6 = BodyLabel(self.widget)
|
||||
self.label_6.setObjectName("label_6")
|
||||
self.verticalLayout_2.addWidget(self.label_6)
|
||||
self.lineEdit_4 = LineEdit(self.widget)
|
||||
self.lineEdit_4.setEchoMode(QtWidgets.QLineEdit.Password)
|
||||
self.lineEdit_4.setClearButtonEnabled(True)
|
||||
self.lineEdit_4.setObjectName("lineEdit_4")
|
||||
self.verticalLayout_2.addWidget(self.lineEdit_4)
|
||||
spacerItem2 = QtWidgets.QSpacerItem(20, 5, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Fixed)
|
||||
self.verticalLayout_2.addItem(spacerItem2)
|
||||
self.checkBox = CheckBox(self.widget)
|
||||
self.checkBox.setChecked(True)
|
||||
self.checkBox.setObjectName("checkBox")
|
||||
self.verticalLayout_2.addWidget(self.checkBox)
|
||||
spacerItem3 = QtWidgets.QSpacerItem(20, 5, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Fixed)
|
||||
self.verticalLayout_2.addItem(spacerItem3)
|
||||
self.pushButton = PrimaryPushButton(self.widget)
|
||||
self.pushButton.setObjectName("pushButton")
|
||||
self.verticalLayout_2.addWidget(self.pushButton)
|
||||
spacerItem4 = QtWidgets.QSpacerItem(20, 6, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Fixed)
|
||||
self.verticalLayout_2.addItem(spacerItem4)
|
||||
self.pushButton_2 = HyperlinkButton(self.widget)
|
||||
self.pushButton_2.setObjectName("pushButton_2")
|
||||
self.verticalLayout_2.addWidget(self.pushButton_2)
|
||||
spacerItem5 = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
|
||||
self.verticalLayout_2.addItem(spacerItem5)
|
||||
self.horizontalLayout.addWidget(self.widget)
|
||||
|
||||
self.retranslateUi(Form)
|
||||
QtCore.QMetaObject.connectSlotsByName(Form)
|
||||
|
||||
def retranslateUi(self, Form):
|
||||
_translate = QtCore.QCoreApplication.translate
|
||||
Form.setWindowTitle(_translate("Form", "Form"))
|
||||
self.lineEdit.setPlaceholderText(_translate("Form", "ftp.example.com"))
|
||||
self.label_3.setText(_translate("Form", "主机"))
|
||||
self.lineEdit_2.setText(_translate("Form", "21"))
|
||||
self.label_4.setText(_translate("Form", "端口"))
|
||||
self.label_5.setText(_translate("Form", "用户名"))
|
||||
self.lineEdit_3.setPlaceholderText(_translate("Form", "example@example.com"))
|
||||
self.label_6.setText(_translate("Form", "密码"))
|
||||
self.lineEdit_4.setPlaceholderText(_translate("Form", "••••••••••••"))
|
||||
self.checkBox.setText(_translate("Form", "记住密码"))
|
||||
self.pushButton.setText(_translate("Form", "登录"))
|
||||
self.pushButton_2.setText(_translate("Form", "找回密码"))
|
||||
from qfluentwidgets import BodyLabel, CheckBox, HyperlinkButton, LineEdit, PrimaryPushButton
|
||||
import resource_rc
|
||||
81
examples/window/login/demo.py
Normal file
@ -0,0 +1,81 @@
|
||||
import sys
|
||||
|
||||
from PySide6.QtCore import Qt, QTranslator, QLocale, QRect
|
||||
from PySide6.QtGui import QIcon, QPixmap, QColor
|
||||
from PySide6.QtWidgets import QApplication
|
||||
from qfluentwidgets import setThemeColor, FluentTranslator, setTheme, Theme, SplitTitleBar, isDarkTheme
|
||||
from Ui_LoginWindow import Ui_Form
|
||||
|
||||
|
||||
def isWin11():
|
||||
return sys.platform == 'win32' and sys.getwindowsversion().build >= 22000
|
||||
|
||||
|
||||
if isWin11():
|
||||
from qframelesswindow import AcrylicWindow as Window
|
||||
else:
|
||||
from qframelesswindow import FramelessWindow as Window
|
||||
|
||||
|
||||
class LoginWindow(Window, Ui_Form):
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.setupUi(self)
|
||||
# setTheme(Theme.DARK)
|
||||
setThemeColor('#28afe9')
|
||||
|
||||
self.setTitleBar(SplitTitleBar(self))
|
||||
self.titleBar.raise_()
|
||||
|
||||
self.label.setScaledContents(False)
|
||||
self.setWindowTitle('PyQt-Fluent-Widget')
|
||||
self.setWindowIcon(QIcon(":/images/logo.png"))
|
||||
self.resize(1000, 650)
|
||||
|
||||
self.windowEffect.setMicaEffect(self.winId(), isDarkMode=isDarkTheme())
|
||||
if not isWin11():
|
||||
color = QColor(25, 33, 42) if isDarkTheme() else QColor(240, 244, 249)
|
||||
self.setStyleSheet(f"LoginWindow{{background: {color.name()}}}")
|
||||
|
||||
if sys.platform == "darwin":
|
||||
self.setSystemTitleBarButtonVisible(True)
|
||||
self.titleBar.minBtn.hide()
|
||||
self.titleBar.maxBtn.hide()
|
||||
self.titleBar.closeBtn.hide()
|
||||
|
||||
self.titleBar.titleLabel.setStyleSheet("""
|
||||
QLabel{
|
||||
background: transparent;
|
||||
font: 13px 'Segoe UI';
|
||||
padding: 0 4px;
|
||||
color: white
|
||||
}
|
||||
""")
|
||||
|
||||
desktop = QApplication.screens()[0].availableGeometry()
|
||||
w, h = desktop.width(), desktop.height()
|
||||
self.move(w//2 - self.width()//2, h//2 - self.height()//2)
|
||||
|
||||
def resizeEvent(self, e):
|
||||
super().resizeEvent(e)
|
||||
pixmap = QPixmap(":/images/background.jpg").scaled(
|
||||
self.label.size(), Qt.KeepAspectRatioByExpanding, Qt.SmoothTransformation)
|
||||
self.label.setPixmap(pixmap)
|
||||
|
||||
def systemTitleBarRect(self, size):
|
||||
""" Returns the system title bar rect, only works for macOS """
|
||||
return QRect(size.width() - 75, 0, 75, size.height())
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
app = QApplication(sys.argv)
|
||||
|
||||
# Internationalization
|
||||
translator = FluentTranslator(QLocale())
|
||||
app.installTranslator(translator)
|
||||
|
||||
w = LoginWindow()
|
||||
w.show()
|
||||
app.exec()
|
||||
BIN
examples/window/login/resource/images/background.jpg
Normal file
|
After Width: | Height: | Size: 1.8 MiB |
BIN
examples/window/login/resource/images/logo.png
Normal file
|
After Width: | Height: | Size: 7.4 KiB |
7
examples/window/login/resource/resource.qrc
Normal file
@ -0,0 +1,7 @@
|
||||
<RCC>
|
||||
<qresource>
|
||||
<file>images/girl.jpg</file>
|
||||
<file>images/background.jpg</file>
|
||||
<file>images/logo.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
360
examples/window/login/resource/ui/LoginWindow.ui
Normal file
@ -0,0 +1,360 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>Form</class>
|
||||
<widget class="QWidget" name="Form">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1250</width>
|
||||
<height>809</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>700</width>
|
||||
<height>500</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="pixmap">
|
||||
<pixmap resource="../resource.qrc">:/images/background.jpg</pixmap>
|
||||
</property>
|
||||
<property name="scaledContents">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="widget" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>360</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>360</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QLabel{
|
||||
font: 13px 'Microsoft YaHei'
|
||||
}</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<property name="spacing">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>20</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>20</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>20</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>20</number>
|
||||
</property>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item alignment="Qt::AlignHCenter">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>100</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>100</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="pixmap">
|
||||
<pixmap resource="../resource.qrc">:/images/logo.png</pixmap>
|
||||
</property>
|
||||
<property name="scaledContents">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>15</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout" columnstretch="2,1">
|
||||
<property name="horizontalSpacing">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="verticalSpacing">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<item row="1" column="0">
|
||||
<widget class="LineEdit" name="lineEdit">
|
||||
<property name="placeholderText">
|
||||
<string>ftp.example.com</string>
|
||||
</property>
|
||||
<property name="clearButtonEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="BodyLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>主机</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="LineEdit" name="lineEdit_2">
|
||||
<property name="text">
|
||||
<string>21</string>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="clearButtonEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="BodyLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>端口</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="BodyLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>用户名</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="LineEdit" name="lineEdit_3">
|
||||
<property name="placeholderText">
|
||||
<string>example@example.com</string>
|
||||
</property>
|
||||
<property name="clearButtonEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="BodyLabel" name="label_6">
|
||||
<property name="text">
|
||||
<string>密码</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="LineEdit" name="lineEdit_4">
|
||||
<property name="echoMode">
|
||||
<enum>QLineEdit::Password</enum>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string>••••••••••••</string>
|
||||
</property>
|
||||
<property name="clearButtonEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_5">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>5</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="CheckBox" name="checkBox">
|
||||
<property name="text">
|
||||
<string>记住密码</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_4">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>5</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="PrimaryPushButton" name="pushButton">
|
||||
<property name="text">
|
||||
<string>登录</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_6">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>6</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="HyperlinkButton" name="pushButton_2">
|
||||
<property name="text">
|
||||
<string>找回密码</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>LineEdit</class>
|
||||
<extends>QLineEdit</extends>
|
||||
<header>qfluentwidgets</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>CheckBox</class>
|
||||
<extends>QCheckBox</extends>
|
||||
<header>qfluentwidgets</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>PrimaryPushButton</class>
|
||||
<extends>QPushButton</extends>
|
||||
<header>qfluentwidgets</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>HyperlinkButton</class>
|
||||
<extends>QPushButton</extends>
|
||||
<header>qfluentwidgets</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>BodyLabel</class>
|
||||
<extends>QLabel</extends>
|
||||
<header>qfluentwidgets</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources>
|
||||
<include location="../resource.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
118625
examples/window/login/resource_rc.py
Normal file
85
examples/window/ms_fluent_window/demo.py
Normal file
@ -0,0 +1,85 @@
|
||||
# coding:utf-8
|
||||
import sys
|
||||
|
||||
from PySide6.QtCore import Qt, QUrl
|
||||
from PySide6.QtGui import QIcon, QDesktopServices
|
||||
from PySide6.QtWidgets import QApplication, QFrame, QHBoxLayout
|
||||
from qfluentwidgets import (NavigationItemPosition, MessageBox, setTheme, Theme, MSFluentWindow,
|
||||
NavigationAvatarWidget, qrouter, SubtitleLabel, setFont)
|
||||
from qfluentwidgets import FluentIcon as FIF
|
||||
|
||||
|
||||
class Widget(QFrame):
|
||||
|
||||
def __init__(self, text: str, parent=None):
|
||||
super().__init__(parent=parent)
|
||||
self.label = SubtitleLabel(text, self)
|
||||
self.hBoxLayout = QHBoxLayout(self)
|
||||
|
||||
setFont(self.label, 24)
|
||||
self.label.setAlignment(Qt.AlignCenter)
|
||||
self.hBoxLayout.addWidget(self.label, 1, Qt.AlignCenter)
|
||||
self.setObjectName(text.replace(' ', '-'))
|
||||
|
||||
|
||||
|
||||
class Window(MSFluentWindow):
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
|
||||
# create sub interface
|
||||
self.homeInterface = Widget('Home Interface', self)
|
||||
self.appInterface = Widget('Application Interface', self)
|
||||
self.videoInterface = Widget('Video Interface', self)
|
||||
self.libraryInterface = Widget('library Interface', self)
|
||||
|
||||
self.initNavigation()
|
||||
self.initWindow()
|
||||
|
||||
def initNavigation(self):
|
||||
self.addSubInterface(self.homeInterface, FIF.HOME, '主页', FIF.HOME_FILL)
|
||||
self.addSubInterface(self.appInterface, FIF.APPLICATION, '应用')
|
||||
self.addSubInterface(self.videoInterface, FIF.VIDEO, '视频')
|
||||
|
||||
self.addSubInterface(self.libraryInterface, FIF.BOOK_SHELF, '库', FIF.LIBRARY_FILL, NavigationItemPosition.BOTTOM)
|
||||
self.navigationInterface.addItem(
|
||||
routeKey='Help',
|
||||
icon=FIF.HELP,
|
||||
text='帮助',
|
||||
onClick=self.showMessageBox,
|
||||
selectable=False,
|
||||
position=NavigationItemPosition.BOTTOM,
|
||||
)
|
||||
|
||||
self.navigationInterface.setCurrentItem(self.homeInterface.objectName())
|
||||
|
||||
def initWindow(self):
|
||||
self.resize(900, 700)
|
||||
self.setWindowIcon(QIcon(':/qfluentwidgets/images/logo.png'))
|
||||
self.setWindowTitle('PyQt-Fluent-Widgets')
|
||||
|
||||
desktop = QApplication.screens()[0].availableGeometry()
|
||||
w, h = desktop.width(), desktop.height()
|
||||
self.move(w//2 - self.width()//2, h//2 - self.height()//2)
|
||||
|
||||
def showMessageBox(self):
|
||||
w = MessageBox(
|
||||
'支持作者🥰',
|
||||
'个人开发不易,如果这个项目帮助到了您,可以考虑请作者喝一瓶快乐水🥤。您的支持就是作者开发和维护项目的动力🚀',
|
||||
self
|
||||
)
|
||||
w.yesButton.setText('来啦老弟')
|
||||
w.cancelButton.setText('下次一定')
|
||||
|
||||
if w.exec():
|
||||
QDesktopServices.openUrl(QUrl("https://afdian.net/a/zhiyiYo"))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
# setTheme(Theme.DARK)
|
||||
|
||||
app = QApplication(sys.argv)
|
||||
w = Window()
|
||||
w.show()
|
||||
app.exec()
|
||||
120
examples/window/settings/config.py
Normal file
@ -0,0 +1,120 @@
|
||||
# coding:utf-8
|
||||
from enum import Enum
|
||||
|
||||
from PySide6.QtCore import Qt, QLocale
|
||||
from PySide6.QtGui import QGuiApplication, QFont
|
||||
from qfluentwidgets import (qconfig, QConfig, ConfigItem, OptionsConfigItem, BoolValidator,
|
||||
ColorConfigItem, OptionsValidator, RangeConfigItem, RangeValidator,
|
||||
FolderListValidator, EnumSerializer, FolderValidator, ConfigSerializer, __version__)
|
||||
|
||||
|
||||
class SongQuality(Enum):
|
||||
""" Online song quality enumeration class """
|
||||
|
||||
STANDARD = "Standard quality"
|
||||
HIGH = "High quality"
|
||||
SUPER = "Super quality"
|
||||
LOSSLESS = "Lossless quality"
|
||||
|
||||
|
||||
class MvQuality(Enum):
|
||||
""" MV quality enumeration class """
|
||||
|
||||
FULL_HD = "Full HD"
|
||||
HD = "HD"
|
||||
SD = "SD"
|
||||
LD = "LD"
|
||||
|
||||
|
||||
class Language(Enum):
|
||||
""" Language enumeration """
|
||||
|
||||
CHINESE_SIMPLIFIED = QLocale(QLocale.Chinese, QLocale.China)
|
||||
CHINESE_TRADITIONAL = QLocale(QLocale.Chinese, QLocale.HongKong)
|
||||
ENGLISH = QLocale(QLocale.English)
|
||||
AUTO = QLocale()
|
||||
|
||||
|
||||
class LanguageSerializer(ConfigSerializer):
|
||||
""" Language serializer """
|
||||
|
||||
def serialize(self, language):
|
||||
return language.value.name() if language != Language.AUTO else "Auto"
|
||||
|
||||
def deserialize(self, value: str):
|
||||
return Language(QLocale(value)) if value != "Auto" else Language.AUTO
|
||||
|
||||
|
||||
class Config(QConfig):
|
||||
""" Config of application """
|
||||
|
||||
# folders
|
||||
musicFolders = ConfigItem(
|
||||
"Folders", "LocalMusic", [], FolderListValidator())
|
||||
downloadFolder = ConfigItem(
|
||||
"Folders", "Download", "download", FolderValidator())
|
||||
|
||||
# online
|
||||
onlineSongQuality = OptionsConfigItem(
|
||||
"Online", "SongQuality", SongQuality.STANDARD, OptionsValidator(SongQuality), EnumSerializer(SongQuality))
|
||||
onlinePageSize = RangeConfigItem(
|
||||
"Online", "PageSize", 30, RangeValidator(0, 50))
|
||||
onlineMvQuality = OptionsConfigItem(
|
||||
"Online", "MvQuality", MvQuality.FULL_HD, OptionsValidator(MvQuality), EnumSerializer(MvQuality))
|
||||
|
||||
# main window
|
||||
enableAcrylicBackground = ConfigItem(
|
||||
"MainWindow", "EnableAcrylicBackground", False, BoolValidator())
|
||||
minimizeToTray = ConfigItem(
|
||||
"MainWindow", "MinimizeToTray", True, BoolValidator())
|
||||
playBarColor = ColorConfigItem("MainWindow", "PlayBarColor", "#225C7F")
|
||||
recentPlaysNumber = RangeConfigItem(
|
||||
"MainWindow", "RecentPlayNumbers", 300, RangeValidator(10, 300))
|
||||
dpiScale = OptionsConfigItem(
|
||||
"MainWindow", "DpiScale", "Auto", OptionsValidator([1, 1.25, 1.5, 1.75, 2, "Auto"]), restart=True)
|
||||
language = OptionsConfigItem(
|
||||
"MainWindow", "Language", Language.AUTO, OptionsValidator(Language), LanguageSerializer(), restart=True)
|
||||
|
||||
# desktop lyric
|
||||
deskLyricHighlightColor = ColorConfigItem(
|
||||
"DesktopLyric", "HighlightColor", "#0099BC")
|
||||
deskLyricFontSize = RangeConfigItem(
|
||||
"DesktopLyric", "FontSize", 50, RangeValidator(15, 50))
|
||||
deskLyricStrokeSize = RangeConfigItem(
|
||||
"DesktopLyric", "StrokeSize", 5, RangeValidator(0, 20))
|
||||
deskLyricStrokeColor = ColorConfigItem(
|
||||
"DesktopLyric", "StrokeColor", Qt.black)
|
||||
deskLyricFontFamily = ConfigItem(
|
||||
"DesktopLyric", "FontFamily", "Microsoft YaHei")
|
||||
deskLyricAlignment = OptionsConfigItem(
|
||||
"DesktopLyric", "Alignment", "Center", OptionsValidator(["Center", "Left", "Right"]))
|
||||
|
||||
# software update
|
||||
checkUpdateAtStartUp = ConfigItem(
|
||||
"Update", "CheckUpdateAtStartUp", True, BoolValidator())
|
||||
|
||||
@property
|
||||
def desktopLyricFont(self):
|
||||
""" get the desktop lyric font """
|
||||
font = QFont(self.deskLyricFontFamily.value)
|
||||
font.setPixelSize(self.deskLyricFontSize.value)
|
||||
return font
|
||||
|
||||
@desktopLyricFont.setter
|
||||
def desktopLyricFont(self, font: QFont):
|
||||
dpi = QGuiApplication.primaryScreen().logicalDotsPerInch()
|
||||
self.deskLyricFontFamily.value = font.family()
|
||||
self.deskLyricFontSize.value = max(15, int(font.pointSize()*dpi/72))
|
||||
self.save()
|
||||
|
||||
|
||||
YEAR = 2023
|
||||
AUTHOR = "zhiyiYo"
|
||||
VERSION = __version__
|
||||
HELP_URL = "https://pyqt-fluent-widgets.readthedocs.io"
|
||||
FEEDBACK_URL = "https://github.com/zhiyiYo/PyQt-Fluent-Widgets/issues"
|
||||
RELEASE_URL = "https://github.com/zhiyiYo/PyQt-Fluent-Widgets/releases/latest"
|
||||
|
||||
|
||||
cfg = Config()
|
||||
qconfig.load('config/config.json', cfg)
|
||||
66
examples/window/settings/demo.py
Normal file
@ -0,0 +1,66 @@
|
||||
# coding:utf-8
|
||||
import os
|
||||
import sys
|
||||
from PySide6.QtCore import Qt, QLocale, QTranslator
|
||||
from PySide6.QtGui import QIcon, QColor
|
||||
from PySide6.QtWidgets import QApplication, QHBoxLayout
|
||||
|
||||
from qframelesswindow import FramelessWindow, StandardTitleBar
|
||||
from qfluentwidgets import isDarkTheme, FluentTranslator
|
||||
from setting_interface import SettingInterface
|
||||
from config import cfg, Language
|
||||
|
||||
|
||||
|
||||
class Window(FramelessWindow):
|
||||
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(parent=parent)
|
||||
self.setTitleBar(StandardTitleBar(self))
|
||||
|
||||
self.hBoxLayout = QHBoxLayout(self)
|
||||
self.settingInterface = SettingInterface(self)
|
||||
self.hBoxLayout.setContentsMargins(0, 0, 0, 0)
|
||||
self.hBoxLayout.addWidget(self.settingInterface)
|
||||
|
||||
self.setWindowIcon(QIcon(":/qfluentwidgets/images/logo.png"))
|
||||
self.setWindowTitle("PySide6-Fluent-Widgets")
|
||||
|
||||
self.resize(1080, 784)
|
||||
desktop = QApplication.primaryScreen().size()
|
||||
w, h = desktop.width(), desktop.height()
|
||||
self.move(w//2 - self.width()//2, h//2 - self.height()//2)
|
||||
|
||||
self.titleBar.raise_()
|
||||
|
||||
self.setQss()
|
||||
cfg.themeChanged.connect(self.setQss)
|
||||
|
||||
def setQss(self):
|
||||
theme = 'dark' if isDarkTheme() else 'light'
|
||||
with open(f'resource/qss/{theme}/demo.qss', encoding='utf-8') as f:
|
||||
self.setStyleSheet(f.read())
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
# enable dpi scale
|
||||
if cfg.get(cfg.dpiScale) != "Auto":
|
||||
os.environ["QT_ENABLE_HIGHDPI_SCALING"] = "0"
|
||||
os.environ["QT_SCALE_FACTOR"] = str(cfg.get(cfg.dpiScale))
|
||||
|
||||
app = QApplication(sys.argv)
|
||||
app.setAttribute(Qt.ApplicationAttribute.AA_DontCreateNativeWidgetSiblings)
|
||||
|
||||
# internationalization
|
||||
locale = cfg.get(cfg.language).value
|
||||
fluentTranslator = FluentTranslator(locale)
|
||||
settingTranslator = QTranslator()
|
||||
settingTranslator.load(locale, "settings", ".", "resource/i18n")
|
||||
|
||||
app.installTranslator(fluentTranslator)
|
||||
app.installTranslator(settingTranslator)
|
||||
|
||||
# create main window
|
||||
w = Window()
|
||||
w.show()
|
||||
app.exec()
|
||||
240
examples/window/settings/resource/i18n/settings.zh_CN.ts
Normal file
@ -0,0 +1,240 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE TS>
|
||||
<TS version="2.1" language="zh_CN">
|
||||
<context>
|
||||
<name>SettingInterface</name>
|
||||
<message>
|
||||
<source>Settings</source>
|
||||
<translation>设置</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Music on this PC</source>
|
||||
<translation>此 PC 上的音乐</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Local music library</source>
|
||||
<translation>本地音乐库</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Choose folder</source>
|
||||
<translation>选择文件夹</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Download directory</source>
|
||||
<translation>下载目录</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Personalization</source>
|
||||
<translation>个性化</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Use Acrylic effect</source>
|
||||
<translation>启用亚克力效果</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Acrylic effect has better visual experience, but it may cause the window to become stuck</source>
|
||||
<translation>亚克力效果的视觉体验更好,但可能导致窗口卡顿</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Application theme</source>
|
||||
<translation>应用主题</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Theme color</source>
|
||||
<translation>主题色</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Change the theme color of you application</source>
|
||||
<translation>调整你的应用主题颜色</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Change the appearance of your application</source>
|
||||
<translation>调整你的应用外观</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Light</source>
|
||||
<translation>浅色</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Dark</source>
|
||||
<translation>深色</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Use system setting</source>
|
||||
<translation>跟随系统设置</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Interface zoom</source>
|
||||
<translation>界面缩放</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Change the size of widgets and fonts</source>
|
||||
<translation>调整组件和字体的大小</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Language</source>
|
||||
<translation>语言</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Set your preferred language for UI</source>
|
||||
<translation>选择界面所使用的语言</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Online Music</source>
|
||||
<translation>在线音乐</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Number of online music displayed on each page</source>
|
||||
<translation>每页显示的在线歌曲数量</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Online music quality</source>
|
||||
<translation>在线播放音质</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Standard quality</source>
|
||||
<translation>流畅</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>High quality</source>
|
||||
<translation>高品</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Super quality</source>
|
||||
<translation>超品</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Lossless quality</source>
|
||||
<translation>无损</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Online MV quality</source>
|
||||
<translation>在线 MV 画质</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Full HD</source>
|
||||
<translation>超清</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>HD</source>
|
||||
<translation>高清</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>SD</source>
|
||||
<translation>标清</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>LD</source>
|
||||
<translation>流畅</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Desktop Lyric</source>
|
||||
<translation>桌面歌词</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Choose font</source>
|
||||
<translation>选择字体</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Font</source>
|
||||
<translation>字体</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Foreground color</source>
|
||||
<translation>前景色</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Background color</source>
|
||||
<translation>背景色</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Stroke color</source>
|
||||
<translation>描边色</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Stroke size</source>
|
||||
<translation>描边大小</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Alignment</source>
|
||||
<translation>对齐方式</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Center aligned</source>
|
||||
<translation>居中对齐</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Left aligned</source>
|
||||
<translation>左对齐</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Right aligned</source>
|
||||
<translation>右对齐</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Main Panel</source>
|
||||
<translation>主面板</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Minimize to tray after closing</source>
|
||||
<translation>关闭后最小化到托盘</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>PyQt-Fluent-Widgets will continue to run in the background</source>
|
||||
<translation>PyQt-Fluent-Widgets 将在后台继续运行</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../View/setting_interface/setting_interface.py" line="156"/>
|
||||
<source>Software update</source>
|
||||
<translation>软件更新</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Check for updates when the application starts</source>
|
||||
<translation>在应用程序启动时检查更新</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>The new version will be more stable and have more features</source>
|
||||
<translation>新版本将更加稳定并拥有更多功能(建议启用此选项)</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>About</source>
|
||||
<translation>关于</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Open help page</source>
|
||||
<translation>打开帮助页面</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Discover new features and learn useful tips about PyQt-Fluent-Widgets</source>
|
||||
<translation>发现新功能并了解有关 PyQt-Fluent-Widgets 的使用技巧</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Provide feedback</source>
|
||||
<translation>提供反馈</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Help us improve PyQt-Fluent-Widgets by providing feedback</source>
|
||||
<translation>通过提供反馈帮助我们改进 PyQt-Fluent-Widgets</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Check update</source>
|
||||
<translation>检查更新</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Copyright</source>
|
||||
<translation>版权所有</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Version</source>
|
||||
<translation>当前版本</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Configuration updated successfully</source>
|
||||
<translation>配置更新成功</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Configuration takes effect after restart</source>
|
||||
<translation>配置在重启软件后生效</translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
||||
241
examples/window/settings/resource/i18n/settings.zh_HK.ts
Normal file
@ -0,0 +1,241 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE TS>
|
||||
<TS version="2.1" language="zh_HK">
|
||||
<context>
|
||||
<name>SettingInterface</name>
|
||||
<message>
|
||||
<source>Settings</source>
|
||||
<translation>設置</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Music on this PC</source>
|
||||
<translation>此 PC 上的音樂</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Local music library</source>
|
||||
<translation>本地音樂庫</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Choose folder</source>
|
||||
<translation>選擇文件夾</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Download directory</source>
|
||||
<translation>下載目錄</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Personalization</source>
|
||||
<translation>個性化</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Use Acrylic effect</source>
|
||||
<translation>啟用亞克力效果</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Acrylic effect has better visual experience, but it may cause the window to
|
||||
become stuck</source>
|
||||
<translation>亞克力效果的視覺體驗更好,但可能導致窗口卡頓</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Application theme</source>
|
||||
<translation>應用主題</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Theme color</source>
|
||||
<translation>主題色</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Change the theme color of you application</source>
|
||||
<translation>調整你的應用主題顏色</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Change the appearance of your application</source>
|
||||
<translation>調整你的應用外觀</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Light</source>
|
||||
<translation>淺色</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Dark</source>
|
||||
<translation>深色</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Use system setting</source>
|
||||
<translation>跟隨系統設置</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Interface zoom</source>
|
||||
<translation>界面縮放</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Change the size of widgets and fonts</source>
|
||||
<translation>調整組件和字體的大小</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Language</source>
|
||||
<translation>語言</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Set your preferred language for UI</source>
|
||||
<translation>選擇界面所使用的語言</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Online Music</source>
|
||||
<translation>在線音樂</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Number of online music displayed on each page</source>
|
||||
<translation>每頁顯示的在線歌曲數量</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Online music quality</source>
|
||||
<translation>在線播放音質</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Standard quality</source>
|
||||
<translation>流暢</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>High quality</source>
|
||||
<translation>高品</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Super quality</source>
|
||||
<translation>超品</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Lossless quality</source>
|
||||
<translation>無損</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Online MV quality</source>
|
||||
<translation>在線 MV 畫質</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Full HD</source>
|
||||
<translation>超清</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>HD</source>
|
||||
<translation>高清</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>SD</source>
|
||||
<translation>標清</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>LD</source>
|
||||
<translation>流暢</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Desktop Lyric</source>
|
||||
<translation>桌面歌詞</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Choose font</source>
|
||||
<translation>選擇字體</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Font</source>
|
||||
<translation>字體</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Foreground color</source>
|
||||
<translation>前景色</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Background color</source>
|
||||
<translation>背景色</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Stroke color</source>
|
||||
<translation>描邊色</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Stroke size</source>
|
||||
<translation>描邊大小</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Alignment</source>
|
||||
<translation>對齊方式</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Center aligned</source>
|
||||
<translation>居中對齊</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Left aligned</source>
|
||||
<translation>左對齊</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Right aligned</source>
|
||||
<translation>右對齊</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Main Panel</source>
|
||||
<translation>主面板</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Minimize to tray after closing</source>
|
||||
<translation>關閉後最小化到托盤</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>PyQt-Fluent-Widgets will continue to run in the background</source>
|
||||
<translation>PyQt-Fluent-Widgets 將在後臺繼續運行</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../View/setting_interface/setting_interface.py" line="156" />
|
||||
<source>Software update</source>
|
||||
<translation>軟件更新</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Check for updates when the application starts</source>
|
||||
<translation>在應用程序啟動時檢查更新</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>The new version will be more stable and have more features</source>
|
||||
<translation>新版本將更加穩定並擁有更多功能(建議啟用此選項)</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>About</source>
|
||||
<translation>關於</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Open help page</source>
|
||||
<translation>打開幫助頁面</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Discover new features and learn useful tips about PyQt-Fluent-Widgets</source>
|
||||
<translation>發現新功能並了解有關 PyQt-Fluent-Widgets 的使用技巧</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Provide feedback</source>
|
||||
<translation>提供反饋</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Help us improve PyQt-Fluent-Widgets by providing feedback</source>
|
||||
<translation>通過提供反饋幫助我們改進 PyQt-Fluent-Widgets</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Check update</source>
|
||||
<translation>檢查更新</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Copyright</source>
|
||||
<translation>版權所有</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Version</source>
|
||||
<translation>當前版本</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Configuration updated successfully</source>
|
||||
<translation>配置更新成功</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Configuration takes effect after restart</source>
|
||||
<translation>配置在重啟軟件後生效</translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
||||
27
examples/window/settings/resource/qss/dark/demo.qss
Normal file
@ -0,0 +1,27 @@
|
||||
MinimizeButton {
|
||||
qproperty-normalColor: white;
|
||||
qproperty-normalBackgroundColor: transparent;
|
||||
qproperty-hoverColor: white;
|
||||
qproperty-hoverBackgroundColor: rgba(255, 255, 255, 26);
|
||||
qproperty-pressedColor: white;
|
||||
qproperty-pressedBackgroundColor: rgba(255, 255, 255, 51)
|
||||
}
|
||||
|
||||
|
||||
MaximizeButton {
|
||||
qproperty-normalColor: white;
|
||||
qproperty-normalBackgroundColor: transparent;
|
||||
qproperty-hoverColor: white;
|
||||
qproperty-hoverBackgroundColor: rgba(255, 255, 255, 26);
|
||||
qproperty-pressedColor: white;
|
||||
qproperty-pressedBackgroundColor: rgba(255, 255, 255, 51)
|
||||
}
|
||||
|
||||
CloseButton {
|
||||
qproperty-normalColor: white;
|
||||
qproperty-normalBackgroundColor: transparent;
|
||||
}
|
||||
|
||||
StandardTitleBar > QLabel {
|
||||
color: white;
|
||||
}
|
||||
@ -0,0 +1,17 @@
|
||||
SettingInterface, #scrollWidget {
|
||||
background-color: rgb(39, 39, 39);
|
||||
}
|
||||
|
||||
QScrollArea {
|
||||
border: none;
|
||||
background-color: rgb(39, 39, 39);
|
||||
}
|
||||
|
||||
|
||||
/* 标签 */
|
||||
QLabel#settingLabel {
|
||||
font: 33px 'Microsoft YaHei Light';
|
||||
background-color: transparent;
|
||||
color: white;
|
||||
}
|
||||
|
||||
23
examples/window/settings/resource/qss/light/demo.qss
Normal file
@ -0,0 +1,23 @@
|
||||
MinimizeButton {
|
||||
qproperty-normalColor: black;
|
||||
qproperty-normalBackgroundColor: transparent;
|
||||
qproperty-hoverColor: black;
|
||||
qproperty-hoverBackgroundColor: rgba(0, 0, 0, 26);
|
||||
qproperty-pressedColor: black;
|
||||
qproperty-pressedBackgroundColor: rgba(0, 0, 0, 51)
|
||||
}
|
||||
|
||||
|
||||
MaximizeButton {
|
||||
qproperty-normalColor: black;
|
||||
qproperty-normalBackgroundColor: transparent;
|
||||
qproperty-hoverColor: black;
|
||||
qproperty-hoverBackgroundColor: rgba(0, 0, 0, 26);
|
||||
qproperty-pressedColor: black;
|
||||
qproperty-pressedBackgroundColor: rgba(0, 0, 0, 51)
|
||||
}
|
||||
|
||||
CloseButton {
|
||||
qproperty-normalColor: black;
|
||||
qproperty-normalBackgroundColor: transparent;
|
||||
}
|
||||
@ -0,0 +1,16 @@
|
||||
SettingInterface, #scrollWidget {
|
||||
background-color: rgb(249, 249, 249);
|
||||
}
|
||||
|
||||
QScrollArea {
|
||||
background-color: rgb(249, 249, 249);
|
||||
border: none;
|
||||
}
|
||||
|
||||
|
||||
/* 标签 */
|
||||
QLabel#settingLabel {
|
||||
font: 33px 'Microsoft YaHei Light';
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
333
examples/window/settings/setting_interface.py
Normal file
@ -0,0 +1,333 @@
|
||||
# coding:utf-8
|
||||
from config import cfg, HELP_URL, FEEDBACK_URL, AUTHOR, VERSION, YEAR
|
||||
from qfluentwidgets import (SettingCardGroup, SwitchSettingCard, FolderListSettingCard,
|
||||
OptionsSettingCard, RangeSettingCard, PushSettingCard,
|
||||
ColorSettingCard, HyperlinkCard, PrimaryPushSettingCard, ScrollArea,
|
||||
ComboBoxSettingCard, ExpandLayout, Theme, InfoBar, CustomColorSettingCard,
|
||||
setTheme, setThemeColor, isDarkTheme)
|
||||
from qfluentwidgets import FluentIcon as FIF
|
||||
from PySide6.QtCore import Qt, Signal, QUrl, QStandardPaths
|
||||
from PySide6.QtGui import QDesktopServices
|
||||
from PySide6.QtWidgets import QWidget, QLabel, QFontDialog, QFileDialog
|
||||
|
||||
|
||||
class SettingInterface(ScrollArea):
|
||||
""" Setting interface """
|
||||
|
||||
checkUpdateSig = Signal()
|
||||
musicFoldersChanged = Signal(list)
|
||||
acrylicEnableChanged = Signal(bool)
|
||||
downloadFolderChanged = Signal(str)
|
||||
minimizeToTrayChanged = Signal(bool)
|
||||
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(parent=parent)
|
||||
self.scrollWidget = QWidget()
|
||||
self.expandLayout = ExpandLayout(self.scrollWidget)
|
||||
|
||||
# setting label
|
||||
self.settingLabel = QLabel(self.tr("Settings"), self)
|
||||
|
||||
# music folders
|
||||
self.musicInThisPCGroup = SettingCardGroup(
|
||||
self.tr("Music on this PC"), self.scrollWidget)
|
||||
self.musicFolderCard = FolderListSettingCard(
|
||||
cfg.musicFolders,
|
||||
self.tr("Local music library"),
|
||||
directory=QStandardPaths.writableLocation(QStandardPaths.MusicLocation),
|
||||
parent=self.musicInThisPCGroup
|
||||
)
|
||||
self.downloadFolderCard = PushSettingCard(
|
||||
self.tr('Choose folder'),
|
||||
FIF.DOWNLOAD,
|
||||
self.tr("Download directory"),
|
||||
cfg.get(cfg.downloadFolder),
|
||||
self.musicInThisPCGroup
|
||||
)
|
||||
|
||||
# personalization
|
||||
self.personalGroup = SettingCardGroup(self.tr('Personalization'), self.scrollWidget)
|
||||
self.enableAcrylicCard = SwitchSettingCard(
|
||||
FIF.TRANSPARENT,
|
||||
self.tr("Use Acrylic effect"),
|
||||
self.tr("Acrylic effect has better visual experience, but it may cause the window to become stuck"),
|
||||
configItem=cfg.enableAcrylicBackground,
|
||||
parent=self.personalGroup
|
||||
)
|
||||
self.themeCard = OptionsSettingCard(
|
||||
cfg.themeMode,
|
||||
FIF.BRUSH,
|
||||
self.tr('Application theme'),
|
||||
self.tr("Change the appearance of your application"),
|
||||
texts=[
|
||||
self.tr('Light'), self.tr('Dark'),
|
||||
self.tr('Use system setting')
|
||||
],
|
||||
parent=self.personalGroup
|
||||
)
|
||||
self.themeColorCard=CustomColorSettingCard(
|
||||
cfg.themeColor,
|
||||
FIF.PALETTE,
|
||||
self.tr('Theme color'),
|
||||
self.tr('Change the theme color of you application'),
|
||||
self.personalGroup
|
||||
)
|
||||
self.zoomCard = OptionsSettingCard(
|
||||
cfg.dpiScale,
|
||||
FIF.ZOOM,
|
||||
self.tr("Interface zoom"),
|
||||
self.tr("Change the size of widgets and fonts"),
|
||||
texts=[
|
||||
"100%", "125%", "150%", "175%", "200%",
|
||||
self.tr("Use system setting")
|
||||
],
|
||||
parent=self.personalGroup
|
||||
)
|
||||
self.languageCard = ComboBoxSettingCard(
|
||||
cfg.language,
|
||||
FIF.LANGUAGE,
|
||||
self.tr('Language'),
|
||||
self.tr('Set your preferred language for UI'),
|
||||
texts=['简体中文', '繁體中文', 'English', self.tr('Use system setting')],
|
||||
parent=self.personalGroup
|
||||
)
|
||||
|
||||
# online music
|
||||
self.onlineMusicGroup = SettingCardGroup(self.tr('Online Music'), self.scrollWidget)
|
||||
self.onlinePageSizeCard = RangeSettingCard(
|
||||
cfg.onlinePageSize,
|
||||
FIF.SEARCH,
|
||||
self.tr("Number of online music displayed on each page"),
|
||||
parent=self.onlineMusicGroup
|
||||
)
|
||||
self.onlineMusicQualityCard = OptionsSettingCard(
|
||||
cfg.onlineSongQuality,
|
||||
FIF.MUSIC,
|
||||
self.tr('Online music quality'),
|
||||
texts=[
|
||||
self.tr('Standard quality'), self.tr('High quality'),
|
||||
self.tr('Super quality'), self.tr('Lossless quality')
|
||||
],
|
||||
parent=self.onlineMusicGroup
|
||||
)
|
||||
self.onlineMvQualityCard = OptionsSettingCard(
|
||||
cfg.onlineMvQuality,
|
||||
FIF.VIDEO,
|
||||
self.tr('Online MV quality'),
|
||||
texts=[
|
||||
self.tr('Full HD'), self.tr('HD'),
|
||||
self.tr('SD'), self.tr('LD')
|
||||
],
|
||||
parent=self.onlineMusicGroup
|
||||
)
|
||||
|
||||
# desktop lyric
|
||||
self.deskLyricGroup = SettingCardGroup(self.tr('Desktop Lyric'), self.scrollWidget)
|
||||
self.deskLyricFontCard = PushSettingCard(
|
||||
self.tr('Choose font'),
|
||||
FIF.FONT,
|
||||
self.tr('Font'),
|
||||
parent=self.deskLyricGroup
|
||||
)
|
||||
self.deskLyricHighlightColorCard = ColorSettingCard(
|
||||
cfg.deskLyricHighlightColor,
|
||||
FIF.PALETTE,
|
||||
self.tr('Foreground color'),
|
||||
parent=self.deskLyricGroup
|
||||
)
|
||||
self.deskLyricStrokeColorCard = ColorSettingCard(
|
||||
cfg.deskLyricStrokeColor,
|
||||
FIF.PENCIL_INK,
|
||||
self.tr('Stroke color'),
|
||||
parent=self.deskLyricGroup
|
||||
)
|
||||
self.deskLyricStrokeSizeCard = RangeSettingCard(
|
||||
cfg.deskLyricStrokeSize,
|
||||
FIF.HIGHTLIGHT,
|
||||
self.tr('Stroke size'),
|
||||
parent=self.deskLyricGroup
|
||||
)
|
||||
self.deskLyricAlignmentCard = OptionsSettingCard(
|
||||
cfg.deskLyricAlignment,
|
||||
FIF.ALIGNMENT,
|
||||
self.tr('Alignment'),
|
||||
texts=[
|
||||
self.tr('Center aligned'), self.tr('Left aligned'),
|
||||
self.tr('Right aligned')
|
||||
],
|
||||
parent=self.deskLyricGroup
|
||||
)
|
||||
|
||||
# main panel
|
||||
self.mainPanelGroup = SettingCardGroup(self.tr('Main Panel'), self.scrollWidget)
|
||||
self.minimizeToTrayCard = SwitchSettingCard(
|
||||
FIF.MINIMIZE,
|
||||
self.tr('Minimize to tray after closing'),
|
||||
self.tr('PyQt-Fluent-Widgets will continue to run in the background'),
|
||||
configItem=cfg.minimizeToTray,
|
||||
parent=self.mainPanelGroup
|
||||
)
|
||||
|
||||
# update software
|
||||
self.updateSoftwareGroup = SettingCardGroup(self.tr("Software update"), self.scrollWidget)
|
||||
self.updateOnStartUpCard = SwitchSettingCard(
|
||||
FIF.UPDATE,
|
||||
self.tr('Check for updates when the application starts'),
|
||||
self.tr('The new version will be more stable and have more features'),
|
||||
configItem=cfg.checkUpdateAtStartUp,
|
||||
parent=self.updateSoftwareGroup
|
||||
)
|
||||
|
||||
# application
|
||||
self.aboutGroup = SettingCardGroup(self.tr('About'), self.scrollWidget)
|
||||
self.helpCard = HyperlinkCard(
|
||||
HELP_URL,
|
||||
self.tr('Open help page'),
|
||||
FIF.HELP,
|
||||
self.tr('Help'),
|
||||
self.tr('Discover new features and learn useful tips about PyQt-Fluent-Widgets'),
|
||||
self.aboutGroup
|
||||
)
|
||||
self.feedbackCard = PrimaryPushSettingCard(
|
||||
self.tr('Provide feedback'),
|
||||
FIF.FEEDBACK,
|
||||
self.tr('Provide feedback'),
|
||||
self.tr('Help us improve PyQt-Fluent-Widgets by providing feedback'),
|
||||
self.aboutGroup
|
||||
)
|
||||
self.aboutCard = PrimaryPushSettingCard(
|
||||
self.tr('Check update'),
|
||||
FIF.INFO,
|
||||
self.tr('About'),
|
||||
'© ' + self.tr('Copyright') + f" {YEAR}, {AUTHOR}. " +
|
||||
self.tr('Version') + f" {VERSION}",
|
||||
self.aboutGroup
|
||||
)
|
||||
|
||||
self.__initWidget()
|
||||
|
||||
def __initWidget(self):
|
||||
self.resize(1000, 800)
|
||||
self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
|
||||
self.setViewportMargins(0, 120, 0, 20)
|
||||
self.setWidget(self.scrollWidget)
|
||||
self.setWidgetResizable(True)
|
||||
|
||||
# initialize style sheet
|
||||
self.__setQss()
|
||||
|
||||
# initialize layout
|
||||
self.__initLayout()
|
||||
self.__connectSignalToSlot()
|
||||
|
||||
def __initLayout(self):
|
||||
self.settingLabel.move(60, 63)
|
||||
|
||||
# add cards to group
|
||||
self.musicInThisPCGroup.addSettingCard(self.musicFolderCard)
|
||||
self.musicInThisPCGroup.addSettingCard(self.downloadFolderCard)
|
||||
|
||||
self.personalGroup.addSettingCard(self.enableAcrylicCard)
|
||||
self.personalGroup.addSettingCard(self.themeCard)
|
||||
self.personalGroup.addSettingCard(self.themeColorCard)
|
||||
self.personalGroup.addSettingCard(self.zoomCard)
|
||||
self.personalGroup.addSettingCard(self.languageCard)
|
||||
|
||||
self.onlineMusicGroup.addSettingCard(self.onlinePageSizeCard)
|
||||
self.onlineMusicGroup.addSettingCard(self.onlineMusicQualityCard)
|
||||
self.onlineMusicGroup.addSettingCard(self.onlineMvQualityCard)
|
||||
|
||||
self.deskLyricGroup.addSettingCard(self.deskLyricFontCard)
|
||||
self.deskLyricGroup.addSettingCard(self.deskLyricHighlightColorCard)
|
||||
self.deskLyricGroup.addSettingCard(self.deskLyricStrokeColorCard)
|
||||
self.deskLyricGroup.addSettingCard(self.deskLyricStrokeSizeCard)
|
||||
self.deskLyricGroup.addSettingCard(self.deskLyricAlignmentCard)
|
||||
|
||||
self.updateSoftwareGroup.addSettingCard(self.updateOnStartUpCard)
|
||||
|
||||
self.mainPanelGroup.addSettingCard(self.minimizeToTrayCard)
|
||||
|
||||
self.aboutGroup.addSettingCard(self.helpCard)
|
||||
self.aboutGroup.addSettingCard(self.feedbackCard)
|
||||
self.aboutGroup.addSettingCard(self.aboutCard)
|
||||
|
||||
# add setting card group to layout
|
||||
self.expandLayout.setSpacing(28)
|
||||
self.expandLayout.setContentsMargins(60, 10, 60, 0)
|
||||
self.expandLayout.addWidget(self.musicInThisPCGroup)
|
||||
self.expandLayout.addWidget(self.personalGroup)
|
||||
self.expandLayout.addWidget(self.onlineMusicGroup)
|
||||
self.expandLayout.addWidget(self.deskLyricGroup)
|
||||
self.expandLayout.addWidget(self.mainPanelGroup)
|
||||
self.expandLayout.addWidget(self.updateSoftwareGroup)
|
||||
self.expandLayout.addWidget(self.aboutGroup)
|
||||
|
||||
def __setQss(self):
|
||||
""" set style sheet """
|
||||
self.scrollWidget.setObjectName('scrollWidget')
|
||||
self.settingLabel.setObjectName('settingLabel')
|
||||
|
||||
theme = 'dark' if isDarkTheme() else 'light'
|
||||
with open(f'resource/qss/{theme}/setting_interface.qss', encoding='utf-8') as f:
|
||||
self.setStyleSheet(f.read())
|
||||
|
||||
def __showRestartTooltip(self):
|
||||
""" show restart tooltip """
|
||||
InfoBar.warning(
|
||||
'',
|
||||
self.tr('Configuration takes effect after restart'),
|
||||
parent=self.window()
|
||||
)
|
||||
|
||||
def __onDeskLyricFontCardClicked(self):
|
||||
""" desktop lyric font button clicked slot """
|
||||
isOk, font = QFontDialog.getFont(
|
||||
cfg.desktopLyricFont, self.window(), self.tr("Choose font"))
|
||||
if isOk:
|
||||
cfg.desktopLyricFont = font
|
||||
|
||||
def __onDownloadFolderCardClicked(self):
|
||||
""" download folder card clicked slot """
|
||||
folder = QFileDialog.getExistingDirectory(
|
||||
self, self.tr("Choose folder"), "./")
|
||||
if not folder or cfg.get(cfg.downloadFolder) == folder:
|
||||
return
|
||||
|
||||
cfg.set(cfg.downloadFolder, folder)
|
||||
self.downloadFolderCard.setContent(folder)
|
||||
|
||||
def __onThemeChanged(self, theme: Theme):
|
||||
""" theme changed slot """
|
||||
# change the theme of qfluentwidgets
|
||||
setTheme(theme)
|
||||
|
||||
# chang the theme of setting interface
|
||||
self.__setQss()
|
||||
|
||||
def __connectSignalToSlot(self):
|
||||
""" connect signal to slot """
|
||||
cfg.appRestartSig.connect(self.__showRestartTooltip)
|
||||
cfg.themeChanged.connect(self.__onThemeChanged)
|
||||
|
||||
# music in the pc
|
||||
self.musicFolderCard.folderChanged.connect(
|
||||
self.musicFoldersChanged)
|
||||
self.downloadFolderCard.clicked.connect(
|
||||
self.__onDownloadFolderCardClicked)
|
||||
|
||||
# personalization
|
||||
self.enableAcrylicCard.checkedChanged.connect(
|
||||
self.acrylicEnableChanged)
|
||||
self.themeColorCard.colorChanged.connect(setThemeColor)
|
||||
|
||||
# playing interface
|
||||
self.deskLyricFontCard.clicked.connect(self.__onDeskLyricFontCardClicked)
|
||||
|
||||
# main panel
|
||||
self.minimizeToTrayCard.checkedChanged.connect(
|
||||
self.minimizeToTrayChanged)
|
||||
|
||||
# about
|
||||
self.aboutCard.clicked.connect(self.checkUpdateSig)
|
||||
self.feedbackCard.clicked.connect(
|
||||
lambda: QDesktopServices.openUrl(QUrl(FEEDBACK_URL)))
|
||||
49
examples/window/splash_screen/demo.py
Normal file
@ -0,0 +1,49 @@
|
||||
# coding:utf-8
|
||||
import sys
|
||||
|
||||
from PySide6.QtCore import Qt, QEventLoop, QTimer, QSize
|
||||
from PySide6.QtGui import QIcon
|
||||
from PySide6.QtWidgets import QApplication
|
||||
|
||||
from qfluentwidgets import SplashScreen
|
||||
from qframelesswindow import FramelessWindow, StandardTitleBar
|
||||
|
||||
|
||||
class Demo(FramelessWindow):
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.resize(700, 600)
|
||||
self.setWindowTitle('PyQt-Fluent-Widgets')
|
||||
self.setWindowIcon(QIcon(':/qfluentwidgets/images/logo.png'))
|
||||
|
||||
# create splash screen and show window
|
||||
self.splashScreen = SplashScreen(self.windowIcon(), self)
|
||||
self.splashScreen.setIconSize(QSize(102, 102))
|
||||
|
||||
# customize the title bar of splash screen
|
||||
# titleBar = StandardTitleBar(self.splashScreen)
|
||||
# titleBar.setIcon(self.windowIcon())
|
||||
# titleBar.setTitle(self.windowTitle())
|
||||
# self.splashScreen.setTitleBar(titleBar)
|
||||
|
||||
self.show()
|
||||
|
||||
# create other subinterfaces
|
||||
self.createSubInterface()
|
||||
|
||||
# close splash screen
|
||||
self.splashScreen.finish()
|
||||
|
||||
def createSubInterface(self):
|
||||
loop = QEventLoop(self)
|
||||
QTimer.singleShot(3000, loop.quit)
|
||||
loop.exec()
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
app = QApplication(sys.argv)
|
||||
w = Demo()
|
||||
w.show()
|
||||
app.exec()
|
||||
101
examples/window/split_fluent_window/demo.py
Normal file
@ -0,0 +1,101 @@
|
||||
# coding:utf-8
|
||||
import sys
|
||||
|
||||
from PySide6.QtCore import Qt, QUrl
|
||||
from PySide6.QtGui import QIcon, QDesktopServices
|
||||
from PySide6.QtWidgets import QApplication, QFrame, QHBoxLayout
|
||||
from qfluentwidgets import (NavigationItemPosition, MessageBox, setTheme, Theme, SplitFluentWindow,
|
||||
NavigationAvatarWidget, qrouter, SubtitleLabel, setFont)
|
||||
from qfluentwidgets import FluentIcon as FIF
|
||||
|
||||
|
||||
class Widget(QFrame):
|
||||
|
||||
def __init__(self, text: str, parent=None):
|
||||
super().__init__(parent=parent)
|
||||
self.label = SubtitleLabel(text, self)
|
||||
self.hBoxLayout = QHBoxLayout(self)
|
||||
|
||||
setFont(self.label, 24)
|
||||
self.label.setAlignment(Qt.AlignCenter)
|
||||
self.hBoxLayout.addWidget(self.label, 1, Qt.AlignCenter)
|
||||
self.setObjectName(text.replace(' ', '-'))
|
||||
|
||||
# !IMPORTANT: leave some space for title bar
|
||||
self.hBoxLayout.setContentsMargins(0, 32, 0, 0)
|
||||
|
||||
|
||||
class Window(SplitFluentWindow):
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
|
||||
# create sub interface
|
||||
self.homeInterface = Widget('Home Interface', self)
|
||||
self.musicInterface = Widget('Music Interface', self)
|
||||
self.videoInterface = Widget('Video Interface', self)
|
||||
self.folderInterface = Widget('Folder Interface', self)
|
||||
self.settingInterface = Widget('Setting Interface', self)
|
||||
self.albumInterface = Widget('Album Interface', self)
|
||||
self.albumInterface1 = Widget('Album Interface 1', self)
|
||||
self.albumInterface2 = Widget('Album Interface 2', self)
|
||||
self.albumInterface1_1 = Widget('Album Interface 1-1', self)
|
||||
|
||||
self.initNavigation()
|
||||
self.initWindow()
|
||||
|
||||
def initNavigation(self):
|
||||
self.addSubInterface(self.homeInterface, FIF.HOME, 'Home')
|
||||
self.addSubInterface(self.musicInterface, FIF.MUSIC, 'Music library')
|
||||
self.addSubInterface(self.videoInterface, FIF.VIDEO, 'Video library')
|
||||
|
||||
self.navigationInterface.addSeparator()
|
||||
|
||||
self.addSubInterface(self.albumInterface, FIF.ALBUM, 'Albums', NavigationItemPosition.SCROLL)
|
||||
self.addSubInterface(self.albumInterface1, FIF.ALBUM, 'Album 1', parent=self.albumInterface)
|
||||
self.addSubInterface(self.albumInterface1_1, FIF.ALBUM, 'Album 1.1', parent=self.albumInterface1)
|
||||
self.addSubInterface(self.albumInterface2, FIF.ALBUM, 'Album 2', parent=self.albumInterface)
|
||||
self.addSubInterface(self.folderInterface, FIF.FOLDER, 'Folder library', NavigationItemPosition.SCROLL)
|
||||
|
||||
# add custom widget to bottom
|
||||
self.navigationInterface.addWidget(
|
||||
routeKey='avatar',
|
||||
widget=NavigationAvatarWidget('zhiyiYo', 'resource/shoko.png'),
|
||||
onClick=self.showMessageBox,
|
||||
position=NavigationItemPosition.BOTTOM,
|
||||
)
|
||||
|
||||
self.addSubInterface(self.settingInterface, FIF.SETTING, 'Settings', NavigationItemPosition.BOTTOM)
|
||||
|
||||
# NOTE: enable acrylic effect
|
||||
# self.navigationInterface.setAcrylicEnabled(True)
|
||||
|
||||
def initWindow(self):
|
||||
self.resize(900, 700)
|
||||
self.setWindowIcon(QIcon(':/qfluentwidgets/images/logo.png'))
|
||||
self.setWindowTitle('PyQt-Fluent-Widgets')
|
||||
|
||||
desktop = QApplication.screens()[0].availableGeometry()
|
||||
w, h = desktop.width(), desktop.height()
|
||||
self.move(w//2 - self.width()//2, h//2 - self.height()//2)
|
||||
|
||||
def showMessageBox(self):
|
||||
w = MessageBox(
|
||||
'支持作者🥰',
|
||||
'个人开发不易,如果这个项目帮助到了您,可以考虑请作者喝一瓶快乐水🥤。您的支持就是作者开发和维护项目的动力🚀',
|
||||
self
|
||||
)
|
||||
w.yesButton.setText('来啦老弟')
|
||||
w.cancelButton.setText('下次一定')
|
||||
|
||||
if w.exec():
|
||||
QDesktopServices.openUrl(QUrl("https://afdian.net/a/zhiyiYo"))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
setTheme(Theme.DARK)
|
||||
|
||||
app = QApplication(sys.argv)
|
||||
w = Window()
|
||||
w.show()
|
||||
app.exec()
|
||||
BIN
examples/window/split_fluent_window/resource/shoko.png
Normal file
|
After Width: | Height: | Size: 262 KiB |
60
examples/window/web_engine/demo.py
Normal file
@ -0,0 +1,60 @@
|
||||
# coding:utf-8
|
||||
import sys
|
||||
|
||||
from PySide6.QtCore import Qt, QUrl
|
||||
from PySide6.QtGui import QIcon, QDesktopServices
|
||||
from PySide6.QtWidgets import QApplication, QFrame, QHBoxLayout, QVBoxLayout
|
||||
from qfluentwidgets import setTheme, Theme, SubtitleLabel, setFont, SplitFluentWindow
|
||||
from qfluentwidgets import FluentIcon as FIF
|
||||
from qframelesswindow.webengine import FramelessWebEngineView
|
||||
|
||||
|
||||
class Widget(QFrame):
|
||||
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(parent=parent)
|
||||
self.setObjectName("homeInterface")
|
||||
|
||||
self.webView = FramelessWebEngineView(self)
|
||||
self.webView.load(QUrl("https://www.baidu.com/"))
|
||||
|
||||
self.vBoxLayout = QVBoxLayout(self)
|
||||
self.vBoxLayout.setContentsMargins(0, 48, 0, 0)
|
||||
self.vBoxLayout.addWidget(self.webView)
|
||||
|
||||
|
||||
class Window(SplitFluentWindow):
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
|
||||
# create sub interface
|
||||
self.homeInterface = Widget(self)
|
||||
|
||||
self.initNavigation()
|
||||
self.initWindow()
|
||||
|
||||
def initNavigation(self):
|
||||
self.addSubInterface(self.homeInterface, FIF.HOME, "Home")
|
||||
|
||||
# NOTE: enable acrylic effect
|
||||
# self.navigationInterface.setAcrylicEnabled(True)
|
||||
|
||||
def initWindow(self):
|
||||
self.resize(900, 700)
|
||||
self.setWindowIcon(QIcon(':/qfluentwidgets/images/logo.png'))
|
||||
self.setWindowTitle('PyQt-Fluent-Widgets')
|
||||
|
||||
desktop = QApplication.screens()[0].availableGeometry()
|
||||
w, h = desktop.width(), desktop.height()
|
||||
self.move(w//2 - self.width()//2, h//2 - self.height()//2)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
# setTheme(Theme.DARK)
|
||||
|
||||
app = QApplication(sys.argv)
|
||||
w = Window()
|
||||
w.show()
|
||||
w.setMicaEffectEnabled(True)
|
||||
app.exec()
|
||||