forked from openlp/openlp
Some more code cleanups to raise our code score on CI.
This commit is contained in:
parent
88272a3a6a
commit
5a008c3910
@ -26,5 +26,31 @@
|
|||||||
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
|
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
|
||||||
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
"""
|
||||||
|
Forms in OpenLP are made up of two classes. One class holds all the graphical
|
||||||
|
elements, like buttons and lists, and the other class holds all the functional
|
||||||
|
code, like slots and loading and saving.
|
||||||
|
|
||||||
|
The first class, commonly known as the **Dialog** class, is typically named
|
||||||
|
``Ui_<name>Dialog``. It is a slightly modified version of the class that the
|
||||||
|
``pyuic4`` command produces from Qt4's .ui file. Typical modifications will be
|
||||||
|
converting most strings from "" to u'' and using OpenLP's ``translate()``
|
||||||
|
function for translating strings.
|
||||||
|
|
||||||
|
The second class, commonly known as the **Form** class, is typically named
|
||||||
|
``<name>Form``. This class is the one which is instantiated and used. It uses
|
||||||
|
dual inheritance to inherit from (usually) QtGui.QDialog and the Ui class
|
||||||
|
mentioned above, like so::
|
||||||
|
|
||||||
|
class AuthorsForm(QtGui.QDialog, Ui_AuthorsDialog):
|
||||||
|
|
||||||
|
def __init__(self, parent=None):
|
||||||
|
QtGui.QDialog.__init__(self, parent)
|
||||||
|
self.setupUi(self)
|
||||||
|
|
||||||
|
This allows OpenLP to use ``self.object`` for all the GUI elements while keeping
|
||||||
|
them separate from the functionality, so that it is easier to recreate the GUI
|
||||||
|
from the .ui files later if necessary.
|
||||||
|
"""
|
||||||
|
|
||||||
from alertform import AlertForm
|
from alertform import AlertForm
|
||||||
|
@ -26,6 +26,10 @@
|
|||||||
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
|
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
|
||||||
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
"""
|
||||||
|
The :mod:`~openlp.plugins.custom.customplugin` module contains the Plugin class
|
||||||
|
for the Custom Slides plugin.
|
||||||
|
"""
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
@ -26,6 +26,10 @@
|
|||||||
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
|
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
|
||||||
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
"""
|
||||||
|
The :mod:`~openlp.plugins.custom.lib.customtab` module contains the settings tab
|
||||||
|
for the Custom Slides plugin, which is inserted into the configuration dialog.
|
||||||
|
"""
|
||||||
|
|
||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
|
|
||||||
@ -66,6 +70,9 @@ class CustomTab(SettingsTab):
|
|||||||
'Import missing custom slides from service files'))
|
'Import missing custom slides from service files'))
|
||||||
|
|
||||||
def onDisplayFooterCheckBoxChanged(self, check_state):
|
def onDisplayFooterCheckBoxChanged(self, check_state):
|
||||||
|
"""
|
||||||
|
Toggle the setting for displaying the footer.
|
||||||
|
"""
|
||||||
self.displayFooter = False
|
self.displayFooter = False
|
||||||
# we have a set value convert to True/False
|
# we have a set value convert to True/False
|
||||||
if check_state == QtCore.Qt.Checked:
|
if check_state == QtCore.Qt.Checked:
|
||||||
|
@ -50,6 +50,7 @@ from lxml import etree, objectify
|
|||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
#TODO: These classes need to be refactored into a single class.
|
||||||
class CustomXMLBuilder(object):
|
class CustomXMLBuilder(object):
|
||||||
"""
|
"""
|
||||||
This class builds the XML used to describe songs.
|
This class builds the XML used to describe songs.
|
||||||
@ -84,11 +85,11 @@ class CustomXMLBuilder(object):
|
|||||||
self.lyrics.setAttribute(u'language', u'en')
|
self.lyrics.setAttribute(u'language', u'en')
|
||||||
self.song.appendChild(self.lyrics)
|
self.song.appendChild(self.lyrics)
|
||||||
|
|
||||||
def add_verse_to_lyrics(self, type, number, content):
|
def add_verse_to_lyrics(self, verse_type, number, content):
|
||||||
"""
|
"""
|
||||||
Add a verse to the ``<lyrics>`` tag.
|
Add a verse to the ``<lyrics>`` tag.
|
||||||
|
|
||||||
``type``
|
``verse_type``
|
||||||
A string denoting the type of verse. Possible values are "Chorus",
|
A string denoting the type of verse. Possible values are "Chorus",
|
||||||
"Verse", "Bridge", and "Custom".
|
"Verse", "Bridge", and "Custom".
|
||||||
|
|
||||||
@ -99,7 +100,7 @@ class CustomXMLBuilder(object):
|
|||||||
The actual text of the verse to be stored.
|
The actual text of the verse to be stored.
|
||||||
"""
|
"""
|
||||||
verse = self.custom_xml.createElement(u'verse')
|
verse = self.custom_xml.createElement(u'verse')
|
||||||
verse.setAttribute(u'type', type)
|
verse.setAttribute(u'type', verse_type)
|
||||||
verse.setAttribute(u'label', number)
|
verse.setAttribute(u'label', number)
|
||||||
self.lyrics.appendChild(verse)
|
self.lyrics.appendChild(verse)
|
||||||
# add data as a CDATA section to protect the XML from special chars
|
# add data as a CDATA section to protect the XML from special chars
|
||||||
|
@ -77,7 +77,7 @@ class PresentationPlugin(Plugin):
|
|||||||
if self.controllers[controller].enabled():
|
if self.controllers[controller].enabled():
|
||||||
try:
|
try:
|
||||||
self.controllers[controller].start_process()
|
self.controllers[controller].start_process()
|
||||||
except:
|
except Exception:
|
||||||
log.warn(u'Failed to start controller process')
|
log.warn(u'Failed to start controller process')
|
||||||
self.controllers[controller].available = False
|
self.controllers[controller].available = False
|
||||||
self.mediaItem.buildFileMaskString()
|
self.mediaItem.buildFileMaskString()
|
||||||
|
@ -26,7 +26,6 @@
|
|||||||
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
|
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
|
||||||
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Forms in OpenLP are made up of two classes. One class holds all the graphical
|
Forms in OpenLP are made up of two classes. One class holds all the graphical
|
||||||
elements, like buttons and lists, and the other class holds all the functional
|
elements, like buttons and lists, and the other class holds all the functional
|
||||||
|
@ -26,6 +26,10 @@
|
|||||||
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
|
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
|
||||||
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
"""
|
||||||
|
The :mod:`~openlp.plugins.songs.forms.editsongform` module contains the form
|
||||||
|
used to edit songs.
|
||||||
|
"""
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import re
|
import re
|
||||||
@ -42,7 +46,7 @@ from openlp.plugins.songs.forms import EditVerseForm, MediaFilesForm
|
|||||||
from openlp.plugins.songs.lib import SongXML, VerseType, clean_song
|
from openlp.plugins.songs.lib import SongXML, VerseType, clean_song
|
||||||
from openlp.plugins.songs.lib.db import Book, Song, Author, Topic, MediaFile
|
from openlp.plugins.songs.lib.db import Book, Song, Author, Topic, MediaFile
|
||||||
from openlp.plugins.songs.lib.ui import SongStrings
|
from openlp.plugins.songs.lib.ui import SongStrings
|
||||||
from editsongdialog import Ui_EditSongDialog
|
from openlp.plugins.songs.forms.editsongdialog import Ui_EditSongDialog
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -56,7 +60,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
|||||||
"""
|
"""
|
||||||
Constructor
|
Constructor
|
||||||
"""
|
"""
|
||||||
QtGui.QDialog.__init__(self, parent)
|
super(EditSongForm, self).__init__(parent)
|
||||||
self.mediaitem = mediaitem
|
self.mediaitem = mediaitem
|
||||||
self.song = None
|
self.song = None
|
||||||
# can this be automated?
|
# can this be automated?
|
||||||
@ -113,12 +117,18 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
|||||||
self.whitespace = re.compile(r'\W+', re.UNICODE)
|
self.whitespace = re.compile(r'\W+', re.UNICODE)
|
||||||
|
|
||||||
def initialise(self):
|
def initialise(self):
|
||||||
|
"""
|
||||||
|
Set up the form for when it is displayed.
|
||||||
|
"""
|
||||||
self.verseEditButton.setEnabled(False)
|
self.verseEditButton.setEnabled(False)
|
||||||
self.verseDeleteButton.setEnabled(False)
|
self.verseDeleteButton.setEnabled(False)
|
||||||
self.authorRemoveButton.setEnabled(False)
|
self.authorRemoveButton.setEnabled(False)
|
||||||
self.topicRemoveButton.setEnabled(False)
|
self.topicRemoveButton.setEnabled(False)
|
||||||
|
|
||||||
def loadAuthors(self):
|
def loadAuthors(self):
|
||||||
|
"""
|
||||||
|
Load the authors from the database into the combobox.
|
||||||
|
"""
|
||||||
authors = self.manager.get_all_objects(Author,
|
authors = self.manager.get_all_objects(Author,
|
||||||
order_by_ref=Author.display_name)
|
order_by_ref=Author.display_name)
|
||||||
self.authorsComboBox.clear()
|
self.authorsComboBox.clear()
|
||||||
@ -132,14 +142,23 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
|||||||
set_case_insensitive_completer(self.authors, self.authorsComboBox)
|
set_case_insensitive_completer(self.authors, self.authorsComboBox)
|
||||||
|
|
||||||
def loadTopics(self):
|
def loadTopics(self):
|
||||||
|
"""
|
||||||
|
Load the topics into the combobox.
|
||||||
|
"""
|
||||||
self.topics = []
|
self.topics = []
|
||||||
self.__loadObjects(Topic, self.topicsComboBox, self.topics)
|
self.__loadObjects(Topic, self.topicsComboBox, self.topics)
|
||||||
|
|
||||||
def loadBooks(self):
|
def loadBooks(self):
|
||||||
|
"""
|
||||||
|
Load the song books into the combobox
|
||||||
|
"""
|
||||||
self.books = []
|
self.books = []
|
||||||
self.__loadObjects(Book, self.songBookComboBox, self.books)
|
self.__loadObjects(Book, self.songBookComboBox, self.books)
|
||||||
|
|
||||||
def __loadObjects(self, cls, combo, cache):
|
def __loadObjects(self, cls, combo, cache):
|
||||||
|
"""
|
||||||
|
Generically load a set of objects into a cache and a combobox.
|
||||||
|
"""
|
||||||
objects = self.manager.get_all_objects(cls, order_by_ref=cls.name)
|
objects = self.manager.get_all_objects(cls, order_by_ref=cls.name)
|
||||||
combo.clear()
|
combo.clear()
|
||||||
combo.addItem(u'')
|
combo.addItem(u'')
|
||||||
@ -151,6 +170,9 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
|||||||
set_case_insensitive_completer(cache, combo)
|
set_case_insensitive_completer(cache, combo)
|
||||||
|
|
||||||
def loadThemes(self, theme_list):
|
def loadThemes(self, theme_list):
|
||||||
|
"""
|
||||||
|
Load the themes into a combobox.
|
||||||
|
"""
|
||||||
self.themeComboBox.clear()
|
self.themeComboBox.clear()
|
||||||
self.themeComboBox.addItem(u'')
|
self.themeComboBox.addItem(u'')
|
||||||
self.themes = theme_list
|
self.themes = theme_list
|
||||||
@ -158,6 +180,9 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
|||||||
set_case_insensitive_completer(self.themes, self.themeComboBox)
|
set_case_insensitive_completer(self.themes, self.themeComboBox)
|
||||||
|
|
||||||
def loadMediaFiles(self):
|
def loadMediaFiles(self):
|
||||||
|
"""
|
||||||
|
Load the media files into a combobox.
|
||||||
|
"""
|
||||||
self.audioAddFromMediaButton.setVisible(False)
|
self.audioAddFromMediaButton.setVisible(False)
|
||||||
for plugin in self.parent().pluginManager.plugins:
|
for plugin in self.parent().pluginManager.plugins:
|
||||||
if plugin.name == u'media' and plugin.status == PluginStatus.Active:
|
if plugin.name == u'media' and plugin.status == PluginStatus.Active:
|
||||||
@ -166,6 +191,9 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
|||||||
break
|
break
|
||||||
|
|
||||||
def newSong(self):
|
def newSong(self):
|
||||||
|
"""
|
||||||
|
Blank the edit form out in preparation for a new song.
|
||||||
|
"""
|
||||||
log.debug(u'New Song')
|
log.debug(u'New Song')
|
||||||
self.song = None
|
self.song = None
|
||||||
self.initialise()
|
self.initialise()
|
||||||
@ -313,6 +341,9 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
|||||||
self.verseListWidget.repaint()
|
self.verseListWidget.repaint()
|
||||||
|
|
||||||
def onAuthorAddButtonClicked(self):
|
def onAuthorAddButtonClicked(self):
|
||||||
|
"""
|
||||||
|
Add the author to the list of authors associated with this song when the button is clicked.
|
||||||
|
"""
|
||||||
item = int(self.authorsComboBox.currentIndex())
|
item = int(self.authorsComboBox.currentIndex())
|
||||||
text = self.authorsComboBox.currentText().strip(u' \r\n\t')
|
text = self.authorsComboBox.currentText().strip(u' \r\n\t')
|
||||||
# This if statement is for OS X, which doesn't seem to work well with
|
# This if statement is for OS X, which doesn't seem to work well with
|
||||||
@ -361,10 +392,16 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
|||||||
self.authorsListView.addItem(author_item)
|
self.authorsListView.addItem(author_item)
|
||||||
|
|
||||||
def onAuthorsListViewClicked(self):
|
def onAuthorsListViewClicked(self):
|
||||||
|
"""
|
||||||
|
Run a set of actions when an author in the list is selected (mainly enable the delete button).
|
||||||
|
"""
|
||||||
if self.authorsListView.count() > 1:
|
if self.authorsListView.count() > 1:
|
||||||
self.authorRemoveButton.setEnabled(True)
|
self.authorRemoveButton.setEnabled(True)
|
||||||
|
|
||||||
def onAuthorRemoveButtonClicked(self):
|
def onAuthorRemoveButtonClicked(self):
|
||||||
|
"""
|
||||||
|
Remove the author from the list when the delete button is clicked.
|
||||||
|
"""
|
||||||
self.authorRemoveButton.setEnabled(False)
|
self.authorRemoveButton.setEnabled(False)
|
||||||
item = self.authorsListView.currentItem()
|
item = self.authorsListView.currentItem()
|
||||||
row = self.authorsListView.row(item)
|
row = self.authorsListView.row(item)
|
||||||
|
@ -26,6 +26,10 @@
|
|||||||
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
|
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
|
||||||
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
"""
|
||||||
|
The :mod:`~openlp.plugins.songs.songsplugin` module contains the Plugin class
|
||||||
|
for the Songs plugin.
|
||||||
|
"""
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
|
Loading…
Reference in New Issue
Block a user