Postprocessing of GUI tasks (e.g. printing) without confirmation optionally possible. Closes #19

This commit is contained in:
Balthasar Reuter
2018-07-17 01:17:15 +02:00
parent 69b51d520b
commit eed71bc23a
4 changed files with 25 additions and 5 deletions

View File

@@ -19,7 +19,7 @@ module = python-gphoto2
[Gpio]
# Enable use of GPIO (True/False)
enable = True
enable = False
# BOARD pin 18 (BCM pin 24) lets you return to start screen
exit_pin = 24
# BOARD pin 16 (BCM pin 23) triggers capturing pictures
@@ -32,6 +32,8 @@ lamp_pin = 4
enable = True
# Print to PDF (True/False) for debugging purposes
pdf = False
# Ask for confirmation before printing
confirmation = True
# Printer module to use (PyQt5)
module = PyQt5
# Paper width in mm

View File

@@ -27,19 +27,29 @@ class GuiPostprocessor:
super().__init__()
self._task_list = []
self._get_task_list = []
self._do_task_list = []
if config.getBool('Printer', 'enable'):
module = config.get('Printer', 'module')
paper_size = (config.getInt('Printer', 'width'),
config.getInt('Printer', 'height'))
pdf = config.getBool('Printer', 'pdf')
self._task_list.append(PrintPostprocess(module, paper_size, pdf))
if config.getBool('Printer', 'confirmation'):
self._get_task_list.append(
PrintPostprocess(module, paper_size, pdf))
else:
self._do_task_list.append(
PrintPostprocess(module, paper_size, pdf))
def get(self, picture):
tasks = [task.get(picture) for task in self._task_list]
return tasks
return [task.get(picture) for task in self._get_task_list]
def do(self, picture):
for task in self._do_task_list:
task.get(picture).action()
class PostprocessTask:

View File

@@ -743,6 +743,10 @@ class Settings(QtWidgets.QFrame):
pdf.setChecked(self._cfg.getBool('Printer', 'pdf'))
self.add('Printer', 'pdf', pdf)
confirmation = QtWidgets.QCheckBox()
confirmation.setChecked(self._cfg.getBool('Printer', 'confirmation'))
self.add('Printer', 'confirmation', confirmation)
module = self.createModuleComboBox(printer.modules,
self._cfg.get('Printer', 'module'))
self.add('Printer', 'module', module)
@@ -765,6 +769,7 @@ class Settings(QtWidgets.QFrame):
layout.addRow('Enable printing:', enable)
layout.addRow('Module:', module)
layout.addRow('Print to PDF (for debugging):', pdf)
layout.addRow('Ask for confirmation before printing:', confirmation)
layout.addRow('Paper size [mm]:', lay_size)
widget = QtWidgets.QWidget()
@@ -827,6 +832,8 @@ class Settings(QtWidgets.QFrame):
str(self.get('Printer', 'enable').isChecked()))
self._cfg.set('Printer', 'pdf',
str(self.get('Printer', 'pdf').isChecked()))
self._cfg.set('Printer', 'confirmation',
str(self.get('Printer', 'confirmation').isChecked()))
self._cfg.set('Printer', 'module',
printer.modules[self.get('Printer',
'module').currentIndex()][0])

View File

@@ -218,6 +218,7 @@ class PyQt5Gui(GuiSkeleton):
QtCore.QTimer.singleShot(
review_time,
lambda: self._comm.send(Workers.MASTER, GuiEvent('postprocess')))
self._postprocess.do(self._picture)
def showPostprocess(self, state):