75 lines
3.0 KiB
Python
75 lines
3.0 KiB
Python
# Copyright (c) 2025 Jeffrey Hsu - JITToolBox
|
|
# #
|
|
# This program is free software: you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
# (at your option) any later version.
|
|
# #
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
# #
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
from PySide6.QtGui import QIcon, QShowEvent
|
|
from qfluentwidgets import FluentIcon, MSFluentWindow, NavigationItemPosition, MessageBox, setThemeColor
|
|
|
|
from ui import MAIN_THEME_COLOR, BLUE_BACKGROUND_COLOR
|
|
from ui.pyui.about_ui import AboutWidget
|
|
from ui.pyui.achievement_ui import AchievementWidget
|
|
from ui.pyui.defense_ui import DefenseWidget
|
|
# from ui.pyui.picker_ui import PickerWidget
|
|
from ui.pyui.test_ui import TestWidget
|
|
from utils.function import RELEASE_ENV
|
|
|
|
|
|
class MainWindow(MSFluentWindow):
|
|
def __init__(self):
|
|
super().__init__()
|
|
|
|
setThemeColor(MAIN_THEME_COLOR)
|
|
self.setCustomBackgroundColor(BLUE_BACKGROUND_COLOR, BLUE_BACKGROUND_COLOR)
|
|
|
|
self.achievementInterface = AchievementWidget('Achievement Interface', self)
|
|
self.defenseInterface = DefenseWidget('Defense Interface', self)
|
|
self.aboutInterface = AboutWidget('About Interface', self)
|
|
# self.pickerInterface = PickerWidget('Picker Interface', self)
|
|
if not RELEASE_ENV:
|
|
self.testInterface = TestWidget('Test Interface', self)
|
|
|
|
self.achievementInterface.error.connect(self.showError)
|
|
self.defenseInterface.errorSignal.connect(self.showError)
|
|
# self.pickerInterface.errorSignal.connect(self.showError)
|
|
|
|
self.initNavigation()
|
|
self.initWindow()
|
|
|
|
def initNavigation(self):
|
|
self.addSubInterface(self.achievementInterface, FluentIcon.SPEED_HIGH, '达成度')
|
|
self.addSubInterface(self.defenseInterface, FluentIcon.FEEDBACK, '答辩')
|
|
# self.addSubInterface(self.pickerInterface, FluentIcon.PEOPLE, '提问')
|
|
if not RELEASE_ENV:
|
|
self.addSubInterface(self.testInterface, FluentIcon.VIEW, '测试')
|
|
|
|
self.addSubInterface(self.aboutInterface, FluentIcon.INFO, '关于', position=NavigationItemPosition.BOTTOM)
|
|
|
|
def initWindow(self):
|
|
self.resize(900, 700)
|
|
self.setWindowTitle('教学工具箱')
|
|
self.setWindowIcon(QIcon(':/images/logo.png'))
|
|
|
|
def showError(self, title: str, message: str):
|
|
box = MessageBox(title, message, self)
|
|
box.yesButton.setText("关闭")
|
|
box.cancelButton.hide()
|
|
box.exec()
|
|
|
|
def showEvent(self, event: QShowEvent):
|
|
super().showEvent(event)
|
|
if RELEASE_ENV:
|
|
import pyi_splash
|
|
pyi_splash.update_text('正在加载...')
|
|
pyi_splash.close()
|