diff options
| author | tassaron | 2017-07-11 06:06:22 -0400 |
|---|---|---|
| committer | tassaron | 2017-07-11 06:06:22 -0400 |
| commit | 2e37dafd7036973a315b525f131850a6fb6d0b35 (patch) | |
| tree | 090e5b29c706f38945209e33161b4cc9713782f2 /src | |
| parent | 4c3920e6309b4e67e3d8d809dd0b5b6cd245fd0c (diff) | |
fixed various bugs
Diffstat (limited to 'src')
| -rw-r--r-- | src/component.py | 9 | ||||
| -rw-r--r-- | src/components/image.py | 10 | ||||
| -rw-r--r-- | src/components/sound.py | 8 | ||||
| -rw-r--r-- | src/components/text.py | 10 | ||||
| -rw-r--r-- | src/components/video.py | 21 | ||||
| -rw-r--r-- | src/components/video.ui | 17 | ||||
| -rw-r--r-- | src/core.py | 4 | ||||
| -rw-r--r-- | src/mainwindow.py | 4 | ||||
| -rw-r--r-- | src/preview_thread.py | 26 | ||||
| -rw-r--r-- | src/video_thread.py | 9 |
10 files changed, 83 insertions, 35 deletions
diff --git a/src/component.py b/src/component.py index 7c2f753..eea82d7 100644 --- a/src/component.py +++ b/src/component.py @@ -30,10 +30,17 @@ class Component(QtCore.QObject): def properties(self): ''' Return a list of properties to signify if your component is - non-animated ('static') or returns sound ('audio'). + non-animated ('static'), returns sound ('audio'), or has + encountered an error in configuration ('error'). ''' return [] + def error(self): + ''' + Return a string containing an error message, or None for a default. + ''' + return + def cancel(self): # please stop any lengthy process in response to this variable self.canceled = True diff --git a/src/components/image.py b/src/components/image.py index 94dcb83..07abc3f 100644 --- a/src/components/image.py +++ b/src/components/image.py @@ -47,7 +47,15 @@ class Component(Component): return self.drawFrame(width, height) def properties(self): - return ['static'] + props = ['static'] + if not os.path.exists(self.imagePath): + props.append('error') + return props + + def error(self): + if not os.path.exists(self.imagePath): + return "The image path selected on " \ + "layer %s no longer exists!" % str(self.compPos) def frameRender(self, layerNo, frameNo): width = int(self.worker.core.settings.value('outputWidth')) diff --git a/src/components/sound.py b/src/components/sound.py index 1f43c83..9c114a8 100644 --- a/src/components/sound.py +++ b/src/components/sound.py @@ -28,7 +28,7 @@ class Component(Component): def previewRender(self, previewWorker): width = int(previewWorker.core.settings.value('outputWidth')) height = int(previewWorker.core.settings.value('outputHeight')) - return self.frameRender(self.compPos, 0) + return BlankFrame(width, height) def preFrameRender(self, **kwargs): pass @@ -37,7 +37,7 @@ class Component(Component): return ['static', 'audio'] def audio(self): - return self.sound + return (self.sound, {}) def pickSound(self): sndDir = self.settings.value("componentDir", os.path.expanduser("~")) @@ -50,8 +50,8 @@ class Component(Component): self.update() def frameRender(self, layerNo, frameNo): - width = int(self.core.settings.value('outputWidth')) - height = int(self.core.settings.value('outputHeight')) + width = int(self.settings.value('outputWidth')) + height = int(self.settings.value('outputHeight')) return BlankFrame(width, height) def loadPreset(self, pr, presetName=None): diff --git a/src/components/text.py b/src/components/text.py index fb6a90e..ed50064 100644 --- a/src/components/text.py +++ b/src/components/text.py @@ -75,15 +75,15 @@ class Component(Component): '''Returns true x, y after considering alignment settings''' fm = QtGui.QFontMetrics(self.titleFont) if self.alignment == 0: # Left - x = self.xPosition + x = int(self.xPosition) if self.alignment == 1: # Middle offset = fm.width(self.title)/2 - x = self.xPosition - offset + x = int(self.xPosition - offset) if self.alignment == 2: # Right offset = fm.width(self.title) - x = self.xPosition - offset + x = int(self.xPosition - offset) return x, self.yPosition def loadPreset(self, pr, presetName=None): @@ -128,12 +128,12 @@ class Component(Component): return self.addText(width, height) def addText(self, width, height): - x, y = self.getXY() - image = FramePainter(width, height) + image = FramePainter(width, height) self.titleFont.setPixelSize(self.fontSize) image.setFont(self.titleFont) image.setPen(self.textColor) + x, y = self.getXY() image.drawText(x, y, self.title) return image.finalize() diff --git a/src/components/video.py b/src/components/video.py index e6890e0..5303e3a 100644 --- a/src/components/video.py +++ b/src/components/video.py @@ -123,6 +123,7 @@ class Component(Component): page.pushButton_video.clicked.connect(self.pickVideo) page.checkBox_loop.stateChanged.connect(self.update) page.checkBox_distort.stateChanged.connect(self.update) + page.checkBox_useAudio.stateChanged.connect(self.update) page.spinBox_scale.valueChanged.connect(self.update) page.spinBox_x.valueChanged.connect(self.update) page.spinBox_y.valueChanged.connect(self.update) @@ -133,6 +134,7 @@ class Component(Component): def update(self): self.videoPath = self.page.lineEdit_video.text() self.loopVideo = self.page.checkBox_loop.isChecked() + self.useAudio = self.page.checkBox_useAudio.isChecked() self.distort = self.page.checkBox_distort.isChecked() self.scale = self.page.spinBox_scale.value() self.xPosition = self.page.spinBox_x.value() @@ -151,6 +153,23 @@ class Component(Component): else: return frame + def properties(self): + props = [] + if self.useAudio: + # props.append('audio') + pass + if not os.path.exists(self.videoPath): + props.append('error') + return props + + def error(self): + if not os.path.exists(self.videoPath): + return "The video path selected on " \ + "layer %s no longer exists!" % str(self.compPos) + + def audio(self): + return (self.videoPath, {}) + def preFrameRender(self, **kwargs): super().preFrameRender(**kwargs) width = int(self.worker.core.settings.value('outputWidth')) @@ -175,6 +194,7 @@ class Component(Component): super().loadPreset(pr, presetName) self.page.lineEdit_video.setText(pr['video']) self.page.checkBox_loop.setChecked(pr['loop']) + self.page.checkBox_useAudio.setChecked(pr['useAudio']) self.page.checkBox_distort.setChecked(pr['distort']) self.page.spinBox_scale.setValue(pr['scale']) self.page.spinBox_x.setValue(pr['x']) @@ -185,6 +205,7 @@ class Component(Component): 'preset': self.currentPreset, 'video': self.videoPath, 'loop': self.loopVideo, + 'useAudio': self.useAudio, 'distort': self.distort, 'scale': self.scale, 'x': self.xPosition, diff --git a/src/components/video.ui b/src/components/video.ui index f05e8a5..97b7d6f 100644 --- a/src/components/video.ui +++ b/src/components/video.ui @@ -190,16 +190,20 @@ </widget> </item> <item> - <spacer name="horizontalSpacer_10"> + <widget class="QCheckBox" name="checkBox_useAudio"> + <property name="text"> + <string>Use Audio</string> + </property> + </widget> + </item> + <item> + <spacer name="horizontalSpacer"> <property name="orientation"> <enum>Qt::Horizontal</enum> </property> - <property name="sizeType"> - <enum>QSizePolicy::Fixed</enum> - </property> <property name="sizeHint" stdset="0"> <size> - <width>5</width> + <width>40</width> <height>20</height> </size> </property> @@ -256,9 +260,6 @@ </property> </spacer> </item> - <item> - <widget class="QWidget" name="widget" native="true"/> - </item> </layout> </widget> <resources/> diff --git a/src/core.py b/src/core.py index 3d64c3b..450e43b 100644 --- a/src/core.py +++ b/src/core.py @@ -524,7 +524,7 @@ class Core: if 'audio' in comp.properties() ] if extraAudio: - for extraInputFile in extraAudio: + for extraInputFile, params in extraAudio: ffmpegCommand.extend([ '-i', extraInputFile ]) @@ -532,7 +532,7 @@ class Core: '-filter_complex', 'amix=inputs=%s:duration=longest:dropout_transition=3' % str( len(extraAudio) + 1 - ) + ), ]) ffmpegCommand.extend([ diff --git a/src/mainwindow.py b/src/mainwindow.py index 3cd45d6..d21ba0a 100644 --- a/src/mainwindow.py +++ b/src/mainwindow.py @@ -713,6 +713,10 @@ class MainWindow(QtWidgets.QMainWindow): def saveCurrentProject(self): if self.currentProject: self.core.createProjectFile(self.currentProject, self.window) + try: + os.remove(self.autosavePath) + except FileNotFoundError: + pass self.updateWindowTitle() else: self.openSaveProjectDialog() diff --git a/src/preview_thread.py b/src/preview_thread.py index a72845b..fb3b792 100644 --- a/src/preview_thread.py +++ b/src/preview_thread.py @@ -25,8 +25,8 @@ class Worker(QtCore.QObject): self.parent = parent self.core = self.parent.core self.queue = queue - self.core.settings = parent.settings - self.stackedWidget = parent.window.stackedWidget + self.width = int(self.core.settings.value('outputWidth')) + self.height = int(self.core.settings.value('outputHeight')) # create checkerboard background to represent transparency self.background = FloodFrame(1920, 1080, (0, 0, 0, 0)) @@ -50,10 +50,10 @@ class Worker(QtCore.QObject): except Empty: continue - width = int(self.core.settings.value('outputWidth')) - height = int(self.core.settings.value('outputHeight')) + if self.background.width != self.width: + self.background = self.background.resize( + (self.width, self.height)) frame = self.background.copy() - frame = frame.resize((width, height)) components = nextPreviewInformation["components"] for component in reversed(components): @@ -63,23 +63,21 @@ class Worker(QtCore.QObject): ) except ValueError as e: + errMsg = "Bad frame returned by %s's preview renderer. " \ + "%s. This is a fatal error." % ( + str(component), str(e).capitalize() + ) + print(errMsg) self.parent.showMessage( - msg="Bad frame returned by %s's previewRender method. " - "This is a fatal error." % - str(component), + msg=errMsg, detail=str(e), icon='Warning', parent=None # MainWindow is in a different thread ) - self.imageCreated.emit( - QtGui.QImage(ImageQt( - FloodFrame(width, height, (0, 0, 0, 0)) - )) - ) self.error.emit() break else: - self.imageCreated.emit(ImageQt(frame)) + self.imageCreated.emit(QtGui.QImage(ImageQt(frame))) except Empty: True diff --git a/src/video_thread.py b/src/video_thread.py index dde71da..b00d512 100644 --- a/src/video_thread.py +++ b/src/video_thread.py @@ -151,6 +151,15 @@ class Worker(QtCore.QObject): progressBarSetText=self.progressBarSetText ) + if 'error' in comp.properties(): + self.canceled = True + errMsg = "Component #%s encountered an error!" % compNo \ + if comp.error() is None else comp.error() + self.parent.showMessage( + msg=errMsg, + icon='Warning', + parent=None # MainWindow is in a different thread + ) if 'static' in comp.properties(): self.staticComponents[compNo] = \ comp.frameRender(compNo, 0).copy() |
