Postprocessing of GUI tasks (e.g. printing) without confirmation optionally possible. Closes #19
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -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])
|
||||
|
||||
@@ -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):
|
||||
|
||||
|
||||
Reference in New Issue
Block a user