From 8ed42169753824e5506dfa4d6be01aa263feca1f Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sun, 20 Jan 2019 09:29:47 +0000 Subject: [PATCH] settings updates --- openlp/core/ui/media/playertab.py | 218 ++++++++++++++------------- openlp/core/ui/settingsform.py | 11 +- openlp/plugins/media/lib/mediatab.py | 22 +-- 3 files changed, 131 insertions(+), 120 deletions(-) diff --git a/openlp/core/ui/media/playertab.py b/openlp/core/ui/media/playertab.py index 4bdba1008..8638352d0 100644 --- a/openlp/core/ui/media/playertab.py +++ b/openlp/core/ui/media/playertab.py @@ -54,8 +54,8 @@ class PlayerTab(SettingsTab): """ Constructor """ - self.media_players = Registry().get('media_controller').media_players - self.saved_used_players = None + # self.media_players = Registry().get('media_controller').media_players + # self.saved_used_players = None self.icon_path = UiIcons().player player_translated = translate('OpenLP.PlayerTab', 'Players') super(PlayerTab, self).__init__(parent, 'Players', player_translated) @@ -66,72 +66,72 @@ class PlayerTab(SettingsTab): """ self.setObjectName('MediaTab') super(PlayerTab, self).setupUi() - 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.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) def retranslateUi(self): """ Translate the UI on the fly """ - 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.background_color_group_box.setTitle(UiStrings().BackgroundColor) - self.background_color_label.setText(UiStrings().BackgroundColorColon) - self.information_label.setText(translate('OpenLP.PlayerTab', - 'Visible background for videos with aspect ratio different to screen.')) + # 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.background_color_group_box.setTitle(UiStrings().BackgroundColor) + # self.background_color_label.setText(UiStrings().BackgroundColorColon) + # self.information_label.setText(translate('OpenLP.PlayerTab', + # 'Visible background for videos with aspect ratio different to screen.')) self.retranslate_players() def on_background_color_changed(self, color): @@ -199,26 +199,28 @@ class PlayerTab(SettingsTab): """ Load the settings """ - 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 + pass + # 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 def save(self): """ Save the settings """ - settings = Settings() - settings.beginGroup(self.settings_section) - settings.setValue('background color', self.background_color) - settings.endGroup() + pass + # settings = Settings() + # settings.beginGroup(self.settings_section) + # settings.setValue('background color', self.background_color) + # settings.endGroup() # old_players, override_player = get_media_players() # if self.used_players != old_players: # # clean old Media stuff @@ -233,37 +235,39 @@ class PlayerTab(SettingsTab): :param post_update: Indicates if called before or after updates. """ - for key, player in self.media_players.items(): - player = self.media_players[key] - checkbox = MediaQCheckBox(self.media_player_group_box) - checkbox.setEnabled(player.available) - checkbox.setObjectName(player.name + '_check_box') - checkbox.setToolTip(player.get_info()) - checkbox.set_player_name(player.name) - self.player_check_boxes[player.name] = checkbox - checkbox.stateChanged.connect(self.on_player_check_box_changed) - self.media_player_layout.addWidget(checkbox) - if player.available and player.name in self.used_players: - checkbox.setChecked(True) - else: - checkbox.setChecked(False) - self.update_player_list() - self.retranslate_players() + pass + # for key, player in self.media_players.items(): + # player = self.media_players[key] + # checkbox = MediaQCheckBox(self.media_player_group_box) + # checkbox.setEnabled(player.available) + # checkbox.setObjectName(player.name + '_check_box') + # checkbox.setToolTip(player.get_info()) + # checkbox.set_player_name(player.name) + # self.player_check_boxes[player.name] = checkbox + # checkbox.stateChanged.connect(self.on_player_check_box_changed) + # self.media_player_layout.addWidget(checkbox) + # if player.available and player.name in self.used_players: + # checkbox.setChecked(True) + # else: + # checkbox.setChecked(False) + # self.update_player_list() + # self.retranslate_players() def retranslate_players(self): """ Translations for players is dependent on their setup as well """ - for key in self.media_players and self.player_check_boxes: - player = self.media_players[key] - checkbox = self.player_check_boxes[player.name] - checkbox.set_player_name(player.name) - if player.available: - checkbox.setText(player.display_name) - else: - checkbox_text = translate('OpenLP.PlayerTab', '%s (unavailable)') % player.display_name - if player.name == 'vlc': - checkbox_text += ' ' + translate('OpenLP.PlayerTab', - 'NOTE: To use VLC you must install the %s version', - 'Will insert "32bit" or "64bit"') % platform.architecture()[0] - checkbox.setText(checkbox_text) + pass + # for key in self.media_players and self.player_check_boxes: + # player = self.media_players[key] + # checkbox = self.player_check_boxes[player.name] + # checkbox.set_player_name(player.name) + # if player.available: + # checkbox.setText(player.display_name) + # else: + # checkbox_text = translate('OpenLP.PlayerTab', '%s (unavailable)') % player.display_name + # if player.name == 'vlc': + # checkbox_text += ' ' + translate('OpenLP.PlayerTab', + # 'NOTE: To use VLC you must install the %s version', + # 'Will insert "32bit" or "64bit"') % platform.architecture()[0] + # checkbox.setText(checkbox_text) diff --git a/openlp/core/ui/settingsform.py b/openlp/core/ui/settingsform.py index aa7943ec4..b07bcd761 100644 --- a/openlp/core/ui/settingsform.py +++ b/openlp/core/ui/settingsform.py @@ -26,6 +26,7 @@ import logging from PyQt5 import QtCore, QtWidgets +from openlp.core.state import State from openlp.core.api.tab import ApiTab from openlp.core.common.mixins import RegistryProperties 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.generaltab import GeneralTab from openlp.core.ui.themestab import ThemesTab +from openlp.core.ui.media.playertab import PlayerTab from openlp.core.ui.settingsdialog import Ui_SettingsDialog log = logging.getLogger(__name__) @@ -58,6 +60,7 @@ class SettingsForm(QtWidgets.QDialog, Ui_SettingsDialog, RegistryProperties): self.themes_tab = None self.projector_tab = None self.advanced_tab = None + self.player_tab = None self.api_tab = None def exec(self): @@ -73,9 +76,10 @@ class SettingsForm(QtWidgets.QDialog, Ui_SettingsDialog, RegistryProperties): self.insert_tab(self.general_tab) self.insert_tab(self.themes_tab) self.insert_tab(self.advanced_tab) + self.insert_tab(self.player_tab) self.insert_tab(self.projector_tab) self.insert_tab(self.api_tab) - for plugin in self.plugin_manager.plugins: + for plugin in State().list_plugins(): if plugin.settings_tab: self.insert_tab(plugin.settings_tab, plugin.is_active()) self.setting_list_widget.setCurrentRow(0) @@ -156,13 +160,16 @@ class SettingsForm(QtWidgets.QDialog, Ui_SettingsDialog, RegistryProperties): self.projector_tab = ProjectorTab(self) # Advanced tab self.advanced_tab = AdvancedTab(self) + # Advanced tab + self.player_tab = PlayerTab(self) # Api tab self.api_tab = ApiTab(self) self.general_tab.post_set_up() self.themes_tab.post_set_up() self.advanced_tab.post_set_up() + self.player_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: plugin.settings_tab.post_set_up() diff --git a/openlp/plugins/media/lib/mediatab.py b/openlp/plugins/media/lib/mediatab.py index 297a9e723..2e88d0e68 100644 --- a/openlp/plugins/media/lib/mediatab.py +++ b/openlp/plugins/media/lib/mediatab.py @@ -42,9 +42,9 @@ class MediaTab(SettingsTab): self.advanced_group_box.setObjectName('advanced_group_box') self.advanced_layout = QtWidgets.QVBoxLayout(self.advanced_group_box) self.advanced_layout.setObjectName('advanced_layout') - self.override_player_check_box = QtWidgets.QCheckBox(self.advanced_group_box) - self.override_player_check_box.setObjectName('override_player_check_box') - self.advanced_layout.addWidget(self.override_player_check_box) + # self.override_player_check_box = QtWidgets.QCheckBox(self.advanced_group_box) + # self.override_player_check_box.setObjectName('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.setObjectName('auto_start_check_box') self.advanced_layout.addWidget(self.auto_start_check_box) @@ -54,20 +54,20 @@ class MediaTab(SettingsTab): def retranslateUi(self): 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')) 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')) def save(self): - setting_key = self.settings_section + '/override player' - if Settings().value(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_media_rebuild') - self.settings_form.register_post_process('mediaitem_suffixes') + # setting_key = self.settings_section + '/override player' + # if Settings().value(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_media_rebuild') + # self.settings_form.register_post_process('mediaitem_suffixes') setting_key = self.settings_section + '/media auto start' if Settings().value(setting_key) != self.auto_start_check_box.checkState(): Settings().setValue(setting_key, self.auto_start_check_box.checkState())