diff --git a/openlp/core/lib/ui.py b/openlp/core/lib/ui.py index fb60d9275..943c4a78e 100644 --- a/openlp/core/lib/ui.py +++ b/openlp/core/lib/ui.py @@ -465,9 +465,8 @@ def create_valign_selection_widgets(parent): label = QtGui.QLabel(parent) label.setText(translate('OpenLP.Ui', '&Vertical Align:')) combo_box = QtGui.QComboBox(parent) - combo_box.addItem(UiStrings().Top) - combo_box.addItem(UiStrings().Middle) - combo_box.addItem(UiStrings().Bottom) + combo_box.addItems( + [UiStrings().Top, UiStrings().Middle, UiStrings().Bottom]) label.setBuddy(combo_box) return label, combo_box @@ -482,8 +481,7 @@ def find_and_set_in_combo_box(combo_box, value_to_find): ``value_to_find`` The value to find """ - index = combo_box.findText(value_to_find, - QtCore.Qt.MatchExactly) + index = combo_box.findText(value_to_find, QtCore.Qt.MatchExactly) if index == -1: # Not Found. index = 0 diff --git a/openlp/core/ui/advancedtab.py b/openlp/core/ui/advancedtab.py index 581d1238c..e8d088f60 100644 --- a/openlp/core/ui/advancedtab.py +++ b/openlp/core/ui/advancedtab.py @@ -103,28 +103,22 @@ class AdvancedTab(SettingsTab): u'expandServiceItemCheckBox') self.uiLayout.addRow(self.expandServiceItemCheckBox) self.enableAutoCloseCheckBox = QtGui.QCheckBox(self.uiGroupBox) - self.enableAutoCloseCheckBox.setObjectName( - u'enableAutoCloseCheckBox') + self.enableAutoCloseCheckBox.setObjectName(u'enableAutoCloseCheckBox') self.uiLayout.addRow(self.enableAutoCloseCheckBox) self.leftLayout.addWidget(self.uiGroupBox) # Default service name self.serviceNameGroupBox = QtGui.QGroupBox(self.leftColumn) self.serviceNameGroupBox.setObjectName(u'serviceNameGroupBox') - self.serviceNameLayout = QtGui.QFormLayout( - self.serviceNameGroupBox) - self.serviceNameCheckBox = QtGui.QCheckBox( - self.serviceNameGroupBox) + self.serviceNameLayout = QtGui.QFormLayout(self.serviceNameGroupBox) + self.serviceNameCheckBox = QtGui.QCheckBox(self.serviceNameGroupBox) self.serviceNameCheckBox.setObjectName(u'serviceNameCheckBox') self.serviceNameLayout.setObjectName(u'serviceNameLayout') self.serviceNameLayout.addRow(self.serviceNameCheckBox) self.serviceNameTimeLabel = QtGui.QLabel(self.serviceNameGroupBox) self.serviceNameTimeLabel.setObjectName(u'serviceNameTimeLabel') - self.serviceNameDay = QtGui.QComboBox( - self.serviceNameGroupBox) - self.serviceNameDay.addItems( - [u'', u'', u'', u'', u'', u'', u'', u'']) - self.serviceNameDay.setObjectName( - u'serviceNameDay') + self.serviceNameDay = QtGui.QComboBox(self.serviceNameGroupBox) + self.serviceNameDay.addItems([u'', u'', u'', u'', u'', u'', u'', u'']) + self.serviceNameDay.setObjectName(u'serviceNameDay') self.serviceNameTime = QtGui.QTimeEdit(self.serviceNameGroupBox) self.serviceNameTime.setObjectName(u'serviceNameTime') self.serviceNameTimeHBox = QtGui.QHBoxLayout() @@ -151,8 +145,7 @@ class AdvancedTab(SettingsTab): self.serviceNameHBox.addWidget(self.serviceNameRevertButton) self.serviceNameLayout.addRow(self.serviceNameLabel, self.serviceNameHBox) - self.serviceNameExampleLabel = QtGui.QLabel( - self.serviceNameGroupBox) + self.serviceNameExampleLabel = QtGui.QLabel(self.serviceNameGroupBox) self.serviceNameExampleLabel.setObjectName( u'serviceNameExampleLabel') self.serviceNameExample = QtGui.QLabel(self.serviceNameGroupBox) @@ -202,8 +195,7 @@ class AdvancedTab(SettingsTab): self.newDataDirectoryLabelHBox.setObjectName( u'newDataDirectoryLabelHBox') self.newDataDirectoryLabelHBox.addWidget(self.newDataDirectoryEdit) - self.newDataDirectoryLabelHBox.addWidget( - self.dataDirectoryBrowseButton) + self.newDataDirectoryLabelHBox.addWidget(self.dataDirectoryBrowseButton) self.newDataDirectoryLabelHBox.addWidget( self.dataDirectoryDefaultButton) self.dataDirectoryCopyCheckHBox = QtGui.QHBoxLayout() @@ -340,8 +332,7 @@ class AdvancedTab(SettingsTab): Setup the interface translation strings. """ self.tabTitleVisible = UiStrings().Advanced - self.uiGroupBox.setTitle( - translate('OpenLP.AdvancedTab', 'UI Settings')) + self.uiGroupBox.setTitle(translate('OpenLP.AdvancedTab', 'UI Settings')) self.dataDirectoryGroupBox.setTitle( translate('OpenLP.AdvancedTab', 'Data Location')) self.recentLabel.setText( @@ -504,8 +495,7 @@ class AdvancedTab(SettingsTab): self.defaultColor = settings.value(u'default color', QtCore.QVariant(u'#ffffff')).toString() self.defaultFileEdit.setText(settings.value(u'default image', - QtCore.QVariant(u':/graphics/openlp-splash-screen.png'))\ - .toString()) + QtCore.QVariant(u':/graphics/openlp-splash-screen.png')).toString()) self.slide_limits = settings.value( u'slide limits', QtCore.QVariant(SlideLimits.End)).toInt()[0] if self.slide_limits == SlideLimits.End: @@ -547,8 +537,7 @@ class AdvancedTab(SettingsTab): self.currentDataPath = AppLocation.get_data_path() log.warning(u'User requested data path set to default %s' % self.currentDataPath) - self.dataDirectoryLabel.setText(os.path.abspath( - self.currentDataPath)) + self.dataDirectoryLabel.setText(os.path.abspath(self.currentDataPath)) self.defaultColorButton.setStyleSheet( u'background-color: %s' % self.defaultColor) # Don't allow data directory move if running portable. @@ -662,8 +651,7 @@ class AdvancedTab(SettingsTab): file_filters = u'%s;;%s (*.*) (*)' % (get_images_filter(), UiStrings().AllFiles) filename = QtGui.QFileDialog.getOpenFileName(self, - translate('OpenLP.AdvancedTab', 'Open File'), '', - file_filters) + translate('OpenLP.AdvancedTab', 'Open File'), '', file_filters) if filename: self.defaultFileEdit.setText(filename) self.defaultFileEdit.setFocus() @@ -713,7 +701,8 @@ class AdvancedTab(SettingsTab): """ new_data_path = AppLocation.get_directory(AppLocation.DataDir) if self.currentDataPath.lower() != new_data_path.lower(): - # Make sure they want to change the data location back to the default. + # Make sure they want to change the data location back to the + # default. answer = QtGui.QMessageBox.question(self, translate('OpenLP.AdvancedTab', 'Reset Data Directory'), translate('OpenLP.AdvancedTab', diff --git a/openlp/core/ui/firsttimeform.py b/openlp/core/ui/firsttimeform.py index d20cc9ee0..94d2ae467 100644 --- a/openlp/core/ui/firsttimeform.py +++ b/openlp/core/ui/firsttimeform.py @@ -105,7 +105,7 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'config_screen_changed'), self.updateScreenListCombo) - def exec_(self, edit=False): + def exec_(self): """ Run the wizard. """ @@ -271,8 +271,7 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): self._performWizard() Receiver.send_message(u'cursor_normal') Receiver.send_message(u'openlp_process_events') - Settings().setValue(u'general/has run wizard', - QtCore.QVariant(True)) + Settings().setValue(u'general/has run wizard', QtCore.QVariant(True)) self.close() def urlGetFile(self, url, fpath): @@ -283,7 +282,6 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): block_count = 0 block_size = 4096 urlfile = urllib2.urlopen(url) - filesize = urlfile.headers["Content-Length"] filename = open(fpath, "wb") # Download until finished or canceled. while not self.downloadCancelled: @@ -292,7 +290,7 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): break filename.write(data) block_count += 1 - self._downloadProgress(block_count, block_size, filesize) + self._downloadProgress(block_count, block_size) filename.close() # Delete file if cancelled, it may be a partial file. if self.downloadCancelled: @@ -320,7 +318,7 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): meta = site.info() return int(meta.getheaders("Content-Length")[0]) - def _downloadProgress(self, count, block_size, total_size): + def _downloadProgress(self, count, block_size): increment = (count * block_size) - self.previous_size self._incrementProgressBar(None, increment) self.previous_size = count * block_size @@ -484,7 +482,7 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): Settings().setValue(u'General/monitor', QtCore.QVariant(self.displayComboBox.currentIndex())) self.screens.set_current_display( - self.displayComboBox.currentIndex()) + self.displayComboBox.currentIndex()) # Set Global Theme if self.themeComboBox.currentIndex() != -1: Settings().setValue(u'themes/global theme', diff --git a/openlp/core/ui/shortcutlistform.py b/openlp/core/ui/shortcutlistform.py index 6b0457f10..86c83b5a5 100644 --- a/openlp/core/ui/shortcutlistform.py +++ b/openlp/core/ui/shortcutlistform.py @@ -223,10 +223,10 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): self.alternatePushButton.setChecked(column not in [0, 1]) if column in [0, 1]: self.primaryPushButton.setText(u'') - self.primaryPushButton.setFocus(QtCore.Qt.OtherFocusReason) + self.primaryPushButton.setFocus() else: self.alternatePushButton.setText(u'') - self.alternatePushButton.setFocus(QtCore.Qt.OtherFocusReason) + self.alternatePushButton.setFocus() def onCurrentItemChanged(self, item=None, previousItem=None): """ diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index f6ea4351b..b7e9aea34 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -44,14 +44,6 @@ from openlp.core.utils.actions import ActionList, CategoryOrder log = logging.getLogger(__name__) -class SlideList(QtGui.QTableWidget): - """ - Customised version of QTableWidget which can respond to keyboard - events. - """ - def __init__(self, parent=None): - QtGui.QTableWidget.__init__(self, parent.controller) - class Controller(QtGui.QWidget): """ @@ -150,7 +142,7 @@ class SlideController(Controller): self.controllerLayout.setSpacing(0) self.controllerLayout.setMargin(0) # Controller list view - self.previewListWidget = SlideList(self) + self.previewListWidget = QtGui.QTableWidget(self.controller) self.previewListWidget.setColumnCount(1) self.previewListWidget.horizontalHeader().setVisible(False) self.previewListWidget.setColumnWidth(0, self.controller.width()) @@ -287,7 +279,7 @@ class SlideController(Controller): text=translate('OpenLP.SlideController', 'Pause Audio'), tooltip=translate('OpenLP.SlideController', 'Pause audio.'), checked=False, visible=False, category=self.category, - context=QtCore.Qt.WindowShortcut, + context=QtCore.Qt.WindowShortcut, shortcuts=[], triggers=self.onAudioPauseClicked) self.audioMenu = QtGui.QMenu( translate('OpenLP.SlideController', 'Background Audio'), self.toolbar) diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index f35236fba..46e1f2a1e 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -458,7 +458,7 @@ class ThemeManager(QtGui.QWidget): QtCore.QVariant(theme.theme_name)) self.configUpdated() files = SettingsManager.get_files(self.settingsSection, u'.png') - # Sort the themes by its name considering language specific characters. + # 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 diff --git a/openlp/plugins/bibles/lib/biblestab.py b/openlp/plugins/bibles/lib/biblestab.py index a645ba00c..25a3bbb83 100644 --- a/openlp/plugins/bibles/lib/biblestab.py +++ b/openlp/plugins/bibles/lib/biblestab.py @@ -538,8 +538,7 @@ class BiblesTab(SettingsTab): """ self.bibleThemeComboBox.clear() self.bibleThemeComboBox.addItem(u'') - for theme in theme_list: - self.bibleThemeComboBox.addItem(theme) + self.bibleThemeComboBox.addItems(theme_list) find_and_set_in_combo_box(self.bibleThemeComboBox, self.bible_theme) def getGreyTextPalette(self, greyed): diff --git a/openlp/plugins/custom/forms/editcustomform.py b/openlp/plugins/custom/forms/editcustomform.py index 730b2c344..e8a587494 100644 --- a/openlp/plugins/custom/forms/editcustomform.py +++ b/openlp/plugins/custom/forms/editcustomform.py @@ -76,8 +76,7 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog): def loadThemes(self, themelist): self.themeComboBox.clear() self.themeComboBox.addItem(u'') - for themename in themelist: - self.themeComboBox.addItem(themename) + self.themeComboBox.addItems(themelist) def loadCustom(self, id, preview=False): """ @@ -106,7 +105,7 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog): self.slideListView.addItem(slide[1]) theme = self.customSlide.theme_name find_and_set_in_combo_box(self.themeComboBox, theme) - self.titleEdit.setFocus(QtCore.Qt.OtherFocusReason) + self.titleEdit.setFocus() # If not preview hide the preview button. self.previewButton.setVisible(preview) @@ -128,11 +127,9 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog): sxml = CustomXMLBuilder() sxml.new_document() sxml.add_lyrics_to_song() - count = 1 - for i in range(self.slideListView.count()): - sxml.add_verse_to_lyrics(u'custom', unicode(count), - unicode(self.slideListView.item(i).text())) - count += 1 + for count in range(self.slideListView.count()): + sxml.add_verse_to_lyrics(u'custom', unicode(count + 1), + unicode(self.slideListView.item(count).text())) self.customSlide.title = unicode(self.titleEdit.text()) self.customSlide.text = unicode(sxml.extract_xml(), u'utf-8') self.customSlide.credits = unicode(self.creditEdit.text()) @@ -159,8 +156,7 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog): def onAddButtonClicked(self): self.editSlideForm.setText(u'') if self.editSlideForm.exec_(): - for slide in self.editSlideForm.getText(): - self.slideListView.addItem(slide) + self.slideListView.addItems(self.editSlideForm.getText()) def onEditButtonClicked(self): self.editSlideForm.setText(self.slideListView.currentItem().text()) @@ -171,13 +167,13 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog): """ Edits all slides. """ - slide_list = u'' + slide_text = u'' for row in range(self.slideListView.count()): item = self.slideListView.item(row) - slide_list += item.text() + slide_text += item.text() if row != self.slideListView.count() - 1: - slide_list += u'\n[===]\n' - self.editSlideForm.setText(slide_list) + slide_text += u'\n[===]\n' + self.editSlideForm.setText(slide_text) if self.editSlideForm.exec_(): self.updateSlideList(self.editSlideForm.getText(), True) @@ -201,21 +197,19 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog): """ if edit_all: self.slideListView.clear() - for slide in slides: - self.slideListView.addItem(slide) + self.slideListView.addItems(slides) else: old_slides = [] old_row = self.slideListView.currentRow() # Create a list with all (old/unedited) slides. - old_slides = [self.slideListView.item(row).text() for row in \ + old_slides = [self.slideListView.item(row).text() for row in range(self.slideListView.count())] self.slideListView.clear() old_slides.pop(old_row) # Insert all slides to make the old_slides list complete. for slide in slides: old_slides.insert(old_row, slide) - for slide in old_slides: - self.slideListView.addItem(slide) + self.slideListView.addItems(old_slides) self.slideListView.repaint() def onDeleteButtonClicked(self): @@ -242,14 +236,8 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog): self.deleteButton.setEnabled(True) self.editButton.setEnabled(True) # Decide if the up/down buttons should be enabled or not. - if self.slideListView.count() - 1 == row: - self.downButton.setEnabled(False) - else: - self.downButton.setEnabled(True) - if row == 0: - self.upButton.setEnabled(False) - else: - self.upButton.setEnabled(True) + self.downButton.setEnabled(self.slideListView.count() - 1 != row) + self.upButton.setEnabled(row != 0) def _validate(self): """ diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index 3f92feed2..634346b62 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -203,7 +203,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): self.authorsListView.clear() self.topicsListView.clear() self.audioListWidget.clear() - self.titleEdit.setFocus(QtCore.Qt.OtherFocusReason) + self.titleEdit.setFocus() self.songBookNumberEdit.clear() self.loadAuthors() self.loadTopics() @@ -326,7 +326,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): media_file.setData(QtCore.Qt.UserRole, QtCore.QVariant(media.file_name)) self.audioListWidget.addItem(media_file) - self.titleEdit.setFocus(QtCore.Qt.OtherFocusReason) + self.titleEdit.setFocus() # Hide or show the preview button. self.previewButton.setVisible(preview) diff --git a/openlp/plugins/songs/forms/editverseform.py b/openlp/plugins/songs/forms/editverseform.py index f4fa8ff7f..0755ff47a 100644 --- a/openlp/plugins/songs/forms/editverseform.py +++ b/openlp/plugins/songs/forms/editverseform.py @@ -172,7 +172,7 @@ class EditVerseForm(QtGui.QDialog, Ui_EditVerseDialog): self.verseNumberBox.setValue(1) self.insertButton.setVisible(True) self.verseTextEdit.setPlainText(text) - self.verseTextEdit.setFocus(QtCore.Qt.OtherFocusReason) + self.verseTextEdit.setFocus() self.verseTextEdit.moveCursor(QtGui.QTextCursor.End) def getVerse(self):