def __on_msoupdate(self, msoupdate): ''' Handles msoupdate message sent after the device is updated. :param msoupdate: the update. ''' if len(msoupdate) > 0 and 'path' in msoupdate[0] and msoupdate[0][ 'path'].startswith('/peq/slots/'): self.__last_received_msoupdate = msoupdate was_requested = False if self.__spinner is not None: was_requested = True stop_spinner(self.__spinner, self.syncStatus) self.__spinner = None if was_requested: if not self.__msoupdate_matches(msoupdate): self.syncStatus.setIcon(qta.icon('fa5s.times', color='red')) self.show_sync_details() else: self.syncStatus.setIcon( qta.icon('fa5s.check', color='green')) else: self.syncStatus.setIcon(qta.icon('fa5s.question', color='red')) self.__update_device_state(msoupdate) self.showDetailsButton.setEnabled(True) else: logger.debug(f"Ignoring UI driven update")
def __stop_spinning(self): from model.batch import stop_spinner stop_spinner(self.__tmdb_spinner, self.tmdbButton) self.__tmdb_spinner = None self.tmdbButton.setIcon(QIcon()) self.tmdbButton.setText('Load TMDB Info') self.tmdbButton.setEnabled(True)
def __on_ws_message(self, msg): ''' Handles messages from the device. :param msg: the message. ''' if msg.startswith('mso '): logger.debug(f"Processing mso {msg}") self.__on_mso(json.loads(msg[4:])) elif msg.startswith('msoupdate '): logger.debug(f"Processing msoupdate {msg}") self.__on_msoupdate(json.loads(msg[10:])) else: logger.warning(f"Unknown message {msg}") msg_box = QMessageBox(QMessageBox.Critical, 'Unknown Message', f"Received unexpected message from {self.ipAddress.text()}") msg_box.setDetailedText(f"<code>{msg}</code>") msg_box.setTextFormat(Qt.RichText) msg_box.exec() if self.__spinner is not None: stop_spinner(self.__spinner, self.syncStatus) self.__spinner = None self.syncStatus.setIcon(qta.icon('fa5s.times', color='red'))
def __on_send_filter_event(self, code: int, btn: QPushButton): if code == FilterPublisherSignals.ON_START: self.__process_spinner = qta.Spin(btn) spin_icon = qta.icon('fa5s.spinner', color='green', animation=self.__process_spinner) btn.setIcon(spin_icon) btn.setEnabled(False) pass elif code == FilterPublisherSignals.ON_COMPLETE: from model.batch import stop_spinner stop_spinner(self.__process_spinner, btn) self.__process_spinner = None btn.setIcon(qta.icon('fa5s.check', color='green')) btn.setEnabled(True) elif code == FilterPublisherSignals.ON_ERROR: from model.batch import stop_spinner stop_spinner(self.__process_spinner, btn) self.__process_spinner = None btn.setIcon(qta.icon('fa5s.times', color='red')) btn.setEnabled(True) else: logger.warning( f"Unknown code received from FilterPublisher - {code}")
def __stop_spinning(self): from model.batch import stop_spinner stop_spinner(self.__process_spinner, self.processFiles) self.__process_spinner = None self.processFiles.setIcon(qta.icon('fa5s.save')) self.processFiles.setEnabled(True)