The GUI no longer needs command line arguments: on first run it opens a settings dialog that lists the registry, downloads models in-app (mirror base, HTTP proxy, resume), and picks the active model. The caption window gains a tray icon (show/hide, settings, quit); its close button hides to the tray so the window can always be brought back, and the language pill opens the settings. Appearance (font, opacity, line counts, position) is persisted. CLI flags remain for automated testing and override settings. GUI 不再依赖命令行参数:首次启动打开设置对话框,可在应用内下载模型 (下载源/代理/断点续传)、选择当前模型与识别语言;字幕窗增加托盘(显示 隐藏/设置/退出),关闭按钮改为隐藏到托盘以免关掉后无法再打开,语言标签 点击进设置;字号/透明度/行数/位置都会持久化。命令行参数保留作自动化测试。
73 lines
2.0 KiB
C++
73 lines
2.0 KiB
C++
#pragma once
|
|
|
|
#include <QPoint>
|
|
#include <QWidget>
|
|
|
|
class QLabel;
|
|
class QPushButton;
|
|
class QTextEdit;
|
|
|
|
namespace lc {
|
|
|
|
// 悬浮字幕窗(对应 Chrome 实时字幕那种样式):
|
|
// 无边框、置顶、不接受焦点;折叠时两行,展开后多行。
|
|
class CaptionWindow : public QWidget {
|
|
Q_OBJECT
|
|
|
|
public:
|
|
explicit CaptionWindow(QWidget * parent = nullptr);
|
|
|
|
// committed 为已稳定文本,tail 为不稳定尾部(暗色显示)
|
|
void setCaption(const QString & committed, const QString & tail);
|
|
void setLanguage(const QString & language);
|
|
|
|
bool isCollapsed() const { return collapsed_; }
|
|
void setCollapsed(bool collapsed);
|
|
|
|
// 背景不透明度(百分比)。范围限制在 20~100:
|
|
// 太低会让字幕在任何桌面背景下都读不清,所以不给到全透明。
|
|
void setPanelOpacity(int percent);
|
|
int panelOpacity() const { return opacityPercent_; }
|
|
|
|
void setTextFontSize(int px);
|
|
void setLineCounts(int collapsed, int expanded);
|
|
void setShowTail(bool on);
|
|
|
|
Q_SIGNALS:
|
|
void languageClicked();
|
|
void closed();
|
|
void moved(const QPoint & topLeft);
|
|
|
|
protected:
|
|
void mousePressEvent(QMouseEvent * e) override;
|
|
void mouseMoveEvent(QMouseEvent * e) override;
|
|
void mouseReleaseEvent(QMouseEvent * e) override;
|
|
void paintEvent(QPaintEvent * e) override;
|
|
|
|
private:
|
|
int lineHeight() const;
|
|
int textHeight() const; // 按折叠/展开计算文本区高度
|
|
void relayout();
|
|
void scrollToEnd();
|
|
void applyStyle();
|
|
|
|
QPushButton * langPill_ = nullptr;
|
|
QPushButton * closeBtn_ = nullptr;
|
|
QPushButton * toggleBtn_ = nullptr;
|
|
QTextEdit * text_ = nullptr;
|
|
|
|
bool collapsed_ = true;
|
|
bool showTail_ = true;
|
|
int fontSize_ = 15;
|
|
int collapsedLines_ = 2;
|
|
int expandedLines_ = 8;
|
|
int opacityPercent_ = 84; // 背景不透明度(百分比)
|
|
bool dragging_ = false;
|
|
QPoint dragOffset_;
|
|
QString language_;
|
|
QString committed_;
|
|
QString tail_;
|
|
};
|
|
|
|
} // namespace lc
|