""" The ui loader class """ # Python import os # Qt from email import message from PySide2 import QtWidgets from PySide2.QtCore import Slot # parent from simulator.dynamicloader import DynamicLoader # hd Simulator from dialin.ui.hd_simulator import HDSimulator from dialin.ui.hd_simulator import RequestRejectReasons # plugin specific # -- None -- class Loader(DynamicLoader): """ The ui loader class """ leMessageID: QtWidgets.QLineEdit btnAccept: QtWidgets.QPushButton btnReject: QtWidgets.QPushButton lblAction: QtWidgets.QLabel spnReason: QtWidgets.QSpinBox def __init__(self, hd_simulator: HDSimulator): super().__init__(os.path.dirname(__file__), hd_simulator) def _init_loader(self): """ finds and creates widgets :return: none """ self.leMessageID = self.find_line_edit('leMessageID') self.btnAccept = self.find_button('btnAccept') self.btnReject = self.find_button('btnReject') self.lblAction = self.find_label('lblAction') self.spnReason = self.find_spinbox('spnReason') def _init_widgets(self): """ initializes the widgets' properties :return: none """ pass def _init_connections(self): """ initializes the widgets connections :return: """ self.btnAccept.clicked.connect(self.do_accept) self.btnReject.clicked.connect(self.do_reject) @Slot() def do_accept(self): """ the slot for accept button :return: none """ message_id = self.leMessageID.text() self.hd_simulator.cmd_send_general_response(int(message_id), True, 0) self.lblAction.setText('Accepted ') @Slot() def do_reject(self): """ the slot for reject button :return: none """ message_id = self.leMessageID.text() reason = self.spnReason.value() self.hd_simulator.cmd_send_general_response(int(message_id), False, reason) self.lblAction.setText('Rejected ' + "{}".format(reason))