prod
This commit is contained in:
1 parent
5ae45d615e
commit
9e201bf12e
40 files changed
+4896
-490
No files matched your search
@@ -52,6 +52,7 @@ DEFAULT_CONFIG = {
|
||||
"log_history": True,
|
||||
"check_updates": True, # Check for app updates on startup
|
||||
"update_url": "", # Optional custom release metadata URL
|
||||
"language": "auto", # "auto", "it", "en"
|
||||
}
|
||||
|
||||
|
||||
|
||||
+122
-89
@@ -15,6 +15,7 @@ from PySide6.QtWidgets import (
|
||||
QApplication,
|
||||
QButtonGroup,
|
||||
QCheckBox,
|
||||
QComboBox,
|
||||
QDialog,
|
||||
QFormLayout,
|
||||
QFrame,
|
||||
@@ -39,6 +40,7 @@ from PySide6.QtWidgets import (
|
||||
|
||||
from autostart import is_autostart_enabled, set_autostart
|
||||
from config import load_config
|
||||
from i18n import get_language, set_language, tr
|
||||
from server_core import BarcodeServerCore, generate_qr_image
|
||||
from tray import ServerTrayIcon, load_app_icon
|
||||
from updater import (
|
||||
@@ -90,7 +92,7 @@ QFrame#Card {
|
||||
border: 1px solid #334155;
|
||||
border-radius: 12px;
|
||||
}
|
||||
QLineEdit, QTextEdit {
|
||||
QLineEdit, QTextEdit, QComboBox {
|
||||
background-color: #0F172A;
|
||||
color: #F8FAFC;
|
||||
border: 1px solid #475569;
|
||||
@@ -98,6 +100,11 @@ QLineEdit, QTextEdit {
|
||||
padding: 7px 10px;
|
||||
selection-background-color: #0284C7;
|
||||
}
|
||||
QComboBox QAbstractItemView {
|
||||
background-color: #1E293B;
|
||||
color: #F8FAFC;
|
||||
selection-background-color: #0284C7;
|
||||
}
|
||||
QLineEdit:focus, QTextEdit:focus {
|
||||
border-color: #38BDF8;
|
||||
}
|
||||
@@ -234,7 +241,7 @@ class UpdateDialog(QDialog):
|
||||
self.on_ready_to_exit = on_ready_to_exit
|
||||
self._download_worker: Optional[_UpdateDownloadWorker] = None
|
||||
|
||||
self.setWindowTitle(f"Aggiornamento Disponibile — v{release.version}")
|
||||
self.setWindowTitle(tr("update_win_title", version=release.version))
|
||||
self.setMinimumWidth(480)
|
||||
self.setStyleSheet(DARK_STYLESHEET)
|
||||
|
||||
@@ -242,16 +249,18 @@ class UpdateDialog(QDialog):
|
||||
layout.setContentsMargins(20, 20, 20, 20)
|
||||
layout.setSpacing(12)
|
||||
|
||||
title_lbl = QLabel(f"Nuova versione disponibile: v{release.version}")
|
||||
title_lbl = QLabel(tr("update_new_version", version=release.version))
|
||||
title_lbl.setStyleSheet("font-size: 16px; font-weight: 700; color: #38BDF8;")
|
||||
layout.addWidget(title_lbl)
|
||||
|
||||
subtitle_lbl = QLabel(f"Versione installata: v{APP_VERSION} • {release.title}")
|
||||
subtitle_lbl = QLabel(
|
||||
tr("update_installed_sub", version=APP_VERSION, title=release.title)
|
||||
)
|
||||
subtitle_lbl.setStyleSheet("color: #94A3B8;")
|
||||
subtitle_lbl.setWordWrap(True)
|
||||
layout.addWidget(subtitle_lbl)
|
||||
|
||||
notes_text = (release.notes or "").strip() or "Nessuna nota di rilascio specificata."
|
||||
notes_text = (release.notes or "").strip() or tr("update_no_notes")
|
||||
self.notes_box = QTextEdit()
|
||||
self.notes_box.setReadOnly(True)
|
||||
self.notes_box.setMinimumHeight(140)
|
||||
@@ -263,14 +272,12 @@ class UpdateDialog(QDialog):
|
||||
self.status_lbl.setWordWrap(True)
|
||||
self.status_lbl.setStyleSheet("color: #94A3B8; font-size: 12px;")
|
||||
if self.asset is None:
|
||||
self.status_lbl.setText(
|
||||
"Nessun pacchetto specifico trovato per questa piattaforma negli asset della release."
|
||||
)
|
||||
self.status_lbl.setText(tr("update_no_asset"))
|
||||
elif not self.can_auto:
|
||||
self.status_lbl.setText(self.auto_reason)
|
||||
else:
|
||||
size_mb = f" ({self.asset.size / (1024 * 1024):.1f} MB)" if self.asset.size > 0 else ""
|
||||
self.status_lbl.setText(f"Pacchetto pronto per l'installazione: {self.asset.name}{size_mb}")
|
||||
self.status_lbl.setText(tr("update_ready_pkg", name=self.asset.name, size=size_mb))
|
||||
layout.addWidget(self.status_lbl)
|
||||
|
||||
self.progress_bar = QProgressBar()
|
||||
@@ -278,17 +285,17 @@ class UpdateDialog(QDialog):
|
||||
layout.addWidget(self.progress_bar)
|
||||
|
||||
btn_row = QHBoxLayout()
|
||||
self.btn_later = QPushButton("Più Tardi")
|
||||
self.btn_later = QPushButton(tr("btn_later"))
|
||||
self.btn_later.clicked.connect(self.reject)
|
||||
btn_row.addWidget(self.btn_later)
|
||||
|
||||
self.btn_browser = QPushButton("Apri Pagina Release")
|
||||
self.btn_browser = QPushButton(tr("btn_open_release_page"))
|
||||
self.btn_browser.clicked.connect(self._open_release_page)
|
||||
btn_row.addWidget(self.btn_browser)
|
||||
|
||||
btn_row.addStretch(1)
|
||||
|
||||
self.btn_install = QPushButton("Aggiorna e Riavvia")
|
||||
self.btn_install = QPushButton(tr("btn_update_restart"))
|
||||
self.btn_install.setObjectName("PrimaryBtn")
|
||||
can_run_auto = self.can_auto and self.asset is not None
|
||||
self.btn_install.setVisible(can_run_auto)
|
||||
@@ -311,7 +318,7 @@ class UpdateDialog(QDialog):
|
||||
self.btn_browser.setEnabled(False)
|
||||
self.progress_bar.setVisible(True)
|
||||
self.progress_bar.setRange(0, 0)
|
||||
self.status_lbl.setText(f"Scaricamento di {self.asset.name}...")
|
||||
self.status_lbl.setText(tr("update_downloading", name=self.asset.name))
|
||||
|
||||
self._download_worker = _UpdateDownloadWorker(self.asset, self)
|
||||
self._download_worker.progress.connect(self._on_download_progress)
|
||||
@@ -325,18 +332,25 @@ class UpdateDialog(QDialog):
|
||||
self.progress_bar.setRange(0, 100)
|
||||
self.progress_bar.setValue(percent)
|
||||
self.status_lbl.setText(
|
||||
f"Scaricamento: {downloaded / (1024 * 1024):.1f} / {total / (1024 * 1024):.1f} MB ({percent}%)"
|
||||
tr(
|
||||
"update_downloading_pct",
|
||||
done=downloaded / (1024 * 1024),
|
||||
total=total / (1024 * 1024),
|
||||
percent=percent,
|
||||
)
|
||||
)
|
||||
else:
|
||||
self.status_lbl.setText(f"Scaricati {downloaded / (1024 * 1024):.1f} MB...")
|
||||
self.status_lbl.setText(
|
||||
tr("update_downloading_mb", done=downloaded / (1024 * 1024))
|
||||
)
|
||||
|
||||
def _on_download_completed(self, path_obj: object) -> None:
|
||||
downloaded_path = Path(path_obj)
|
||||
self.status_lbl.setText("Installazione aggiornamento e riavvio in corso...")
|
||||
self.status_lbl.setText(tr("update_installing"))
|
||||
try:
|
||||
apply_downloaded_update(downloaded_path)
|
||||
except Exception as exc:
|
||||
self._on_download_failed(f"Errore avvio aggiornamento: {exc}")
|
||||
self._on_download_failed(tr("update_apply_error", error=exc))
|
||||
return
|
||||
self.accept()
|
||||
self.on_ready_to_exit()
|
||||
@@ -346,8 +360,8 @@ class UpdateDialog(QDialog):
|
||||
self.btn_install.setEnabled(True)
|
||||
self.btn_later.setEnabled(True)
|
||||
self.btn_browser.setEnabled(True)
|
||||
self.status_lbl.setText(f"Errore: {error_msg}")
|
||||
QMessageBox.critical(self, "Errore Aggiornamento", error_msg)
|
||||
self.status_lbl.setText(tr("update_error_prefix", error=error_msg))
|
||||
QMessageBox.critical(self, tr("update_error_title"), error_msg)
|
||||
|
||||
|
||||
class ServerAppGUI(QMainWindow):
|
||||
@@ -357,6 +371,7 @@ class ServerAppGUI(QMainWindow):
|
||||
super().__init__()
|
||||
self.server = server
|
||||
self.config = load_config()
|
||||
set_language(self.config.get("language", "auto"))
|
||||
self._quitting = False
|
||||
self._update_worker: Optional[_UpdateCheckWorker] = None
|
||||
self._pending_update: Optional[UpdateCheckResult] = None
|
||||
@@ -410,16 +425,14 @@ class ServerAppGUI(QMainWindow):
|
||||
title_box.setSpacing(2)
|
||||
title_lbl = QLabel("Barcode Reader PC Server")
|
||||
title_lbl.setStyleSheet("font-size: 20px; font-weight: 700; color: #38BDF8;")
|
||||
subtitle_lbl = QLabel(
|
||||
f"Ricezione codici a barre da Smartphone • Catelli Srl • v{APP_VERSION}"
|
||||
)
|
||||
subtitle_lbl = QLabel(tr("app_subtitle", version=APP_VERSION))
|
||||
subtitle_lbl.setStyleSheet("color: #94A3B8; font-size: 12px;")
|
||||
title_box.addWidget(title_lbl)
|
||||
title_box.addWidget(subtitle_lbl)
|
||||
header_layout.addLayout(title_box)
|
||||
header_layout.addStretch(1)
|
||||
|
||||
self.btn_update_banner = QPushButton("Aggiornamento disponibile")
|
||||
self.btn_update_banner = QPushButton(tr("update_available_btn"))
|
||||
self.btn_update_banner.setObjectName("UpdateBannerBtn")
|
||||
self.btn_update_banner.setVisible(False)
|
||||
self.btn_update_banner.clicked.connect(self._open_pending_update_dialog)
|
||||
@@ -441,8 +454,8 @@ class ServerAppGUI(QMainWindow):
|
||||
self.tabs = QTabWidget()
|
||||
self.tab_dashboard = QWidget()
|
||||
self.tab_settings = QWidget()
|
||||
self.tabs.addTab(self.tab_dashboard, "Dashboard & Dispositivi")
|
||||
self.tabs.addTab(self.tab_settings, "Impostazioni")
|
||||
self.tabs.addTab(self.tab_dashboard, tr("tab_dashboard"))
|
||||
self.tabs.addTab(self.tab_settings, tr("tab_settings"))
|
||||
root_layout.addWidget(self.tabs, stretch=1)
|
||||
|
||||
self._build_dashboard_tab()
|
||||
@@ -467,7 +480,7 @@ class ServerAppGUI(QMainWindow):
|
||||
qr_layout = QVBoxLayout(qr_card)
|
||||
qr_layout.setContentsMargins(18, 16, 18, 16)
|
||||
qr_layout.setSpacing(10)
|
||||
qr_title = QLabel("CONNESSIONE RAPIDA (QR)")
|
||||
qr_title = QLabel(tr("card_qr_title"))
|
||||
qr_title.setStyleSheet("font-size: 11px; font-weight: 700; color: #94A3B8;")
|
||||
qr_layout.addWidget(qr_title)
|
||||
|
||||
@@ -481,7 +494,7 @@ class ServerAppGUI(QMainWindow):
|
||||
qr_wrapper_layout.addWidget(self.qr_label, alignment=Qt.AlignmentFlag.AlignCenter)
|
||||
qr_layout.addWidget(qr_wrapper, alignment=Qt.AlignmentFlag.AlignCenter)
|
||||
|
||||
qr_hint = QLabel("Inquadra con l'app Android/iOS")
|
||||
qr_hint = QLabel(tr("qr_hint"))
|
||||
qr_hint.setStyleSheet("color: #64748B; font-size: 12px;")
|
||||
qr_hint.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
||||
qr_layout.addWidget(qr_hint)
|
||||
@@ -492,7 +505,7 @@ class ServerAppGUI(QMainWindow):
|
||||
info_layout = QVBoxLayout(info_card)
|
||||
info_layout.setContentsMargins(20, 16, 20, 16)
|
||||
info_layout.setSpacing(12)
|
||||
info_title = QLabel("DETTAGLI SERVER")
|
||||
info_title = QLabel(tr("card_server_title"))
|
||||
info_title.setStyleSheet("font-size: 11px; font-weight: 700; color: #94A3B8;")
|
||||
info_layout.addWidget(info_title)
|
||||
|
||||
@@ -500,19 +513,19 @@ class ServerAppGUI(QMainWindow):
|
||||
grid.setHorizontalSpacing(18)
|
||||
grid.setVerticalSpacing(10)
|
||||
|
||||
self.lbl_ip = self._add_info_row(grid, 0, "Indirizzo IP Locale:", self.server.local_ip, "#38BDF8")
|
||||
self.lbl_port = self._add_info_row(grid, 1, "Porta:", str(self.server.port))
|
||||
self.lbl_name = self._add_info_row(grid, 2, "Nome PC:", self.server.server_name)
|
||||
pin_text = self.config.get("pin", "") or "Nessuno (Libero)"
|
||||
self.lbl_pin = self._add_info_row(grid, 3, "PIN di Accesso:", pin_text)
|
||||
self.lbl_ip = self._add_info_row(grid, 0, tr("lbl_local_ip"), self.server.local_ip, "#38BDF8")
|
||||
self.lbl_port = self._add_info_row(grid, 1, tr("lbl_port"), str(self.server.port))
|
||||
self.lbl_name = self._add_info_row(grid, 2, tr("lbl_pc_name"), self.server.server_name)
|
||||
pin_text = self.config.get("pin", "") or tr("pin_none")
|
||||
self.lbl_pin = self._add_info_row(grid, 3, tr("lbl_pin"), pin_text)
|
||||
info_layout.addLayout(grid)
|
||||
info_layout.addStretch(1)
|
||||
|
||||
btn_row = QHBoxLayout()
|
||||
btn_copy = QPushButton("Copia IP")
|
||||
btn_copy = QPushButton(tr("btn_copy_ip"))
|
||||
btn_copy.setCursor(Qt.CursorShape.PointingHandCursor)
|
||||
btn_copy.clicked.connect(self._copy_ip_to_clipboard)
|
||||
btn_web = QPushButton("Apri Dashboard Web")
|
||||
btn_web = QPushButton(tr("btn_open_web"))
|
||||
btn_web.setObjectName("PrimaryBtn")
|
||||
btn_web.setCursor(Qt.CursorShape.PointingHandCursor)
|
||||
btn_web.clicked.connect(self.open_web_dashboard)
|
||||
@@ -529,9 +542,9 @@ class ServerAppGUI(QMainWindow):
|
||||
dev_layout = QVBoxLayout(dev_card)
|
||||
dev_layout.setContentsMargins(18, 12, 18, 12)
|
||||
dev_layout.setSpacing(4)
|
||||
dev_title = QLabel("DISPOSITIVI CONNESSI")
|
||||
dev_title = QLabel(tr("card_devices_title"))
|
||||
dev_title.setStyleSheet("font-size: 11px; font-weight: 700; color: #94A3B8;")
|
||||
self.lbl_devices = QLabel("Nessun dispositivo mobile collegato.")
|
||||
self.lbl_devices = QLabel(tr("no_devices_connected"))
|
||||
self.lbl_devices.setStyleSheet("color: #64748B;")
|
||||
self.lbl_devices.setWordWrap(True)
|
||||
dev_layout.addWidget(dev_title)
|
||||
@@ -545,9 +558,9 @@ class ServerAppGUI(QMainWindow):
|
||||
hist_layout.setSpacing(10)
|
||||
|
||||
hist_header = QHBoxLayout()
|
||||
hist_title = QLabel("CRONOLOGIA SCANSIONI LIVE")
|
||||
hist_title = QLabel(tr("card_history_title"))
|
||||
hist_title.setStyleSheet("font-size: 11px; font-weight: 700; color: #94A3B8;")
|
||||
btn_clear = QPushButton("Pulisci Log")
|
||||
btn_clear = QPushButton(tr("btn_clear_log"))
|
||||
btn_clear.setCursor(Qt.CursorShape.PointingHandCursor)
|
||||
btn_clear.clicked.connect(self._clear_scan_log)
|
||||
hist_header.addWidget(hist_title)
|
||||
@@ -556,7 +569,9 @@ class ServerAppGUI(QMainWindow):
|
||||
hist_layout.addLayout(hist_header)
|
||||
|
||||
self.table = QTableWidget(0, 4)
|
||||
self.table.setHorizontalHeaderLabels(["Ora", "Dispositivo", "Codice Letto", "Esito"])
|
||||
self.table.setHorizontalHeaderLabels(
|
||||
[tr("col_time"), tr("col_device"), tr("col_code"), tr("col_status")]
|
||||
)
|
||||
self.table.setEditTriggers(QTableWidget.EditTrigger.NoEditTriggers)
|
||||
self.table.setSelectionBehavior(QTableWidget.SelectionBehavior.SelectRows)
|
||||
self.table.setAlternatingRowColors(True)
|
||||
@@ -596,7 +611,7 @@ class ServerAppGUI(QMainWindow):
|
||||
container.setContentsMargins(24, 22, 24, 22)
|
||||
container.setSpacing(14)
|
||||
|
||||
sec1 = QLabel("RETE E IDENTIFICAZIONE")
|
||||
sec1 = QLabel(tr("sec_network"))
|
||||
sec1.setStyleSheet("font-size: 12px; font-weight: 700; color: #38BDF8;")
|
||||
container.addWidget(sec1)
|
||||
|
||||
@@ -606,32 +621,32 @@ class ServerAppGUI(QMainWindow):
|
||||
|
||||
self.inp_name = QLineEdit(self.config.get("server_name", socket.gethostname()))
|
||||
self.inp_pin = QLineEdit(self.config.get("pin", ""))
|
||||
self.inp_pin.setPlaceholderText("Lascia vuoto per accesso libero")
|
||||
self.inp_pin.setPlaceholderText(tr("placeholder_pin"))
|
||||
self.inp_port = QLineEdit(str(self.config.get("port", 8765)))
|
||||
self.inp_port.setMaximumWidth(120)
|
||||
|
||||
port_row = QHBoxLayout()
|
||||
port_row.addWidget(self.inp_port)
|
||||
port_hint = QLabel("(Il cambio porta richiede riavvio)")
|
||||
port_hint = QLabel(tr("port_restart_hint"))
|
||||
port_hint.setStyleSheet("color: #64748B; font-size: 12px;")
|
||||
port_row.addWidget(port_hint)
|
||||
port_row.addStretch(1)
|
||||
|
||||
form.addRow("Nome visualizzato nell'app mobile:", self.inp_name)
|
||||
form.addRow("PIN di accesso (es. 4 cifre):", self.inp_pin)
|
||||
form.addRow("Porta Server WebSocket:", port_row)
|
||||
form.addRow(tr("lbl_mobile_name"), self.inp_name)
|
||||
form.addRow(tr("lbl_pin_input"), self.inp_pin)
|
||||
form.addRow(tr("lbl_ws_port"), port_row)
|
||||
container.addLayout(form)
|
||||
|
||||
sec2 = QLabel("COMPORTAMENTO TASTIERA")
|
||||
sec2 = QLabel(tr("sec_keyboard"))
|
||||
sec2.setStyleSheet("font-size: 12px; font-weight: 700; color: #38BDF8; margin-top: 8px;")
|
||||
container.addWidget(sec2)
|
||||
|
||||
self.grp_suffix = QButtonGroup(self)
|
||||
suffix_row = QHBoxLayout()
|
||||
suffix_row.addWidget(QLabel("Tasto finale dopo ogni scansione:"))
|
||||
self.rb_suffix_enter = QRadioButton("Invio (Enter)")
|
||||
self.rb_suffix_tab = QRadioButton("Tabulatore (Tab)")
|
||||
self.rb_suffix_none = QRadioButton("Nessun tasto")
|
||||
suffix_row.addWidget(QLabel(tr("lbl_suffix")))
|
||||
self.rb_suffix_enter = QRadioButton(tr("rb_suffix_enter"))
|
||||
self.rb_suffix_tab = QRadioButton(tr("rb_suffix_tab"))
|
||||
self.rb_suffix_none = QRadioButton(tr("rb_suffix_none"))
|
||||
self._suffix_map = {
|
||||
"enter": self.rb_suffix_enter,
|
||||
"tab": self.rb_suffix_tab,
|
||||
@@ -646,9 +661,9 @@ class ServerAppGUI(QMainWindow):
|
||||
|
||||
self.grp_mode = QButtonGroup(self)
|
||||
mode_row = QHBoxLayout()
|
||||
mode_row.addWidget(QLabel("Modalità di scrittura:"))
|
||||
self.rb_mode_type = QRadioButton("Digitazione tastiera reale (Consigliato)")
|
||||
self.rb_mode_paste = QRadioButton("Incolla da appunti (Ctrl+V / Cmd+V)")
|
||||
mode_row.addWidget(QLabel(tr("lbl_typing_mode")))
|
||||
self.rb_mode_type = QRadioButton(tr("rb_mode_type"))
|
||||
self.rb_mode_paste = QRadioButton(tr("rb_mode_paste"))
|
||||
self._mode_map = {"type": self.rb_mode_type, "paste": self.rb_mode_paste}
|
||||
for rb in self._mode_map.values():
|
||||
self.grp_mode.addButton(rb)
|
||||
@@ -657,46 +672,50 @@ class ServerAppGUI(QMainWindow):
|
||||
self._mode_map.get(self.config.get("mode", "type"), self.rb_mode_type).setChecked(True)
|
||||
container.addLayout(mode_row)
|
||||
|
||||
sec3 = QLabel("AVVIO AUTOMATICO, TRAY E AGGIORNAMENTI")
|
||||
sec3 = QLabel(tr("sec_system"))
|
||||
sec3.setStyleSheet("font-size: 12px; font-weight: 700; color: #38BDF8; margin-top: 8px;")
|
||||
container.addWidget(sec3)
|
||||
|
||||
self.chk_autostart = QCheckBox(
|
||||
"Avvia automaticamente all'avvio del sistema operativo (Login / Boot)"
|
||||
)
|
||||
self.chk_autostart = QCheckBox(tr("chk_autostart"))
|
||||
self.chk_autostart.setChecked(is_autostart_enabled())
|
||||
container.addWidget(self.chk_autostart)
|
||||
|
||||
self.chk_tray = QCheckBox(
|
||||
"Alla chiusura (X) riduci nella System Tray invece di terminare"
|
||||
)
|
||||
self.chk_tray = QCheckBox(tr("chk_tray"))
|
||||
self.chk_tray.setChecked(bool(self.config.get("minimize_to_tray", True)))
|
||||
container.addWidget(self.chk_tray)
|
||||
|
||||
self.chk_updates = QCheckBox(
|
||||
"Controlla automaticamente nuovi aggiornamenti all'avvio"
|
||||
)
|
||||
self.chk_updates = QCheckBox(tr("chk_updates"))
|
||||
self.chk_updates.setChecked(bool(self.config.get("check_updates", True)))
|
||||
container.addWidget(self.chk_updates)
|
||||
|
||||
adv_form = QFormLayout()
|
||||
adv_form.setHorizontalSpacing(18)
|
||||
self.cmb_language = QComboBox()
|
||||
self.cmb_language.addItem(tr("lang_auto"), "auto")
|
||||
self.cmb_language.addItem(tr("lang_it"), "it")
|
||||
self.cmb_language.addItem(tr("lang_en"), "en")
|
||||
current_lang_pref = self.config.get("language", "auto")
|
||||
lang_idx = self.cmb_language.findData(current_lang_pref)
|
||||
if lang_idx >= 0:
|
||||
self.cmb_language.setCurrentIndex(lang_idx)
|
||||
adv_form.addRow(tr("lbl_language"), self.cmb_language)
|
||||
|
||||
self.inp_update_url = QLineEdit(self.config.get("update_url", ""))
|
||||
self.inp_update_url.setPlaceholderText("Vuoto = Gitea Releases (gitea.catelli.it)")
|
||||
adv_form.addRow("URL aggiornamento custom (opzionale):", self.inp_update_url)
|
||||
self.inp_update_url.setPlaceholderText(tr("placeholder_update_url"))
|
||||
adv_form.addRow(tr("lbl_update_url"), self.inp_update_url)
|
||||
container.addLayout(adv_form)
|
||||
|
||||
update_row = QHBoxLayout()
|
||||
self.btn_check_updates = QPushButton("Controlla Aggiornamenti Ora")
|
||||
self.btn_check_updates = QPushButton(tr("btn_check_updates"))
|
||||
self.btn_check_updates.setCursor(Qt.CursorShape.PointingHandCursor)
|
||||
self.btn_check_updates.clicked.connect(lambda: self.check_updates_async(manual=True))
|
||||
self.lbl_update_status = QLabel(f"Versione installata: v{APP_VERSION}")
|
||||
self.lbl_update_status = QLabel(tr("installed_version", version=APP_VERSION))
|
||||
self.lbl_update_status.setStyleSheet("color: #94A3B8; font-size: 12px;")
|
||||
update_row.addWidget(self.btn_check_updates)
|
||||
update_row.addWidget(self.lbl_update_status, stretch=1)
|
||||
container.addLayout(update_row)
|
||||
|
||||
btn_save = QPushButton("Salva ed Applica Impostazioni")
|
||||
btn_save = QPushButton(tr("btn_save_settings"))
|
||||
btn_save.setObjectName("PrimaryBtn")
|
||||
btn_save.setCursor(Qt.CursorShape.PointingHandCursor)
|
||||
btn_save.clicked.connect(self._save_settings_action)
|
||||
@@ -723,7 +742,7 @@ class ServerAppGUI(QMainWindow):
|
||||
if clipboard is not None:
|
||||
clipboard.setText(self.server.local_ip)
|
||||
QMessageBox.information(
|
||||
self, "Copia", f"Indirizzo IP ({self.server.local_ip}) copiato negli appunti!"
|
||||
self, tr("msg_copy_title"), tr("msg_copy_body", ip=self.server.local_ip)
|
||||
)
|
||||
|
||||
def _clear_scan_log(self) -> None:
|
||||
@@ -733,10 +752,10 @@ class ServerAppGUI(QMainWindow):
|
||||
try:
|
||||
port = int(self.inp_port.text().strip())
|
||||
if not (1 <= port <= 65535):
|
||||
raise ValueError("Porta fuori intervallo")
|
||||
raise ValueError("Port out of range")
|
||||
except ValueError:
|
||||
QMessageBox.critical(
|
||||
self, "Errore", "La porta deve essere un numero valido (es. 8765)."
|
||||
self, tr("msg_error_title"), tr("msg_port_invalid")
|
||||
)
|
||||
return
|
||||
|
||||
@@ -746,6 +765,8 @@ class ServerAppGUI(QMainWindow):
|
||||
selected_mode = next(
|
||||
(key for key, btn in self._mode_map.items() if btn.isChecked()), "type"
|
||||
)
|
||||
selected_lang = self.cmb_language.currentData() or "auto"
|
||||
prev_resolved_lang = get_language()
|
||||
|
||||
new_config = {
|
||||
"server_name": self.inp_name.text().strip() or socket.gethostname(),
|
||||
@@ -756,6 +777,7 @@ class ServerAppGUI(QMainWindow):
|
||||
"minimize_to_tray": self.chk_tray.isChecked(),
|
||||
"check_updates": self.chk_updates.isChecked(),
|
||||
"update_url": self.inp_update_url.text().strip(),
|
||||
"language": selected_lang,
|
||||
}
|
||||
|
||||
autostart_desired = self.chk_autostart.isChecked()
|
||||
@@ -764,16 +786,21 @@ class ServerAppGUI(QMainWindow):
|
||||
|
||||
self.server.update_settings(new_config)
|
||||
self.config = load_config()
|
||||
new_resolved_lang = set_language(selected_lang)
|
||||
self.tray.retranslate()
|
||||
|
||||
self.lbl_name.setText(self.server.server_name)
|
||||
pin_text = new_config["pin"] if new_config["pin"] else "Nessuno (Libero)"
|
||||
pin_text = new_config["pin"] if new_config["pin"] else tr("pin_none")
|
||||
self.lbl_pin.setText(pin_text)
|
||||
self.lbl_port.setText(str(port))
|
||||
self._refresh_qr_display()
|
||||
|
||||
QMessageBox.information(
|
||||
self, "Impostazioni", "Impostazioni salvate ed applicate con successo!"
|
||||
msg_key = (
|
||||
"msg_settings_saved_restart_lang"
|
||||
if new_resolved_lang != prev_resolved_lang
|
||||
else "msg_settings_saved"
|
||||
)
|
||||
QMessageBox.information(self, tr("msg_settings_title"), tr(msg_key))
|
||||
|
||||
def toggle_listening(self) -> None:
|
||||
new_state = not self.server.is_listening
|
||||
@@ -781,19 +808,19 @@ class ServerAppGUI(QMainWindow):
|
||||
|
||||
def _update_status_badge(self, is_listening: bool) -> None:
|
||||
if is_listening:
|
||||
self.status_badge.setText("● IN ASCOLTO")
|
||||
self.status_badge.setText(tr("status_listening_badge"))
|
||||
self.status_badge.setStyleSheet(
|
||||
"background-color: #064E3B; color: #10B981; border-radius: 6px;"
|
||||
"padding: 6px 12px; font-weight: 700;"
|
||||
)
|
||||
self.btn_toggle.setText("Metti in Pausa")
|
||||
self.btn_toggle.setText(tr("btn_pause"))
|
||||
else:
|
||||
self.status_badge.setText("○ IN PAUSA")
|
||||
self.status_badge.setText(tr("status_paused_badge"))
|
||||
self.status_badge.setStyleSheet(
|
||||
"background-color: #451A03; color: #F59E0B; border-radius: 6px;"
|
||||
"padding: 6px 12px; font-weight: 700;"
|
||||
)
|
||||
self.btn_toggle.setText("Riprendi Ricezione")
|
||||
self.btn_toggle.setText(tr("btn_resume"))
|
||||
|
||||
def _on_status_changed(self, is_listening: bool) -> None:
|
||||
self._update_status_badge(is_listening)
|
||||
@@ -801,7 +828,7 @@ class ServerAppGUI(QMainWindow):
|
||||
|
||||
def _on_scan_received(self, code: str, source: str, success: bool) -> None:
|
||||
timestamp = datetime.now().strftime("%H:%M:%S")
|
||||
status_str = "Digitato ✓" if success else "Fallito ✗"
|
||||
status_str = tr("scan_typed") if success else tr("scan_failed")
|
||||
status_color = QColor("#10B981") if success else QColor("#EF4444")
|
||||
|
||||
self.table.insertRow(0)
|
||||
@@ -817,10 +844,12 @@ class ServerAppGUI(QMainWindow):
|
||||
|
||||
def _on_devices_changed(self, devices: list[str]) -> None:
|
||||
if not devices:
|
||||
self.lbl_devices.setText("Nessun dispositivo mobile collegato.")
|
||||
self.lbl_devices.setText(tr("no_devices_connected"))
|
||||
self.lbl_devices.setStyleSheet("color: #64748B;")
|
||||
else:
|
||||
self.lbl_devices.setText(f"{len(devices)} collegati: " + ", ".join(devices))
|
||||
self.lbl_devices.setText(
|
||||
tr("devices_connected_fmt", count=len(devices), devices=", ".join(devices))
|
||||
)
|
||||
self.lbl_devices.setStyleSheet("color: #10B981; font-weight: 600;")
|
||||
|
||||
def check_updates_async(self, manual: bool = False) -> None:
|
||||
@@ -830,7 +859,7 @@ class ServerAppGUI(QMainWindow):
|
||||
|
||||
if manual:
|
||||
self.btn_check_updates.setEnabled(False)
|
||||
self.lbl_update_status.setText("Ricerca aggiornamenti in corso...")
|
||||
self.lbl_update_status.setText(tr("checking_updates"))
|
||||
|
||||
update_url = self.inp_update_url.text().strip() if manual else self.config.get("update_url", "")
|
||||
self._update_worker = _UpdateCheckWorker(APP_VERSION, update_url, manual, self)
|
||||
@@ -839,27 +868,31 @@ class ServerAppGUI(QMainWindow):
|
||||
|
||||
def _on_update_check_finished(self, result: UpdateCheckResult, manual: bool) -> None:
|
||||
self.btn_check_updates.setEnabled(True)
|
||||
self.lbl_update_status.setText(result.message or f"Versione installata: v{APP_VERSION}")
|
||||
self.lbl_update_status.setText(
|
||||
result.message or tr("installed_version", version=APP_VERSION)
|
||||
)
|
||||
|
||||
if result.status == "update_available" and result.release is not None:
|
||||
self._pending_update = result
|
||||
self.btn_update_banner.setText(f"Aggiorna a v{result.release.version}")
|
||||
self.btn_update_banner.setText(
|
||||
tr("update_to_version_btn", version=result.release.version)
|
||||
)
|
||||
self.btn_update_banner.setVisible(True)
|
||||
|
||||
if manual or self.isVisible():
|
||||
self._show_update_dialog(result)
|
||||
elif self._tray_available:
|
||||
self.tray.show_message(
|
||||
f"Aggiornamento disponibile (v{result.release.version})",
|
||||
"Apri la finestra di Barcode Reader Server per installarlo automaticamente.",
|
||||
tr("tray_update_title", version=result.release.version),
|
||||
tr("tray_update_body"),
|
||||
)
|
||||
return
|
||||
|
||||
if manual:
|
||||
if result.status == "up_to_date":
|
||||
QMessageBox.information(self, "Aggiornamenti", result.message)
|
||||
QMessageBox.information(self, tr("updates_dialog_title"), result.message)
|
||||
else:
|
||||
QMessageBox.warning(self, "Controllo Aggiornamenti", result.message)
|
||||
QMessageBox.warning(self, tr("updates_check_title"), result.message)
|
||||
|
||||
def _open_pending_update_dialog(self) -> None:
|
||||
if self._pending_update and self._pending_update.release:
|
||||
|
||||
+253
@@ -0,0 +1,253 @@
|
||||
"""Internationalization (i18n) helper for Barcode Reader PC Server (IT / EN)."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import locale
|
||||
import os
|
||||
|
||||
_CURRENT_LANG = "en"
|
||||
|
||||
TRANSLATIONS: dict[str, dict[str, str]] = {
|
||||
"en": {
|
||||
"app_subtitle": "Receive barcodes from Smartphone • Catelli Srl • v{version}",
|
||||
"update_available_btn": "Update available",
|
||||
"update_to_version_btn": "Update to v{version}",
|
||||
"tab_dashboard": "Dashboard & Devices",
|
||||
"tab_settings": "Settings",
|
||||
"card_qr_title": "QUICK CONNECT (QR)",
|
||||
"qr_hint": "Scan with the Android/iOS app",
|
||||
"card_server_title": "SERVER DETAILS",
|
||||
"lbl_local_ip": "Local IP Address:",
|
||||
"lbl_port": "Port:",
|
||||
"lbl_pc_name": "PC Name:",
|
||||
"lbl_pin": "Access PIN:",
|
||||
"pin_none": "None (Open)",
|
||||
"btn_copy_ip": "Copy IP",
|
||||
"btn_open_web": "Open Web Dashboard",
|
||||
"card_devices_title": "CONNECTED DEVICES",
|
||||
"no_devices_connected": "No mobile device connected.",
|
||||
"devices_connected_fmt": "{count} connected: {devices}",
|
||||
"card_history_title": "LIVE SCAN HISTORY",
|
||||
"btn_clear_log": "Clear Log",
|
||||
"col_time": "Time",
|
||||
"col_device": "Device",
|
||||
"col_code": "Scanned Code",
|
||||
"col_status": "Status",
|
||||
"scan_typed": "Typed ✓",
|
||||
"scan_failed": "Failed ✗",
|
||||
"status_listening_badge": "● LISTENING",
|
||||
"status_paused_badge": "○ PAUSED",
|
||||
"status_listening_short": "LISTENING",
|
||||
"status_paused_short": "PAUSED",
|
||||
"btn_pause": "Pause",
|
||||
"btn_resume": "Resume Listening",
|
||||
"sec_network": "NETWORK & IDENTIFICATION",
|
||||
"lbl_mobile_name": "Name shown in mobile app:",
|
||||
"lbl_pin_input": "Access PIN (e.g. 4 digits):",
|
||||
"placeholder_pin": "Leave empty for open access",
|
||||
"lbl_ws_port": "WebSocket Server Port:",
|
||||
"port_restart_hint": "(Changing port requires restart)",
|
||||
"sec_keyboard": "KEYBOARD BEHAVIOR",
|
||||
"lbl_suffix": "Trailing key after each scan:",
|
||||
"rb_suffix_enter": "Enter",
|
||||
"rb_suffix_tab": "Tab",
|
||||
"rb_suffix_none": "No key",
|
||||
"lbl_typing_mode": "Input mode:",
|
||||
"rb_mode_type": "Real keyboard typing (Recommended)",
|
||||
"rb_mode_paste": "Paste from clipboard (Ctrl+V / Cmd+V)",
|
||||
"sec_system": "AUTOSTART, TRAY, LANGUAGE & UPDATES",
|
||||
"chk_autostart": "Start automatically at OS login (Autostart)",
|
||||
"chk_tray": "Minimize to System Tray on close (X) instead of quitting",
|
||||
"chk_updates": "Check for updates automatically on startup",
|
||||
"lbl_language": "Interface language:",
|
||||
"lang_auto": "System default (Auto)",
|
||||
"lang_it": "Italiano",
|
||||
"lang_en": "English",
|
||||
"lbl_update_url": "Custom update URL (optional):",
|
||||
"placeholder_update_url": "Empty = Gitea Releases (gitea.catelli.it)",
|
||||
"btn_check_updates": "Check for Updates Now",
|
||||
"installed_version": "Installed version: v{version}",
|
||||
"btn_save_settings": "Save & Apply Settings",
|
||||
"msg_copy_title": "Copied",
|
||||
"msg_copy_body": "IP address ({ip}) copied to clipboard!",
|
||||
"msg_error_title": "Error",
|
||||
"msg_port_invalid": "Port must be a valid number (e.g. 8765).",
|
||||
"msg_settings_title": "Settings",
|
||||
"msg_settings_saved": "Settings saved and applied successfully!",
|
||||
"msg_settings_saved_restart_lang": "Settings saved! Restart the app to apply the new language everywhere.",
|
||||
"checking_updates": "Checking for updates...",
|
||||
"tray_show_window": "Show Window",
|
||||
"tray_pause": "Pause",
|
||||
"tray_resume": "Resume Listening",
|
||||
"tray_open_web": "Open Web Dashboard",
|
||||
"tray_check_updates": "Check for Updates...",
|
||||
"tray_quit": "Quit",
|
||||
"tray_update_title": "Update available (v{version})",
|
||||
"tray_update_body": "Open Barcode Reader Server to install it automatically.",
|
||||
"updates_dialog_title": "Updates",
|
||||
"updates_check_title": "Update Check",
|
||||
"update_win_title": "Update Available — v{version}",
|
||||
"update_new_version": "New version available: v{version}",
|
||||
"update_installed_sub": "Installed version: v{version} • {title}",
|
||||
"update_no_notes": "No release notes provided.",
|
||||
"update_no_asset": "No platform-specific package found in this release.",
|
||||
"update_ready_pkg": "Package ready to install: {name}{size}",
|
||||
"btn_later": "Later",
|
||||
"btn_open_release_page": "Open Release Page",
|
||||
"btn_update_restart": "Update & Restart",
|
||||
"update_downloading": "Downloading {name}...",
|
||||
"update_downloading_pct": "Downloading: {done:.1f} / {total:.1f} MB ({percent}%)",
|
||||
"update_downloading_mb": "Downloaded {done:.1f} MB...",
|
||||
"update_installing": "Installing update and restarting...",
|
||||
"update_apply_error": "Failed to launch update: {error}",
|
||||
"update_error_prefix": "Error: {error}",
|
||||
"update_error_title": "Update Error",
|
||||
},
|
||||
"it": {
|
||||
"app_subtitle": "Ricezione codici a barre da Smartphone • Catelli Srl • v{version}",
|
||||
"update_available_btn": "Aggiornamento disponibile",
|
||||
"update_to_version_btn": "Aggiorna a v{version}",
|
||||
"tab_dashboard": "Dashboard & Dispositivi",
|
||||
"tab_settings": "Impostazioni",
|
||||
"card_qr_title": "CONNESSIONE RAPIDA (QR)",
|
||||
"qr_hint": "Inquadra con l'app Android/iOS",
|
||||
"card_server_title": "DETTAGLI SERVER",
|
||||
"lbl_local_ip": "Indirizzo IP Locale:",
|
||||
"lbl_port": "Porta:",
|
||||
"lbl_pc_name": "Nome PC:",
|
||||
"lbl_pin": "PIN di Accesso:",
|
||||
"pin_none": "Nessuno (Libero)",
|
||||
"btn_copy_ip": "Copia IP",
|
||||
"btn_open_web": "Apri Dashboard Web",
|
||||
"card_devices_title": "DISPOSITIVI CONNESSI",
|
||||
"no_devices_connected": "Nessun dispositivo mobile collegato.",
|
||||
"devices_connected_fmt": "{count} collegati: {devices}",
|
||||
"card_history_title": "CRONOLOGIA SCANSIONI LIVE",
|
||||
"btn_clear_log": "Pulisci Log",
|
||||
"col_time": "Ora",
|
||||
"col_device": "Dispositivo",
|
||||
"col_code": "Codice Letto",
|
||||
"col_status": "Esito",
|
||||
"scan_typed": "Digitato ✓",
|
||||
"scan_failed": "Fallito ✗",
|
||||
"status_listening_badge": "● IN ASCOLTO",
|
||||
"status_paused_badge": "○ IN PAUSA",
|
||||
"status_listening_short": "IN ASCOLTO",
|
||||
"status_paused_short": "IN PAUSA",
|
||||
"btn_pause": "Metti in Pausa",
|
||||
"btn_resume": "Riprendi Ricezione",
|
||||
"sec_network": "RETE E IDENTIFICAZIONE",
|
||||
"lbl_mobile_name": "Nome visualizzato nell'app mobile:",
|
||||
"lbl_pin_input": "PIN di accesso (es. 4 cifre):",
|
||||
"placeholder_pin": "Lascia vuoto per accesso libero",
|
||||
"lbl_ws_port": "Porta Server WebSocket:",
|
||||
"port_restart_hint": "(Il cambio porta richiede riavvio)",
|
||||
"sec_keyboard": "COMPORTAMENTO TASTIERA",
|
||||
"lbl_suffix": "Tasto finale dopo ogni scansione:",
|
||||
"rb_suffix_enter": "Invio (Enter)",
|
||||
"rb_suffix_tab": "Tabulatore (Tab)",
|
||||
"rb_suffix_none": "Nessun tasto",
|
||||
"lbl_typing_mode": "Modalità di scrittura:",
|
||||
"rb_mode_type": "Digitazione tastiera reale (Consigliato)",
|
||||
"rb_mode_paste": "Incolla da appunti (Ctrl+V / Cmd+V)",
|
||||
"sec_system": "AVVIO AUTOMATICO, TRAY, LINGUA E AGGIORNAMENTI",
|
||||
"chk_autostart": "Avvia automaticamente all'avvio del sistema operativo (Login / Boot)",
|
||||
"chk_tray": "Alla chiusura (X) riduci nella System Tray invece di terminare",
|
||||
"chk_updates": "Controlla automaticamente nuovi aggiornamenti all'avvio",
|
||||
"lbl_language": "Lingua interfaccia:",
|
||||
"lang_auto": "Predefinita di sistema (Auto)",
|
||||
"lang_it": "Italiano",
|
||||
"lang_en": "English",
|
||||
"lbl_update_url": "URL aggiornamento custom (opzionale):",
|
||||
"placeholder_update_url": "Vuoto = Gitea Releases (gitea.catelli.it)",
|
||||
"btn_check_updates": "Controlla Aggiornamenti Ora",
|
||||
"installed_version": "Versione installata: v{version}",
|
||||
"btn_save_settings": "Salva ed Applica Impostazioni",
|
||||
"msg_copy_title": "Copia",
|
||||
"msg_copy_body": "Indirizzo IP ({ip}) copiato negli appunti!",
|
||||
"msg_error_title": "Errore",
|
||||
"msg_port_invalid": "La porta deve essere un numero valido (es. 8765).",
|
||||
"msg_settings_title": "Impostazioni",
|
||||
"msg_settings_saved": "Impostazioni salvate ed applicate con successo!",
|
||||
"msg_settings_saved_restart_lang": "Impostazioni salvate! Riavvia l'app per applicare completamente la nuova lingua.",
|
||||
"checking_updates": "Ricerca aggiornamenti in corso...",
|
||||
"tray_show_window": "Mostra Finestra",
|
||||
"tray_pause": "Metti in Pausa",
|
||||
"tray_resume": "Riprendi Ascolto",
|
||||
"tray_open_web": "Apri Dashboard Web",
|
||||
"tray_check_updates": "Controlla Aggiornamenti...",
|
||||
"tray_quit": "Esci",
|
||||
"tray_update_title": "Aggiornamento disponibile (v{version})",
|
||||
"tray_update_body": "Apri la finestra di Barcode Reader Server per installarlo automaticamente.",
|
||||
"updates_dialog_title": "Aggiornamenti",
|
||||
"updates_check_title": "Controllo Aggiornamenti",
|
||||
"update_win_title": "Aggiornamento Disponibile — v{version}",
|
||||
"update_new_version": "Nuova versione disponibile: v{version}",
|
||||
"update_installed_sub": "Versione installata: v{version} • {title}",
|
||||
"update_no_notes": "Nessuna nota di rilascio specificata.",
|
||||
"update_no_asset": "Nessun pacchetto specifico trovato per questa piattaforma negli asset della release.",
|
||||
"update_ready_pkg": "Pacchetto pronto per l'installazione: {name}{size}",
|
||||
"btn_later": "Più Tardi",
|
||||
"btn_open_release_page": "Apri Pagina Release",
|
||||
"btn_update_restart": "Aggiorna e Riavvia",
|
||||
"update_downloading": "Scaricamento di {name}...",
|
||||
"update_downloading_pct": "Scaricamento: {done:.1f} / {total:.1f} MB ({percent}%)",
|
||||
"update_downloading_mb": "Scaricati {done:.1f} MB...",
|
||||
"update_installing": "Installazione aggiornamento e riavvio in corso...",
|
||||
"update_apply_error": "Errore avvio aggiornamento: {error}",
|
||||
"update_error_prefix": "Errore: {error}",
|
||||
"update_error_title": "Errore Aggiornamento",
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
def detect_system_language() -> str:
|
||||
"""Detect OS locale and return 'it' for Italian, 'en' otherwise."""
|
||||
try:
|
||||
from PySide6.QtCore import QLocale
|
||||
|
||||
qt_lang = QLocale.system().name().lower()
|
||||
if qt_lang.startswith("it"):
|
||||
return "it"
|
||||
if qt_lang:
|
||||
return "en"
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
for candidate in (
|
||||
os.environ.get("LC_ALL"),
|
||||
os.environ.get("LC_MESSAGES"),
|
||||
os.environ.get("LANG"),
|
||||
):
|
||||
if candidate:
|
||||
return "it" if candidate.lower().startswith("it") else "en"
|
||||
|
||||
try:
|
||||
loc, _ = locale.getlocale()
|
||||
if loc and loc.lower().startswith("it"):
|
||||
return "it"
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
return "en"
|
||||
|
||||
|
||||
def set_language(lang_code: str | None) -> str:
|
||||
"""Set active language ('auto', 'it', 'en') and return the resolved language code."""
|
||||
global _CURRENT_LANG
|
||||
normalized = (lang_code or "auto").strip().lower()
|
||||
if normalized in ("it", "en"):
|
||||
_CURRENT_LANG = normalized
|
||||
else:
|
||||
_CURRENT_LANG = detect_system_language()
|
||||
return _CURRENT_LANG
|
||||
|
||||
|
||||
def get_language() -> str:
|
||||
return _CURRENT_LANG
|
||||
|
||||
|
||||
def tr(key: str, **kwargs) -> str:
|
||||
table = TRANSLATIONS.get(_CURRENT_LANG, TRANSLATIONS["en"])
|
||||
template = table.get(key, TRANSLATIONS["en"].get(key, key))
|
||||
return template.format(**kwargs) if kwargs else template
|
||||
@@ -203,7 +203,14 @@ class QtGuiAndTrayTests(unittest.TestCase):
|
||||
self.assertEqual(gui.table.rowCount(), 1)
|
||||
self.assertIn("Pixel 8", gui.lbl_devices.text())
|
||||
self.assertFalse(dummy.is_listening)
|
||||
self.assertIn("IN PAUSA", gui.status_badge.text())
|
||||
import i18n
|
||||
self.assertIn(i18n.tr("status_paused_short"), gui.status_badge.text())
|
||||
|
||||
# Verifica traduzioni IT/EN
|
||||
i18n.set_language("it")
|
||||
self.assertEqual(i18n.tr("tab_settings"), "Impostazioni")
|
||||
i18n.set_language("en")
|
||||
self.assertEqual(i18n.tr("tab_settings"), "Settings")
|
||||
|
||||
# Smoke test UpdateDialog
|
||||
rel = updater.ReleaseInfo(
|
||||
|
||||
+19
-6
@@ -8,6 +8,7 @@ from PySide6.QtCore import QObject, Qt
|
||||
from PySide6.QtGui import QAction, QColor, QFont, QIcon, QPainter, QPainterPath, QPen, QPixmap
|
||||
from PySide6.QtWidgets import QMenu, QSystemTrayIcon
|
||||
|
||||
from i18n import tr
|
||||
from version import APP_NAME, APP_VERSION, get_resource_path
|
||||
|
||||
|
||||
@@ -124,7 +125,7 @@ class ServerTrayIcon(QObject):
|
||||
self._action_status.setEnabled(False)
|
||||
self._menu.addAction(self._action_status)
|
||||
|
||||
self._action_show = QAction("Mostra Finestra", self._menu)
|
||||
self._action_show = QAction(tr("tray_show_window"), self._menu)
|
||||
show_font = QFont(self._action_show.font())
|
||||
show_font.setBold(True)
|
||||
self._action_show.setFont(show_font)
|
||||
@@ -137,17 +138,17 @@ class ServerTrayIcon(QObject):
|
||||
self._action_toggle.triggered.connect(self.on_toggle_listening)
|
||||
self._menu.addAction(self._action_toggle)
|
||||
|
||||
self._action_web = QAction("Apri Dashboard Web", self._menu)
|
||||
self._action_web = QAction(tr("tray_open_web"), self._menu)
|
||||
self._action_web.triggered.connect(self.on_open_web)
|
||||
self._menu.addAction(self._action_web)
|
||||
|
||||
self._action_updates = QAction("Controlla Aggiornamenti...", self._menu)
|
||||
self._action_updates = QAction(tr("tray_check_updates"), self._menu)
|
||||
self._action_updates.triggered.connect(self.on_check_updates)
|
||||
self._menu.addAction(self._action_updates)
|
||||
|
||||
self._menu.addSeparator()
|
||||
|
||||
self._action_quit = QAction("Esci", self._menu)
|
||||
self._action_quit = QAction(tr("tray_quit"), self._menu)
|
||||
self._action_quit.triggered.connect(self.on_quit)
|
||||
self._menu.addAction(self._action_quit)
|
||||
|
||||
@@ -169,14 +170,26 @@ class ServerTrayIcon(QObject):
|
||||
icon.addPixmap(create_status_pixmap(is_listening, 64))
|
||||
self._tray.setIcon(icon)
|
||||
|
||||
status_text = "IN ASCOLTO" if is_listening else "IN PAUSA"
|
||||
status_text = tr("status_listening_short") if is_listening else tr("status_paused_short")
|
||||
self._tray.setToolTip(f"{APP_NAME} v{APP_VERSION} — {status_text}")
|
||||
|
||||
if self._action_status is not None:
|
||||
marker = "●" if is_listening else "○"
|
||||
self._action_status.setText(f"{marker} {status_text} (v{APP_VERSION})")
|
||||
if self._action_toggle is not None:
|
||||
self._action_toggle.setText("Metti in Pausa" if is_listening else "Riprendi Ascolto")
|
||||
self._action_toggle.setText(tr("tray_pause") if is_listening else tr("tray_resume"))
|
||||
|
||||
def retranslate(self) -> None:
|
||||
"""Aggiorna le etichette del menu tray dopo un cambio lingua."""
|
||||
if self._action_show is not None:
|
||||
self._action_show.setText(tr("tray_show_window"))
|
||||
if self._action_web is not None:
|
||||
self._action_web.setText(tr("tray_open_web"))
|
||||
if self._action_updates is not None:
|
||||
self._action_updates.setText(tr("tray_check_updates"))
|
||||
if self._action_quit is not None:
|
||||
self._action_quit.setText(tr("tray_quit"))
|
||||
self.update_status(self.is_listening)
|
||||
|
||||
def show_message(self, title: str, message: str, duration_ms: int = 5000) -> None:
|
||||
"""Mostra una notifica desktop nativa tramite la System Tray."""
|
||||
|
||||
Reference in new issue
Block a user