diff --git a/openlp/core/lib/htmlbuilder.py b/openlp/core/lib/htmlbuilder.py index 6496aeef1..9c8b04076 100644 --- a/openlp/core/lib/htmlbuilder.py +++ b/openlp/core/lib/htmlbuilder.py @@ -240,9 +240,9 @@ def build_html(item, screen, is_live, background, image=None, plugins=None): html_additions = u'' if plugins: for plugin in plugins: - css_additions += plugin.getDisplayCss() - js_additions += plugin.getDisplayJavaScript() - html_additions += plugin.getDisplayHtml() + css_additions += plugin.get_display_css() + js_additions += plugin.get_display_javascript() + html_additions += plugin.get_display_html() html = HTMLSRC % ( build_background_css(item, width), css_additions, diff --git a/openlp/core/lib/listwidgetwithdnd.py b/openlp/core/lib/listwidgetwithdnd.py index 987dcb240..5b15b8103 100644 --- a/openlp/core/lib/listwidgetwithdnd.py +++ b/openlp/core/lib/listwidgetwithdnd.py @@ -54,7 +54,7 @@ class ListWidgetWithDnD(QtGui.QListWidget): """ self.setAcceptDrops(True) self.setDragDropMode(QtGui.QAbstractItemView.DragDrop) - Registry().register_function((u'%s_dnd' % self.mimeDataText), self.parent().loadFile) + Registry().register_function((u'%s_dnd' % self.mimeDataText), self.parent().load_file) def mouseMoveEvent(self, event): """ diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index 9ada00fa1..e261bfe59 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -63,11 +63,11 @@ class MediaManagerItem(QtGui.QWidget): When creating a descendant class from this class for your plugin, the following member variables should be set. - ``self.onNewPrompt`` + ``self.on_new_prompt`` Defaults to *'Select Image(s)'*. - ``self.onNewFileMasks`` + ``self.on_new_file_masks`` Defaults to *'Images (*.jpg *jpeg *.gif *.png *.bmp)'*. This assumes that the new action is to load a file. If not, you need to override the ``OnNew`` method. @@ -86,35 +86,35 @@ class MediaManagerItem(QtGui.QWidget): self.hide() self.whitespace = re.compile(r'[\W_]+', re.UNICODE) self.plugin = plugin - visible_title = self.plugin.getString(StringContent.VisibleName) + visible_title = self.plugin.get_string(StringContent.VisibleName) self.title = unicode(visible_title[u'title']) Registry().register(self.plugin.name, self) - self.settingsSection = self.plugin.name + self.settings_section = self.plugin.name self.toolbar = None - self.remoteTriggered = None - self.singleServiceItem = True - self.quickPreviewAllowed = False + self.remote_triggered = None + self.single_service_item = True + self.quick_preview_allowed = False self.hasSearch = False - self.pageLayout = QtGui.QVBoxLayout(self) - self.pageLayout.setSpacing(0) - self.pageLayout.setMargin(0) - self.requiredIcons() + self.page_layout = QtGui.QVBoxLayout(self) + self.page_layout.setSpacing(0) + self.page_layout.setMargin(0) + self.required_icons() self.setupUi() self.retranslateUi() - self.autoSelectId = -1 - Registry().register_function(u'%s_service_load' % self.plugin.name, self.serviceLoad) + self.auto_select_id = -1 + Registry().register_function(u'%s_service_load' % self.plugin.name, self.service_load) - def requiredIcons(self): + def required_icons(self): """ This method is called to define the icons for the plugin. It provides a default set and the plugin is able to override the if required. """ - self.hasImportIcon = False - self.hasNewIcon = True - self.hasEditIcon = True - self.hasFileIcon = False - self.hasDeleteIcon = True - self.addToServiceItem = False + self.has_import_icon = False + self.has_new_icon = True + self.has_edit_icon = True + self.has_file_icon = False + self.has_delete_icon = True + self.add_to_service_item = False def retranslateUi(self): """ @@ -123,13 +123,13 @@ class MediaManagerItem(QtGui.QWidget): """ pass - def addToolbar(self): + def add_toolbar(self): """ A method to help developers easily add a toolbar to the media manager item. """ if self.toolbar is None: self.toolbar = OpenLPToolbar(self) - self.pageLayout.addWidget(self.toolbar) + self.page_layout.addWidget(self.toolbar) def setupUi(self): """ @@ -137,143 +137,143 @@ class MediaManagerItem(QtGui.QWidget): rest of the interface of the media manager item. """ # Add a toolbar - self.addToolbar() + self.add_toolbar() # Allow the plugin to define buttons at start of bar - self.addStartHeaderBar() + self.add_start_header_bar() # Add the middle of the tool bar (pre defined) - self.addMiddleHeaderBar() + self.add_middle_header_bar() # Allow the plugin to define buttons at end of bar - self.addEndHeaderBar() + self.add_end_header_bar() # Add the list view - self.addListViewToToolBar() + self.add_list_view_to_toolbar() - def addMiddleHeaderBar(self): + def add_middle_header_bar(self): """ Create buttons for the media item toolbar """ toolbar_actions = [] ## Import Button ## - if self.hasImportIcon: + if self.has_import_icon: toolbar_actions.append([u'Import', StringContent.Import, - u':/general/general_import.png', self.onImportClick]) + u':/general/general_import.png', self.on_import_click]) ## Load Button ## - if self.hasFileIcon: - toolbar_actions.append([u'Load', StringContent.Load, u':/general/general_open.png', self.onFileClick]) + if self.has_file_icon: + toolbar_actions.append([u'Load', StringContent.Load, u':/general/general_open.png', self.on_file_click]) ## New Button ## - if self.hasNewIcon: - toolbar_actions.append([u'New', StringContent.New, u':/general/general_new.png', self.onNewClick]) + if self.has_new_icon: + toolbar_actions.append([u'New', StringContent.New, u':/general/general_new.png', self.on_new_click]) ## Edit Button ## - if self.hasEditIcon: - toolbar_actions.append([u'Edit', StringContent.Edit, u':/general/general_edit.png', self.onEditClick]) + if self.has_edit_icon: + toolbar_actions.append([u'Edit', StringContent.Edit, u':/general/general_edit.png', self.on_edit_click]) ## Delete Button ## - if self.hasDeleteIcon: + if self.has_delete_icon: toolbar_actions.append([u'Delete', StringContent.Delete, - u':/general/general_delete.png', self.onDeleteClick]) + u':/general/general_delete.png', self.on_delete_click]) ## Preview ## toolbar_actions.append([u'Preview', StringContent.Preview, - u':/general/general_preview.png', self.onPreviewClick]) + u':/general/general_preview.png', self.on_preview_click]) ## Live Button ## - toolbar_actions.append([u'Live', StringContent.Live, u':/general/general_live.png', self.onLiveClick]) + toolbar_actions.append([u'Live', StringContent.Live, u':/general/general_live.png', self.on_live_click]) ## Add to service Button ## - toolbar_actions.append([u'Service', StringContent.Service, u':/general/general_add.png', self.onAddClick]) + toolbar_actions.append([u'Service', StringContent.Service, u':/general/general_add.png', self.on_add_click]) for action in toolbar_actions: if action[0] == StringContent.Preview: self.toolbar.addSeparator() self.toolbar.add_toolbar_action(u'%s%sAction' % (self.plugin.name, action[0]), - text=self.plugin.getString(action[1])[u'title'], icon=action[2], - tooltip=self.plugin.getString(action[1])[u'tooltip'], + text=self.plugin.get_string(action[1])[u'title'], icon=action[2], + tooltip=self.plugin.get_string(action[1])[u'tooltip'], triggers=action[3]) - def addListViewToToolBar(self): + def add_list_view_to_toolbar(self): """ Creates the main widget for listing items the media item is tracking """ # Add the List widget - self.listView = ListWidgetWithDnD(self, self.plugin.name) - self.listView.setSpacing(1) - self.listView.setSelectionMode(QtGui.QAbstractItemView.ExtendedSelection) - self.listView.setAlternatingRowColors(True) - self.listView.setObjectName(u'%sListView' % self.plugin.name) - # Add to pageLayout - self.pageLayout.addWidget(self.listView) + self.list_view = ListWidgetWithDnD(self, self.plugin.name) + self.list_view.setSpacing(1) + self.list_view.setSelectionMode(QtGui.QAbstractItemView.ExtendedSelection) + self.list_view.setAlternatingRowColors(True) + self.list_view.setObjectName(u'%sListView' % self.plugin.name) + # Add to page_layout + self.page_layout.addWidget(self.list_view) # define and add the context menu - self.listView.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) - if self.hasEditIcon: - create_widget_action(self.listView, - text=self.plugin.getString(StringContent.Edit)[u'title'], + self.list_view.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) + if self.has_edit_icon: + create_widget_action(self.list_view, + text=self.plugin.get_string(StringContent.Edit)[u'title'], icon=u':/general/general_edit.png', - triggers=self.onEditClick) - create_widget_action(self.listView, separator=True) - if self.hasDeleteIcon: - create_widget_action(self.listView, + triggers=self.on_edit_click) + create_widget_action(self.list_view, separator=True) + if self.has_delete_icon: + create_widget_action(self.list_view, u'listView%s%sItem' % (self.plugin.name.title(), StringContent.Delete.title()), - text=self.plugin.getString(StringContent.Delete)[u'title'], + text=self.plugin.get_string(StringContent.Delete)[u'title'], icon=u':/general/general_delete.png', - can_shortcuts=True, triggers=self.onDeleteClick) - create_widget_action(self.listView, separator=True) - create_widget_action(self.listView, + can_shortcuts=True, triggers=self.on_delete_click) + create_widget_action(self.list_view, separator=True) + create_widget_action(self.list_view, u'listView%s%sItem' % (self.plugin.name.title(), StringContent.Preview.title()), - text=self.plugin.getString(StringContent.Preview)[u'title'], + text=self.plugin.get_string(StringContent.Preview)[u'title'], icon=u':/general/general_preview.png', can_shortcuts=True, - triggers=self.onPreviewClick) - create_widget_action(self.listView, + triggers=self.on_preview_click) + create_widget_action(self.list_view, u'listView%s%sItem' % (self.plugin.name.title(), StringContent.Live.title()), - text=self.plugin.getString(StringContent.Live)[u'title'], + text=self.plugin.get_string(StringContent.Live)[u'title'], icon=u':/general/general_live.png', can_shortcuts=True, - triggers=self.onLiveClick) - create_widget_action(self.listView, + triggers=self.on_live_click) + create_widget_action(self.list_view, u'listView%s%sItem' % (self.plugin.name.title(), StringContent.Service.title()), can_shortcuts=True, - text=self.plugin.getString(StringContent.Service)[u'title'], + text=self.plugin.get_string(StringContent.Service)[u'title'], icon=u':/general/general_add.png', - triggers=self.onAddClick) - if self.addToServiceItem: - create_widget_action(self.listView, separator=True) - create_widget_action(self.listView, + triggers=self.on_add_click) + if self.add_to_service_item: + create_widget_action(self.list_view, separator=True) + create_widget_action(self.list_view, text=translate('OpenLP.MediaManagerItem', '&Add to selected Service Item'), icon=u':/general/general_add.png', - triggers=self.onAddEditClick) - self.addCustomContextActions() - # Create the context menu and add all actions from the listView. + triggers=self.on_add_edit_click) + self.add_custom_context_actions() + # Create the context menu and add all actions from the list_view. self.menu = QtGui.QMenu() - self.menu.addActions(self.listView.actions()) - self.listView.doubleClicked.connect(self.onDoubleClicked) - self.listView.itemSelectionChanged.connect(self.onSelectionChange) - self.listView.customContextMenuRequested.connect(self.contextMenu) + self.menu.addActions(self.list_view.actions()) + self.list_view.doubleClicked.connect(self.on_double_clicked) + self.list_view.itemSelectionChanged.connect(self.on_selection_change) + self.list_view.customContextMenuRequested.connect(self.context_menu) - def addSearchToToolBar(self): + def add_search_to_toolbar(self): """ Creates a search field with button and related signal handling. """ - self.searchWidget = QtGui.QWidget(self) - self.searchWidget.setObjectName(u'searchWidget') - self.searchLayout = QtGui.QVBoxLayout(self.searchWidget) - self.searchLayout.setObjectName(u'searchLayout') - self.searchTextLayout = QtGui.QFormLayout() - self.searchTextLayout.setObjectName(u'searchTextLayout') - self.searchTextLabel = QtGui.QLabel(self.searchWidget) - self.searchTextLabel.setObjectName(u'searchTextLabel') - self.searchTextEdit = SearchEdit(self.searchWidget) - self.searchTextEdit.setObjectName(u'searchTextEdit') - self.searchTextLabel.setBuddy(self.searchTextEdit) - self.searchTextLayout.addRow(self.searchTextLabel, self.searchTextEdit) - self.searchLayout.addLayout(self.searchTextLayout) - self.searchButtonLayout = QtGui.QHBoxLayout() - self.searchButtonLayout.setObjectName(u'searchButtonLayout') - self.searchButtonLayout.addStretch() - self.searchTextButton = QtGui.QPushButton(self.searchWidget) - self.searchTextButton.setObjectName(u'searchTextButton') - self.searchButtonLayout.addWidget(self.searchTextButton) - self.searchLayout.addLayout(self.searchButtonLayout) - self.pageLayout.addWidget(self.searchWidget) + self.search_widget = QtGui.QWidget(self) + self.search_widget.setObjectName(u'search_widget') + self.search_layout = QtGui.QVBoxLayout(self.search_widget) + self.search_layout.setObjectName(u'search_layout') + self.search_text_layout = QtGui.QFormLayout() + self.search_text_layout.setObjectName(u'search_text_layout') + self.search_text_label = QtGui.QLabel(self.search_widget) + self.search_text_label.setObjectName(u'search_text_label') + self.search_text_edit = SearchEdit(self.search_widget) + self.search_text_edit.setObjectName(u'search_text_edit') + self.search_text_label.setBuddy(self.search_text_edit) + self.search_text_layout.addRow(self.search_text_label, self.search_text_edit) + self.search_layout.addLayout(self.search_text_layout) + self.search_button_layout = QtGui.QHBoxLayout() + self.search_button_layout.setObjectName(u'search_button_layout') + self.search_button_layout.addStretch() + self.search_text_button = QtGui.QPushButton(self.search_widget) + self.search_text_button.setObjectName(u'search_text_button') + self.search_button_layout.addWidget(self.search_text_button) + self.search_layout.addLayout(self.search_button_layout) + self.page_layout.addWidget(self.search_widget) # Signals and slots - self.searchTextEdit.returnPressed.connect(self.onSearchTextButtonClicked) - self.searchTextButton.clicked.connect(self.onSearchTextButtonClicked) - self.searchTextEdit.textChanged.connect(self.onSearchTextEditChanged) + self.search_text_edit.returnPressed.connect(self.on_search_text_button_clicked) + self.search_text_button.clicked.connect(self.on_search_text_button_clicked) + self.search_text_edit.textChanged.connect(self.on_search_text_edit_changed) - def addCustomContextActions(self): + def add_custom_context_actions(self): """ Implement this method in your descendent media manager item to add any context menu items. This method is called automatically. @@ -287,31 +287,31 @@ class MediaManagerItem(QtGui.QWidget): """ pass - def addStartHeaderBar(self): + def add_start_header_bar(self): """ Slot at start of toolbar for plugin to addwidgets """ pass - def addEndHeaderBar(self): + def add_end_header_bar(self): """ Slot at end of toolbar for plugin to add widgets """ pass - def onFileClick(self): + def on_file_click(self): """ Add a file to the list widget to make it available for showing """ - files = QtGui.QFileDialog.getOpenFileNames(self, self.onNewPrompt, - Settings().value(self.settingsSection + u'/last directory'), self.onNewFileMasks) + files = QtGui.QFileDialog.getOpenFileNames(self, self.on_new_prompt, + Settings().value(self.settings_section + u'/last directory'), self.on_new_file_masks) log.info(u'New files(s) %s', files) if files: self.application.set_busy_cursor() - self.validateAndLoad(files) + self.validate_and_load(files) self.application.set_normal_cursor() - def loadFile(self, data): + def load_file(self, data): """ Turn file from Drag and Drop into an array so the Validate code can run it. @@ -322,7 +322,7 @@ class MediaManagerItem(QtGui.QWidget): error_shown = False for file_name in data['files']: file_type = file_name.split(u'.')[-1] - if file_type.lower() not in self.onNewFileMasks: + if file_type.lower() not in self.on_new_file_masks: if not error_shown: critical_error_message_box(translate('OpenLP.MediaManagerItem', 'Invalid File Type'), translate('OpenLP.MediaManagerItem', 'Invalid File %s.\nSuffix not supported') % file_name) @@ -330,7 +330,7 @@ class MediaManagerItem(QtGui.QWidget): else: new_files.append(file_name) if new_files: - self.validateAndLoad(new_files, data['target']) + self.validate_and_load(new_files, data['target']) def dnd_move_internal(self, target): """ @@ -341,7 +341,7 @@ class MediaManagerItem(QtGui.QWidget): """ pass - def validateAndLoad(self, files, target_group=None): + def validate_and_load(self, files, target_group=None): """ Process a list for files either from the File Dialog or from Drag and Drop @@ -354,9 +354,9 @@ class MediaManagerItem(QtGui.QWidget): """ names = [] full_list = [] - for count in range(self.listView.count()): - names.append(self.listView.item(count).text()) - full_list.append(self.listView.item(count).data(QtCore.Qt.UserRole)) + for count in range(self.list_view.count()): + names.append(self.list_view.item(count).text()) + full_list.append(self.list_view.item(count).data(QtCore.Qt.UserRole)) duplicates_found = False files_added = False for file_path in files: @@ -368,61 +368,61 @@ class MediaManagerItem(QtGui.QWidget): full_list.append(file_path) if full_list and files_added: if target_group is None: - self.listView.clear() - self.loadList(full_list, target_group) + self.list_view.clear() + self.load_list(full_list, target_group) last_dir = os.path.split(unicode(files[0]))[0] - Settings().setValue(self.settingsSection + u'/last directory', last_dir) - Settings().setValue(u'%s/%s files' % (self.settingsSection, self.settingsSection), self.getFileList()) + Settings().setValue(self.settings_section + u'/last directory', last_dir) + Settings().setValue(u'%s/%s files' % (self.settings_section, self.settings_section), self.get_file_list()) if duplicates_found: critical_error_message_box(UiStrings().Duplicate, translate('OpenLP.MediaManagerItem', 'Duplicate files were found on import and were ignored.')) - def contextMenu(self, point): + def context_menu(self, point): """ Display a context menu """ - item = self.listView.itemAt(point) + item = self.list_view.itemAt(point) # Decide if we have to show the context menu or not. if item is None: return if not item.flags() & QtCore.Qt.ItemIsSelectable: return - self.menu.exec_(self.listView.mapToGlobal(point)) + self.menu.exec_(self.list_view.mapToGlobal(point)) - def getFileList(self): + def get_file_list(self): """ Return the current list of files """ file_list = [] - for index in xrange(self.listView.count()): - bitem = self.listView.item(index) + for index in xrange(self.list_view.count()): + bitem = self.list_view.item(index) filename = bitem.data(QtCore.Qt.UserRole) file_list.append(filename) return file_list - def loadList(self, list, target_group): + def load_list(self, list, target_group): """ Load a list. Needs to be implemented by the plugin. """ raise NotImplementedError(u'MediaManagerItem.loadList needs to be defined by the plugin') - def onNewClick(self): + def on_new_click(self): """ Hook for plugins to define behaviour for adding new items. """ pass - def onEditClick(self): + def on_edit_click(self): """ Hook for plugins to define behaviour for editing items. """ pass - def onDeleteClick(self): + def on_delete_click(self): """ Delete an item. Needs to be implemented by the plugin. """ - raise NotImplementedError(u'MediaManagerItem.onDeleteClick needs to be defined by the plugin') + raise NotImplementedError(u'MediaManagerItem.on_delete_click needs to be defined by the plugin') def onFocus(self): """ @@ -431,65 +431,65 @@ class MediaManagerItem(QtGui.QWidget): """ pass - def generateSlideData(self, service_item, item=None, xml_version=False, remote=False, + def generate_slide_data(self, service_item, item=None, xml_version=False, remote=False, context=ServiceItemContext.Live): """ Generate the slide data. Needs to be implemented by the plugin. """ - raise NotImplementedError(u'MediaManagerItem.generateSlideData needs to be defined by the plugin') + raise NotImplementedError(u'MediaManagerItem.generate_slide_data needs to be defined by the plugin') - def onDoubleClicked(self): + def on_double_clicked(self): """ Allows the list click action to be determined dynamically """ if Settings().value(u'advanced/double click live'): - self.onLiveClick() + self.on_live_click() else: - self.onPreviewClick() + self.on_preview_click() - def onSelectionChange(self): + def on_selection_change(self): """ Allows the change of current item in the list to be actioned """ - if Settings().value(u'advanced/single click preview') and self.quickPreviewAllowed \ - and self.listView.selectedIndexes() and self.autoSelectId == -1: - self.onPreviewClick(True) + if Settings().value(u'advanced/single click preview') and self.quick_preview_allowed \ + and self.list_view.selectedIndexes() and self.auto_select_id == -1: + self.on_preview_click(True) - def onPreviewClick(self, keepFocus=False): + def on_preview_click(self, keep_focus=False): """ Preview an item by building a service item then adding that service item to the preview slide controller. """ - if not self.listView.selectedIndexes() and not self.remoteTriggered: + if not self.list_view.selectedIndexes() and not self.remote_triggered: QtGui.QMessageBox.information(self, UiStrings().NISp, translate('OpenLP.MediaManagerItem', 'You must select one or more items to preview.')) else: log.debug(u'%s Preview requested', self.plugin.name) - service_item = self.buildServiceItem() + service_item = self.build_service_item() if service_item: service_item.from_plugin = True self.preview_controller.add_service_item(service_item) - if keepFocus: - self.listView.setFocus() + if keep_focus: + self.list_view.setFocus() - def onLiveClick(self): + def on_live_click(self): """ Send an item live by building a service item then adding that service item to the live slide controller. """ - if not self.listView.selectedIndexes(): + if not self.list_view.selectedIndexes(): QtGui.QMessageBox.information(self, UiStrings().NISp, translate('OpenLP.MediaManagerItem', 'You must select one or more items to send live.')) else: - self.goLive() + self.go_live() - def goLive(self, item_id=None, remote=False): + def go_live(self, item_id=None, remote=False): """ Make the currently selected item go live. """ log.debug(u'%s Live requested', self.plugin.name) item = None if item_id: - item = self.createItemFromId(item_id) - service_item = self.buildServiceItem(item, remote=remote) + item = self.create_item_from_id(item_id) + service_item = self.build_service_item(item, remote=remote) if service_item: if not item_id: service_item.from_plugin = True @@ -497,7 +497,7 @@ class MediaManagerItem(QtGui.QWidget): service_item.will_auto_start = True self.live_controller.add_service_item(service_item) - def createItemFromId(self, item_id): + def create_item_from_id(self, item_id): """ Create a media item from an item id. """ @@ -505,38 +505,38 @@ class MediaManagerItem(QtGui.QWidget): item.setData(QtCore.Qt.UserRole, item_id) return item - def onAddClick(self): + def on_add_click(self): """ Add a selected item to the current service """ - if not self.listView.selectedIndexes(): + if not self.list_view.selectedIndexes(): QtGui.QMessageBox.information(self, UiStrings().NISp, translate('OpenLP.MediaManagerItem', 'You must select one or more items to add.')) else: # Is it possible to process multiple list items to generate # multiple service items? - if self.singleServiceItem: + if self.single_service_item: log.debug(u'%s Add requested', self.plugin.name) - self.addToService(replace=self.remoteTriggered) + self.add_to_service(replace=self.remote_triggered) else: - items = self.listView.selectedIndexes() + items = self.list_view.selectedIndexes() for item in items: - self.addToService(item) + self.add_to_service(item) - def addToService(self, item=None, replace=None, remote=False): + def add_to_service(self, item=None, replace=None, remote=False): """ Add this item to the current service. """ - service_item = self.buildServiceItem(item, True, remote=remote, context=ServiceItemContext.Service) + service_item = self.build_service_item(item, True, remote=remote, context=ServiceItemContext.Service) if service_item: service_item.from_plugin = False self.service_manager.add_service_item(service_item, replace=replace) - def onAddEditClick(self): + def on_add_edit_click(self): """ Add a selected item to an existing item in the current service. """ - if not self.listView.selectedIndexes() and not self.remoteTriggered: + if not self.list_view.selectedIndexes() and not self.remote_triggered: QtGui.QMessageBox.information(self, UiStrings().NISp, translate('OpenLP.MediaManagerItem', 'You must select one or more items.')) else: @@ -546,36 +546,36 @@ class MediaManagerItem(QtGui.QWidget): QtGui.QMessageBox.information(self, UiStrings().NISs, translate('OpenLP.MediaManagerItem', 'You must select an existing service item to add to.')) elif self.plugin.name == service_item.name: - self.generateSlideData(service_item) + self.generate_slide_data(service_item) self.service_manager.add_service_item(service_item, replace=True) else: # Turn off the remote edit update message indicator QtGui.QMessageBox.information(self, translate('OpenLP.MediaManagerItem', 'Invalid Service Item'), translate('OpenLP.MediaManagerItem', 'You must select a %s service item.') % self.title) - def buildServiceItem(self, item=None, xmlVersion=False, remote=False, context=ServiceItemContext.Live): + def build_service_item(self, item=None, xml_version=False, remote=False, context=ServiceItemContext.Live): """ Common method for generating a service item """ service_item = ServiceItem(self.plugin) - service_item.add_icon(self.plugin.iconPath) - if self.generateSlideData(service_item, item, xmlVersion, remote, context): + service_item.add_icon(self.plugin.icon_path) + if self.generate_slide_data(service_item, item, xml_version, remote, context): return service_item else: return None - def serviceLoad(self, message): + def service_load(self, message): """ Method to add processing when a service has been loaded and individual service items need to be processed by the plugins. """ pass - def checkSearchResult(self): + def check_search_result(self): """ - Checks if the listView is empty and adds a "No Search Results" item. + Checks if the list_view is empty and adds a "No Search Results" item. """ - if self.listView.count(): + if self.list_view.count(): return message = translate('OpenLP.MediaManagerItem', 'No Search Results') item = QtGui.QListWidgetItem(message) @@ -583,41 +583,41 @@ class MediaManagerItem(QtGui.QWidget): font = QtGui.QFont() font.setItalic(True) item.setFont(font) - self.listView.addItem(item) + self.list_view.addItem(item) - def _getIdOfItemToGenerate(self, item, remoteItem): + def _get_id_of_item_to_generate(self, item, remote_item): """ Utility method to check items being submitted for slide generation. ``item`` The item to check. - ``remoteItem`` + ``remote_item`` The id to assign if the slide generation was remotely triggered. """ if item is None: - if self.remoteTriggered is None: - item = self.listView.currentItem() + if self.remote_triggered is None: + item = self.list_view.currentItem() if item is None: return False item_id = item.data(QtCore.Qt.UserRole) else: - item_id = remoteItem + item_id = remote_item else: item_id = item.data(QtCore.Qt.UserRole) return item_id - def saveAutoSelectId(self): + def save_auto_select_id(self): """ Sorts out, what item to select after loading a list. """ # The item to select has not been set. - if self.autoSelectId == -1: - item = self.listView.currentItem() + if self.auto_select_id == -1: + item = self.list_view.currentItem() if item: - self.autoSelectId = item.data(QtCore.Qt.UserRole) + self.auto_select_id = item.data(QtCore.Qt.UserRole) - def search(self, string, showError=True): + def search(self, string, show_error=True): """ Performs a plugin specific search for items containing ``string`` """ diff --git a/openlp/core/lib/plugin.py b/openlp/core/lib/plugin.py index b535e4bcd..dd9843930 100644 --- a/openlp/core/lib/plugin.py +++ b/openlp/core/lib/plugin.py @@ -76,7 +76,7 @@ class Plugin(QtCore.QObject): ``version`` The version number of this iteration of the plugin. - ``settingsSection`` + ``settings_section`` The namespace to store settings for the plugin. ``icon`` @@ -90,24 +90,24 @@ class Plugin(QtCore.QObject): **Hook Functions** - ``checkPreConditions()`` + ``check_pre_conditions()`` Provides the Plugin with a handle to check if it can be loaded. - ``createMediaManagerItem()`` + ``create_media_manager_item()`` Creates a new instance of MediaManagerItem to be used in the Media Manager. - ``addImportMenuItem(import_menu)`` + ``add_import_menu_item(import_menu)`` Add an item to the Import menu. - ``addExportMenuItem(export_menu)`` + ``add_export_menu_Item(export_menu)`` Add an item to the Export menu. - ``createSettingsTab()`` + ``create_settings_Tab()`` Creates a new instance of SettingsTabItem to be used in the Settings dialog. - ``addToMenu(menubar)`` + ``add_to_menu(menubar)`` A method to add a menu item to anywhere in the menu, given the menu bar. ``handle_event(event)`` @@ -147,19 +147,19 @@ class Plugin(QtCore.QObject): log.debug(u'Plugin %s initialised' % name) QtCore.QObject.__init__(self) self.name = name - self.textStrings = {} + self.text_strings = {} self.set_plugin_text_strings() - self.nameStrings = self.textStrings[StringContent.Name] + self.name_strings = self.text_strings[StringContent.Name] if version: self.version = version else: self.version = get_application_version()[u'version'] - self.settingsSection = self.name + self.settings_section = self.name self.icon = None - self.mediaItemClass = media_item_class - self.settingsTabClass = settings_tab_class - self.settingsTab = None - self.mediaItem = None + self.media_item_class = media_item_class + self.settings_tab_class = settings_tab_class + self.settings_tab = None + self.media_item = None self.weight = 0 self.status = PluginStatus.Inactive # Add the default status to the default settings. @@ -171,10 +171,10 @@ class Plugin(QtCore.QObject): default_settings[u'%s/%s files' % (name, name)] = [] # Add settings to the dict of all settings. Settings.extend_default_settings(default_settings) - Registry().register_function(u'%s_add_service_item' % self.name, self.processAddServiceEvent) + Registry().register_function(u'%s_add_service_item' % self.name, self.process_add_service_event) Registry().register_function(u'%s_config_updated' % self.name, self.config_update) - def checkPreConditions(self): + def check_pre_conditions(self): """ Provides the Plugin with a handle to check if it can be loaded. Failing Preconditions does not stop a settings Tab being created @@ -183,24 +183,24 @@ class Plugin(QtCore.QObject): """ return True - def setStatus(self): + def set_status(self): """ Sets the status of the plugin """ - self.status = Settings().value(self.settingsSection + u'/status') + self.status = Settings().value(self.settings_section + u'/status') - def toggleStatus(self, new_status): + def toggle_status(self, new_status): """ Changes the status of the plugin and remembers it """ self.status = new_status - Settings().setValue(self.settingsSection + u'/status', self.status) + Settings().setValue(self.settings_section + u'/status', self.status) if new_status == PluginStatus.Active: self.initialise() elif new_status == PluginStatus.Inactive: self.finalise() - def isActive(self): + def is_active(self): """ Indicates if the plugin is active @@ -208,13 +208,13 @@ class Plugin(QtCore.QObject): """ return self.status == PluginStatus.Active - def createMediaManagerItem(self): + def create_media_manager_item(self): """ Construct a MediaManagerItem object with all the buttons and things you need, and return it for integration into OpenLP. """ - if self.mediaItemClass: - self.mediaItem = self.mediaItemClass(self.main_window.media_dock_manager.media_dock, self) + if self.media_item_class: + self.media_item = self.media_item_class(self.main_window.media_dock_manager.media_dock, self) def upgrade_settings(self, settings): """ @@ -225,7 +225,7 @@ class Plugin(QtCore.QObject): """ pass - def addImportMenuItem(self, importMenu): + def add_import_menu_item(self, importMenu): """ Create a menu item and add it to the "Import" menu. @@ -234,7 +234,7 @@ class Plugin(QtCore.QObject): """ pass - def addExportMenuItem(self, exportMenu): + def add_export_menu_Item(self, exportMenu): """ Create a menu item and add it to the "Export" menu. @@ -243,7 +243,7 @@ class Plugin(QtCore.QObject): """ pass - def addToolsMenuItem(self, toolsMenu): + def add_tools_menu_item(self, toolsMenu): """ Create a menu item and add it to the "Tools" menu. @@ -252,16 +252,16 @@ class Plugin(QtCore.QObject): """ pass - def createSettingsTab(self, parent): + def create_settings_Tab(self, parent): """ Create a tab for the settings window to display the configurable options for this plugin to the user. """ - if self.settingsTabClass: - self.settingsTab = self.settingsTabClass(parent, self.name, - self.getString(StringContent.VisibleName)[u'title'], self.iconPath) + if self.settings_tab_class: + self.settings_tab = self.settings_tab_class(parent, self.name, + self.get_string(StringContent.VisibleName)[u'title'], self.icon_path) - def addToMenu(self, menubar): + def add_to_menu(self, menubar): """ Add menu items to the menu, given the menubar. @@ -270,15 +270,15 @@ class Plugin(QtCore.QObject): """ pass - def processAddServiceEvent(self, replace=False): + def process_add_service_event(self, replace=False): """ Generic Drag and drop handler triggered from service_manager. """ - log.debug(u'processAddServiceEvent event called for plugin %s' % self.name) + log.debug(u'process_add_service_event event called for plugin %s' % self.name) if replace: - self.mediaItem.onAddEditClick() + self.media_item.on_add_edit_click() else: - self.mediaItem.onAddClick() + self.media_item.on_add_click() def about(self): """ @@ -291,16 +291,16 @@ class Plugin(QtCore.QObject): """ Called by the plugin Manager to initialise anything it needs. """ - if self.mediaItem: - self.mediaItem.initialise() - self.main_window.media_dock_manager.insert_dock(self.mediaItem, self.icon, self.weight) + if self.media_item: + self.media_item.initialise() + self.main_window.media_dock_manager.insert_dock(self.media_item, self.icon, self.weight) def finalise(self): """ Called by the plugin Manager to cleanup things. """ - if self.mediaItem: - self.main_window.media_dock_manager.remove_dock(self.mediaItem) + if self.media_item: + self.main_window.media_dock_manager.remove_dock(self.media_item) def app_startup(self): """ @@ -309,10 +309,10 @@ class Plugin(QtCore.QObject): # FIXME: Remove after 2.2 release. # This is needed to load the list of images/media/presentation from the config saved # before the settings rewrite. - if self.mediaItemClass is not None and self.name != u'images': + if self.media_item_class is not None and self.name != u'images': loaded_list = Settings().get_files_from_config(self) # Now save the list to the config using our Settings class. - Settings().setValue(u'%s/%s files' % (self.settingsSection, self.name), loaded_list) + Settings().setValue(u'%s/%s files' % (self.settings_section, self.name), loaded_list) def uses_theme(self, theme): """ @@ -334,54 +334,54 @@ class Plugin(QtCore.QObject): """ pass - def getString(self, name): + def get_string(self, name): """ - encapsulate access of plugins translated text strings + Encapsulate access of plugins translated text strings """ - return self.textStrings[name] + return self.text_strings[name] - def setPluginUiTextStrings(self, tooltips): + def set_plugin_ui_text_strings(self, tooltips): """ Called to define all translatable texts of the plugin """ ## Load Action ## - self.__setNameTextString(StringContent.Load, UiStrings().Load, tooltips[u'load']) + self.__set_name_text_string(StringContent.Load, UiStrings().Load, tooltips[u'load']) ## Import Action ## - self.__setNameTextString(StringContent.Import, UiStrings().Import, tooltips[u'import']) + self.__set_name_text_string(StringContent.Import, UiStrings().Import, tooltips[u'import']) ## New Action ## - self.__setNameTextString(StringContent.New, UiStrings().Add, tooltips[u'new']) + self.__set_name_text_string(StringContent.New, UiStrings().Add, tooltips[u'new']) ## Edit Action ## - self.__setNameTextString(StringContent.Edit, UiStrings().Edit, tooltips[u'edit']) + self.__set_name_text_string(StringContent.Edit, UiStrings().Edit, tooltips[u'edit']) ## Delete Action ## - self.__setNameTextString(StringContent.Delete, UiStrings().Delete, tooltips[u'delete']) + self.__set_name_text_string(StringContent.Delete, UiStrings().Delete, tooltips[u'delete']) ## Preview Action ## - self.__setNameTextString(StringContent.Preview, UiStrings().Preview, tooltips[u'preview']) + self.__set_name_text_string(StringContent.Preview, UiStrings().Preview, tooltips[u'preview']) ## Send Live Action ## - self.__setNameTextString(StringContent.Live, UiStrings().Live, tooltips[u'live']) + self.__set_name_text_string(StringContent.Live, UiStrings().Live, tooltips[u'live']) ## Add to Service Action ## - self.__setNameTextString(StringContent.Service, UiStrings().Service, tooltips[u'service']) + self.__set_name_text_string(StringContent.Service, UiStrings().Service, tooltips[u'service']) - def __setNameTextString(self, name, title, tooltip): + def __set_name_text_string(self, name, title, tooltip): """ - Utility method for creating a plugin's textStrings. This method makes + Utility method for creating a plugin's text_strings. This method makes use of the singular name of the plugin object so must only be called after this has been set. """ - self.textStrings[name] = {u'title': title, u'tooltip': tooltip} + self.text_strings[name] = {u'title': title, u'tooltip': tooltip} - def getDisplayCss(self): + def get_display_css(self): """ Add css style sheets to htmlbuilder. """ return u'' - def getDisplayJavaScript(self): + def get_display_javascript(self): """ Add javascript functions to htmlbuilder. """ return u'' - def refreshCss(self, frame): + def refresh_css(self, frame): """ Allow plugins to refresh javascript on displayed screen. @@ -390,7 +390,7 @@ class Plugin(QtCore.QObject): """ return u'' - def getDisplayHtml(self): + def get_display_html(self): """ Add html code to htmlbuilder. """ @@ -401,8 +401,8 @@ class Plugin(QtCore.QObject): Called when Config is changed to restart values dependent on configuration. """ log.info(u'config update processed') - if self.mediaItem: - self.mediaItem.config_update() + if self.media_item: + self.media_item.config_update() def new_service_created(self): """ diff --git a/openlp/core/lib/pluginmanager.py b/openlp/core/lib/pluginmanager.py index 8f4bb89f9..8fc294ea6 100644 --- a/openlp/core/lib/pluginmanager.py +++ b/openlp/core/lib/pluginmanager.py @@ -129,9 +129,9 @@ class PluginManager(object): log.exception(u'Failed to load plugin %s', unicode(p)) plugins_list = sorted(plugin_objects, key=lambda plugin: plugin.weight) for plugin in plugins_list: - if plugin.checkPreConditions(): + if plugin.check_pre_conditions(): log.debug(u'Plugin %s active', unicode(plugin.name)) - plugin.setStatus() + plugin.set_status() else: plugin.status = PluginStatus.Disabled self.plugins.append(plugin) @@ -142,7 +142,7 @@ class PluginManager(object): """ for plugin in self.plugins: if plugin.status is not PluginStatus.Disabled: - plugin.createMediaManagerItem() + plugin.create_media_manager_item() def hook_settings_tabs(self): """ @@ -153,7 +153,7 @@ class PluginManager(object): """ for plugin in self.plugins: if plugin.status is not PluginStatus.Disabled: - plugin.createSettingsTab(self.settings_form) + plugin.create_settings_Tab(self.settings_form) def hook_import_menu(self): """ @@ -163,7 +163,7 @@ class PluginManager(object): """ for plugin in self.plugins: if plugin.status is not PluginStatus.Disabled: - plugin.addImportMenuItem(self.main_window.file_import_menu) + plugin.add_import_menu_item(self.main_window.file_import_menu) def hook_export_menu(self): """ @@ -172,7 +172,7 @@ class PluginManager(object): """ for plugin in self.plugins: if plugin.status is not PluginStatus.Disabled: - plugin.addExportMenuItem(self.main_window.file_export_menu) + plugin.add_export_menu_Item(self.main_window.file_export_menu) def hook_tools_menu(self): """ @@ -181,7 +181,7 @@ class PluginManager(object): """ for plugin in self.plugins: if plugin.status is not PluginStatus.Disabled: - plugin.addToolsMenuItem(self.main_window.tools_menu) + plugin.add_tools_menu_item(self.main_window.tools_menu) def hook_upgrade_plugin_settings(self, settings): """ @@ -201,8 +201,8 @@ class PluginManager(object): """ log.info(u'Initialise Plugins - Started') for plugin in self.plugins: - log.info(u'initialising plugins %s in a %s state' % (plugin.name, plugin.isActive())) - if plugin.isActive(): + log.info(u'initialising plugins %s in a %s state' % (plugin.name, plugin.is_active())) + if plugin.is_active(): plugin.initialise() log.info(u'Initialisation Complete for %s ' % plugin.name) log.info(u'Initialise Plugins - Finished') @@ -214,7 +214,7 @@ class PluginManager(object): """ log.info(u'finalising plugins') for plugin in self.plugins: - if plugin.isActive(): + if plugin.is_active(): plugin.finalise() log.info(u'Finalisation Complete for %s ' % plugin.name) @@ -233,7 +233,7 @@ class PluginManager(object): """ log.info(u'plugins - new service created') for plugin in self.plugins: - if plugin.isActive(): + if plugin.is_active(): plugin.new_service_created() def _get_settings_form(self): diff --git a/openlp/core/lib/serviceitem.py b/openlp/core/lib/serviceitem.py index 3aadabb55..f57243818 100644 --- a/openlp/core/lib/serviceitem.py +++ b/openlp/core/lib/serviceitem.py @@ -419,8 +419,8 @@ class ServiceItem(object): for slide in serviceitem[u'serviceitem'][u'data']: self._raw_frames.append(slide) elif self.service_item_type == ServiceItemType.Image: - settingsSection = serviceitem[u'serviceitem'][u'header'][u'name'] - background = QtGui.QColor(Settings().value(settingsSection + u'/background color')) + settings_section = serviceitem[u'serviceitem'][u'header'][u'name'] + background = QtGui.QColor(Settings().value(settings_section + u'/background color')) if path: self.has_original_files = False for text_image in serviceitem[u'serviceitem'][u'data']: diff --git a/openlp/core/lib/settings.py b/openlp/core/lib/settings.py index 42d4e7161..c9c1bc240 100644 --- a/openlp/core/lib/settings.py +++ b/openlp/core/lib/settings.py @@ -454,7 +454,7 @@ class Settings(QtCore.QSettings): # We need QSettings instead of Settings here to bypass our central settings dict. # Do NOT do this anywhere else! settings = QtCore.QSettings(self.fileName(), Settings.IniFormat) - settings.beginGroup(plugin.settingsSection) + settings.beginGroup(plugin.settings_section) if settings.contains(u'%s count' % plugin.name): # Get the count. list_count = int(settings.value(u'%s count' % plugin.name, 0)) diff --git a/openlp/core/lib/treewidgetwithdnd.py b/openlp/core/lib/treewidgetwithdnd.py index 12ee0d12f..8bcc3c687 100644 --- a/openlp/core/lib/treewidgetwithdnd.py +++ b/openlp/core/lib/treewidgetwithdnd.py @@ -59,7 +59,7 @@ class TreeWidgetWithDnD(QtGui.QTreeWidget): """ self.setAcceptDrops(True) self.setDragDropMode(QtGui.QAbstractItemView.DragDrop) - Registry().register_function((u'%s_dnd' % self.mimeDataText), self.parent().loadFile) + Registry().register_function((u'%s_dnd' % self.mimeDataText), self.parent().load_file) Registry().register_function((u'%s_dnd_internal' % self.mimeDataText), self.parent().dnd_move_internal) def mouseMoveEvent(self, event): diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 712430387..6567ae9ba 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -607,7 +607,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): """ self.application.process_events() for plugin in self.plugin_manager.plugins: - if plugin.isActive(): + if plugin.is_active(): plugin.app_startup() self.application.process_events() @@ -654,10 +654,10 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): self.activePlugin.setStatus() if oldStatus != self.activePlugin.status: if self.activePlugin.status == PluginStatus.Active: - self.activePlugin.toggleStatus(PluginStatus.Active) + self.activePlugin.toggle_status(PluginStatus.Active) self.activePlugin.app_startup() else: - self.activePlugin.toggleStatus(PluginStatus.Inactive) + self.activePlugin.toggle_status(PluginStatus.Inactive) # Set global theme and Registry().execute(u'theme_update_global', self.theme_manager_contents.global_theme) self.theme_manager_contents.load_first_time_themes() diff --git a/openlp/core/ui/media/mediacontroller.py b/openlp/core/ui/media/mediacontroller.py index c6df532e4..9edbda90a 100644 --- a/openlp/core/ui/media/mediacontroller.py +++ b/openlp/core/ui/media/mediacontroller.py @@ -127,7 +127,7 @@ class MediaController(object): """ saved_players = get_media_players()[0] for player in self.media_players.keys(): - self.media_players[player].isActive = player in saved_players + self.media_players[player].is_active = player in saved_players def _generate_extensions_lists(self): """ @@ -135,14 +135,14 @@ class MediaController(object): """ self.audio_extensions_list = [] for player in self.media_players.values(): - if player.isActive: + if player.is_active: for item in player.audio_extensions_list: if not item in self.audio_extensions_list: self.audio_extensions_list.append(item) self.service_manager.supported_suffixes(item[2:]) self.video_extensions_list = [] for player in self.media_players.values(): - if player.isActive: + if player.is_active: for item in player.video_extensions_list: if item not in self.video_extensions_list: self.video_extensions_list.extend(item) @@ -224,7 +224,7 @@ class MediaController(object): """ css = u'' for player in self.media_players.values(): - if player.isActive: + if player.is_active: css += player.get_media_display_css() return css @@ -234,7 +234,7 @@ class MediaController(object): """ js = u'' for player in self.media_players.values(): - if player.isActive: + if player.is_active: js += player.get_media_display_javascript() return js @@ -244,7 +244,7 @@ class MediaController(object): """ html = u'' for player in self.media_players.values(): - if player.isActive: + if player.is_active: html += player.get_media_display_html() return html @@ -325,7 +325,7 @@ class MediaController(object): if preview: display.has_audio = False for player in self.media_players.values(): - if player.isActive: + if player.is_active: player.setup(display) def set_controls_visible(self, controller, value): diff --git a/openlp/core/ui/media/mediaplayer.py b/openlp/core/ui/media/mediaplayer.py index 48e86411e..1b296beb7 100644 --- a/openlp/core/ui/media/mediaplayer.py +++ b/openlp/core/ui/media/mediaplayer.py @@ -46,7 +46,7 @@ class MediaPlayer(object): self.parent = parent self.name = name self.available = self.check_available() - self.isActive = False + self.is_active = False self.can_background = False self.can_folder = False self.state = MediaState.Off diff --git a/openlp/core/ui/mediadockmanager.py b/openlp/core/ui/mediadockmanager.py index 981528fca..2334ce624 100644 --- a/openlp/core/ui/mediadockmanager.py +++ b/openlp/core/ui/mediadockmanager.py @@ -56,7 +56,7 @@ class MediaDockManager(object): ``icon`` An icon for this dock item """ - visible_title = media_item.plugin.getString(StringContent.VisibleName) + visible_title = media_item.plugin.get_string(StringContent.VisibleName) log.info(u'Adding %s dock' % visible_title) self.media_dock.addItem(media_item, icon, visible_title[u'title']) @@ -66,11 +66,11 @@ class MediaDockManager(object): This does not work as it gives a Segmentation error. For now add at end of stack if not present """ - visible_title = media_item.plugin.getString(StringContent.VisibleName) + visible_title = media_item.plugin.get_string(StringContent.VisibleName) log.debug(u'Inserting %s dock' % visible_title[u'title']) match = False for dock_index in range(self.media_dock.count()): - if self.media_dock.widget(dock_index).settingsSection == media_item.plugin.name: + if self.media_dock.widget(dock_index).settings_section == media_item.plugin.name: match = True break if not match: @@ -83,10 +83,10 @@ class MediaDockManager(object): ``media_item`` The item to add to the dock """ - visible_title = media_item.plugin.getString(StringContent.VisibleName) + visible_title = media_item.plugin.get_string(StringContent.VisibleName) log.debug(u'remove %s dock' % visible_title[u'title']) for dock_index in range(self.media_dock.count()): if self.media_dock.widget(dock_index): - if self.media_dock.widget(dock_index).settingsSection == media_item.plugin.name: + if self.media_dock.widget(dock_index).settings_section == media_item.plugin.name: self.media_dock.widget(dock_index).setVisible(False) self.media_dock.removeItem(dock_index) diff --git a/openlp/core/ui/pluginform.py b/openlp/core/ui/pluginform.py index 238cb92c2..954203d26 100644 --- a/openlp/core/ui/pluginform.py +++ b/openlp/core/ui/pluginform.py @@ -79,13 +79,13 @@ class PluginForm(QtGui.QDialog, Ui_PluginViewDialog): else: # PluginStatus.Inactive status_text = translate('OpenLP.PluginForm', '%s (Inactive)') - item.setText(status_text % plugin.nameStrings[u'singular']) + item.setText(status_text % plugin.name_strings[u'singular']) # If the plugin has an icon, set it! if plugin.icon: item.setIcon(plugin.icon) self.pluginListWidget.addItem(item) pluginListWidth = max(pluginListWidth, self.fontMetrics().width( - translate('OpenLP.PluginForm', '%s (Inactive)') % plugin.nameStrings[u'singular'])) + translate('OpenLP.PluginForm', '%s (Inactive)') % plugin.name_strings[u'singular'])) self.pluginListWidget.setFixedWidth(pluginListWidth + self.pluginListWidget.iconSize().width() + 48) def _clearDetails(self): @@ -123,7 +123,7 @@ class PluginForm(QtGui.QDialog, Ui_PluginViewDialog): self.activePlugin = None for plugin in self.plugin_manager.plugins: if plugin.status != PluginStatus.Disabled: - if plugin.nameStrings[u'singular'] == plugin_name_singular: + if plugin.name_strings[u'singular'] == plugin_name_singular: self.activePlugin = plugin break if self.activePlugin: @@ -139,11 +139,11 @@ class PluginForm(QtGui.QDialog, Ui_PluginViewDialog): return if status == PluginStatus.Inactive: self.application.set_busy_cursor() - self.activePlugin.toggleStatus(PluginStatus.Active) + self.activePlugin.toggle_status(PluginStatus.Active) self.application.set_normal_cursor() self.activePlugin.app_startup() else: - self.activePlugin.toggleStatus(PluginStatus.Inactive) + self.activePlugin.toggle_status(PluginStatus.Inactive) status_text = translate('OpenLP.PluginForm', '%s (Inactive)') if self.activePlugin.status == PluginStatus.Active: status_text = translate('OpenLP.PluginForm', '%s (Active)') @@ -152,7 +152,7 @@ class PluginForm(QtGui.QDialog, Ui_PluginViewDialog): elif self.activePlugin.status == PluginStatus.Disabled: status_text = translate('OpenLP.PluginForm', '%s (Disabled)') self.pluginListWidget.currentItem().setText( - status_text % self.activePlugin.nameStrings[u'singular']) + status_text % self.activePlugin.name_strings[u'singular']) def _get_plugin_manager(self): """ diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 647a01e9d..7be147b8a 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -896,7 +896,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog): item = self.find_service_item()[0] service_item = self.service_items[item][u'service_item'] if service_item.timed_slide_interval == 0: - timed_slide_interval = Settings().value(self.mainwindow.generalSettingsSection + u'/loop delay') + timed_slide_interval = Settings().value(self.main_window.general_settings_section + u'/loop delay') else: timed_slide_interval = service_item.timed_slide_interval timed_slide_interval, ok = QtGui.QInputDialog.getInteger(self, translate('OpenLP.ServiceManager', diff --git a/openlp/core/ui/settingsform.py b/openlp/core/ui/settingsform.py index d60b33b3a..eeb85fa66 100644 --- a/openlp/core/ui/settingsform.py +++ b/openlp/core/ui/settingsform.py @@ -70,8 +70,8 @@ class SettingsForm(QtGui.QDialog, Ui_SettingsDialog): self.insert_tab(self.player_tab, 3, PluginStatus.Active) count = 4 for plugin in self.plugin_manager.plugins: - if plugin.settingsTab: - self.insert_tab(plugin.settingsTab, count, plugin.status) + if plugin.settings_tab: + self.insert_tab(plugin.settings_tab, count, plugin.status) count += 1 self.setting_list_widget.setCurrentRow(0) return QtGui.QDialog.exec_(self) @@ -132,8 +132,8 @@ class SettingsForm(QtGui.QDialog, Ui_SettingsDialog): self.advanced_tab.post_set_up() self.player_tab.post_set_up() for plugin in self.plugin_manager.plugins: - if plugin.settingsTab: - plugin.settingsTab.post_set_up() + if plugin.settings_tab: + plugin.settings_tab.post_set_up() def tab_changed(self, tabIndex): """ diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index 97c24e467..4e7341081 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -912,9 +912,9 @@ class SlideController(DisplayController): self.theme_screen.setChecked(False) self.desktop_screen.setChecked(False) if checked: - Settings().setValue(self.main_window.generalSettingsSection + u'/screen blank', u'blanked') + Settings().setValue(self.main_window.general_settings_section + u'/screen blank', u'blanked') else: - Settings().remove(self.main_window.generalSettingsSection + u'/screen blank') + Settings().remove(self.main_window.general_settings_section + u'/screen blank') self.blankPlugin() self.updatePreview() self.onToggleLoop() @@ -931,9 +931,9 @@ class SlideController(DisplayController): self.theme_screen.setChecked(checked) self.desktop_screen.setChecked(False) if checked: - Settings().setValue(self.main_window.generalSettingsSection + u'/screen blank', u'themed') + Settings().setValue(self.main_window.general_settings_section + u'/screen blank', u'themed') else: - Settings().remove(self.main_window.generalSettingsSection + u'/screen blank') + Settings().remove(self.main_window.general_settings_section + u'/screen blank') self.blankPlugin() self.updatePreview() self.onToggleLoop() @@ -950,9 +950,9 @@ class SlideController(DisplayController): self.theme_screen.setChecked(False) self.desktop_screen.setChecked(checked) if checked: - Settings().setValue(self.main_window.generalSettingsSection + u'/screen blank', u'hidden') + Settings().setValue(self.main_window.general_settings_section + u'/screen blank', u'hidden') else: - Settings().remove(self.main_window.generalSettingsSection + u'/screen blank') + Settings().remove(self.main_window.general_settings_section + u'/screen blank') self.hidePlugin(checked) self.updatePreview() self.onToggleLoop() diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index edee2cfb2..89bbe86f8 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -61,7 +61,7 @@ class ThemeManager(QtGui.QWidget): Registry().register(u'theme_manager', self) Registry().register_function(u'bootstrap_initialise', self.load_first_time_themes) Registry().register_function(u'bootstrap_post_set_up', self._push_themes) - self.settingsSection = u'themes' + self.settings_section = u'themes' self.theme_form = ThemeForm(self) self.file_rename_form = FileRenameForm() # start with the layout @@ -135,7 +135,7 @@ class ThemeManager(QtGui.QWidget): Registry().register_function(u'theme_update_global', self.change_global_from_tab) # Variables self.theme_list = [] - self.path = AppLocation.get_section_data_path(self.settingsSection) + self.path = AppLocation.get_section_data_path(self.settings_section) check_directory_exists(self.path) self.thumb_path = os.path.join(self.path, u'thumbnails') check_directory_exists(self.thumb_path) @@ -143,7 +143,7 @@ class ThemeManager(QtGui.QWidget): self.old_background_image = None self.bad_v1_name_chars = re.compile(r'[%+\[\]]') # Last little bits of setting up - self.global_theme = Settings().value(self.settingsSection + u'/global theme') + self.global_theme = Settings().value(self.settings_section + u'/global theme') def check_list_state(self, item): """ @@ -179,7 +179,7 @@ class ThemeManager(QtGui.QWidget): """ Change the global theme when it is changed through the Themes settings tab """ - self.global_theme = Settings().value(self.settingsSection + u'/global theme') + self.global_theme = Settings().value(self.settings_section + u'/global theme') log.debug(u'change_global_from_tab %s', self.global_theme) for count in range(0, self.theme_list_widget.count()): # reset the old name @@ -212,7 +212,7 @@ class ThemeManager(QtGui.QWidget): self.global_theme = self.theme_list_widget.item(count).text() name = translate('OpenLP.ThemeManager', '%s (default)') % self.global_theme self.theme_list_widget.item(count).setText(name) - Settings().setValue(self.settingsSection + u'/global theme', self.global_theme) + Settings().setValue(self.settings_section + u'/global theme', self.global_theme) Registry().execute(u'theme_update_global') self._push_themes() @@ -342,10 +342,10 @@ class ThemeManager(QtGui.QWidget): theme = item.data(QtCore.Qt.UserRole) path = QtGui.QFileDialog.getExistingDirectory(self, translate('OpenLP.ThemeManager', 'Save Theme - (%s)') % theme, - Settings().value(self.settingsSection + u'/last directory export')) + Settings().value(self.settings_section + u'/last directory export')) self.application.set_busy_cursor() if path: - Settings().setValue(self.settingsSection + u'/last directory export', path) + Settings().setValue(self.settings_section + u'/last directory export', path) theme_path = os.path.join(path, theme + u'.otz') theme_zip = None try: @@ -375,14 +375,14 @@ class ThemeManager(QtGui.QWidget): """ files = QtGui.QFileDialog.getOpenFileNames(self, translate('OpenLP.ThemeManager', 'Select Theme Import File'), - Settings().value(self.settingsSection + u'/last directory import'), + Settings().value(self.settings_section + u'/last directory import'), translate('OpenLP.ThemeManager', 'OpenLP Themes (*.theme *.otz)')) log.info(u'New Themes %s', unicode(files)) if not files: return self.application.set_busy_cursor() for file_name in files: - Settings().setValue(self.settingsSection + u'/last directory import', unicode(file_name)) + Settings().setValue(self.settings_section + u'/last directory import', unicode(file_name)) self.unzip_theme(file_name, self.path) self.load_themes() self.application.set_normal_cursor() @@ -392,18 +392,18 @@ class ThemeManager(QtGui.QWidget): Imports any themes on start up and makes sure there is at least one theme """ self.application.set_busy_cursor() - files = AppLocation.get_files(self.settingsSection, u'.otz') + files = AppLocation.get_files(self.settings_section, u'.otz') for theme_file in files: theme_file = os.path.join(self.path, theme_file) self.unzip_theme(theme_file, self.path) delete_file(theme_file) - files = AppLocation.get_files(self.settingsSection, u'.png') + files = AppLocation.get_files(self.settings_section, u'.png') # No themes have been found so create one if not files: theme = ThemeXML() theme.theme_name = UiStrings().Default self._write_theme(theme, None, None) - Settings().setValue(self.settingsSection + u'/global theme', theme.theme_name) + Settings().setValue(self.settings_section + u'/global theme', theme.theme_name) self.application.set_normal_cursor() self.load_themes() @@ -416,7 +416,7 @@ class ThemeManager(QtGui.QWidget): log.debug(u'Load themes from dir') self.theme_list = [] self.theme_list_widget.clear() - files = AppLocation.get_files(self.settingsSection, u'.png') + files = AppLocation.get_files(self.settings_section, u'.png') # Sort the themes by its name considering language specific files.sort(key=lambda file_name: unicode(file_name), cmp=locale_compare) # now process the file list of png files @@ -718,7 +718,7 @@ class ThemeManager(QtGui.QWidget): Check to see if theme has been selected and the destructive action is allowed. """ - self.global_theme = Settings().value(self.settingsSection + u'/global theme') + self.global_theme = Settings().value(self.settings_section + u'/global theme') if check_item_selected(self.theme_list_widget, select_text): item = self.theme_list_widget.currentItem() theme = item.text() diff --git a/openlp/core/ui/wizard.py b/openlp/core/ui/wizard.py index d0a6cf422..f8b32a9c0 100644 --- a/openlp/core/ui/wizard.py +++ b/openlp/core/ui/wizard.py @@ -277,10 +277,10 @@ class OpenLPWizard(QtGui.QWizard): filters += u';;' filters += u'%s (*)' % UiStrings().AllFiles filename = QtGui.QFileDialog.getOpenFileName(self, title, - os.path.dirname(Settings().value(self.plugin.settingsSection + u'/' + setting_name)), filters) + os.path.dirname(Settings().value(self.plugin.settings_section + u'/' + setting_name)), filters) if filename: editbox.setText(filename) - Settings().setValue(self.plugin.settingsSection + u'/' + setting_name, filename) + Settings().setValue(self.plugin.settings_section + u'/' + setting_name, filename) def get_folder(self, title, editbox, setting_name): """ @@ -296,10 +296,10 @@ class OpenLPWizard(QtGui.QWizard): The place where to save the last opened directory. """ folder = QtGui.QFileDialog.getExistingDirectory(self, title, - Settings().value(self.plugin.settingsSection + u'/' + setting_name), QtGui.QFileDialog.ShowDirsOnly) + Settings().value(self.plugin.settings_section + u'/' + setting_name), QtGui.QFileDialog.ShowDirsOnly) if folder: editbox.setText(folder) - Settings().setValue(self.plugin.settingsSection + u'/' + setting_name, folder) + Settings().setValue(self.plugin.settings_section + u'/' + setting_name, folder) def _get_application(self): """ diff --git a/openlp/plugins/alerts/alertsplugin.py b/openlp/plugins/alerts/alertsplugin.py index 15516d054..452b45713 100644 --- a/openlp/plugins/alerts/alertsplugin.py +++ b/openlp/plugins/alerts/alertsplugin.py @@ -131,13 +131,13 @@ class AlertsPlugin(Plugin): def __init__(self): Plugin.__init__(self, u'alerts', __default_settings__, settings_tab_class=AlertsTab) self.weight = -3 - self.iconPath = u':/plugins/plugin_alerts.png' - self.icon = build_icon(self.iconPath) + self.icon_path = u':/plugins/plugin_alerts.png' + self.icon = build_icon(self.icon_path) self.alerts_manager = AlertsManager(self) self.manager = Manager(u'alerts', init_schema) - self.alertForm = AlertForm(self) + self.alert_form = AlertForm(self) - def addToolsMenuItem(self, tools_menu): + def add_tools_menu_item(self, tools_menu): """ Give the alerts plugin the opportunity to add items to the **Tools** menu. @@ -147,18 +147,18 @@ class AlertsPlugin(Plugin): use it as their parent. """ log.info(u'add tools menu') - self.toolsAlertItem = create_action(tools_menu, u'toolsAlertItem', + self.tools_alert_item = create_action(tools_menu, u'toolsAlertItem', text=translate('AlertsPlugin', '&Alert'), icon=u':/plugins/plugin_alerts.png', statustip=translate('AlertsPlugin', 'Show an alert message.'), - visible=False, can_shortcuts=True, triggers=self.onAlertsTrigger) - self.main_window.tools_menu.addAction(self.toolsAlertItem) + visible=False, can_shortcuts=True, triggers=self.on_alerts_trigger) + self.main_window.tools_menu.addAction(self.tools_alert_item) def initialise(self): log.info(u'Alerts Initialising') Plugin.initialise(self) - self.toolsAlertItem.setVisible(True) + self.tools_alert_item.setVisible(True) action_list = ActionList.get_instance() - action_list.add_action(self.toolsAlertItem, UiStrings().Tools) + action_list.add_action(self.tools_alert_item, UiStrings().Tools) def finalise(self): """ @@ -167,17 +167,17 @@ class AlertsPlugin(Plugin): log.info(u'Alerts Finalising') self.manager.finalise() Plugin.finalise(self) - self.toolsAlertItem.setVisible(False) + self.tools_alert_item.setVisible(False) action_list = ActionList.get_instance() - action_list.remove_action(self.toolsAlertItem, u'Tools') + action_list.remove_action(self.tools_alert_item, u'Tools') - def toggleAlertsState(self): - self.alertsActive = not self.alertsActive - Settings().setValue(self.settingsSection + u'/active', self.alertsActive) + def toggle_alerts_state(self): + self.alerts_active = not self.alerts_active + Settings().setValue(self.settings_section + u'/active', self.alerts_active) - def onAlertsTrigger(self): - self.alertForm.load_list() - self.alertForm.exec_() + def on_alerts_trigger(self): + self.alert_form.load_list() + self.alert_form.exec_() def about(self): about_text = translate('AlertsPlugin', 'Alerts Plugin' @@ -189,36 +189,36 @@ class AlertsPlugin(Plugin): Called to define all translatable texts of the plugin """ ## Name PluginList ## - self.textStrings[StringContent.Name] = { + self.text_strings[StringContent.Name] = { u'singular': translate('AlertsPlugin', 'Alert', 'name singular'), u'plural': translate('AlertsPlugin', 'Alerts', 'name plural') } ## Name for MediaDockManager, SettingsManager ## - self.textStrings[StringContent.VisibleName] = { + self.text_strings[StringContent.VisibleName] = { u'title': translate('AlertsPlugin', 'Alerts', 'container title') } - def getDisplayJavaScript(self): + def get_display_javascript(self): """ Add Javascript to the main display. """ return JAVASCRIPT - def getDisplayCss(self): + def get_display_css(self): """ Add CSS to the main display. """ - align = VerticalType.Names[self.settingsTab.location] - return CSS % (align, self.settingsTab.font_face, self.settingsTab.font_size, self.settingsTab.font_color, - self.settingsTab.background_color) + align = VerticalType.Names[self.settings_tab.location] + return CSS % (align, self.settings_tab.font_face, self.settings_tab.font_size, self.settings_tab.font_color, + self.settings_tab.background_color) - def getDisplayHtml(self): + def get_display_html(self): """ Add HTML to the main display. """ return HTML - def refreshCss(self, frame): + def refresh_css(self, frame): """ Trigger an update of the CSS in the maindisplay. diff --git a/openlp/plugins/bibles/bibleplugin.py b/openlp/plugins/bibles/bibleplugin.py index dcf3bc1b3..1f17ae39a 100644 --- a/openlp/plugins/bibles/bibleplugin.py +++ b/openlp/plugins/bibles/bibleplugin.py @@ -62,7 +62,7 @@ __default_settings__ = { u'bibles/list separator': u'', u'bibles/end separator': u'', u'bibles/last directory import': u'' - } +} class BiblePlugin(Plugin): @@ -71,8 +71,8 @@ class BiblePlugin(Plugin): def __init__(self): Plugin.__init__(self, u'bibles', __default_settings__, BibleMediaItem, BiblesTab) self.weight = -9 - self.iconPath = u':/plugins/plugin_bibles.png' - self.icon = build_icon(self.iconPath) + self.icon_path = u':/plugins/plugin_bibles.png' + self.icon = build_icon(self.icon_path) self.manager = None def initialise(self): @@ -80,14 +80,14 @@ class BiblePlugin(Plugin): if self.manager is None: self.manager = BibleManager(self) Plugin.initialise(self) - self.importBibleItem.setVisible(True) + self.import_bible_item.setVisible(True) action_list = ActionList.get_instance() - action_list.add_action(self.importBibleItem, UiStrings().Import) + action_list.add_action(self.import_bible_item, UiStrings().Import) # Do not add the action to the list yet. - #action_list.add_action(self.exportBibleItem, UiStrings().Export) + #action_list.add_action(self.export_bible_item, UiStrings().Export) # Set to invisible until we can export bibles - self.exportBibleItem.setVisible(False) - self.toolsUpgradeItem.setVisible(bool(self.manager.old_bible_databases)) + self.export_bible_item.setVisible(False) + self.tools_upgrade_item.setVisible(bool(self.manager.old_bible_databases)) def finalise(self): """ @@ -97,10 +97,10 @@ class BiblePlugin(Plugin): self.manager.finalise() Plugin.finalise(self) action_list = ActionList.get_instance() - action_list.remove_action(self.importBibleItem, UiStrings().Import) - self.importBibleItem.setVisible(False) - #action_list.remove_action(self.exportBibleItem, UiStrings().Export) - self.exportBibleItem.setVisible(False) + action_list.remove_action(self.import_bible_item, UiStrings().Import) + self.import_bible_item.setVisible(False) + #action_list.remove_action(self.export_bible_item, UiStrings().Export) + self.export_bible_item.setVisible(False) def app_startup(self): """ @@ -114,21 +114,21 @@ class BiblePlugin(Plugin): 'Should OpenLP upgrade now?'), QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes | QtGui.QMessageBox.No)) == \ QtGui.QMessageBox.Yes: - self.onToolsUpgradeItemTriggered() + self.on_tools_upgrade_Item_triggered() - def addImportMenuItem(self, import_menu): - self.importBibleItem = create_action(import_menu, u'importBibleItem', + def add_import_menu_item(self, import_menu): + self.import_bible_item = create_action(import_menu, u'importBibleItem', text=translate('BiblesPlugin', '&Bible'), visible=False, - triggers=self.onBibleImportClick) - import_menu.addAction(self.importBibleItem) + triggers=self.on_bible_import_click) + import_menu.addAction(self.import_bible_item) - def addExportMenuItem(self, export_menu): - self.exportBibleItem = create_action(export_menu, u'exportBibleItem', + def add_export_menu_Item(self, export_menu): + self.export_bible_item = create_action(export_menu, u'exportBibleItem', text=translate('BiblesPlugin', '&Bible'), visible=False) - export_menu.addAction(self.exportBibleItem) + export_menu.addAction(self.export_bible_item) - def addToolsMenuItem(self, tools_menu): + def add_tools_menu_item(self, tools_menu): """ Give the bible plugin the opportunity to add items to the **Tools** menu. @@ -138,13 +138,13 @@ class BiblePlugin(Plugin): use it as their parent. """ log.debug(u'add tools menu') - self.toolsUpgradeItem = create_action(tools_menu, u'toolsUpgradeItem', + self.tools_upgrade_item = create_action(tools_menu, u'toolsUpgradeItem', text=translate('BiblesPlugin', '&Upgrade older Bibles'), statustip=translate('BiblesPlugin', 'Upgrade the Bible databases to the latest format.'), - visible=False, triggers=self.onToolsUpgradeItemTriggered) - tools_menu.addAction(self.toolsUpgradeItem) + visible=False, triggers=self.on_tools_upgrade_Item_triggered) + tools_menu.addAction(self.tools_upgrade_item) - def onToolsUpgradeItemTriggered(self): + def on_tools_upgrade_Item_triggered(self): """ Upgrade older bible databases. """ @@ -152,11 +152,11 @@ class BiblePlugin(Plugin): self.upgrade_wizard = BibleUpgradeForm(self.main_window, self.manager, self) # If the import was not cancelled then reload. if self.upgrade_wizard.exec_(): - self.mediaItem.reloadBibles() + self.media_item.reloadBibles() - def onBibleImportClick(self): - if self.mediaItem: - self.mediaItem.onImportClick() + def on_bible_import_click(self): + if self.media_item: + self.media_item.on_import_click() def about(self): about_text = translate('BiblesPlugin', 'Bible Plugin' @@ -170,7 +170,7 @@ class BiblePlugin(Plugin): Returns ``True`` if the theme is being used, otherwise returns ``False``. """ - return unicode(self.settingsTab.bible_theme) == theme + return unicode(self.settings_tab.bible_theme) == theme def rename_theme(self, oldTheme, newTheme): """ @@ -184,20 +184,20 @@ class BiblePlugin(Plugin): ``newTheme`` The new name the plugin should now use. """ - self.settingsTab.bible_theme = newTheme - self.settingsTab.save() + self.settings_tab.bible_theme = newTheme + self.settings_tab.save() def set_plugin_text_strings(self): """ Called to define all translatable texts of the plugin """ ## Name PluginList ## - self.textStrings[StringContent.Name] = { + self.text_strings[StringContent.Name] = { u'singular': translate('BiblesPlugin', 'Bible', 'name singular'), u'plural': translate('BiblesPlugin', 'Bibles', 'name plural') } ## Name for MediaDockManager, SettingsManager ## - self.textStrings[StringContent.VisibleName] = { + self.text_strings[StringContent.VisibleName] = { u'title': translate('BiblesPlugin', 'Bibles', 'container title') } # Middle Header Bar @@ -212,4 +212,4 @@ class BiblePlugin(Plugin): u'live': translate('BiblesPlugin', 'Send the selected Bible live.'), u'service': translate('BiblesPlugin', 'Add the selected Bible to the service.') } - self.setPluginUiTextStrings(tooltips) + self.set_plugin_ui_text_strings(tooltips) diff --git a/openlp/plugins/bibles/forms/bibleimportform.py b/openlp/plugins/bibles/forms/bibleimportform.py index 8f94771fd..e360cd4a1 100644 --- a/openlp/plugins/bibles/forms/bibleimportform.py +++ b/openlp/plugins/bibles/forms/bibleimportform.py @@ -515,7 +515,7 @@ class BibleImportForm(OpenLPWizard): Set default values for the wizard pages. """ settings = Settings() - settings.beginGroup(self.plugin.settingsSection) + settings.beginGroup(self.plugin.settings_section) self.restart() self.finish_button.setVisible(False) self.cancel_button.setVisible(True) @@ -634,4 +634,4 @@ class BibleImportForm(OpenLPWizard): else: self.progress_label.setText(translate('BiblesPlugin.ImportWizardForm', 'Your Bible import failed.')) del self.manager.db_cache[importer.name] - delete_database(self.plugin.settingsSection, importer.file) + delete_database(self.plugin.settings_section, importer.file) diff --git a/openlp/plugins/bibles/forms/bibleupgradeform.py b/openlp/plugins/bibles/forms/bibleupgradeform.py index 7c1017a11..0127d19be 100644 --- a/openlp/plugins/bibles/forms/bibleupgradeform.py +++ b/openlp/plugins/bibles/forms/bibleupgradeform.py @@ -53,7 +53,7 @@ class BibleUpgradeForm(OpenLPWizard): """ log.info(u'BibleUpgradeForm loaded') - def __init__(self, parent, manager, bibleplugin): + def __init__(self, parent, manager, bible_plugin): """ Instantiate the wizard, and run any extra setup we need to. @@ -67,15 +67,15 @@ class BibleUpgradeForm(OpenLPWizard): The Bible plugin. """ self.manager = manager - self.mediaItem = bibleplugin.mediaItem + self.media_item = bible_plugin.media_item self.suffix = u'.sqlite' - self.settingsSection = u'bibles' - self.path = AppLocation.get_section_data_path(self.settingsSection) + self.settings_section = u'bibles' + self.path = AppLocation.get_section_data_path(self.settings_section) self.temp_dir = os.path.join(unicode(gettempdir(), get_filesystem_encoding()), u'openlp') self.files = self.manager.old_bible_databases self.success = {} self.newbibles = {} - OpenLPWizard.__init__(self, parent, bibleplugin, u'bibleUpgradeWizard', u':/wizards/wizard_importbible.bmp') + OpenLPWizard.__init__(self, parent, bible_plugin, u'bibleUpgradeWizard', u':/wizards/wizard_importbible.bmp') def setupUi(self, image): """ @@ -218,7 +218,7 @@ class BibleUpgradeForm(OpenLPWizard): """ self.checkBox = {} for number, filename in enumerate(self.files): - bible = OldBibleDB(self.mediaItem, path=self.path, file=filename[0]) + bible = OldBibleDB(self.media_item, path=self.path, file=filename[0]) self.checkBox[number] = QtGui.QCheckBox(self.scrollAreaContents) self.checkBox[number].setObjectName(u'checkBox[%d]' % number) self.checkBox[number].setText(bible.get_name()) @@ -313,7 +313,7 @@ class BibleUpgradeForm(OpenLPWizard): """ log.debug(u'BibleUpgrade setDefaults') settings = Settings() - settings.beginGroup(self.plugin.settingsSection) + settings.beginGroup(self.plugin.settings_section) self.stop_import_flag = False self.success.clear() self.newbibles.clear() @@ -367,12 +367,12 @@ class BibleUpgradeForm(OpenLPWizard): self.success[number] = False continue self.progress_bar.reset() - old_bible = OldBibleDB(self.mediaItem, path=self.temp_dir, + old_bible = OldBibleDB(self.media_item, path=self.temp_dir, file=filename[0]) name = filename[1] self.progress_label.setText(translate('BiblesPlugin.UpgradeWizardForm', 'Upgrading Bible %s of %s: "%s"\nUpgrading ...') % (number + 1, max_bibles, name)) - self.newbibles[number] = BibleDB(self.mediaItem, path=self.path, name=name, file=filename[0]) + self.newbibles[number] = BibleDB(self.media_item, path=self.path, name=name, file=filename[0]) self.newbibles[number].register(self.plugin.upgrade_wizard) metadata = old_bible.get_metadata() web_bible = False diff --git a/openlp/plugins/bibles/forms/editbibleform.py b/openlp/plugins/bibles/forms/editbibleform.py index 939cd8383..cbb02109a 100644 --- a/openlp/plugins/bibles/forms/editbibleform.py +++ b/openlp/plugins/bibles/forms/editbibleform.py @@ -46,12 +46,12 @@ class EditBibleForm(QtGui.QDialog, Ui_EditBibleDialog): """ log.info(u'%s EditBibleForm loaded', __name__) - def __init__(self, mediaitem, parent, manager): + def __init__(self, media_item, parent, manager): """ Constructor """ QtGui.QDialog.__init__(self, parent) - self.mediaitem = mediaitem + self.media_item = media_item self.book_names = BibleStrings().BookNames self.setupUi(self) self.manager = manager diff --git a/openlp/plugins/bibles/lib/manager.py b/openlp/plugins/bibles/lib/manager.py index 987817bdc..15c2e5d80 100644 --- a/openlp/plugins/bibles/lib/manager.py +++ b/openlp/plugins/bibles/lib/manager.py @@ -120,11 +120,11 @@ class BibleManager(object): """ log.debug(u'Bible Initialising') self.parent = parent - self.settingsSection = u'bibles' + self.settings_section = u'bibles' self.web = u'Web' self.db_cache = None - self.path = AppLocation.get_section_data_path(self.settingsSection) - self.proxy_name = Settings().value(self.settingsSection + u'/proxy name') + self.path = AppLocation.get_section_data_path(self.settings_section) + self.proxy_name = Settings().value(self.settings_section + u'/proxy name') self.suffix = u'.sqlite' self.import_wizard = None self.reload_bibles() @@ -137,7 +137,7 @@ class BibleManager(object): BibleDB class. """ log.debug(u'Reload bibles') - files = AppLocation.get_files(self.settingsSection, self.suffix) + files = AppLocation.get_files(self.settings_section, self.suffix) if u'alternative_book_names.sqlite' in files: files.remove(u'alternative_book_names.sqlite') log.debug(u'Bible Files %s', files) @@ -352,7 +352,7 @@ class BibleManager(object): if not language_selection or language_selection.value == "None" or language_selection.value == "-1": # If None is returned, it's not the singleton object but a # BibleMeta object with the value "None" - language_selection = Settings().value(self.settingsSection + u'/book name language') + language_selection = Settings().value(self.settings_section + u'/book name language') else: language_selection = language_selection.value try: diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index 1d7912dd1..2bb3fb383 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -60,27 +60,27 @@ class BibleMediaItem(MediaManagerItem): log.info(u'Bible Media Item loaded') def __init__(self, parent, plugin): - self.IconPath = u'songs/song' + self.icon_path = u'songs/song' self.lockIcon = build_icon(u':/bibles/bibles_search_lock.png') self.unlockIcon = build_icon(u':/bibles/bibles_search_unlock.png') MediaManagerItem.__init__(self, parent, plugin) # Place to store the search results for both bibles. - self.settings = self.plugin.settingsTab - self.quickPreviewAllowed = True + self.settings = self.plugin.settings_tab + self.quick_preview_allowed = True self.hasSearch = True self.search_results = {} self.second_search_results = {} - self.checkSearchResult() + self.check_search_result() Registry().register_function(u'bibles_load_list', self.reload_bibles) def __checkSecondBible(self, bible, second_bible): """ Check if the first item is a second bible item or not. """ - bitem = self.listView.item(0) + bitem = self.list_view.item(0) if not bitem.flags() & QtCore.Qt.ItemIsSelectable: # The item is the "No Search Results" item. - self.listView.clear() + self.list_view.clear() self.displayResults(bible, second_bible) return else: @@ -92,7 +92,7 @@ class BibleMediaItem(MediaManagerItem): 'You cannot combine single and dual Bible verse search results. ' 'Do you want to delete your search results and start a new search?'), parent=self, question=True) == QtGui.QMessageBox.Yes: - self.listView.clear() + self.list_view.clear() self.displayResults(bible, second_bible) def _decodeQtObject(self, bitem, key): @@ -100,13 +100,16 @@ class BibleMediaItem(MediaManagerItem): obj = reference[unicode(key)] return unicode(obj).strip() - def requiredIcons(self): - MediaManagerItem.requiredIcons(self) - self.hasImportIcon = True - self.hasNewIcon = False - self.hasEditIcon = True - self.hasDeleteIcon = True - self.addToServiceItem = False + def required_icons(self): + """ + Set which icons the media manager tab should show + """ + MediaManagerItem.required_icons(self) + self.has_import_icon = True + self.has_new_icon = False + self.has_edit_icon = True + self.has_delete_icon = True + self.add_to_service_item = False def addSearchTab(self, prefix, name): self.searchTabBar.addTab(name) @@ -152,19 +155,19 @@ class BibleMediaItem(MediaManagerItem): styleComboBox = create_horizontal_adjusting_combo_box(tab, prefix + u'StyleComboBox') styleComboBox.addItems([u'', u'', u'']) layout.addWidget(styleComboBox, idx + 2, 1, 1, 2) - searchButtonLayout = QtGui.QHBoxLayout() - searchButtonLayout.setObjectName(prefix + u'SearchButtonLayout') - searchButtonLayout.addStretch() + search_button_layout = QtGui.QHBoxLayout() + search_button_layout.setObjectName(prefix + u'search_button_layout') + search_button_layout.addStretch() lockButton = QtGui.QToolButton(tab) lockButton.setIcon(self.unlockIcon) lockButton.setCheckable(True) lockButton.setObjectName(prefix + u'LockButton') - searchButtonLayout.addWidget(lockButton) + search_button_layout.addWidget(lockButton) searchButton = QtGui.QPushButton(tab) searchButton.setObjectName(prefix + u'SearchButton') - searchButtonLayout.addWidget(searchButton) - layout.addLayout(searchButtonLayout, idx + 3, 1, 1, 2) - self.pageLayout.addWidget(tab) + search_button_layout.addWidget(searchButton) + layout.addLayout(search_button_layout, idx + 3, 1, 1, 2) + self.page_layout.addWidget(tab) tab.setVisible(False) lockButton.toggled.connect(self.onLockButtonToggled) setattr(self, prefix + u'VersionLabel', versionLabel) @@ -174,14 +177,14 @@ class BibleMediaItem(MediaManagerItem): setattr(self, prefix + u'StyleLabel', styleLabel) setattr(self, prefix + u'StyleComboBox', styleComboBox) setattr(self, prefix + u'LockButton', lockButton) - setattr(self, prefix + u'SearchButtonLayout', searchButtonLayout) + setattr(self, prefix + u'SearchButtonLayout', search_button_layout) setattr(self, prefix + u'SearchButton', searchButton) - def addEndHeaderBar(self): + def add_end_header_bar(self): self.searchTabBar = QtGui.QTabBar(self) self.searchTabBar.setExpanding(False) self.searchTabBar.setObjectName(u'searchTabBar') - self.pageLayout.addWidget(self.searchTabBar) + self.page_layout.addWidget(self.searchTabBar) # Add the Quick Search tab. self.addSearchTab(u'quick', translate('BiblesPlugin.MediaItem', 'Quick')) self.quickSearchLabel = QtGui.QLabel(self.quickTab) @@ -255,7 +258,7 @@ class BibleMediaItem(MediaManagerItem): def config_update(self): log.debug(u'config_update') - if Settings().value(self.settingsSection + u'/second bibles'): + if Settings().value(self.settings_section + u'/second bibles'): self.advancedSecondLabel.setVisible(True) self.advancedSecondComboBox.setVisible(True) self.quickSecondLabel.setVisible(True) @@ -307,7 +310,7 @@ class BibleMediaItem(MediaManagerItem): translate('BiblesPlugin.MediaItem', 'Text Search'), translate('BiblesPlugin.MediaItem', 'Search Text...')) ]) - self.quickSearchEdit.set_current_search_type(Settings().value(u'%s/last search type' % self.settingsSection)) + self.quickSearchEdit.set_current_search_type(Settings().value(u'%s/last search type' % self.settings_section)) self.config_update() log.debug(u'bible manager initialise complete') @@ -329,13 +332,13 @@ class BibleMediaItem(MediaManagerItem): self.advancedVersionComboBox.addItems(bibles) self.advancedSecondComboBox.addItems(bibles) # set the default value - bible = Settings().value(self.settingsSection + u'/advanced bible') + bible = Settings().value(self.settings_section + u'/advanced bible') if bible in bibles: find_and_set_in_combo_box(self.advancedVersionComboBox, bible) self.initialiseAdvancedBible(unicode(bible)) elif bibles: self.initialiseAdvancedBible(bibles[0]) - bible = Settings().value(self.settingsSection + u'/quick bible') + bible = Settings().value(self.settings_section + u'/quick bible') find_and_set_in_combo_box(self.quickVersionComboBox, bible) def reload_bibles(self, process=False): @@ -427,9 +430,9 @@ class BibleMediaItem(MediaManagerItem): """ log.debug(u'updateAutoCompleter') # Save the current search type to the configuration. - Settings().setValue(u'%s/last search type' % self.settingsSection, self.quickSearchEdit.current_search_type()) + Settings().setValue(u'%s/last search type' % self.settings_section, self.quickSearchEdit.current_search_type()) # Save the current bible to the configuration. - Settings().setValue(self.settingsSection + u'/quick bible', self.quickVersionComboBox.currentText()) + Settings().setValue(self.settings_section + u'/quick bible', self.quickVersionComboBox.currentText()) books = [] # We have to do a 'Reference Search'. if self.quickSearchEdit.current_search_type() == BibleSearch.Reference: @@ -461,14 +464,14 @@ class BibleMediaItem(MediaManagerItem): books.sort(cmp=locale_compare) set_case_insensitive_completer(books, self.quickSearchEdit) - def onImportClick(self): + def on_import_click(self): if not hasattr(self, u'import_wizard'): self.import_wizard = BibleImportForm(self, self.plugin.manager, self.plugin) # If the import was not cancelled then reload. if self.import_wizard.exec_(): self.reload_bibles() - def onEditClick(self): + def on_edit_click(self): if self.quickTab.isVisible(): bible = self.quickVersionComboBox.currentText() elif self.advancedTab.isVisible(): @@ -479,7 +482,7 @@ class BibleMediaItem(MediaManagerItem): if self.editBibleForm.exec_(): self.reload_bibles() - def onDeleteClick(self): + def on_delete_click(self): if self.quickTab.isVisible(): bible = self.quickVersionComboBox.currentText() elif self.advancedTab.isVisible(): @@ -514,16 +517,16 @@ class BibleMediaItem(MediaManagerItem): self.settings.layout_style = self.quickStyleComboBox.currentIndex() self.advancedStyleComboBox.setCurrentIndex(self.settings.layout_style) self.settings.layoutStyleComboBox.setCurrentIndex(self.settings.layout_style) - Settings().setValue(self.settingsSection + u'/verse layout style', self.settings.layout_style) + Settings().setValue(self.settings_section + u'/verse layout style', self.settings.layout_style) def onAdvancedStyleComboBoxChanged(self): self.settings.layout_style = self.advancedStyleComboBox.currentIndex() self.quickStyleComboBox.setCurrentIndex(self.settings.layout_style) self.settings.layoutStyleComboBox.setCurrentIndex(self.settings.layout_style) - Settings().setValue(self.settingsSection + u'/verse layout style', self.settings.layout_style) + Settings().setValue(self.settings_section + u'/verse layout style', self.settings.layout_style) def onAdvancedVersionComboBox(self): - Settings().setValue(self.settingsSection + u'/advanced bible', self.advancedVersionComboBox.currentText()) + Settings().setValue(self.settings_section + u'/advanced bible', self.advancedVersionComboBox.currentText()) self.initialiseAdvancedBible(self.advancedVersionComboBox.currentText(), self.advancedBookComboBox.itemData(int(self.advancedBookComboBox.currentIndex()))) @@ -628,13 +631,13 @@ class BibleMediaItem(MediaManagerItem): if second_bible: self.second_search_results = self.plugin.manager.get_verses(second_bible, versetext, book_ref_id) if not self.advancedLockButton.isChecked(): - self.listView.clear() - if self.listView.count() != 0: + self.list_view.clear() + if self.list_view.count() != 0: self.__checkSecondBible(bible, second_bible) elif self.search_results: self.displayResults(bible, second_bible) self.advancedSearchButton.setEnabled(True) - self.checkSearchResult() + self.check_search_result() self.application.set_normal_cursor() def onQuickSearchButton(self): @@ -684,13 +687,13 @@ class BibleMediaItem(MediaManagerItem): self.search_results = new_search_results self.second_search_results = bibles[second_bible].get_verses(text) if not self.quickLockButton.isChecked(): - self.listView.clear() - if self.listView.count() != 0 and self.search_results: + self.list_view.clear() + if self.list_view.count() != 0 and self.search_results: self.__checkSecondBible(bible, second_bible) elif self.search_results: self.displayResults(bible, second_bible) self.quickSearchButton.setEnabled(True) - self.checkSearchResult() + self.check_search_result() self.application.set_normal_cursor() def displayResults(self, bible, second_bible=u''): @@ -700,8 +703,8 @@ class BibleMediaItem(MediaManagerItem): """ items = self.buildDisplayResults(bible, second_bible, self.search_results) for bible_verse in items: - self.listView.addItem(bible_verse) - self.listView.selectAll() + self.list_view.addItem(bible_verse) + self.list_view.selectAll() self.search_results = {} self.second_search_results = {} @@ -764,7 +767,7 @@ class BibleMediaItem(MediaManagerItem): items.append(bible_verse) return items - def generateSlideData(self, service_item, item=None, xmlVersion=False, + def generate_slide_data(self, service_item, item=None, xmlVersion=False, remote=False, context=ServiceItemContext.Service): """ Generates and formats the slides for the service item as well as the @@ -774,7 +777,7 @@ class BibleMediaItem(MediaManagerItem): if item: items = item else: - items = self.listView.selectedItems() + items = self.list_view.selectedItems() if not items: return False bible_text = u'' @@ -963,7 +966,10 @@ class BibleMediaItem(MediaManagerItem): return [[string, versetext]] return [] - def createItemFromId(self, item_id): + def create_item_from_id(self, item_id): + """ + Create a media item from an item id. + """ item = QtGui.QListWidgetItem() bible = self.quickVersionComboBox.currentText() search_results = self.plugin.manager.get_verses(bible, item_id, False) diff --git a/openlp/plugins/custom/customplugin.py b/openlp/plugins/custom/customplugin.py index 9d618314a..06b070490 100644 --- a/openlp/plugins/custom/customplugin.py +++ b/openlp/plugins/custom/customplugin.py @@ -64,8 +64,8 @@ class CustomPlugin(Plugin): Plugin.__init__(self, u'custom', __default_settings__, CustomMediaItem, CustomTab) self.weight = -5 self.manager = Manager(u'custom', init_schema) - self.iconPath = u':/plugins/plugin_custom.png' - self.icon = build_icon(self.iconPath) + self.icon_path = u':/plugins/plugin_custom.png' + self.icon = build_icon(self.icon_path) def about(self): about_text = translate('CustomPlugin', 'Custom Slide Plugin
The custom slide plugin ' @@ -104,12 +104,12 @@ class CustomPlugin(Plugin): Called to define all translatable texts of the plugin """ ## Name PluginList ## - self.textStrings[StringContent.Name] = { + self.text_strings[StringContent.Name] = { u'singular': translate('CustomPlugin', 'Custom Slide', 'name singular'), u'plural': translate('CustomPlugin', 'Custom Slides', 'name plural') } ## Name for MediaDockManager, SettingsManager ## - self.textStrings[StringContent.VisibleName] = { + self.text_strings[StringContent.VisibleName] = { u'title': translate('CustomPlugin', 'Custom Slides', 'container title') } # Middle Header Bar @@ -123,7 +123,7 @@ class CustomPlugin(Plugin): u'live': translate('CustomPlugin', 'Send the selected custom slide live.'), u'service': translate('CustomPlugin', 'Add the selected custom slide to the service.') } - self.setPluginUiTextStrings(tooltips) + self.set_plugin_ui_text_strings(tooltips) def finalise(self): """ diff --git a/openlp/plugins/custom/forms/editcustomform.py b/openlp/plugins/custom/forms/editcustomform.py index 135535a8f..5146a0e05 100644 --- a/openlp/plugins/custom/forms/editcustomform.py +++ b/openlp/plugins/custom/forms/editcustomform.py @@ -47,13 +47,13 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog): """ log.info(u'Custom Editor loaded') - def __init__(self, mediaitem, parent, manager): + def __init__(self, media_item, parent, manager): """ Constructor """ super(EditCustomForm, self).__init__(parent) self.manager = manager - self.mediaitem = mediaitem + self.media_item = media_item self.setupUi(self) # Create other objects and forms. self.edit_slide_form = EditCustomSlideForm(self) @@ -130,7 +130,7 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog): self.custom_slide.credits = self.credit_edit.text() self.custom_slide.theme_name = self.theme_combo_box.currentText() success = self.manager.save_object(self.custom_slide) - self.mediaitem.autoSelectId = self.custom_slide.id + self.media_item.auto_select_id = self.custom_slide.id return success def on_up_button_clicked(self): diff --git a/openlp/plugins/custom/lib/mediaitem.py b/openlp/plugins/custom/lib/mediaitem.py index f5a0102ca..8e95b038b 100644 --- a/openlp/plugins/custom/lib/mediaitem.py +++ b/openlp/plugins/custom/lib/mediaitem.py @@ -55,26 +55,26 @@ class CustomMediaItem(MediaManagerItem): log.info(u'Custom Media Item loaded') def __init__(self, parent, plugin): - self.IconPath = u'custom/custom' + self.icon_path = u'custom/custom' MediaManagerItem.__init__(self, parent, plugin) self.edit_custom_form = EditCustomForm(self, self.main_window, self.plugin.manager) - self.singleServiceItem = False - self.quickPreviewAllowed = True + self.single_service_item = False + self.quick_preview_allowed = True self.hasSearch = True # Holds information about whether the edit is remotely triggered and # which Custom is required. self.remoteCustom = -1 self.manager = plugin.manager - def addEndHeaderBar(self): + def add_end_header_bar(self): self.toolbar.addSeparator() - self.addSearchToToolBar() + self.add_search_to_toolbar() # Signals and slots - QtCore.QObject.connect(self.searchTextEdit, QtCore.SIGNAL(u'cleared()'), self.onClearTextButtonClick) - QtCore.QObject.connect(self.searchTextEdit, QtCore.SIGNAL(u'searchTypeChanged(int)'), - self.onSearchTextButtonClicked) - Registry().register_function(u'custom_load_list', self.loadList) - Registry().register_function(u'custom_preview', self.onPreviewClick) + QtCore.QObject.connect(self.search_text_edit, QtCore.SIGNAL(u'cleared()'), self.onClearTextButtonClick) + QtCore.QObject.connect(self.search_text_edit, QtCore.SIGNAL(u'searchTypeChanged(int)'), + self.on_search_text_button_clicked) + Registry().register_function(u'custom_load_list', self.load_list) + Registry().register_function(u'custom_preview', self.on_preview_click) Registry().register_function(u'custom_create_from_service', self.create_from_service_item) def config_update(self): @@ -82,45 +82,45 @@ class CustomMediaItem(MediaManagerItem): Config has been updated so reload values """ log.debug(u'Config loaded') - self.add_custom_from_service = Settings().value(self.settingsSection + u'/add custom from service') + self.add_custom_from_service = Settings().value(self.settings_section + u'/add custom from service') def retranslateUi(self): - self.searchTextLabel.setText(u'%s:' % UiStrings().Search) - self.searchTextButton.setText(UiStrings().Search) + self.search_text_label.setText(u'%s:' % UiStrings().Search) + self.search_text_button.setText(UiStrings().Search) def initialise(self): - self.searchTextEdit.set_search_types([ + self.search_text_edit.set_search_types([ (CustomSearch.Titles, u':/songs/song_search_title.png', translate('SongsPlugin.MediaItem', 'Titles'), translate('SongsPlugin.MediaItem', 'Search Titles...')), (CustomSearch.Themes, u':/slides/slide_theme.png', UiStrings().Themes, UiStrings().SearchThemes) ]) - self.searchTextEdit.set_current_search_type(Settings().value(u'%s/last search type' % self.settingsSection)) - self.loadList(self.manager.get_all_objects(CustomSlide, order_by_ref=CustomSlide.title)) + self.search_text_edit.set_current_search_type(Settings().value(u'%s/last search type' % self.settings_section)) + self.load_list(self.manager.get_all_objects(CustomSlide, order_by_ref=CustomSlide.title)) self.config_update() - def loadList(self, custom_slides, target_group=None): + def load_list(self, custom_slides, target_group=None): # Sort out what custom we want to select after loading the list. - self.saveAutoSelectId() - self.listView.clear() + self.save_auto_select_id() + self.list_view.clear() custom_slides.sort() for custom_slide in custom_slides: custom_name = QtGui.QListWidgetItem(custom_slide.title) custom_name.setData(QtCore.Qt.UserRole, custom_slide.id) - self.listView.addItem(custom_name) + self.list_view.addItem(custom_name) # Auto-select the custom. - if custom_slide.id == self.autoSelectId: - self.listView.setCurrentItem(custom_name) - self.autoSelectId = -1 + if custom_slide.id == self.auto_select_id: + self.list_view.setCurrentItem(custom_name) + self.auto_select_id = -1 # Called to redisplay the custom list screen edith from a search # or from the exit of the Custom edit dialog. If remote editing is # active trigger it and clean up so it will not update again. - def onNewClick(self): + def on_new_click(self): self.edit_custom_form.load_custom(0) self.edit_custom_form.exec_() self.onClearTextButtonClick() - self.onSelectionChange() + self.on_selection_change() def onRemoteEdit(self, custom_id, preview=False): """ @@ -133,35 +133,35 @@ class CustomMediaItem(MediaManagerItem): if valid: self.edit_custom_form.load_custom(custom_id, preview) if self.edit_custom_form.exec_() == QtGui.QDialog.Accepted: - self.remoteTriggered = True + self.remote_triggered = True self.remoteCustom = custom_id - self.autoSelectId = -1 - self.onSearchTextButtonClicked() - item = self.buildServiceItem(remote=True) - self.remoteTriggered = None + self.auto_select_id = -1 + self.on_search_text_button_clicked() + item = self.build_service_item(remote=True) + self.remote_triggered = None self.remoteCustom = 1 if item: return item return None - def onEditClick(self): + def on_edit_click(self): """ Edit a custom item """ - if check_item_selected(self.listView, UiStrings().SelectEdit): - item = self.listView.currentItem() + if check_item_selected(self.list_view, UiStrings().SelectEdit): + item = self.list_view.currentItem() item_id = item.data(QtCore.Qt.UserRole) self.edit_custom_form.load_custom(item_id, False) self.edit_custom_form.exec_() - self.autoSelectId = -1 - self.onSearchTextButtonClicked() + self.auto_select_id = -1 + self.on_search_text_button_clicked() - def onDeleteClick(self): + def on_delete_click(self): """ Remove a custom item from the list and database """ - if check_item_selected(self.listView, UiStrings().SelectDelete): - items = self.listView.selectedIndexes() + if check_item_selected(self.list_view, UiStrings().SelectDelete): + items = self.list_view.selectedIndexes() if QtGui.QMessageBox.question(self, UiStrings().ConfirmDelete, translate('CustomPlugin.MediaItem', @@ -170,20 +170,23 @@ class CustomMediaItem(MediaManagerItem): QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes | QtGui.QMessageBox.No), QtGui.QMessageBox.Yes) == QtGui.QMessageBox.No: return - row_list = [item.row() for item in self.listView.selectedIndexes()] + row_list = [item.row() for item in self.list_view.selectedIndexes()] row_list.sort(reverse=True) id_list = [(item.data(QtCore.Qt.UserRole)) - for item in self.listView.selectedIndexes()] + for item in self.list_view.selectedIndexes()] for id in id_list: self.plugin.manager.delete_object(CustomSlide, id) - self.onSearchTextButtonClicked() + self.on_search_text_button_clicked() def onFocus(self): - self.searchTextEdit.setFocus() + self.search_text_edit.setFocus() - def generateSlideData(self, service_item, item=None, xmlVersion=False, + def generate_slide_data(self, service_item, item=None, xmlVersion=False, remote=False, context=ServiceItemContext.Service): - item_id = self._getIdOfItemToGenerate(item, self.remoteCustom) + """ + Generate the slide data. Needs to be implemented by the plugin. + """ + item_id = self._get_id_of_item_to_generate(item, self.remoteCustom) service_item.add_capability(ItemCapabilities.CanEdit) service_item.add_capability(ItemCapabilities.CanPreview) service_item.add_capability(ItemCapabilities.CanLoop) @@ -202,34 +205,34 @@ class CustomMediaItem(MediaManagerItem): service_item.title = title for slide in raw_slides: service_item.add_from_text(slide) - if Settings().value(self.settingsSection + u'/display footer') or credit: + if Settings().value(self.settings_section + u'/display footer') or credit: service_item.raw_footer.append(u' '.join([title, credit])) else: service_item.raw_footer.append(u'') return True - def onSearchTextButtonClicked(self): + def on_search_text_button_clicked(self): # Save the current search type to the configuration. - Settings().setValue(u'%s/last search type' % self.settingsSection, self.searchTextEdit.current_search_type()) + Settings().setValue(u'%s/last search type' % self.settings_section, self.search_text_edit.current_search_type()) # Reload the list considering the new search type. - search_keywords = self.searchTextEdit.displayText() + search_keywords = self.search_text_edit.displayText() search_results = [] - search_type = self.searchTextEdit.current_search_type() + search_type = self.search_text_edit.current_search_type() if search_type == CustomSearch.Titles: log.debug(u'Titles Search') search_results = self.plugin.manager.get_all_objects(CustomSlide, CustomSlide.title.like(u'%' + self.whitespace.sub(u' ', search_keywords) + u'%'), order_by_ref=CustomSlide.title) - self.loadList(search_results) + self.load_list(search_results) elif search_type == CustomSearch.Themes: log.debug(u'Theme Search') search_results = self.plugin.manager.get_all_objects(CustomSlide, CustomSlide.theme_name.like(u'%' + self.whitespace.sub(u' ', search_keywords) + u'%'), order_by_ref=CustomSlide.title) - self.loadList(search_results) - self.checkSearchResult() + self.load_list(search_results) + self.check_search_result() - def onSearchTextEditChanged(self, text): + def on_search_text_edit_changed(self, text): """ If search as type enabled invoke the search on each key press. If the Title is being searched do not start until 2 characters @@ -237,15 +240,15 @@ class CustomMediaItem(MediaManagerItem): """ search_length = 2 if len(text) > search_length: - self.onSearchTextButtonClicked() + self.on_search_text_button_clicked() elif not text: self.onClearTextButtonClick() - def serviceLoad(self, item): + def service_load(self, item): """ Triggered by a song being loaded by the service manager. """ - log.debug(u'serviceLoad') + log.debug(u'service_load') if self.plugin.status != PluginStatus.Active: return custom = self.plugin.manager.get_object_filtered(CustomSlide, @@ -280,7 +283,7 @@ class CustomMediaItem(MediaManagerItem): custom_xml.add_verse_to_lyrics(u'custom', unicode(idx + 1), slide['raw_slide']) custom.text = unicode(custom_xml.extract_xml(), u'utf-8') self.plugin.manager.save_object(custom) - self.onSearchTextButtonClicked() + self.on_search_text_button_clicked() if item.name.lower() == u'custom': Registry().execute(u'service_item_update', u'%s:%s:%s' % (custom.id, item.unique_identifier, False)) @@ -288,8 +291,8 @@ class CustomMediaItem(MediaManagerItem): """ Clear the search text. """ - self.searchTextEdit.clear() - self.onSearchTextButtonClicked() + self.search_text_edit.clear() + self.on_search_text_button_clicked() def search(self, string, showError): search_results = self.manager.get_all_objects(CustomSlide, diff --git a/openlp/plugins/images/imageplugin.py b/openlp/plugins/images/imageplugin.py index 5b41f6761..cb25dc375 100644 --- a/openlp/plugins/images/imageplugin.py +++ b/openlp/plugins/images/imageplugin.py @@ -51,8 +51,8 @@ class ImagePlugin(Plugin): Plugin.__init__(self, u'images', __default_settings__, ImageMediaItem, ImageTab) self.manager = Manager(u'images', init_schema) self.weight = -7 - self.iconPath = u':/plugins/plugin_images.png' - self.icon = build_icon(self.iconPath) + self.icon_path = u':/plugins/plugin_images.png' + self.icon = build_icon(self.icon_path) def about(self): about_text = translate('ImagePlugin', 'Image Plugin' @@ -77,7 +77,7 @@ class ImagePlugin(Plugin): files_from_config = Settings().get_files_from_config(self) if files_from_config: log.debug(u'Importing images list from old config: %s' % files_from_config) - self.mediaItem.save_new_images_list(files_from_config) + self.media_item.save_new_images_list(files_from_config) def upgrade_settings(self, settings): """ @@ -89,19 +89,19 @@ class ImagePlugin(Plugin): files_from_config = settings.get_files_from_config(self) if files_from_config: log.debug(u'Importing images list from old config: %s' % files_from_config) - self.mediaItem.save_new_images_list(files_from_config) + self.media_item.save_new_images_list(files_from_config) def set_plugin_text_strings(self): """ Called to define all translatable texts of the plugin """ ## Name PluginList ## - self.textStrings[StringContent.Name] = { + self.text_strings[StringContent.Name] = { u'singular': translate('ImagePlugin', 'Image', 'name singular'), u'plural': translate('ImagePlugin', 'Images', 'name plural') } ## Name for MediaDockManager, SettingsManager ## - self.textStrings[StringContent.VisibleName] = {u'title': translate('ImagePlugin', 'Images', 'container title')} + self.text_strings[StringContent.VisibleName] = {u'title': translate('ImagePlugin', 'Images', 'container title')} # Middle Header Bar tooltips = { u'load': translate('ImagePlugin', 'Load a new image.'), @@ -113,7 +113,7 @@ class ImagePlugin(Plugin): u'live': translate('ImagePlugin', 'Send the selected image live.'), u'service': translate('ImagePlugin', 'Add the selected image to the service.') } - self.setPluginUiTextStrings(tooltips) + self.set_plugin_ui_text_strings(tooltips) def config_update(self): """ @@ -121,7 +121,7 @@ class ImagePlugin(Plugin): Actual update is triggered by the last part of saving the config. """ log.info(u'Images config_update') - background = QtGui.QColor(Settings().value(self.settingsSection + u'/background color')) + background = QtGui.QColor(Settings().value(self.settings_section + u'/background color')) self.image_manager.update_images_border(ImageSource.ImagePlugin, background) def _get_image_manager(self): diff --git a/openlp/plugins/images/lib/mediaitem.py b/openlp/plugins/images/lib/mediaitem.py index 1d975db35..1b2fe512e 100644 --- a/openlp/plugins/images/lib/mediaitem.py +++ b/openlp/plugins/images/lib/mediaitem.py @@ -50,9 +50,9 @@ class ImageMediaItem(MediaManagerItem): log.info(u'Image Media Item loaded') def __init__(self, parent, plugin): - self.IconPath = u'images/image' + self.icon_path = u'images/image' MediaManagerItem.__init__(self, parent, plugin) - self.quickPreviewAllowed = True + self.quick_preview_allowed = True self.hasSearch = True self.manager = plugin.manager self.choose_group_form = ChooseGroupForm(self) @@ -61,13 +61,13 @@ class ImageMediaItem(MediaManagerItem): self.fill_groups_combobox(self.add_group_form.parent_group_combobox) Registry().register_function(u'live_theme_changed', self.live_theme_changed) # Allow DnD from the desktop - self.listView.activateDnD() + self.list_view.activateDnD() def retranslateUi(self): - self.onNewPrompt = translate('ImagePlugin.MediaItem', + self.on_new_prompt = translate('ImagePlugin.MediaItem', 'Select Image(s)') file_formats = get_images_filter() - self.onNewFileMasks = u'%s;;%s (*.*) (*)' % (file_formats, UiStrings().AllFiles) + self.on_new_file_masks = u'%s;;%s (*.*) (*)' % (file_formats, UiStrings().AllFiles) self.addGroupAction.setText(UiStrings().AddGroup) self.addGroupAction.setToolTip(UiStrings().AddGroup) self.replaceAction.setText(UiStrings().ReplaceBG) @@ -75,107 +75,110 @@ class ImageMediaItem(MediaManagerItem): self.resetAction.setText(UiStrings().ResetBG) self.resetAction.setToolTip(UiStrings().ResetLiveBG) - def requiredIcons(self): - MediaManagerItem.requiredIcons(self) - self.hasFileIcon = True - self.hasNewIcon = False - self.hasEditIcon = False - self.addToServiceItem = True + def required_icons(self): + """ + Set which icons the media manager tab should show + """ + MediaManagerItem.required_icons(self) + self.has_file_icon = True + self.has_new_icon = False + self.has_edit_icon = False + self.add_to_service_item = True def initialise(self): log.debug(u'initialise') - self.listView.clear() - self.listView.setIconSize(QtCore.QSize(88, 50)) - self.listView.setIndentation(self.listView.defaultIndentation) - self.listView.allow_internal_dnd = True - self.servicePath = os.path.join(AppLocation.get_section_data_path(self.settingsSection), u'thumbnails') + self.list_view.clear() + self.list_view.setIconSize(QtCore.QSize(88, 50)) + self.list_view.setIndentation(self.list_view.defaultIndentation) + self.list_view.allow_internal_dnd = True + self.servicePath = os.path.join(AppLocation.get_section_data_path(self.settings_section), u'thumbnails') check_directory_exists(self.servicePath) # Load images from the database self.loadFullList( self.manager.get_all_objects(ImageFilenames, order_by_ref=ImageFilenames.filename), initial_load=True) - def addListViewToToolBar(self): + def add_list_view_to_toolbar(self): """ Creates the main widget for listing items the media item is tracking. - This method overloads MediaManagerItem.addListViewToToolBar + This method overloads MediaManagerItem.add_list_view_to_toolbar """ # Add the List widget - self.listView = TreeWidgetWithDnD(self, self.plugin.name) - self.listView.setSelectionMode(QtGui.QAbstractItemView.ExtendedSelection) - self.listView.setAlternatingRowColors(True) - self.listView.setObjectName(u'%sTreeView' % self.plugin.name) + self.list_view = TreeWidgetWithDnD(self, self.plugin.name) + self.list_view.setSelectionMode(QtGui.QAbstractItemView.ExtendedSelection) + self.list_view.setAlternatingRowColors(True) + self.list_view.setObjectName(u'%sTreeView' % self.plugin.name) # Add to pageLayout - self.pageLayout.addWidget(self.listView) + self.page_layout.addWidget(self.list_view) # define and add the context menu - self.listView.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) - if self.hasEditIcon: - create_widget_action(self.listView, - text=self.plugin.getString(StringContent.Edit)[u'title'], + self.list_view.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) + if self.has_edit_icon: + create_widget_action(self.list_view, + text=self.plugin.get_string(StringContent.Edit)[u'title'], icon=u':/general/general_edit.png', - triggers=self.onEditClick) - create_widget_action(self.listView, separator=True) - if self.hasDeleteIcon: - create_widget_action(self.listView, + triggers=self.on_edit_click) + create_widget_action(self.list_view, separator=True) + if self.has_delete_icon: + create_widget_action(self.list_view, u'listView%s%sItem' % (self.plugin.name.title(), StringContent.Delete.title()), - text=self.plugin.getString(StringContent.Delete)[u'title'], + text=self.plugin.get_string(StringContent.Delete)[u'title'], icon=u':/general/general_delete.png', - can_shortcuts=True, triggers=self.onDeleteClick) - create_widget_action(self.listView, separator=True) - create_widget_action(self.listView, + can_shortcuts=True, triggers=self.on_delete_click) + create_widget_action(self.list_view, separator=True) + create_widget_action(self.list_view, u'listView%s%sItem' % (self.plugin.name.title(), StringContent.Preview.title()), - text=self.plugin.getString(StringContent.Preview)[u'title'], + text=self.plugin.get_string(StringContent.Preview)[u'title'], icon=u':/general/general_preview.png', can_shortcuts=True, - triggers=self.onPreviewClick) - create_widget_action(self.listView, + triggers=self.on_preview_click) + create_widget_action(self.list_view, u'listView%s%sItem' % (self.plugin.name.title(), StringContent.Live.title()), - text=self.plugin.getString(StringContent.Live)[u'title'], + text=self.plugin.get_string(StringContent.Live)[u'title'], icon=u':/general/general_live.png', can_shortcuts=True, - triggers=self.onLiveClick) - create_widget_action(self.listView, + triggers=self.on_live_click) + create_widget_action(self.list_view, u'listView%s%sItem' % (self.plugin.name.title(), StringContent.Service.title()), can_shortcuts=True, - text=self.plugin.getString(StringContent.Service)[u'title'], + text=self.plugin.get_string(StringContent.Service)[u'title'], icon=u':/general/general_add.png', - triggers=self.onAddClick) - if self.addToServiceItem: - create_widget_action(self.listView, separator=True) - create_widget_action(self.listView, + triggers=self.on_add_click) + if self.add_to_service_item: + create_widget_action(self.list_view, separator=True) + create_widget_action(self.list_view, text=translate('OpenLP.MediaManagerItem', '&Add to selected Service Item'), icon=u':/general/general_add.png', - triggers=self.onAddEditClick) - self.addCustomContextActions() - # Create the context menu and add all actions from the listView. + triggers=self.on_add_edit_click) + self.add_custom_context_actions() + # Create the context menu and add all actions from the list_view. self.menu = QtGui.QMenu() - self.menu.addActions(self.listView.actions()) - self.listView.doubleClicked.connect(self.onDoubleClicked) - self.listView.itemSelectionChanged.connect(self.onSelectionChange) - self.listView.customContextMenuRequested.connect(self.contextMenu) - self.listView.addAction(self.replaceAction) + self.menu.addActions(self.list_view.actions()) + self.list_view.doubleClicked.connect(self.on_double_clicked) + self.list_view.itemSelectionChanged.connect(self.on_selection_change) + self.list_view.customContextMenuRequested.connect(self.context_menu) + self.list_view.addAction(self.replaceAction) - def addCustomContextActions(self): + def add_custom_context_actions(self): """ Add custom actions to the context menu """ - create_widget_action(self.listView, separator=True) - create_widget_action(self.listView, + create_widget_action(self.list_view, separator=True) + create_widget_action(self.list_view, text=UiStrings().AddGroup, icon=u':/images/image_new_group.png', triggers=self.onAddGroupClick) - create_widget_action(self.listView, - text=self.plugin.getString(StringContent.Load)[u'tooltip'], + create_widget_action(self.list_view, + text=self.plugin.get_string(StringContent.Load)[u'tooltip'], icon=u':/general/general_open.png', - triggers=self.onFileClick) + triggers=self.on_file_click) - def addStartHeaderBar(self): + def add_start_header_bar(self): """ Add custom buttons to the start of the toolbar """ self.addGroupAction = self.toolbar.add_toolbar_action(u'addGroupAction', icon=u':/images/image_new_group.png', triggers=self.onAddGroupClick) - def addEndHeaderBar(self): + def add_end_header_bar(self): """ Add custom buttons to the end of the toolbar """ @@ -200,15 +203,15 @@ class ImageMediaItem(MediaManagerItem): self.recursively_delete_group(group) self.manager.delete_object(ImageGroups, group.id) - def onDeleteClick(self): + def on_delete_click(self): """ Remove an image item from the list """ # Turn off auto preview triggers. - self.listView.blockSignals(True) - if check_item_selected(self.listView, translate('ImagePlugin.MediaItem', + self.list_view.blockSignals(True) + if check_item_selected(self.list_view, translate('ImagePlugin.MediaItem', 'You must select an image or group to delete.')): - item_list = self.listView.selectedItems() + item_list = self.list_view.selectedItems() self.application.set_busy_cursor() self.main_window.display_progress_bar(len(item_list)) for row_item in item_list: @@ -217,12 +220,12 @@ class ImageMediaItem(MediaManagerItem): if isinstance(item_data, ImageFilenames): delete_file(os.path.join(self.servicePath, row_item.text(0))) if item_data.group_id == 0: - self.listView.takeTopLevelItem(self.listView.indexOfTopLevelItem(row_item)) + self.list_view.takeTopLevelItem(self.list_view.indexOfTopLevelItem(row_item)) else: row_item.parent().removeChild(row_item) self.manager.delete_object(ImageFilenames, row_item.data(0, QtCore.Qt.UserRole).id) elif isinstance(item_data, ImageGroups): - if QtGui.QMessageBox.question(self.listView.parent(), + if QtGui.QMessageBox.question(self.list_view.parent(), translate('ImagePlugin.MediaItem', 'Remove group'), translate('ImagePlugin.MediaItem', 'Are you sure you want to remove "%s" and everything in it?') % item_data.group_name, @@ -231,7 +234,7 @@ class ImageMediaItem(MediaManagerItem): self.recursively_delete_group(item_data) self.manager.delete_object(ImageGroups, row_item.data(0, QtCore.Qt.UserRole).id) if item_data.parent_id == 0: - self.listView.takeTopLevelItem(self.listView.indexOfTopLevelItem(row_item)) + self.list_view.takeTopLevelItem(self.list_view.indexOfTopLevelItem(row_item)) else: row_item.parent().removeChild(row_item) self.fill_groups_combobox(self.choose_group_form.group_combobox) @@ -239,7 +242,7 @@ class ImageMediaItem(MediaManagerItem): self.main_window.increment_progress_bar() self.main_window.finished_progress_bar() self.application.set_normal_cursor() - self.listView.blockSignals(False) + self.list_view.blockSignals(False) def add_sub_groups(self, group_list, parent_group_id): """ @@ -260,7 +263,7 @@ class ImageMediaItem(MediaManagerItem): group.setData(0, QtCore.Qt.UserRole, image_group) group.setIcon(0, folder_icon) if parent_group_id == 0: - self.listView.addTopLevelItem(group) + self.list_view.addTopLevelItem(group) else: group_list[parent_group_id].addChild(group) group_list[image_group.id] = group @@ -300,7 +303,7 @@ class ImageMediaItem(MediaManagerItem): """ return_value = False if root_item is None: - root_item = self.listView.invisibleRootItem() + root_item = self.list_view.invisibleRootItem() for i in range(root_item.childCount()): child = root_item.child(i) if self.expand_group(group_id, child): @@ -327,7 +330,7 @@ class ImageMediaItem(MediaManagerItem): if not initial_load: self.application.set_busy_cursor() self.main_window.display_progress_bar(len(images)) - self.listView.clear() + self.list_view.clear() # Load the list of groups and add them to the treeView group_items = {} self.add_sub_groups(group_items, parent_group_id=0) @@ -353,7 +356,7 @@ class ImageMediaItem(MediaManagerItem): item_name.setToolTip(0, imageFile.filename) item_name.setData(0, QtCore.Qt.UserRole, imageFile) if imageFile.group_id == 0: - self.listView.addTopLevelItem(item_name) + self.list_view.addTopLevelItem(item_name) else: group_items[imageFile.group_id].addChild(item_name) if not initial_load: @@ -362,7 +365,7 @@ class ImageMediaItem(MediaManagerItem): self.main_window.finished_progress_bar() self.application.set_normal_cursor() - def validateAndLoad(self, files, target_group=None): + def validate_and_load(self, files, target_group=None): """ Process a list for files either from the File Dialog or from Drag and Drop. This method is overloaded from MediaManagerItem. @@ -374,11 +377,11 @@ class ImageMediaItem(MediaManagerItem): The QTreeWidgetItem of the group that will be the parent of the added files """ self.application.set_normal_cursor() - self.loadList(files, target_group) + self.load_list(files, target_group) last_dir = os.path.split(unicode(files[0]))[0] - Settings().setValue(self.settingsSection + u'/last directory', last_dir) + Settings().setValue(self.settings_section + u'/last directory', last_dir) - def loadList(self, images, target_group=None, initial_load=False): + def load_list(self, images, target_group=None, initial_load=False): """ Add new images to the database. This method is called when adding images using the Add button or DnD. @@ -394,7 +397,7 @@ class ImageMediaItem(MediaManagerItem): if target_group is None: # Find out if a group must be pre-selected preselect_group = None - selected_items = self.listView.selectedItems() + selected_items = self.list_view.selectedItems() if selected_items: selected_item = selected_items[0] if isinstance(selected_item.data(0, QtCore.Qt.UserRole), ImageFilenames): @@ -488,14 +491,14 @@ class ImageMediaItem(MediaManagerItem): ``target`` This contains the QTreeWidget that is the target of the DnD action """ - items_to_move = self.listView.selectedItems() + items_to_move = self.list_view.selectedItems() # Determine group to move images to target_group = target if target_group is not None and isinstance(target_group.data(0, QtCore.Qt.UserRole), ImageFilenames): target_group = target.parent() # Move to toplevel if target_group is None: - target_group = self.listView.invisibleRootItem() + target_group = self.list_view.invisibleRootItem() target_group.setData(0, QtCore.Qt.UserRole, ImageGroups()) target_group.data(0, QtCore.Qt.UserRole).id = 0 # Move images in the treeview @@ -505,7 +508,7 @@ class ImageMediaItem(MediaManagerItem): if isinstance(item.parent(), QtGui.QTreeWidgetItem): item.parent().removeChild(item) else: - self.listView.invisibleRootItem().removeChild(item) + self.list_view.invisibleRootItem().removeChild(item) target_group.addChild(item) item.setSelected(True) item_data = item.data(0, QtCore.Qt.UserRole) @@ -527,20 +530,23 @@ class ImageMediaItem(MediaManagerItem): image_items.sort(cmp=locale_compare, key=lambda item: item.text(0)) target_group.addChildren(image_items) - def generateSlideData(self, service_item, item=None, xmlVersion=False, + def generate_slide_data(self, service_item, item=None, xmlVersion=False, remote=False, context=ServiceItemContext.Service): - background = QtGui.QColor(Settings().value(self.settingsSection + u'/background color')) + """ + Generate the slide data. Needs to be implemented by the plugin. + """ + background = QtGui.QColor(Settings().value(self.settings_section + u'/background color')) if item: items = [item] else: - items = self.listView.selectedItems() + items = self.list_view.selectedItems() if not items: return False # Determine service item title if isinstance(items[0].data(0, QtCore.Qt.UserRole), ImageGroups): service_item.title = items[0].text(0) else: - service_item.title = unicode(self.plugin.nameStrings[u'plural']) + service_item.title = unicode(self.plugin.name_strings[u'plural']) service_item.add_capability(ItemCapabilities.CanMaintain) service_item.add_capability(ItemCapabilities.CanPreview) service_item.add_capability(ItemCapabilities.CanLoop) @@ -608,7 +614,7 @@ class ImageMediaItem(MediaManagerItem): """ # Find out if a group must be pre-selected preselect_group = 0 - selected_items = self.listView.selectedItems() + selected_items = self.list_view.selectedItems() if selected_items: selected_item = selected_items[0] if isinstance(selected_item.data(0, QtCore.Qt.UserRole), ImageFilenames): @@ -652,10 +658,10 @@ class ImageMediaItem(MediaManagerItem): """ Called to replace Live backgound with the image selected. """ - if check_item_selected(self.listView, + if check_item_selected(self.list_view, translate('ImagePlugin.MediaItem', 'You must select an image to replace the background with.')): - background = QtGui.QColor(Settings().value(self.settingsSection + u'/background color')) - bitem = self.listView.selectedItems()[0] + background = QtGui.QColor(Settings().value(self.settings_section + u'/background color')) + bitem = self.list_view.selectedItems()[0] if not isinstance(bitem.data(0, QtCore.Qt.UserRole), ImageFilenames): # Only continue when an image is selected return diff --git a/openlp/plugins/media/lib/mediaitem.py b/openlp/plugins/media/lib/mediaitem.py index 6500a666a..64f637b00 100644 --- a/openlp/plugins/media/lib/mediaitem.py +++ b/openlp/plugins/media/lib/mediaitem.py @@ -54,11 +54,11 @@ class MediaMediaItem(MediaManagerItem): log.info(u'%s MediaMediaItem loaded', __name__) def __init__(self, parent, plugin): - self.iconPath = u'images/image' + self.icon_path = u'images/image' self.background = False self.automatic = u'' MediaManagerItem.__init__(self, parent, plugin) - self.singleServiceItem = False + self.single_service_item = False self.hasSearch = True self.media_object = None self.display_controller = DisplayController(parent) @@ -75,10 +75,10 @@ class MediaMediaItem(MediaManagerItem): Registry().register_function(u'mediaitem_media_rebuild', self.rebuild_players) Registry().register_function(u'config_screen_changed', self.display_setup) # Allow DnD from the desktop - self.listView.activateDnD() + self.list_view.activateDnD() def retranslateUi(self): - self.onNewPrompt = translate('MediaPlugin.MediaItem', 'Select Media') + self.on_new_prompt = translate('MediaPlugin.MediaItem', 'Select Media') self.replaceAction.setText(UiStrings().ReplaceBG) self.replaceAction.setToolTip(UiStrings().ReplaceLiveBG) self.resetAction.setText(UiStrings().ResetBG) @@ -87,17 +87,20 @@ class MediaMediaItem(MediaManagerItem): self.displayTypeLabel.setText(translate('MediaPlugin.MediaItem', 'Use Player:')) self.rebuild_players() - def requiredIcons(self): - MediaManagerItem.requiredIcons(self) - self.hasFileIcon = True - self.hasNewIcon = False - self.hasEditIcon = False + def required_icons(self): + """ + Set which icons the media manager tab should show + """ + MediaManagerItem.required_icons(self) + self.has_file_icon = True + self.has_new_icon = False + self.has_edit_icon = False - def addListViewToToolBar(self): - MediaManagerItem.addListViewToToolBar(self) - self.listView.addAction(self.replaceAction) + def add_list_view_to_toolbar(self): + MediaManagerItem.add_list_view_to_toolbar(self) + self.list_view.addAction(self.replaceAction) - def addEndHeaderBar(self): + def add_end_header_bar(self): # Replace backgrounds do not work at present so remove functionality. self.replaceAction = self.toolbar.add_toolbar_action(u'replaceAction', icon=u':/slides/slide_blank.png', triggers=self.onReplaceClick) @@ -114,7 +117,7 @@ class MediaMediaItem(MediaManagerItem): self.displayTypeLabel.setBuddy(self.displayTypeComboBox) self.displayLayout.addRow(self.displayTypeLabel, self.displayTypeComboBox) # Add the Media widget to the page layout - self.pageLayout.addWidget(self.mediaWidget) + self.page_layout.addWidget(self.mediaWidget) self.displayTypeComboBox.currentIndexChanged.connect(self.overridePlayerChanged) def overridePlayerChanged(self, index): @@ -141,9 +144,9 @@ class MediaMediaItem(MediaManagerItem): """ Called to replace Live background with the media selected. """ - if check_item_selected(self.listView, + if check_item_selected(self.list_view, translate('MediaPlugin.MediaItem', 'You must select a media file to replace the background with.')): - item = self.listView.currentItem() + item = self.list_view.currentItem() filename = item.data(QtCore.Qt.UserRole) if os.path.exists(filename): service_item = ServiceItem() @@ -161,10 +164,13 @@ class MediaMediaItem(MediaManagerItem): translate('MediaPlugin.MediaItem', 'There was a problem replacing your background, the media file "%s" no longer exists.') % filename) - def generateSlideData(self, service_item, item=None, xmlVersion=False, remote=False, + def generate_slide_data(self, service_item, item=None, xmlVersion=False, remote=False, context=ServiceItemContext.Live): + """ + Generate the slide data. Needs to be implemented by the plugin. + """ if item is None: - item = self.listView.currentItem() + item = self.list_view.currentItem() if item is None: return False filename = item.data(QtCore.Qt.UserRole) @@ -187,18 +193,18 @@ class MediaMediaItem(MediaManagerItem): service_item.add_capability(ItemCapabilities.CanAutoStartForLive) service_item.add_capability(ItemCapabilities.RequiresMedia) service_item.add_capability(ItemCapabilities.HasDetailedTitleDisplay) - if Settings().value(self.settingsSection + u'/media auto start') == QtCore.Qt.Checked: + if Settings().value(self.settings_section + u'/media auto start') == QtCore.Qt.Checked: service_item.will_auto_start = True # force a non-existent theme service_item.theme = -1 return True def initialise(self): - self.listView.clear() - self.listView.setIconSize(QtCore.QSize(88, 50)) - self.servicePath = os.path.join(AppLocation.get_section_data_path(self.settingsSection), u'thumbnails') + self.list_view.clear() + self.list_view.setIconSize(QtCore.QSize(88, 50)) + self.servicePath = os.path.join(AppLocation.get_section_data_path(self.settings_section), u'thumbnails') check_directory_exists(self.servicePath) - self.loadList(Settings().value(self.settingsSection + u'/media files')) + self.load_list(Settings().value(self.settings_section + u'/media files')) self.populateDisplayTypes() def rebuild_players(self): @@ -207,7 +213,7 @@ class MediaMediaItem(MediaManagerItem): the settings """ self.populateDisplayTypes() - self.onNewFileMasks = translate('MediaPlugin.MediaItem', 'Videos (%s);;Audio (%s);;%s (*)') % ( + self.on_new_file_masks = translate('MediaPlugin.MediaItem', 'Videos (%s);;Audio (%s);;%s (*)') % ( u' '.join(self.media_controller.video_extensions_list), u' '.join(self.media_controller.audio_extensions_list), UiStrings().AllFiles) @@ -240,19 +246,19 @@ class MediaMediaItem(MediaManagerItem): self.mediaWidget.hide() self.displayTypeComboBox.blockSignals(False) - def onDeleteClick(self): + def on_delete_click(self): """ Remove a media item from the list. """ - if check_item_selected(self.listView, + if check_item_selected(self.list_view, translate('MediaPlugin.MediaItem', 'You must select a media file to delete.')): - row_list = [item.row() for item in self.listView.selectedIndexes()] + row_list = [item.row() for item in self.list_view.selectedIndexes()] row_list.sort(reverse=True) for row in row_list: - self.listView.takeItem(row) - Settings().setValue(self.settingsSection + u'/media files', self.getFileList()) + self.list_view.takeItem(row) + Settings().setValue(self.settings_section + u'/media files', self.get_file_list()) - def loadList(self, media, target_group=None): + def load_list(self, media, target_group=None): # Sort the media by its filename considering language specific # characters. media.sort(cmp=locale_compare, key=lambda filename: os.path.split(unicode(filename))[1]) @@ -277,10 +283,10 @@ class MediaMediaItem(MediaManagerItem): item_name.setIcon(build_icon(DVDICON)) item_name.setData(QtCore.Qt.UserRole, track) item_name.setToolTip(track) - self.listView.addItem(item_name) + self.list_view.addItem(item_name) def getList(self, type=MediaType.Audio): - media = Settings().value(self.settingsSection + u'/media files') + media = Settings().value(self.settings_section + u'/media files') media.sort(cmp=locale_compare, key=lambda filename: os.path.split(unicode(filename))[1]) ext = [] if type == MediaType.Audio: @@ -292,7 +298,7 @@ class MediaMediaItem(MediaManagerItem): return media def search(self, string, showError): - files = Settings().value(self.settingsSection + u'/media files') + files = Settings().value(self.settings_section + u'/media files') results = [] string = string.lower() for file in files: diff --git a/openlp/plugins/media/mediaplugin.py b/openlp/plugins/media/mediaplugin.py index f1f98423a..3e685f4c6 100644 --- a/openlp/plugins/media/mediaplugin.py +++ b/openlp/plugins/media/mediaplugin.py @@ -40,7 +40,7 @@ log = logging.getLogger(__name__) __default_settings__ = { u'media/media auto start': QtCore.Qt.Unchecked, u'media/media files': [] - } +} class MediaPlugin(Plugin): @@ -49,17 +49,17 @@ class MediaPlugin(Plugin): def __init__(self): Plugin.__init__(self, u'media', __default_settings__, MediaMediaItem) self.weight = -6 - self.iconPath = u':/plugins/plugin_media.png' - self.icon = build_icon(self.iconPath) + self.icon_path = u':/plugins/plugin_media.png' + self.icon = build_icon(self.icon_path) # passed with drag and drop messages self.dnd_id = u'Media' - def createSettingsTab(self, parent): + def create_settings_Tab(self, parent): """ Create the settings Tab """ - visible_name = self.getString(StringContent.VisibleName) - self.settingsTab = MediaTab(parent, self.name, visible_name[u'title'], self.iconPath) + visible_name = self.get_string(StringContent.VisibleName) + self.settings_tab = MediaTab(parent, self.name, visible_name[u'title'], self.icon_path) def about(self): about_text = translate('MediaPlugin', 'Media Plugin' @@ -71,12 +71,12 @@ class MediaPlugin(Plugin): Called to define all translatable texts of the plugin """ ## Name PluginList ## - self.textStrings[StringContent.Name] = { + self.text_strings[StringContent.Name] = { u'singular': translate('MediaPlugin', 'Media', 'name singular'), u'plural': translate('MediaPlugin', 'Media', 'name plural') } ## Name for MediaDockManager, SettingsManager ## - self.textStrings[StringContent.VisibleName] = { + self.text_strings[StringContent.VisibleName] = { u'title': translate('MediaPlugin', 'Media', 'container title') } # Middle Header Bar @@ -90,7 +90,7 @@ class MediaPlugin(Plugin): u'live': translate('MediaPlugin', 'Send the selected media live.'), u'service': translate('MediaPlugin', 'Add the selected media to the service.') } - self.setPluginUiTextStrings(tooltips) + self.set_plugin_ui_text_strings(tooltips) def finalise(self): """ @@ -100,19 +100,19 @@ class MediaPlugin(Plugin): self.media_controller.finalise() Plugin.finalise(self) - def getDisplayCss(self): + def get_display_css(self): """ Add css style sheets to htmlbuilder """ return self.media_controller.get_media_display_css() - def getDisplayJavaScript(self): + def get_display_javascript(self): """ Add javascript functions to htmlbuilder """ return self.media_controller.get_media_display_javascript() - def getDisplayHtml(self): + def get_display_html(self): """ Add html code to htmlbuilder """ @@ -126,7 +126,7 @@ class MediaPlugin(Plugin): """ Plugin.app_startup(self) settings = Settings() - settings.beginGroup(self.settingsSection) + settings.beginGroup(self.settings_section) if settings.contains(u'use phonon'): log.info(u'Found old Phonon setting') players = self.media_controller.mediaPlayers.keys() @@ -137,7 +137,7 @@ class MediaPlugin(Plugin): if players: new_players = [player for player in players if player != u'phonon'] new_players.insert(0, u'phonon') - self.media_controller.mediaPlayers[u'phonon'].isActive = True + self.media_controller.mediaPlayers[u'phonon'].is_active = True settings.setValue(u'players', u','.join(new_players)) self.settingsTab.load() settings.remove(u'use phonon') diff --git a/openlp/plugins/presentations/lib/mediaitem.py b/openlp/plugins/presentations/lib/mediaitem.py index 1f240f5d0..fb7aacca8 100644 --- a/openlp/plugins/presentations/lib/mediaitem.py +++ b/openlp/plugins/presentations/lib/mediaitem.py @@ -54,22 +54,22 @@ class PresentationMediaItem(MediaManagerItem): Constructor. Setup defaults """ self.controllers = controllers - self.IconPath = u'presentations/presentation' + self.icon_path = u'presentations/presentation' self.Automatic = u'' MediaManagerItem.__init__(self, parent, plugin) self.message_listener = MessageListener(self) self.hasSearch = True - self.singleServiceItem = False + self.single_service_item = False Registry().register_function(u'mediaitem_presentation_rebuild', self.populate_display_types) Registry().register_function(u'mediaitem_suffixes', self.build_file_mask_string) # Allow DnD from the desktop - self.listView.activateDnD() + self.list_view.activateDnD() def retranslateUi(self): """ The name of the plugin media displayed in UI """ - self.onNewPrompt = translate('PresentationPlugin.MediaItem', 'Select Presentation(s)') + self.on_new_prompt = translate('PresentationPlugin.MediaItem', 'Select Presentation(s)') self.Automatic = translate('PresentationPlugin.MediaItem', 'Automatic') self.displayTypeLabel.setText(translate('PresentationPlugin.MediaItem', 'Present using:')) @@ -85,18 +85,18 @@ class PresentationMediaItem(MediaManagerItem): if fileType.find(type) == -1: fileType += u'*.%s ' % type self.service_manager.supported_suffixes(type) - self.onNewFileMasks = translate('PresentationPlugin.MediaItem', 'Presentations (%s)') % fileType + self.on_new_file_masks = translate('PresentationPlugin.MediaItem', 'Presentations (%s)') % fileType - def requiredIcons(self): + def required_icons(self): """ Set which icons the media manager tab should show """ - MediaManagerItem.requiredIcons(self) - self.hasFileIcon = True - self.hasNewIcon = False - self.hasEditIcon = False + MediaManagerItem.required_icons(self) + self.has_file_icon = True + self.has_new_icon = False + self.has_edit_icon = False - def addEndHeaderBar(self): + def add_end_header_bar(self): """ Display custom media manager items for presentations """ @@ -112,15 +112,15 @@ class PresentationMediaItem(MediaManagerItem): self.displayTypeLabel.setBuddy(self.displayTypeComboBox) self.displayLayout.addRow(self.displayTypeLabel, self.displayTypeComboBox) # Add the Presentation widget to the page layout - self.pageLayout.addWidget(self.presentationWidget) + self.page_layout.addWidget(self.presentationWidget) def initialise(self): """ Populate the media manager tab """ - self.listView.setIconSize(QtCore.QSize(88, 50)) - files = Settings().value(self.settingsSection + u'/presentations files') - self.loadList(files, initialLoad=True) + self.list_view.setIconSize(QtCore.QSize(88, 50)) + files = Settings().value(self.settings_section + u'/presentations files') + self.load_list(files, initialLoad=True) self.populate_display_types() def populate_display_types(self): @@ -136,18 +136,18 @@ class PresentationMediaItem(MediaManagerItem): if self.displayTypeComboBox.count() > 1: self.displayTypeComboBox.insertItem(0, self.Automatic) self.displayTypeComboBox.setCurrentIndex(0) - if Settings().value(self.settingsSection + u'/override app') == QtCore.Qt.Checked: + if Settings().value(self.settings_section + u'/override app') == QtCore.Qt.Checked: self.presentationWidget.show() else: self.presentationWidget.hide() - def loadList(self, files, target_group=None, initialLoad=False): + def load_list(self, files, target_group=None, initialLoad=False): """ Add presentations into the media manager This is called both on initial load of the plugin to populate with existing files, and when the user adds new files via the media manager """ - currlist = self.getFileList() + currlist = self.get_file_list() titles = [os.path.split(file)[1] for file in currlist] self.application.set_busy_cursor() if not initialLoad: @@ -166,7 +166,7 @@ class PresentationMediaItem(MediaManagerItem): item_name.setIcon(build_icon(ERROR)) item_name.setData(QtCore.Qt.UserRole, file) item_name.setToolTip(file) - self.listView.addItem(item_name) + self.list_view.addItem(item_name) else: if titles.count(filename) > 0: if not initialLoad: @@ -203,17 +203,17 @@ class PresentationMediaItem(MediaManagerItem): item_name.setData(QtCore.Qt.UserRole, file) item_name.setIcon(icon) item_name.setToolTip(file) - self.listView.addItem(item_name) + self.list_view.addItem(item_name) if not initialLoad: self.main_window.finished_progress_bar() self.application.set_normal_cursor() - def onDeleteClick(self): + def on_delete_click(self): """ Remove a presentation item from the list """ - if check_item_selected(self.listView, UiStrings().SelectDelete): - items = self.listView.selectedIndexes() + if check_item_selected(self.list_view, UiStrings().SelectDelete): + items = self.list_view.selectedIndexes() row_list = [item.row() for item in items] row_list.sort(reverse=True) self.application.set_busy_cursor() @@ -228,10 +228,10 @@ class PresentationMediaItem(MediaManagerItem): self.main_window.finished_progress_bar() self.application.set_busy_cursor() for row in row_list: - self.listView.takeItem(row) - Settings().setValue(self.settingsSection + u'/presentations files', self.getFileList()) + self.list_view.takeItem(row) + Settings().setValue(self.settings_section + u'/presentations files', self.get_file_list()) - def generateSlideData(self, service_item, item=None, xmlVersion=False, + def generate_slide_data(self, service_item, item=None, xmlVersion=False, remote=False, context=ServiceItemContext.Service): """ Load the relevant information for displaying the presentation @@ -241,7 +241,7 @@ class PresentationMediaItem(MediaManagerItem): if item: items = [item] else: - items = self.listView.selectedItems() + items = self.list_view.selectedItems() if len(items) > 1: return False service_item.title = self.displayTypeComboBox.currentText() @@ -308,7 +308,7 @@ class PresentationMediaItem(MediaManagerItem): return None def search(self, string, showError): - files = Settings().value(self.settingsSection + u'/presentations files') + files = Settings().value(self.settings_section + u'/presentations files') results = [] string = string.lower() for file in files: diff --git a/openlp/plugins/presentations/lib/messagelistener.py b/openlp/plugins/presentations/lib/messagelistener.py index 9a4c0d2ae..d87e7e5dc 100644 --- a/openlp/plugins/presentations/lib/messagelistener.py +++ b/openlp/plugins/presentations/lib/messagelistener.py @@ -288,9 +288,9 @@ class MessageListener(object): """ log.info(u'Message Listener loaded') - def __init__(self, mediaitem): - self.controllers = mediaitem.controllers - self.mediaitem = mediaitem + def __init__(self, media_item): + self.controllers = media_item.controllers + self.media_item = media_item self.preview_handler = Controller(False) self.live_handler = Controller(True) # messages are sent from core.ui.slidecontroller @@ -319,8 +319,8 @@ class MessageListener(object): hide_mode = message[2] file = item.get_frame_path() self.handler = item.title - if self.handler == self.mediaitem.Automatic: - self.handler = self.mediaitem.findControllerByType(file) + if self.handler == self.media_item.Automatic: + self.handler = self.media_item.findControllerByType(file) if not self.handler: return if is_live: diff --git a/openlp/plugins/presentations/lib/presentationcontroller.py b/openlp/plugins/presentations/lib/presentationcontroller.py index 4348e23dc..48955ebb2 100644 --- a/openlp/plugins/presentations/lib/presentationcontroller.py +++ b/openlp/plugins/presentations/lib/presentationcontroller.py @@ -375,7 +375,7 @@ class PresentationController(object): self.plugin = plugin self.name = name self.document_class = document_class - self.settings_section = self.plugin.settingsSection + self.settings_section = self.plugin.settings_section self.available = None self.temp_folder = os.path.join(AppLocation.get_section_data_path(self.settings_section), name) self.thumbnail_folder = os.path.join(AppLocation.get_section_data_path(self.settings_section), u'thumbnails') diff --git a/openlp/plugins/presentations/presentationplugin.py b/openlp/plugins/presentations/presentationplugin.py index 024a278cb..7872c25b7 100644 --- a/openlp/plugins/presentations/presentationplugin.py +++ b/openlp/plugins/presentations/presentationplugin.py @@ -66,15 +66,16 @@ class PresentationPlugin(Plugin): self.controllers = {} Plugin.__init__(self, u'presentations', __default_settings__, __default_settings__) self.weight = -8 - self.iconPath = u':/plugins/plugin_presentations.png' - self.icon = build_icon(self.iconPath) + self.icon_path = u':/plugins/plugin_presentations.png' + self.icon = build_icon(self.icon_path) - def createSettingsTab(self, parent): + def create_settings_Tab(self, parent): """ Create the settings Tab """ - visible_name = self.getString(StringContent.VisibleName) - self.settingsTab = PresentationTab(parent, self.name, visible_name[u'title'], self.controllers, self.iconPath) + visible_name = self.get_string(StringContent.VisibleName) + self.settings_tab = PresentationTab(parent, self.name, visible_name[u'title'], self.controllers, + self.icon_path) def initialise(self): """ @@ -90,7 +91,7 @@ class PresentationPlugin(Plugin): except Exception: log.warn(u'Failed to start controller process') self.controllers[controller].available = False - self.mediaItem.build_file_mask_string() + self.media_item.build_file_mask_string() def finalise(self): """ @@ -105,26 +106,25 @@ class PresentationPlugin(Plugin): controller.kill() Plugin.finalise(self) - def createMediaManagerItem(self): + def create_media_manager_item(self): """ Create the Media Manager List """ - self.mediaItem = PresentationMediaItem( + self.media_item = PresentationMediaItem( self.main_window.media_dock_manager.media_dock, self, self.icon, self.controllers) - def registerControllers(self, controller): + def register_controllers(self, controller): """ - Register each presentation controller (Impress, PPT etc) and - store for later use + Register each presentation controller (Impress, PPT etc) and store for later use """ self.controllers[controller.name] = controller - def checkPreConditions(self): + def check_pre_conditions(self): """ Check to see if we have any presentation software available If Not do not install the plugin. """ - log.debug(u'checkPreConditions') + log.debug(u'check_pre_conditions') controller_dir = os.path.join( AppLocation.get_directory(AppLocation.PluginsDir), u'presentations', u'lib') @@ -141,7 +141,7 @@ class PresentationPlugin(Plugin): controller_classes = PresentationController.__subclasses__() for controller_class in controller_classes: controller = controller_class(self) - self.registerControllers(controller) + self.register_controllers(controller) return bool(self.controllers) def about(self): @@ -160,12 +160,12 @@ class PresentationPlugin(Plugin): Called to define all translatable texts of the plugin """ ## Name PluginList ## - self.textStrings[StringContent.Name] = { + self.text_strings[StringContent.Name] = { u'singular': translate('PresentationPlugin', 'Presentation', 'name singular'), u'plural': translate('PresentationPlugin', 'Presentations', 'name plural') } ## Name for MediaDockManager, SettingsManager ## - self.textStrings[StringContent.VisibleName] = { + self.text_strings[StringContent.VisibleName] = { u'title': translate('PresentationPlugin', 'Presentations', 'container title') } # Middle Header Bar @@ -179,4 +179,4 @@ class PresentationPlugin(Plugin): u'live': translate('PresentationPlugin', 'Send the selected presentation live.'), u'service': translate('PresentationPlugin', 'Add the selected presentation to the service.') } - self.setPluginUiTextStrings(tooltips) + self.set_plugin_ui_text_strings(tooltips) diff --git a/openlp/plugins/remotes/lib/httpserver.py b/openlp/plugins/remotes/lib/httpserver.py index 77a0f31ea..d57b970c6 100644 --- a/openlp/plugins/remotes/lib/httpserver.py +++ b/openlp/plugins/remotes/lib/httpserver.py @@ -171,8 +171,8 @@ class HttpServer(object): clients. Listen out for socket connections. """ log.debug(u'Start TCP server') - port = Settings().value(self.plugin.settingsSection + u'/port') - address = Settings().value(self.plugin.settingsSection + u'/ip address') + port = Settings().value(self.plugin.settings_section + u'/port') + address = Settings().value(self.plugin.settings_section + u'/ip address') self.server = QtNetwork.QTcpServer() self.server.listen(QtNetwork.QHostAddress(address), port) self.server.newConnection.connect(self.new_connection) @@ -492,7 +492,7 @@ class HttpConnection(object): if action == u'search': searches = [] for plugin in self.plugin_manager.plugins: - if plugin.status == PluginStatus.Active and plugin.mediaItem and plugin.mediaItem.hasSearch: + if plugin.status == PluginStatus.Active and plugin.media_item and plugin.mediaItem.hasSearch: searches.append([plugin.name, unicode(plugin.textStrings[StringContent.Name][u'plural'])]) return HttpResponse(json.dumps({u'results': {u'items': searches}}), {u'Content-Type': u'application/json'}) @@ -509,8 +509,8 @@ class HttpConnection(object): return HttpResponse(code=u'400 Bad Request') text = urllib.unquote(text) plugin = self.plugin_manager.get_plugin_by_name(plugin_name) - if plugin.status == PluginStatus.Active and plugin.mediaItem and plugin.mediaItem.hasSearch: - results = plugin.mediaItem.search(text, False) + if plugin.status == PluginStatus.Active and plugin.media_item and plugin.mediaItem.hasSearch: + results = plugin.media_item.search(text, False) else: results = [] return HttpResponse(json.dumps({u'results': {u'items': results}}), {u'Content-Type': u'application/json'}) @@ -524,8 +524,8 @@ class HttpConnection(object): except KeyError, ValueError: return HttpResponse(code=u'400 Bad Request') plugin = self.plugin_manager.get_plugin_by_name(plugin_name) - if plugin.status == PluginStatus.Active and plugin.mediaItem: - plugin.mediaItem.goLive(id, remote=True) + if plugin.status == PluginStatus.Active and plugin.media_item: + plugin.media_item.go_live(id, remote=True) return HttpResponse(code=u'200 OK') def add_to_service(self, plugin_name): @@ -537,9 +537,9 @@ class HttpConnection(object): except KeyError, ValueError: return HttpResponse(code=u'400 Bad Request') plugin = self.plugin_manager.get_plugin_by_name(plugin_name) - if plugin.status == PluginStatus.Active and plugin.mediaItem: - item_id = plugin.mediaItem.createItemFromId(id) - plugin.mediaItem.addToService(item_id, remote=True) + if plugin.status == PluginStatus.Active and plugin.media_item: + item_id = plugin.media_item.createItemFromId(id) + plugin.media_item.add_to_service(item_id, remote=True) return HttpResponse(code=u'200 OK') def send_response(self, response): diff --git a/openlp/plugins/remotes/remoteplugin.py b/openlp/plugins/remotes/remoteplugin.py index 39bb3f430..e990101e3 100644 --- a/openlp/plugins/remotes/remoteplugin.py +++ b/openlp/plugins/remotes/remoteplugin.py @@ -49,8 +49,8 @@ class RemotesPlugin(Plugin): remotes constructor """ Plugin.__init__(self, u'remotes', __default_settings__, settings_tab_class=RemoteTab) - self.iconPath = u':/plugins/plugin_remote.png' - self.icon = build_icon(self.iconPath) + self.icon_path = u':/plugins/plugin_remote.png' + self.icon = build_icon(self.icon_path) self.weight = -1 self.server = None @@ -86,12 +86,12 @@ class RemotesPlugin(Plugin): Called to define all translatable texts of the plugin """ ## Name PluginList ## - self.textStrings[StringContent.Name] = { + self.text_strings[StringContent.Name] = { u'singular': translate('RemotePlugin', 'Remote', 'name singular'), u'plural': translate('RemotePlugin', 'Remotes', 'name plural') } ## Name for MediaDockManager, SettingsManager ## - self.textStrings[StringContent.VisibleName] = { + self.text_strings[StringContent.VisibleName] = { u'title': translate('RemotePlugin', 'Remote', 'container title') } diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index 1a5604402..f5a0f0cac 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -59,12 +59,12 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): """ log.info(u'%s EditSongForm loaded', __name__) - def __init__(self, mediaitem, parent, manager): + def __init__(self, media_item, parent, manager): """ Constructor """ super(EditSongForm, self).__init__(parent) - self.mediaitem = mediaitem + self.media_item = media_item self.song = None # can this be automated? self.width = 400 @@ -320,7 +320,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): for plugin in self.plugin_manager.plugins: if plugin.name == u'media' and plugin.status == PluginStatus.Active: self.from_media_button.setVisible(True) - self.media_form.populateFiles(plugin.mediaItem.getList(MediaType.Audio)) + self.media_form.populateFiles(plugin.media_item.getList(MediaType.Audio)) break def new_song(self): @@ -714,7 +714,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): text = self.song_book_combo_box.currentText() if item == 0 and text: temp_song_book = text - self.mediaitem.songMaintenanceForm.exec_(True) + self.media_item.songMaintenanceForm.exec_(True) self.load_authors() self.load_books() self.load_topics() @@ -884,7 +884,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): self.manager.save_object(self.song) audio_files = map(lambda a: a.file_name, self.song.media_files) log.debug(audio_files) - save_path = os.path.join(AppLocation.get_section_data_path(self.mediaitem.plugin.name), 'audio', + save_path = os.path.join(AppLocation.get_section_data_path(self.media_item.plugin.name), 'audio', str(self.song.id)) check_directory_exists(save_path) self.song.media_files = [] @@ -914,7 +914,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): log.exception(u'Could not remove directory: %s', save_path) clean_song(self.manager, self.song) self.manager.save_object(self.song) - self.mediaitem.autoSelectId = self.song.id + self.media_item.auto_select_id = self.song.id def _get_plugin_manager(self): """ diff --git a/openlp/plugins/songs/forms/songimportform.py b/openlp/plugins/songs/forms/songimportform.py index 537d7552b..4c749f4d0 100644 --- a/openlp/plugins/songs/forms/songimportform.py +++ b/openlp/plugins/songs/forms/songimportform.py @@ -245,10 +245,10 @@ class SongImportForm(OpenLPWizard): filters += u';;' filters += u'%s (*)' % UiStrings().AllFiles filenames = QtGui.QFileDialog.getOpenFileNames(self, title, - Settings().value(self.plugin.settingsSection + u'/last directory import'), filters) + Settings().value(self.plugin.settings_section + u'/last directory import'), filters) if filenames: listbox.addItems(filenames) - Settings().setValue(self.plugin.settingsSection + u'/last directory import', + Settings().setValue(self.plugin.settings_section + u'/last directory import', os.path.split(unicode(filenames[0]))[0]) def get_list_of_files(self, listbox): @@ -364,7 +364,7 @@ class SongImportForm(OpenLPWizard): Save the error report to a file. """ filename = QtGui.QFileDialog.getSaveFileName(self, - Settings().value(self.plugin.settingsSection + u'/last directory import')) + Settings().value(self.plugin.settings_section + u'/last directory import')) if not filename: return report_file = codecs.open(filename, u'w', u'utf-8') diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index 65cf487e3..9d520ee36 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -70,17 +70,17 @@ class SongMediaItem(MediaManagerItem): log.info(u'Song Media Item loaded') def __init__(self, parent, plugin): - self.IconPath = u'songs/song' + self.icon_path = u'songs/song' MediaManagerItem.__init__(self, parent, plugin) self.editSongForm = EditSongForm(self, self.main_window, self.plugin.manager) self.openLyrics = OpenLyrics(self.plugin.manager) - self.singleServiceItem = False + self.single_service_item = False self.songMaintenanceForm = SongMaintenanceForm(self.plugin.manager, self) # Holds information about whether the edit is remotely triggered and # which Song is required. self.remoteSong = -1 self.editItem = None - self.quickPreviewAllowed = True + self.quick_preview_allowed = True self.hasSearch = True def _updateBackgroundAudio(self, song, item): @@ -95,47 +95,47 @@ class SongMediaItem(MediaManagerItem): weight=i, file_name=dest_file)) self.plugin.manager.save_object(song, True) - def addEndHeaderBar(self): + def add_end_header_bar(self): self.toolbar.addSeparator() ## Song Maintenance Button ## self.maintenanceAction = self.toolbar.add_toolbar_action('maintenanceAction', icon=':/songs/song_maintenance.png', triggers=self.onSongMaintenanceClick) - self.addSearchToToolBar() + self.add_search_to_toolbar() # Signals and slots Registry().register_function(u'songs_load_list', self.on_song_list_load) - Registry().register_function(u'songs_preview', self.onPreviewClick) - QtCore.QObject.connect(self.searchTextEdit, QtCore.SIGNAL(u'cleared()'), self.onClearTextButtonClick) - QtCore.QObject.connect(self.searchTextEdit, QtCore.SIGNAL(u'searchTypeChanged(int)'), - self.onSearchTextButtonClicked) + Registry().register_function(u'songs_preview', self.on_preview_click) + QtCore.QObject.connect(self.search_text_edit, QtCore.SIGNAL(u'cleared()'), self.onClearTextButtonClick) + QtCore.QObject.connect(self.search_text_edit, QtCore.SIGNAL(u'searchTypeChanged(int)'), + self.on_search_text_button_clicked) - def addCustomContextActions(self): - create_widget_action(self.listView, separator=True) - create_widget_action(self.listView, + def add_custom_context_actions(self): + create_widget_action(self.list_view, separator=True) + create_widget_action(self.list_view, text=translate('OpenLP.MediaManagerItem', '&Clone'), icon=u':/general/general_clone.png', triggers=self.onCloneClick) def onFocus(self): - self.searchTextEdit.setFocus() + self.search_text_edit.setFocus() def config_update(self): """ IS triggered when the songs config is updated """ log.debug(u'config_updated') - self.searchAsYouType = Settings().value(self.settingsSection + u'/search as type') - self.updateServiceOnEdit = Settings().value(self.settingsSection + u'/update service on edit') - self.addSongFromService = Settings().value(self.settingsSection + u'/add song from service',) + self.searchAsYouType = Settings().value(self.settings_section + u'/search as type') + self.updateServiceOnEdit = Settings().value(self.settings_section + u'/update service on edit') + self.addSongFromService = Settings().value(self.settings_section + u'/add song from service',) def retranslateUi(self): - self.searchTextLabel.setText(u'%s:' % UiStrings().Search) - self.searchTextButton.setText(UiStrings().Search) + self.search_text_label.setText(u'%s:' % UiStrings().Search) + self.search_text_button.setText(UiStrings().Search) self.maintenanceAction.setText(SongStrings.SongMaintenance) self.maintenanceAction.setToolTip(translate('SongsPlugin.MediaItem', 'Maintain the lists of authors, topics and books.')) def initialise(self): - self.searchTextEdit.set_search_types([ + self.search_text_edit.set_search_types([ (SongSearch.Entire, u':/songs/song_search_all.png', translate('SongsPlugin.MediaItem', 'Entire Song'), translate('SongsPlugin.MediaItem', 'Search Entire Song...')), @@ -152,16 +152,16 @@ class SongMediaItem(MediaManagerItem): (SongSearch.Themes, u':/slides/slide_theme.png', UiStrings().Themes, UiStrings().SearchThemes) ]) - self.searchTextEdit.set_current_search_type(Settings().value(u'%s/last search type' % self.settingsSection)) + self.search_text_edit.set_current_search_type(Settings().value(u'%s/last search type' % self.settings_section)) self.config_update() - def onSearchTextButtonClicked(self): + def on_search_text_button_clicked(self): # Save the current search type to the configuration. - Settings().setValue(u'%s/last search type' % self.settingsSection, self.searchTextEdit.current_search_type()) + Settings().setValue(u'%s/last search type' % self.settings_section, self.search_text_edit.current_search_type()) # Reload the list considering the new search type. - search_keywords = unicode(self.searchTextEdit.displayText()) + search_keywords = unicode(self.search_text_edit.displayText()) search_results = [] - search_type = self.searchTextEdit.current_search_type() + search_type = self.search_text_edit.current_search_type() if search_type == SongSearch.Entire: log.debug(u'Entire Song Search') search_results = self.searchEntire(search_keywords) @@ -197,7 +197,7 @@ class SongMediaItem(MediaManagerItem): search_results = self.plugin.manager.get_all_objects(Song, Song.theme_name.like(u'%' + search_keywords + u'%')) self.displayResultsSong(search_results) - self.checkSearchResult() + self.check_search_result() def searchEntire(self, search_keywords): return self.plugin.manager.get_all_objects(Song, @@ -215,16 +215,16 @@ class SongMediaItem(MediaManagerItem): # or from the exit of the Song edit dialog. If remote editing is active # Trigger it and clean up so it will not update again. # Push edits to the service manager to update items - if self.editItem and self.updateServiceOnEdit and not self.remoteTriggered: - item = self.buildServiceItem(self.editItem) + if self.editItem and self.updateServiceOnEdit and not self.remote_triggered: + item = self.build_service_item(self.editItem) self.service_manager.replace_service_item(item) - self.onSearchTextButtonClicked() + self.on_search_text_button_clicked() log.debug(u'on_song_list_load - finished') def displayResultsSong(self, searchresults): log.debug(u'display results Song') - self.saveAutoSelectId() - self.listView.clear() + self.save_auto_select_id() + self.list_view.clear() searchresults.sort(cmp=natcmp, key=lambda song: song.sort_key) for song in searchresults: # Do not display temporary songs @@ -235,15 +235,15 @@ class SongMediaItem(MediaManagerItem): song_detail = u'%s (%s)' % (song_title, create_separated_list(author_list)) song_name = QtGui.QListWidgetItem(song_detail) song_name.setData(QtCore.Qt.UserRole, song.id) - self.listView.addItem(song_name) + self.list_view.addItem(song_name) # Auto-select the item if name has been set - if song.id == self.autoSelectId: - self.listView.setCurrentItem(song_name) - self.autoSelectId = -1 + if song.id == self.auto_select_id: + self.list_view.setCurrentItem(song_name) + self.auto_select_id = -1 def displayResultsAuthor(self, searchresults): log.debug(u'display results Author') - self.listView.clear() + self.list_view.clear() for author in searchresults: for song in author.songs: # Do not display temporary songs @@ -252,11 +252,11 @@ class SongMediaItem(MediaManagerItem): song_detail = u'%s (%s)' % (author.display_name, song.title) song_name = QtGui.QListWidgetItem(song_detail) song_name.setData(QtCore.Qt.UserRole, song.id) - self.listView.addItem(song_name) + self.list_view.addItem(song_name) def displayResultsBook(self, searchresults, song_number=False): log.debug(u'display results Book') - self.listView.clear() + self.list_view.clear() for book in searchresults: songs = sorted(book.songs, key=lambda song: int(re.match(r'[0-9]+', u'0' + song.song_number).group())) @@ -269,16 +269,16 @@ class SongMediaItem(MediaManagerItem): song_detail = u'%s - %s (%s)' % (book.name, song.song_number, song.title) song_name = QtGui.QListWidgetItem(song_detail) song_name.setData(QtCore.Qt.UserRole, song.id) - self.listView.addItem(song_name) + self.list_view.addItem(song_name) def onClearTextButtonClick(self): """ Clear the search text. """ - self.searchTextEdit.clear() - self.onSearchTextButtonClicked() + self.search_text_edit.clear() + self.on_search_text_button_clicked() - def onSearchTextEditChanged(self, text): + def on_search_text_edit_changed(self, text): """ If search as type enabled invoke the search on each key press. If the Lyrics are being searched do not start till 7 characters @@ -286,34 +286,34 @@ class SongMediaItem(MediaManagerItem): """ if self.searchAsYouType: search_length = 1 - if self.searchTextEdit.current_search_type() == SongSearch.Entire: + if self.search_text_edit.current_search_type() == SongSearch.Entire: search_length = 4 - elif self.searchTextEdit.current_search_type() == SongSearch.Lyrics: + elif self.search_text_edit.current_search_type() == SongSearch.Lyrics: search_length = 3 if len(text) > search_length: - self.onSearchTextButtonClicked() + self.on_search_text_button_clicked() elif not text: self.onClearTextButtonClick() - def onImportClick(self): + def on_import_click(self): if not hasattr(self, u'import_wizard'): self.import_wizard = SongImportForm(self, self.plugin) self.import_wizard.exec_() # Run song load as list may have been cancelled but some songs loaded Registry().execute(u'songs_load_list') - def onExportClick(self): + def on_export_click(self): if not hasattr(self, u'exportWizard'): self.exportWizard = SongExportForm(self, self.plugin) self.exportWizard.exec_() - def onNewClick(self): - log.debug(u'onNewClick') + def on_new_click(self): + log.debug(u'on_new_click') self.editSongForm.new_song() self.editSongForm.exec_() self.onClearTextButtonClick() - self.onSelectionChange() - self.autoSelectId = -1 + self.on_selection_change() + self.auto_select_id = -1 def onSongMaintenanceClick(self): self.songMaintenanceForm.exec_() @@ -330,37 +330,37 @@ class SongMediaItem(MediaManagerItem): if valid: self.editSongForm.load_song(song_id, preview) if self.editSongForm.exec_() == QtGui.QDialog.Accepted: - self.autoSelectId = -1 + self.auto_select_id = -1 self.on_song_list_load() self.remoteSong = song_id - self.remoteTriggered = True - item = self.buildServiceItem(remote=True) + self.remote_triggered = True + item = self.build_service_item(remote=True) self.remoteSong = -1 - self.remoteTriggered = None + self.remote_triggered = None if item: return item return None - def onEditClick(self): + def on_edit_click(self): """ Edit a song """ - log.debug(u'onEditClick') - if check_item_selected(self.listView, UiStrings().SelectEdit): - self.editItem = self.listView.currentItem() + log.debug(u'on_edit_click') + if check_item_selected(self.list_view, UiStrings().SelectEdit): + self.editItem = self.list_view.currentItem() item_id = self.editItem.data(QtCore.Qt.UserRole) self.editSongForm.load_song(item_id, False) self.editSongForm.exec_() - self.autoSelectId = -1 + self.auto_select_id = -1 self.on_song_list_load() self.editItem = None - def onDeleteClick(self): + def on_delete_click(self): """ Remove a song from the list and database """ - if check_item_selected(self.listView, UiStrings().SelectDelete): - items = self.listView.selectedIndexes() + if check_item_selected(self.list_view, UiStrings().SelectDelete): + items = self.list_view.selectedIndexes() if QtGui.QMessageBox.question(self, UiStrings().ConfirmDelete, translate('SongsPlugin.MediaItem', 'Are you sure you want to delete the %n selected song(s)?', '', @@ -388,15 +388,15 @@ class SongMediaItem(MediaManagerItem): self.main_window.increment_progress_bar() self.main_window.finished_progress_bar() self.application.set_normal_cursor() - self.onSearchTextButtonClicked() + self.on_search_text_button_clicked() def onCloneClick(self): """ Clone a Song """ log.debug(u'onCloneClick') - if check_item_selected(self.listView, UiStrings().SelectEdit): - self.editItem = self.listView.currentItem() + if check_item_selected(self.list_view, UiStrings().SelectEdit): + self.editItem = self.list_view.currentItem() item_id = self.editItem.data(QtCore.Qt.UserRole) old_song = self.plugin.manager.get_object(Song, item_id) song_xml = self.openLyrics.song_to_xml(old_song) @@ -406,10 +406,13 @@ class SongMediaItem(MediaManagerItem): self.plugin.manager.save_object(new_song) self.on_song_list_load() - def generateSlideData(self, service_item, item=None, xmlVersion=False, + def generate_slide_data(self, service_item, item=None, xmlVersion=False, remote=False, context=ServiceItemContext.Service): - log.debug(u'generateSlideData: %s, %s, %s' % (service_item, item, self.remoteSong)) - item_id = self._getIdOfItemToGenerate(item, self.remoteSong) + """ + Generate the slide data. Needs to be implemented by the plugin. + """ + log.debug(u'generate_slide_data: %s, %s, %s' % (service_item, item, self.remoteSong)) + item_id = self._get_id_of_item_to_generate(item, self.remoteSong) service_item.add_capability(ItemCapabilities.CanEdit) service_item.add_capability(ItemCapabilities.CanPreview) service_item.add_capability(ItemCapabilities.CanLoop) @@ -478,11 +481,11 @@ class SongMediaItem(MediaManagerItem): service_item.background_audio = [m.file_name for m in song.media_files] return True - def serviceLoad(self, item): + def service_load(self, item): """ Triggered by a song being loaded by the service manager. """ - log.debug(u'serviceLoad') + log.debug(u'service_load') if self.plugin.status != PluginStatus.Active or not item.data_string: return if item.data_string[u'title'].find(u'@') == -1: @@ -522,7 +525,7 @@ class SongMediaItem(MediaManagerItem): if item.background_audio: self._updateBackgroundAudio(song, item) editId = song.id - self.onSearchTextButtonClicked() + self.on_search_text_button_clicked() elif add_song and not self.addSongFromService: # Make sure we temporary import formatting tags. song = self.openLyrics.xml_to_song(item.xml_version, True) diff --git a/openlp/plugins/songs/songsplugin.py b/openlp/plugins/songs/songsplugin.py index b98180f20..65056ee5b 100644 --- a/openlp/plugins/songs/songsplugin.py +++ b/openlp/plugins/songs/songsplugin.py @@ -82,24 +82,27 @@ class SongsPlugin(Plugin): Plugin.__init__(self, u'songs', __default_settings__, SongMediaItem, SongsTab) self.manager = Manager(u'songs', init_schema, upgrade_mod=upgrade) self.weight = -10 - self.iconPath = u':/plugins/plugin_songs.png' - self.icon = build_icon(self.iconPath) + self.icon_path = u':/plugins/plugin_songs.png' + self.icon = build_icon(self.icon_path) - def checkPreConditions(self): + def check_pre_conditions(self): + """ + Check the plugin can run. + """ return self.manager.session is not None def initialise(self): log.info(u'Songs Initialising') Plugin.initialise(self) - self.songImportItem.setVisible(True) - self.songExportItem.setVisible(True) - self.toolsReindexItem.setVisible(True) + self.song_import_item.setVisible(True) + self.song_export_item.setVisible(True) + self.tools_reindex_item.setVisible(True) action_list = ActionList.get_instance() - action_list.add_action(self.songImportItem, UiStrings().Import) - action_list.add_action(self.songExportItem, UiStrings().Export) - action_list.add_action(self.toolsReindexItem, UiStrings().Tools) + action_list.add_action(self.song_import_item, UiStrings().Import) + action_list.add_action(self.song_export_item, UiStrings().Export) + action_list.add_action(self.tools_reindex_item, UiStrings().Tools) - def addImportMenuItem(self, import_menu): + def add_import_menu_item(self, import_menu): """ Give the Songs plugin the opportunity to add items to the **Import** menu. @@ -109,13 +112,13 @@ class SongsPlugin(Plugin): use it as their parent. """ # Main song import menu item - will eventually be the only one - self.songImportItem = create_action(import_menu, u'songImportItem', + self.song_import_item = create_action(import_menu, u'songImportItem', text=translate('SongsPlugin', '&Song'), tooltip=translate('SongsPlugin', 'Import songs using the import wizard.'), - triggers=self.onSongImportItemClicked) - import_menu.addAction(self.songImportItem) + triggers=self.on_song_import_item_clicked) + import_menu.addAction(self.song_import_item) - def addExportMenuItem(self, export_menu): + def add_export_menu_Item(self, export_menu): """ Give the Songs plugin the opportunity to add items to the **Export** menu. @@ -125,13 +128,13 @@ class SongsPlugin(Plugin): use it as their parent. """ # Main song import menu item - will eventually be the only one - self.songExportItem = create_action(export_menu, u'songExportItem', + self.song_export_item = create_action(export_menu, u'songExportItem', text=translate('SongsPlugin', '&Song'), tooltip=translate('SongsPlugin', 'Exports songs using the export wizard.'), - triggers=self.onSongExportItemClicked) - export_menu.addAction(self.songExportItem) + triggers=self.on_song_export_item_clicked) + export_menu.addAction(self.song_export_item) - def addToolsMenuItem(self, tools_menu): + def add_tools_menu_item(self, tools_menu): """ Give the alerts plugin the opportunity to add items to the **Tools** menu. @@ -141,38 +144,38 @@ class SongsPlugin(Plugin): use it as their parent. """ log.info(u'add tools menu') - self.toolsReindexItem = create_action(tools_menu, u'toolsReindexItem', + self.tools_reindex_item = create_action(tools_menu, u'toolsReindexItem', text=translate('SongsPlugin', '&Re-index Songs'), icon=u':/plugins/plugin_songs.png', statustip=translate('SongsPlugin', 'Re-index the songs database to improve searching and ordering.'), - visible=False, triggers=self.onToolsReindexItemTriggered) - tools_menu.addAction(self.toolsReindexItem) + visible=False, triggers=self.on_tools_reindex_item_triggered) + tools_menu.addAction(self.tools_reindex_item) - def onToolsReindexItemTriggered(self): + def on_tools_reindex_item_triggered(self): """ Rebuild each song. """ maxSongs = self.manager.get_object_count(Song) if maxSongs == 0: return - progressDialog = QtGui.QProgressDialog(translate('SongsPlugin', 'Reindexing songs...'), UiStrings().Cancel, + progress_dialog = QtGui.QProgressDialog(translate('SongsPlugin', 'Reindexing songs...'), UiStrings().Cancel, 0, maxSongs, self.main_window) - progressDialog.setWindowTitle(translate('SongsPlugin', 'Reindexing songs')) - progressDialog.setWindowModality(QtCore.Qt.WindowModal) + progress_dialog.setWindowTitle(translate('SongsPlugin', 'Reindexing songs')) + progress_dialog.setWindowModality(QtCore.Qt.WindowModal) songs = self.manager.get_all_objects(Song) for number, song in enumerate(songs): clean_song(self.manager, song) - progressDialog.setValue(number + 1) + progress_dialog.setValue(number + 1) self.manager.save_objects(songs) - self.mediaItem.onSearchTextButtonClicked() + self.media_item.on_search_text_button_clicked() - def onSongImportItemClicked(self): - if self.mediaItem: - self.mediaItem.onImportClick() + def on_song_import_item_clicked(self): + if self.media_item: + self.media_item.on_import_click() - def onSongExportItemClicked(self): - if self.mediaItem: - self.mediaItem.onExportClick() + def on_song_export_item_clicked(self): + if self.media_item: + self.media_item.on_export_click() def about(self): return translate('SongsPlugin', 'Songs Plugin' @@ -207,7 +210,7 @@ class SongsPlugin(Plugin): def importSongs(self, format, **kwargs): class_ = SongFormat.get(format, u'class') importer = class_(self.manager, **kwargs) - importer.register(self.mediaItem.import_wizard) + importer.register(self.media_item.import_wizard) return importer def set_plugin_text_strings(self): @@ -215,12 +218,12 @@ class SongsPlugin(Plugin): Called to define all translatable texts of the plugin """ ## Name PluginList ## - self.textStrings[StringContent.Name] = { + self.text_strings[StringContent.Name] = { u'singular': translate('SongsPlugin', 'Song', 'name singular'), u'plural': translate('SongsPlugin', 'Songs', 'name plural') } ## Name for MediaDockManager, SettingsManager ## - self.textStrings[StringContent.VisibleName] = { + self.text_strings[StringContent.VisibleName] = { u'title': translate('SongsPlugin', 'Songs', 'container title') } # Middle Header Bar @@ -235,7 +238,7 @@ class SongsPlugin(Plugin): u'service': translate('SongsPlugin', 'Add the selected song to the service.') } - self.setPluginUiTextStrings(tooltips) + self.set_plugin_ui_text_strings(tooltips) def first_time(self): """ @@ -243,7 +246,7 @@ class SongsPlugin(Plugin): new songs into the database. """ self.application.process_events() - self.onToolsReindexItemTriggered() + self.on_tools_reindex_item_triggered() self.application.process_events() db_dir = unicode(os.path.join(unicode(gettempdir(), get_filesystem_encoding()), u'openlp')) if not os.path.exists(db_dir): @@ -272,7 +275,7 @@ class SongsPlugin(Plugin): importer.doImport(progress) self.application.process_events() progress.setValue(song_count) - self.mediaItem.onSearchTextButtonClicked() + self.media_item.on_search_text_button_clicked() def finalise(self): """ @@ -282,13 +285,13 @@ class SongsPlugin(Plugin): self.new_service_created() # Clean up files and connections self.manager.finalise() - self.songImportItem.setVisible(False) - self.songExportItem.setVisible(False) - self.toolsReindexItem.setVisible(False) + self.song_import_item.setVisible(False) + self.song_export_item.setVisible(False) + self.tools_reindex_item.setVisible(False) action_list = ActionList.get_instance() - action_list.remove_action(self.songImportItem, UiStrings().Import) - action_list.remove_action(self.songExportItem, UiStrings().Export) - action_list.remove_action(self.toolsReindexItem, UiStrings().Tools) + action_list.remove_action(self.song_import_item, UiStrings().Import) + action_list.remove_action(self.song_export_item, UiStrings().Export) + action_list.remove_action(self.tools_reindex_item, UiStrings().Tools) Plugin.finalise(self) def new_service_created(self): diff --git a/openlp/plugins/songusage/forms/songusagedetailform.py b/openlp/plugins/songusage/forms/songusagedetailform.py index 69611fd69..edb007421 100644 --- a/openlp/plugins/songusage/forms/songusagedetailform.py +++ b/openlp/plugins/songusage/forms/songusagedetailform.py @@ -58,9 +58,9 @@ class SongUsageDetailForm(QtGui.QDialog, Ui_SongUsageDetailDialog): """ We need to set up the screen """ - self.from_date_calendar.setSelectedDate(Settings().value(self.plugin.settingsSection + u'/from date')) - self.to_date_calendar.setSelectedDate(Settings().value(self.plugin.settingsSection + u'/to date')) - self.file_line_edit.setText(Settings().value(self.plugin.settingsSection + u'/last directory export')) + self.from_date_calendar.setSelectedDate(Settings().value(self.plugin.settings_section + u'/from date')) + self.to_date_calendar.setSelectedDate(Settings().value(self.plugin.settings_section + u'/to date')) + self.file_line_edit.setText(Settings().value(self.plugin.settings_section + u'/last directory export')) def define_output_location(self): """ @@ -68,9 +68,9 @@ class SongUsageDetailForm(QtGui.QDialog, Ui_SongUsageDetailDialog): """ path = QtGui.QFileDialog.getExistingDirectory(self, translate('SongUsagePlugin.SongUsageDetailForm', 'Output File Location'), - Settings().value(self.plugin.settingsSection + u'/last directory export')) + Settings().value(self.plugin.settings_section + u'/last directory export')) if path: - Settings().setValue(self.plugin.settingsSection + u'/last directory export', path) + Settings().setValue(self.plugin.settings_section + u'/last directory export', path) self.file_line_edit.setText(path) def accept(self): @@ -90,8 +90,8 @@ class SongUsageDetailForm(QtGui.QDialog, Ui_SongUsageDetailDialog): file_name = translate('SongUsagePlugin.SongUsageDetailForm', 'usage_detail_%s_%s.txt') % ( self.from_date_calendar.selectedDate().toString(u'ddMMyyyy'), self.to_date_calendar.selectedDate().toString(u'ddMMyyyy')) - Settings().setValue(self.plugin.settingsSection + u'/from date', self.from_date_calendar.selectedDate()) - Settings().setValue(self.plugin.settingsSection + u'/to date', self.to_date_calendar.selectedDate()) + Settings().setValue(self.plugin.settings_section + u'/from date', self.from_date_calendar.selectedDate()) + Settings().setValue(self.plugin.settings_section + u'/to date', self.to_date_calendar.selectedDate()) usage = self.plugin.manager.get_all_objects( SongUsageItem, and_( SongUsageItem.usagedate >= self.from_date_calendar.selectedDate().toPyDate(), diff --git a/openlp/plugins/songusage/songusageplugin.py b/openlp/plugins/songusage/songusageplugin.py index 2bfc6b253..7ca056184 100644 --- a/openlp/plugins/songusage/songusageplugin.py +++ b/openlp/plugins/songusage/songusageplugin.py @@ -64,14 +64,17 @@ class SongUsagePlugin(Plugin): self.manager = Manager(u'songusage', init_schema, upgrade_mod=upgrade) self.weight = -4 self.icon = build_icon(u':/plugins/plugin_songusage.png') - self.activeIcon = build_icon(u':/songusage/song_usage_active.png') - self.inactiveIcon = build_icon(u':/songusage/song_usage_inactive.png') + self.active_icon = build_icon(u':/songusage/song_usage_active.png') + self.inactive_icon = build_icon(u':/songusage/song_usage_inactive.png') self.song_usage_active = False - def checkPreConditions(self): + def check_pre_conditions(self): + """ + Check the plugin can run. + """ return self.manager.session is not None - def addToolsMenuItem(self, tools_menu): + def add_tools_menu_item(self, tools_menu): """ Give the SongUsage plugin the opportunity to add items to the **Tools** menu. @@ -124,7 +127,7 @@ class SongUsagePlugin(Plugin): Plugin.initialise(self) Registry().register_function(u'slidecontroller_live_started', self.display_song_usage) Registry().register_function(u'print_service_started', self.print_song_usage) - self.song_usage_active = Settings().value(self.settingsSection + u'/active') + self.song_usage_active = Settings().value(self.settings_section + u'/active') # Set the button and checkbox state self.set_button_state() action_list = ActionList.get_instance() @@ -158,7 +161,7 @@ class SongUsagePlugin(Plugin): the UI when necessary, """ self.song_usage_active = not self.song_usage_active - Settings().setValue(self.settingsSection + u'/active', self.song_usage_active) + Settings().setValue(self.settings_section + u'/active', self.song_usage_active) self.set_button_state() def set_button_state(self): @@ -169,12 +172,12 @@ class SongUsagePlugin(Plugin): self.song_usage_active_button.blockSignals(True) self.song_usage_status.blockSignals(True) if self.song_usage_active: - self.song_usage_active_button.setIcon(self.activeIcon) + self.song_usage_active_button.setIcon(self.active_icon) self.song_usage_status.setChecked(True) self.song_usage_active_button.setChecked(True) self.song_usage_active_button.setToolTip(translate('SongUsagePlugin', 'Song usage tracking is active.')) else: - self.song_usage_active_button.setIcon(self.inactiveIcon) + self.song_usage_active_button.setIcon(self.inactive_icon) self.song_usage_status.setChecked(False) self.song_usage_active_button.setChecked(False) self.song_usage_active_button.setToolTip(translate('SongUsagePlugin', 'Song usage tracking is inactive.')) @@ -224,11 +227,11 @@ class SongUsagePlugin(Plugin): Called to define all translatable texts of the plugin """ ## Name PluginList ## - self.textStrings[StringContent.Name] = { + self.text_strings[StringContent.Name] = { u'singular': translate('SongUsagePlugin', 'SongUsage', 'name singular'), u'plural': translate('SongUsagePlugin', 'SongUsage', 'name plural') } ## Name for MediaDockManager, SettingsManager ## - self.textStrings[StringContent.VisibleName] = { + self.text_strings[StringContent.VisibleName] = { u'title': translate('SongUsagePlugin', 'SongUsage', 'container title') } diff --git a/tests/functional/openlp_core_lib/test_pluginmanager.py b/tests/functional/openlp_core_lib/test_pluginmanager.py index 5ae9341cb..9d6c30f8e 100644 --- a/tests/functional/openlp_core_lib/test_pluginmanager.py +++ b/tests/functional/openlp_core_lib/test_pluginmanager.py @@ -41,9 +41,9 @@ class TestPluginManager(TestCase): # WHEN: We run hook_media_manager() plugin_manager.hook_media_manager() - # THEN: The createMediaManagerItem() method should have been called - assert mocked_plugin.createMediaManagerItem.call_count == 0, \ - u'The createMediaManagerItem() method should not have been called.' + # THEN: The create_media_manager_item() method should have been called + assert mocked_plugin.create_media_manager_item.call_count == 0, \ + u'The create_media_manager_item() method should not have been called.' def hook_media_manager_with_active_plugin_test(self): """ @@ -58,8 +58,8 @@ class TestPluginManager(TestCase): # WHEN: We run hook_media_manager() plugin_manager.hook_media_manager() - # THEN: The createMediaManagerItem() method should have been called - mocked_plugin.createMediaManagerItem.assert_called_with() + # THEN: The create_media_manager_item() method should have been called + mocked_plugin.create_media_manager_item.assert_called_with() def hook_settings_tabs_with_disabled_plugin_and_no_form_test(self): """ @@ -74,9 +74,9 @@ class TestPluginManager(TestCase): # WHEN: We run hook_settings_tabs() plugin_manager.hook_settings_tabs() - # THEN: The createSettingsTab() method should have been called - assert mocked_plugin.createMediaManagerItem.call_count == 0, \ - u'The createMediaManagerItem() method should not have been called.' + # THEN: The create_settings_Tab() method should have been called + assert mocked_plugin.create_media_manager_item.call_count == 0, \ + u'The create_media_manager_item() method should not have been called.' def hook_settings_tabs_with_disabled_plugin_and_mocked_form_test(self): """ @@ -94,9 +94,9 @@ class TestPluginManager(TestCase): # WHEN: We run hook_settings_tabs() plugin_manager.hook_settings_tabs() - # THEN: The createSettingsTab() method should not have been called, but the plugins lists should be the same - assert mocked_plugin.createSettingsTab.call_count == 0, \ - u'The createMediaManagerItem() method should not have been called.' + # THEN: The create_settings_Tab() method should not have been called, but the plugins lists should be the same + assert mocked_plugin.create_settings_Tab.call_count == 0, \ + u'The create_media_manager_item() method should not have been called.' self.assertEqual(mocked_settings_form.plugin_manager.plugins, plugin_manager.plugins, u'The plugins on the settings form should be the same as the plugins in the plugin manager') @@ -116,9 +116,9 @@ class TestPluginManager(TestCase): # WHEN: We run hook_settings_tabs() plugin_manager.hook_settings_tabs() - # THEN: The createMediaManagerItem() method should have been called with the mocked settings form - assert mocked_plugin.createSettingsTab.call_count == 1, \ - u'The createMediaManagerItem() method should have been called once.' + # THEN: The create_media_manager_item() method should have been called with the mocked settings form + assert mocked_plugin.create_settings_Tab.call_count == 1, \ + u'The create_media_manager_item() method should have been called once.' self.assertEqual(mocked_settings_form.plugin_manager.plugins, plugin_manager.plugins, u'The plugins on the settings form should be the same as the plugins in the plugin manager') @@ -135,8 +135,8 @@ class TestPluginManager(TestCase): # WHEN: We run hook_settings_tabs() plugin_manager.hook_settings_tabs() - # THEN: The createSettingsTab() method should have been called - mocked_plugin.createSettingsTab.assert_called_with(self.mocked_settings_form) + # THEN: The create_settings_Tab() method should have been called + mocked_plugin.create_settings_Tab.assert_called_with(self.mocked_settings_form) def hook_import_menu_with_disabled_plugin_test(self): """ @@ -151,9 +151,9 @@ class TestPluginManager(TestCase): # WHEN: We run hook_import_menu() plugin_manager.hook_import_menu() - # THEN: The createMediaManagerItem() method should have been called - assert mocked_plugin.addImportMenuItem.call_count == 0, \ - u'The addImportMenuItem() method should not have been called.' + # THEN: The create_media_manager_item() method should have been called + assert mocked_plugin.add_import_menu_item.call_count == 0, \ + u'The add_import_menu_item() method should not have been called.' def hook_import_menu_with_active_plugin_test(self): """ @@ -168,8 +168,8 @@ class TestPluginManager(TestCase): # WHEN: We run hook_import_menu() plugin_manager.hook_import_menu() - # THEN: The addImportMenuItem() method should have been called - mocked_plugin.addImportMenuItem.assert_called_with(self.mocked_main_window.file_import_menu) + # THEN: The add_import_menu_item() method should have been called + mocked_plugin.add_import_menu_item.assert_called_with(self.mocked_main_window.file_import_menu) def hook_export_menu_with_disabled_plugin_test(self): """ @@ -184,9 +184,9 @@ class TestPluginManager(TestCase): # WHEN: We run hook_export_menu() plugin_manager.hook_export_menu() - # THEN: The addExportMenuItem() method should not have been called - assert mocked_plugin.addExportMenuItem.call_count == 0, \ - u'The addExportMenuItem() method should not have been called.' + # THEN: The add_export_menu_Item() method should not have been called + assert mocked_plugin.add_export_menu_Item.call_count == 0, \ + u'The add_export_menu_Item() method should not have been called.' def hook_export_menu_with_active_plugin_test(self): """ @@ -201,8 +201,8 @@ class TestPluginManager(TestCase): # WHEN: We run hook_export_menu() plugin_manager.hook_export_menu() - # THEN: The addExportMenuItem() method should have been called - mocked_plugin.addExportMenuItem.assert_called_with(self.mocked_main_window.file_export_menu) + # THEN: The add_export_menu_Item() method should have been called + mocked_plugin.add_export_menu_Item.assert_called_with(self.mocked_main_window.file_export_menu) def hook_upgrade_plugin_settings_with_disabled_plugin_test(self): """ @@ -236,7 +236,7 @@ class TestPluginManager(TestCase): # WHEN: We run hook_upgrade_plugin_settings() plugin_manager.hook_upgrade_plugin_settings(settings) - # THEN: The addExportMenuItem() method should have been called + # THEN: The add_export_menu_Item() method should have been called mocked_plugin.upgrade_settings.assert_called_with(settings) def hook_tools_menu_with_disabled_plugin_test(self): @@ -252,9 +252,9 @@ class TestPluginManager(TestCase): # WHEN: We run hook_tools_menu() plugin_manager.hook_tools_menu() - # THEN: The addToolsMenuItem() method should have been called - assert mocked_plugin.addToolsMenuItem.call_count == 0, \ - u'The addToolsMenuItem() method should not have been called.' + # THEN: The add_tools_menu_item() method should have been called + assert mocked_plugin.add_tools_menu_item.call_count == 0, \ + u'The add_tools_menu_item() method should not have been called.' def hook_tools_menu_with_active_plugin_test(self): """ @@ -269,8 +269,8 @@ class TestPluginManager(TestCase): # WHEN: We run hook_tools_menu() plugin_manager.hook_tools_menu() - # THEN: The addToolsMenuItem() method should have been called - mocked_plugin.addToolsMenuItem.assert_called_with(self.mocked_main_window.tools_menu) + # THEN: The add_tools_menu_item() method should have been called + mocked_plugin.add_tools_menu_item.assert_called_with(self.mocked_main_window.tools_menu) def initialise_plugins_with_disabled_plugin_test(self): """ @@ -279,15 +279,15 @@ class TestPluginManager(TestCase): # GIVEN: A PluginManager instance and a list with a mocked up plugin whose status is set to Disabled mocked_plugin = MagicMock() mocked_plugin.status = PluginStatus.Disabled - mocked_plugin.isActive.return_value = False + mocked_plugin.is_active.return_value = False plugin_manager = PluginManager() plugin_manager.plugins = [mocked_plugin] # WHEN: We run initialise_plugins() plugin_manager.initialise_plugins() - # THEN: The isActive() method should have been called, and initialise() method should NOT have been called - mocked_plugin.isActive.assert_called_with() + # THEN: The is_active() method should have been called, and initialise() method should NOT have been called + mocked_plugin.is_active.assert_called_with() assert mocked_plugin.initialise.call_count == 0, u'The initialise() method should not have been called.' def initialise_plugins_with_active_plugin_test(self): @@ -297,15 +297,15 @@ class TestPluginManager(TestCase): # GIVEN: A PluginManager instance and a list with a mocked up plugin whose status is set to Active mocked_plugin = MagicMock() mocked_plugin.status = PluginStatus.Active - mocked_plugin.isActive.return_value = True + mocked_plugin.is_active.return_value = True plugin_manager = PluginManager() plugin_manager.plugins = [mocked_plugin] # WHEN: We run initialise_plugins() plugin_manager.initialise_plugins() - # THEN: The isActive() and initialise() methods should have been called - mocked_plugin.isActive.assert_called_with() + # THEN: The is_active() and initialise() methods should have been called + mocked_plugin.is_active.assert_called_with() mocked_plugin.initialise.assert_called_with() def finalise_plugins_with_disabled_plugin_test(self): @@ -315,15 +315,15 @@ class TestPluginManager(TestCase): # GIVEN: A PluginManager instance and a list with a mocked up plugin whose status is set to Disabled mocked_plugin = MagicMock() mocked_plugin.status = PluginStatus.Disabled - mocked_plugin.isActive.return_value = False + mocked_plugin.is_active.return_value = False plugin_manager = PluginManager() plugin_manager.plugins = [mocked_plugin] # WHEN: We run finalise_plugins() plugin_manager.finalise_plugins() - # THEN: The isActive() method should have been called, and initialise() method should NOT have been called - mocked_plugin.isActive.assert_called_with() + # THEN: The is_active() method should have been called, and initialise() method should NOT have been called + mocked_plugin.is_active.assert_called_with() assert mocked_plugin.finalise.call_count == 0, u'The finalise() method should not have been called.' def finalise_plugins_with_active_plugin_test(self): @@ -333,15 +333,15 @@ class TestPluginManager(TestCase): # GIVEN: A PluginManager instance and a list with a mocked up plugin whose status is set to Active mocked_plugin = MagicMock() mocked_plugin.status = PluginStatus.Active - mocked_plugin.isActive.return_value = True + mocked_plugin.is_active.return_value = True plugin_manager = PluginManager() plugin_manager.plugins = [mocked_plugin] # WHEN: We run finalise_plugins() plugin_manager.finalise_plugins() - # THEN: The isActive() and finalise() methods should have been called - mocked_plugin.isActive.assert_called_with() + # THEN: The is_active() and finalise() methods should have been called + mocked_plugin.is_active.assert_called_with() mocked_plugin.finalise.assert_called_with() def get_plugin_by_name_does_not_exist_test(self): @@ -357,7 +357,7 @@ class TestPluginManager(TestCase): # WHEN: We run finalise_plugins() result = plugin_manager.get_plugin_by_name('Missing Plugin') - # THEN: The isActive() and finalise() methods should have been called + # THEN: The is_active() and finalise() methods should have been called self.assertIsNone(result, u'The result for get_plugin_by_name should be None') def get_plugin_by_name_exists_test(self): @@ -373,7 +373,7 @@ class TestPluginManager(TestCase): # WHEN: We run finalise_plugins() result = plugin_manager.get_plugin_by_name('Mocked Plugin') - # THEN: The isActive() and finalise() methods should have been called + # THEN: The is_active() and finalise() methods should have been called self.assertEqual(result, mocked_plugin, u'The result for get_plugin_by_name should be the mocked plugin') def new_service_created_with_disabled_plugin_test(self): @@ -383,7 +383,7 @@ class TestPluginManager(TestCase): # GIVEN: A PluginManager instance and a list with a mocked up plugin whose status is set to Disabled mocked_plugin = MagicMock() mocked_plugin.status = PluginStatus.Disabled - mocked_plugin.isActive.return_value = False + mocked_plugin.is_active.return_value = False plugin_manager = PluginManager() plugin_manager.plugins = [mocked_plugin] @@ -391,7 +391,7 @@ class TestPluginManager(TestCase): plugin_manager.new_service_created() # THEN: The isActive() method should have been called, and initialise() method should NOT have been called - mocked_plugin.isActive.assert_called_with() + mocked_plugin.is_active.assert_called_with() assert mocked_plugin.new_service_created.call_count == 0,\ u'The new_service_created() method should not have been called.' @@ -402,13 +402,13 @@ class TestPluginManager(TestCase): # GIVEN: A PluginManager instance and a list with a mocked up plugin whose status is set to Active mocked_plugin = MagicMock() mocked_plugin.status = PluginStatus.Active - mocked_plugin.isActive.return_value = True + mocked_plugin.is_active.return_value = True plugin_manager = PluginManager() plugin_manager.plugins = [mocked_plugin] # WHEN: We run new_service_created() plugin_manager.new_service_created() - # THEN: The isActive() and finalise() methods should have been called - mocked_plugin.isActive.assert_called_with() + # THEN: The is_active() and finalise() methods should have been called + mocked_plugin.is_active.assert_called_with() mocked_plugin.new_service_created.assert_called_with() diff --git a/tests/functional/openlp_plugins/images/test_lib.py b/tests/functional/openlp_plugins/images/test_lib.py index eae30a113..a355e956b 100644 --- a/tests/functional/openlp_plugins/images/test_lib.py +++ b/tests/functional/openlp_plugins/images/test_lib.py @@ -27,7 +27,7 @@ class TestImageMediaItem(TestCase): mocked_plugin = MagicMock() with patch(u'openlp.plugins.images.lib.mediaitem.ImageMediaItem.__init__') as mocked_init: mocked_init.return_value = None - self.mediaitem = ImageMediaItem(mocked_parent, mocked_plugin) + self.media_item = ImageMediaItem(mocked_parent, mocked_plugin) def save_new_images_list_empty_list_test(self): """ @@ -36,13 +36,13 @@ class TestImageMediaItem(TestCase): # GIVEN: An empty image_list image_list = [] with patch(u'openlp.plugins.images.lib.mediaitem.ImageMediaItem.loadFullList') as mocked_loadFullList: - self.mediaitem.manager = MagicMock() + self.media_item.manager = MagicMock() # WHEN: We run save_new_images_list with the empty list - self.mediaitem.save_new_images_list(image_list) + self.media_item.save_new_images_list(image_list) # THEN: The save_object() method should not have been called - assert self.mediaitem.manager.save_object.call_count == 0, \ + assert self.media_item.manager.save_object.call_count == 0, \ u'The save_object() method should not have been called' def save_new_images_list_single_image_with_reload_test(self): @@ -53,10 +53,10 @@ class TestImageMediaItem(TestCase): image_list = [ u'test_image.jpg' ] with patch(u'openlp.plugins.images.lib.mediaitem.ImageMediaItem.loadFullList') as mocked_loadFullList: ImageFilenames.filename = '' - self.mediaitem.manager = MagicMock() + self.media_item.manager = MagicMock() # WHEN: We run save_new_images_list with reload_list=True - self.mediaitem.save_new_images_list(image_list, reload_list=True) + self.media_item.save_new_images_list(image_list, reload_list=True) # THEN: loadFullList() should have been called assert mocked_loadFullList.call_count == 1, u'loadFullList() should have been called' @@ -71,10 +71,10 @@ class TestImageMediaItem(TestCase): # GIVEN: A list with 1 image image_list = [ u'test_image.jpg' ] with patch(u'openlp.plugins.images.lib.mediaitem.ImageMediaItem.loadFullList') as mocked_loadFullList: - self.mediaitem.manager = MagicMock() + self.media_item.manager = MagicMock() # WHEN: We run save_new_images_list with reload_list=False - self.mediaitem.save_new_images_list(image_list, reload_list=False) + self.media_item.save_new_images_list(image_list, reload_list=False) # THEN: loadFullList() should not have been called assert mocked_loadFullList.call_count == 0, u'loadFullList() should not have been called' @@ -86,13 +86,13 @@ class TestImageMediaItem(TestCase): # GIVEN: A list with 3 images image_list = [ u'test_image_1.jpg', u'test_image_2.jpg', u'test_image_3.jpg' ] with patch(u'openlp.plugins.images.lib.mediaitem.ImageMediaItem.loadFullList') as mocked_loadFullList: - self.mediaitem.manager = MagicMock() + self.media_item.manager = MagicMock() # WHEN: We run save_new_images_list with the list of 3 images - self.mediaitem.save_new_images_list(image_list, reload_list=False) + self.media_item.save_new_images_list(image_list, reload_list=False) # THEN: loadFullList() should not have been called - assert self.mediaitem.manager.save_object.call_count == 3, \ + assert self.media_item.manager.save_object.call_count == 3, \ u'loadFullList() should have been called three times' def save_new_images_list_other_objects_in_list_test(self): @@ -102,11 +102,11 @@ class TestImageMediaItem(TestCase): # GIVEN: A list with images and objects image_list = [ u'test_image_1.jpg', None, True, ImageFilenames(), 'test_image_2.jpg' ] with patch(u'openlp.plugins.images.lib.mediaitem.ImageMediaItem.loadFullList') as mocked_loadFullList: - self.mediaitem.manager = MagicMock() + self.media_item.manager = MagicMock() # WHEN: We run save_new_images_list with the list of images and objects - self.mediaitem.save_new_images_list(image_list, reload_list=False) + self.media_item.save_new_images_list(image_list, reload_list=False) # THEN: loadFullList() should not have been called - assert self.mediaitem.manager.save_object.call_count == 2, \ + assert self.media_item.manager.save_object.call_count == 2, \ u'loadFullList() should have been called only once'