Open thp opened 1 year ago
For the loading part, it seems like it uses the file extension to distinguish between file types (vidcutter/vidcutter.py
):
project_type = info.suffix()
...
if project_type == 'vcp' and linenum == 1:
self.loadMedia(line)
...
One quick workaround would be to assume that an extension-less file is a .vcp
file:
diff --git a/vidcutter/videocutter.py b/vidcutter/videocutter.py
index 98e5553..7082f7c 100644
--- a/vidcutter/videocutter.py
+++ b/vidcutter/videocutter.py
@@ -832,7 +832,7 @@ class VideoCutter(QWidget):
self.lastFolder = QFileInfo(project_file).absolutePath()
file = QFile(project_file)
info = QFileInfo(file)
- project_type = info.suffix()
+ project_type = info.suffix() or 'vcp'
if not file.open(QFile.ReadOnly | QFile.Text):
QMessageBox.critical(self.parent, 'Open project file',
'Cannot read project file {0}:\n\n{1}'.format(project_file, file.errorString()))
However, this wouldn't work if the file name contains a "." (as then info.suffix()
would return some weird value).
Possibly better:
diff --git a/vidcutter/videocutter.py b/vidcutter/videocutter.py
index 98e5553..237f927 100644
--- a/vidcutter/videocutter.py
+++ b/vidcutter/videocutter.py
@@ -833,6 +833,9 @@ class VideoCutter(QWidget):
file = QFile(project_file)
info = QFileInfo(file)
project_type = info.suffix()
+ if project_type not in self.project_files:
+ # Assume .vcp file if the file extension is missing or invalid
+ project_type = 'vcp'
if not file.open(QFile.ReadOnly | QFile.Text):
QMessageBox.critical(self.parent, 'Open project file',
'Cannot read project file {0}:\n\n{1}'.format(project_file, file.errorString()))
For the saving part, seems like it should work with the filter alone, but it doesn't work for me (Flatpak/Linux).
A naive solution (which most likely has sandboxing restrictions) would be to just append the extension if it's missing:
diff --git a/vidcutter/videocutter.py b/vidcutter/videocutter.py
index 98e5553..46b13ba 100644
--- a/vidcutter/videocutter.py
+++ b/vidcutter/videocutter.py
@@ -934,6 +937,9 @@ class VideoCutter(QWidget):
filter=self.projectFilters(True),
initialFilter='VidCutter Project (*.vcp)',
options=self.getFileDialogOptions())
+ if ptype == 'VidCutter Project (*.vcp)' and not project_save.endswith('.vcp'):
+ # Add extension, will probably not work with sandboxing
+ project_save += '.vcp'
if project_save is not None and len(project_save.strip()):
file = QFile(project_save)
if not file.open(QFile.WriteOnly | QFile.Text):
According to this SO thread you might need to use setDefaultSuffix()
on a QFileDialog
you create yourself, sidestepping the QFileDialog.getSaveFileName()
static method.
When saving projects, the ".vcp" extension isn't added automatically. When loading projects, selecting a file without a ".vcp" extension does nothing.
Steps to reproduce:
Expected result:
Actual result:
VidCutter version: 6.0.5.1 Flatpak