Skip to content

Commit

Permalink
enforce clip range on save
Browse files Browse the repository at this point in the history
  • Loading branch information
halworsen committed Mar 24, 2023
1 parent c9de6b8 commit 0a4977a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
1 change: 1 addition & 0 deletions footgas/footgas.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
23 changes: 10 additions & 13 deletions footgas/widgets/footgas_options.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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',
Expand All @@ -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):
Expand All @@ -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):
Expand Down

0 comments on commit 0a4977a

Please sign in to comment.