Skip to content

Commit

Permalink
Prevent users from using "Batch Translation" button without their own…
Browse files Browse the repository at this point in the history
… API key.
  • Loading branch information
philpw99 committed Dec 23, 2024
1 parent e88d2b0 commit c20b1af
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion app/view/subtitle_optimization_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from PyQt5.QtCore import *
from PyQt5.QtGui import QDragEnterEvent, QDropEvent, QColor
from PyQt5.QtWidgets import QAbstractItemView
from PyQt5.QtWidgets import QWidget, QVBoxLayout, QHBoxLayout, QApplication, QHeaderView, QFileDialog
from PyQt5.QtWidgets import QWidget, QVBoxLayout, QHBoxLayout, QApplication, QHeaderView, QFileDialog, QMessageBox
from qfluentwidgets import ComboBox, PrimaryPushButton, ProgressBar, PushButton, InfoBar, BodyLabel, TableView, ToolButton, TextEdit, MessageBoxBase, RoundMenu, Action, FluentIcon as FIF
from qfluentwidgets import InfoBarPosition
from PyQt5.QtCore import QUrl
Expand Down Expand Up @@ -600,6 +600,15 @@ def on_batch_file_select(self):
并获取用户选择的文件路径。
- 加载字幕文件:如果用户选择了多个文件,调用 load_subtitle_file 方法加载这些文件。
"""
# Batch processing only for people with their own API key.
if cfg.api_key.value == "" or cfg.api_base.value == "":
QMessageBox.warning(
self,
self.tr("No API Key or API Base set"),
self.tr("批量字幕处理占用大量服务器资源,因此必须要使用自己的API KEY & BASE,免得公益服务器无法工作,请见谅。\n具体设定在程序左下角的‘设定’里。"),
)
return

# 构建文件过滤器
subtitle_formats = " ".join(f"*.{fmt.value}" for fmt in SupportedSubtitleFormats)
filter_str = f"{self.tr('字幕文件')} ({subtitle_formats})"
Expand All @@ -609,6 +618,7 @@ def on_batch_file_select(self):
# self.file_select_button.setProperty("selected_file", file_path)
# self.load_subtitle_file(file_path)
# self.process()

self.file_queue.extend(file_paths) # 将文件路径加入队列
self._process_next_file() # 开始处理队列中的第一个文件

Expand Down

0 comments on commit c20b1af

Please sign in to comment.