Code cleanups and style fixes

bzr-revno: 2166
This commit is contained in:
Tim Bentley 2013-02-02 20:53:50 +00:00
commit 44ea74cf55
17 changed files with 764 additions and 617 deletions

View File

@ -688,3 +688,13 @@ class MediaManagerItem(QtGui.QWidget):
service_manager = property(_get_service_manager)
def _get_theme_manager(self):
"""
Adds the theme manager to the class dynamically
"""
if not hasattr(self, u'_theme_manager'):
self._theme_manager = Registry().get(u'theme_manager')
return self._theme_manager
theme_manager = property(_get_theme_manager)

View File

@ -128,7 +128,7 @@ class Renderer(object):
The theme name.
"""
if theme_name not in self._theme_dimensions:
theme_data = self.theme_manager.getThemeData(theme_name)
theme_data = self.theme_manager.get_theme_data(theme_name)
main_rect = self.get_main_rectangle(theme_data)
footer_rect = self.get_footer_rectangle(theme_data)
self._theme_dimensions[theme_name] = [theme_data, main_rect, footer_rect]
@ -662,3 +662,4 @@ class Renderer(object):
return self._theme_manager
theme_manager = property(_get_theme_manager)

View File

@ -29,6 +29,8 @@
from PyQt4 import QtGui
from openlp.core.lib import Registry
class SettingsTab(QtGui.QWidget):
"""
SettingsTab is a helper widget for plugins to define Tabs for the settings
@ -131,3 +133,54 @@ class SettingsTab(QtGui.QWidget):
Tab has just been made visible to the user
"""
pass
def _get_service_manager(self):
"""
Adds the service manager to the class dynamically
"""
if not hasattr(self, u'_service_manager'):
self._service_manager = Registry().get(u'service_manager')
return self._service_manager
service_manager = property(_get_service_manager)
def _get_main_window(self):
"""
Adds the main window to the class dynamically
"""
if not hasattr(self, u'_main_window'):
self._main_window = Registry().get(u'main_window')
return self._main_window
main_window = property(_get_main_window)
def _get_renderer(self):
"""
Adds the Renderer to the class dynamically
"""
if not hasattr(self, u'_renderer'):
self._renderer = Registry().get(u'renderer')
return self._renderer
renderer = property(_get_renderer)
def _get_theme_manager(self):
"""
Adds the theme manager to the class dynamically
"""
if not hasattr(self, u'_theme_manager'):
self._theme_manager = Registry().get(u'theme_manager')
return self._theme_manager
theme_manager = property(_get_theme_manager)
def _get_media_controller(self):
"""
Adds the media controller to the class dynamically
"""
if not hasattr(self, u'_media_controller'):
self._media_controller = Registry().get(u'media_controller')
return self._media_controller
media_controller = property(_get_media_controller)

View File

@ -213,6 +213,7 @@ class ThemeXML(object):
"""
FIRST_CAMEL_REGEX = re.compile(u'(.)([A-Z][a-z]+)')
SECOND_CAMEL_REGEX = re.compile(u'([a-z0-9])([A-Z])')
def __init__(self):
"""
Initialise the theme object.

View File

@ -164,6 +164,7 @@ class Theme(object):
* ``0`` - normal
* ``1`` - lyrics
"""
def __init__(self, xml):
"""
Initialise a theme with data from xml

View File

@ -52,10 +52,10 @@ class AdvancedTab(SettingsTab):
"""
Initialise the settings tab
"""
self.displayChanged = False
self.defaultImage = u':/graphics/openlp-splash-screen.png'
self.defaultColor = u'#ffffff'
self.dataExists = False
self.display_changed = False
self.default_image = u':/graphics/openlp-splash-screen.png'
self.default_color = u'#ffffff'
self.data_exists = False
self.iconPath = u':/system/system_settings.png'
advanced_translated = translate('OpenLP.AdvancedTab', 'Advanced')
SettingsTab.__init__(self, parent, u'Advanced', advanced_translated)
@ -66,278 +66,288 @@ class AdvancedTab(SettingsTab):
"""
self.setObjectName(u'AdvancedTab')
SettingsTab.setupUi(self)
self.uiGroupBox = QtGui.QGroupBox(self.leftColumn)
self.uiGroupBox.setObjectName(u'uiGroupBox')
self.uiLayout = QtGui.QFormLayout(self.uiGroupBox)
self.uiLayout.setObjectName(u'uiLayout')
self.recentLabel = QtGui.QLabel(self.uiGroupBox)
self.recentLabel.setObjectName(u'recentLabel')
self.recentSpinBox = QtGui.QSpinBox(self.uiGroupBox)
self.recentSpinBox.setObjectName(u'recentSpinBox')
self.recentSpinBox.setMinimum(0)
self.uiLayout.addRow(self.recentLabel, self.recentSpinBox)
self.mediaPluginCheckBox = QtGui.QCheckBox(self.uiGroupBox)
self.mediaPluginCheckBox.setObjectName(u'mediaPluginCheckBox')
self.uiLayout.addRow(self.mediaPluginCheckBox)
self.doubleClickLiveCheckBox = QtGui.QCheckBox(self.uiGroupBox)
self.doubleClickLiveCheckBox.setObjectName(u'doubleClickLiveCheckBox')
self.uiLayout.addRow(self.doubleClickLiveCheckBox)
self.singleClickPreviewCheckBox = QtGui.QCheckBox(self.uiGroupBox)
self.singleClickPreviewCheckBox.setObjectName(u'singleClickPreviewCheckBox')
self.uiLayout.addRow(self.singleClickPreviewCheckBox)
self.expandServiceItemCheckBox = QtGui.QCheckBox(self.uiGroupBox)
self.expandServiceItemCheckBox.setObjectName(u'expandServiceItemCheckBox')
self.uiLayout.addRow(self.expandServiceItemCheckBox)
self.enableAutoCloseCheckBox = QtGui.QCheckBox(self.uiGroupBox)
self.enableAutoCloseCheckBox.setObjectName(u'enableAutoCloseCheckBox')
self.uiLayout.addRow(self.enableAutoCloseCheckBox)
self.leftLayout.addWidget(self.uiGroupBox)
self.ui_group_box = QtGui.QGroupBox(self.leftColumn)
self.ui_group_box.setObjectName(u'ui_group_box')
self.ui_layout = QtGui.QFormLayout(self.ui_group_box)
self.ui_layout.setObjectName(u'ui_layout')
self.recent_label = QtGui.QLabel(self.ui_group_box)
self.recent_label.setObjectName(u'recent_label')
self.recent_spin_box = QtGui.QSpinBox(self.ui_group_box)
self.recent_spin_box.setObjectName(u'recent_spin_box')
self.recent_spin_box.setMinimum(0)
self.ui_layout.addRow(self.recent_label, self.recent_spin_box)
self.media_plugin_check_box = QtGui.QCheckBox(self.ui_group_box)
self.media_plugin_check_box.setObjectName(u'media_plugin_check_box')
self.ui_layout.addRow(self.media_plugin_check_box)
self.double_click_live_check_box = QtGui.QCheckBox(self.ui_group_box)
self.double_click_live_check_box.setObjectName(u'double_click_live_check_box')
self.ui_layout.addRow(self.double_click_live_check_box)
self.single_click_preview_check_box = QtGui.QCheckBox(self.ui_group_box)
self.single_click_preview_check_box.setObjectName(u'single_click_preview_check_box')
self.ui_layout.addRow(self.single_click_preview_check_box)
self.expand_service_item_check_box = QtGui.QCheckBox(self.ui_group_box)
self.expand_service_item_check_box.setObjectName(u'expand_service_item_check_box')
self.ui_layout.addRow(self.expand_service_item_check_box)
self.enable_auto_close_check_box = QtGui.QCheckBox(self.ui_group_box)
self.enable_auto_close_check_box.setObjectName(u'enable_auto_close_check_box')
self.ui_layout.addRow(self.enable_auto_close_check_box)
self.leftLayout.addWidget(self.ui_group_box)
# Default service name
self.serviceNameGroupBox = QtGui.QGroupBox(self.leftColumn)
self.serviceNameGroupBox.setObjectName(u'serviceNameGroupBox')
self.serviceNameLayout = QtGui.QFormLayout(self.serviceNameGroupBox)
self.serviceNameCheckBox = QtGui.QCheckBox(self.serviceNameGroupBox)
self.serviceNameCheckBox.setObjectName(u'serviceNameCheckBox')
self.serviceNameLayout.setObjectName(u'serviceNameLayout')
self.serviceNameLayout.addRow(self.serviceNameCheckBox)
self.serviceNameTimeLabel = QtGui.QLabel(self.serviceNameGroupBox)
self.serviceNameTimeLabel.setObjectName(u'serviceNameTimeLabel')
self.serviceNameDay = QtGui.QComboBox(self.serviceNameGroupBox)
self.serviceNameDay.addItems([u'', u'', u'', u'', u'', u'', u'', u''])
self.serviceNameDay.setObjectName(u'serviceNameDay')
self.serviceNameTime = QtGui.QTimeEdit(self.serviceNameGroupBox)
self.serviceNameTime.setObjectName(u'serviceNameTime')
self.serviceNameTimeHBox = QtGui.QHBoxLayout()
self.serviceNameTimeHBox.setObjectName(u'serviceNameTimeHBox')
self.serviceNameTimeHBox.addWidget(self.serviceNameDay)
self.serviceNameTimeHBox.addWidget(self.serviceNameTime)
self.serviceNameLayout.addRow(self.serviceNameTimeLabel, self.serviceNameTimeHBox)
self.serviceNameLabel = QtGui.QLabel(self.serviceNameGroupBox)
self.serviceNameLabel.setObjectName(u'serviceNameLabel')
self.serviceNameEdit = QtGui.QLineEdit(self.serviceNameGroupBox)
self.serviceNameEdit.setObjectName(u'serviceNameEdit')
self.serviceNameEdit.setValidator(QtGui.QRegExpValidator(QtCore.QRegExp(r'[^/\\?*|<>\[\]":+]+'), self))
self.serviceNameRevertButton = QtGui.QToolButton(self.serviceNameGroupBox)
self.serviceNameRevertButton.setObjectName(u'serviceNameRevertButton')
self.serviceNameRevertButton.setIcon(build_icon(u':/general/general_revert.png'))
self.serviceNameHBox = QtGui.QHBoxLayout()
self.serviceNameHBox.setObjectName(u'serviceNameHBox')
self.serviceNameHBox.addWidget(self.serviceNameEdit)
self.serviceNameHBox.addWidget(self.serviceNameRevertButton)
self.serviceNameLayout.addRow(self.serviceNameLabel, self.serviceNameHBox)
self.serviceNameExampleLabel = QtGui.QLabel(self.serviceNameGroupBox)
self.serviceNameExampleLabel.setObjectName(u'serviceNameExampleLabel')
self.serviceNameExample = QtGui.QLabel(self.serviceNameGroupBox)
self.serviceNameExample.setObjectName(u'serviceNameExample')
self.serviceNameLayout.addRow(self.serviceNameExampleLabel, self.serviceNameExample)
self.leftLayout.addWidget(self.serviceNameGroupBox)
self.service_name_group_box = QtGui.QGroupBox(self.leftColumn)
self.service_name_group_box.setObjectName(u'service_name_group_box')
self.service_name_layout = QtGui.QFormLayout(self.service_name_group_box)
self.service_name_check_box = QtGui.QCheckBox(self.service_name_group_box)
self.service_name_check_box.setObjectName(u'service_name_check_box')
self.service_name_layout.setObjectName(u'service_name_layout')
self.service_name_layout.addRow(self.service_name_check_box)
self.service_name_time_label = QtGui.QLabel(self.service_name_group_box)
self.service_name_time_label.setObjectName(u'service_name_time_label')
self.service_name_day = QtGui.QComboBox(self.service_name_group_box)
self.service_name_day.addItems([u'', u'', u'', u'', u'', u'', u'', u''])
self.service_name_day.setObjectName(u'service_name_day')
self.service_name_time = QtGui.QTimeEdit(self.service_name_group_box)
self.service_name_time.setObjectName(u'service_name_time')
self.service_name_time_layout = QtGui.QHBoxLayout()
self.service_name_time_layout.setObjectName(u'service_name_time_layout')
self.service_name_time_layout.addWidget(self.service_name_day)
self.service_name_time_layout.addWidget(self.service_name_time)
self.service_name_layout.addRow(self.service_name_time_label, self.service_name_time_layout)
self.service_name_label = QtGui.QLabel(self.service_name_group_box)
self.service_name_label.setObjectName(u'service_name_label')
self.service_name_edit = QtGui.QLineEdit(self.service_name_group_box)
self.service_name_edit.setObjectName(u'service_name_edit')
self.service_name_edit.setValidator(QtGui.QRegExpValidator(QtCore.QRegExp(r'[^/\\?*|<>\[\]":+]+'), self))
self.service_name_revert_button = QtGui.QToolButton(self.service_name_group_box)
self.service_name_revert_button.setObjectName(u'service_name_revert_button')
self.service_name_revert_button.setIcon(build_icon(u':/general/general_revert.png'))
self.service_name_button_layout = QtGui.QHBoxLayout()
self.service_name_button_layout.setObjectName(u'service_name_button_layout')
self.service_name_button_layout.addWidget(self.service_name_edit)
self.service_name_button_layout.addWidget(self.service_name_revert_button)
self.service_name_layout.addRow(self.service_name_label, self.service_name_button_layout)
self.service_name_example_label = QtGui.QLabel(self.service_name_group_box)
self.service_name_example_label.setObjectName(u'service_name_example_label')
self.service_name_example = QtGui.QLabel(self.service_name_group_box)
self.service_name_example.setObjectName(u'service_name_example')
self.service_name_layout.addRow(self.service_name_example_label, self.service_name_example)
self.leftLayout.addWidget(self.service_name_group_box)
# Data Directory
self.dataDirectoryGroupBox = QtGui.QGroupBox(self.leftColumn)
self.dataDirectoryGroupBox.setObjectName(u'dataDirectoryGroupBox')
self.dataDirectoryLayout = QtGui.QFormLayout(self.dataDirectoryGroupBox)
self.dataDirectoryLayout.setObjectName(u'dataDirectoryLayout')
self.dataDirectoryCurrentLabel = QtGui.QLabel(self.dataDirectoryGroupBox)
self.dataDirectoryCurrentLabel.setObjectName( u'dataDirectoryCurrentLabel')
self.dataDirectoryLabel = QtGui.QLabel(self.dataDirectoryGroupBox)
self.dataDirectoryLabel.setObjectName(u'dataDirectoryLabel')
self.dataDirectoryNewLabel = QtGui.QLabel(self.dataDirectoryGroupBox)
self.dataDirectoryNewLabel.setObjectName(u'dataDirectoryCurrentLabel')
self.newDataDirectoryEdit = QtGui.QLineEdit(self.dataDirectoryGroupBox)
self.newDataDirectoryEdit.setObjectName(u'newDataDirectoryEdit')
self.newDataDirectoryEdit.setReadOnly(True)
self.newDataDirectoryHasFilesLabel = QtGui.QLabel(self.dataDirectoryGroupBox)
self.newDataDirectoryHasFilesLabel.setObjectName(u'newDataDirectoryHasFilesLabel')
self.newDataDirectoryHasFilesLabel.setWordWrap(True)
self.dataDirectoryBrowseButton = QtGui.QToolButton(self.dataDirectoryGroupBox)
self.dataDirectoryBrowseButton.setObjectName(u'dataDirectoryBrowseButton')
self.dataDirectoryBrowseButton.setIcon(build_icon(u':/general/general_open.png'))
self.dataDirectoryDefaultButton = QtGui.QToolButton(self.dataDirectoryGroupBox)
self.dataDirectoryDefaultButton.setObjectName(u'dataDirectoryDefaultButton')
self.dataDirectoryDefaultButton.setIcon(build_icon(u':/general/general_revert.png'))
self.dataDirectoryCancelButton = QtGui.QToolButton(self.dataDirectoryGroupBox)
self.dataDirectoryCancelButton.setObjectName(u'dataDirectoryCancelButton')
self.dataDirectoryCancelButton.setIcon(build_icon(u':/general/general_delete.png'))
self.newDataDirectoryLabelHBox = QtGui.QHBoxLayout()
self.newDataDirectoryLabelHBox.setObjectName(u'newDataDirectoryLabelHBox')
self.newDataDirectoryLabelHBox.addWidget(self.newDataDirectoryEdit)
self.newDataDirectoryLabelHBox.addWidget(self.dataDirectoryBrowseButton)
self.newDataDirectoryLabelHBox.addWidget(self.dataDirectoryDefaultButton)
self.dataDirectoryCopyCheckHBox = QtGui.QHBoxLayout()
self.dataDirectoryCopyCheckHBox.setObjectName(u'dataDirectoryCopyCheckHBox')
self.dataDirectoryCopyCheckBox = QtGui.QCheckBox(self.dataDirectoryGroupBox)
self.dataDirectoryCopyCheckBox.setObjectName(u'dataDirectoryCopyCheckBox')
self.dataDirectoryCopyCheckHBox.addWidget(self.dataDirectoryCopyCheckBox)
self.dataDirectoryCopyCheckHBox.addStretch()
self.dataDirectoryCopyCheckHBox.addWidget(self.dataDirectoryCancelButton)
self.dataDirectoryLayout.addRow(self.dataDirectoryCurrentLabel, self.dataDirectoryLabel)
self.dataDirectoryLayout.addRow(self.dataDirectoryNewLabel, self.newDataDirectoryLabelHBox)
self.dataDirectoryLayout.addRow(self.dataDirectoryCopyCheckHBox)
self.dataDirectoryLayout.addRow(self.newDataDirectoryHasFilesLabel)
self.leftLayout.addWidget(self.dataDirectoryGroupBox)
self.data_directory_group_box = QtGui.QGroupBox(self.leftColumn)
self.data_directory_group_box.setObjectName(u'data_directory_group_box')
self.data_directory_layout = QtGui.QFormLayout(self.data_directory_group_box)
self.data_directory_layout.setObjectName(u'data_directory_layout')
self.data_directory_current_label = QtGui.QLabel(self.data_directory_group_box)
self.data_directory_current_label.setObjectName( u'data_directory_current_label')
self.data_directory_label = QtGui.QLabel(self.data_directory_group_box)
self.data_directory_label.setObjectName(u'data_directory_label')
self.data_directory_new_label = QtGui.QLabel(self.data_directory_group_box)
self.data_directory_new_label.setObjectName(u'data_directory_current_label')
self.new_data_directory_edit = QtGui.QLineEdit(self.data_directory_group_box)
self.new_data_directory_edit.setObjectName(u'new_data_directory_edit')
self.new_data_directory_edit.setReadOnly(True)
self.new_data_directory_has_files_label = QtGui.QLabel(self.data_directory_group_box)
self.new_data_directory_has_files_label.setObjectName(u'new_data_directory_has_files_label')
self.new_data_directory_has_files_label.setWordWrap(True)
self.data_directory_browse_button = QtGui.QToolButton(self.data_directory_group_box)
self.data_directory_browse_button.setObjectName(u'data_directory_browse_button')
self.data_directory_browse_button.setIcon(build_icon(u':/general/general_open.png'))
self.data_directory_default_button = QtGui.QToolButton(self.data_directory_group_box)
self.data_directory_default_button.setObjectName(u'data_directory_default_button')
self.data_directory_default_button.setIcon(build_icon(u':/general/general_revert.png'))
self.data_directory_cancel_button = QtGui.QToolButton(self.data_directory_group_box)
self.data_directory_cancel_button.setObjectName(u'data_directory_cancel_button')
self.data_directory_cancel_button.setIcon(build_icon(u':/general/general_delete.png'))
self.new_data_directory_label_layout = QtGui.QHBoxLayout()
self.new_data_directory_label_layout.setObjectName(u'new_data_directory_label_layout')
self.new_data_directory_label_layout.addWidget(self.new_data_directory_edit)
self.new_data_directory_label_layout.addWidget(self.data_directory_browse_button)
self.new_data_directory_label_layout.addWidget(self.data_directory_default_button)
self.data_directory_copy_check_layout = QtGui.QHBoxLayout()
self.data_directory_copy_check_layout.setObjectName(u'data_directory_copy_check_layout')
self.data_directory_copy_check_box = QtGui.QCheckBox(self.data_directory_group_box)
self.data_directory_copy_check_box.setObjectName(u'data_directory_copy_check_box')
self.data_directory_copy_check_layout.addWidget(self.data_directory_copy_check_box)
self.data_directory_copy_check_layout.addStretch()
self.data_directory_copy_check_layout.addWidget(self.data_directory_cancel_button)
self.data_directory_layout.addRow(self.data_directory_current_label, self.data_directory_label)
self.data_directory_layout.addRow(self.data_directory_new_label, self.new_data_directory_label_layout)
self.data_directory_layout.addRow(self.data_directory_copy_check_layout)
self.data_directory_layout.addRow(self.new_data_directory_has_files_label)
self.leftLayout.addWidget(self.data_directory_group_box)
self.leftLayout.addStretch()
# Default Image
self.defaultImageGroupBox = QtGui.QGroupBox(self.rightColumn)
self.defaultImageGroupBox.setObjectName(u'defaultImageGroupBox')
self.defaultImageLayout = QtGui.QFormLayout(self.defaultImageGroupBox)
self.defaultImageLayout.setObjectName(u'defaultImageLayout')
self.defaultColorLabel = QtGui.QLabel(self.defaultImageGroupBox)
self.defaultColorLabel.setObjectName(u'defaultColorLabel')
self.defaultColorButton = QtGui.QPushButton(self.defaultImageGroupBox)
self.defaultColorButton.setObjectName(u'defaultColorButton')
self.defaultImageLayout.addRow(self.defaultColorLabel, self.defaultColorButton)
self.defaultFileLabel = QtGui.QLabel(self.defaultImageGroupBox)
self.defaultFileLabel.setObjectName(u'defaultFileLabel')
self.defaultFileEdit = QtGui.QLineEdit(self.defaultImageGroupBox)
self.defaultFileEdit.setObjectName(u'defaultFileEdit')
self.defaultBrowseButton = QtGui.QToolButton(self.defaultImageGroupBox)
self.defaultBrowseButton.setObjectName(u'defaultBrowseButton')
self.defaultBrowseButton.setIcon(build_icon(u':/general/general_open.png'))
self.defaultRevertButton = QtGui.QToolButton(self.defaultImageGroupBox)
self.defaultRevertButton.setObjectName(u'defaultRevertButton')
self.defaultRevertButton.setIcon(build_icon(u':/general/general_revert.png'))
self.defaultFileLayout = QtGui.QHBoxLayout()
self.defaultFileLayout.setObjectName(u'defaultFileLayout')
self.defaultFileLayout.addWidget(self.defaultFileEdit)
self.defaultFileLayout.addWidget(self.defaultBrowseButton)
self.defaultFileLayout.addWidget(self.defaultRevertButton)
self.defaultImageLayout.addRow(self.defaultFileLabel, self.defaultFileLayout)
self.rightLayout.addWidget(self.defaultImageGroupBox)
self.default_image_group_box = QtGui.QGroupBox(self.rightColumn)
self.default_image_group_box.setObjectName(u'default_image_group_box')
self.default_image_layout = QtGui.QFormLayout(self.default_image_group_box)
self.default_image_layout.setObjectName(u'default_image_layout')
self.default_color_label = QtGui.QLabel(self.default_image_group_box)
self.default_color_label.setObjectName(u'default_color_label')
self.default_color_button = QtGui.QPushButton(self.default_image_group_box)
self.default_color_button.setObjectName(u'default_color_button')
self.default_image_layout.addRow(self.default_color_label, self.default_color_button)
self.default_file_label = QtGui.QLabel(self.default_image_group_box)
self.default_file_label.setObjectName(u'default_file_label')
self.default_file_edit = QtGui.QLineEdit(self.default_image_group_box)
self.default_file_edit.setObjectName(u'default_file_edit')
self.default_browse_button = QtGui.QToolButton(self.default_image_group_box)
self.default_browse_button.setObjectName(u'default_browse_button')
self.default_browse_button.setIcon(build_icon(u':/general/general_open.png'))
self.default_revert_button = QtGui.QToolButton(self.default_image_group_box)
self.default_revert_button.setObjectName(u'default_revert_button')
self.default_revert_button.setIcon(build_icon(u':/general/general_revert.png'))
self.default_file_layout = QtGui.QHBoxLayout()
self.default_file_layout.setObjectName(u'default_file_layout')
self.default_file_layout.addWidget(self.default_file_edit)
self.default_file_layout.addWidget(self.default_browse_button)
self.default_file_layout.addWidget(self.default_revert_button)
self.default_image_layout.addRow(self.default_file_label, self.default_file_layout)
self.rightLayout.addWidget(self.default_image_group_box)
# Hide mouse
self.hideMouseGroupBox = QtGui.QGroupBox(self.rightColumn)
self.hideMouseGroupBox.setObjectName(u'hideMouseGroupBox')
self.hideMouseLayout = QtGui.QVBoxLayout(self.hideMouseGroupBox)
self.hideMouseLayout.setObjectName(u'hideMouseLayout')
self.hideMouseCheckBox = QtGui.QCheckBox(self.hideMouseGroupBox)
self.hideMouseCheckBox.setObjectName(u'hideMouseCheckBox')
self.hideMouseLayout.addWidget(self.hideMouseCheckBox)
self.rightLayout.addWidget(self.hideMouseGroupBox)
self.hide_mouse_group_box = QtGui.QGroupBox(self.rightColumn)
self.hide_mouse_group_box.setObjectName(u'hide_mouse_group_box')
self.hide_mouse_layout = QtGui.QVBoxLayout(self.hide_mouse_group_box)
self.hide_mouse_layout.setObjectName(u'hide_mouse_layout')
self.hide_mouse_check_box = QtGui.QCheckBox(self.hide_mouse_group_box)
self.hide_mouse_check_box.setObjectName(u'hide_mouse_check_box')
self.hide_mouse_layout.addWidget(self.hide_mouse_check_box)
self.rightLayout.addWidget(self.hide_mouse_group_box)
# Service Item Slide Limits
self.slideGroupBox = QtGui.QGroupBox(self.rightColumn)
self.slideGroupBox.setObjectName(u'slideGroupBox')
self.slideLayout = QtGui.QVBoxLayout(self.slideGroupBox)
self.slideLayout.setObjectName(u'slideLayout')
self.slideLabel = QtGui.QLabel(self.slideGroupBox)
self.slideLabel.setWordWrap(True)
self.slideLayout.addWidget(self.slideLabel)
self.endSlideRadioButton = QtGui.QRadioButton(self.slideGroupBox)
self.endSlideRadioButton.setObjectName(u'endSlideRadioButton')
self.slideLayout.addWidget(self.endSlideRadioButton)
self.wrapSlideRadioButton = QtGui.QRadioButton(self.slideGroupBox)
self.wrapSlideRadioButton.setObjectName(u'wrapSlideRadioButton')
self.slideLayout.addWidget(self.wrapSlideRadioButton)
self.nextItemRadioButton = QtGui.QRadioButton(self.slideGroupBox)
self.nextItemRadioButton.setObjectName(u'nextItemRadioButton')
self.slideLayout.addWidget(self.nextItemRadioButton)
self.rightLayout.addWidget(self.slideGroupBox)
self.slide_group_box = QtGui.QGroupBox(self.rightColumn)
self.slide_group_box.setObjectName(u'slide_group_box')
self.slide_layout = QtGui.QVBoxLayout(self.slide_group_box)
self.slide_layout.setObjectName(u'slide_layout')
self.slide_label = QtGui.QLabel(self.slide_group_box)
self.slide_label.setWordWrap(True)
self.slide_layout.addWidget(self.slide_label)
self.end_slide_radio_button = QtGui.QRadioButton(self.slide_group_box)
self.end_slide_radio_button.setObjectName(u'end_slide_radio_button')
self.slide_layout.addWidget(self.end_slide_radio_button)
self.wrap_slide_radio_button = QtGui.QRadioButton(self.slide_group_box)
self.wrap_slide_radio_button.setObjectName(u'wrap_slide_radio_button')
self.slide_layout.addWidget(self.wrap_slide_radio_button)
self.next_item_radio_button = QtGui.QRadioButton(self.slide_group_box)
self.next_item_radio_button.setObjectName(u'next_item_radio_button')
self.slide_layout.addWidget(self.next_item_radio_button)
self.rightLayout.addWidget(self.slide_group_box)
# Display Workarounds
self.displayWorkaroundGroupBox = QtGui.QGroupBox(self.leftColumn)
self.displayWorkaroundGroupBox.setObjectName(u'displayWorkaroundGroupBox')
self.displayWorkaroundLayout = QtGui.QVBoxLayout(self.displayWorkaroundGroupBox)
self.displayWorkaroundLayout.setObjectName(u'displayWorkaroundLayout')
self.x11BypassCheckBox = QtGui.QCheckBox(self.displayWorkaroundGroupBox)
self.x11BypassCheckBox.setObjectName(u'x11BypassCheckBox')
self.displayWorkaroundLayout.addWidget(self.x11BypassCheckBox)
self.alternateRowsCheckBox = QtGui.QCheckBox(self.displayWorkaroundGroupBox)
self.alternateRowsCheckBox.setObjectName(u'alternateRowsCheckBox')
self.displayWorkaroundLayout.addWidget(self.alternateRowsCheckBox)
self.rightLayout.addWidget(self.displayWorkaroundGroupBox)
self.display_workaround_group_box = QtGui.QGroupBox(self.leftColumn)
self.display_workaround_group_box.setObjectName(u'display_workaround_group_box')
self.display_workaround_layout = QtGui.QVBoxLayout(self.display_workaround_group_box)
self.display_workaround_layout.setObjectName(u'display_workaround_layout')
self.x11_bypass_check_box = QtGui.QCheckBox(self.display_workaround_group_box)
self.x11_bypass_check_box.setObjectName(u'x11_bypass_check_box')
self.display_workaround_layout.addWidget(self.x11_bypass_check_box)
self.alternate_rows_check_box = QtGui.QCheckBox(self.display_workaround_group_box)
self.alternate_rows_check_box.setObjectName(u'alternate_rows_check_box')
self.display_workaround_layout.addWidget(self.alternate_rows_check_box)
self.rightLayout.addWidget(self.display_workaround_group_box)
self.rightLayout.addStretch()
self.shouldUpdateServiceNameExample = False
QtCore.QObject.connect(self.serviceNameCheckBox, QtCore.SIGNAL(u'toggled(bool)'),
self.serviceNameCheckBoxToggled)
QtCore.QObject.connect(self.serviceNameDay, QtCore.SIGNAL(u'currentIndexChanged(int)'),
self.onServiceNameDayChanged)
QtCore.QObject.connect(self.serviceNameTime, QtCore.SIGNAL(u'timeChanged(QTime)'),
self.updateServiceNameExample)
QtCore.QObject.connect(self.serviceNameEdit, QtCore.SIGNAL(u'textChanged(QString)'),
self.updateServiceNameExample)
QtCore.QObject.connect(self.serviceNameRevertButton, QtCore.SIGNAL(u'clicked()'),
self.onServiceNameRevertButtonClicked)
QtCore.QObject.connect(self.defaultColorButton, QtCore.SIGNAL(u'clicked()'), self.onDefaultColorButtonClicked)
QtCore.QObject.connect(self.defaultBrowseButton, QtCore.SIGNAL(u'clicked()'), self.onDefaultBrowseButtonClicked)
QtCore.QObject.connect(self.defaultRevertButton, QtCore.SIGNAL(u'clicked()'), self.onDefaultRevertButtonClicked)
QtCore.QObject.connect(self.x11BypassCheckBox, QtCore.SIGNAL(u'toggled(bool)'), self.onX11BypassCheckBoxToggled)
QtCore.QObject.connect(self.alternateRowsCheckBox,
QtCore.SIGNAL(u'toggled(bool)'), self.onAlternateRowsCheckBoxToggled)
QtCore.QObject.connect(self.dataDirectoryBrowseButton, QtCore.SIGNAL(u'clicked()'),
self.onDataDirectoryBrowseButtonClicked)
QtCore.QObject.connect(self.dataDirectoryDefaultButton, QtCore.SIGNAL(u'clicked()'),
self.onDataDirectoryDefaultButtonClicked)
QtCore.QObject.connect(self.dataDirectoryCancelButton, QtCore.SIGNAL(u'clicked()'),
self.onDataDirectoryCancelButtonClicked)
QtCore.QObject.connect(self.dataDirectoryCopyCheckBox, QtCore.SIGNAL(u'toggled(bool)'),
self.onDataDirectoryCopyCheckBoxToggled)
QtCore.QObject.connect(self.endSlideRadioButton, QtCore.SIGNAL(u'clicked()'), self.onEndSlideButtonClicked)
QtCore.QObject.connect(self.wrapSlideRadioButton, QtCore.SIGNAL(u'clicked()'), self.onWrapSlideButtonClicked)
QtCore.QObject.connect(self.nextItemRadioButton, QtCore.SIGNAL(u'clicked()'), self.onnextItemButtonClicked)
self.should_update_service_name_example = False
QtCore.QObject.connect(self.service_name_check_box, QtCore.SIGNAL(u'toggled(bool)'),
self.service_name_check_box_toggled)
QtCore.QObject.connect(self.service_name_day, QtCore.SIGNAL(u'currentIndexChanged(int)'),
self.on_service_name_day_changed)
QtCore.QObject.connect(self.service_name_time, QtCore.SIGNAL(u'timeChanged(QTime)'),
self.update_service_name_example)
QtCore.QObject.connect(self.service_name_edit, QtCore.SIGNAL(u'textChanged(QString)'),
self.update_service_name_example)
QtCore.QObject.connect(self.service_name_revert_button, QtCore.SIGNAL(u'clicked()'),
self.on_service_name_revert_button_clicked)
QtCore.QObject.connect(self.default_color_button, QtCore.SIGNAL(u'clicked()'),
self.on_default_color_button_clicked)
QtCore.QObject.connect(self.default_browse_button, QtCore.SIGNAL(u'clicked()'),
self.on_default_browse_button_clicked)
QtCore.QObject.connect(self.default_revert_button, QtCore.SIGNAL(u'clicked()'),
self.on_default_revert_button_clicked)
QtCore.QObject.connect(self.x11_bypass_check_box, QtCore.SIGNAL(u'toggled(bool)'),
self.on_X11_bypass_check_box_toggled)
QtCore.QObject.connect(self.alternate_rows_check_box,QtCore.SIGNAL(u'toggled(bool)'),
self.on_alternate_rows_check_box_toggled)
QtCore.QObject.connect(self.data_directory_browse_button, QtCore.SIGNAL(u'clicked()'),
self.on_data_directory_browse_button_clicked)
QtCore.QObject.connect(self.data_directory_default_button, QtCore.SIGNAL(u'clicked()'),
self.on_data_directory_default_button_clicked)
QtCore.QObject.connect(self.data_directory_cancel_button, QtCore.SIGNAL(u'clicked()'),
self.on_data_directory_cancel_button_clicked)
QtCore.QObject.connect(self.data_directory_copy_check_box, QtCore.SIGNAL(u'toggled(bool)'),
self.on_data_directory_copy_check_box_toggled)
QtCore.QObject.connect(self.end_slide_radio_button, QtCore.SIGNAL(u'clicked()'),
self.on_end_slide_button_clicked)
QtCore.QObject.connect(self.wrap_slide_radio_button, QtCore.SIGNAL(u'clicked()'),
self.on_wrap_slide_button_clicked)
QtCore.QObject.connect(self.next_item_radio_button, QtCore.SIGNAL(u'clicked()'),
self.on_next_item_button_clicked)
def retranslateUi(self):
"""
Setup the interface translation strings.
"""
self.tabTitleVisible = UiStrings().Advanced
self.uiGroupBox.setTitle(translate('OpenLP.AdvancedTab', 'UI Settings'))
self.dataDirectoryGroupBox.setTitle(translate('OpenLP.AdvancedTab', 'Data Location'))
self.recentLabel.setText(translate('OpenLP.AdvancedTab', 'Number of recent files to display:'))
self.mediaPluginCheckBox.setText(translate('OpenLP.AdvancedTab',
self.ui_group_box.setTitle(translate('OpenLP.AdvancedTab', 'UI Settings'))
self.data_directory_group_box.setTitle(translate('OpenLP.AdvancedTab', 'Data Location'))
self.recent_label.setText(translate('OpenLP.AdvancedTab', 'Number of recent files to display:'))
self.media_plugin_check_box.setText(translate('OpenLP.AdvancedTab',
'Remember active media manager tab on startup'))
self.doubleClickLiveCheckBox.setText(translate('OpenLP.AdvancedTab',
self.double_click_live_check_box.setText(translate('OpenLP.AdvancedTab',
'Double-click to send items straight to live'))
self.singleClickPreviewCheckBox.setText(translate('OpenLP.AdvancedTab',
self.single_click_preview_check_box.setText(translate('OpenLP.AdvancedTab',
'Preview items when clicked in Media Manager'))
self.expandServiceItemCheckBox.setText(translate('OpenLP.AdvancedTab',
self.expand_service_item_check_box.setText(translate('OpenLP.AdvancedTab',
'Expand new service items on creation'))
self.enableAutoCloseCheckBox.setText(translate('OpenLP.AdvancedTab',
self.enable_auto_close_check_box.setText(translate('OpenLP.AdvancedTab',
'Enable application exit confirmation'))
self.serviceNameGroupBox.setTitle(translate('OpenLP.AdvancedTab', 'Default Service Name'))
self.serviceNameCheckBox.setText(translate('OpenLP.AdvancedTab', 'Enable default service name'))
self.serviceNameTimeLabel.setText(translate('OpenLP.AdvancedTab', 'Date and Time:'))
self.serviceNameDay.setItemText(0, translate('OpenLP.AdvancedTab', 'Monday'))
self.serviceNameDay.setItemText(1, translate('OpenLP.AdvancedTab', 'Tuesday'))
self.serviceNameDay.setItemText(2, translate('OpenLP.AdvancedTab', 'Wednesday'))
self.serviceNameDay.setItemText(3, translate('OpenLP.AdvancedTab', 'Thurdsday'))
self.serviceNameDay.setItemText(4, translate('OpenLP.AdvancedTab', 'Friday'))
self.serviceNameDay.setItemText(5, translate('OpenLP.AdvancedTab', 'Saturday'))
self.serviceNameDay.setItemText(6, translate('OpenLP.AdvancedTab', 'Sunday'))
self.serviceNameDay.setItemText(7, translate('OpenLP.AdvancedTab', 'Now'))
self.serviceNameTime.setToolTip(translate('OpenLP.AdvancedTab',
self.service_name_group_box.setTitle(translate('OpenLP.AdvancedTab', 'Default Service Name'))
self.service_name_check_box.setText(translate('OpenLP.AdvancedTab', 'Enable default service name'))
self.service_name_time_label.setText(translate('OpenLP.AdvancedTab', 'Date and Time:'))
self.service_name_day.setItemText(0, translate('OpenLP.AdvancedTab', 'Monday'))
self.service_name_day.setItemText(1, translate('OpenLP.AdvancedTab', 'Tuesday'))
self.service_name_day.setItemText(2, translate('OpenLP.AdvancedTab', 'Wednesday'))
self.service_name_day.setItemText(3, translate('OpenLP.AdvancedTab', 'Thurdsday'))
self.service_name_day.setItemText(4, translate('OpenLP.AdvancedTab', 'Friday'))
self.service_name_day.setItemText(5, translate('OpenLP.AdvancedTab', 'Saturday'))
self.service_name_day.setItemText(6, translate('OpenLP.AdvancedTab', 'Sunday'))
self.service_name_day.setItemText(7, translate('OpenLP.AdvancedTab', 'Now'))
self.service_name_time.setToolTip(translate('OpenLP.AdvancedTab',
'Time when usual service starts.'))
self.serviceNameLabel.setText(translate('OpenLP.AdvancedTab', 'Name:'))
self.serviceNameEdit.setToolTip(translate('OpenLP.AdvancedTab', 'Consult the OpenLP manual for usage.'))
self.serviceNameRevertButton.setToolTip(
translate('OpenLP.AdvancedTab', 'Revert to the default service name "%s".') % UiStrings().DefaultServiceName)
self.serviceNameExampleLabel.setText(translate('OpenLP.AdvancedTab', 'Example:'))
self.hideMouseGroupBox.setTitle(translate('OpenLP.AdvancedTab', 'Mouse Cursor'))
self.hideMouseCheckBox.setText(translate('OpenLP.AdvancedTab', 'Hide mouse cursor when over display window'))
self.defaultImageGroupBox.setTitle(translate('OpenLP.AdvancedTab', 'Default Image'))
self.defaultColorLabel.setText(translate('OpenLP.AdvancedTab', 'Background color:'))
self.defaultColorButton.setToolTip(translate('OpenLP.AdvancedTab', 'Click to select a color.'))
self.defaultFileLabel.setText(translate('OpenLP.AdvancedTab', 'Image file:'))
self.defaultBrowseButton.setToolTip(translate('OpenLP.AdvancedTab', 'Browse for an image file to display.'))
self.defaultRevertButton.setToolTip(translate('OpenLP.AdvancedTab', 'Revert to the default OpenLP logo.'))
self.dataDirectoryCurrentLabel.setText(translate('OpenLP.AdvancedTab', 'Current path:'))
self.dataDirectoryNewLabel.setText(translate('OpenLP.AdvancedTab', 'Custom path:'))
self.dataDirectoryBrowseButton.setToolTip(translate('OpenLP.AdvancedTab', 'Browse for new data file location.'))
self.dataDirectoryDefaultButton.setToolTip(
self.service_name_label.setText(translate('OpenLP.AdvancedTab', 'Name:'))
self.service_name_edit.setToolTip(translate('OpenLP.AdvancedTab', 'Consult the OpenLP manual for usage.'))
self.service_name_revert_button.setToolTip(
translate('OpenLP.AdvancedTab', 'Revert to the default service name "%s".') %
UiStrings().DefaultServiceName)
self.service_name_example_label.setText(translate('OpenLP.AdvancedTab', 'Example:'))
self.hide_mouse_group_box.setTitle(translate('OpenLP.AdvancedTab', 'Mouse Cursor'))
self.hide_mouse_check_box.setText(translate('OpenLP.AdvancedTab', 'Hide mouse cursor when over display window'))
self.default_image_group_box.setTitle(translate('OpenLP.AdvancedTab', 'Default Image'))
self.default_color_label.setText(translate('OpenLP.AdvancedTab', 'Background color:'))
self.default_color_button.setToolTip(translate('OpenLP.AdvancedTab', 'Click to select a color.'))
self.default_file_label.setText(translate('OpenLP.AdvancedTab', 'Image file:'))
self.default_browse_button.setToolTip(translate('OpenLP.AdvancedTab', 'Browse for an image file to display.'))
self.default_revert_button.setToolTip(translate('OpenLP.AdvancedTab', 'Revert to the default OpenLP logo.'))
self.data_directory_current_label.setText(translate('OpenLP.AdvancedTab', 'Current path:'))
self.data_directory_new_label.setText(translate('OpenLP.AdvancedTab', 'Custom path:'))
self.data_directory_browse_button.setToolTip(translate('OpenLP.AdvancedTab',
'Browse for new data file location.'))
self.data_directory_default_button.setToolTip(
translate('OpenLP.AdvancedTab', 'Set the data location to the default.'))
self.dataDirectoryCancelButton.setText(translate('OpenLP.AdvancedTab', 'Cancel'))
self.dataDirectoryCancelButton.setToolTip(
self.data_directory_cancel_button.setText(translate('OpenLP.AdvancedTab', 'Cancel'))
self.data_directory_cancel_button.setToolTip(
translate('OpenLP.AdvancedTab', 'Cancel OpenLP data directory location change.'))
self.dataDirectoryCopyCheckBox.setText(translate('OpenLP.AdvancedTab', 'Copy data to new location.'))
self.dataDirectoryCopyCheckBox.setToolTip(translate(
self.data_directory_copy_check_box.setText(translate('OpenLP.AdvancedTab', 'Copy data to new location.'))
self.data_directory_copy_check_box.setToolTip(translate(
'OpenLP.AdvancedTab', 'Copy the OpenLP data files to the new location.'))
self.newDataDirectoryHasFilesLabel.setText(
self.new_data_directory_has_files_label.setText(
translate('OpenLP.AdvancedTab', '<strong>WARNING:</strong> New data directory location contains '
'OpenLP data files. These files WILL be replaced during a copy.'))
self.displayWorkaroundGroupBox.setTitle(translate('OpenLP.AdvancedTab', 'Display Workarounds'))
self.x11BypassCheckBox.setText(translate('OpenLP.AdvancedTab','Bypass X11 Window Manager'))
self.alternateRowsCheckBox.setText(translate('OpenLP.AdvancedTab', 'Use alternating row colours in lists'))
self.display_workaround_group_box.setTitle(translate('OpenLP.AdvancedTab', 'Display Workarounds'))
self.x11_bypass_check_box.setText(translate('OpenLP.AdvancedTab','Bypass X11 Window Manager'))
self.alternate_rows_check_box.setText(translate('OpenLP.AdvancedTab', 'Use alternating row colours in lists'))
# Slide Limits
self.slideGroupBox.setTitle(translate('OpenLP.GeneralTab', 'Service Item Slide Limits'))
self.slideLabel.setText(translate('OpenLP.GeneralTab', 'Behavior of next/previous on the last/first slide:'))
self.endSlideRadioButton.setText(translate('OpenLP.GeneralTab', '&Remain on Slide'))
self.wrapSlideRadioButton.setText(translate('OpenLP.GeneralTab', '&Wrap around'))
self.nextItemRadioButton.setText(translate('OpenLP.GeneralTab', '&Move to next/previous service item'))
self.slide_group_box.setTitle(translate('OpenLP.GeneralTab', 'Service Item Slide Limits'))
self.slide_label.setText(translate('OpenLP.GeneralTab', 'Behavior of next/previous on the last/first slide:'))
self.end_slide_radio_button.setText(translate('OpenLP.GeneralTab', '&Remain on Slide'))
self.wrap_slide_radio_button.setText(translate('OpenLP.GeneralTab', '&Wrap around'))
self.next_item_radio_button.setText(translate('OpenLP.GeneralTab', '&Move to next/previous service item'))
def load(self):
"""
@ -348,44 +358,44 @@ class AdvancedTab(SettingsTab):
# The max recent files value does not have an interface and so never
# gets actually stored in the settings therefore the default value of
# 20 will always be used.
self.recentSpinBox.setMaximum(settings.value(u'max recent files'))
self.recentSpinBox.setValue(settings.value(u'recent file count'))
self.mediaPluginCheckBox.setChecked(settings.value(u'save current plugin'))
self.doubleClickLiveCheckBox.setChecked(settings.value(u'double click live'))
self.singleClickPreviewCheckBox.setChecked(settings.value(u'single click preview'))
self.expandServiceItemCheckBox.setChecked(settings.value(u'expand service item'))
self.enableAutoCloseCheckBox.setChecked(settings.value(u'enable exit confirmation'))
self.hideMouseCheckBox.setChecked(settings.value(u'hide mouse'))
self.serviceNameDay.setCurrentIndex(settings.value(u'default service day'))
self.serviceNameTime.setTime(QtCore.QTime(settings.value(u'default service hour'),
self.recent_spin_box.setMaximum(settings.value(u'max recent files'))
self.recent_spin_box.setValue(settings.value(u'recent file count'))
self.media_plugin_check_box.setChecked(settings.value(u'save current plugin'))
self.double_click_live_check_box.setChecked(settings.value(u'double click live'))
self.single_click_preview_check_box.setChecked(settings.value(u'single click preview'))
self.expand_service_item_check_box.setChecked(settings.value(u'expand service item'))
self.enable_auto_close_check_box.setChecked(settings.value(u'enable exit confirmation'))
self.hide_mouse_check_box.setChecked(settings.value(u'hide mouse'))
self.service_name_day.setCurrentIndex(settings.value(u'default service day'))
self.service_name_time.setTime(QtCore.QTime(settings.value(u'default service hour'),
settings.value(u'default service minute')))
self.shouldUpdateServiceNameExample = True
self.serviceNameEdit.setText(settings.value(u'default service name'))
self.should_update_service_name_example = True
self.service_name_edit.setText(settings.value(u'default service name'))
default_service_enabled = settings.value(u'default service enabled')
self.serviceNameCheckBox.setChecked(default_service_enabled)
self.serviceNameCheckBoxToggled(default_service_enabled)
self.x11BypassCheckBox.setChecked(settings.value(u'x11 bypass wm'))
self.defaultColor = settings.value(u'default color')
self.defaultFileEdit.setText(settings.value(u'default image'))
self.service_name_check_box.setChecked(default_service_enabled)
self.service_name_check_box_toggled(default_service_enabled)
self.x11_bypass_check_box.setChecked(settings.value(u'x11 bypass wm'))
self.default_color = settings.value(u'default color')
self.default_file_edit.setText(settings.value(u'default image'))
self.slide_limits = settings.value(u'slide limits')
# Prevent the dialog displayed by the alternateRowsCheckBox to display.
self.alternateRowsCheckBox.blockSignals(True)
self.alternateRowsCheckBox.setChecked(settings.value(u'alternate rows'))
self.alternateRowsCheckBox.blockSignals(False)
# Prevent the dialog displayed by the alternate_rows_check_box to display.
self.alternate_rows_check_box.blockSignals(True)
self.alternate_rows_check_box.setChecked(settings.value(u'alternate rows'))
self.alternate_rows_check_box.blockSignals(False)
if self.slide_limits == SlideLimits.End:
self.endSlideRadioButton.setChecked(True)
self.end_slide_radio_button.setChecked(True)
elif self.slide_limits == SlideLimits.Wrap:
self.wrapSlideRadioButton.setChecked(True)
self.wrap_slide_radio_button.setChecked(True)
else:
self.nextItemRadioButton.setChecked(True)
self.next_item_radio_button.setChecked(True)
settings.endGroup()
self.dataDirectoryCopyCheckBox.hide()
self.newDataDirectoryHasFilesLabel.hide()
self.dataDirectoryCancelButton.hide()
self.data_directory_copy_check_box.hide()
self.new_data_directory_has_files_label.hide()
self.data_directory_cancel_button.hide()
# Since data location can be changed, make sure the path is present.
self.currentDataPath = AppLocation.get_data_path()
if not os.path.exists(self.currentDataPath):
log.error(u'Data path not found %s' % self.currentDataPath)
self.current_data_path = AppLocation.get_data_path()
if not os.path.exists(self.current_data_path):
log.error(u'Data path not found %s' % self.current_data_path)
answer = QtGui.QMessageBox.critical(self,
translate('OpenLP.AdvancedTab',
'Data Directory Error'),
@ -397,10 +407,8 @@ class AdvancedTab(SettingsTab):
'Click "No" to stop loading OpenLP. allowing you to fix '
'the the problem.\n\n'
'Click "Yes" to reset the data directory to the default '
'location.').replace('%s', self.currentDataPath),
QtGui.QMessageBox.StandardButtons(
QtGui.QMessageBox.Yes |
QtGui.QMessageBox.No),
'location.').replace('%s', self.current_data_path),
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes | QtGui.QMessageBox.No),
QtGui.QMessageBox.No)
if answer == QtGui.QMessageBox.No:
log.info(u'User requested termination')
@ -408,13 +416,13 @@ class AdvancedTab(SettingsTab):
sys.exit()
# Set data location to default.
settings.remove(u'advanced/data path')
self.currentDataPath = AppLocation.get_data_path()
log.warning(u'User requested data path set to default %s' % self.currentDataPath)
self.dataDirectoryLabel.setText(os.path.abspath(self.currentDataPath))
self.defaultColorButton.setStyleSheet(u'background-color: %s' % self.defaultColor)
self.current_data_path = AppLocation.get_data_path()
log.warning(u'User requested data path set to default %s' % self.current_data_path)
self.data_directory_label.setText(os.path.abspath(self.current_data_path))
self.default_color_button.setStyleSheet(u'background-color: %s' % self.default_color)
# Don't allow data directory move if running portable.
if settings.value(u'advanced/is portable'):
self.dataDirectoryGroupBox.hide()
self.data_directory_group_box.hide()
def save(self):
"""
@ -422,101 +430,124 @@ class AdvancedTab(SettingsTab):
"""
settings = Settings()
settings.beginGroup(self.settingsSection)
settings.setValue(u'default service enabled', self.serviceNameCheckBox.isChecked())
service_name = self.serviceNameEdit.text()
preset_is_valid = self.generateServiceNameExample()[0]
settings.setValue(u'default service enabled', self.service_name_check_box.isChecked())
service_name = self.service_name_edit.text()
preset_is_valid = self.generate_service_name_example()[0]
if service_name == UiStrings().DefaultServiceName or not preset_is_valid:
settings.remove(u'default service name')
self.serviceNameEdit.setText(service_name)
self.service_name_edit.setText(service_name)
else:
settings.setValue(u'default service name', service_name)
settings.setValue(u'default service day', self.serviceNameDay.currentIndex())
settings.setValue(u'default service hour', self.serviceNameTime.time().hour())
settings.setValue(u'default service minute', self.serviceNameTime.time().minute())
settings.setValue(u'recent file count', self.recentSpinBox.value())
settings.setValue(u'save current plugin', self.mediaPluginCheckBox.isChecked())
settings.setValue(u'double click live', self.doubleClickLiveCheckBox.isChecked())
settings.setValue(u'single click preview', self.singleClickPreviewCheckBox.isChecked())
settings.setValue(u'expand service item', self.expandServiceItemCheckBox.isChecked())
settings.setValue(u'enable exit confirmation', self.enableAutoCloseCheckBox.isChecked())
settings.setValue(u'hide mouse', self.hideMouseCheckBox.isChecked())
settings.setValue(u'x11 bypass wm', self.x11BypassCheckBox.isChecked())
settings.setValue(u'alternate rows', self.alternateRowsCheckBox.isChecked())
settings.setValue(u'default color', self.defaultColor)
settings.setValue(u'default image', self.defaultFileEdit.text())
settings.setValue(u'default service day', self.service_name_day.currentIndex())
settings.setValue(u'default service hour', self.service_name_time.time().hour())
settings.setValue(u'default service minute', self.service_name_time.time().minute())
settings.setValue(u'recent file count', self.recent_spin_box.value())
settings.setValue(u'save current plugin', self.media_plugin_check_box.isChecked())
settings.setValue(u'double click live', self.double_click_live_check_box.isChecked())
settings.setValue(u'single click preview', self.single_click_preview_check_box.isChecked())
settings.setValue(u'expand service item', self.expand_service_item_check_box.isChecked())
settings.setValue(u'enable exit confirmation', self.enable_auto_close_check_box.isChecked())
settings.setValue(u'hide mouse', self.hide_mouse_check_box.isChecked())
settings.setValue(u'x11 bypass wm', self.x11_bypass_check_box.isChecked())
settings.setValue(u'alternate rows', self.alternate_rows_check_box.isChecked())
settings.setValue(u'default color', self.default_color)
settings.setValue(u'default image', self.default_file_edit.text())
settings.setValue(u'slide limits', self.slide_limits)
settings.endGroup()
if self.displayChanged:
if self.display_changed:
Receiver.send_message(u'config_screen_changed')
self.displayChanged = False
self.display_changed = False
Receiver.send_message(u'slidecontroller_update_slide_limits')
def cancel(self):
"""
Cancel Pressed.
"""
# Dialogue was cancelled, remove any pending data path change.
self.onDataDirectoryCancelButtonClicked()
self.on_data_directory_cancel_button_clicked()
SettingsTab.cancel(self)
def serviceNameCheckBoxToggled(self, default_service_enabled):
self.serviceNameDay.setEnabled(default_service_enabled)
time_enabled = default_service_enabled and self.serviceNameDay.currentIndex() is not 7
self.serviceNameTime.setEnabled(time_enabled)
self.serviceNameEdit.setEnabled(default_service_enabled)
self.serviceNameRevertButton.setEnabled(default_service_enabled)
def service_name_check_box_toggled(self, default_service_enabled):
"""
Service Name options changed
"""
self.service_name_day.setEnabled(default_service_enabled)
time_enabled = default_service_enabled and self.service_name_day.currentIndex() is not 7
self.service_name_time.setEnabled(time_enabled)
self.service_name_edit.setEnabled(default_service_enabled)
self.service_name_revert_button.setEnabled(default_service_enabled)
def generateServiceNameExample(self):
def generate_service_name_example(self):
"""
Display an example of the template used
"""
preset_is_valid = True
if self.serviceNameDay.currentIndex() == 7:
if self.service_name_day.currentIndex() == 7:
local_time = datetime.now()
else:
now = datetime.now()
day_delta = self.serviceNameDay.currentIndex() - now.weekday()
day_delta = self.service_name_day.currentIndex() - now.weekday()
if day_delta < 0:
day_delta += 7
time = now + timedelta(days=day_delta)
local_time = time.replace(hour = self.serviceNameTime.time().hour(),
minute = self.serviceNameTime.time().minute())
local_time = time.replace(hour = self.service_name_time.time().hour(),
minute = self.service_name_time.time().minute())
try:
service_name_example = format_time(unicode(self.serviceNameEdit.text()), local_time)
service_name_example = format_time(unicode(self.service_name_edit.text()), local_time)
except ValueError:
preset_is_valid = False
service_name_example = translate('OpenLP.AdvancedTab', 'Syntax error.')
return preset_is_valid, service_name_example
def updateServiceNameExample(self, returned_value):
if not self.shouldUpdateServiceNameExample:
def update_service_name_example(self, returned_value):
"""
Example Updated
"""
if not self.should_update_service_name_example:
return
name_example = self.generateServiceNameExample()[1]
self.serviceNameExample.setText(name_example)
name_example = self.generate_service_name_example()[1]
self.service_name_example.setText(name_example)
def onServiceNameDayChanged(self, service_day):
self.serviceNameTime.setEnabled(service_day is not 7)
self.updateServiceNameExample(None)
def on_service_name_day_changed(self, service_day):
"""
Service Name day changed
"""
self.service_name_time.setEnabled(service_day is not 7)
self.update_service_name_example(None)
def onServiceNameRevertButtonClicked(self):
self.serviceNameEdit.setText(UiStrings().DefaultServiceName)
self.serviceNameEdit.setFocus()
def on_service_name_revert_button_clicked(self):
"""
Service Name reverted
"""
self.service_name_edit.setText(UiStrings().DefaultServiceName)
self.service_name_edit.setFocus()
def onDefaultColorButtonClicked(self):
def on_default_color_button_clicked(self):
"""
Changed the default color
"""
new_color = QtGui.QColorDialog.getColor(
QtGui.QColor(self.defaultColor), self)
QtGui.QColor(self.default_color), self)
if new_color.isValid():
self.defaultColor = new_color.name()
self.defaultColorButton.setStyleSheet(u'background-color: %s' % self.defaultColor)
self.default_color = new_color.name()
self.default_color_button.setStyleSheet(u'background-color: %s' % self.default_color)
def onDefaultBrowseButtonClicked(self):
file_filters = u'%s;;%s (*.*) (*)' % (get_images_filter(),
UiStrings().AllFiles)
def on_default_browse_button_clicked(self):
"""
Service Name options changed
"""
file_filters = u'%s;;%s (*.*) (*)' % (get_images_filter(), UiStrings().AllFiles)
filename = QtGui.QFileDialog.getOpenFileName(self,
translate('OpenLP.AdvancedTab', 'Open File'), '', file_filters)
if filename:
self.defaultFileEdit.setText(filename)
self.defaultFileEdit.setFocus()
self.default_file_edit.setText(filename)
self.default_file_edit.setFocus()
def onDataDirectoryBrowseButtonClicked(self):
def on_data_directory_browse_button_clicked(self):
"""
Browse for a new data directory location.
"""
old_root_path = unicode(self.dataDirectoryLabel.text())
old_root_path = unicode(self.data_directory_label.text())
# Get the new directory location.
new_data_path = QtGui.QFileDialog.getExistingDirectory(self,
translate('OpenLP.AdvancedTab', 'Select Data Directory Location'), old_root_path,
@ -524,8 +555,8 @@ class AdvancedTab(SettingsTab):
# Set the new data path.
if new_data_path:
new_data_path = os.path.normpath(new_data_path)
if self.currentDataPath.lower() == new_data_path.lower():
self.onDataDirectoryCancelButtonClicked()
if self.current_data_path.lower() == new_data_path.lower():
self.on_data_directory_cancel_button_clicked()
return
else:
return
@ -539,18 +570,18 @@ class AdvancedTab(SettingsTab):
if answer != QtGui.QMessageBox.Yes:
return
# Check if data already exists here.
self.checkDataOverwrite(new_data_path)
self.check_data_overwrite(new_data_path)
# Save the new location.
Receiver.send_message(u'set_new_data_path', new_data_path)
self.newDataDirectoryEdit.setText(new_data_path)
self.dataDirectoryCancelButton.show()
self.new_data_directory_edit.setText(new_data_path)
self.data_directory_cancel_button.show()
def onDataDirectoryDefaultButtonClicked(self):
def on_data_directory_default_button_clicked(self):
"""
Re-set the data directory location to the 'default' location.
"""
new_data_path = AppLocation.get_directory(AppLocation.DataDir)
if self.currentDataPath.lower() != new_data_path.lower():
if self.current_data_path.lower() != new_data_path.lower():
# Make sure they want to change the data location back to the
# default.
answer = QtGui.QMessageBox.question(self,
@ -560,29 +591,35 @@ class AdvancedTab(SettingsTab):
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes | QtGui.QMessageBox.No), QtGui.QMessageBox.No)
if answer != QtGui.QMessageBox.Yes:
return
self.checkDataOverwrite(new_data_path)
self.check_data_overwrite(new_data_path)
# Save the new location.
Receiver.send_message(u'set_new_data_path', new_data_path)
self.newDataDirectoryEdit.setText(os.path.abspath(new_data_path))
self.dataDirectoryCancelButton.show()
self.new_data_directory_edit.setText(os.path.abspath(new_data_path))
self.data_directory_cancel_button.show()
else:
# We cancel the change in case user changed their mind.
self.onDataDirectoryCancelButtonClicked()
self.on_data_directory_cancel_button_clicked()
def onDataDirectoryCopyCheckBoxToggled(self):
def on_data_directory_copy_check_box_toggled(self):
"""
Service Name options changed
"""
Receiver.send_message(u'set_copy_data',
self.dataDirectoryCopyCheckBox.isChecked())
if self.dataExists:
if self.dataDirectoryCopyCheckBox.isChecked():
self.newDataDirectoryHasFilesLabel.show()
self.data_directory_copy_check_box.isChecked())
if self.data_exists:
if self.data_directory_copy_check_box.isChecked():
self.new_data_directory_has_files_label.show()
else:
self.newDataDirectoryHasFilesLabel.hide()
self.new_data_directory_has_files_label.hide()
def checkDataOverwrite(self, data_path ):
def check_data_overwrite(self, data_path ):
"""
Service Name options changed
"""
test_path = os.path.join(data_path, u'songs')
self.dataDirectoryCopyCheckBox.show()
self.data_directory_copy_check_box.show()
if os.path.exists(test_path):
self.dataExists = True
self.data_exists = True
# Check is they want to replace existing data.
answer = QtGui.QMessageBox.warning(self,
translate('OpenLP.AdvancedTab', 'Overwrite Existing Data'),
@ -591,42 +628,45 @@ class AdvancedTab(SettingsTab):
).replace('%s', os.path.abspath(data_path,)),
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes | QtGui.QMessageBox.No), QtGui.QMessageBox.No)
if answer == QtGui.QMessageBox.Yes:
self.dataDirectoryCopyCheckBox.setChecked(True)
self.newDataDirectoryHasFilesLabel.show()
self.data_directory_copy_check_box.setChecked(True)
self.new_data_directory_has_files_label.show()
else:
self.dataDirectoryCopyCheckBox.setChecked(False)
self.newDataDirectoryHasFilesLabel.hide()
self.data_directory_copy_check_box.setChecked(False)
self.new_data_directory_has_files_label.hide()
else:
self.dataExists = False
self.dataDirectoryCopyCheckBox.setChecked(True)
self.newDataDirectoryHasFilesLabel.hide()
self.data_exists = False
self.data_directory_copy_check_box.setChecked(True)
self.new_data_directory_has_files_label.hide()
def onDataDirectoryCancelButtonClicked(self):
def on_data_directory_cancel_button_clicked(self):
"""
Cancel the data directory location change
"""
self.newDataDirectoryEdit.clear()
self.dataDirectoryCopyCheckBox.setChecked(False)
self.new_data_directory_edit.clear()
self.data_directory_copy_check_box.setChecked(False)
Receiver.send_message(u'set_new_data_path', u'')
Receiver.send_message(u'set_copy_data', False)
self.dataDirectoryCopyCheckBox.hide()
self.dataDirectoryCancelButton.hide()
self.newDataDirectoryHasFilesLabel.hide()
self.data_directory_copy_check_box.hide()
self.data_directory_cancel_button.hide()
self.new_data_directory_has_files_label.hide()
def onDefaultRevertButtonClicked(self):
self.defaultFileEdit.setText(u':/graphics/openlp-splash-screen.png')
self.defaultFileEdit.setFocus()
def on_default_revert_button_clicked(self):
"""
Service Name options changed
"""
self.default_file_edit.setText(u':/graphics/openlp-splash-screen.png')
self.default_file_edit.setFocus()
def onX11BypassCheckBoxToggled(self, checked):
def on_X11_bypass_check_box_toggled(self, checked):
"""
Toggle X11 bypass flag on maindisplay depending on check box state.
``checked``
The state of the check box (boolean).
"""
self.displayChanged = True
self.display_changed = True
def onAlternateRowsCheckBoxToggled(self, checked):
def on_alternate_rows_check_box_toggled(self, checked):
"""
Notify user about required restart.
@ -637,11 +677,20 @@ class AdvancedTab(SettingsTab):
translate('OpenLP.AdvancedTab', 'Restart Required'),
translate('OpenLP.AdvancedTab', 'This change will only take effect once OpenLP has been restarted.'))
def onEndSlideButtonClicked(self):
def on_end_slide_button_clicked(self):
"""
Stop at the end either top ot bottom
"""
self.slide_limits = SlideLimits.End
def onWrapSlideButtonClicked(self):
def on_wrap_slide_button_clicked(self):
"""
Wrap round the service item
"""
self.slide_limits = SlideLimits.Wrap
def onnextItemButtonClicked(self):
def on_next_item_button_clicked(self):
"""
Advance to the next service item
"""
self.slide_limits = SlideLimits.Next

View File

@ -39,7 +39,7 @@ from ConfigParser import SafeConfigParser
from PyQt4 import QtCore, QtGui
from openlp.core.lib import translate, PluginStatus, Receiver, build_icon, check_directory_exists, Settings
from openlp.core.lib import translate, PluginStatus, Receiver, build_icon, check_directory_exists, Settings, Registry
from openlp.core.utils import get_web_page, AppLocation, get_filesystem_encoding
from firsttimewizard import Ui_FirstTimeWizard, FirstTimePage
@ -198,7 +198,7 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard):
self.themeComboBox.addItem(item.text())
if self.hasRunWizard:
# Add any existing themes to list.
for theme in self.parent().themeManagerContents.getThemes():
for theme in self.theme_manager.get_themes():
index = self.themeComboBox.findText(theme)
if index == -1:
self.themeComboBox.addItem(theme)
@ -461,3 +461,13 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard):
def _setPluginStatus(self, field, tag):
status = PluginStatus.Active if field.checkState() == QtCore.Qt.Checked else PluginStatus.Inactive
Settings().setValue(tag, status)
def _get_theme_manager(self):
"""
Adds the theme manager to the class dynamically
"""
if not hasattr(self, u'_theme_manager'):
self._theme_manager = Registry().get(u'theme_manager')
return self._theme_manager
theme_manager = property(_get_theme_manager)

View File

@ -496,9 +496,9 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
self.copyData = False
# Set up signals and slots
QtCore.QObject.connect(self.importThemeItem, QtCore.SIGNAL(u'triggered()'),
self.themeManagerContents.onImportTheme)
self.themeManagerContents.on_import_theme)
QtCore.QObject.connect(self.exportThemeItem, QtCore.SIGNAL(u'triggered()'),
self.themeManagerContents.onExportTheme)
self.themeManagerContents.on_export_theme)
QtCore.QObject.connect(self.mediaManagerDock, QtCore.SIGNAL(u'visibilityChanged(bool)'),
self.viewMediaManagerItem.setChecked)
QtCore.QObject.connect(self.serviceManagerDock, QtCore.SIGNAL(u'visibilityChanged(bool)'),
@ -576,9 +576,9 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
self.settingsForm.postSetUp()
# Once all components are initialised load the Themes
log.info(u'Load Themes')
self.themeManagerContents.loadThemes(True)
self.themeManagerContents.load_themes(True)
# Hide/show the theme combobox on the service manager
self.serviceManagerContents.themeChange()
self.serviceManagerContents.theme_change()
# Reset the cursor
Receiver.send_message(u'cursor_normal')
@ -687,7 +687,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
else:
self.activePlugin.toggleStatus(PluginStatus.Inactive)
self.themeManagerContents.configUpdated()
self.themeManagerContents.loadThemes(True)
self.themeManagerContents.load_themes(True)
Receiver.send_message(u'theme_update_global', self.themeManagerContents.global_theme)
# Check if any Bibles downloaded. If there are, they will be
# processed.
@ -760,7 +760,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
"""
Updates the new theme preview images.
"""
self.themeManagerContents.updatePreviewImages()
self.themeManagerContents.update_preview_images()
def onFormattingTagItemClicked(self):
"""
@ -1040,7 +1040,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
while self.imageManager.imageThread.isRunning():
time.sleep(0.1)
# Clean temporary files used by services
self.serviceManagerContents.cleanUp()
self.serviceManagerContents.clean_up()
if save_settings:
if Settings().value(u'advanced/save current plugin'):
Settings().setValue(u'advanced/current media plugin', self.mediaToolBox.currentIndex())

View File

@ -45,10 +45,8 @@ class PlayerTab(SettingsTab):
"""
MediaTab is the Media settings tab in the settings dialog.
"""
def __init__(self, parent, mainWindow):
self.parent = parent
self.mainWindow = mainWindow
self.mediaPlayers = mainWindow.mediaController.mediaPlayers
def __init__(self, parent):
self.mediaPlayers = self.media_controller.mediaPlayers
self.savedUsedPlayers = None
self.iconPath = u':/media/multimedia-player.png'
player_translated = translate('OpenLP.PlayerTab', 'Players')
@ -194,7 +192,7 @@ class PlayerTab(SettingsTab):
set_media_players(self.usedPlayers, override_player)
player_string_changed = True
if player_string_changed:
self.parent.reset_supported_suffixes()
self.service_manager.reset_supported_suffixes()
Receiver.send_message(u'mediaitem_media_rebuild')
Receiver.send_message(u'config_screen_changed')

View File

@ -95,14 +95,19 @@ class ServiceManagerList(QtGui.QTreeWidget):
class ServiceManagerDialog(object):
"""
UI part of the Service Manager
"""
def setup_ui(self, widget):
"""
Define the UI
"""
# Create the top toolbar
self.toolbar = OpenLPToolbar(self)
self.toolbar.addToolbarAction(u'newService', text=UiStrings().NewService, icon=u':/general/general_new.png',
tooltip=UiStrings().CreateService, triggers=self.on_new_service_clicked)
self.toolbar.addToolbarAction(u'openService', text=UiStrings().OpenService, icon=u':/general/general_open.png',
tooltip=translate('OpenLP.ServiceManager', 'Load an existing service.'), triggers=self.on_load_service_clicked)
tooltip=translate('OpenLP.ServiceManager', 'Load an existing service.'),
triggers=self.on_load_service_clicked)
self.toolbar.addToolbarAction(u'saveService', text=UiStrings().SaveService, icon=u':/general/general_save.png',
tooltip=translate('OpenLP.ServiceManager', 'Save this service.'), triggers=self.decide_save_method)
self.toolbar.addSeparator()
@ -185,7 +190,8 @@ class ServiceManagerDialog(object):
self.service_manager_list.make_live = self.order_toolbar.addToolbarAction(u'make_live',
text=translate('OpenLP.ServiceManager', 'Go Live'), icon=u':/general/general_live.png',
tooltip=translate('OpenLP.ServiceManager', 'Send the selected item to Live.'),
shortcuts=[QtCore.Qt.Key_Enter, QtCore.Qt.Key_Return], category=UiStrings().Service, triggers=self.make_live)
shortcuts=[QtCore.Qt.Key_Enter, QtCore.Qt.Key_Return], category=UiStrings().Service,
triggers=self.make_live)
self.layout.addWidget(self.order_toolbar)
# Connect up our signals and slots
QtCore.QObject.connect(self.theme_combo_box, QtCore.SIGNAL(u'activated(int)'),
@ -206,8 +212,9 @@ class ServiceManagerDialog(object):
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'config_updated'), self.config_updated)
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'config_screen_changed'),
self.regenerate_service_Items)
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'theme_update_global'), self.themeChange)
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'service_item_update'), self.serviceItemUpdate)
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'theme_update_global'), self.theme_change)
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'service_item_update'),
self.service_item_update)
# Last little bits of setting up
self.service_theme = Settings().value(self.main_window.serviceManagerSettingsSection + u'/service theme')
self.servicePath = AppLocation.get_section_data_path(u'servicemanager')
@ -560,7 +567,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog):
if success:
try:
shutil.copy(temp_file_name, path_file_name)
except:
except shutil.Error:
return self.save_file_as()
self.main_window.addRecentFile(path_file_name)
self.set_modified(False)
@ -618,7 +625,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog):
if success:
try:
shutil.copy(temp_file_name, path_file_name)
except:
except shutil.Error:
return self.save_file_as()
self.main_window.addRecentFile(path_file_name)
self.set_modified(False)
@ -697,7 +704,8 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog):
try:
ucsfile = zip_info.filename.decode(u'utf-8')
except UnicodeDecodeError:
log.exception(u'file_name "%s" is not valid UTF-8' % zip_info.file_name.decode(u'utf-8', u'replace'))
log.exception(u'file_name "%s" is not valid UTF-8' %
zip_info.file_name.decode(u'utf-8', u'replace'))
critical_error_message_box(message=translate('OpenLP.ServiceManager',
'File is not a valid service.\n The content encoding is not UTF-8.'))
continue
@ -809,7 +817,8 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog):
delay_suffix = u' %s s' % unicode(service_item[u'service_item'].timed_slide_interval)
else:
delay_suffix = u' ...'
self.timed_slide_interval.setText(translate('OpenLP.ServiceManager', '&Delay between slides') + delay_suffix)
self.timed_slide_interval.setText(translate('OpenLP.ServiceManager', '&Delay between slides') +
delay_suffix)
# TODO for future: make group explains itself more visually
else:
self.auto_play_slides_group.menuAction().setVisible(False)
@ -1201,13 +1210,13 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog):
self.service_manager_list.setCurrentItem(treewidgetitem)
treewidgetitem.setExpanded(item[u'expanded'])
def cleanUp(self):
def clean_up(self):
"""
Empties the servicePath of temporary files on system exit.
"""
log.debug(u'Cleaning up servicePath')
for file in os.listdir(self.servicePath):
file_path = os.path.join(self.servicePath, file)
for file_name in os.listdir(self.servicePath):
file_path = os.path.join(self.servicePath, file_name)
delete_file(file_path)
if os.path.exists(os.path.join(self.servicePath, u'audio')):
shutil.rmtree(os.path.join(self.servicePath, u'audio'), True)
@ -1222,12 +1231,12 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog):
Settings().setValue(self.main_window.serviceManagerSettingsSection + u'/service theme', self.service_theme)
self.regenerate_service_Items(True)
def themeChange(self):
def theme_change(self):
"""
The theme may have changed in the settings dialog so make
sure the theme combo box is in the correct state.
"""
log.debug(u'themeChange')
log.debug(u'theme_change')
visible = self.renderer.theme_level == ThemeLevel.Global
self.theme_label.setVisible(visible)
self.theme_combo_box.setVisible(visible)
@ -1271,7 +1280,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog):
self.repaint_service_list(-1, -1)
Receiver.send_message(u'cursor_normal')
def serviceItemUpdate(self, message):
def service_item_update(self, message):
"""
Triggered from plugins to update service items.
Save the values as they will be used as part of the service load
@ -1406,7 +1415,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog):
"""
Triggers a remote edit to a plugin to allow item to be edited.
"""
item, child = self.find_service_item()
item = self.find_service_item()[0]
if self.service_items[item][u'service_item'].is_capable(ItemCapabilities.CanEdit):
new_item = Registry().get(self.service_items[item][u'service_item'].name). \
onRemoteEdit(self.service_items[item][u'service_item'].edit_id)

View File

@ -54,11 +54,11 @@ class SettingsForm(QtGui.QDialog, Ui_SettingsDialog):
# General tab
self.generalTab = GeneralTab(self)
# Themes tab
self.themesTab = ThemesTab(self, self.main_window)
self.themesTab = ThemesTab(self)
# Advanced tab
self.advancedTab = AdvancedTab(self)
# Advanced tab
self.playerTab = PlayerTab(self, self.main_window)
self.playerTab = PlayerTab(self)
def exec_(self):
# load all the settings

View File

@ -32,7 +32,7 @@ import os
from PyQt4 import QtCore, QtGui
from openlp.core.lib import Receiver, translate, UiStrings
from openlp.core.lib import Receiver, translate, UiStrings, Registry
from openlp.core.lib.theme import BackgroundType, BackgroundGradientType
from openlp.core.lib.ui import critical_error_message_box
from openlp.core.ui import ThemeLayoutForm
@ -56,7 +56,6 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard):
The QWidget-derived parent of the wizard.
"""
QtGui.QWizard.__init__(self, parent)
self.thememanager = parent
self.setupUi(self)
self.registerFields()
self.updateThemeAllowed = True
@ -149,7 +148,7 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard):
# Do not trigger on start up
if self.currentPage != self.welcomePage:
self.updateTheme()
self.thememanager.generateImage(self.theme, True)
self.theme_manager.generate_image(self.theme, True)
def updateLinesText(self, lines):
"""
@ -196,7 +195,7 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard):
self.setOption(QtGui.QWizard.HaveCustomButton1, enabled)
if self.page(pageId) == self.previewPage:
self.updateTheme()
frame = self.thememanager.generateImage(self.theme)
frame = self.theme_manager.generate_image(self.theme)
self.previewBoxLabel.setPixmap(frame)
self.displayAspectRatio = float(frame.width()) / frame.height()
self.resizeEvent()
@ -206,15 +205,15 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard):
Generate layout preview and display the form.
"""
self.updateTheme()
width = self.thememanager.mainwindow.renderer.width
height = self.thememanager.mainwindow.renderer.height
width = self.renderer.width
height = self.renderer.height
pixmap = QtGui.QPixmap(width, height)
pixmap.fill(QtCore.Qt.white)
paint = QtGui.QPainter(pixmap)
paint.setPen(QtGui.QPen(QtCore.Qt.blue, 2))
paint.drawRect(self.thememanager.mainwindow.renderer.get_main_rectangle(self.theme))
paint.drawRect(self.renderer.get_main_rectangle(self.theme))
paint.setPen(QtGui.QPen(QtCore.Qt.red, 2))
paint.drawRect(self.thememanager.mainwindow.renderer.get_footer_rectangle(self.theme))
paint.drawRect(self.renderer.get_footer_rectangle(self.theme))
paint.end()
self.themeLayoutForm.exec_(pixmap)
@ -514,9 +513,9 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard):
filename = os.path.split(unicode(self.theme.background_filename))[1]
saveTo = os.path.join(self.path, self.theme.theme_name, filename)
saveFrom = self.theme.background_filename
if not self.edit_mode and not self.thememanager.checkIfThemeExists(self.theme.theme_name):
if not self.edit_mode and not self.theme_manager.check_if_theme_exists(self.theme.theme_name):
return
self.thememanager.saveTheme(self.theme, saveFrom, saveTo)
self.theme_manager.save_theme(self.theme, saveFrom, saveTo)
return QtGui.QDialog.accept(self)
def _colorButton(self, field):
@ -527,3 +526,23 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard):
if new_color.isValid():
field = new_color.name()
return field
def _get_renderer(self):
"""
Adds the Renderer to the class dynamically
"""
if not hasattr(self, u'_renderer'):
self._renderer = Registry().get(u'renderer')
return self._renderer
renderer = property(_get_renderer)
def _get_theme_manager(self):
"""
Adds the theme manager to the class dynamically
"""
if not hasattr(self, u'_theme_manager'):
self._theme_manager = Registry().get(u'theme_manager')
return self._theme_manager
theme_manager = property(_get_theme_manager)

View File

@ -72,67 +72,67 @@ class ThemeManager(QtGui.QWidget):
text=translate('OpenLP.ThemeManager', 'Edit Theme'),
icon=u':/themes/theme_edit.png',
tooltip=translate('OpenLP.ThemeManager', 'Edit a theme.'),
triggers=self.onEditTheme)
self.deleteToolbarAction = self.toolbar.addToolbarAction(u'deleteTheme',
triggers=self.on_edit_theme)
self.deleteToolbarAction = self.toolbar.addToolbarAction(u'delete_theme',
text=translate('OpenLP.ThemeManager', 'Delete Theme'),
icon=u':/general/general_delete.png',
tooltip=translate('OpenLP.ThemeManager', 'Delete a theme.'),
triggers=self.onDeleteTheme)
triggers=self.on_delete_theme)
self.toolbar.addSeparator()
self.toolbar.addToolbarAction(u'importTheme',
text=translate('OpenLP.ThemeManager', 'Import Theme'),
icon=u':/general/general_import.png',
tooltip=translate('OpenLP.ThemeManager', 'Import a theme.'),
triggers=self.onImportTheme)
triggers=self.on_import_theme)
self.toolbar.addToolbarAction(u'exportTheme',
text=translate('OpenLP.ThemeManager', 'Export Theme'),
icon=u':/general/general_export.png',
tooltip=translate('OpenLP.ThemeManager', 'Export a theme.'),
triggers=self.onExportTheme)
triggers=self.on_export_theme)
self.layout.addWidget(self.toolbar)
self.themeWidget = QtGui.QWidgetAction(self.toolbar)
self.themeWidget.setObjectName(u'themeWidget')
self.theme_widget = QtGui.QWidgetAction(self.toolbar)
self.theme_widget.setObjectName(u'theme_widget')
# create theme manager list
self.themeListWidget = QtGui.QListWidget(self)
self.themeListWidget.setAlternatingRowColors(True)
self.themeListWidget.setIconSize(QtCore.QSize(88, 50))
self.themeListWidget.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
self.themeListWidget.setObjectName(u'themeListWidget')
self.layout.addWidget(self.themeListWidget)
QtCore.QObject.connect(self.themeListWidget, QtCore.SIGNAL('customContextMenuRequested(QPoint)'),
self.contextMenu)
self.theme_list_widget = QtGui.QListWidget(self)
self.theme_list_widget.setAlternatingRowColors(True)
self.theme_list_widget.setIconSize(QtCore.QSize(88, 50))
self.theme_list_widget.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
self.theme_list_widget.setObjectName(u'theme_list_widget')
self.layout.addWidget(self.theme_list_widget)
QtCore.QObject.connect(self.theme_list_widget, QtCore.SIGNAL('customContextMenuRequested(QPoint)'),
self.context_menu)
# build the context menu
self.menu = QtGui.QMenu()
self.editAction = create_widget_action(self.menu,
self.edit_action = create_widget_action(self.menu,
text=translate('OpenLP.ThemeManager', '&Edit Theme'),
icon=u':/themes/theme_edit.png', triggers=self.onEditTheme)
self.copyAction = create_widget_action(self.menu,
icon=u':/themes/theme_edit.png', triggers=self.on_edit_theme)
self.copy_action = create_widget_action(self.menu,
text=translate('OpenLP.ThemeManager', '&Copy Theme'),
icon=u':/themes/theme_edit.png', triggers=self.onCopyTheme)
self.renameAction = create_widget_action(self.menu,
icon=u':/themes/theme_edit.png', triggers=self.on_copy_theme)
self.rename_action = create_widget_action(self.menu,
text=translate('OpenLP.ThemeManager', '&Rename Theme'),
icon=u':/themes/theme_edit.png', triggers=self.onRenameTheme)
self.deleteAction = create_widget_action(self.menu,
icon=u':/themes/theme_edit.png', triggers=self.on_rename_theme)
self.delete_action = create_widget_action(self.menu,
text=translate('OpenLP.ThemeManager', '&Delete Theme'),
icon=u':/general/general_delete.png', triggers=self.onDeleteTheme)
icon=u':/general/general_delete.png', triggers=self.on_delete_theme)
self.menu.addSeparator()
self.globalAction = create_widget_action(self.menu,
self.global_action = create_widget_action(self.menu,
text=translate('OpenLP.ThemeManager', 'Set As &Global Default'),
icon=u':/general/general_export.png',
triggers=self.changeGlobalFromScreen)
self.exportAction = create_widget_action(self.menu,
text=translate('OpenLP.ThemeManager', '&Export Theme'),
icon=u':/general/general_export.png', triggers=self.onExportTheme)
icon=u':/general/general_export.png', triggers=self.on_export_theme)
# Signals
QtCore.QObject.connect(self.themeListWidget,
QtCore.QObject.connect(self.theme_list_widget,
QtCore.SIGNAL(u'doubleClicked(QModelIndex)'), self.changeGlobalFromScreen)
QtCore.QObject.connect(self.themeListWidget,
QtCore.SIGNAL(u'currentItemChanged(QListWidgetItem *, QListWidgetItem *)'), self.checkListState)
QtCore.QObject.connect(self.theme_list_widget,
QtCore.SIGNAL(u'currentItemChanged(QListWidgetItem *, QListWidgetItem *)'), self.check_list_state)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'theme_update_global'), self.changeGlobalFromTab)
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'config_updated'), self.configUpdated)
QtCore.SIGNAL(u'theme_update_global'), self.change_global_from_tab)
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'config_updated'), self.config_updated)
# Variables
self.themeList = []
self.theme_list = []
self.path = AppLocation.get_section_data_path(self.settingsSection)
check_directory_exists(self.path)
self.thumbPath = os.path.join(self.path, u'thumbnails')
@ -141,27 +141,27 @@ class ThemeManager(QtGui.QWidget):
self.oldBackgroundImage = None
self.badV1NameChars = re.compile(r'[%+\[\]]')
# Last little bits of setting up
self.configUpdated()
self.config_updated()
def firstTime(self):
def first_time(self):
"""
Import new themes downloaded by the first time wizard
"""
Receiver.send_message(u'cursor_busy')
files = SettingsManager.get_files(self.settingsSection, u'.otz')
for file in files:
file = os.path.join(self.path, file)
self.unzipTheme(file, self.path)
for file_name in files:
file_name = os.path.join(self.path, file_name)
self.unzip_theme(file_name, self.path)
delete_file(file)
Receiver.send_message(u'cursor_normal')
def configUpdated(self):
def config_updated(self):
"""
Triggered when Config dialog is updated.
"""
self.global_theme = Settings().value(self.settingsSection + u'/global theme')
def checkListState(self, item):
def check_list_state(self, item):
"""
If Default theme selected remove delete button.
"""
@ -175,41 +175,41 @@ class ThemeManager(QtGui.QWidget):
else:
self.deleteToolbarAction.setVisible(False)
def contextMenu(self, point):
def context_menu(self, point):
"""
Build the Right Click Context menu and set state depending on
the type of theme.
"""
item = self.themeListWidget.itemAt(point)
item = self.theme_list_widget.itemAt(point)
if item is None:
return
real_theme_name = item.data(QtCore.Qt.UserRole)
theme_name = unicode(item.text())
visible = real_theme_name == theme_name
self.deleteAction.setVisible(visible)
self.renameAction.setVisible(visible)
self.globalAction.setVisible(visible)
self.menu.exec_(self.themeListWidget.mapToGlobal(point))
self.delete_action.setVisible(visible)
self.rename_action.setVisible(visible)
self.global_action.setVisible(visible)
self.menu.exec_(self.theme_list_widget.mapToGlobal(point))
def changeGlobalFromTab(self, theme_name):
def change_global_from_tab(self, theme_name):
"""
Change the global theme when it is changed through the Themes settings
tab
"""
log.debug(u'changeGlobalFromTab %s', theme_name)
for count in range (0, self.themeListWidget.count()):
log.debug(u'change_global_from_tab %s', theme_name)
for count in range (0, self.theme_list_widget.count()):
# reset the old name
item = self.themeListWidget.item(count)
item = self.theme_list_widget.item(count)
old_name = item.text()
new_name = item.data(QtCore.Qt.UserRole)
if old_name != new_name:
self.themeListWidget.item(count).setText(new_name)
self.theme_list_widget.item(count).setText(new_name)
# Set the new name
if theme_name == new_name:
name = translate('OpenLP.ThemeManager', '%s (default)') % new_name
self.themeListWidget.item(count).setText(name)
self.theme_list_widget.item(count).setText(name)
self.deleteToolbarAction.setVisible(
item not in self.themeListWidget.selectedItems())
item not in self.theme_list_widget.selectedItems())
def changeGlobalFromScreen(self, index=-1):
"""
@ -217,21 +217,21 @@ class ThemeManager(QtGui.QWidget):
Theme Manager list
"""
log.debug(u'changeGlobalFromScreen %s', index)
selected_row = self.themeListWidget.currentRow()
for count in range (0, self.themeListWidget.count()):
item = self.themeListWidget.item(count)
selected_row = self.theme_list_widget.currentRow()
for count in range (0, self.theme_list_widget.count()):
item = self.theme_list_widget.item(count)
old_name = item.text()
# reset the old name
if old_name != item.data(QtCore.Qt.UserRole):
self.themeListWidget.item(count).setText(item.data(QtCore.Qt.UserRole))
self.theme_list_widget.item(count).setText(item.data(QtCore.Qt.UserRole))
# Set the new name
if count == selected_row:
self.global_theme = self.themeListWidget.item(count).text()
self.global_theme = self.theme_list_widget.item(count).text()
name = translate('OpenLP.ThemeManager', '%s (default)') % self.global_theme
self.themeListWidget.item(count).setText(name)
self.theme_list_widget.item(count).setText(name)
Settings().setValue(self.settingsSection + u'/global theme', self.global_theme)
Receiver.send_message(u'theme_update_global', self.global_theme)
self._pushThemes()
self._push_themes()
def onAddTheme(self):
"""
@ -242,44 +242,44 @@ class ThemeManager(QtGui.QWidget):
theme.set_default_header_footer()
self.themeForm.theme = theme
self.themeForm.exec_()
self.loadThemes()
self.load_themes()
def onRenameTheme(self):
def on_rename_theme(self):
"""
Renames an existing theme to a new name
"""
if self._validate_theme_action(translate('OpenLP.ThemeManager', 'You must select a theme to rename.'),
translate('OpenLP.ThemeManager', 'Rename Confirmation'),
translate('OpenLP.ThemeManager', 'Rename %s theme?'), False, False):
item = self.themeListWidget.currentItem()
item = self.theme_list_widget.currentItem()
old_theme_name = item.data(QtCore.Qt.UserRole)
self.fileRenameForm.fileNameEdit.setText(old_theme_name)
if self.fileRenameForm.exec_():
new_theme_name = self.fileRenameForm.fileNameEdit.text()
if old_theme_name == new_theme_name:
return
if self.checkIfThemeExists(new_theme_name):
old_theme_data = self.getThemeData(old_theme_name)
if self.check_if_theme_exists(new_theme_name):
old_theme_data = self.get_theme_data(old_theme_name)
self.cloneThemeData(old_theme_data, new_theme_name)
self.deleteTheme(old_theme_name)
self.delete_theme(old_theme_name)
for plugin in self.plugin_manager.plugins:
if plugin.usesTheme(old_theme_name):
plugin.renameTheme(old_theme_name, new_theme_name)
self.renderer.update_theme(new_theme_name, old_theme_name)
self.loadThemes()
self.load_themes()
def onCopyTheme(self):
def on_copy_theme(self):
"""
Copies an existing theme to a new name
"""
item = self.themeListWidget.currentItem()
item = self.theme_list_widget.currentItem()
old_theme_name = item.data(QtCore.Qt.UserRole)
self.fileRenameForm.fileNameEdit.setText(translate('OpenLP.ThemeManager',
'Copy of %s', 'Copy of <theme name>') % old_theme_name)
if self.fileRenameForm.exec_(True):
new_theme_name = self.fileRenameForm.fileNameEdit.text()
if self.checkIfThemeExists(new_theme_name):
theme_data = self.getThemeData(old_theme_name)
if self.check_if_theme_exists(new_theme_name):
theme_data = self.get_theme_data(old_theme_name)
self.cloneThemeData(theme_data, new_theme_name)
def cloneThemeData(self, theme_data, new_theme_name):
@ -295,65 +295,65 @@ class ThemeManager(QtGui.QWidget):
save_from = theme_data.background_filename
theme_data.theme_name = new_theme_name
theme_data.extend_image_filename(self.path)
self.saveTheme(theme_data, save_from, save_to)
self.loadThemes()
self.save_theme(theme_data, save_from, save_to)
self.load_themes()
def onEditTheme(self):
def on_edit_theme(self):
"""
Loads the settings for the theme that is to be edited and launches the
theme editing form so the user can make their changes.
"""
if check_item_selected(self.themeListWidget,
if check_item_selected(self.theme_list_widget,
translate('OpenLP.ThemeManager', 'You must select a theme to edit.')):
item = self.themeListWidget.currentItem()
theme = self.getThemeData(item.data(QtCore.Qt.UserRole))
item = self.theme_list_widget.currentItem()
theme = self.get_theme_data(item.data(QtCore.Qt.UserRole))
if theme.background_type == u'image':
self.oldBackgroundImage = theme.background_filename
self.themeForm.theme = theme
self.themeForm.exec_(True)
self.oldBackgroundImage = None
self.renderer.update_theme(theme.theme_name)
self.loadThemes()
self.load_themes()
def onDeleteTheme(self):
def on_delete_theme(self):
"""
Delete a theme
"""
if self._validate_theme_action(translate('OpenLP.ThemeManager', 'You must select a theme to delete.'),
translate('OpenLP.ThemeManager', 'Delete Confirmation'),
translate('OpenLP.ThemeManager', 'Delete %s theme?')):
item = self.themeListWidget.currentItem()
item = self.theme_list_widget.currentItem()
theme = item.text()
row = self.themeListWidget.row(item)
self.themeListWidget.takeItem(row)
self.deleteTheme(theme)
row = self.theme_list_widget.row(item)
self.theme_list_widget.takeItem(row)
self.delete_theme(theme)
self.renderer.update_theme(theme, only_delete=True)
# As we do not reload the themes, push out the change. Reload the
# list as the internal lists and events need to be triggered.
self._pushThemes()
self._push_themes()
def deleteTheme(self, theme):
def delete_theme(self, theme):
"""
Delete a theme.
``theme``
The theme to delete.
"""
self.themeList.remove(theme)
self.theme_list.remove(theme)
thumb = u'%s.png' % theme
delete_file(os.path.join(self.path, thumb))
delete_file(os.path.join(self.thumbPath, thumb))
try:
encoding = get_filesystem_encoding()
shutil.rmtree(os.path.join(self.path, theme).encode(encoding))
except OSError:
except OSError, shutil.Error:
log.exception(u'Error deleting theme %s', theme)
def onExportTheme(self):
def on_export_theme(self):
"""
Export the theme in a zip file
"""
item = self.themeListWidget.currentItem()
item = self.theme_list_widget.currentItem()
if item is None:
critical_error_message_box(message=translate('OpenLP.ThemeManager', 'You have not selected a theme.'))
return
@ -366,29 +366,26 @@ class ThemeManager(QtGui.QWidget):
Settings().setValue(self.settingsSection + u'/last directory export', path)
theme_path = os.path.join(path, theme + u'.otz')
# FIXME: Do not overwrite build-in.
zip = None
zip_file = None
try:
zip = zipfile.ZipFile(theme_path, u'w')
zip_file = zipfile.ZipFile(theme_path, u'w')
source = os.path.join(self.path, theme)
for files in os.walk(source):
for name in files[2]:
zip.write(
os.path.join(source, name).encode(u'utf-8'),
zip_file.write(os.path.join(source, name).encode(u'utf-8'),
os.path.join(theme, name).encode(u'utf-8'))
QtGui.QMessageBox.information(self,
translate('OpenLP.ThemeManager', 'Theme Exported'),
QtGui.QMessageBox.information(self, translate('OpenLP.ThemeManager', 'Theme Exported'),
translate('OpenLP.ThemeManager', 'Your theme has been successfully exported.'))
except (IOError, OSError):
log.exception(u'Export Theme Failed')
critical_error_message_box(
translate('OpenLP.ThemeManager', 'Theme Export Failed'),
critical_error_message_box(translate('OpenLP.ThemeManager', 'Theme Export Failed'),
translate('OpenLP.ThemeManager', 'Your theme could not be exported due to an error.'))
finally:
if zip:
zip.close()
if zip_file:
zip_file.close()
Receiver.send_message(u'cursor_normal')
def onImportTheme(self):
def on_import_theme(self):
"""
Opens a file dialog to select the theme file(s) to import before
attempting to extract OpenLP themes from those files. This process
@ -402,36 +399,35 @@ class ThemeManager(QtGui.QWidget):
if not files:
return
Receiver.send_message(u'cursor_busy')
for file in files:
Settings().setValue(self.settingsSection + u'/last directory import', unicode(file))
self.unzipTheme(file, self.path)
self.loadThemes()
for file_name in files:
Settings().setValue(self.settingsSection + u'/last directory import', unicode(file_name))
self.unzip_theme(file_name, self.path)
self.load_themes()
Receiver.send_message(u'cursor_normal')
def loadThemes(self, firstTime=False):
def load_themes(self, first_time=False):
"""
Loads the theme lists and triggers updates accross the whole system
using direct calls or core functions and events for the plugins.
The plugins will call back in to get the real list if they want it.
"""
log.debug(u'Load themes from dir')
self.themeList = []
self.themeListWidget.clear()
self.theme_list = []
self.theme_list_widget.clear()
files = SettingsManager.get_files(self.settingsSection, u'.png')
if firstTime:
self.firstTime()
if first_time:
self.first_time()
files = SettingsManager.get_files(self.settingsSection, u'.png')
# No themes have been found so create one
if not files:
theme = ThemeXML()
theme.theme_name = UiStrings().Default
self._writeTheme(theme, None, None)
self._write_theme(theme, None, None)
Settings().setValue(self.settingsSection + u'/global theme', theme.theme_name)
self.configUpdated()
self.config_updated()
files = SettingsManager.get_files(self.settingsSection, u'.png')
# Sort the themes by its name considering language specific
files.sort(key=lambda file_name: unicode(file_name),
cmp=locale_compare)
files.sort(key=lambda file_name: unicode(file_name), cmp=locale_compare)
# now process the file list of png files
for name in files:
# check to see file is in theme root directory
@ -450,23 +446,23 @@ class ThemeManager(QtGui.QWidget):
icon = create_thumb(theme, thumb)
item_name.setIcon(icon)
item_name.setData(QtCore.Qt.UserRole, text_name)
self.themeListWidget.addItem(item_name)
self.themeList.append(text_name)
self._pushThemes()
self.theme_list_widget.addItem(item_name)
self.theme_list.append(text_name)
self._push_themes()
def _pushThemes(self):
def _push_themes(self):
"""
Notify listeners that the theme list has been updated
"""
Receiver.send_message(u'theme_update_list', self.getThemes())
Receiver.send_message(u'theme_update_list', self.get_themes())
def getThemes(self):
def get_themes(self):
"""
Return the list of loaded themes
"""
return self.themeList
return self.theme_list
def getThemeData(self, theme_name):
def get_theme_data(self, theme_name):
"""
Returns a theme object from an XML file
@ -480,18 +476,20 @@ class ThemeManager(QtGui.QWidget):
log.debug(u'No theme data - using default theme')
return ThemeXML()
else:
return self._createThemeFromXml(xml, self.path)
return self._create_theme_fom_Xml(xml, self.path)
def overWriteMessageBox(self, theme_name):
ret = QtGui.QMessageBox.question(self,
translate('OpenLP.ThemeManager', 'Theme Already Exists'),
def over_write_message_box(self, theme_name):
"""
Check before overwriting the theme
"""
ret = QtGui.QMessageBox.question(self, translate('OpenLP.ThemeManager', 'Theme Already Exists'),
translate('OpenLP.ThemeManager',
'Theme %s already exists. Do you want to replace it?').replace('%s', theme_name),
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes | QtGui.QMessageBox.No),
QtGui.QMessageBox.No)
return ret == QtGui.QMessageBox.Yes
def unzipTheme(self, file_name, dir):
def unzip_theme(self, file_name, dir):
"""
Unzip the theme, remove the preview file if stored
Generate a new preview file. Check the XML theme version and upgrade if
@ -499,32 +497,32 @@ class ThemeManager(QtGui.QWidget):
"""
log.debug(u'Unzipping theme %s', file_name)
file_name = unicode(file_name)
zip = None
zip_file = None
out_file = None
file_xml = None
abort_import = True
try:
zip = zipfile.ZipFile(file_name)
zip_file = zipfile.ZipFile(file_name)
xml_file = filter(lambda name:
os.path.splitext(name)[1].lower() == u'.xml', zip.namelist())
os.path.splitext(name)[1].lower() == u'.xml', zip_file.namelist())
if len(xml_file) != 1:
log.exception(u'Theme contains "%s" XML files' % len(xml_file))
raise Exception(u'validation')
xml_tree = ElementTree(element=XML(zip.read(xml_file[0]))).getroot()
raise Exception('validation')
xml_tree = ElementTree(element=XML(zip_file.read(xml_file[0]))).getroot()
v1_background = xml_tree.find(u'BackgroundType')
if v1_background is not None:
theme_name, file_xml, out_file, abort_import = self.unzipVersion122(
dir, zip, xml_file[0], xml_tree, v1_background, out_file)
theme_name, file_xml, out_file, abort_import = self.unzip_version_122(
dir, zip_file, xml_file[0], xml_tree, v1_background, out_file)
else:
theme_name = xml_tree.find(u'name').text.strip()
theme_folder = os.path.join(dir, theme_name)
theme_exists = os.path.exists(theme_folder)
if theme_exists and not self.overWriteMessageBox(theme_name):
if theme_exists and not self.over_write_message_box(theme_name):
abort_import = True
return
else:
abort_import = False
for name in zip.namelist():
for name in zip_file.namelist():
try:
uname = unicode(name, u'utf-8')
except UnicodeDecodeError:
@ -539,12 +537,12 @@ class ThemeManager(QtGui.QWidget):
full_name = os.path.join(dir, uname)
check_directory_exists(os.path.dirname(full_name))
if os.path.splitext(uname)[1].lower() == u'.xml':
file_xml = unicode(zip.read(name), u'utf-8')
file_xml = unicode(zip_file.read(name), u'utf-8')
out_file = open(full_name, u'w')
out_file.write(file_xml.encode(u'utf-8'))
else:
out_file = open(full_name, u'wb')
out_file.write(zip.read(name))
out_file.write(zip_file.read(name))
out_file.close()
except (IOError, zipfile.BadZipfile):
log.exception(u'Importing theme from zip failed %s' % file_name)
@ -557,15 +555,15 @@ class ThemeManager(QtGui.QWidget):
raise
finally:
# Close the files, to be able to continue creating the theme.
if zip:
zip.close()
if zip_file:
zip_file.close()
if out_file:
out_file.close()
if not abort_import:
# As all files are closed, we can create the Theme.
if file_xml:
theme = self._createThemeFromXml(file_xml, self.path)
self.generateAndSaveImage(dir, theme_name, theme)
theme = self._create_theme_fom_Xml(file_xml, self.path)
self.generate_and_save_image(dir, theme_name, theme)
# Only show the error message, when IOError was not raised (in
# this case the error message has already been shown).
elif zip is not None:
@ -574,22 +572,21 @@ class ThemeManager(QtGui.QWidget):
translate('OpenLP.ThemeManager', 'File is not a valid theme.'))
log.exception(u'Theme file does not contain XML data %s' % file_name)
def unzipVersion122(self, dir, zip, xml_file, xml_tree, background,
out_file):
def unzip_version_122(self, dir_name, zip_file, xml_file, xml_tree, background, out_file):
"""
Unzip openlp.org 1.2x theme file and upgrade the theme xml. When calling
this method, please keep in mind, that some parameters are redundant.
"""
theme_name = xml_tree.find(u'Name').text.strip()
theme_name = self.badV1NameChars.sub(u'', theme_name)
theme_folder = os.path.join(dir, theme_name)
theme_folder = os.path.join(dir_name, theme_name)
theme_exists = os.path.exists(theme_folder)
if theme_exists and not self.overWriteMessageBox(theme_name):
if theme_exists and not self.over_write_message_box(theme_name):
return '', '', '', True
themedir = os.path.join(dir, theme_name)
themedir = os.path.join(dir_name, theme_name)
check_directory_exists(themedir)
file_xml = unicode(zip.read(xml_file), u'utf-8')
file_xml = self._migrateVersion122(file_xml)
file_xml = unicode(zip_file.read(xml_file), u'utf-8')
file_xml = self._migrate_version_122(file_xml)
out_file = open(os.path.join(themedir, theme_name + u'.xml'), u'w')
out_file.write(file_xml.encode(u'utf-8'))
out_file.close()
@ -597,18 +594,17 @@ class ThemeManager(QtGui.QWidget):
image_name = xml_tree.find(u'BackgroundParameter1').text.strip()
# image file has same extension and is in subfolder
image_file = filter(lambda name: os.path.splitext(name)[1].lower()
== os.path.splitext(image_name)[1].lower() and name.find(r'/'),
zip.namelist())
== os.path.splitext(image_name)[1].lower() and name.find(r'/'), zip_file.namelist())
if len(image_file) >= 1:
out_file = open(os.path.join(themedir, image_name), u'wb')
out_file.write(zip.read(image_file[0]))
out_file.write(zip_file.read(image_file[0]))
out_file.close()
else:
log.exception(u'Theme file does not contain image file "%s"' % image_name.decode(u'utf-8', u'replace'))
raise Exception(u'validation')
return theme_name, file_xml, out_file, False
def checkIfThemeExists(self, theme_name):
def check_if_theme_exists(self, theme_name):
"""
Check if theme already exists and displays error message
@ -623,25 +619,25 @@ class ThemeManager(QtGui.QWidget):
return False
return True
def saveTheme(self, theme, image_from, image_to):
def save_theme(self, theme, image_from, image_to):
"""
Called by thememaintenance Dialog to save the theme
and to trigger the reload of the theme list
"""
self._writeTheme(theme, image_from, image_to)
self._write_theme(theme, image_from, image_to)
if theme.background_type == BackgroundType.to_string(BackgroundType.Image):
self.image_manager.updateImageBorder(theme.background_filename,
ImageSource.Theme, QtGui.QColor(theme.background_border_color))
self.image_manager.processUpdates()
def _writeTheme(self, theme, image_from, image_to):
def _write_theme(self, theme, image_from, image_to):
"""
Writes the theme to the disk and handles the background image if
necessary
"""
name = theme.theme_name
theme_pretty_xml = theme.extract_formatted_xml()
log.debug(u'saveTheme %s %s', name, theme_pretty_xml.decode(u'utf-8'))
log.debug(u'save_theme %s %s', name, theme_pretty_xml.decode(u'utf-8'))
theme_dir = os.path.join(self.path, name)
check_directory_exists(theme_dir)
theme_file = os.path.join(theme_dir, name + u'.xml')
@ -660,13 +656,16 @@ class ThemeManager(QtGui.QWidget):
try:
encoding = get_filesystem_encoding()
shutil.copyfile(unicode(image_from).encode(encoding), unicode(image_to).encode(encoding))
except IOError:
except IOError, shutil.Error:
log.exception(u'Failed to save theme image')
self.generateAndSaveImage(self.path, name, theme)
self.generate_and_save_image(self.path, name, theme)
def generateAndSaveImage(self, dir, name, theme):
log.debug(u'generateAndSaveImage %s %s', dir, name)
frame = self.generateImage(theme)
def generate_and_save_image(self, dir, name, theme):
"""
Generate and Save the theme image.
"""
log.debug(u'generate_and_save_image %s %s', dir, name)
frame = self.generate_image(theme)
sample_path_name = os.path.join(self.path, name + u'.png')
if os.path.exists(sample_path_name):
os.unlink(sample_path_name)
@ -675,18 +674,18 @@ class ThemeManager(QtGui.QWidget):
create_thumb(sample_path_name, thumb, False)
log.debug(u'Theme image written to %s', sample_path_name)
def updatePreviewImages(self):
def update_preview_images(self):
"""
Called to update the themes' preview images.
"""
self.main_window.displayProgressBar(len(self.themeList))
for theme in self.themeList:
self.main_window.displayProgressBar(len(self.theme_list))
for theme in self.theme_list:
self.main_window.incrementProgressBar()
self.generateAndSaveImage(self.path, theme, self.getThemeData(theme))
self.generate_and_save_image(self.path, theme, self.get_theme_data(theme))
self.main_window.finishedProgressBar()
self.loadThemes()
self.load_themes()
def generateImage(self, theme_data, forcePage=False):
def generate_image(self, theme_data, forcePage=False):
"""
Call the renderer to build a Sample Image
@ -696,21 +695,21 @@ class ThemeManager(QtGui.QWidget):
``forcePage``
Flag to tell message lines per page need to be generated.
"""
log.debug(u'generateImage \n%s ', theme_data)
log.debug(u'generate_image \n%s ', theme_data)
return self.renderer.generate_preview(theme_data, forcePage)
def getPreviewImage(self, theme):
def get_preview_image(self, theme):
"""
Return an image representing the look of the theme
``theme``
The theme to return the image for
"""
log.debug(u'getPreviewImage %s ', theme)
log.debug(u'get_preview_image %s ', theme)
image = os.path.join(self.path, theme + u'.png')
return image
def _createThemeFromXml(self, theme_xml, path):
def _create_theme_fom_Xml(self, theme_xml, path):
"""
Return a theme object using information parsed from XML
@ -722,15 +721,14 @@ class ThemeManager(QtGui.QWidget):
theme.extend_image_filename(path)
return theme
def _validate_theme_action(self, select_text, confirm_title, confirm_text,
testPlugin=True, confirm=True):
def _validate_theme_action(self, select_text, confirm_title, confirm_text, testPlugin=True, confirm=True):
"""
Check to see if theme has been selected and the destructive action
is allowed.
"""
self.global_theme = Settings().value(self.settingsSection + u'/global theme')
if check_item_selected(self.themeListWidget, select_text):
item = self.themeListWidget.currentItem()
if check_item_selected(self.theme_list_widget, select_text):
item = self.theme_list_widget.currentItem()
theme = item.text()
# confirm deletion
if confirm:
@ -755,7 +753,7 @@ class ThemeManager(QtGui.QWidget):
return True
return False
def _migrateVersion122(self, xml_data):
def _migrate_version_122(self, xml_data):
"""
Convert the xml data from version 1 format to the current format.

View File

@ -38,8 +38,7 @@ class ThemesTab(SettingsTab):
"""
ThemesTab is the theme settings tab in the settings dialog.
"""
def __init__(self, parent, mainwindow):
self.mainwindow = mainwindow
def __init__(self, parent):
generalTranslated = translate('OpenLP.ThemesTab', 'Themes')
SettingsTab.__init__(self, parent, u'Themes', generalTranslated)
self.iconPath = u':/themes/theme_new.png'
@ -135,8 +134,8 @@ class ThemesTab(SettingsTab):
settings.setValue(u'theme level', self.theme_level)
settings.setValue(u'global theme', self.global_theme)
settings.endGroup()
self.mainwindow.renderer.set_global_theme(self.global_theme)
self.mainwindow.renderer.set_theme_level(self.theme_level)
self.renderer.set_global_theme(self.global_theme)
self.renderer.set_theme_level(self.theme_level)
Receiver.send_message(u'theme_update_global', self.global_theme)
def postSetUp(self):
@ -153,7 +152,7 @@ class ThemesTab(SettingsTab):
def onDefaultComboBoxChanged(self, value):
self.global_theme = self.DefaultComboBox.currentText()
self.mainwindow.renderer.set_global_theme(self.global_theme)
self.renderer.set_global_theme(self.global_theme)
self.__previewGlobalTheme()
def updateThemeList(self, theme_list):
@ -170,8 +169,8 @@ class ThemesTab(SettingsTab):
self.DefaultComboBox.clear()
self.DefaultComboBox.addItems(theme_list)
find_and_set_in_combo_box(self.DefaultComboBox, self.global_theme)
self.mainwindow.renderer.set_global_theme(self.global_theme)
self.mainwindow.renderer.set_theme_level(self.theme_level)
self.renderer.set_global_theme(self.global_theme)
self.renderer.set_theme_level(self.theme_level)
if self.global_theme is not u'':
self.__previewGlobalTheme()
@ -179,7 +178,7 @@ class ThemesTab(SettingsTab):
"""
Utility method to update the global theme preview image.
"""
image = self.mainwindow.themeManagerContents.getPreviewImage(self.global_theme)
image = self.theme_manager.get_preview_image(self.global_theme)
preview = QtGui.QPixmap(unicode(image))
if not preview.isNull():
preview = preview.scaled(300, 255, QtCore.Qt.KeepAspectRatio, QtCore.Qt.SmoothTransformation)

View File

@ -61,8 +61,7 @@ class OpenLP1SongImport(SongImport):
The database providing the data to import.
"""
SongImport.__init__(self, manager, **kwargs)
self.availableThemes = \
kwargs[u'plugin'].formParent.themeManagerContents.getThemes()
self.availableThemes = kwargs[u'plugin'].theme_manager.get_themes()
def doImport(self):
"""