Skip to content

Commit

Permalink
Update DouyinCatcher-FluentUI.py
Browse files Browse the repository at this point in the history
  • Loading branch information
HShiDianLu authored Nov 25, 2023
1 parent bac6dd4 commit 6da880f
Showing 1 changed file with 35 additions and 35 deletions.
70 changes: 35 additions & 35 deletions DouyinCatcher-FluentUI.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from qfluentwidgets import FluentIcon as FIF
from configparser import *

VERSION = "v3.2-FluentUI"
VERSION = "v3.3-FluentUI"
FILEDIR = "C:/DouyinCatcher"

# 创建图标
Expand Down Expand Up @@ -716,8 +716,6 @@ def __init__(self):
self.retranslateUi()
QMetaObject.connectSlotsByName(self)

# setupUi

def retranslateUi(self):
self.TitleLabel.setText(QCoreApplication.translate("Form", u"Douyin Catcher", None))
self.CaptionLabel.setText(
Expand Down Expand Up @@ -746,8 +744,6 @@ def retranslateUi(self):
self.StrongBodyLabel_2.setText(
QCoreApplication.translate("Form", u"\u89c6\u9891/\u56fe\u7247\u5217\u8868", None))

# retranslateUi

# 切换选项
def changeVideo(self):
self.cType = "V"
Expand Down Expand Up @@ -1076,8 +1072,6 @@ def __init__(self):

QMetaObject.connectSlotsByName(self)

# setupUi

def retranslateUi(self):
self.setWindowTitle(QCoreApplication.translate("Form", u"Douyin Catcher", None))
self.TitleLabel.setText(QCoreApplication.translate("Form", u"\u8bbe\u7f6e", None))
Expand All @@ -1099,8 +1093,6 @@ def retranslateUi(self):
self.SwitchButton.setOnText(QCoreApplication.translate("Form", u"\u542f\u7528", None))
self.SwitchButton.setOffText(QCoreApplication.translate("Form", u"\u7981\u7528", None))

# retranslateUi

def changeMica(self):
if self.SwitchButton.isChecked():
changeVal("UI", "mica", "1")
Expand Down Expand Up @@ -1291,8 +1283,6 @@ def __init__(self):

QMetaObject.connectSlotsByName(self)

# setupUi`

def retranslateUi(self):
self.setWindowTitle(QCoreApplication.translate("Form", u"Douyin Catcher", None))
self.TitleLabel.setText(QCoreApplication.translate("Form", u"\u5173\u4e8e", None))
Expand All @@ -1314,8 +1304,6 @@ def retranslateUi(self):
self.CaptionLabel_2.setText(QCoreApplication.translate("Form", u"Licensed under The MIT License", None))
self.CaptionLabel_3.setText(QCoreApplication.translate("Form", u"Copyright \u00a9 2023 by HShiDianLu.", None))

# retranslateUi

def openFluentGitHub(self):
QDesktopServices.openUrl(QUrl("https://github.com/zhiyiYo/PyQt-Fluent-Widgets"))

Expand All @@ -1324,18 +1312,14 @@ def openGitHub(self):


class CustomTitleBar(TitleBar):
""" Title bar with icon and title """

def __init__(self, parent):
super().__init__(parent)
# add window icon
self.iconLabel = QLabel(self)
self.iconLabel.setFixedSize(18, 18)
self.hBoxLayout.insertSpacing(0, 10)
self.hBoxLayout.insertWidget(1, self.iconLabel, 0, Qt.AlignLeft | Qt.AlignBottom)
self.window().windowIconChanged.connect(self.setIcon)

# add title label
self.titleLabel = QLabel(self)
self.hBoxLayout.insertWidget(2, self.titleLabel, 0, Qt.AlignLeft | Qt.AlignBottom)
self.titleLabel.setObjectName('titleLabel')
Expand All @@ -1355,30 +1339,53 @@ def setIcon(self, icon):
WindowType = FramelessWindow


class StackedWidget(QFrame):
currentChanged = pyqtSignal(int)

def __init__(self, parent=None):
super().__init__(parent=parent)
self.hBoxLayout = QHBoxLayout(self)
self.view = PopUpAniStackedWidget(self)

self.hBoxLayout.setContentsMargins(0, 0, 0, 0)
self.hBoxLayout.addWidget(self.view)

self.view.currentChanged.connect(self.currentChanged)

def addWidget(self, widget):
self.view.addWidget(widget)

def widget(self, index: int):
return self.view.widget(index)

def setCurrentWidget(self, widget, anim=True):
if anim:
self.view.setCurrentWidget(widget, False, False, 300, QEasingCurve.OutQuad)
else:
self.view.setCurrentWidget(widget, False, False, 0)

def setCurrentIndex(self, index, anim=False):
self.setCurrentWidget(self.view.widget(index), anim)


class MenuUi(WindowType):

def __init__(self):
super().__init__()
if not config["mica"]:
self.setTitleBar(CustomTitleBar(self))

# use dark theme mode
# setTheme(Theme.DARK)

self.hBoxLayout = QHBoxLayout(self)
self.navigationInterface = NavigationInterface(
self, showMenuButton=True, showReturnButton=True)
self.stackWidget = QStackedWidget(self)
self.stackWidget = StackedWidget(self)

# create sub interface
self.mainInterface = MainUi()
self.aboutInterface = InfoUi()
self.settingInterface = SettingUi()

# initialize layout
self.initLayout()

# add items to navigation interface
self.initNavigation()

self.initWindow()
Expand All @@ -1394,23 +1401,18 @@ def initLayout(self):
self.navigationInterface.displayModeChanged.connect(self.titleBar.raise_)

def initNavigation(self):
# enable acrylic effect
self.navigationInterface.setAcrylicEnabled(True)

self.addSubInterface(self.mainInterface, FIF.DOWNLOAD, '首页')
self.addSubInterface(self.settingInterface, FIF.SETTING, '设置')
self.addSubInterface(self.aboutInterface, FIF.INFO, '关于', NavigationItemPosition.BOTTOM)

# !IMPORTANT: don't forget to set the default route key
qrouter.setDefaultRouteKey(self.stackWidget, self.aboutInterface.objectName())

# set the maximum width
# self.navigationInterface.setExpandWidth(300)

self.stackWidget.currentChanged.connect(self.onCurrentInterfaceChanged)
self.stackWidget.setCurrentIndex(2)
self.stackWidget.setCurrentIndex(2, False)

self.switchTo(self.mainInterface)
self.switchTo(self.mainInterface, False)

def initWindow(self):
self.resize(772, 515)
Expand All @@ -1419,7 +1421,6 @@ def initWindow(self):
icon.addPixmap(QPixmap(ico_path), QIcon.Normal, QIcon.Off)
self.setWindowIcon(icon)
self.setWindowTitle('Douyin Catcher | ' + VERSION)
# self.setFixedSize(self.width(), self.height())
self.setMinimumSize(self.width(), self.height())

self.titleBar.setAttribute(Qt.WA_StyledBackground)
Expand All @@ -1431,7 +1432,6 @@ def initWindow(self):
self.setQss()

def addSubInterface(self, interface, icon, text: str, position=NavigationItemPosition.TOP):
""" add sub interface """
self.stackWidget.addWidget(interface)
self.navigationInterface.addItem(
routeKey=interface.objectName(),
Expand All @@ -1448,8 +1448,8 @@ def setQss(self):
else:
self.setStyleSheet(LIGHTQSS)

def switchTo(self, widget):
self.stackWidget.setCurrentWidget(widget)
def switchTo(self, widget, anim=True):
self.stackWidget.setCurrentWidget(widget, anim)

def onCurrentInterfaceChanged(self, index):
widget = self.stackWidget.widget(index)
Expand Down

0 comments on commit 6da880f

Please sign in to comment.