Add save-as to GUI

pull/357/head
nyanpasu64 2018-12-11 20:50:26 -08:00
rodzic 5e609f0ac5
commit a9d62868e3
2 zmienionych plików z 22 dodań i 2 usunięć

Wyświetl plik

@ -56,6 +56,7 @@ class MainWindow(qw.QMainWindow):
self.master_audio_browse.clicked.connect(self.on_master_audio_browse)
self.actionExit.triggered.connect(qw.QApplication.quit)
self.actionSave.triggered.connect(self.on_action_save)
self.actionSaveAs.triggered.connect(self.on_action_save_as)
self.actionPlay.triggered.connect(self.on_action_play)
self.actionRender.triggered.connect(self.on_action_render)
@ -78,6 +79,7 @@ class MainWindow(qw.QMainWindow):
menuBar: qw.QMenuBar
actionExit: qw.QAction
actionSave: qw.QAction
actionSaveAs: qw.QAction
actionPlay: qw.QAction
actionRender: qw.QAction
@ -94,9 +96,26 @@ class MainWindow(qw.QMainWindow):
def on_action_save(self):
if self._cfg_path is None:
raise NotImplementedError
return self.on_action_save_as()
yaml.dump(self.cfg, self._cfg_path)
def on_action_save_as(self):
cfg_path_default = os.path.join(self.cfg_dir, self.file_stem) + cli.YAML_NAME
filters = ["YAML files (*.yaml)", "All files (*)"]
name, file_type = qw.QFileDialog.getSaveFileName(
self, "Save As", cfg_path_default, ';;'.join(filters)
)
if name != '':
path = Path(name)
# FIXME automatic extension bad? Only if "YAML files (*.yaml)"
if file_type == filters[0] and path.suffix == '':
path = path.with_suffix(cli.YAML_NAME)
self._cfg_path = path
self.load_title()
self.on_action_save()
def on_action_play(self):
""" Launch ovgen and ffplay. """
arg = self._get_args([FFplayOutputConfig()])
@ -111,6 +130,7 @@ class MainWindow(qw.QMainWindow):
self, "Render to Video", video_path, "MP4 files (*.mp4);;All files (*)"
)
if name != '':
# FIXME what if missing mp4?
dlg = OvgenProgressDialog(self)
arg = self._get_args([FFmpegOutputConfig(name)], dlg)
error_msg = 'Cannot render to file, another play/render is active'

Wyświetl plik

@ -412,7 +412,7 @@ width: 0px;
</action>
<action name="actionSaveAs">
<property name="text">
<string>Save &amp;As?</string>
<string>Save &amp;As</string>
</property>
<property name="shortcut">
<string>Ctrl+Shift+S</string>