fix(gui): stop quitting when the last window closes; add device and verify

Accepting the settings dialog quit the app: with a tray-resident program
"last window closed" must not mean "quit", but QApplication's default
made it so, and on first run the dialog is the only window. Disable
quitOnLastWindowClosed. Also fix listOutputDevices hanging forever
(its callbacks never signalled the PulseAudio main loop), enlarge the
caption window's close button, and add capture-device selection
(enumerated sinks, settings combo, --list-devices/--device) plus model
integrity verification (size + sha256 in the registry, --verify-model and
a "校验完整性" button).

点「确定」后程序自己退出:本程序常驻托盘,"最后一个窗口关闭"不该等于退出,
但 QApplication 默认如此,而首次启动时设置对话框正是唯一窗口。已关闭该默认
行为。同时修复 listOutputDevices 永久卡死(回调没有 signal 主循环)、放大
字幕窗关闭按钮,并新增采集设备选择与模型完整性校验(注册表含 size/sha256,
提供 --verify-model 与设置里的「校验完整性」按钮)。
This commit is contained in:
blumia committed 2026-10-12 17:03:20 +08:00
1 parent a7a6f3e6b6
commit 0fa0bcb44a
19 files changed
+460 -55

No files matched your search

+13 -1
View File
@@ -7,6 +7,16 @@
namespace lc {
// 一个可选的采集源(输出设备的 monitor)
struct AudioOutputDevice {
std::string sink; // 设备名
std::string description; // 人类可读描述
bool isDefault = false;
};
// 列出所有输出设备(供设置界面选择采集源)
std::vector<AudioOutputDevice> listOutputDevices(std::string * error = nullptr);
// 读取 WAV(PCM 16/24/32 位或 float32),降混为单声道并重采样到 targetRate。
bool readWavMono(const std::string & path, int targetRate,
std::vector<float> & out, std::string * error);
@@ -23,7 +33,9 @@ public:
MonitorCapture(const MonitorCapture &) = delete;
MonitorCapture & operator=(const MonitorCapture &) = delete;
bool start(int targetRate, ChunkCallback callback, std::string * error);
// device: 空 = 跟随系统默认输出;否则是 sink 名(见 listOutputDevices)
bool start(int targetRate, ChunkCallback callback, std::string * error,
const std::string & device = std::string());
void stop();
// 实际采集的 monitor 源名(start 成功后有效)