From ffbd591789b99fd10d2c05d7e47125b266d9fba4 Mon Sep 17 00:00:00 2001 From: Felix Schill Date: Wed, 24 Oct 2018 16:23:34 +0200 Subject: [PATCH] added browse button in file properties dialog, to allow relinking of individual media files. Openshot will not check if the new file has the same properties - has to be used carefully --- src/classes/query.py | 3 ++- src/windows/file_properties.py | 11 +++++++++++ src/windows/main_window.py | 17 +++++++++++++++++ src/windows/ui/file-properties.ui | 14 +++++++++++--- 4 files changed, 41 insertions(+), 4 deletions(-) diff --git a/src/classes/query.py b/src/classes/query.py index 4d3e68fd27..22878024cf 100644 --- a/src/classes/query.py +++ b/src/classes/query.py @@ -165,7 +165,8 @@ def title(self): """ Get the translated display title of this item """ path = self.data.get("reader", {}).get("path") folder_path, filename = os.path.split(path) - return os.path.splitext(filename)[0] + #return os.path.splitext(filename)[0] + return filename class Transition(QueryObject): """ This class allows Transitions (i.e. timeline effects) to be queried, updated, and deleted from the project data. """ diff --git a/src/windows/file_properties.py b/src/windows/file_properties.py index 4d50b26771..63a30e633a 100644 --- a/src/windows/file_properties.py +++ b/src/windows/file_properties.py @@ -98,6 +98,8 @@ def __init__(self, file): self.txtTags.setText(tags) self.txtFilePath.setText(os.path.join(path, filename)) + self.btnBrowse.clicked.connect(self.browsePath) + # Populate video fields self.txtWidth.setValue(self.file.data["width"]) self.txtHeight.setValue(self.file.data["height"]) @@ -172,11 +174,20 @@ def __init__(self, file): # Switch to 1st page self.toolBox.setCurrentIndex(0) + def browsePath(self): + starting_folder, filename = os.path.split(self.file.data["path"]) + newFilePath = QFileDialog.getOpenFileName(None,("Locate media file: %s" % filename), + starting_folder) + self.txtFilePath.setText(newFilePath[0]) + def accept(self): # Update file details self.file.data["name"] = self.txtFileName.text() self.file.data["tags"] = self.txtTags.text() + #experimental: update file path + self.file.data["path"] = self.txtFilePath.text() + # Update Framerate self.file.data["fps"]["num"] = self.txtFrameRateNum.value() self.file.data["fps"]["den"] = self.txtFrameRateDen.value() diff --git a/src/windows/main_window.py b/src/windows/main_window.py index 22a9aee28c..f8e0ddc1d2 100644 --- a/src/windows/main_window.py +++ b/src/windows/main_window.py @@ -365,6 +365,14 @@ def actionEditTitle_trigger(self, event): # Force update of files model (which will rebuild missing thumbnails) get_app().window.filesTreeView.refresh_view() + # force update of clips + + clips = Clip.filter(file_id=selected_file_id) + for c in clips: + # update clip + c.data["reader"]["path"] = file_path + c.save() + def actionDuplicateTitle_trigger(self, event): # Get selected svg title file @@ -1644,6 +1652,15 @@ def actionFile_Properties_trigger(self, event): # Run the dialog event loop - blocking interaction on this window during that time result = win.exec_() if result == QDialog.Accepted: + + # BRUTE FORCE approach: go through all clips and update file path + + clips = Clip.filter(file_id=file_id) + for c in clips: + # update clip + c.data["reader"]["path"] = f.data["path"] + c.save() + log.info('File Properties Finished') else: log.info('File Properties Cancelled') diff --git a/src/windows/ui/file-properties.ui b/src/windows/ui/file-properties.ui index 28400aeb8f..b56b48d866 100644 --- a/src/windows/ui/file-properties.ui +++ b/src/windows/ui/file-properties.ui @@ -107,7 +107,14 @@ true - true + false + + + + + + + Browse... @@ -115,10 +122,10 @@ - + - + @@ -910,6 +917,7 @@ +