Small fixes. Added checks of start/end times.

This commit is contained in:
Tomas Groth 2014-04-07 23:08:48 +02:00
parent bc2d45fc30
commit aefef04d97
3 changed files with 43 additions and 18 deletions

View File

@ -219,11 +219,35 @@ class MediaClipSelectorForm(QtGui.QDialog, Ui_MediaClipSelector):
time = QtCore.QTime()
new_pos_time = time.addMSecs(vlc_ms_pos)
self.end_timeedit.setTime(new_pos_time)
# If start time is after end time, update end time.
# If start time is after end time, update start time.
start_time = self.start_timeedit.time()
if start_time > new_pos_time:
self.start_timeedit.setTime(new_pos_time)
@QtCore.pyqtSlot(QtCore.QTime)
def on_start_timeedit_timeChanged(self, new_time):
"""
Called when start_timeedit is changed manually
:param new_time: The new time
"""
# If start time is after end time, update end time.
end_time = self.end_timeedit.time()
if end_time < new_time:
self.end_timeedit.setTime(new_time)
@QtCore.pyqtSlot(QtCore.QTime)
def on_end_timeedit_timeChanged(self, new_time):
"""
Called when end_timeedit is changed manually
:param new_time: The new time
"""
# If start time is after end time, update start time.
start_time = self.start_timeedit.time()
if start_time > new_time:
self.start_timeedit.setTime(new_time)
@QtCore.pyqtSlot(bool)
def on_jump_end_pushbutton_clicked(self, clicked):
"""
@ -288,12 +312,15 @@ class MediaClipSelectorForm(QtGui.QDialog, Ui_MediaClipSelector):
# Enable subtitle track combobox is anything in it
if len(subtitles_tracks) > 0:
self.subtitle_tracks_combobox.setDisabled(False)
# First track is "deactivated", so set to next if it exists
if len(subtitles_tracks) > 1:
self.subtitle_tracks_combobox.setCurrentIndex(1)
self.vlc_media_player.audio_set_mute(False)
self.playback_length = self.vlc_media_player.get_length()
self.position_horizontalslider.setMaximum(self.playback_length)
# setup start and end time
rounded_vlc_ms_length = int(round(self.playback_length / 100.0) * 100.0)
time = QtCore.QTime()
playback_length_time = time.addMSecs(rounded_vlc_ms_length)
self.start_timeedit.setMaximumTime(playback_length_time)
self.end_timeedit.setMaximumTime(playback_length_time)
# If a title or audio track is available the player is enabled
if self.title_combo_box.count() > 0 or len(audio_tracks) > 0:
self.toggle_disable_player(False)

View File

@ -125,8 +125,8 @@ class MediaMediaItem(MediaManagerItem, RegistryProperties):
"""
Adds buttons to the start of the header bar.
"""
self.load_optical = self.toolbar.add_toolbar_action('load_optical', icon=OPTICAL_ICON, text='Load optical disc',
tooltip='Load optical disc', triggers=self.on_load_optical)
self.load_optical = self.toolbar.add_toolbar_action('load_optical', icon=OPTICAL_ICON, text='Load CD/DVD',
tooltip='Load CD/DVD', triggers=self.on_load_optical)
if not VLC_AVAILABLE:
self.load_optical.setDisabled(True)

View File

@ -137,7 +137,6 @@ class TestMediaClipSelectorForm(TestCase, TestMixin):
self.form.title_combo_box.insertItem(0, 'Test Title 0')
self.form.title_combo_box.insertItem(1, 'Test Title 1')
# WHEN: There exists audio and subtitle tracks and the index is updated.
self.form.vlc_media_player.audio_get_track_description.return_value = [(-1, b'Disabled'),
(0, b'Audio Track 1')]
@ -149,4 +148,3 @@ class TestMediaClipSelectorForm(TestCase, TestMixin):
self.form.audio_tracks_combobox.itemData.assert_any_call(0)
self.form.audio_tracks_combobox.itemData.assert_any_call(1)
self.form.subtitle_tracks_combobox.itemData.assert_any_call(0)