1from PySide6.QtWidgets
import QDialog, QLabel, QVBoxLayout
2from PySide6.QtCore
import Qt, QEvent, QTimer, QPoint
3from frontend.keystatus
import ActivationStatus
8 A tooltip dialog that provides detailed information about a table cell when the mouse hovers over it.
10 This class creates a small hover window that displays information such as the cell's content,
11 the activation status of the keyfile, and its status in the database. It is triggered when the mouse
12 hovers over a cell in the associated table widget.
16 Initialize the HoverInfo dialog with the table widget to monitor.
18 \param table_widget (QTableWidget): The table widget to track mouse hover events on.
19 \param parent (QWidget, optional): The parent widget.
22 super(HoverInfo, self).
__init__(parent)
24 self.setWindowFlags(Qt.WindowType.ToolTip)
25 layout = QVBoxLayout()
33 self.setLayout(layout)
46 Capture mouse hover events and display hover info.
48 This method handles mouse movement over the table widget to determine which cell the mouse is over,
49 and then triggers the tooltip display after a delay.
51 \param source (QObject): The source widget that the event is coming from (table widget viewport).
52 \param event (QEvent): The event being processed (mouse movement).
53 \return (bool): Returns True if the event is handled, otherwise False to pass the event to the base class.
55 if event.type() == QEvent.Type.MouseMove:
60 column = item.column()
63 self.
timer.timeout.disconnect()
69 self.
timer.start(1000)
75 elif event.type() == QEvent.Type.Leave:
84 Show the hover info dialog with details about the cell.
85 Hover info includes the table header name of this column, cell value, activation status,
88 \param item (QTableWidgetItem): The table cell item that is being hovered over.
89 \param pos (QPoint): The current position of the mouse cursor.
94 column_name = self.
table_widget.horizontalHeaderItem(col).text()
96 cell_value = item.data(Qt.ItemDataRole.UserRole + 2)
98 cell_value = item.text()
100 activation_status = self.
table_widget.item(row, 1).data(Qt.ItemDataRole.UserRole + 1)
101 if activation_status == ActivationStatus.ACTIVATED:
102 activate_status = self.tr(
"Keyfile is Activated")
103 elif activation_status == ActivationStatus.DEACTIVATED:
104 activate_status = self.tr(
"Keyfile is Deactivated")
106 activate_status = self.tr(
"")
108 self.
cell_label.setText(f
"{column_name}: {cell_value}")
110 self.tr(
"Activation Status: {activate_status}").format(activate_status=activate_status))
113 self.move(table_pos + QPoint(20, 50))
A tooltip dialog that provides detailed information about a table cell when the mouse hovers over it.
eventFilter(self, source, event)
Capture mouse hover events and display hover info.
show_hover_info(self, item, pos)
Show the hover info dialog with details about the cell.
__init__(self, table_widget, parent=None)
Initialize the HoverInfo dialog with the table widget to monitor.
bool timer_signal_connected