diff --git a/lib/python/qtvcp/lib/notify.py b/lib/python/qtvcp/lib/notify.py index ea3672316..d04d6a3bc 100644 --- a/lib/python/qtvcp/lib/notify.py +++ b/lib/python/qtvcp/lib/notify.py @@ -219,19 +219,19 @@ class Notify: # update the critical message display # 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): + def update(self, n, title='', message='', status_timeout=5, timeout=None, msgs=10): if title is not None: n.title = title if self.alarmpage ==[]: n.body = title + '\n' + message - elif len(self.alarmpage) <9: + elif len(self.alarmpage) < (msgs - 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)-9,len(self.alarmpage)): + for i in range(len(self.alarmpage) - (msgs - 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: diff --git a/lib/python/qtvcp/plugins/screenoptions_plugin.py b/lib/python/qtvcp/plugins/screenoptions_plugin.py index 8e933397c..15cf1326c 100644 --- a/lib/python/qtvcp/plugins/screenoptions_plugin.py +++ b/lib/python/qtvcp/plugins/screenoptions_plugin.py @@ -83,6 +83,9 @@ class screenOptionsDialog(QtWidgets.QDialog): layout = QtWidgets.QGridLayout() self.c_notify = QtWidgets.QCheckBox("Desktop Notify Errors") self.c_notify.setChecked(widget.desktop_notify) + self.c_notify_max_msgs = QtWidgets.QSpinBox("Notify Max Errors") + self.c_notify_max_msgs.setValue(widget.notify_max_messages) + self.c_notify_max_msgs.setRange(1, 10) self.c_errors = QtWidgets.QCheckBox("Catch Errors") self.c_errors.setChecked(widget.catch_errors) self.c_close = QtWidgets.QCheckBox("Catch close Event") @@ -93,6 +96,7 @@ class screenOptionsDialog(QtWidgets.QDialog): self.c_use_pref_file.setChecked(widget.use_pref_file) layout.addWidget(self.c_notify) + layout.addWidget(self.c_notify_max_msgs) layout.addWidget(self.c_errors) layout.addWidget(self.c_close) layout.addWidget(self.c_play_sounds) @@ -110,6 +114,8 @@ class screenOptionsDialog(QtWidgets.QDialog): if formWindow: formWindow.cursor().setProperty("notify_option", QtCore.QVariant(self.c_notify.isChecked())) + formWindow.cursor().setProperty("notify_max_messages", + QtCore.QVariant(self.c_notify_max_msgs.value())) formWindow.cursor().setProperty("catch_errors_option", QtCore.QVariant(self.c_errors.isChecked())) formWindow.cursor().setProperty("catch_close_option", diff --git a/lib/python/qtvcp/widgets/screen_options.py b/lib/python/qtvcp/widgets/screen_options.py index b10ae96c4..ee7e09670 100644 --- a/lib/python/qtvcp/widgets/screen_options.py +++ b/lib/python/qtvcp/widgets/screen_options.py @@ -79,6 +79,7 @@ class ScreenOptions(QtWidgets.QWidget, _HalWidgetBase): self.error = linuxcnc.error_channel() self.catch_errors = True self.desktop_notify = True + self.notify_max_msgs = 10 self.close_event = True self.play_sounds = True self.mchnMsg_play_sound = True @@ -195,6 +196,7 @@ class ScreenOptions(QtWidgets.QWidget, _HalWidgetBase): if self.PREFS_: self.catch_errors = self.PREFS_.getpref('catch_errors', self.catch_errors, bool, 'SCREEN_OPTIONS') self.desktop_notify = self.PREFS_.getpref('desktop_notify', self.desktop_notify, bool, 'SCREEN_OPTIONS') + self.notify_max_msgs = self.PREFS_.getpref('notify_max_msgs', self.notify_max_msgs, int, 'SCREEN_OPTIONS') self.close_event = self.PREFS_.getpref('shutdown_check', self.close_event, bool, 'SCREEN_OPTIONS') self.play_sounds = self.PREFS_.getpref('sound_player_on', self.play_sounds, bool, 'SCREEN_OPTIONS') self.mchnMsg_play_sound = self.PREFS_.getpref('mchnMsg_play_sound', self.mchnMsg_play_sound, bool, 'MCH_MSG_OPTIONS') @@ -313,34 +315,35 @@ class ScreenOptions(QtWidgets.QWidget, _HalWidgetBase): def process_error(self, w, kind, text): if 'on limit switch error' in text: if self.desktop_notify: - NOTICE.update(self.notify_hard_limits, title='Machine Error:', message=text) + NOTICE.update(self.notify_hard_limits, title='Machine Error:', message=text, msgs=self.notify_max_msgs) elif kind == linuxcnc.OPERATOR_ERROR: if self.desktop_notify: - NOTICE.update(self.notify_critical, title='Operator Error:', message=text) + NOTICE.update(self.notify_critical, title='Operator Error:', message=text, msgs=self.notify_max_msgs) elif kind == linuxcnc.OPERATOR_TEXT: if self.desktop_notify: - NOTICE.update(self.notify_critical, title='Operator Text:', message=text) + NOTICE.update(self.notify_critical, title='Operator Text:', message=text, msgs=self.notify_max_msgs) elif kind == linuxcnc.OPERATOR_DISPLAY: if self.desktop_notify: - NOTICE.update(self.notify_critical, title='Operator Display:', message=text) + NOTICE.update(self.notify_critical, title='Operator Display:', message=text, msgs=self.notify_max_msgs) elif kind == linuxcnc.NML_ERROR: if self.desktop_notify: - NOTICE.update(self.notify_critical, title='Internal NML Error:', message=text) + NOTICE.update(self.notify_critical, title='Internal NML Error:', message=text, msgs=self.notify_max_msgs) elif kind == linuxcnc.NML_TEXT: if self.desktop_notify: - NOTICE.update(self.notify_critical, title='Internal NML Text:', message=text) + NOTICE.update(self.notify_critical, title='Internal NML Text:', message=text, msgs=self.notify_max_msgs) elif kind == linuxcnc.NML_DISPLAY: if self.desktop_notify: - NOTICE.update(self.notify_critical, title='Internal NML Display:', message=text) + NOTICE.update(self.notify_critical, title='Internal NML Display:', message=text, msgs=self.notify_max_msgs) elif kind == STATUS.TEMPARARY_MESSAGE: # temporary info if self.desktop_notify: NOTICE.update(self.notify_normal, title='Operator Info:', - message=text, + message=text, status_timeout=0, - timeout=2) + timeout=2, + msgs=self.notify_max_msgs) if self.play_sounds and self.mchnMsg_play_sound: STATUS.emit('play-sound', '%s' % self.mchnMsg_sound_type) @@ -661,6 +664,13 @@ class ScreenOptions(QtWidgets.QWidget, _HalWidgetBase): def reset_notify(self): self.desktop_notify = True + def set_max_messages(self, data): + self.notify_max_msgs = data + def get_max_messages(self): + return self.notify_max_msgs + def reset_max_messages(self): + self.notify_max_msgs = 10 + def set_close(self, data): self.close_event = data def get_close(self): @@ -715,6 +725,7 @@ class ScreenOptions(QtWidgets.QWidget, _HalWidgetBase): # designer will show these properties in this order: notify_option = QtCore.pyqtProperty(bool, get_notify, set_notify, reset_notify) + notify_max_messages = QtCore.pyqtProperty(int, get_max_messages, set_max_messages, reset_max_messages) catch_close_option = QtCore.pyqtProperty(bool, get_close, set_close, reset_close) close_overlay_color = QtCore.pyqtProperty(QtGui.QColor, getColor, setColor)