Add files via upload
This commit is contained in:
1 parent
d3e8504706
commit
502309ad24
25 files changed
+4097
-3006
No files matched your search
@@ -23,7 +23,7 @@ from PyQt6.QtGui import (
|
||||
QRadialGradient, QShortcut,
|
||||
)
|
||||
from PyQt6.QtWidgets import (
|
||||
QApplication, QFileDialog, QFrame, QHBoxLayout, QLabel, QLineEdit,
|
||||
QApplication, QComboBox, QFileDialog, QFrame, QHBoxLayout, QLabel, QLineEdit,
|
||||
QMainWindow, QPushButton, QScrollArea, QSizePolicy, QTextEdit,
|
||||
QVBoxLayout, QWidget, QProgressBar,
|
||||
)
|
||||
@@ -856,111 +856,85 @@ class _DropCanvas(QWidget):
|
||||
|
||||
|
||||
class SetupOverlay(QWidget):
|
||||
done = pyqtSignal(str, str)
|
||||
# Emits a JSON string containing the full config dict
|
||||
done = pyqtSignal(str)
|
||||
|
||||
def __init__(self, parent=None):
|
||||
# ------------------------------------------------------------------ #
|
||||
_INPUT_STYLE = "" # filled in __init__ after C is available
|
||||
|
||||
def __init__(self, parent=None, initial: dict | None = None, mode: str = "init"):
|
||||
super().__init__(parent)
|
||||
self._mode = mode
|
||||
_init = initial or {}
|
||||
self.setAttribute(Qt.WidgetAttribute.WA_StyledBackground, True)
|
||||
self.setStyleSheet(f"""
|
||||
SetupOverlay {{
|
||||
background: rgba(0, 6, 10, 245);
|
||||
background: rgba(0, 6, 10, 248);
|
||||
border: 1px solid {C.BORDER_B};
|
||||
border-radius: 6px;
|
||||
}}
|
||||
""")
|
||||
|
||||
detected = {"darwin": "mac", "windows": "windows"}.get(
|
||||
_OS.lower(), "linux"
|
||||
)
|
||||
self._sel_os = detected
|
||||
|
||||
layout = QVBoxLayout(self)
|
||||
layout.setContentsMargins(30, 22, 30, 22)
|
||||
layout.setSpacing(8)
|
||||
|
||||
def _lbl(txt, font_size=9, bold=False, color=C.PRI,
|
||||
align=Qt.AlignmentFlag.AlignCenter):
|
||||
w = QLabel(txt)
|
||||
w.setAlignment(align)
|
||||
w.setFont(QFont("Courier New", font_size,
|
||||
QFont.Weight.Bold if bold else QFont.Weight.Normal))
|
||||
w.setStyleSheet(f"color: {color}; background: transparent;")
|
||||
return w
|
||||
|
||||
layout.addWidget(_lbl("◈ INITIALISATION REQUIRED", 13, True))
|
||||
layout.addWidget(_lbl("Configure J.A.R.V.I.S. before first boot.", 9, color=C.PRI_DIM))
|
||||
layout.addSpacing(6)
|
||||
|
||||
sep = QFrame(); sep.setFrameShape(QFrame.Shape.HLine)
|
||||
sep.setStyleSheet(f"color: {C.BORDER};"); layout.addWidget(sep)
|
||||
layout.addSpacing(4)
|
||||
|
||||
layout.addWidget(_lbl("GEMINI API KEY", 8, color=C.TEXT_DIM,
|
||||
align=Qt.AlignmentFlag.AlignLeft))
|
||||
self._key_input = QLineEdit()
|
||||
self._key_input.setEchoMode(QLineEdit.EchoMode.Password)
|
||||
self._key_input.setPlaceholderText("AIza…")
|
||||
self._key_input.setFont(QFont("Courier New", 10))
|
||||
self._key_input.setFixedHeight(32)
|
||||
self._key_input.setStyleSheet(f"""
|
||||
_INPUT = f"""
|
||||
QLineEdit {{
|
||||
background: #000d12; color: {C.TEXT};
|
||||
border: 1px solid {C.BORDER}; border-radius: 3px; padding: 4px 8px;
|
||||
border: 1px solid {C.BORDER}; border-radius: 3px; padding: 3px 7px;
|
||||
font-family: 'Courier New'; font-size: 9pt;
|
||||
}}
|
||||
QLineEdit:focus {{ border: 1px solid {C.PRI}; }}
|
||||
""")
|
||||
layout.addWidget(self._key_input)
|
||||
layout.addSpacing(12)
|
||||
"""
|
||||
|
||||
sep2 = QFrame(); sep2.setFrameShape(QFrame.Shape.HLine)
|
||||
sep2.setStyleSheet(f"color: {C.BORDER};"); layout.addWidget(sep2)
|
||||
layout.addSpacing(4)
|
||||
self._sel_stt = _init.get("stt_engine", "whisper")
|
||||
self._sel_tts = _init.get("tts_engine", "edgetts")
|
||||
|
||||
layout.addWidget(_lbl("OPERATING SYSTEM", 8, color=C.TEXT_DIM,
|
||||
align=Qt.AlignmentFlag.AlignLeft))
|
||||
det_name = {"windows": "Windows", "mac": "macOS", "linux": "Linux"}[detected]
|
||||
layout.addWidget(_lbl(f"Auto-detected: {det_name}", 8, color=C.ACC2,
|
||||
align=Qt.AlignmentFlag.AlignLeft))
|
||||
layout = QVBoxLayout(self)
|
||||
layout.setContentsMargins(22, 16, 22, 16)
|
||||
layout.setSpacing(6)
|
||||
|
||||
os_row = QHBoxLayout(); os_row.setSpacing(6)
|
||||
self._os_btns: dict[str, QPushButton] = {}
|
||||
for key, label in [("windows","⊞ Windows"),("mac"," macOS"),("linux","🐧 Linux")]:
|
||||
btn = QPushButton(label)
|
||||
btn.setFont(QFont("Courier New", 9, QFont.Weight.Bold))
|
||||
btn.setFixedHeight(32)
|
||||
btn.setCursor(Qt.CursorShape.PointingHandCursor)
|
||||
btn.clicked.connect(lambda _, k=key: self._sel(k))
|
||||
os_row.addWidget(btn)
|
||||
self._os_btns[key] = btn
|
||||
layout.addLayout(os_row)
|
||||
self._sel(detected)
|
||||
layout.addSpacing(12)
|
||||
def _lbl(txt, sz=9, bold=False, col=C.PRI, align=Qt.AlignmentFlag.AlignCenter):
|
||||
w = QLabel(txt); w.setAlignment(align)
|
||||
w.setFont(QFont("Courier New", sz,
|
||||
QFont.Weight.Bold if bold else QFont.Weight.Normal))
|
||||
w.setStyleSheet(f"color: {col}; background: transparent;")
|
||||
return w
|
||||
|
||||
init_btn = QPushButton("▸ INITIALISE SYSTEMS")
|
||||
init_btn.setFont(QFont("Courier New", 10, QFont.Weight.Bold))
|
||||
init_btn.setFixedHeight(36)
|
||||
init_btn.setCursor(Qt.CursorShape.PointingHandCursor)
|
||||
init_btn.setStyleSheet(f"""
|
||||
QPushButton {{
|
||||
background: transparent; color: {C.PRI};
|
||||
border: 1px solid {C.PRI_DIM}; border-radius: 3px;
|
||||
}}
|
||||
QPushButton:hover {{
|
||||
background: {C.PRI_GHO}; border: 1px solid {C.PRI};
|
||||
}}
|
||||
""")
|
||||
init_btn.clicked.connect(self._submit)
|
||||
layout.addWidget(init_btn)
|
||||
def _sep():
|
||||
s = QFrame(); s.setFrameShape(QFrame.Shape.HLine)
|
||||
s.setStyleSheet(f"color: {C.BORDER}; margin: 2px 0;")
|
||||
return s
|
||||
|
||||
def _sel(self, key: str):
|
||||
self._sel_os = key
|
||||
pal = {"windows":(C.PRI,"#001a22"),"mac":(C.ACC2,"#1a1400"),"linux":(C.GREEN,"#001a0d")}
|
||||
for k, btn in self._os_btns.items():
|
||||
if k == key:
|
||||
fg, bg = pal[k]
|
||||
def _input(placeholder="", pw=False, fixed_h=28):
|
||||
w = QLineEdit()
|
||||
w.setPlaceholderText(placeholder)
|
||||
w.setFixedHeight(fixed_h)
|
||||
if pw:
|
||||
w.setEchoMode(QLineEdit.EchoMode.Password)
|
||||
w.setStyleSheet(_INPUT)
|
||||
return w
|
||||
|
||||
def _toggle_row(keys_labels: list, getter, setter):
|
||||
row = QHBoxLayout(); row.setSpacing(5)
|
||||
btns: dict[str, QPushButton] = {}
|
||||
def _click(k):
|
||||
setter(k)
|
||||
for bk, b in btns.items():
|
||||
_style_btn(b, bk == k)
|
||||
for k, lbl in keys_labels:
|
||||
b = QPushButton(lbl)
|
||||
b.setFixedHeight(26)
|
||||
b.setFont(QFont("Courier New", 8, QFont.Weight.Bold))
|
||||
b.setCursor(Qt.CursorShape.PointingHandCursor)
|
||||
b.clicked.connect(lambda _, kk=k: _click(kk))
|
||||
row.addWidget(b)
|
||||
btns[k] = b
|
||||
_click(getter())
|
||||
return row, btns
|
||||
|
||||
def _style_btn(btn: QPushButton, active: bool):
|
||||
if active:
|
||||
btn.setStyleSheet(f"""
|
||||
QPushButton {{
|
||||
background: {fg}; color: {bg};
|
||||
background: {C.PRI}; color: #001a22;
|
||||
border: none; border-radius: 3px; font-weight: bold;
|
||||
}}
|
||||
""")
|
||||
@@ -973,15 +947,335 @@ class SetupOverlay(QWidget):
|
||||
QPushButton:hover {{ color: {C.TEXT}; border: 1px solid {C.BORDER_B}; }}
|
||||
""")
|
||||
|
||||
# ── Header ──────────────────────────────────────────────────── #
|
||||
if mode == "config":
|
||||
layout.addWidget(_lbl("◈ CONFIGURATION", 12, True))
|
||||
layout.addWidget(_lbl("Update J.A.R.V.I.S. settings and click Apply.", 8, col=C.PRI_DIM))
|
||||
else:
|
||||
layout.addWidget(_lbl("◈ INITIALISATION REQUIRED", 12, True))
|
||||
layout.addWidget(_lbl("Configure J.A.R.V.I.S. before first boot.", 8, col=C.PRI_DIM))
|
||||
layout.addWidget(_sep())
|
||||
|
||||
# ── STT ──────────────────────────────────────────────────────── #
|
||||
layout.addWidget(_lbl("SPEECH-TO-TEXT ENGINE", 7, col=C.TEXT_DIM,
|
||||
align=Qt.AlignmentFlag.AlignLeft))
|
||||
stt_row, self._stt_btns = _toggle_row(
|
||||
[("whisper","🎙 Whisper"), ("vosk","🔊 Vosk")],
|
||||
lambda: self._sel_stt,
|
||||
self._set_stt,
|
||||
)
|
||||
layout.addLayout(stt_row)
|
||||
|
||||
_COMBO_STYLE = f"""
|
||||
QComboBox {{
|
||||
background: #000d12; color: {C.TEXT};
|
||||
border: 1px solid {C.BORDER}; border-radius: 3px; padding: 3px 7px;
|
||||
font-family: 'Courier New'; font-size: 9pt;
|
||||
}}
|
||||
QComboBox:focus {{ border: 1px solid {C.PRI}; }}
|
||||
QComboBox::drop-down {{ border: none; width: 18px; }}
|
||||
QComboBox QAbstractItemView {{
|
||||
background: #000d12; color: {C.TEXT};
|
||||
border: 1px solid {C.BORDER};
|
||||
selection-background-color: {C.PRI_GHO};
|
||||
font-family: 'Courier New'; font-size: 9pt;
|
||||
}}
|
||||
"""
|
||||
|
||||
stt_detail = QHBoxLayout(); stt_detail.setSpacing(5)
|
||||
stt_detail.addWidget(_lbl("Model:", 7, col=C.TEXT_MED,
|
||||
align=Qt.AlignmentFlag.AlignRight))
|
||||
|
||||
# Whisper: dropdown with predefined sizes
|
||||
self._whisper_combo = QComboBox()
|
||||
self._whisper_combo.setFixedHeight(28)
|
||||
self._whisper_combo.setStyleSheet(_COMBO_STYLE)
|
||||
for m in ["tiny", "base", "small", "medium", "large-v3"]:
|
||||
self._whisper_combo.addItem(m)
|
||||
_cur_model = _init.get("stt_model", "base")
|
||||
_idx = self._whisper_combo.findText(_cur_model)
|
||||
self._whisper_combo.setCurrentIndex(_idx if _idx >= 0 else 1)
|
||||
stt_detail.addWidget(self._whisper_combo)
|
||||
|
||||
# Vosk: free-text path input
|
||||
self._vosk_model_input = _input("model dir path (leave empty for auto-download)")
|
||||
self._vosk_model_input.setText(_init.get("vosk_model_path", ""))
|
||||
stt_detail.addWidget(self._vosk_model_input)
|
||||
|
||||
layout.addLayout(stt_detail)
|
||||
|
||||
# Initial visibility
|
||||
self._whisper_combo.setVisible(self._sel_stt == "whisper")
|
||||
self._vosk_model_input.setVisible(self._sel_stt == "vosk")
|
||||
|
||||
stt_lang_row = QHBoxLayout(); stt_lang_row.setSpacing(5)
|
||||
stt_lang_row.addWidget(_lbl("Language:", 7, col=C.TEXT_MED,
|
||||
align=Qt.AlignmentFlag.AlignRight))
|
||||
self._stt_lang_input = _input("auto (or: tr / en / de / fr / es / zh …)")
|
||||
self._stt_lang_input.setText(_init.get("stt_language", "auto"))
|
||||
stt_lang_row.addWidget(self._stt_lang_input)
|
||||
layout.addLayout(stt_lang_row)
|
||||
layout.addWidget(_sep())
|
||||
|
||||
# ── LLM ──────────────────────────────────────────────────────── #
|
||||
layout.addWidget(_lbl("LOCAL LLM (Ollama)", 7, col=C.TEXT_DIM,
|
||||
align=Qt.AlignmentFlag.AlignLeft))
|
||||
llm_row = QHBoxLayout(); llm_row.setSpacing(5)
|
||||
llm_row.addWidget(_lbl("URL:", 7, col=C.TEXT_MED,
|
||||
align=Qt.AlignmentFlag.AlignRight))
|
||||
self._llm_url_input = _input("http://localhost:11434")
|
||||
self._llm_url_input.setText(_init.get("llm_url", "http://localhost:11434"))
|
||||
llm_row.addWidget(self._llm_url_input, stretch=2)
|
||||
llm_row.addWidget(_lbl("Model:", 7, col=C.TEXT_MED,
|
||||
align=Qt.AlignmentFlag.AlignRight))
|
||||
self._llm_model_input = _input("e.g. llama3.2 / qwen2.5 / mistral")
|
||||
self._llm_model_input.setText(_init.get("llm_model", ""))
|
||||
llm_row.addWidget(self._llm_model_input, stretch=2)
|
||||
layout.addLayout(llm_row)
|
||||
layout.addWidget(_sep())
|
||||
|
||||
# ── TTS ──────────────────────────────────────────────────────── #
|
||||
layout.addWidget(_lbl("TEXT-TO-SPEECH ENGINE", 7, col=C.TEXT_DIM,
|
||||
align=Qt.AlignmentFlag.AlignLeft))
|
||||
tts_row, self._tts_btns = _toggle_row(
|
||||
[("edgetts","🔈 EdgeTTS"), ("kokoro","🤖 Kokoro"), ("elevenlabs","⚡ ElevenLabs")],
|
||||
lambda: self._sel_tts,
|
||||
self._set_tts,
|
||||
)
|
||||
layout.addLayout(tts_row)
|
||||
|
||||
voice_row = QHBoxLayout(); voice_row.setSpacing(5)
|
||||
self._voice_lbl = QLabel("Voice:")
|
||||
self._voice_lbl.setFont(QFont("Courier New", 7))
|
||||
self._voice_lbl.setAlignment(Qt.AlignmentFlag.AlignRight | Qt.AlignmentFlag.AlignVCenter)
|
||||
self._voice_lbl.setStyleSheet(f"color: {C.TEXT_MED}; background: transparent;")
|
||||
voice_row.addWidget(self._voice_lbl)
|
||||
|
||||
self._tts_voice_input = _input("en-US-GuyNeural")
|
||||
self._tts_voice_input.setText(_init.get("tts_voice", "en-US-GuyNeural"))
|
||||
voice_row.addWidget(self._tts_voice_input)
|
||||
|
||||
# Kokoro: dropdown with predefined voices (hidden unless Kokoro selected)
|
||||
self._kokoro_combo = QComboBox()
|
||||
self._kokoro_combo.setFixedHeight(28)
|
||||
self._kokoro_combo.setStyleSheet(_COMBO_STYLE)
|
||||
_KOKORO_VOICES = [
|
||||
("af_heart", "af_heart — EN-F warm (recommended)"),
|
||||
("af_sky", "af_sky — EN-F clear"),
|
||||
("af_bella", "af_bella — EN-F bella"),
|
||||
("af_sarah", "af_sarah — EN-F sarah"),
|
||||
("am_adam", "am_adam — EN-M adam"),
|
||||
("am_michael", "am_michael — EN-M michael"),
|
||||
("bf_emma", "bf_emma — UK-F emma"),
|
||||
("bf_isabella", "bf_isabella — UK-F isabella"),
|
||||
("bm_george", "bm_george — UK-M george"),
|
||||
("bm_lewis", "bm_lewis — UK-M lewis"),
|
||||
("jf_alpha", "jf_alpha — Japanese Female"),
|
||||
("jm_kumo", "jm_kumo — Japanese Male"),
|
||||
]
|
||||
for val, display in _KOKORO_VOICES:
|
||||
self._kokoro_combo.addItem(display, userData=val)
|
||||
_cur_voice = _init.get("tts_voice", "af_heart")
|
||||
for i in range(self._kokoro_combo.count()):
|
||||
if self._kokoro_combo.itemData(i) == _cur_voice:
|
||||
self._kokoro_combo.setCurrentIndex(i)
|
||||
break
|
||||
self._kokoro_combo.setVisible(False) # shown only when Kokoro active
|
||||
voice_row.addWidget(self._kokoro_combo)
|
||||
|
||||
layout.addLayout(voice_row)
|
||||
|
||||
# Kokoro speed — only visible when Kokoro is selected
|
||||
self._kokoro_speed_widget = QWidget()
|
||||
self._kokoro_speed_widget.setStyleSheet("background: transparent;")
|
||||
ks_row = QHBoxLayout(self._kokoro_speed_widget)
|
||||
ks_row.setContentsMargins(0, 0, 0, 0)
|
||||
ks_row.setSpacing(5)
|
||||
ks_row.addWidget(_lbl("Speed:", 7, col=C.TEXT_MED,
|
||||
align=Qt.AlignmentFlag.AlignRight))
|
||||
self._kokoro_speed_combo = QComboBox()
|
||||
self._kokoro_speed_combo.setFixedHeight(28)
|
||||
self._kokoro_speed_combo.setStyleSheet(_COMBO_STYLE)
|
||||
for val, label in [
|
||||
("0.8", "0.8× — Slow"),
|
||||
("1.0", "1.0× — Normal"),
|
||||
("1.1", "1.1× — Slightly fast"),
|
||||
("1.2", "1.2× — Fast (recommended)"),
|
||||
("1.3", "1.3× — Faster"),
|
||||
("1.5", "1.5× — Very fast"),
|
||||
]:
|
||||
self._kokoro_speed_combo.addItem(label, userData=val)
|
||||
_cur_speed = str(_init.get("tts_speed", "1.2"))
|
||||
for i in range(self._kokoro_speed_combo.count()):
|
||||
if self._kokoro_speed_combo.itemData(i) == _cur_speed:
|
||||
self._kokoro_speed_combo.setCurrentIndex(i)
|
||||
break
|
||||
ks_row.addWidget(self._kokoro_speed_combo)
|
||||
layout.addWidget(self._kokoro_speed_widget)
|
||||
|
||||
# ElevenLabs key — only visible when ElevenLabs is selected
|
||||
self._el_key_widget = QWidget()
|
||||
self._el_key_widget.setStyleSheet("background: transparent;")
|
||||
el_row = QHBoxLayout(self._el_key_widget)
|
||||
el_row.setContentsMargins(0, 0, 0, 0)
|
||||
el_row.setSpacing(5)
|
||||
el_row.addWidget(_lbl("API Key:", 7, col=C.TEXT_MED,
|
||||
align=Qt.AlignmentFlag.AlignRight))
|
||||
self._el_key_input = _input("ElevenLabs API key", pw=True)
|
||||
self._el_key_input.setText(_init.get("elevenlabs_api_key", ""))
|
||||
el_row.addWidget(self._el_key_input)
|
||||
layout.addWidget(self._el_key_widget)
|
||||
|
||||
layout.addWidget(_sep())
|
||||
|
||||
# Set correct initial state for TTS UI
|
||||
self._update_tts_ui(self._sel_tts)
|
||||
|
||||
# ── Action buttons ─────────────────────────────────────────────── #
|
||||
btn_row = QHBoxLayout(); btn_row.setSpacing(8)
|
||||
|
||||
if mode == "config":
|
||||
cancel_btn = QPushButton("✕ CANCEL")
|
||||
cancel_btn.setFont(QFont("Courier New", 9, QFont.Weight.Bold))
|
||||
cancel_btn.setFixedHeight(34)
|
||||
cancel_btn.setCursor(Qt.CursorShape.PointingHandCursor)
|
||||
cancel_btn.setStyleSheet(f"""
|
||||
QPushButton {{
|
||||
background: transparent; color: {C.TEXT_DIM};
|
||||
border: 1px solid {C.BORDER}; border-radius: 3px;
|
||||
}}
|
||||
QPushButton:hover {{
|
||||
color: {C.RED}; border: 1px solid {C.RED};
|
||||
}}
|
||||
""")
|
||||
cancel_btn.clicked.connect(self.hide)
|
||||
btn_row.addWidget(cancel_btn)
|
||||
|
||||
btn_label = "▸ APPLY CHANGES" if mode == "config" else "▸ INITIALISE SYSTEMS"
|
||||
init_btn = QPushButton(btn_label)
|
||||
init_btn.setFont(QFont("Courier New", 10, QFont.Weight.Bold))
|
||||
init_btn.setFixedHeight(34)
|
||||
init_btn.setCursor(Qt.CursorShape.PointingHandCursor)
|
||||
init_btn.setStyleSheet(f"""
|
||||
QPushButton {{
|
||||
background: transparent; color: {C.PRI};
|
||||
border: 1px solid {C.PRI_DIM}; border-radius: 3px;
|
||||
}}
|
||||
QPushButton:hover {{
|
||||
background: {C.PRI_GHO}; border: 1px solid {C.PRI};
|
||||
}}
|
||||
""")
|
||||
init_btn.clicked.connect(self._submit)
|
||||
btn_row.addWidget(init_btn)
|
||||
layout.addLayout(btn_row)
|
||||
|
||||
# ------------------------------------------------------------------ #
|
||||
def _update_tts_ui(self, key: str) -> None:
|
||||
"""Show/hide and relabel TTS fields based on selected engine."""
|
||||
if not hasattr(self, "_voice_lbl"):
|
||||
return
|
||||
|
||||
is_kokoro = (key == "kokoro")
|
||||
|
||||
# Kokoro uses a dropdown; other engines use a text input
|
||||
if hasattr(self, "_tts_voice_input"):
|
||||
self._tts_voice_input.setVisible(not is_kokoro)
|
||||
if hasattr(self, "_kokoro_combo"):
|
||||
self._kokoro_combo.setVisible(is_kokoro)
|
||||
|
||||
if key == "elevenlabs":
|
||||
self._voice_lbl.setText("Voice ID:")
|
||||
if hasattr(self, "_tts_voice_input"):
|
||||
self._tts_voice_input.setPlaceholderText("ElevenLabs voice ID")
|
||||
elif key == "kokoro":
|
||||
self._voice_lbl.setText("Voice:")
|
||||
else: # edgetts
|
||||
self._voice_lbl.setText("Voice:")
|
||||
if hasattr(self, "_tts_voice_input"):
|
||||
self._tts_voice_input.setPlaceholderText(
|
||||
"en-US-GuyNeural / en-GB-RyanNeural / tr-TR-AhmetNeural …"
|
||||
)
|
||||
|
||||
if hasattr(self, "_kokoro_speed_widget"):
|
||||
self._kokoro_speed_widget.setVisible(is_kokoro)
|
||||
if hasattr(self, "_el_key_widget"):
|
||||
self._el_key_widget.setVisible(key == "elevenlabs")
|
||||
|
||||
def _set_stt(self, key: str):
|
||||
self._sel_stt = key
|
||||
if not hasattr(self, "_stt_btns"):
|
||||
return
|
||||
for k, btn in self._stt_btns.items():
|
||||
active = (k == key)
|
||||
btn.setStyleSheet(f"""
|
||||
QPushButton {{
|
||||
background: {'#00d4ff' if active else '#000d12'};
|
||||
color: {'#001a22' if active else C.TEXT_DIM};
|
||||
border: {'none' if active else f'1px solid {C.BORDER}'};
|
||||
border-radius: 3px; font-weight: {'bold' if active else 'normal'};
|
||||
}}
|
||||
QPushButton:hover {{ color: {C.TEXT}; border: 1px solid {C.BORDER_B}; }}
|
||||
""")
|
||||
# Toggle model selector widgets
|
||||
if hasattr(self, "_whisper_combo"):
|
||||
self._whisper_combo.setVisible(key == "whisper")
|
||||
if hasattr(self, "_vosk_model_input"):
|
||||
self._vosk_model_input.setVisible(key == "vosk")
|
||||
|
||||
def _set_tts(self, key: str):
|
||||
self._sel_tts = key
|
||||
if not hasattr(self, "_tts_btns"):
|
||||
return
|
||||
for k, btn in self._tts_btns.items():
|
||||
active = (k == key)
|
||||
btn.setStyleSheet(f"""
|
||||
QPushButton {{
|
||||
background: {'#00d4ff' if active else '#000d12'};
|
||||
color: {'#001a22' if active else C.TEXT_DIM};
|
||||
border: {'none' if active else f'1px solid {C.BORDER}'};
|
||||
border-radius: 3px; font-weight: {'bold' if active else 'normal'};
|
||||
}}
|
||||
QPushButton:hover {{ color: {C.TEXT}; border: 1px solid {C.BORDER_B}; }}
|
||||
""")
|
||||
self._update_tts_ui(key)
|
||||
|
||||
def _submit(self):
|
||||
key = self._key_input.text().strip()
|
||||
if not key:
|
||||
self._key_input.setStyleSheet(
|
||||
self._key_input.styleSheet() +
|
||||
llm_model = self._llm_model_input.text().strip()
|
||||
if not llm_model:
|
||||
self._llm_model_input.setStyleSheet(
|
||||
self._llm_model_input.styleSheet() +
|
||||
f" QLineEdit {{ border: 1px solid {C.RED}; }}"
|
||||
)
|
||||
return
|
||||
self.done.emit(key, self._sel_os)
|
||||
|
||||
# STT model: combo for Whisper, text input for Vosk
|
||||
if self._sel_stt == "whisper":
|
||||
stt_model = self._whisper_combo.currentText()
|
||||
else:
|
||||
stt_model = self._vosk_model_input.text().strip()
|
||||
|
||||
# Voice: Kokoro uses dropdown, others use text input
|
||||
if self._sel_tts == "kokoro":
|
||||
tts_voice = self._kokoro_combo.currentData() or "af_heart"
|
||||
tts_speed = self._kokoro_speed_combo.currentData() or "1.2"
|
||||
else:
|
||||
tts_voice = self._tts_voice_input.text().strip() or "en-US-GuyNeural"
|
||||
tts_speed = "1.0"
|
||||
|
||||
cfg = {
|
||||
"stt_engine": self._sel_stt,
|
||||
"stt_model": stt_model,
|
||||
"stt_language": self._stt_lang_input.text().strip() or "auto",
|
||||
"llm_url": self._llm_url_input.text().strip() or "http://localhost:11434",
|
||||
"llm_model": llm_model,
|
||||
"tts_engine": self._sel_tts,
|
||||
"tts_voice": tts_voice,
|
||||
"tts_speed": tts_speed,
|
||||
"elevenlabs_api_key": self._el_key_input.text().strip(),
|
||||
}
|
||||
if self._sel_stt == "vosk" and stt_model:
|
||||
cfg["vosk_model_path"] = stt_model
|
||||
self.done.emit(json.dumps(cfg))
|
||||
|
||||
|
||||
class MainWindow(QMainWindow):
|
||||
@@ -990,7 +1284,7 @@ class MainWindow(QMainWindow):
|
||||
|
||||
def __init__(self, face_path: str):
|
||||
super().__init__()
|
||||
self.setWindowTitle("J.A.R.V.I.S — MARK XXXIX")
|
||||
self.setWindowTitle("J.A.R.V.I.S — MARK XL")
|
||||
self.setMinimumSize(_MIN_W, _MIN_H)
|
||||
self.resize(_DEFAULT_W, _DEFAULT_H)
|
||||
|
||||
@@ -1045,6 +1339,7 @@ class MainWindow(QMainWindow):
|
||||
self._state_sig.connect(self._apply_state)
|
||||
|
||||
self._overlay: SetupOverlay | None = None
|
||||
self._on_reconfigure_cb = None
|
||||
self._ready = self._check_config()
|
||||
if not self._ready:
|
||||
self._show_setup()
|
||||
@@ -1063,7 +1358,7 @@ class MainWindow(QMainWindow):
|
||||
def resizeEvent(self, event):
|
||||
super().resizeEvent(event)
|
||||
if self._overlay and self._overlay.isVisible():
|
||||
ow, oh = 460, 390
|
||||
ow, oh = 520, 580
|
||||
cw = self.centralWidget()
|
||||
self._overlay.setGeometry(
|
||||
(cw.width() - ow) // 2,
|
||||
@@ -1135,7 +1430,7 @@ class MainWindow(QMainWindow):
|
||||
l.setStyleSheet(f"color: {color}; background: transparent;")
|
||||
return l
|
||||
|
||||
lay.addWidget(_badge("MARK XXXIX", C.PRI_DIM))
|
||||
lay.addWidget(_badge("MARK XL", C.PRI_DIM))
|
||||
lay.addStretch()
|
||||
|
||||
mid = QVBoxLayout(); mid.setSpacing(1)
|
||||
@@ -1227,7 +1522,7 @@ class MainWindow(QMainWindow):
|
||||
for txt, col in [
|
||||
("AI CORE\nACTIVE", C.GREEN),
|
||||
("SEC\nCLEARED", C.PRI),
|
||||
("PROTOCOL\nXXXVIII", C.TEXT_DIM),
|
||||
("PROTOCOL\nXL", C.TEXT_DIM),
|
||||
]:
|
||||
lbl = QLabel(txt)
|
||||
lbl.setFont(QFont("Courier New", 7, QFont.Weight.Bold))
|
||||
@@ -1303,6 +1598,22 @@ class MainWindow(QMainWindow):
|
||||
fs_btn.clicked.connect(self._toggle_fullscreen)
|
||||
lay.addWidget(fs_btn)
|
||||
|
||||
cfg_btn = QPushButton("⚙ CONFIGURE")
|
||||
cfg_btn.setFixedHeight(26)
|
||||
cfg_btn.setFont(QFont("Courier New", 7))
|
||||
cfg_btn.setCursor(Qt.CursorShape.PointingHandCursor)
|
||||
cfg_btn.setStyleSheet(f"""
|
||||
QPushButton {{
|
||||
background: transparent; color: {C.TEXT_MED};
|
||||
border: 1px solid {C.BORDER}; border-radius: 3px;
|
||||
}}
|
||||
QPushButton:hover {{
|
||||
color: {C.ACC2}; border: 1px solid {C.ACC2};
|
||||
}}
|
||||
""")
|
||||
cfg_btn.clicked.connect(self._show_config)
|
||||
lay.addWidget(cfg_btn)
|
||||
|
||||
return w
|
||||
|
||||
def _build_input_row(self) -> QHBoxLayout:
|
||||
@@ -1349,7 +1660,7 @@ class MainWindow(QMainWindow):
|
||||
|
||||
lay.addWidget(_fl("[F4] Mute · [F11] Fullscreen"))
|
||||
lay.addStretch()
|
||||
lay.addWidget(_fl("FatihMakes Industries · MARK XXXIX · CLASSIFIED"))
|
||||
lay.addWidget(_fl("FatihMakes Industries · MARK XL · CLASSIFIED"))
|
||||
lay.addStretch()
|
||||
lay.addWidget(_fl("© FATIHMAKES", C.PRI_DIM))
|
||||
return w
|
||||
@@ -1417,14 +1728,18 @@ class MainWindow(QMainWindow):
|
||||
if not API_FILE.exists(): return False
|
||||
try:
|
||||
d = json.loads(API_FILE.read_text(encoding="utf-8"))
|
||||
return bool(d.get("gemini_api_key")) and bool(d.get("os_system"))
|
||||
return (
|
||||
bool(d.get("llm_model")) and
|
||||
bool(d.get("stt_engine")) and
|
||||
bool(d.get("tts_engine"))
|
||||
)
|
||||
except Exception:
|
||||
return False
|
||||
|
||||
def _show_setup(self):
|
||||
ov = SetupOverlay(self.centralWidget())
|
||||
cw = self.centralWidget()
|
||||
ow, oh = 460, 390
|
||||
ow, oh = 520, 580
|
||||
ov.setGeometry(
|
||||
(cw.width() - ow) // 2,
|
||||
(cw.height() - oh) // 2,
|
||||
@@ -1434,10 +1749,14 @@ class MainWindow(QMainWindow):
|
||||
ov.show()
|
||||
self._overlay = ov
|
||||
|
||||
def _on_setup_done(self, key: str, os_name: str):
|
||||
def _on_setup_done(self, config_json: str):
|
||||
try:
|
||||
cfg = json.loads(config_json)
|
||||
except Exception:
|
||||
cfg = {}
|
||||
os.makedirs(CONFIG_DIR, exist_ok=True)
|
||||
API_FILE.write_text(
|
||||
json.dumps({"gemini_api_key": key, "os_system": os_name}, indent=4),
|
||||
json.dumps(cfg, indent=4),
|
||||
encoding="utf-8",
|
||||
)
|
||||
self._ready = True
|
||||
@@ -1445,7 +1764,50 @@ class MainWindow(QMainWindow):
|
||||
self._overlay.hide()
|
||||
self._overlay = None
|
||||
self._apply_state("LISTENING")
|
||||
self._log.append_log(f"SYS: Initialised. OS={os_name.upper()}. JARVIS online.")
|
||||
llm = cfg.get("llm_model", "")
|
||||
stt = cfg.get("stt_engine", "")
|
||||
tts = cfg.get("tts_engine", "")
|
||||
self._log.append_log(
|
||||
f"SYS: Initialised. LLM={llm} | STT={stt} | TTS={tts}"
|
||||
)
|
||||
|
||||
def _show_config(self):
|
||||
if self._overlay and self._overlay.isVisible():
|
||||
return
|
||||
current: dict = {}
|
||||
try:
|
||||
current = json.loads(API_FILE.read_text(encoding="utf-8"))
|
||||
except Exception:
|
||||
pass
|
||||
ov = SetupOverlay(self.centralWidget(), initial=current, mode="config")
|
||||
cw = self.centralWidget()
|
||||
ow, oh = 520, 600
|
||||
ov.setGeometry(
|
||||
(cw.width() - ow) // 2,
|
||||
(cw.height() - oh) // 2,
|
||||
ow, oh,
|
||||
)
|
||||
ov.done.connect(self._on_config_done)
|
||||
ov.show()
|
||||
self._overlay = ov
|
||||
|
||||
def _on_config_done(self, config_json: str):
|
||||
try:
|
||||
cfg = json.loads(config_json)
|
||||
except Exception:
|
||||
cfg = {}
|
||||
os.makedirs(CONFIG_DIR, exist_ok=True)
|
||||
API_FILE.write_text(json.dumps(cfg, indent=4), encoding="utf-8")
|
||||
if self._overlay:
|
||||
self._overlay.hide()
|
||||
self._overlay = None
|
||||
llm = cfg.get("llm_model", "")
|
||||
stt = cfg.get("stt_engine", "")
|
||||
tts = cfg.get("tts_engine", "")
|
||||
self._log.append_log(f"SYS: Config updated. LLM={llm} | STT={stt} | TTS={tts}")
|
||||
if self._on_reconfigure_cb:
|
||||
self._on_reconfigure_cb(cfg)
|
||||
|
||||
|
||||
class _RootShim:
|
||||
def __init__(self, app: QApplication):
|
||||
@@ -1485,6 +1847,14 @@ class JarvisUI:
|
||||
def on_text_command(self, cb):
|
||||
self._win.on_text_command = cb
|
||||
|
||||
@property
|
||||
def on_reconfigure(self):
|
||||
return self._win._on_reconfigure_cb
|
||||
|
||||
@on_reconfigure.setter
|
||||
def on_reconfigure(self, cb):
|
||||
self._win._on_reconfigure_cb = cb
|
||||
|
||||
def set_state(self, state: str):
|
||||
self._win._state_sig.emit(state)
|
||||
|
||||
|
||||
Reference in new issue
Block a user