Skip to content

Commit

Permalink
Show all subtitles if no scenes are selected
Browse files Browse the repository at this point in the history
  • Loading branch information
machinewrapped committed Jun 14, 2023
1 parent aa1a773 commit 85ae456
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
10 changes: 10 additions & 0 deletions GUI/ProjectViewModel.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,16 @@ def GetLineItem(self, line_number, get_translated):
if line_item.number == line_number:
return line_item

def GetBatchNumbers(self):
"""
Get all batch numbers for the model
"""
batch_numbers = []
for scene_item in self.model.values():
for batch_item in scene_item.batches.values():
batch_numbers.append((batch_item.scene, batch_item.number))
return batch_numbers

def UpdateModel(self, update):
"""
Incrementally update the viewmodel
Expand Down
4 changes: 3 additions & 1 deletion GUI/Widgets/SubtitleListModel.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ def __init__(self, show_translated, viewmodel=None, parent=None):
def ShowSelection(self, selection : ProjectSelection):
if selection.selected_batches:
batch_numbers = [(batch.scene, batch.number) for batch in selection.selected_batches]
else:
elif selection.selected_scenes:
batch_numbers = selection.batch_numbers
else:
batch_numbers = self.viewmodel.GetBatchNumbers()

self.ShowSelectedBatches(batch_numbers)

Expand Down
1 change: 1 addition & 0 deletions GUI/Widgets/SubtitleView.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def __init__(self, show_translated, parent=None):
def SetViewModel(self, viewmodel : ProjectViewModel):
model = SubtitleListModel(self.show_translated, viewmodel)
self.setModel(model)
self.ShowSelection(ProjectSelection())

def ShowSelection(self, selection : ProjectSelection):
self.model().ShowSelection(selection)
Expand Down

0 comments on commit 85ae456

Please sign in to comment.