diff --git a/openlp/core/lib/__init__.py b/openlp/core/lib/__init__.py index 0591d397c..5966e39f9 100644 --- a/openlp/core/lib/__init__.py +++ b/openlp/core/lib/__init__.py @@ -282,14 +282,15 @@ def resize_image(image_path, width, height, background=u'#000000'): if image_ratio == resize_ratio: # We neither need to centre the image nor add "bars" to the image. return preview - realw = preview.width() - realh = preview.height() + real_width = preview.width() + real_height = preview.height() # and move it to the centre of the preview space new_image = QtGui.QImage(width, height, QtGui.QImage.Format_ARGB32_Premultiplied) painter = QtGui.QPainter(new_image) painter.fillRect(new_image.rect(), QtGui.QColor(background)) - painter.drawImage((width - realw) / 2, (height - realh) / 2, preview) + painter.drawImage( + (width - real_width) / 2, (height - real_height) / 2, preview) return new_image diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index e6c5b0599..ce0797240 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -352,24 +352,23 @@ class MediaManagerItem(QtGui.QWidget): ``files`` The list of files to be loaded """ - #FIXME: change local variables to words_separated_by_underscores. - newFiles = [] - errorShown = False + new_files = [] + error_shown = False for file in files: type = file.split(u'.')[-1] if type.lower() not in self.onNewFileMasks: - if not errorShown: + if not error_shown: critical_error_message_box( translate('OpenLP.MediaManagerItem', 'Invalid File Type'), unicode(translate('OpenLP.MediaManagerItem', 'Invalid File %s.\nSuffix not supported')) % file) - errorShown = True + error_shown = True else: - newFiles.append(file) - if files: - self.validateAndLoad(newFiles) + new_files.append(file) + if new_files: + self.validateAndLoad(new_files) def validateAndLoad(self, files): """ @@ -379,30 +378,29 @@ class MediaManagerItem(QtGui.QWidget): ``files`` The files to be loaded. """ - #FIXME: change local variables to words_separated_by_underscores. names = [] - fullList = [] + full_list = [] for count in range(self.listView.count()): names.append(unicode(self.listView.item(count).text())) - fullList.append(unicode(self.listView.item(count). + full_list.append(unicode(self.listView.item(count). data(QtCore.Qt.UserRole).toString())) - duplicatesFound = False - filesAdded = False + duplicates_found = False + files_added = False for file in files: filename = os.path.split(unicode(file))[1] if filename in names: - duplicatesFound = True + duplicates_found = True else: - filesAdded = True - fullList.append(file) - if fullList and filesAdded: + files_added = True + full_list.append(file) + if full_list and files_added: self.listView.clear() - self.loadList(fullList) - lastDir = os.path.split(unicode(files[0]))[0] - SettingsManager.set_last_dir(self.settingsSection, lastDir) + self.loadList(full_list) + last_dir = os.path.split(unicode(files[0]))[0] + SettingsManager.set_last_dir(self.settingsSection, last_dir) SettingsManager.set_list(self.settingsSection, self.settingsSection, self.getFileList()) - if duplicatesFound: + if duplicates_found: critical_error_message_box( UiStrings().Duplicate, unicode(translate('OpenLP.MediaManagerItem', @@ -422,13 +420,13 @@ class MediaManagerItem(QtGui.QWidget): Return the current list of files """ count = 0 - filelist = [] + file_list = [] while count < self.listView.count(): bitem = self.listView.item(count) filename = unicode(bitem.data(QtCore.Qt.UserRole).toString()) - filelist.append(filename) + file_list.append(filename) count += 1 - return filelist + return file_list def loadList(self, list): raise NotImplementedError(u'MediaManagerItem.loadList needs to be ' @@ -477,9 +475,8 @@ class MediaManagerItem(QtGui.QWidget): Allows the change of current item in the list to be actioned """ if Settings().value(u'advanced/single click preview', - QtCore.QVariant(False)).toBool() and self.quickPreviewAllowed \ - and self.listView.selectedIndexes() \ - and self.autoSelectId == -1: + QtCore.QVariant(False)).toBool() and self.quickPreviewAllowed and \ + self.listView.selectedIndexes() and self.autoSelectId == -1: self.onPreviewClick(True) def onPreviewClick(self, keepFocus=False): diff --git a/openlp/core/lib/renderer.py b/openlp/core/lib/renderer.py index ae9803a7f..81d5361cb 100644 --- a/openlp/core/lib/renderer.py +++ b/openlp/core/lib/renderer.py @@ -82,6 +82,9 @@ class Renderer(object): self._calculate_default() QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'theme_update_global'), self.set_global_theme) + self.web = QtWebKit.QWebView() + self.web.setVisible(False) + self.web_frame = self.web.page().mainFrame() def update_display(self): """ @@ -403,10 +406,7 @@ class Renderer(object): if theme_data.font_main_shadow: self.page_width -= int(theme_data.font_main_shadow_size) self.page_height -= int(theme_data.font_main_shadow_size) - self.web = QtWebKit.QWebView() - self.web.setVisible(False) self.web.resize(self.page_width, self.page_height) - self.web_frame = self.web.page().mainFrame() # Adjust width and height to account for shadow. outline done in css. html = u"""