2026-04-27 09:52:10 +08:00
|
|
|
|
"""Entry: `python -m voice_confirmation_client` or `voice-confirmation-client`."""
|
|
|
|
|
|
|
|
|
|
|
|
from __future__ import annotations
|
|
|
|
|
|
|
2026-04-27 11:21:16 +08:00
|
|
|
|
import signal
|
2026-04-27 09:52:10 +08:00
|
|
|
|
import sys
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def main() -> None:
|
2026-04-27 11:21:16 +08:00
|
|
|
|
from PySide6.QtCore import QTimer
|
2026-04-27 09:52:10 +08:00
|
|
|
|
from PySide6.QtWidgets import QApplication
|
|
|
|
|
|
|
|
|
|
|
|
from voice_confirmation_client.gui.main_window import MainWindow
|
|
|
|
|
|
|
|
|
|
|
|
app = QApplication(sys.argv)
|
|
|
|
|
|
win = MainWindow()
|
|
|
|
|
|
win.show()
|
2026-04-27 11:21:16 +08:00
|
|
|
|
|
|
|
|
|
|
app.aboutToQuit.connect(win.shutdown)
|
|
|
|
|
|
|
|
|
|
|
|
# Qt 事件循环长时间跑在 native 代码里时,Python 无法处理 SIGINT;定时器让解释器周期性醒来。
|
|
|
|
|
|
_pulse = QTimer()
|
|
|
|
|
|
_pulse.timeout.connect(lambda: None)
|
|
|
|
|
|
_pulse.start(200)
|
|
|
|
|
|
|
|
|
|
|
|
def _on_sigint(_signum: int, _frame: object | None) -> None:
|
|
|
|
|
|
app.quit()
|
|
|
|
|
|
|
|
|
|
|
|
signal.signal(signal.SIGINT, _on_sigint)
|
|
|
|
|
|
|
2026-04-27 09:52:10 +08:00
|
|
|
|
raise SystemExit(app.exec())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
|
|
main()
|