forked from openlp/openlp
Add settings tab
This commit is contained in:
parent
77f84e2b95
commit
5c9e47d977
@ -178,6 +178,7 @@ class Settings(QtCore.QSettings):
|
||||
'core/application version': '0.0',
|
||||
'images/background color': '#000000',
|
||||
'media/media auto start': QtCore.Qt.Unchecked,
|
||||
'media/stream command': '',
|
||||
'remotes/download version': '0.0',
|
||||
'players/background color': '#000000',
|
||||
'servicemanager/last directory': None,
|
||||
|
@ -26,15 +26,14 @@ import platform
|
||||
|
||||
from PyQt5 import QtCore, QtWidgets
|
||||
|
||||
from openlp.core.common import is_linux, is_win
|
||||
from openlp.core.common.i18n import UiStrings, translate
|
||||
from openlp.core.common.registry import Registry
|
||||
from openlp.core.common.settings import Settings
|
||||
from openlp.core.lib.settingstab import SettingsTab
|
||||
from openlp.core.lib.ui import create_button
|
||||
from openlp.core.ui.icons import UiIcons
|
||||
from openlp.core.widgets.buttons import ColorButton
|
||||
|
||||
LINUX_STREAM = 'v4l2:// :v4l-vdev="/dev/video0"'
|
||||
LINUX_STREAM = 'v4l2:///dev/video0'
|
||||
WIN_STREAM = 'dshow:// :dshow-vdev='
|
||||
|
||||
|
||||
@ -60,171 +59,48 @@ class MediaTab(SettingsTab):
|
||||
super(MediaTab, self).setupUi()
|
||||
self.live_media_group_box = QtWidgets.QGroupBox(self.left_column)
|
||||
self.live_media_group_box.setObjectName('live_media_group_box')
|
||||
|
||||
self.media_layout = QtWidgets.QVBoxLayout(self.live_media_group_box)
|
||||
self.media_layout.setObjectName('live_media_layout')
|
||||
|
||||
self.auto_start_check_box = QtWidgets.QCheckBox(self.live_media_group_box)
|
||||
self.auto_start_check_box.setObjectName('auto_start_check_box')
|
||||
self.media_layout.addWidget(self.auto_start_check_box)
|
||||
|
||||
self.left_layout.addWidget(self.live_media_group_box)
|
||||
|
||||
self.stream_media_group_box = QtWidgets.QGroupBox(self.left_column)
|
||||
self.stream_media_group_box.setObjectName('stream_media_group_box')
|
||||
|
||||
self.stream_edit_field = QtWidgets.QLineEdit(self.stream_media_group_box)
|
||||
self.stream_edit_field.setObjectName('stream_edit_field')
|
||||
self.media_layout.addWidget(self.stream_edit_field)
|
||||
|
||||
self.media_layout.addWidget(self.stream_media_group_box)
|
||||
self.media_layout = QtWidgets.QVBoxLayout(self.stream_media_group_box)
|
||||
self.media_layout.setObjectName('media_layout')
|
||||
self.stream_media_layout = QtWidgets.QHBoxLayout(self.stream_media_group_box)
|
||||
self.stream_media_layout.setObjectName('live_media_layout')
|
||||
self.stream_media_layout.setContentsMargins(0, 0, 0, 0)
|
||||
self.stream_edit = QtWidgets.QPlainTextEdit(self)
|
||||
self.stream_media_layout.addWidget(self.stream_edit)
|
||||
self.browse_button = QtWidgets.QToolButton(self)
|
||||
self.browse_button.setIcon(UiIcons().undo)
|
||||
self.stream_media_layout.addWidget(self.browse_button)
|
||||
self.left_layout.addWidget(self.stream_media_group_box)
|
||||
self.left_layout.addWidget(self.stream_media_group_box)
|
||||
|
||||
self.left_layout.addStretch()
|
||||
self.right_layout.addStretch()
|
||||
# self.background_color_group_box = QtWidgets.QGroupBox(self.left_column)
|
||||
# self.background_color_group_box.setObjectName('background_color_group_box')
|
||||
# self.form_layout = QtWidgets.QFormLayout(self.background_color_group_box)
|
||||
# self.form_layout.setObjectName('form_layout')
|
||||
# self.color_layout = QtWidgets.QHBoxLayout()
|
||||
# self.background_color_label = QtWidgets.QLabel(self.background_color_group_box)
|
||||
# self.background_color_label.setObjectName('background_color_label')
|
||||
# self.color_layout.addWidget(self.background_color_label)
|
||||
# self.background_color_button = ColorButton(self.background_color_group_box)
|
||||
# self.background_color_button.setObjectName('background_color_button')
|
||||
# self.color_layout.addWidget(self.background_color_button)
|
||||
# self.form_layout.addRow(self.color_layout)
|
||||
# self.information_label = QtWidgets.QLabel(self.background_color_group_box)
|
||||
# self.information_label.setObjectName('information_label')
|
||||
# self.information_label.setWordWrap(True)
|
||||
# self.form_layout.addRow(self.information_label)
|
||||
# self.left_layout.addWidget(self.background_color_group_box)
|
||||
# self.right_column.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Preferred)
|
||||
# self.media_player_group_box = QtWidgets.QGroupBox(self.left_column)
|
||||
# self.media_player_group_box.setObjectName('media_player_group_box')
|
||||
# self.media_player_layout = QtWidgets.QVBoxLayout(self.media_player_group_box)
|
||||
# self.media_player_layout.setObjectName('media_player_layout')
|
||||
# self.player_check_boxes = {}
|
||||
# self.left_layout.addWidget(self.media_player_group_box)
|
||||
# self.player_order_group_box = QtWidgets.QGroupBox(self.left_column)
|
||||
# self.player_order_group_box.setObjectName('player_order_group_box')
|
||||
# self.player_order_layout = QtWidgets.QHBoxLayout(self.player_order_group_box)
|
||||
# self.player_order_layout.setObjectName('player_order_layout')
|
||||
# self.player_order_list_widget = QtWidgets.QListWidget(self.player_order_group_box)
|
||||
# size_policy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
|
||||
# size_policy.setHorizontalStretch(0)
|
||||
# size_policy.setVerticalStretch(0)
|
||||
# size_policy.setHeightForWidth(self.player_order_list_widget.sizePolicy().hasHeightForWidth())
|
||||
# self.player_order_list_widget.setSizePolicy(size_policy)
|
||||
# self.player_order_list_widget.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded)
|
||||
# self.player_order_list_widget.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
|
||||
# self.player_order_list_widget.setEditTriggers(QtWidgets.QAbstractItemView.NoEditTriggers)
|
||||
# self.player_order_list_widget.setObjectName('player_order_list_widget')
|
||||
# self.player_order_layout.addWidget(self.player_order_list_widget)
|
||||
# self.ordering_button_layout = QtWidgets.QVBoxLayout()
|
||||
# self.ordering_button_layout.setObjectName('ordering_button_layout')
|
||||
# self.ordering_button_layout.addStretch(1)
|
||||
# self.ordering_up_button = create_button(self, 'ordering_up_button', role='up',
|
||||
# click=self.on_up_button_clicked)
|
||||
# self.ordering_down_button = create_button(self, 'ordering_down_button', role='down',
|
||||
# click=self.on_down_button_clicked)
|
||||
# self.ordering_button_layout.addWidget(self.ordering_up_button)
|
||||
# self.ordering_button_layout.addWidget(self.ordering_down_button)
|
||||
# self.ordering_button_layout.addStretch(1)
|
||||
# self.player_order_layout.addLayout(self.ordering_button_layout)
|
||||
# self.left_layout.addWidget(self.player_order_group_box)
|
||||
self.left_layout.addStretch()
|
||||
self.right_layout.addStretch()
|
||||
# # Signals and slots
|
||||
# self.background_color_button.colorChanged.connect(self.on_background_color_changed)
|
||||
self.browse_button.clicked.connect(self.on_revert)
|
||||
|
||||
def retranslateUi(self):
|
||||
"""
|
||||
Translate the UI on the fly
|
||||
"""
|
||||
self.live_media_group_box.setTitle(translate('MediaPlugin.MediaTab', 'Live Media'))
|
||||
self.stream_media_group_box.setTitle(translate('MediaPlugin.MediaTab', 'Stream Media'))
|
||||
self.stream_media_group_box.setTitle(translate('MediaPlugin.MediaTab', 'Stream Media Command'))
|
||||
self.auto_start_check_box.setText(translate('MediaPlugin.MediaTab', 'Start automatically'))
|
||||
|
||||
def on_background_color_changed(self, color):
|
||||
"""
|
||||
Set the background color
|
||||
|
||||
:param color: The color to be set.
|
||||
"""
|
||||
self.background_color = color
|
||||
|
||||
def on_player_check_box_changed(self, check_state):
|
||||
"""
|
||||
Add or remove players depending on their status
|
||||
|
||||
:param check_state: The requested status.
|
||||
"""
|
||||
player = self.sender().player_name
|
||||
if check_state == QtCore.Qt.Checked:
|
||||
if player not in self.used_players:
|
||||
self.used_players.append(player)
|
||||
else:
|
||||
if player in self.used_players:
|
||||
self.used_players.remove(player)
|
||||
self.update_player_list()
|
||||
|
||||
def update_player_list(self):
|
||||
"""
|
||||
Update the list of media players
|
||||
"""
|
||||
self.player_order_list_widget.clear()
|
||||
for player in self.used_players:
|
||||
if player in list(self.player_check_boxes.keys()):
|
||||
if len(self.used_players) == 1:
|
||||
# At least one media player has to stay active
|
||||
self.player_check_boxes['%s' % player].setEnabled(False)
|
||||
else:
|
||||
self.player_check_boxes['%s' % player].setEnabled(True)
|
||||
self.player_order_list_widget.addItem(self.media_players[str(player)].original_name)
|
||||
|
||||
def on_up_button_clicked(self):
|
||||
"""
|
||||
Move a media player up in the order
|
||||
"""
|
||||
row = self.player_order_list_widget.currentRow()
|
||||
if row <= 0:
|
||||
return
|
||||
item = self.player_order_list_widget.takeItem(row)
|
||||
self.player_order_list_widget.insertItem(row - 1, item)
|
||||
self.player_order_list_widget.setCurrentRow(row - 1)
|
||||
self.used_players.insert(row - 1, self.used_players.pop(row))
|
||||
|
||||
def on_down_button_clicked(self):
|
||||
"""
|
||||
Move a media player down in the order
|
||||
"""
|
||||
row = self.player_order_list_widget.currentRow()
|
||||
if row == -1 or row > self.player_order_list_widget.count() - 1:
|
||||
return
|
||||
item = self.player_order_list_widget.takeItem(row)
|
||||
self.player_order_list_widget.insertItem(row + 1, item)
|
||||
self.player_order_list_widget.setCurrentRow(row + 1)
|
||||
self.used_players.insert(row + 1, self.used_players.pop(row))
|
||||
|
||||
def load(self):
|
||||
"""
|
||||
Load the settings
|
||||
"""
|
||||
self.auto_start_check_box.setChecked(Settings().value(self.settings_section + '/media auto start'))
|
||||
# if self.saved_used_players:
|
||||
# self.used_players = self.saved_used_players
|
||||
# # self.used_players = get_media_players()[0]
|
||||
# self.saved_used_players = self.used_players
|
||||
# settings = Settings()
|
||||
# settings.beginGroup(self.settings_section)
|
||||
# self.update_player_list()
|
||||
# self.background_color = settings.value('background color')
|
||||
# self.initial_color = self.background_color
|
||||
# settings.endGroup()
|
||||
# self.background_color_button.color = self.background_color
|
||||
self.stream_edit.setPlainText(Settings().value(self.settings_section + '/stream command'))
|
||||
if not self.stream_edit.toPlainText():
|
||||
if is_linux:
|
||||
self.stream_edit.setPlainText(LINUX_STREAM)
|
||||
elif is_win:
|
||||
self.stream_edit.setPlainText(WIN_STREAM)
|
||||
|
||||
def save(self):
|
||||
"""
|
||||
@ -268,3 +144,6 @@ class MediaTab(SettingsTab):
|
||||
# checkbox.setChecked(False)
|
||||
# self.update_player_list()
|
||||
# self.retranslate_players()
|
||||
|
||||
def on_revert(self):
|
||||
pass
|
||||
|
@ -224,7 +224,7 @@ class VlcPlayer(MediaPlayer):
|
||||
return False
|
||||
display.vlc_media = audio_cd_tracks.item_at_index(controller.media_info.title_track)
|
||||
elif controller.media_info.media_type == MediaType.Stream:
|
||||
display.vlc_media = display.vlc_instance.media_new_location("XXXXXXXXXXXXX")
|
||||
display.vlc_media = display.vlc_instance.media_new_location("ZZZZZZ")
|
||||
else:
|
||||
display.vlc_media = display.vlc_instance.media_new_path(path)
|
||||
# put the media in the media player
|
||||
|
Loading…
Reference in New Issue
Block a user