From 675a06dd4c10babb3ef2553f6c7cdd92b5f5ef0a Mon Sep 17 00:00:00 2001 From: tassaron Date: Sun, 25 Jun 2017 14:27:56 -0400 Subject: project files save settings & out/in fields --- src/components/video.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/components/video.py') diff --git a/src/components/video.py b/src/components/video.py index 44f88a5..d37dd99 100644 --- a/src/components/video.py +++ b/src/components/video.py @@ -88,8 +88,8 @@ class Video: self.parent.showMessage( msg='%s couldn\'t be loaded. ' 'This is a fatal error.' % os.path.basename( - self.videoPath - ), + self.videoPath + ), detail=str(e) ) self.parent.stopVideo() @@ -188,13 +188,13 @@ class Component(__base__.Component): } def pickVideo(self): - imgDir = self.settings.value("backgroundDir", os.path.expanduser("~")) + imgDir = self.settings.value("componentDir", os.path.expanduser("~")) filename, _ = QtWidgets.QFileDialog.getOpenFileName( self.page, "Choose Video", imgDir, "Video Files (%s)" % " ".join(self.videoFormats) ) if filename: - self.settings.setValue("backgroundDir", os.path.dirname(filename)) + self.settings.setValue("componentDir", os.path.dirname(filename)) self.page.lineEdit_video.setText(filename) self.update() -- cgit v1.2.3 From 6a1a5cd6eb931f5f9316f89c680ca318f845a746 Mon Sep 17 00:00:00 2001 From: tassaron Date: Sun, 25 Jun 2017 15:31:42 -0400 Subject: --export commandline option overrides -i and -o to use saved fields from a project file --- src/command.py | 48 +++++++++++++++++++++++++++++++++++++++--------- src/components/video.py | 3 ++- src/core.py | 2 ++ src/mainwindow.py | 7 +++++-- src/preview_thread.py | 3 ++- 5 files changed, 50 insertions(+), 13 deletions(-) (limited to 'src/components/video.py') diff --git a/src/command.py b/src/command.py index b400773..09b54ac 100644 --- a/src/command.py +++ b/src/command.py @@ -23,13 +23,20 @@ class Command(QtCore.QObject): epilog='EXAMPLE COMMAND: main.py myvideotemplate.avp ' '-i ~/Music/song.mp3 -o ~/video.mp4 ' '-c 0 image path=~/Pictures/thisWeeksPicture.jpg ' - '-c 1 video "preset=My Logo" -c 2 vis layout=classic') + '-c 1 video "preset=My Logo" -c 2 vis layout=classic' + ) self.parser.add_argument( '-i', '--input', metavar='SOUND', - help='input audio file') + help='input audio file' + ) self.parser.add_argument( '-o', '--output', metavar='OUTPUT', - help='output video file') + help='output video file' + ) + self.parser.add_argument( + '-e', '--export', action='store_true', + help='use input and output files from project file' + ) # optional arguments self.parser.add_argument( @@ -46,7 +53,15 @@ class Command(QtCore.QObject): LoadDefaultSettings(self) if self.args.projpath: - self.core.openProject(self, self.args.projpath) + projPath = self.args.projpath + if not os.path.dirname(projPath): + projPath = os.path.join( + self.settings.value("projectDir"), + projPath + ) + if not projPath.endswith('.avp'): + projPath += '.avp' + self.core.openProject(self, projPath) self.core.selectedComponents = list( reversed(self.core.selectedComponents)) self.core.componentListChanged() @@ -70,13 +85,28 @@ class Command(QtCore.QObject): for arg in args: self.core.selectedComponents[i].command(arg) - if self.args.input and self.args.output: - self.createAudioVisualisation() + if self.args.export and self.args.projpath: + errcode, data = self.core.parseAvFile(projPath) + for line in data['WindowFields']: + if 'outputFile' in line: + output = line.split('=', 1)[1] + if not os.path.dirname(output): + output = os.path.join( + os.path.expanduser('~'), + output + ) + if 'audioFile' in line: + input = line.split('=', 1)[1] + self.createAudioVisualisation(input, output) + + elif self.args.input and self.args.output: + self.createAudioVisualisation(self.args.input, self.args.output) + elif 'help' not in sys.argv: self.parser.print_help() quit(1) - def createAudioVisualisation(self): + def createAudioVisualisation(self, input, output): self.videoThread = QtCore.QThread(self) self.videoWorker = video_thread.Worker(self) self.videoWorker.moveToThread(self.videoThread) @@ -84,8 +114,8 @@ class Command(QtCore.QObject): self.videoThread.start() self.videoTask.emit( - self.args.input, - self.args.output, + input, + output, list(reversed(self.core.selectedComponents)) ) diff --git a/src/components/video.py b/src/components/video.py index d37dd99..02bb44b 100644 --- a/src/components/video.py +++ b/src/components/video.py @@ -90,7 +90,8 @@ class Video: 'This is a fatal error.' % os.path.basename( self.videoPath ), - detail=str(e) + detail=str(e), + icon='Warning' ) self.parent.stopVideo() break diff --git a/src/core.py b/src/core.py index d7e8219..a435c2c 100644 --- a/src/core.py +++ b/src/core.py @@ -183,7 +183,9 @@ class Core(): for pair in data['WindowFields']: widget, value = pair.split('=', 1) widget = eval('loader.window.%s' % widget) + widget.blockSignals(True) widget.setText(value.strip()) + widget.blockSignals(False) for pair in data['Settings']: key, value = pair.split('=', 1) diff --git a/src/mainwindow.py b/src/mainwindow.py index e4e4f38..203992b 100644 --- a/src/mainwindow.py +++ b/src/mainwindow.py @@ -229,7 +229,9 @@ class MainWindow(QtWidgets.QMainWindow): project += '.avp' # open a project from the commandline if not os.path.dirname(project): - project = os.path.join(os.path.expanduser('~'), project) + project = os.path.join( + self.settings.value("projectDir"), project + ) self.currentProject = project self.settings.setValue("currentProject", project) if os.path.exists(self.autosavePath): @@ -433,7 +435,8 @@ class MainWindow(QtWidgets.QMainWindow): self.showMessage( msg='Chosen filename matches a directory, which ' 'cannot be overwritten. Please choose a different ' - 'filename or move the directory.' + 'filename or move the directory.', + icon='Warning', ) return else: diff --git a/src/preview_thread.py b/src/preview_thread.py index 769656b..e58f04e 100644 --- a/src/preview_thread.py +++ b/src/preview_thread.py @@ -58,7 +58,8 @@ class Worker(QtCore.QObject): msg="Bad frame returned by %s's previewRender method. " "This is a fatal error." % str(component), - detail=str(e) + detail=str(e), + icon='Warning' ) quit(1) -- cgit v1.2.3