diff --git a/lib/python/hal_glib.py b/lib/python/hal_glib.py index b943ff3e2..0a08ad9ea 100644 --- a/lib/python/hal_glib.py +++ b/lib/python/hal_glib.py @@ -202,6 +202,7 @@ class _GStat(GObject.GObject): 'play-sound': (GObject.SIGNAL_RUN_FIRST, GObject.TYPE_NONE, (GObject.TYPE_STRING,)), 'virtual-keyboard': (GObject.SIGNAL_RUN_FIRST, GObject.TYPE_NONE, (GObject.TYPE_STRING,)), 'dro-reference-change-request': (GObject.SIGNAL_RUN_FIRST, GObject.TYPE_NONE, (GObject.TYPE_INT,)), + 'error_osd_button_pressed': (GObject.SIGNAL_RUN_FIRST, GObject.TYPE_NONE, ()), 'show-preference': (GObject.SIGNAL_RUN_FIRST, GObject.TYPE_NONE, ()), 'shutdown': (GObject.SIGNAL_RUN_FIRST, GObject.TYPE_NONE, ()), 'error': (GObject.SIGNAL_RUN_FIRST, GObject.TYPE_NONE, (GObject.TYPE_INT, GObject.TYPE_STRING)), diff --git a/lib/python/qtvcp/lib/notify.py b/lib/python/qtvcp/lib/notify.py index ea3672316..1b3868f2d 100644 --- a/lib/python/qtvcp/lib/notify.py +++ b/lib/python/qtvcp/lib/notify.py @@ -8,7 +8,7 @@ import sys # callback work around: # http://stackoverflow.com/questions/8727937/callbacks-and-gtk-main-loop -from qtvcp.core import Status +from qtvcp.core import Status, Info from qtvcp.lib import sys_notify # Set up logging @@ -17,6 +17,7 @@ from qtvcp import logger log = logger.getLogger(__name__) STATUS = Status() +INFO = Info() sys_notify.init('notify') @@ -168,24 +169,30 @@ class Notify: ################################################ def yesClicked(self, n, action, callback): callback(True) + STATUS.emit('error_osd_button_pressed') def noClicked(self, n, action, callback): callback(False) + STATUS.emit('error_osd_button_pressed') def okClicked(self, n, action, callback): callback(True) + STATUS.emit('error_osd_button_pressed') def cancelClicked(self, n, action, callback): callback(False) + STATUS.emit('error_osd_button_pressed') def jogPauseClicked(self, n, action, callback): callback(-1) + STATUS.emit('error_osd_button_pressed') def handle_closed(self, n): pass def closeClicked(self, n, text): n.close() + STATUS.emit('error_osd_button_pressed') def OnClicked(self, n, signal_text): print('1: ' + str(n)) @@ -208,10 +215,12 @@ class Notify: len(self.alarmpage), self.alarmpage[num][1]) n.show() + STATUS.emit('error_osd_button_pressed') def destroyClicked(self, n, signal_text): self.alarmpage = [] n.body = '' + STATUS.emit('error_osd_button_pressed') ##################################################### # General work functions @@ -220,23 +229,24 @@ class Notify: # this adds the new message to the old # show a max of 10 messages on screen def update(self, n, title='', message='', status_timeout=5, timeout=None): - if title is not None: - n.title = title - if self.alarmpage ==[]: - n.body = title + '\n' + message - elif len(self.alarmpage) <9: - n.body = '' - for i in range(len(self.alarmpage)): - n.body = n.body + '\n' + self.alarmpage[i][1] - n.body = n.body + '\n' + title + '\n' + message - else: - n.body = '' - for i in range(len(self.alarmpage)-9,len(self.alarmpage)): - n.body = n.body + '\n' + self.alarmpage[i][1] - n.body = n.body + '\n' + title + '\n' + message - if timeout is not None: - n.setTimeout(timeout * 1000) - n.show() + if INFO.MAX_DISPLAYED_ERRORS: + if title is not None: + n.title = title + if self.alarmpage ==[]: + n.body = title + '\n' + message + elif len(self.alarmpage) < (INFO.MAX_DISPLAYED_ERRORS - 1): + n.body = '' + for i in range(len(self.alarmpage)): + n.body = n.body + '\n' + self.alarmpage[i][1] + n.body = n.body + '\n' + title + '\n' + message + else: + n.body = '' + for i in range(len(self.alarmpage) - (INFO.MAX_DISPLAYED_ERRORS - 1), len(self.alarmpage)): + n.body = n.body + '\n' + self.alarmpage[i][1] + n.body = n.body + '\n' + title + '\n' + message + if timeout is not None: + n.setTimeout(timeout * 1000) + n.show() try: self.show_status(message, status_timeout) except: diff --git a/lib/python/qtvcp/qt_istat.py b/lib/python/qtvcp/qt_istat.py index 874ff9886..ecb1bb3ba 100644 --- a/lib/python/qtvcp/qt_istat.py +++ b/lib/python/qtvcp/qt_istat.py @@ -369,6 +369,9 @@ class _IStat(object): # Some systems need repeat disabled for keyboard jogging because repeat rate is uneven self.DISABLE_REPEAT_KEYS_LIST = self.INI.find("DISPLAY", "DISABLE_REPEAT_KEYS") or None + # maximum number of errors shown in on screen display + self.MAX_DISPLAYED_ERRORS = int(self.INI.find("DISPLAY", "MAX_DISPLAYED_ERRORS") or 10) + ################### # helper functions ################### diff --git a/share/qtvcp/screens/qtplasmac/qtplasmac_handler.py b/share/qtvcp/screens/qtplasmac/qtplasmac_handler.py index bd7aa8ab3..81b362ffd 100644 --- a/share/qtvcp/screens/qtplasmac/qtplasmac_handler.py +++ b/share/qtvcp/screens/qtplasmac/qtplasmac_handler.py @@ -43,6 +43,7 @@ from qtvcp.lib.qtplasmac import conv_sector as CONVSECT from qtvcp.lib.qtplasmac import conv_rotate as CONVROTA from qtvcp.lib.qtplasmac import conv_array as CONVARAY from qtvcp.lib.qtplasmac import conv_scale as CONVSCAL + # **** TEMP FOR CONVERSATIONAL TESTING **** #from importlib import reload @@ -288,6 +289,8 @@ class HandlerClass: STATUS.connect('interp-run', self.interp_running) STATUS.connect('jograte-changed', self.jog_rate_changed) STATUS.connect('graphics-gcode-properties', lambda w, d:self.update_gcode_properties(d)) + STATUS.connect('update-machine-log', self.machine_log_update) + STATUS.connect('error_osd_button_pressed', lambda s:self.color_last_tab(self.backColor, self.foreColor)) self.overlay.setText(self.get_overlay_text(False)) self.overlayConv.setText(self.get_overlay_text(True)) if not self.w.chk_overlay.isChecked(): @@ -1157,6 +1160,10 @@ class HandlerClass: def update_gcode_properties(self, props): self.gcodeProps = props + def machine_log_update(self, obj, msg, time): + if 'Tool 0' not in msg: + self.color_last_tab('#000000', '#FF0000') + ########################################################################################################################### # CALLBACKS FROM FORM # @@ -1345,6 +1352,9 @@ class HandlerClass: self.vkb_show(True) else: self.vkb_hide() + self.color_last_tab(self.backColor, self.foreColor) + self.w.machinelog.moveCursor(QTextCursor.End) + self.w.machinelog.setCursorWidth(0) def z_height_changed(self, value): self.w.dro_z.update_user(value * hal.get_value('plasmac.units-multiplier')) @@ -1467,6 +1477,10 @@ class HandlerClass: ######################################################################################################################### # GENERAL FUNCTIONS # ######################################################################################################################### + def color_last_tab(self, fg, bg): + self.w.main_tab_widget.setStyleSheet( \ + 'QTabBar::tab:last {{ color: {}; background: {} }}'.format(fg, bg)) + def touch_off_xy(self, x, y): if STATUS.is_on_and_idle() and STATUS.is_all_homed(): ACTION.CALL_MDI('G10 L20 P0 X{} Y{}'.format(x, y))