diff --git a/src/components/rfid_pn532.py b/src/components/rfid_pn532.py
index 23796d3..6ea90ca 100644
--- a/src/components/rfid_pn532.py
+++ b/src/components/rfid_pn532.py
@@ -3,7 +3,7 @@ import ctypes
import sys
import platform
from PyQt5.QtCore import QMutex, Qt, QTimer, pyqtSlot, pyqtSignal
-from .component import Component
+from src.components import Component
import ndef
import src.lib.nfc
from src.lib.nfc.clf import RemoteTarget
diff --git a/src/ui/barcode_recipe_selection/barcode_recipe_selection.py b/src/ui/barcode_recipe_selection/barcode_recipe_selection.py
index 28faf93..244a634 100644
--- a/src/ui/barcode_recipe_selection/barcode_recipe_selection.py
+++ b/src/ui/barcode_recipe_selection/barcode_recipe_selection.py
@@ -6,14 +6,52 @@ from PyQt5 import Qt
from lib.helpers import timing
from PyQt5.QtCore import Qt, QTimer, QThread
from PyQt5.QtGui import QKeySequence, QPixmap, QPalette, QColor
-from PyQt5.QtWidgets import QShortcut, QApplication
+from PyQt5.QtWidgets import QShortcut, QApplication, QDialog, QVBoxLayout, QLabel, QPushButton, QPlainTextEdit, \
+ QHBoxLayout, QMessageBox
from ui.test_test import Test_Test
from ui.widget import Widget
from lib import db
-from lib.db.models import Recipes
+from lib.db.models import Recipes , Users
test_scan="xxx\nyyy\nzzz"
+
+class TagWindow(QDialog):
+ def __init__(self, parent=None):
+ super().__init__(parent)
+
+ self.setWindowTitle("Scrittura NFC")
+ self.setFixedSize(400, 300)
+
+ layout = QVBoxLayout(self)
+
+
+ self.text_edit = QPlainTextEdit(self)
+ self.text_edit.setPlaceholderText("Scanerizza il QRcode della Dima")
+ self.text_edit.setFixedHeight(100)
+
+
+ layout.addWidget(self.text_edit)
+ button_layout = QHBoxLayout()
+
+
+ self.ok_button = QPushButton("Conferma Tag", self)
+ self.ok_button.clicked.connect(self.on_ok_clicked)
+
+ # Create the Close button
+ self.close_button = QPushButton("Chiudi", self)
+ self.close_button.clicked.connect(self.close)
+
+ button_layout.addWidget(self.ok_button)
+ button_layout.addWidget(self.close_button)
+ layout.addLayout(button_layout)
+
+ def on_ok_clicked(self):
+ entered_text = self.text_edit.toPlainText()
+ print(f"Text Entered: {entered_text}")
+ self.accept()
+
+
class Barcode_Recipe_Selection(Test_Test):
def __init__(self, parent):
super().__init__()
@@ -34,6 +72,8 @@ class Barcode_Recipe_Selection(Test_Test):
self.status_palettes["warning"].setColor(QPalette.Base, QColor(255, 165, 0))
self.status_palettes[""].setColor(QPalette.Base, QColor(255, 255, 0))
+ self.tag_b.clicked.connect(self.open_tag_window)
+
self.recipe_selection_b.clicked.connect(self.parent.set_recipe_mode_table)
self.barcode_input_l.setFocus()
@@ -49,6 +89,12 @@ class Barcode_Recipe_Selection(Test_Test):
self.ok_timer.setSingleShot(True)
self.ok_timer.timeout.connect(self.set_recipe)
+ session= Users.get_session()
+
+ if session.is_admin:
+ self.tag_b.setVisible(True)
+ else:
+ self.tag_b.setVisible(False)
def start(self, recipe=None, step=None, pieces=None):
@@ -113,4 +159,35 @@ class Barcode_Recipe_Selection(Test_Test):
self.parent_assembly_widget().set_text("SCANSIONARE BARCODE SELEZIONE RICETTA")
+ def open_tag_window(self):
+ # Open the tag writing window
+ self.tag_window = TagWindow(self)
+ result = self.tag_window.exec_() # Get the result of the dialog (OK or Cancel)
+ if result != QDialog.Accepted:
+ return # If canceled, return
+
+ entered_text = self.tag_window.text_edit.toPlainText().strip()
+ if not entered_text:
+ QMessageBox.warning(
+ self,
+ "Warning",
+ "The text is empty. Please enter text to write to the tag.",
+ )
+ return
+
+ # Check if the tag is empty
+ if self.parent.components["fixture_id"].current_data:
+ # Tag already contains data, ask for confirmation to overwrite
+ confirmation_result = QMessageBox.question(
+ self,
+ "Tag Already Written",
+ "The tag already contains data. Do you want to overwrite it?",
+ QMessageBox.Yes | QMessageBox.No,
+ )
+ if confirmation_result == QMessageBox.No:
+ return # User does not want to overwrite, so return without writing
+
+ # Write the entered text to the tag
+ self.parent.components["fixture_id"].write_tag(entered_text)
+ QMessageBox.information(self, "Success", "The tag has been successfully written.")
diff --git a/src/ui/barcode_recipe_selection/barcode_recipe_selection.ui b/src/ui/barcode_recipe_selection/barcode_recipe_selection.ui
index b45d4a3..33b402b 100644
--- a/src/ui/barcode_recipe_selection/barcode_recipe_selection.ui
+++ b/src/ui/barcode_recipe_selection/barcode_recipe_selection.ui
@@ -13,54 +13,146 @@
Test Connector
-
-
- 0
-
-
- 0
-
-
- 0
-
-
- 0
-
- -
-
-
-
- 600
- 0
-
-
-
-
- 600
- 200
-
-
-
-
- 20
-
-
-
-
-
-
-
- -
-
-
-
- 20
-
-
-
- TORNA ALLA TABELLA RICETTE
-
-
+
+
-
+
+
-
+
+
-
+
+
+ Qt::Horizontal
+
+
+
+ 308
+ 20
+
+
+
+
+ -
+
+
+
+ 20
+
+
+
+ TORNA ALLA TABELLA RICETTE
+
+
+
+ -
+
+
+
+ 600
+ 0
+
+
+
+
+ 600
+ 200
+
+
+
+
+ 20
+
+
+
+
+
+
+
+ -
+
+
+ Qt::Vertical
+
+
+
+ 20
+ 78
+
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 378
+ 20
+
+
+
+
+ -
+
+
+ Qt::Vertical
+
+
+
+ 20
+ 78
+
+
+
+
+ -
+
+
+ Qt::Vertical
+
+
+
+ 20
+ 168
+
+
+
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+
+ 11
+
+
+
+ SCRIVI TAG NFC
+
+
+
+ -
+
+
+ Qt::Vertical
+
+
+
+ 20
+ 28
+
+
+
+
+