From 0a4977a770ffbd9a4f86ea14d1638634899381e1 Mon Sep 17 00:00:00 2001 From: Markus Wang Halvorsen Date: Fri, 24 Mar 2023 01:47:17 +0100 Subject: [PATCH] enforce clip range on save --- footgas/footgas.py | 1 + footgas/widgets/footgas_options.py | 23 ++++++++++------------- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/footgas/footgas.py b/footgas/footgas.py index 7653221..9a55467 100644 --- a/footgas/footgas.py +++ b/footgas/footgas.py @@ -132,6 +132,7 @@ def _video_duration_changed(self, duration): def _save(self, filename: str): start, end = map(ftime, self.w_clip_range.value()) + self.w_clip_range.setEnabled(False) self.w_options.setEnabled(False) diff --git a/footgas/widgets/footgas_options.py b/footgas/widgets/footgas_options.py index 1329a98..6c24a4b 100644 --- a/footgas/widgets/footgas_options.py +++ b/footgas/widgets/footgas_options.py @@ -1,6 +1,6 @@ from PyQt6.QtCore import pyqtSignal from PyQt6.QtWidgets import (QComboBox, QFileDialog, QHBoxLayout, QVBoxLayout, QLabel, - QLineEdit, QPushButton, QWidget) + QLineEdit, QPushButton, QWidget, QMessageBox) from ..util import ftime, strtoms @@ -154,6 +154,15 @@ def _set_source(self): self.sourceSelected.emit(fn) def _save(self): + start, end = map(strtoms, (self.w_override_start.text(), self.w_override_end.text())) + if start >= end: + error_popup = QMessageBox() + error_popup.setWindowTitle('Error') + error_popup.setIcon(QMessageBox.Icon.Warning) + error_popup.setText('Clip cannot start before it ends!') + error_popup.exec() + return + out_fn, _ = QFileDialog.getSaveFileName( self, 'Select save destination', @@ -175,12 +184,6 @@ def _update_override_start(self, start): if start_ms is None: return - # don't allow the clip to start after it has ended - end_ms = strtoms(self.w_override_end.text()) - if start_ms > end_ms: - start_ms = end_ms - self.w_override_start.setText(ftime(start_ms)) - self.overrideStartChanged.emit(start_ms) def _update_override_end(self, end): @@ -193,12 +196,6 @@ def _update_override_end(self, end): if end_ms is None: return - # don't allow the clip to end before it has begun - start_ms = strtoms(self.w_override_start.text()) - if end_ms < start_ms: - end_ms = start_ms - self.w_override_end.setText(ftime(end_ms)) - self.overrideEndChanged.emit(end_ms) def _validate_max_file_size(self):