Saving settings restarts photobooth now to apply settings immediately

This commit is contained in:
Balthasar Reuter
2018-04-04 22:38:37 +02:00
parent 90ec84e286
commit 7a02d36c80
2 changed files with 31 additions and 6 deletions

View File

@@ -169,7 +169,7 @@ def main_photobooth(config, send, recv):
return photobooth.run(send, recv)
def main(argv):
def run(argv):
config = Config('photobooth.cfg')
@@ -181,3 +181,20 @@ def main(argv):
gui = PyQt5Gui(argv, config)
return gui.run(event_send, gui_recv)
def main(argv):
known_status_codes = {
-1: 'Initializing photobooth',
-2: 'Restarting photobooth and reloading config'
}
status_code = -1
while status_code in known_status_codes:
print(known_status_codes[status_code])
status_code = run(argv)
return status_code

View File

@@ -33,7 +33,10 @@ class PyQt5Gui(Gui.Gui):
self.showStart()
return self._app.exec_()
exit_code = self._app.exec_()
self._p = None
return exit_code
def close(self):
@@ -41,6 +44,11 @@ class PyQt5Gui(Gui.Gui):
self._p.close()
def restart(self):
self._app.exit(-2)
def handleKeypressEvent(self, event):
if event.key() == Qt.Key_Escape:
@@ -284,7 +292,7 @@ class PyQt5Settings(QFrame):
layout.addRow(QLabel('Width:'), self._value_widgets['Gui']['width'])
layout.addRow(QLabel('Height:'), self._value_widgets['Gui']['height'])
widget = QGroupBox('Interface settings (restart required)')
widget = QGroupBox('Interface settings')
widget.setLayout(layout)
return widget
@@ -294,7 +302,7 @@ class PyQt5Settings(QFrame):
global cfg
self._value_widgets['Gpio'] = {}
self._value_widgets['Gpio']['enable'] = QCheckBox('Enable GPIO (restart required)')
self._value_widgets['Gpio']['enable'] = QCheckBox('Enable GPIO')
if cfg.getBool('Gpio', 'enable'):
self._value_widgets['Gpio']['enable'].toggle()
self._value_widgets['Gpio']['exit_channel'] = QLineEdit(cfg.get('Gpio', 'exit_channel'))
@@ -347,7 +355,7 @@ class PyQt5Settings(QFrame):
global cfg
self._value_widgets['Photobooth'] = {}
self._value_widgets['Photobooth']['show_preview'] = QCheckBox('Show preview while countdown (restart required)')
self._value_widgets['Photobooth']['show_preview'] = QCheckBox('Show preview while countdown')
if cfg.getBool('Photobooth', 'show_preview'):
self._value_widgets['Photobooth']['show_preview'].toggle()
self._value_widgets['Photobooth']['pose_time'] = QLineEdit(cfg.get('Photobooth', 'pose_time'))
@@ -463,7 +471,7 @@ class PyQt5Settings(QFrame):
cfg.set('Camera', 'gphoto2_wrapper', wrapper_idx2val[self._value_widgets['Camera']['gphoto2_wrapper'].currentIndex()])
cfg.write()
self._gui.showStart()
self._gui.restart()
def restoreDefaults(self):