Merged Raouls GUI changes

This commit is contained in:
Tomas Groth 2014-08-26 22:11:29 +01:00
commit 11a19fbd32
5 changed files with 239 additions and 230 deletions

View File

@ -30,179 +30,179 @@
from PyQt4 import QtCore, QtGui
from openlp.core.common import translate
from openlp.core.lib import build_icon
class Ui_MediaClipSelector(object):
def setupUi(self, MediaClipSelector):
MediaClipSelector.setObjectName("MediaClipSelector")
MediaClipSelector.resize(683, 739)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.MinimumExpanding, QtGui.QSizePolicy.MinimumExpanding)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(MediaClipSelector.sizePolicy().hasHeightForWidth())
MediaClipSelector.setSizePolicy(sizePolicy)
MediaClipSelector.setMinimumSize(QtCore.QSize(683, 686))
MediaClipSelector.setFocusPolicy(QtCore.Qt.NoFocus)
MediaClipSelector.setAutoFillBackground(False)
MediaClipSelector.setInputMethodHints(QtCore.Qt.ImhNone)
self.centralwidget = QtGui.QWidget(MediaClipSelector)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.MinimumExpanding, QtGui.QSizePolicy.MinimumExpanding)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.centralwidget.sizePolicy().hasHeightForWidth())
self.centralwidget.setSizePolicy(sizePolicy)
self.centralwidget.setObjectName("centralwidget")
self.gridLayout = QtGui.QGridLayout(self.centralwidget)
self.gridLayout.setObjectName("gridLayout")
self.media_path_combobox = QtGui.QComboBox(self.centralwidget)
self.media_path_combobox.setEnabled(True)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.media_path_combobox.sizePolicy().hasHeightForWidth())
self.media_path_combobox.setSizePolicy(sizePolicy)
def setupUi(self, media_clip_selector):
media_clip_selector.setObjectName('media_clip_selector')
media_clip_selector.resize(554, 654)
self.combobox_size_policy = QtGui.QSizePolicy(QtGui.QSizePolicy.MinimumExpanding, QtGui.QSizePolicy.Fixed)
media_clip_selector.setSizePolicy(
QtGui.QSizePolicy(QtGui.QSizePolicy.MinimumExpanding, QtGui.QSizePolicy.MinimumExpanding))
self.main_layout = QtGui.QVBoxLayout(media_clip_selector)
self.main_layout.setContentsMargins(8, 8, 8, 8)
self.main_layout.setObjectName('main_layout')
# Source groupbox
self.source_groupbox = QtGui.QGroupBox(media_clip_selector)
self.source_groupbox.setObjectName('source_groupbox')
self.source_layout = QtGui.QHBoxLayout()
self.source_layout.setContentsMargins(8, 8, 8, 8)
self.source_layout.setObjectName('source_layout')
self.source_groupbox.setLayout(self.source_layout)
# Media path label
self.media_path_label = QtGui.QLabel(self.source_groupbox)
self.media_path_label.setObjectName('media_path_label')
self.source_layout.addWidget(self.media_path_label)
# Media path combobox
self.media_path_combobox = QtGui.QComboBox(self.source_groupbox)
# Make the combobox expand
self.media_path_combobox.setSizePolicy(self.combobox_size_policy)
self.media_path_combobox.setEditable(True)
self.media_path_combobox.setObjectName("media_path_combobox")
self.gridLayout.addWidget(self.media_path_combobox, 0, 2, 1, 2)
self.start_timeedit = QtGui.QTimeEdit(self.centralwidget)
self.start_timeedit.setEnabled(True)
self.start_timeedit.setObjectName("start_timeedit")
self.gridLayout.addWidget(self.start_timeedit, 7, 2, 1, 1)
self.end_timeedit = QtGui.QTimeEdit(self.centralwidget)
self.end_timeedit.setEnabled(True)
self.end_timeedit.setObjectName("end_timeedit")
self.gridLayout.addWidget(self.end_timeedit, 8, 2, 1, 1)
self.set_start_pushbutton = QtGui.QPushButton(self.centralwidget)
self.set_start_pushbutton.setEnabled(True)
self.set_start_pushbutton.setObjectName("set_start_pushbutton")
self.gridLayout.addWidget(self.set_start_pushbutton, 7, 3, 1, 1)
self.load_disc_pushbutton = QtGui.QPushButton(self.centralwidget)
self.load_disc_pushbutton.setEnabled(True)
self.load_disc_pushbutton.setObjectName("load_disc_pushbutton")
self.gridLayout.addWidget(self.load_disc_pushbutton, 0, 4, 1, 1)
spacerItem = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Minimum)
self.gridLayout.addItem(spacerItem, 9, 3, 1, 1)
self.play_pushbutton = QtGui.QPushButton(self.centralwidget)
self.play_pushbutton.setEnabled(True)
self.play_pushbutton.setText("")
icon = QtGui.QIcon()
icon.addPixmap(QtGui.QPixmap(":/slides/media_playback_start.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.play_pushbutton.setIcon(icon)
self.play_pushbutton.setObjectName("play_pushbutton")
self.gridLayout.addWidget(self.play_pushbutton, 6, 0, 1, 1)
self.end_point_label = QtGui.QLabel(self.centralwidget)
self.end_point_label.setEnabled(True)
self.end_point_label.setObjectName("end_point_label")
self.gridLayout.addWidget(self.end_point_label, 8, 0, 1, 1)
self.subtitle_tracks_combobox = QtGui.QComboBox(self.centralwidget)
self.subtitle_tracks_combobox.setEnabled(True)
self.subtitle_tracks_combobox.setObjectName("subtitle_tracks_combobox")
self.gridLayout.addWidget(self.subtitle_tracks_combobox, 4, 2, 1, 2)
self.title_label = QtGui.QLabel(self.centralwidget)
self.title_label.setEnabled(True)
self.title_label.setObjectName("title_label")
self.gridLayout.addWidget(self.title_label, 2, 0, 1, 1)
self.audio_tracks_combobox = QtGui.QComboBox(self.centralwidget)
self.audio_tracks_combobox.setEnabled(True)
self.audio_tracks_combobox.setObjectName("audio_tracks_combobox")
self.gridLayout.addWidget(self.audio_tracks_combobox, 3, 2, 1, 2)
self.set_end_pushbutton = QtGui.QPushButton(self.centralwidget)
self.set_end_pushbutton.setEnabled(True)
self.set_end_pushbutton.setObjectName("set_end_pushbutton")
self.gridLayout.addWidget(self.set_end_pushbutton, 8, 3, 1, 1)
self.save_pushbutton = QtGui.QPushButton(self.centralwidget)
self.save_pushbutton.setEnabled(True)
self.save_pushbutton.setObjectName("save_pushbutton")
self.gridLayout.addWidget(self.save_pushbutton, 10, 3, 1, 1)
self.close_pushbutton = QtGui.QPushButton(self.centralwidget)
self.close_pushbutton.setEnabled(True)
self.close_pushbutton.setObjectName("close_pushbutton")
self.gridLayout.addWidget(self.close_pushbutton, 10, 4, 1, 1)
self.start_point_label = QtGui.QLabel(self.centralwidget)
self.start_point_label.setEnabled(True)
self.start_point_label.setObjectName("start_point_label")
self.gridLayout.addWidget(self.start_point_label, 7, 0, 1, 2)
self.jump_start_pushbutton = QtGui.QPushButton(self.centralwidget)
self.jump_start_pushbutton.setEnabled(True)
self.jump_start_pushbutton.setObjectName("jump_start_pushbutton")
self.gridLayout.addWidget(self.jump_start_pushbutton, 7, 4, 1, 1)
self.audio_track_label = QtGui.QLabel(self.centralwidget)
self.audio_track_label.setEnabled(True)
self.audio_track_label.setObjectName("audio_track_label")
self.gridLayout.addWidget(self.audio_track_label, 3, 0, 1, 2)
self.media_position_timeedit = QtGui.QTimeEdit(self.centralwidget)
self.media_position_timeedit.setEnabled(True)
self.media_position_timeedit.setReadOnly(True)
self.media_position_timeedit.setObjectName("media_position_timeedit")
self.gridLayout.addWidget(self.media_position_timeedit, 6, 4, 1, 1)
self.media_view_frame = QtGui.QFrame(self.centralwidget)
self.media_view_frame.setMinimumSize(QtCore.QSize(665, 375))
self.media_view_frame.setStyleSheet("background-color:black;")
self.media_view_frame.setFrameShape(QtGui.QFrame.StyledPanel)
self.media_view_frame.setFrameShadow(QtGui.QFrame.Raised)
self.media_view_frame.setObjectName("media_view_frame")
self.gridLayout.addWidget(self.media_view_frame, 5, 0, 1, 5)
self.subtitle_track_label = QtGui.QLabel(self.centralwidget)
self.subtitle_track_label.setEnabled(True)
self.subtitle_track_label.setObjectName("subtitle_track_label")
self.gridLayout.addWidget(self.subtitle_track_label, 4, 0, 1, 2)
self.jump_end_pushbutton = QtGui.QPushButton(self.centralwidget)
self.jump_end_pushbutton.setEnabled(True)
self.jump_end_pushbutton.setObjectName("jump_end_pushbutton")
self.gridLayout.addWidget(self.jump_end_pushbutton, 8, 4, 1, 1)
self.media_path_label = QtGui.QLabel(self.centralwidget)
self.media_path_label.setEnabled(True)
self.media_path_label.setObjectName("media_path_label")
self.gridLayout.addWidget(self.media_path_label, 0, 0, 1, 2)
self.title_combo_box = QtGui.QComboBox(self.centralwidget)
self.title_combo_box.setEnabled(True)
self.title_combo_box.setProperty("currentText", "")
self.title_combo_box.setObjectName("title_combo_box")
self.gridLayout.addWidget(self.title_combo_box, 2, 2, 1, 2)
self.position_horizontalslider = QtGui.QSlider(self.centralwidget)
self.position_horizontalslider.setEnabled(True)
self.position_horizontalslider.setTracking(False)
self.position_horizontalslider.setOrientation(QtCore.Qt.Horizontal)
self.position_horizontalslider.setInvertedAppearance(False)
self.position_horizontalslider.setObjectName("position_horizontalslider")
self.gridLayout.addWidget(self.position_horizontalslider, 6, 1, 1, 3)
self.retranslateUi(MediaClipSelector)
QtCore.QMetaObject.connectSlotsByName(MediaClipSelector)
MediaClipSelector.setTabOrder(self.media_path_combobox, self.load_disc_pushbutton)
MediaClipSelector.setTabOrder(self.load_disc_pushbutton, self.title_combo_box)
MediaClipSelector.setTabOrder(self.title_combo_box, self.audio_tracks_combobox)
MediaClipSelector.setTabOrder(self.audio_tracks_combobox, self.subtitle_tracks_combobox)
MediaClipSelector.setTabOrder(self.subtitle_tracks_combobox, self.play_pushbutton)
MediaClipSelector.setTabOrder(self.play_pushbutton, self.position_horizontalslider)
MediaClipSelector.setTabOrder(self.position_horizontalslider, self.media_position_timeedit)
MediaClipSelector.setTabOrder(self.media_position_timeedit, self.start_timeedit)
MediaClipSelector.setTabOrder(self.start_timeedit, self.set_start_pushbutton)
MediaClipSelector.setTabOrder(self.set_start_pushbutton, self.jump_start_pushbutton)
MediaClipSelector.setTabOrder(self.jump_start_pushbutton, self.end_timeedit)
MediaClipSelector.setTabOrder(self.end_timeedit, self.set_end_pushbutton)
MediaClipSelector.setTabOrder(self.set_end_pushbutton, self.jump_end_pushbutton)
MediaClipSelector.setTabOrder(self.jump_end_pushbutton, self.save_pushbutton)
MediaClipSelector.setTabOrder(self.save_pushbutton, self.close_pushbutton)
self.media_path_combobox.setObjectName('media_path_combobox')
self.source_layout.addWidget(self.media_path_combobox)
# Load disc button
self.load_disc_button = QtGui.QPushButton(media_clip_selector)
self.load_disc_button.setEnabled(True)
self.load_disc_button.setObjectName('load_disc_button')
self.source_layout.addWidget(self.load_disc_button)
self.main_layout.addWidget(self.source_groupbox)
# Track details group box
self.track_groupbox = QtGui.QGroupBox(media_clip_selector)
self.track_groupbox.setObjectName('track_groupbox')
self.track_layout = QtGui.QFormLayout()
self.track_layout.setContentsMargins(8, 8, 8, 8)
self.track_layout.setObjectName('track_layout')
self.label_alignment = self.track_layout.labelAlignment()
self.track_groupbox.setLayout(self.track_layout)
# Title track
self.title_label = QtGui.QLabel(self.track_groupbox)
self.title_label.setObjectName('title_label')
self.titles_combo_box = QtGui.QComboBox(self.track_groupbox)
self.titles_combo_box.setSizePolicy(self.combobox_size_policy)
self.titles_combo_box.setEditText('')
self.titles_combo_box.setObjectName('titles_combo_box')
self.track_layout.addRow(self.title_label, self.titles_combo_box)
# Audio track
self.audio_track_label = QtGui.QLabel(self.track_groupbox)
self.audio_track_label.setObjectName('audio_track_label')
self.audio_tracks_combobox = QtGui.QComboBox(self.track_groupbox)
self.audio_tracks_combobox.setSizePolicy(self.combobox_size_policy)
self.audio_tracks_combobox.setObjectName('audio_tracks_combobox')
self.track_layout.addRow(self.audio_track_label, self.audio_tracks_combobox)
self.main_layout.addWidget(self.track_groupbox)
# Subtitle track
self.subtitle_track_label = QtGui.QLabel(self.track_groupbox)
self.subtitle_track_label.setObjectName('subtitle_track_label')
self.subtitle_tracks_combobox = QtGui.QComboBox(self.track_groupbox)
self.subtitle_tracks_combobox.setSizePolicy(self.combobox_size_policy)
self.subtitle_tracks_combobox.setObjectName('subtitle_tracks_combobox')
self.track_layout.addRow(self.subtitle_track_label, self.subtitle_tracks_combobox)
# Preview frame
self.preview_frame = QtGui.QFrame(media_clip_selector)
self.preview_frame.setMinimumSize(QtCore.QSize(320, 240))
self.preview_frame.setSizePolicy(QtGui.QSizePolicy(QtGui.QSizePolicy.MinimumExpanding, QtGui.QSizePolicy.MinimumExpanding))
self.preview_frame.setStyleSheet('background-color:black;')
self.preview_frame.setFrameShape(QtGui.QFrame.NoFrame)
self.preview_frame.setObjectName('preview_frame')
self.main_layout.addWidget(self.preview_frame)
# player controls
self.controls_layout = QtGui.QHBoxLayout()
self.controls_layout.setObjectName('controls_layout')
self.play_button = QtGui.QToolButton(media_clip_selector)
self.play_button.setIcon(build_icon(':/slides/media_playback_start.png'))
self.play_button.setObjectName('play_button')
self.controls_layout.addWidget(self.play_button)
self.position_slider = QtGui.QSlider(media_clip_selector)
self.position_slider.setTracking(False)
self.position_slider.setOrientation(QtCore.Qt.Horizontal)
self.position_slider.setObjectName('position_slider')
self.controls_layout.addWidget(self.position_slider)
self.position_timeedit = QtGui.QTimeEdit(media_clip_selector)
self.position_timeedit.setReadOnly(True)
self.position_timeedit.setObjectName('position_timeedit')
self.controls_layout.addWidget(self.position_timeedit)
self.main_layout.addLayout(self.controls_layout)
# Range
self.range_groupbox = QtGui.QGroupBox(media_clip_selector)
self.range_groupbox.setObjectName('range_groupbox')
self.range_layout = QtGui.QGridLayout()
self.range_layout.setContentsMargins(8, 8, 8, 8)
self.range_layout.setObjectName('range_layout')
self.range_groupbox.setLayout(self.range_layout)
# Start position
self.start_position_label = QtGui.QLabel(self.range_groupbox)
self.start_position_label.setObjectName('start_position_label')
self.range_layout.addWidget(self.start_position_label, 0, 0, self.label_alignment)
self.start_position_edit = QtGui.QTimeEdit(self.range_groupbox)
self.start_position_edit.setObjectName('start_position_edit')
self.range_layout.addWidget(self.start_position_edit, 0, 1)
self.set_start_button = QtGui.QPushButton(self.range_groupbox)
self.set_start_button.setObjectName('set_start_button')
self.range_layout.addWidget(self.set_start_button, 0, 2)
self.jump_start_button = QtGui.QPushButton(self.range_groupbox)
self.jump_start_button.setObjectName('jump_start_button')
self.range_layout.addWidget(self.jump_start_button, 0, 3)
# End position
self.end_position_label = QtGui.QLabel(self.range_groupbox)
self.end_position_label.setObjectName('end_position_label')
self.range_layout.addWidget(self.end_position_label, 1, 0, self.label_alignment)
self.end_timeedit = QtGui.QTimeEdit(self.range_groupbox)
self.end_timeedit.setObjectName('end_timeedit')
self.range_layout.addWidget(self.end_timeedit, 1, 1)
self.set_end_button = QtGui.QPushButton(self.range_groupbox)
self.set_end_button.setObjectName('set_end_button')
self.range_layout.addWidget(self.set_end_button, 1, 2)
self.jump_end_button = QtGui.QPushButton(self.range_groupbox)
self.jump_end_button.setObjectName('jump_end_button')
self.range_layout.addWidget(self.jump_end_button, 1, 3)
self.main_layout.addWidget(self.range_groupbox)
# Save and close buttons
self.button_box = QtGui.QDialogButtonBox(media_clip_selector)
self.button_box.addButton(QtGui.QDialogButtonBox.Save)
self.button_box.addButton(QtGui.QDialogButtonBox.Cancel)
self.close_button = self.button_box.button(QtGui.QDialogButtonBox.Cancel)
self.save_button = self.button_box.button(QtGui.QDialogButtonBox.Save)
self.main_layout.addWidget(self.button_box)
def retranslateUi(self, MediaClipSelector):
MediaClipSelector.setWindowTitle(translate("MediaPlugin.MediaClipSelector", "Select media clip", None))
self.start_timeedit.setDisplayFormat(translate("MediaPlugin.MediaClipSelector", "HH:mm:ss.z", None))
self.end_timeedit.setDisplayFormat(translate("MediaPlugin.MediaClipSelector", "HH:mm:ss.z", None))
self.set_start_pushbutton.setText(translate("MediaPlugin.MediaClipSelector",
"Set current position as start point", None))
self.load_disc_pushbutton.setText(translate("MediaPlugin.MediaClipSelector", "Load disc", None))
self.end_point_label.setText(translate("MediaPlugin.MediaClipSelector", "End point", None))
self.title_label.setText(translate("MediaPlugin.MediaClipSelector", "Title", None))
self.set_end_pushbutton.setText(translate("MediaPlugin.MediaClipSelector",
"Set current position as end point", None))
self.save_pushbutton.setText(translate("MediaPlugin.MediaClipSelector", "Save current clip", None))
self.close_pushbutton.setText(translate("MediaPlugin.MediaClipSelector", "Close", None))
self.start_point_label.setText(translate("MediaPlugin.MediaClipSelector", "Start point", None))
self.jump_start_pushbutton.setText(translate("MediaPlugin.MediaClipSelector", "Jump to start point", None))
self.audio_track_label.setText(translate("MediaPlugin.MediaClipSelector", "Audio track", None))
self.media_position_timeedit.setDisplayFormat(translate("MediaPlugin.MediaClipSelector", "HH:mm:ss.z", None))
self.subtitle_track_label.setText(translate("MediaPlugin.MediaClipSelector", "Subtitle track", None))
self.jump_end_pushbutton.setText(translate("MediaPlugin.MediaClipSelector", "Jump to end point", None))
self.media_path_label.setText(translate("MediaPlugin.MediaClipSelector", "Media path", None))
self.media_path_combobox.lineEdit().setPlaceholderText(translate("MediaPlugin.MediaClipSelector",
"Select drive from list", None))
self.retranslateUi(media_clip_selector)
self.button_box.accepted.connect(media_clip_selector.accept)
self.button_box.rejected.connect(media_clip_selector.reject)
QtCore.QMetaObject.connectSlotsByName(media_clip_selector)
media_clip_selector.setTabOrder(self.media_path_combobox, self.load_disc_button)
media_clip_selector.setTabOrder(self.load_disc_button, self.titles_combo_box)
media_clip_selector.setTabOrder(self.titles_combo_box, self.audio_tracks_combobox)
media_clip_selector.setTabOrder(self.audio_tracks_combobox, self.subtitle_tracks_combobox)
media_clip_selector.setTabOrder(self.subtitle_tracks_combobox, self.play_button)
media_clip_selector.setTabOrder(self.play_button, self.position_slider)
media_clip_selector.setTabOrder(self.position_slider, self.position_timeedit)
media_clip_selector.setTabOrder(self.position_timeedit, self.start_position_edit)
media_clip_selector.setTabOrder(self.start_position_edit, self.set_start_button)
media_clip_selector.setTabOrder(self.set_start_button, self.jump_start_button)
media_clip_selector.setTabOrder(self.jump_start_button, self.end_timeedit)
media_clip_selector.setTabOrder(self.end_timeedit, self.set_end_button)
media_clip_selector.setTabOrder(self.set_end_button, self.jump_end_button)
media_clip_selector.setTabOrder(self.jump_end_button, self.save_button)
media_clip_selector.setTabOrder(self.save_button, self.close_button)
def retranslateUi(self, media_clip_selector):
media_clip_selector.setWindowTitle(translate('MediaPlugin.MediaClipSelector', 'Select Media Clip'))
self.source_groupbox.setTitle(translate('MediaPlugin.MediaClipSelector', 'Source'))
self.media_path_label.setText(translate('MediaPlugin.MediaClipSelector', 'Media path:'))
self.media_path_combobox.lineEdit().setPlaceholderText(translate('MediaPlugin.MediaClipSelector',
'Select drive from list'))
self.load_disc_button.setText(translate('MediaPlugin.MediaClipSelector', 'Load disc'))
self.track_groupbox.setTitle(translate('MediaPlugin.MediaClipSelector', 'Track Details'))
self.title_label.setText(translate('MediaPlugin.MediaClipSelector', 'Title:'))
self.audio_track_label.setText(translate('MediaPlugin.MediaClipSelector', 'Audio track:'))
self.subtitle_track_label.setText(translate('MediaPlugin.MediaClipSelector', 'Subtitle track:'))
self.position_timeedit.setDisplayFormat(translate('MediaPlugin.MediaClipSelector', 'HH:mm:ss.z'))
self.range_groupbox.setTitle(translate('MediaPlugin.MediaClipSelector', 'Clip Range'))
self.start_position_label.setText(translate('MediaPlugin.MediaClipSelector', 'Start point:'))
self.start_position_edit.setDisplayFormat(translate('MediaPlugin.MediaClipSelector', 'HH:mm:ss.z'))
self.set_start_button.setText(translate('MediaPlugin.MediaClipSelector', 'Set start point'))
self.jump_start_button.setText(translate('MediaPlugin.MediaClipSelector', 'Jump to start point'))
self.end_position_label.setText(translate('MediaPlugin.MediaClipSelector', 'End point:'))
self.end_timeedit.setDisplayFormat(translate('MediaPlugin.MediaClipSelector', 'HH:mm:ss.z'))
self.set_end_button.setText(translate('MediaPlugin.MediaClipSelector', 'Set end point'))
self.jump_end_button.setText(translate('MediaPlugin.MediaClipSelector', 'Jump to end point'))

View File

@ -72,10 +72,15 @@ class MediaClipSelectorForm(QtGui.QDialog, Ui_MediaClipSelector):
Constructor
"""
super(MediaClipSelectorForm, self).__init__(parent)
self.vlc_instance = None
self.vlc_media_player = None
self.vlc_media = None
self.timer = None
self.audio_cd_tracks = None
self.audio_cd = False
self.playback_length = 0
self.media_item = media_item
self.setupUi(self)
# most actions auto-connect due to the functions name, so only a few left to do
self.close_pushbutton.clicked.connect(self.reject)
# setup play/pause icon
self.play_icon = QtGui.QIcon()
self.play_icon.addPixmap(QtGui.QPixmap(":/slides/media_playback_start.png"), QtGui.QIcon.Normal,
@ -100,7 +105,7 @@ class MediaClipSelectorForm(QtGui.QDialog, Ui_MediaClipSelector):
if self.vlc_media:
self.vlc_media.release()
self.vlc_media = None
QtGui.QDialog.reject(self)
return QtGui.QDialog.reject(self)
def exec_(self):
"""
@ -115,16 +120,16 @@ class MediaClipSelectorForm(QtGui.QDialog, Ui_MediaClipSelector):
Reset the UI to default values
"""
self.playback_length = 0
self.position_horizontalslider.setMinimum(0)
self.position_slider.setMinimum(0)
self.disable_all()
self.toggle_disable_load_media(False)
self.subtitle_tracks_combobox.clear()
self.audio_tracks_combobox.clear()
self.title_combo_box.clear()
self.titles_combo_box.clear()
time = QtCore.QTime()
self.start_timeedit.setTime(time)
self.start_position_edit.setTime(time)
self.end_timeedit.setTime(time)
self.media_position_timeedit.setTime(time)
self.position_timeedit.setTime(time)
def setup_vlc(self):
"""
@ -138,7 +143,7 @@ class MediaClipSelectorForm(QtGui.QDialog, Ui_MediaClipSelector):
# This is platform specific!
# You have to give the id of the QFrame (or similar object)
# to vlc, different platforms have different functions for this.
win_id = int(self.media_view_frame.winId())
win_id = int(self.preview_frame.winId())
if sys.platform == "win32":
self.vlc_media_player.set_hwnd(win_id)
elif sys.platform == "darwin":
@ -175,16 +180,16 @@ class MediaClipSelectorForm(QtGui.QDialog, Ui_MediaClipSelector):
self.audio_cd_tracks = self.vlc_media.subitems()
if not self.audio_cd_tracks or self.audio_cd_tracks.count() < 1:
return False
# Insert into title_combo_box
self.title_combo_box.clear()
# Insert into titles_combo_box
self.titles_combo_box.clear()
for i in range(self.audio_cd_tracks.count()):
item = self.audio_cd_tracks.item_at_index(i)
item_title = item.get_meta(vlc.Meta.Title)
self.title_combo_box.addItem(item_title, i)
self.titles_combo_box.addItem(item_title, i)
self.vlc_media_player.set_media(self.audio_cd_tracks.item_at_index(0))
self.audio_cd = True
self.title_combo_box.setDisabled(False)
self.title_combo_box.setCurrentIndex(0)
self.titles_combo_box.setDisabled(False)
self.titles_combo_box.setCurrentIndex(0)
self.on_title_combo_box_currentIndexChanged(0)
return True
@ -248,19 +253,19 @@ class MediaClipSelectorForm(QtGui.QDialog, Ui_MediaClipSelector):
if not self.audio_cd:
# Get titles, insert in combobox
titles = self.vlc_media_player.video_get_title_description()
self.title_combo_box.clear()
self.titles_combo_box.clear()
for title in titles:
self.title_combo_box.addItem(title[1].decode(), title[0])
self.titles_combo_box.addItem(title[1].decode(), title[0])
# Main title is usually title #1
if len(titles) > 1:
self.title_combo_box.setCurrentIndex(1)
self.titles_combo_box.setCurrentIndex(1)
else:
self.title_combo_box.setCurrentIndex(0)
self.titles_combo_box.setCurrentIndex(0)
# Enable audio track combobox if anything is in it
if len(titles) > 0:
self.title_combo_box.setDisabled(False)
self.titles_combo_box.setDisabled(False)
self.toggle_disable_load_media(False)
log.debug('load_disc_pushbutton end - vlc_media_player state: %s' % self.vlc_media_player.get_state())
log.debug('load_disc_button end - vlc_media_player state: %s' % self.vlc_media_player.get_state())
@QtCore.pyqtSlot(bool)
def on_play_pushbutton_clicked(self, clicked):
@ -271,23 +276,23 @@ class MediaClipSelectorForm(QtGui.QDialog, Ui_MediaClipSelector):
"""
if self.vlc_media_player.get_state() == vlc.State.Playing:
self.vlc_media_player.pause()
self.play_pushbutton.setIcon(self.play_icon)
self.play_button.setIcon(self.play_icon)
else:
self.vlc_media_player.play()
self.media_state_wait(vlc.State.Playing)
self.play_pushbutton.setIcon(self.pause_icon)
self.play_button.setIcon(self.pause_icon)
@QtCore.pyqtSlot(bool)
def on_set_start_pushbutton_clicked(self, clicked):
"""
Copy the current player position to start_timeedit
Copy the current player position to start_position_edit
:param clicked: Given from signal, not used.
"""
vlc_ms_pos = self.vlc_media_player.get_time()
time = QtCore.QTime()
new_pos_time = time.addMSecs(vlc_ms_pos)
self.start_timeedit.setTime(new_pos_time)
self.start_position_edit.setTime(new_pos_time)
# If start time is after end time, update end time.
end_time = self.end_timeedit.time()
if end_time < new_pos_time:
@ -305,14 +310,14 @@ class MediaClipSelectorForm(QtGui.QDialog, Ui_MediaClipSelector):
new_pos_time = time.addMSecs(vlc_ms_pos)
self.end_timeedit.setTime(new_pos_time)
# If start time is after end time, update start time.
start_time = self.start_timeedit.time()
start_time = self.start_position_edit.time()
if start_time > new_pos_time:
self.start_timeedit.setTime(new_pos_time)
self.start_position_edit.setTime(new_pos_time)
@QtCore.pyqtSlot(QtCore.QTime)
def on_start_timeedit_timeChanged(self, new_time):
"""
Called when start_timeedit is changed manually
Called when start_position_edit is changed manually
:param new_time: The new time
"""
@ -329,9 +334,9 @@ class MediaClipSelectorForm(QtGui.QDialog, Ui_MediaClipSelector):
:param new_time: The new time
"""
# If start time is after end time, update start time.
start_time = self.start_timeedit.time()
start_time = self.start_position_edit.time()
if start_time > new_time:
self.start_timeedit.setTime(new_time)
self.start_position_edit.setTime(new_time)
@QtCore.pyqtSlot(bool)
def on_jump_end_pushbutton_clicked(self, clicked):
@ -350,11 +355,11 @@ class MediaClipSelectorForm(QtGui.QDialog, Ui_MediaClipSelector):
@QtCore.pyqtSlot(bool)
def on_jump_start_pushbutton_clicked(self, clicked):
"""
Set the player position to the position stored in start_timeedit
Set the player position to the position stored in start_position_edit
:param clicked: Given from signal, not used.
"""
start_time = self.start_timeedit.time()
start_time = self.start_position_edit.time()
start_time_ms = start_time.hour() * 60 * 60 * 1000 + \
start_time.minute() * 60 * 1000 + \
start_time.second() * 1000 + \
@ -421,17 +426,17 @@ class MediaClipSelectorForm(QtGui.QDialog, Ui_MediaClipSelector):
self.vlc_media_player.audio_set_mute(False)
self.vlc_media_player.set_pause(1)
# If a title or audio track is available the player is enabled
if self.title_combo_box.count() > 0 or len(audio_tracks) > 0:
if self.titles_combo_box.count() > 0 or len(audio_tracks) > 0:
self.toggle_disable_player(False)
# Set media length info
self.playback_length = self.vlc_media_player.get_length()
log.debug('playback_length: %d ms' % self.playback_length)
self.position_horizontalslider.setMaximum(self.playback_length)
self.position_slider.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.start_position_edit.setMaximumTime(playback_length_time)
self.end_timeedit.setMaximumTime(playback_length_time)
self.end_timeedit.setTime(playback_length_time)
# Pause once again, just to make sure
@ -440,7 +445,7 @@ class MediaClipSelectorForm(QtGui.QDialog, Ui_MediaClipSelector):
sleep(0.1)
self.vlc_media_player.set_pause(1)
loop_count += 1
log.debug('title_combo_box end - vlc_media_player state: %s' % self.vlc_media_player.get_state())
log.debug('titles_combo_box end - vlc_media_player state: %s' % self.vlc_media_player.get_state())
@QtCore.pyqtSlot(int)
def on_audio_tracks_combobox_currentIndexChanged(self, index):
@ -486,15 +491,15 @@ class MediaClipSelectorForm(QtGui.QDialog, Ui_MediaClipSelector):
rounded_vlc_ms_pos = int(round(vlc_ms_pos / 100.0) * 100.0)
time = QtCore.QTime()
new_pos_time = time.addMSecs(rounded_vlc_ms_pos)
self.media_position_timeedit.setTime(new_pos_time)
self.position_horizontalslider.setSliderPosition(vlc_ms_pos)
self.position_timeedit.setTime(new_pos_time)
self.position_slider.setSliderPosition(vlc_ms_pos)
def disable_all(self):
"""
Disable all elements in the dialog
"""
self.toggle_disable_load_media(True)
self.title_combo_box.setDisabled(True)
self.titles_combo_box.setDisabled(True)
self.audio_tracks_combobox.setDisabled(True)
self.subtitle_tracks_combobox.setDisabled(True)
self.toggle_disable_player(True)
@ -506,7 +511,7 @@ class MediaClipSelectorForm(QtGui.QDialog, Ui_MediaClipSelector):
:param action: If True elements are disabled, if False they are enabled.
"""
self.media_path_combobox.setDisabled(action)
self.load_disc_pushbutton.setDisabled(action)
self.load_disc_button.setDisabled(action)
def toggle_disable_player(self, action):
"""
@ -514,16 +519,16 @@ class MediaClipSelectorForm(QtGui.QDialog, Ui_MediaClipSelector):
:param action: If True elements are disabled, if False they are enabled.
"""
self.play_pushbutton.setDisabled(action)
self.position_horizontalslider.setDisabled(action)
self.media_position_timeedit.setDisabled(action)
self.start_timeedit.setDisabled(action)
self.set_start_pushbutton.setDisabled(action)
self.jump_start_pushbutton.setDisabled(action)
self.play_button.setDisabled(action)
self.position_slider.setDisabled(action)
self.position_timeedit.setDisabled(action)
self.start_position_edit.setDisabled(action)
self.set_start_button.setDisabled(action)
self.jump_start_button.setDisabled(action)
self.end_timeedit.setDisabled(action)
self.set_end_pushbutton.setDisabled(action)
self.jump_end_pushbutton.setDisabled(action)
self.save_pushbutton.setDisabled(action)
self.set_end_button.setDisabled(action)
self.jump_end_button.setDisabled(action)
self.save_button.setDisabled(action)
@QtCore.pyqtSlot(bool)
def on_save_pushbutton_clicked(self, clicked):
@ -533,7 +538,7 @@ class MediaClipSelectorForm(QtGui.QDialog, Ui_MediaClipSelector):
:param clicked: Given from signal, not used.
"""
log.debug('in on_save_pushbutton_clicked')
start_time = self.start_timeedit.time()
start_time = self.start_position_edit.time()
start_time_ms = start_time.hour() * 60 * 60 * 1000 + \
start_time.minute() * 60 * 1000 + \
start_time.second() * 1000 + \
@ -543,7 +548,7 @@ class MediaClipSelectorForm(QtGui.QDialog, Ui_MediaClipSelector):
end_time.minute() * 60 * 1000 + \
end_time.second() * 1000 + \
end_time.msec()
title = self.title_combo_box.itemData(self.title_combo_box.currentIndex())
title = self.titles_combo_box.itemData(self.titles_combo_box.currentIndex())
path = self.media_path_combobox.currentText()
optical = ''
if self.audio_cd:

View File

@ -287,8 +287,6 @@ class MediaMediaItem(MediaManagerItem, RegistryProperties):
check_directory_exists(self.service_path)
self.load_list(Settings().value(self.settings_section + '/media files'))
self.rebuild_players()
if VLC_AVAILABLE:
self.media_clip_selector_form = MediaClipSelectorForm(self, self.main_window, None)
def rebuild_players(self):
"""
@ -415,7 +413,13 @@ class MediaMediaItem(MediaManagerItem, RegistryProperties):
"""
When the load optical button is clicked, open the clip selector window.
"""
self.media_clip_selector_form.exec_()
# self.media_clip_selector_form.exec_()
if VLC_AVAILABLE:
media_clip_selector_form = MediaClipSelectorForm(self, self.main_window, None)
media_clip_selector_form.exec_()
del media_clip_selector_form
else:
QtGui.QMessageBox.critical(self, 'VLC is not available', 'VLC is not available')
def add_optical_clip(self, optical):
"""

View File

@ -124,7 +124,7 @@ class SongExportForm(OpenLPWizard):
self.export_song_layout = QtGui.QHBoxLayout(self.export_song_page)
self.export_song_layout.setObjectName('export_song_layout')
self.grid_layout = QtGui.QGridLayout()
self.grid_layout.setObjectName('grid_layout')
self.grid_layout.setObjectName('range_layout')
self.selected_list_widget = QtGui.QListWidget(self.export_song_page)
self.selected_list_widget.setObjectName('selected_list_widget')
self.grid_layout.addWidget(self.selected_list_widget, 1, 0, 1, 1)

View File

@ -100,7 +100,7 @@ class TestMediaClipSelectorForm(TestCase, TestMixin):
self.form.exec_()
# WHEN: The load button is clicked with no path set
QtTest.QTest.mouseClick(self.form.load_disc_pushbutton, QtCore.Qt.LeftButton)
QtTest.QTest.mouseClick(self.form.load_disc_button, QtCore.Qt.LeftButton)
# THEN: we should get an error
mocked_critical_error_message_box.assert_called_with(message='No path was given')
@ -109,7 +109,7 @@ class TestMediaClipSelectorForm(TestCase, TestMixin):
mocked_os_path_exists.return_value = False
self.form.media_path_combobox.insertItem(0, '/non-existing/test-path.test')
self.form.media_path_combobox.setCurrentIndex(0)
QtTest.QTest.mouseClick(self.form.load_disc_pushbutton, QtCore.Qt.LeftButton)
QtTest.QTest.mouseClick(self.form.load_disc_button, QtCore.Qt.LeftButton)
# THEN: we should get an error
assert self.form.media_path_combobox.currentText() == '/non-existing/test-path.test',\
@ -122,7 +122,7 @@ class TestMediaClipSelectorForm(TestCase, TestMixin):
self.form.vlc_media_player.play.return_value = -1
self.form.media_path_combobox.insertItem(0, '/existing/test-path.test')
self.form.media_path_combobox.setCurrentIndex(0)
QtTest.QTest.mouseClick(self.form.load_disc_pushbutton, QtCore.Qt.LeftButton)
QtTest.QTest.mouseClick(self.form.load_disc_button, QtCore.Qt.LeftButton)
# THEN: we should get an error
assert self.form.media_path_combobox.currentText() == '/existing/test-path.test',\
@ -141,15 +141,15 @@ class TestMediaClipSelectorForm(TestCase, TestMixin):
self.form.subtitle_tracks_combobox.itemData = MagicMock()
self.form.audio_tracks_combobox.itemData.return_value = None
self.form.subtitle_tracks_combobox.itemData.return_value = None
self.form.title_combo_box.insertItem(0, 'Test Title 0')
self.form.title_combo_box.insertItem(1, 'Test Title 1')
self.form.titles_combo_box.insertItem(0, 'Test Title 0')
self.form.titles_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')]
self.form.vlc_media_player.video_get_spu_description.return_value = [(-1, b'Disabled'),
(0, b'Subtitle Track 1')]
self.form.title_combo_box.setCurrentIndex(1)
self.form.titles_combo_box.setCurrentIndex(1)
# THEN: The subtitle and audio track comboboxes should be updated and get signals and call itemData.
self.form.audio_tracks_combobox.itemData.assert_any_call(0)