wait validation for production
This commit is contained in:
parent
e695eaa789
commit
5b41cb3805
|
|
@ -6,9 +6,9 @@ import weakref
|
|||
from glob import glob
|
||||
|
||||
from lib.db import Recipes, Users, db
|
||||
from PyQt5.QtCore import QTimer, pyqtSignal
|
||||
from PyQt5.QtCore import QTimer, pyqtSignal, Qt
|
||||
from PyQt5.QtGui import QKeySequence
|
||||
from PyQt5.QtWidgets import QFileDialog, QMessageBox, QShortcut, QInputDialog
|
||||
from PyQt5.QtWidgets import QFileDialog, QMessageBox, QShortcut, QInputDialog, QDialog, QVBoxLayout, QLabel, QLineEdit, QDialogButtonBox
|
||||
import shutil
|
||||
|
||||
from lib.helpers.recipe_manager import export_recipes, import_recipes, recipe_manager_signals, backup_current_recipes
|
||||
|
|
@ -332,8 +332,7 @@ class Recipe_Selection(Widget):
|
|||
|
||||
if len(candidates) > 1:
|
||||
# Prompt for a QR/barcode. If it contains or matches a recipe name among candidates, use that; else abort.
|
||||
text, ok = QInputDialog.getText(self, 'Selezione tramite QR',
|
||||
'Scansionare/Inserire il QR (deve contenere il nome ricetta):')
|
||||
text, ok = self._prompt_qr_for_dima()
|
||||
if not (ok and text):
|
||||
# Cancelled or empty: do nothing
|
||||
return
|
||||
|
|
@ -376,6 +375,49 @@ class Recipe_Selection(Widget):
|
|||
# Emit the resolved recipe (either the originally selected one or the matched one)
|
||||
self.ok.emit(final_recipe)
|
||||
|
||||
def _prompt_qr_for_dima(self):
|
||||
"""Show a larger dialog to disambiguate recipes when multiple share the same Codice Dima.
|
||||
Returns (text, ok) like QInputDialog.getText.
|
||||
"""
|
||||
dlg = QDialog(self)
|
||||
dlg.setWindowTitle('Selezione tramite QR')
|
||||
layout = QVBoxLayout(dlg)
|
||||
|
||||
# Highly visible warning requested by user
|
||||
warn = QLabel('SCANSIONARE IL FOGLIO DI LAVORO PER SELZIONARE IL CODICE DA COLLAUDARE', dlg)
|
||||
warn.setWordWrap(True)
|
||||
warn.setAlignment(Qt.AlignCenter)
|
||||
warn.setStyleSheet('font-size: 26px; font-weight: 700; color: red; background-color: yellow; padding: 12px;')
|
||||
layout.addWidget(warn)
|
||||
|
||||
edit = QLineEdit(dlg)
|
||||
edit.setPlaceholderText('Scansiona o digita qui e premi Invio...')
|
||||
layout.addWidget(edit)
|
||||
|
||||
buttons = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel, parent=dlg)
|
||||
layout.addWidget(buttons)
|
||||
|
||||
buttons.accepted.connect(dlg.accept)
|
||||
buttons.rejected.connect(dlg.reject)
|
||||
edit.returnPressed.connect(dlg.accept)
|
||||
|
||||
# Enlarge dialog by 50% for better visibility
|
||||
dlg.setModal(True)
|
||||
dlg.adjustSize()
|
||||
sh = dlg.sizeHint()
|
||||
try:
|
||||
dlg.resize(int(sh.width() * 1.5), int(sh.height() * 1.5))
|
||||
except Exception:
|
||||
# Fallback to a reasonable minimum size if sizeHint is unavailable
|
||||
dlg.resize(700, 400)
|
||||
|
||||
edit.setFocus()
|
||||
result = dlg.exec_()
|
||||
if result == QDialog.Accepted:
|
||||
return edit.text(), True
|
||||
else:
|
||||
return '', False
|
||||
|
||||
def get_def(self, dict, key):
|
||||
val = dict.get(key, self.defaults[key])
|
||||
return val if val != "" else self.defaults[key]
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user