From d53c1c74cb61ecaf01c98cddd67fccff5d992eb9 Mon Sep 17 00:00:00 2001 From: Balthasar Reuter Date: Fri, 27 Jul 2018 16:25:51 +0200 Subject: [PATCH] Added overwrite error message that is displayed instead of the actual error. Error message itself is still logged. Closes #34 --- photobooth/defaults.cfg | 3 ++- photobooth/gui/Qt5Gui/Frames.py | 34 +++++++++++++++++++++++++++++++ photobooth/gui/Qt5Gui/PyQt5Gui.py | 8 +++++++- 3 files changed, 43 insertions(+), 2 deletions(-) diff --git a/photobooth/defaults.cfg b/photobooth/defaults.cfg index 940af2d..b799c29 100644 --- a/photobooth/defaults.cfg +++ b/photobooth/defaults.cfg @@ -33,7 +33,6 @@ chan_r_pin = 27 # BOARD pin (BCM pin 22) switches the green channel chan_g_pin = 22 - [Printer] # Enable printing (True/False) enable = True @@ -59,6 +58,8 @@ countdown_time = 8 display_time = 5 # Timeout for postprocessing (shown after review) postprocess_time = 60 +# Overwrite displayed error message (Leave empty for none) +overwrite_error_message = [Picture] # Basedir of output pictures diff --git a/photobooth/gui/Qt5Gui/Frames.py b/photobooth/gui/Qt5Gui/Frames.py index e49bce3..5f64821 100644 --- a/photobooth/gui/Qt5Gui/Frames.py +++ b/photobooth/gui/Qt5Gui/Frames.py @@ -588,12 +588,17 @@ class Settings(QtWidgets.QFrame): 'postprocess_time')) self.add('Photobooth', 'postprocess_time', postproc_time) + err_msg = QtWidgets.QLineEdit( + self._cfg.get('Photobooth', 'overwrite_error_message')) + self.add('Photobooth', 'overwrite_error_message', err_msg) + layout = QtWidgets.QFormLayout() layout.addRow(_('Show preview during countdown:'), preview) layout.addRow(_('Greeter time before countdown [s]:'), greet_time) layout.addRow(_('Countdown time [s]:'), count_time) layout.addRow(_('Picture display time [s]:'), displ_time) layout.addRow(_('Postprocess timeout [s]:'), postproc_time) + layout.addRow(_('Overwrite displayed error message:'), err_msg) widget = QtWidgets.QWidget() widget.setLayout(layout) @@ -746,11 +751,32 @@ class Settings(QtWidgets.QFrame): lamp_pin.setValue(self._cfg.getInt('Gpio', 'lamp_pin')) self.add('Gpio', 'lamp_pin', lamp_pin) + chan_r_pin = QtWidgets.QSpinBox() + chan_r_pin.setRange(1, 40) + chan_r_pin.setValue(self._cfg.getInt('Gpio', 'chan_r_pin')) + self.add('Gpio', 'chan_r_pin', chan_r_pin) + + chan_g_pin = QtWidgets.QSpinBox() + chan_g_pin.setRange(1, 40) + chan_g_pin.setValue(self._cfg.getInt('Gpio', 'chan_g_pin')) + self.add('Gpio', 'chan_g_pin', chan_r_pin) + + chan_b_pin = QtWidgets.QSpinBox() + chan_b_pin.setRange(1, 40) + chan_b_pin.setValue(self._cfg.getInt('Gpio', 'chan_b_pin')) + self.add('Gpio', 'chan_b_pin', chan_b_pin) + + lay_rgb = QtWidgets.QHBoxLayout() + lay_rgb.addWidget(chan_r_pin) + lay_rgb.addWidget(chan_g_pin) + lay_rgb.addWidget(chan_b_pin) + layout = QtWidgets.QFormLayout() layout.addRow(_('Enable GPIO:'), enable) layout.addRow(_('Exit button pin (BCM numbering):'), exit_pin) layout.addRow(_('Trigger button pin (BCM numbering):'), trig_pin) layout.addRow(_('Idle lamp pin (BCM numbering):'), lamp_pin) + layout.addRow(_('RGB LED pins (BCM numbering):'), lay_rgb) widget = QtWidgets.QWidget() widget.setLayout(layout) @@ -824,6 +850,8 @@ class Settings(QtWidgets.QFrame): str(self.get('Photobooth', 'display_time').text())) self._cfg.set('Photobooth', 'postprocess_time', str(self.get('Photobooth', 'postprocess_time').text())) + self._cfg.set('Photobooth', 'overwrite_error_message', + self.get('Photobooth', 'overwrite_error_message').text()) self._cfg.set('Camera', 'module', camera.modules[self.get('Camera', @@ -856,6 +884,12 @@ class Settings(QtWidgets.QFrame): self._cfg.set('Gpio', 'trigger_pin', self.get('Gpio', 'trigger_pin').text()) self._cfg.set('Gpio', 'lamp_pin', self.get('Gpio', 'lamp_pin').text()) + self._cfg.set('Gpio', 'chan_r_pin', + self.get('Gpio', 'chan_r_pin').text()) + self._cfg.set('Gpio', 'chan_g_pin', + self.get('Gpio', 'chan_g_pin').text()) + self._cfg.set('Gpio', 'chan_b_pin', + self.get('Gpio', 'chan_b_pin').text()) self._cfg.set('Printer', 'enable', str(self.get('Printer', 'enable').isChecked())) diff --git a/photobooth/gui/Qt5Gui/PyQt5Gui.py b/photobooth/gui/Qt5Gui/PyQt5Gui.py index de05f1d..ddf5aab 100644 --- a/photobooth/gui/Qt5Gui/PyQt5Gui.py +++ b/photobooth/gui/Qt5Gui/PyQt5Gui.py @@ -146,8 +146,14 @@ class PyQt5Gui(GuiSkeleton): logging.error('%s: %s', state.origin, state.message) + err_msg = self._cfg.get('Photobooth', 'overwrite_error_message') + if len(err_msg) > 0: + message = err_msg + else: + message = 'Error: ' + state.message + reply = QtWidgets.QMessageBox.critical( - self._gui, state.origin, 'Error: ' + state.message, + self._gui, state.origin, message, QtWidgets.QMessageBox.Retry | QtWidgets.QMessageBox.Cancel, QtWidgets.QMessageBox.Cancel)