settings updates

This commit is contained in:
Tim Bentley 2019-01-20 09:29:47 +00:00
parent 59d61d6c9b
commit 8ed4216975
3 changed files with 131 additions and 120 deletions

View File

@ -54,8 +54,8 @@ class PlayerTab(SettingsTab):
""" """
Constructor Constructor
""" """
self.media_players = Registry().get('media_controller').media_players # self.media_players = Registry().get('media_controller').media_players
self.saved_used_players = None # self.saved_used_players = None
self.icon_path = UiIcons().player self.icon_path = UiIcons().player
player_translated = translate('OpenLP.PlayerTab', 'Players') player_translated = translate('OpenLP.PlayerTab', 'Players')
super(PlayerTab, self).__init__(parent, 'Players', player_translated) super(PlayerTab, self).__init__(parent, 'Players', player_translated)
@ -66,72 +66,72 @@ class PlayerTab(SettingsTab):
""" """
self.setObjectName('MediaTab') self.setObjectName('MediaTab')
super(PlayerTab, self).setupUi() super(PlayerTab, self).setupUi()
self.background_color_group_box = QtWidgets.QGroupBox(self.left_column) # self.background_color_group_box = QtWidgets.QGroupBox(self.left_column)
self.background_color_group_box.setObjectName('background_color_group_box') # self.background_color_group_box.setObjectName('background_color_group_box')
self.form_layout = QtWidgets.QFormLayout(self.background_color_group_box) # self.form_layout = QtWidgets.QFormLayout(self.background_color_group_box)
self.form_layout.setObjectName('form_layout') # self.form_layout.setObjectName('form_layout')
self.color_layout = QtWidgets.QHBoxLayout() # self.color_layout = QtWidgets.QHBoxLayout()
self.background_color_label = QtWidgets.QLabel(self.background_color_group_box) # self.background_color_label = QtWidgets.QLabel(self.background_color_group_box)
self.background_color_label.setObjectName('background_color_label') # self.background_color_label.setObjectName('background_color_label')
self.color_layout.addWidget(self.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 = ColorButton(self.background_color_group_box)
self.background_color_button.setObjectName('background_color_button') # self.background_color_button.setObjectName('background_color_button')
self.color_layout.addWidget(self.background_color_button) # self.color_layout.addWidget(self.background_color_button)
self.form_layout.addRow(self.color_layout) # self.form_layout.addRow(self.color_layout)
self.information_label = QtWidgets.QLabel(self.background_color_group_box) # self.information_label = QtWidgets.QLabel(self.background_color_group_box)
self.information_label.setObjectName('information_label') # self.information_label.setObjectName('information_label')
self.information_label.setWordWrap(True) # self.information_label.setWordWrap(True)
self.form_layout.addRow(self.information_label) # self.form_layout.addRow(self.information_label)
self.left_layout.addWidget(self.background_color_group_box) # self.left_layout.addWidget(self.background_color_group_box)
self.right_column.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Preferred) # 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 = QtWidgets.QGroupBox(self.left_column)
self.media_player_group_box.setObjectName('media_player_group_box') # 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 = QtWidgets.QVBoxLayout(self.media_player_group_box)
self.media_player_layout.setObjectName('media_player_layout') # self.media_player_layout.setObjectName('media_player_layout')
self.player_check_boxes = {} # self.player_check_boxes = {}
self.left_layout.addWidget(self.media_player_group_box) # self.left_layout.addWidget(self.media_player_group_box)
self.player_order_group_box = QtWidgets.QGroupBox(self.left_column) # self.player_order_group_box = QtWidgets.QGroupBox(self.left_column)
self.player_order_group_box.setObjectName('player_order_group_box') # 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 = QtWidgets.QHBoxLayout(self.player_order_group_box)
self.player_order_layout.setObjectName('player_order_layout') # self.player_order_layout.setObjectName('player_order_layout')
self.player_order_list_widget = QtWidgets.QListWidget(self.player_order_group_box) # self.player_order_list_widget = QtWidgets.QListWidget(self.player_order_group_box)
size_policy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding) # size_policy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
size_policy.setHorizontalStretch(0) # size_policy.setHorizontalStretch(0)
size_policy.setVerticalStretch(0) # size_policy.setVerticalStretch(0)
size_policy.setHeightForWidth(self.player_order_list_widget.sizePolicy().hasHeightForWidth()) # size_policy.setHeightForWidth(self.player_order_list_widget.sizePolicy().hasHeightForWidth())
self.player_order_list_widget.setSizePolicy(size_policy) # self.player_order_list_widget.setSizePolicy(size_policy)
self.player_order_list_widget.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded) # self.player_order_list_widget.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded)
self.player_order_list_widget.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) # self.player_order_list_widget.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
self.player_order_list_widget.setEditTriggers(QtWidgets.QAbstractItemView.NoEditTriggers) # self.player_order_list_widget.setEditTriggers(QtWidgets.QAbstractItemView.NoEditTriggers)
self.player_order_list_widget.setObjectName('player_order_list_widget') # self.player_order_list_widget.setObjectName('player_order_list_widget')
self.player_order_layout.addWidget(self.player_order_list_widget) # self.player_order_layout.addWidget(self.player_order_list_widget)
self.ordering_button_layout = QtWidgets.QVBoxLayout() # self.ordering_button_layout = QtWidgets.QVBoxLayout()
self.ordering_button_layout.setObjectName('ordering_button_layout') # self.ordering_button_layout.setObjectName('ordering_button_layout')
self.ordering_button_layout.addStretch(1) # self.ordering_button_layout.addStretch(1)
self.ordering_up_button = create_button(self, 'ordering_up_button', role='up', # self.ordering_up_button = create_button(self, 'ordering_up_button', role='up',
click=self.on_up_button_clicked) # click=self.on_up_button_clicked)
self.ordering_down_button = create_button(self, 'ordering_down_button', role='down', # self.ordering_down_button = create_button(self, 'ordering_down_button', role='down',
click=self.on_down_button_clicked) # click=self.on_down_button_clicked)
self.ordering_button_layout.addWidget(self.ordering_up_button) # self.ordering_button_layout.addWidget(self.ordering_up_button)
self.ordering_button_layout.addWidget(self.ordering_down_button) # self.ordering_button_layout.addWidget(self.ordering_down_button)
self.ordering_button_layout.addStretch(1) # self.ordering_button_layout.addStretch(1)
self.player_order_layout.addLayout(self.ordering_button_layout) # self.player_order_layout.addLayout(self.ordering_button_layout)
self.left_layout.addWidget(self.player_order_group_box) # self.left_layout.addWidget(self.player_order_group_box)
self.left_layout.addStretch() # self.left_layout.addStretch()
self.right_layout.addStretch() # self.right_layout.addStretch()
# Signals and slots # # Signals and slots
self.background_color_button.colorChanged.connect(self.on_background_color_changed) # self.background_color_button.colorChanged.connect(self.on_background_color_changed)
def retranslateUi(self): def retranslateUi(self):
""" """
Translate the UI on the fly Translate the UI on the fly
""" """
self.media_player_group_box.setTitle(translate('OpenLP.PlayerTab', 'Available Media Players')) # self.media_player_group_box.setTitle(translate('OpenLP.PlayerTab', 'Available Media Players'))
self.player_order_group_box.setTitle(translate('OpenLP.PlayerTab', 'Player Search Order')) # self.player_order_group_box.setTitle(translate('OpenLP.PlayerTab', 'Player Search Order'))
self.background_color_group_box.setTitle(UiStrings().BackgroundColor) # self.background_color_group_box.setTitle(UiStrings().BackgroundColor)
self.background_color_label.setText(UiStrings().BackgroundColorColon) # self.background_color_label.setText(UiStrings().BackgroundColorColon)
self.information_label.setText(translate('OpenLP.PlayerTab', # self.information_label.setText(translate('OpenLP.PlayerTab',
'Visible background for videos with aspect ratio different to screen.')) # 'Visible background for videos with aspect ratio different to screen.'))
self.retranslate_players() self.retranslate_players()
def on_background_color_changed(self, color): def on_background_color_changed(self, color):
@ -199,26 +199,28 @@ class PlayerTab(SettingsTab):
""" """
Load the settings Load the settings
""" """
if self.saved_used_players: pass
self.used_players = self.saved_used_players # if self.saved_used_players:
# self.used_players = get_media_players()[0] # self.used_players = self.saved_used_players
self.saved_used_players = self.used_players # # self.used_players = get_media_players()[0]
settings = Settings() # self.saved_used_players = self.used_players
settings.beginGroup(self.settings_section) # settings = Settings()
self.update_player_list() # settings.beginGroup(self.settings_section)
self.background_color = settings.value('background color') # self.update_player_list()
self.initial_color = self.background_color # self.background_color = settings.value('background color')
settings.endGroup() # self.initial_color = self.background_color
self.background_color_button.color = self.background_color # settings.endGroup()
# self.background_color_button.color = self.background_color
def save(self): def save(self):
""" """
Save the settings Save the settings
""" """
settings = Settings() pass
settings.beginGroup(self.settings_section) # settings = Settings()
settings.setValue('background color', self.background_color) # settings.beginGroup(self.settings_section)
settings.endGroup() # settings.setValue('background color', self.background_color)
# settings.endGroup()
# old_players, override_player = get_media_players() # old_players, override_player = get_media_players()
# if self.used_players != old_players: # if self.used_players != old_players:
# # clean old Media stuff # # clean old Media stuff
@ -233,37 +235,39 @@ class PlayerTab(SettingsTab):
:param post_update: Indicates if called before or after updates. :param post_update: Indicates if called before or after updates.
""" """
for key, player in self.media_players.items(): pass
player = self.media_players[key] # for key, player in self.media_players.items():
checkbox = MediaQCheckBox(self.media_player_group_box) # player = self.media_players[key]
checkbox.setEnabled(player.available) # checkbox = MediaQCheckBox(self.media_player_group_box)
checkbox.setObjectName(player.name + '_check_box') # checkbox.setEnabled(player.available)
checkbox.setToolTip(player.get_info()) # checkbox.setObjectName(player.name + '_check_box')
checkbox.set_player_name(player.name) # checkbox.setToolTip(player.get_info())
self.player_check_boxes[player.name] = checkbox # checkbox.set_player_name(player.name)
checkbox.stateChanged.connect(self.on_player_check_box_changed) # self.player_check_boxes[player.name] = checkbox
self.media_player_layout.addWidget(checkbox) # checkbox.stateChanged.connect(self.on_player_check_box_changed)
if player.available and player.name in self.used_players: # self.media_player_layout.addWidget(checkbox)
checkbox.setChecked(True) # if player.available and player.name in self.used_players:
else: # checkbox.setChecked(True)
checkbox.setChecked(False) # else:
self.update_player_list() # checkbox.setChecked(False)
self.retranslate_players() # self.update_player_list()
# self.retranslate_players()
def retranslate_players(self): def retranslate_players(self):
""" """
Translations for players is dependent on their setup as well Translations for players is dependent on their setup as well
""" """
for key in self.media_players and self.player_check_boxes: pass
player = self.media_players[key] # for key in self.media_players and self.player_check_boxes:
checkbox = self.player_check_boxes[player.name] # player = self.media_players[key]
checkbox.set_player_name(player.name) # checkbox = self.player_check_boxes[player.name]
if player.available: # checkbox.set_player_name(player.name)
checkbox.setText(player.display_name) # if player.available:
else: # checkbox.setText(player.display_name)
checkbox_text = translate('OpenLP.PlayerTab', '%s (unavailable)') % player.display_name # else:
if player.name == 'vlc': # checkbox_text = translate('OpenLP.PlayerTab', '%s (unavailable)') % player.display_name
checkbox_text += ' ' + translate('OpenLP.PlayerTab', # if player.name == 'vlc':
'NOTE: To use VLC you must install the %s version', # checkbox_text += ' ' + translate('OpenLP.PlayerTab',
'Will insert "32bit" or "64bit"') % platform.architecture()[0] # 'NOTE: To use VLC you must install the %s version',
checkbox.setText(checkbox_text) # 'Will insert "32bit" or "64bit"') % platform.architecture()[0]
# checkbox.setText(checkbox_text)

View File

@ -26,6 +26,7 @@ import logging
from PyQt5 import QtCore, QtWidgets from PyQt5 import QtCore, QtWidgets
from openlp.core.state import State
from openlp.core.api.tab import ApiTab from openlp.core.api.tab import ApiTab
from openlp.core.common.mixins import RegistryProperties from openlp.core.common.mixins import RegistryProperties
from openlp.core.common.registry import Registry from openlp.core.common.registry import Registry
@ -34,6 +35,7 @@ from openlp.core.projectors.tab import ProjectorTab
from openlp.core.ui.advancedtab import AdvancedTab from openlp.core.ui.advancedtab import AdvancedTab
from openlp.core.ui.generaltab import GeneralTab from openlp.core.ui.generaltab import GeneralTab
from openlp.core.ui.themestab import ThemesTab from openlp.core.ui.themestab import ThemesTab
from openlp.core.ui.media.playertab import PlayerTab
from openlp.core.ui.settingsdialog import Ui_SettingsDialog from openlp.core.ui.settingsdialog import Ui_SettingsDialog
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
@ -58,6 +60,7 @@ class SettingsForm(QtWidgets.QDialog, Ui_SettingsDialog, RegistryProperties):
self.themes_tab = None self.themes_tab = None
self.projector_tab = None self.projector_tab = None
self.advanced_tab = None self.advanced_tab = None
self.player_tab = None
self.api_tab = None self.api_tab = None
def exec(self): def exec(self):
@ -73,9 +76,10 @@ class SettingsForm(QtWidgets.QDialog, Ui_SettingsDialog, RegistryProperties):
self.insert_tab(self.general_tab) self.insert_tab(self.general_tab)
self.insert_tab(self.themes_tab) self.insert_tab(self.themes_tab)
self.insert_tab(self.advanced_tab) self.insert_tab(self.advanced_tab)
self.insert_tab(self.player_tab)
self.insert_tab(self.projector_tab) self.insert_tab(self.projector_tab)
self.insert_tab(self.api_tab) self.insert_tab(self.api_tab)
for plugin in self.plugin_manager.plugins: for plugin in State().list_plugins():
if plugin.settings_tab: if plugin.settings_tab:
self.insert_tab(plugin.settings_tab, plugin.is_active()) self.insert_tab(plugin.settings_tab, plugin.is_active())
self.setting_list_widget.setCurrentRow(0) self.setting_list_widget.setCurrentRow(0)
@ -156,13 +160,16 @@ class SettingsForm(QtWidgets.QDialog, Ui_SettingsDialog, RegistryProperties):
self.projector_tab = ProjectorTab(self) self.projector_tab = ProjectorTab(self)
# Advanced tab # Advanced tab
self.advanced_tab = AdvancedTab(self) self.advanced_tab = AdvancedTab(self)
# Advanced tab
self.player_tab = PlayerTab(self)
# Api tab # Api tab
self.api_tab = ApiTab(self) self.api_tab = ApiTab(self)
self.general_tab.post_set_up() self.general_tab.post_set_up()
self.themes_tab.post_set_up() self.themes_tab.post_set_up()
self.advanced_tab.post_set_up() self.advanced_tab.post_set_up()
self.player_tab.post_set_up()
self.api_tab.post_set_up() self.api_tab.post_set_up()
for plugin in self.plugin_manager.plugins: for plugin in State().list_plugins():
if plugin.settings_tab: if plugin.settings_tab:
plugin.settings_tab.post_set_up() plugin.settings_tab.post_set_up()

View File

@ -42,9 +42,9 @@ class MediaTab(SettingsTab):
self.advanced_group_box.setObjectName('advanced_group_box') self.advanced_group_box.setObjectName('advanced_group_box')
self.advanced_layout = QtWidgets.QVBoxLayout(self.advanced_group_box) self.advanced_layout = QtWidgets.QVBoxLayout(self.advanced_group_box)
self.advanced_layout.setObjectName('advanced_layout') self.advanced_layout.setObjectName('advanced_layout')
self.override_player_check_box = QtWidgets.QCheckBox(self.advanced_group_box) # self.override_player_check_box = QtWidgets.QCheckBox(self.advanced_group_box)
self.override_player_check_box.setObjectName('override_player_check_box') # self.override_player_check_box.setObjectName('override_player_check_box')
self.advanced_layout.addWidget(self.override_player_check_box) # self.advanced_layout.addWidget(self.override_player_check_box)
self.auto_start_check_box = QtWidgets.QCheckBox(self.advanced_group_box) self.auto_start_check_box = QtWidgets.QCheckBox(self.advanced_group_box)
self.auto_start_check_box.setObjectName('auto_start_check_box') self.auto_start_check_box.setObjectName('auto_start_check_box')
self.advanced_layout.addWidget(self.auto_start_check_box) self.advanced_layout.addWidget(self.auto_start_check_box)
@ -54,20 +54,20 @@ class MediaTab(SettingsTab):
def retranslateUi(self): def retranslateUi(self):
self.advanced_group_box.setTitle(UiStrings().Advanced) self.advanced_group_box.setTitle(UiStrings().Advanced)
self.override_player_check_box.setText(translate('MediaPlugin.MediaTab', 'Allow media player to be overridden')) # self.override_player_check_box.setText(translate('MediaPlugin.MediaTab', 'Allow media player to be overridden'))
self.auto_start_check_box.setText(translate('MediaPlugin.MediaTab', 'Start new Live media automatically')) self.auto_start_check_box.setText(translate('MediaPlugin.MediaTab', 'Start new Live media automatically'))
def load(self): def load(self):
self.override_player_check_box.setChecked(Settings().value(self.settings_section + '/override player')) # self.override_player_check_box.setChecked(Settings().value(self.settings_section + '/override player'))
self.auto_start_check_box.setChecked(Settings().value(self.settings_section + '/media auto start')) self.auto_start_check_box.setChecked(Settings().value(self.settings_section + '/media auto start'))
def save(self): def save(self):
setting_key = self.settings_section + '/override player' # setting_key = self.settings_section + '/override player'
if Settings().value(setting_key) != self.override_player_check_box.checkState(): # if Settings().value(setting_key) != self.override_player_check_box.checkState():
Settings().setValue(setting_key, self.override_player_check_box.checkState()) # Settings().setValue(setting_key, self.override_player_check_box.checkState())
self.settings_form.register_post_process('mediaitem_suffix_reset') # self.settings_form.register_post_process('mediaitem_suffix_reset')
self.settings_form.register_post_process('mediaitem_media_rebuild') # self.settings_form.register_post_process('mediaitem_media_rebuild')
self.settings_form.register_post_process('mediaitem_suffixes') # self.settings_form.register_post_process('mediaitem_suffixes')
setting_key = self.settings_section + '/media auto start' setting_key = self.settings_section + '/media auto start'
if Settings().value(setting_key) != self.auto_start_check_box.checkState(): if Settings().value(setting_key) != self.auto_start_check_box.checkState():
Settings().setValue(setting_key, self.auto_start_check_box.checkState()) Settings().setValue(setting_key, self.auto_start_check_box.checkState())