| 31 | |
| 32 | |
| 33 | class MainWindow(FluentWindow): |
| 34 | def __init__(self): |
| 35 | super().__init__() |
| 36 | self.initWindow() |
| 37 | |
| 38 | # 创建子界面 |
| 39 | self.homeInterface = HomeInterface(self) |
| 40 | self.settingInterface = SettingInterface(self) |
| 41 | self.subtitleStyleInterface = SubtitleStyleInterface(self) |
| 42 | self.batchProcessInterface = BatchProcessInterface(self) |
| 43 | self.llmLogsInterface = LLMLogsInterface(self) |
| 44 | |
| 45 | # 初始化版本检查器 |
| 46 | self.versionChecker = VersionChecker() |
| 47 | self.versionChecker.newVersionAvailable.connect(self.onNewVersion) |
| 48 | self.versionChecker.announcementAvailable.connect(self.onAnnouncement) |
| 49 | |
| 50 | self.versionThread = QThread() |
| 51 | self.versionChecker.moveToThread(self.versionThread) |
| 52 | self.versionThread.started.connect(self.versionChecker.perform_check) |
| 53 | self.versionThread.start() |
| 54 | |
| 55 | # 初始化导航界面 |
| 56 | self.initNavigation() |
| 57 | self.splashScreen.finish() |
| 58 | |
| 59 | # 检查系统依赖 |
| 60 | self._check_ffmpeg() |
| 61 | |
| 62 | # 注册退出处理, 清理进程 |
| 63 | atexit.register(self.stop) |
| 64 | |
| 65 | def initNavigation(self): |
| 66 | """初始化导航栏""" |
| 67 | # 添加导航项 |
| 68 | self.addSubInterface(self.homeInterface, FIF.HOME, self.tr("主页")) |
| 69 | self.addSubInterface(self.batchProcessInterface, FIF.VIDEO, self.tr("批量处理")) |
| 70 | self.addSubInterface(self.subtitleStyleInterface, FIF.FONT, self.tr("字幕样式")) |
| 71 | self.addSubInterface(self.llmLogsInterface, FIF.HISTORY, self.tr("请求日志")) |
| 72 | |
| 73 | self.navigationInterface.addSeparator() |
| 74 | |
| 75 | # 在底部添加自定义小部件 |
| 76 | self.navigationInterface.addItem( |
| 77 | routeKey="avatar", |
| 78 | text="GitHub", |
| 79 | icon=FIF.GITHUB, |
| 80 | onClick=self.onGithubDialog, |
| 81 | position=NavigationItemPosition.BOTTOM, |
| 82 | ) |
| 83 | self.addSubInterface( |
| 84 | self.settingInterface, |
| 85 | FIF.SETTING, |
| 86 | self.tr("Settings"), |
| 87 | NavigationItemPosition.BOTTOM, |
| 88 | ) |
| 89 | |
| 90 | # 设置默认界面 |