Linting cleanups.

This commit is contained in:
Raoul Snyman 2013-02-01 21:58:18 +02:00
parent b0b89fdc05
commit 18034a2f6a
33 changed files with 291 additions and 81 deletions

View File

@ -34,4 +34,3 @@ import core
import plugins import plugins
__all__ = [u'core', u'plugins'] __all__ = [u'core', u'plugins']

View File

@ -172,6 +172,19 @@ class OpenLP(QtGui.QApplication):
return False return False
def hookException(self, exctype, value, traceback): def hookException(self, exctype, value, traceback):
"""
Add an exception hook so that any uncaught exceptions are displayed in this window rather than somewhere where
users cannot see it and cannot report when we encounter these problems.
``exctype``
The class of exception.
``value``
The actual exception object.
``traceback``
A traceback object with the details of where the exception occurred.
"""
if not hasattr(self, u'mainWindow'): if not hasattr(self, u'mainWindow'):
log.exception(''.join(format_exception(exctype, value, traceback))) log.exception(''.join(format_exception(exctype, value, traceback)))
return return
@ -283,7 +296,7 @@ def main(args=None):
else: else:
app.setApplicationName(u'OpenLP') app.setApplicationName(u'OpenLP')
set_up_logging(AppLocation.get_directory(AppLocation.CacheDir)) set_up_logging(AppLocation.get_directory(AppLocation.CacheDir))
registry = Registry.create() Registry.create()
app.setApplicationVersion(get_application_version()[u'version']) app.setApplicationVersion(get_application_version()[u'version'])
# Instance check # Instance check
if not options.testing: if not options.testing:

View File

@ -45,6 +45,7 @@ from openlp.core.utils import AppLocation, delete_file
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
def init_db(url, auto_flush=True, auto_commit=False): def init_db(url, auto_flush=True, auto_commit=False):
""" """
Initialise and return the session and metadata for a database Initialise and return the session and metadata for a database
@ -109,7 +110,7 @@ def upgrade_db(url, upgrade):
while hasattr(upgrade, u'upgrade_%d' % version): while hasattr(upgrade, u'upgrade_%d' % version):
log.debug(u'Running upgrade_%d', version) log.debug(u'Running upgrade_%d', version)
try: try:
getattr(upgrade, u'upgrade_%d' % version) (session, metadata, tables) getattr(upgrade, u'upgrade_%d' % version)(session, metadata, tables)
except (SQLAlchemyError, DBAPIError): except (SQLAlchemyError, DBAPIError):
log.exception(u'Could not run database upgrade script ' log.exception(u'Could not run database upgrade script '
'"upgrade_%s", upgrade process has been halted.', version) '"upgrade_%s", upgrade process has been halted.', version)
@ -156,6 +157,7 @@ class BaseModel(object):
instance.__setattr__(key, value) instance.__setattr__(key, value)
return instance return instance
class Manager(object): class Manager(object):
""" """
Provide generic object persistence management Provide generic object persistence management
@ -205,12 +207,9 @@ class Manager(object):
if db_ver > up_ver: if db_ver > up_ver:
critical_error_message_box( critical_error_message_box(
translate('OpenLP.Manager', 'Database Error'), translate('OpenLP.Manager', 'Database Error'),
translate('OpenLP.Manager', 'The database being ' translate('OpenLP.Manager', 'The database being loaded was created in a more recent version of '
'loaded was created in a more recent version of ' 'OpenLP. The database is version %d, while OpenLP expects version %d. The database will not '
'OpenLP. The database is version %d, while OpenLP ' 'be loaded.\n\nDatabase: %s') % (db_ver, up_ver, self.db_url)
'expects version %d. The database will not be loaded.'
'\n\nDatabase: %s') % \
(db_ver, up_ver, self.db_url)
) )
return return
try: try:

View File

@ -39,6 +39,7 @@ from openlp.core.lib import build_icon, ScreenList
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
class OpenLPDockWidget(QtGui.QDockWidget): class OpenLPDockWidget(QtGui.QDockWidget):
""" """
Custom DockWidget class to handle events Custom DockWidget class to handle events

View File

@ -35,6 +35,7 @@ from PyQt4 import QtCore
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
class EventReceiver(QtCore.QObject): class EventReceiver(QtCore.QObject):
""" """
Class to allow events to be passed from different parts of the system. This Class to allow events to be passed from different parts of the system. This

View File

@ -33,6 +33,7 @@ import cPickle
from openlp.core.lib import translate, Settings from openlp.core.lib import translate, Settings
class FormattingTags(object): class FormattingTags(object):
""" """
Static Class to HTML Tags to be access around the code the list is managed Static Class to HTML Tags to be access around the code the list is managed

View File

@ -207,6 +207,7 @@ sup {
</html> </html>
""" """
def build_html(item, screen, islive, background, image=None, def build_html(item, screen, islive, background, image=None,
plugins=None): plugins=None):
""" """
@ -264,6 +265,7 @@ def build_html(item, screen, islive, background, image=None,
build_lyrics_html(item, webkitvers)) build_lyrics_html(item, webkitvers))
return html return html
def webkit_version(): def webkit_version():
""" """
Return the Webkit version in use. Return the Webkit version in use.
@ -276,6 +278,7 @@ def webkit_version():
webkitvers = 0 webkitvers = 0
return webkitvers return webkitvers
def build_background_css(item, width, height): def build_background_css(item, width, height):
""" """
Build the background css Build the background css
@ -310,6 +313,7 @@ def build_background_css(item, width, height):
% (width, width, width, theme.background_start_color, theme.background_end_color) % (width, width, width, theme.background_start_color, theme.background_end_color)
return background return background
def build_lyrics_css(item, webkitvers): def build_lyrics_css(item, webkitvers):
""" """
Build the lyrics display css Build the lyrics display css
@ -384,6 +388,7 @@ def build_lyrics_css(item, webkitvers):
lyrics_css = style % (lyricstable, lyrics, lyricsmain, outline, shadow) lyrics_css = style % (lyricstable, lyrics, lyricsmain, outline, shadow)
return lyrics_css return lyrics_css
def build_lyrics_outline_css(theme, is_shadow=False): def build_lyrics_outline_css(theme, is_shadow=False):
""" """
Build the css which controls the theme outline Build the css which controls the theme outline
@ -407,6 +412,7 @@ def build_lyrics_outline_css(theme, is_shadow=False):
else: else:
return u'' return u''
def build_lyrics_format_css(theme, width, height): def build_lyrics_format_css(theme, width, height):
""" """
Build the css which controls the theme format Build the css which controls the theme format
@ -451,6 +457,7 @@ def build_lyrics_format_css(theme, width, height):
lyrics += u' font-weight:bold; ' lyrics += u' font-weight:bold; '
return lyrics return lyrics
def build_lyrics_html(item, webkitvers): def build_lyrics_html(item, webkitvers):
""" """
Build the HTML required to show the lyrics Build the HTML required to show the lyrics
@ -480,6 +487,7 @@ def build_lyrics_html(item, webkitvers):
u'class="lyricscell lyricsmain"></div></div>' u'class="lyricscell lyricsmain"></div></div>'
return lyrics return lyrics
def build_footer_css(item, height): def build_footer_css(item, height):
""" """
Build the display of the item footer Build the display of the item footer

View File

@ -43,12 +43,19 @@ from openlp.core.lib import resize_image, image_to_byte, Receiver, Registry, Scr
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
class ImageThread(QtCore.QThread): class ImageThread(QtCore.QThread):
""" """
A special Qt thread class to speed up the display of images. This is A special Qt thread class to speed up the display of images. This is
threaded so it loads the frames and generates byte stream in background. threaded so it loads the frames and generates byte stream in background.
""" """
def __init__(self, manager): def __init__(self, manager):
"""
Constructor for the thread class.
``manager``
The image manager.
"""
QtCore.QThread.__init__(self, None) QtCore.QThread.__init__(self, None)
self.imageManager = manager self.imageManager = manager
@ -181,6 +188,9 @@ class ImageManager(QtCore.QObject):
log.info(u'Image Manager loaded') log.info(u'Image Manager loaded')
def __init__(self): def __init__(self):
"""
Consutructor for the image manager.
"""
QtCore.QObject.__init__(self) QtCore.QObject.__init__(self)
Registry().register(u'image_manager', self) Registry().register(u'image_manager', self)
currentScreen = ScreenList().current currentScreen = ScreenList().current

View File

@ -35,6 +35,7 @@ from PyQt4 import QtCore, QtGui
from openlp.core.lib import Receiver from openlp.core.lib import Receiver
class ListWidgetWithDnD(QtGui.QListWidget): class ListWidgetWithDnD(QtGui.QListWidget):
""" """
Provide a list widget to store objects and handle drag and drop events Provide a list widget to store objects and handle drag and drop events
@ -58,9 +59,8 @@ class ListWidgetWithDnD(QtGui.QListWidget):
def mouseMoveEvent(self, event): def mouseMoveEvent(self, event):
""" """
Drag and drop event does not care what data is selected Drag and drop event does not care what data is selected as the recipient will use events to request the data
as the recipient will use events to request the data move move just tell it what plugin to call
just tell it what plugin to call
""" """
if event.buttons() != QtCore.Qt.LeftButton: if event.buttons() != QtCore.Qt.LeftButton:
event.ignore() event.ignore()
@ -75,12 +75,18 @@ class ListWidgetWithDnD(QtGui.QListWidget):
drag.start(QtCore.Qt.CopyAction) drag.start(QtCore.Qt.CopyAction)
def dragEnterEvent(self, event): def dragEnterEvent(self, event):
"""
When something is dragged into this object, check if you should be able to drop it in here.
"""
if event.mimeData().hasUrls(): if event.mimeData().hasUrls():
event.accept() event.accept()
else: else:
event.ignore() event.ignore()
def dragMoveEvent(self, event): def dragMoveEvent(self, event):
"""
Make an object droppable, and set it to copy the contents of the object, not move it.
"""
if event.mimeData().hasUrls(): if event.mimeData().hasUrls():
event.setDropAction(QtCore.Qt.CopyAction) event.setDropAction(QtCore.Qt.CopyAction)
event.accept() event.accept()

View File

@ -35,14 +35,14 @@ import re
from PyQt4 import QtCore, QtGui from PyQt4 import QtCore, QtGui
from openlp.core.lib import OpenLPToolbar, ServiceItem, StringContent, build_icon, translate, Receiver, \ from openlp.core.lib import OpenLPToolbar, ServiceItem, StringContent, Receiver, ListWidgetWithDnD, \
ListWidgetWithDnD, ServiceItemContext, Settings, Registry, UiStrings ServiceItemContext, Settings, Registry, UiStrings, build_icon, translate
from openlp.core.lib.searchedit import SearchEdit from openlp.core.lib.searchedit import SearchEdit
from openlp.core.lib.ui import create_widget_action, critical_error_message_box from openlp.core.lib.ui import create_widget_action, critical_error_message_box
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
class MediaManagerItem(QtGui.QWidget): class MediaManagerItem(QtGui.QWidget):
""" """
MediaManagerItem is a helper widget for plugins. MediaManagerItem is a helper widget for plugins.
@ -345,15 +345,15 @@ class MediaManagerItem(QtGui.QWidget):
""" """
new_files = [] new_files = []
error_shown = False error_shown = False
for file in files: for file_name in files:
type = file.split(u'.')[-1] file_type = file_name.split(u'.')[-1]
if type.lower() not in self.onNewFileMasks: if file_type.lower() not in self.onNewFileMasks:
if not error_shown: if not error_shown:
critical_error_message_box(translate('OpenLP.MediaManagerItem', 'Invalid File Type'), critical_error_message_box(translate('OpenLP.MediaManagerItem', 'Invalid File Type'),
translate('OpenLP.MediaManagerItem', 'Invalid File %s.\nSuffix not supported') % file) translate('OpenLP.MediaManagerItem', 'Invalid File %s.\nSuffix not supported') % file_name)
error_shown = True error_shown = True
else: else:
new_files.append(file) new_files.append(file_name)
if new_files: if new_files:
self.validateAndLoad(new_files) self.validateAndLoad(new_files)
@ -390,6 +390,9 @@ class MediaManagerItem(QtGui.QWidget):
translate('OpenLP.MediaManagerItem', 'Duplicate files were found on import and were ignored.')) translate('OpenLP.MediaManagerItem', 'Duplicate files were found on import and were ignored.'))
def contextMenu(self, point): def contextMenu(self, point):
"""
Display a context menu
"""
item = self.listView.itemAt(point) item = self.listView.itemAt(point)
# Decide if we have to show the context menu or not. # Decide if we have to show the context menu or not.
if item is None: if item is None:
@ -412,6 +415,9 @@ class MediaManagerItem(QtGui.QWidget):
return file_list return file_list
def loadList(self, list): def loadList(self, list):
"""
Load a list. Needs to be implemented by the plugin.
"""
raise NotImplementedError(u'MediaManagerItem.loadList needs to be defined by the plugin') raise NotImplementedError(u'MediaManagerItem.loadList needs to be defined by the plugin')
def onNewClick(self): def onNewClick(self):
@ -427,6 +433,9 @@ class MediaManagerItem(QtGui.QWidget):
pass pass
def onDeleteClick(self): def onDeleteClick(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.onDeleteClick needs to be defined by the plugin')
def onFocus(self): def onFocus(self):
@ -438,6 +447,9 @@ class MediaManagerItem(QtGui.QWidget):
def generateSlideData(self, serviceItem, item=None, xmlVersion=False, remote=False, def generateSlideData(self, serviceItem, item=None, xmlVersion=False, remote=False,
context=ServiceItemContext.Live): 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.generateSlideData needs to be defined by the plugin')
def onDoubleClicked(self): def onDoubleClicked(self):
@ -486,6 +498,9 @@ class MediaManagerItem(QtGui.QWidget):
self.goLive() self.goLive()
def goLive(self, item_id=None, remote=False): def goLive(self, item_id=None, remote=False):
"""
Make the currently selected item go live.
"""
log.debug(u'%s Live requested', self.plugin.name) log.debug(u'%s Live requested', self.plugin.name)
item = None item = None
if item_id: if item_id:
@ -499,6 +514,9 @@ class MediaManagerItem(QtGui.QWidget):
self.live_controller.add_service_item(serviceItem) self.live_controller.add_service_item(serviceItem)
def createItemFromId(self, item_id): def createItemFromId(self, item_id):
"""
Create a media item from an item id.
"""
item = QtGui.QListWidgetItem() item = QtGui.QListWidgetItem()
item.setData(QtCore.Qt.UserRole, item_id) item.setData(QtCore.Qt.UserRole, item_id)
return item return item
@ -522,6 +540,9 @@ class MediaManagerItem(QtGui.QWidget):
self.addToService(item) self.addToService(item)
def addToService(self, item=None, replace=None, remote=False): def addToService(self, item=None, replace=None, remote=False):
"""
Add this item to the current service.
"""
serviceItem = self.buildServiceItem(item, True, remote=remote, context=ServiceItemContext.Service) serviceItem = self.buildServiceItem(item, True, remote=remote, context=ServiceItemContext.Service)
if serviceItem: if serviceItem:
serviceItem.from_plugin = False serviceItem.from_plugin = False
@ -687,4 +708,3 @@ class MediaManagerItem(QtGui.QWidget):
return self._service_manager return self._service_manager
service_manager = property(_get_service_manager) service_manager = property(_get_service_manager)

View File

@ -38,6 +38,7 @@ from openlp.core.utils import get_application_version
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
class PluginStatus(object): class PluginStatus(object):
""" """
Defines the status of the plugin Defines the status of the plugin
@ -320,7 +321,6 @@ class Plugin(QtCore.QObject):
Settings().setValue(u'%s/%s files' % (self.settingsSection, self.name), loaded_list) Settings().setValue(u'%s/%s files' % (self.settingsSection, self.name), loaded_list)
settings.endGroup() settings.endGroup()
def usesTheme(self, theme): def usesTheme(self, theme):
""" """
Called to find out if a plugin is currently using a theme. Called to find out if a plugin is currently using a theme.
@ -418,4 +418,3 @@ class Plugin(QtCore.QObject):
return self._main_window return self._main_window
main_window = property(_get_main_window) main_window = property(_get_main_window)

View File

@ -37,6 +37,7 @@ from openlp.core.lib import Plugin, PluginStatus, Registry
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
class PluginManager(object): class PluginManager(object):
""" """
This is the Plugin manager, which loads all the plugins, This is the Plugin manager, which loads all the plugins,

View File

@ -34,6 +34,7 @@ import sys
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
class Registry(object): class Registry(object):
""" """
This is the Component Registry. It is a singleton object and is used to provide a This is the Component Registry. It is a singleton object and is used to provide a
@ -43,6 +44,9 @@ class Registry(object):
__instance__ = None __instance__ = None
def __new__(cls): def __new__(cls):
"""
Re-implement the __new__ method to make sure we create a true singleton.
"""
if not cls.__instance__: if not cls.__instance__:
cls.__instance__ = object.__new__(cls) cls.__instance__ = object.__new__(cls)
return cls.__instance__ return cls.__instance__
@ -61,7 +65,6 @@ class Registry(object):
registry.running_under_test = True registry.running_under_test = True
return registry return registry
def get(self, key): def get(self, key):
""" """
Extracts the registry value from the list based on the key passed in Extracts the registry value from the list based on the key passed in
@ -87,10 +90,9 @@ class Registry(object):
Removes the registry value from the list based on the key passed in Removes the registry value from the list based on the key passed in
(Only valid and active for testing framework) (Only valid and active for testing framework)
""" """
if self.running_under_test == False: if self.running_under_test is False:
log.error(u'Invalid Method call for key %s' % key) log.error(u'Invalid Method call for key %s' % key)
raise KeyError(u'Invalid Method call for key %s' % key) raise KeyError(u'Invalid Method call for key %s' % key)
return return
if key in self.service_list: if key in self.service_list:
del self.service_list[key] del self.service_list[key]

View File

@ -315,7 +315,7 @@ class Renderer(object):
if text_contains_split: if text_contains_split:
text = slides[-1] + u'\n[---]\n' + text text = slides[-1] + u'\n[---]\n' + text
else: else:
text = slides[-1] + u'\n'+ text text = slides[-1] + u'\n' + text
text = text.replace(u'<br>', u'\n') text = text.replace(u'<br>', u'\n')
else: else:
pages.extend(slides) pages.extend(slides)
@ -543,7 +543,7 @@ class Renderer(object):
end_tags.reverse() end_tags.reverse()
# Remove the indexes. # Remove the indexes.
html_tags = [tag[1] for tag in html_tags] html_tags = [tag[1] for tag in html_tags]
return raw_text + u''.join(end_tags), u''.join(start_tags), u''.join(html_tags) return raw_text + u''.join(end_tags), u''.join(start_tags), u''.join(html_tags)
def _binary_chop(self, formatted, previous_html, previous_raw, html_list, raw_list, separator, line_end): def _binary_chop(self, formatted, previous_html, previous_raw, html_list, raw_list, separator, line_end):
""" """

View File

@ -37,7 +37,6 @@ from PyQt4 import QtCore
from openlp.core.lib import Receiver, translate from openlp.core.lib import Receiver, translate
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
@ -51,6 +50,9 @@ class ScreenList(object):
__instance__ = None __instance__ = None
def __new__(cls): def __new__(cls):
"""
Re-implement __new__ to create a true singleton.
"""
if not cls.__instance__: if not cls.__instance__:
cls.__instance__ = object.__new__(cls) cls.__instance__ = object.__new__(cls)
return cls.__instance__ return cls.__instance__

View File

@ -36,6 +36,7 @@ from openlp.core.lib.ui import create_widget_action
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
class SearchEdit(QtGui.QLineEdit): class SearchEdit(QtGui.QLineEdit):
""" """
This is a specialised QLineEdit with a "clear" button inside for searches. This is a specialised QLineEdit with a "clear" button inside for searches.

View File

@ -43,6 +43,7 @@ from openlp.core.lib import build_icon, clean_tags, expand_tags, translate, Imag
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
class ServiceItemType(object): class ServiceItemType(object):
""" """
Defines the type of service item Defines the type of service item
@ -607,7 +608,7 @@ class ServiceItem(object):
``theme`` ``theme``
The new theme to be replaced in the service item The new theme to be replaced in the service item
""" """
self.theme_overwritten = (theme == None) self.theme_overwritten = (theme is None)
self.theme = theme self.theme = theme
self._new_item() self._new_item()
self.render() self.render()

View File

@ -127,8 +127,8 @@ class Settings(QtCore.QSettings):
u'general/enable slide loop': True, u'general/enable slide loop': True,
u'general/show splash': True, u'general/show splash': True,
u'general/screen blank': False, u'general/screen blank': False,
# The oder display settings (display position and dimensions) are defined in the ScreenList class due to crycle # The other display settings (display position and dimensions) are defined in the ScreenList class due to a
# dependency. # circular dependency.
u'general/override position': False, u'general/override position': False,
u'general/loop delay': 5, u'general/loop delay': 5,
u'general/songselect username': u'', u'general/songselect username': u'',
@ -276,6 +276,9 @@ class Settings(QtCore.QSettings):
Settings.__default_settings__[u'advanced/default service name'] = UiStrings().DefaultServiceName Settings.__default_settings__[u'advanced/default service name'] = UiStrings().DefaultServiceName
def __init__(self, *args): def __init__(self, *args):
"""
Constructor which checks if this should be a native settings object, or an INI file.
"""
if not args and Settings.__file_path__ and Settings.defaultFormat() == Settings.IniFormat: if not args and Settings.__file_path__ and Settings.defaultFormat() == Settings.IniFormat:
QtCore.QSettings.__init__(self, Settings.__file_path__, Settings.IniFormat) QtCore.QSettings.__init__(self, Settings.__file_path__, Settings.IniFormat)
else: else:
@ -340,4 +343,3 @@ class Settings(QtCore.QSettings):
if isinstance(default_value, int): if isinstance(default_value, int):
return int(setting) return int(setting)
return setting return setting

View File

@ -33,9 +33,6 @@ format.
""" """
import os import os
from PyQt4 import QtCore
from openlp.core.lib import Settings
from openlp.core.utils import AppLocation from openlp.core.utils import AppLocation

View File

@ -26,9 +26,14 @@
# 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.core.lib.settingstab` module contains the base SettingsTab class which plugins use for adding their
own tab to the settings dialog.
"""
from PyQt4 import QtGui from PyQt4 import QtGui
class SettingsTab(QtGui.QWidget): class SettingsTab(QtGui.QWidget):
""" """
SettingsTab is a helper widget for plugins to define Tabs for the settings SettingsTab is a helper widget for plugins to define Tabs for the settings

View File

@ -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.core.lib.spelltextedit` module contains a classes to add spell checking to an edit widget.
"""
import logging import logging
import re import re
@ -47,11 +51,15 @@ from openlp.core.lib.ui import create_action
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
class SpellTextEdit(QtGui.QPlainTextEdit): class SpellTextEdit(QtGui.QPlainTextEdit):
""" """
Spell checking widget based on QPlanTextEdit. Spell checking widget based on QPlanTextEdit.
""" """
def __init__(self, parent=None, formattingTagsAllowed=True): def __init__(self, parent=None, formattingTagsAllowed=True):
"""
Constructor.
"""
global ENCHANT_AVAILABLE global ENCHANT_AVAILABLE
QtGui.QPlainTextEdit.__init__(self, parent) QtGui.QPlainTextEdit.__init__(self, parent)
self.formattingTagsAllowed = formattingTagsAllowed self.formattingTagsAllowed = formattingTagsAllowed
@ -171,6 +179,9 @@ class Highlighter(QtGui.QSyntaxHighlighter):
WORDS = u'(?iu)[\w\']+' WORDS = u'(?iu)[\w\']+'
def __init__(self, *args): def __init__(self, *args):
"""
Constructor
"""
QtGui.QSyntaxHighlighter.__init__(self, *args) QtGui.QSyntaxHighlighter.__init__(self, *args)
self.spellingDictionary = None self.spellingDictionary = None
@ -197,5 +208,8 @@ class SpellAction(QtGui.QAction):
correct = QtCore.pyqtSignal(unicode) correct = QtCore.pyqtSignal(unicode)
def __init__(self, *args): def __init__(self, *args):
"""
Constructor
"""
QtGui.QAction.__init__(self, *args) QtGui.QAction.__init__(self, *args)
self.triggered.connect(lambda x: self.correct.emit(self.text())) self.triggered.connect(lambda x: self.correct.emit(self.text()))

View File

@ -86,6 +86,7 @@ BLANK_THEME_XML = \
</theme> </theme>
''' '''
class ThemeLevel(object): class ThemeLevel(object):
""" """
Provides an enumeration for the level a theme applies to Provides an enumeration for the level a theme applies to
@ -213,6 +214,7 @@ class ThemeXML(object):
""" """
FIRST_CAMEL_REGEX = re.compile(u'(.)([A-Z][a-z]+)') FIRST_CAMEL_REGEX = re.compile(u'(.)([A-Z][a-z]+)')
SECOND_CAMEL_REGEX = re.compile(u'([a-z0-9])([A-Z])') SECOND_CAMEL_REGEX = re.compile(u'([a-z0-9])([A-Z])')
def __init__(self): def __init__(self):
""" """
Initialise the theme object. Initialise the theme object.
@ -608,13 +610,15 @@ class ThemeXML(object):
self.add_background_gradient( self.add_background_gradient(
self.background_start_color, self.background_start_color,
self.background_end_color, self.background_end_color,
self.background_direction) self.background_direction
)
elif self.background_type == BackgroundType.to_string(BackgroundType.Image): elif self.background_type == BackgroundType.to_string(BackgroundType.Image):
filename = os.path.split(self.background_filename)[1] filename = os.path.split(self.background_filename)[1]
self.add_background_image(filename, self.background_border_color) self.add_background_image(filename, self.background_border_color)
elif self.background_type == BackgroundType.to_string(BackgroundType.Transparent): elif self.background_type == BackgroundType.to_string(BackgroundType.Transparent):
self.add_background_transparent() self.add_background_transparent()
self.add_font(self.font_main_name, self.add_font(
self.font_main_name,
self.font_main_color, self.font_main_color,
self.font_main_size, self.font_main_size,
self.font_main_override, u'main', self.font_main_override, u'main',
@ -630,14 +634,16 @@ class ThemeXML(object):
self.font_main_outline_size, self.font_main_outline_size,
self.font_main_shadow, self.font_main_shadow,
self.font_main_shadow_color, self.font_main_shadow_color,
self.font_main_shadow_size) self.font_main_shadow_size
self.add_font(self.font_footer_name, )
self.add_font(
self.font_footer_name,
self.font_footer_color, self.font_footer_color,
self.font_footer_size, self.font_footer_size,
self.font_footer_override, u'footer', self.font_footer_override, u'footer',
self.font_footer_bold, self.font_footer_bold,
self.font_footer_italics, self.font_footer_italics,
0, # line adjustment 0, # line adjustment
self.font_footer_x, self.font_footer_x,
self.font_footer_y, self.font_footer_y,
self.font_footer_width, self.font_footer_width,
@ -647,7 +653,10 @@ class ThemeXML(object):
self.font_footer_outline_size, self.font_footer_outline_size,
self.font_footer_shadow, self.font_footer_shadow,
self.font_footer_shadow_color, self.font_footer_shadow_color,
self.font_footer_shadow_size) self.font_footer_shadow_size
self.add_display(self.display_horizontal_align, )
self.add_display(
self.display_horizontal_align,
self.display_vertical_align, self.display_vertical_align,
self.display_slide_transition) self.display_slide_transition
)

View File

@ -37,6 +37,7 @@ from openlp.core.lib.ui import create_widget_action
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
class OpenLPToolbar(QtGui.QToolBar): class OpenLPToolbar(QtGui.QToolBar):
""" """
Lots of toolbars around the place, so it makes sense to have a common way Lots of toolbars around the place, so it makes sense to have a common way
@ -85,4 +86,3 @@ class OpenLPToolbar(QtGui.QToolBar):
self.actions[handle].setVisible(visible) self.actions[handle].setVisible(visible)
else: else:
log.warn(u'No handle "%s" in actions list.', unicode(handle)) log.warn(u'No handle "%s" in actions list.', unicode(handle))

View File

@ -111,8 +111,8 @@ class UiStrings(object):
self.OLPV2x = translate('OpenLP.Ui', 'OpenLP 2.1') self.OLPV2x = translate('OpenLP.Ui', 'OpenLP 2.1')
self.OpenLPStart = translate('OpenLP.Ui', 'OpenLP is already running. Do you wish to continue?') self.OpenLPStart = translate('OpenLP.Ui', 'OpenLP is already running. Do you wish to continue?')
self.OpenService = translate('OpenLP.Ui', 'Open service.') self.OpenService = translate('OpenLP.Ui', 'Open service.')
self.PlaySlidesInLoop = translate('OpenLP.Ui','Play Slides in Loop') self.PlaySlidesInLoop = translate('OpenLP.Ui', 'Play Slides in Loop')
self.PlaySlidesToEnd = translate('OpenLP.Ui','Play Slides to End') self.PlaySlidesToEnd = translate('OpenLP.Ui', 'Play Slides to End')
self.Preview = translate('OpenLP.Ui', 'Preview') self.Preview = translate('OpenLP.Ui', 'Preview')
self.PrintService = translate('OpenLP.Ui', 'Print Service') self.PrintService = translate('OpenLP.Ui', 'Print Service')
self.ReplaceBG = translate('OpenLP.Ui', 'Replace Background') self.ReplaceBG = translate('OpenLP.Ui', 'Replace Background')
@ -144,4 +144,3 @@ class UiStrings(object):
self.Version = translate('OpenLP.Ui', 'Version') self.Version = translate('OpenLP.Ui', 'Version')
self.View = translate('OpenLP.Ui', 'View') self.View = translate('OpenLP.Ui', 'View')
self.ViewMode = translate('OpenLP.Ui', 'View Mode') self.ViewMode = translate('OpenLP.Ui', 'View Mode')

View File

@ -32,3 +32,5 @@ OpenLP when displaying a song or a scripture.
""" """
from openlp.core.theme.theme import Theme from openlp.core.theme.theme import Theme
__all__ = ['Theme']

View File

@ -37,11 +37,21 @@ from xml.etree.ElementTree import ElementTree, XML
from PyQt4 import QtGui from PyQt4 import QtGui
DELPHI_COLORS = { DELPHI_COLORS = {
u'clAqua': 0x00FFFF, u'clBlack': 0x000000, u'clBlue': 0x0000FF, u'clAqua': 0x00FFFF,
u'clFuchsia': 0xFF00FF, u'clGray': 0x808080, u'clGreen': 0x008000, u'clBlack': 0x000000,
u'clLime': 0x00FF00, u'clMaroon': 0x800000, u'clNavy': 0x000080, u'clBlue': 0x0000FF,
u'clOlive': 0x808000, u'clPurple': 0x800080, u'clRed': 0xFF0000, u'clFuchsia': 0xFF00FF,
u'clSilver': 0xC0C0C0, u'clTeal': 0x008080, u'clWhite': 0xFFFFFF, u'clGray': 0x808080,
u'clGreen': 0x008000,
u'clLime': 0x00FF00,
u'clMaroon': 0x800000,
u'clNavy': 0x000080,
u'clOlive': 0x808000,
u'clPurple': 0x800080,
u'clRed': 0xFF0000,
u'clSilver': 0xC0C0C0,
u'clTeal': 0x008080,
u'clWhite': 0xFFFFFF,
u'clYellow': 0xFFFF00 u'clYellow': 0xFFFF00
} }
@ -66,6 +76,7 @@ BLANK_STYLE_XML = \
</Theme> </Theme>
''' '''
class Theme(object): class Theme(object):
""" """
Provide a class wrapper storing data from an XML theme Provide a class wrapper storing data from an XML theme
@ -205,10 +216,12 @@ class Theme(object):
val = element_text val = element_text
# strings need special handling to sort the colours out # strings need special handling to sort the colours out
if isinstance(element_text, basestring): if isinstance(element_text, basestring):
if element_text[0] == u'$': # might be a hex number if element_text[0] == u'$':
# might be a hex number
try: try:
val = int(element_text[1:], 16) val = int(element_text[1:], 16)
except ValueError: # nope except ValueError:
# nope
pass pass
elif element_text in DELPHI_COLORS: elif element_text in DELPHI_COLORS:
val = DELPHI_COLORS[element_text] val = DELPHI_COLORS[element_text]
@ -222,9 +235,9 @@ class Theme(object):
isinstance(val, int))): isinstance(val, int))):
# convert to a wx.Colour # convert to a wx.Colour
if not delphi_color_change: if not delphi_color_change:
val = QtGui.QColor(val&0xFF, (val>>8)&0xFF, (val>>16)&0xFF) val = QtGui.QColor(val & 0xFF, (val >> 8) & 0xFF, (val >> 16) & 0xFF)
else: else:
val = QtGui.QColor((val>>16)&0xFF, (val>>8)&0xFF, val&0xFF) val = QtGui.QColor((val >> 16) & 0xFF, (val >> 8) & 0xFF, val & 0xFF)
setattr(self, element.tag, val) setattr(self, element.tag, val)
def __str__(self): def __str__(self):

View File

@ -31,7 +31,6 @@ The :mod:`ui` module provides the core user interface for OpenLP
""" """
class HideMode(object): class HideMode(object):
""" """
This is an enumeration class which specifies the different modes of hiding the display. This is an enumeration class which specifies the different modes of hiding the display.
@ -101,6 +100,8 @@ from mediadockmanager import MediaDockManager
from servicemanager import ServiceManager from servicemanager import ServiceManager
from thememanager import ThemeManager from thememanager import ThemeManager
__all__ = ['SplashScreen', 'AboutForm', 'SettingsForm', 'MainDisplay', __all__ = ['SplashScreen', 'AboutForm', 'SettingsForm', 'MainDisplay', 'SlideController', 'ServiceManager',
'SlideController', 'ServiceManager', 'ThemeManager', 'MediaDockManager', 'ThemeManager', 'MediaDockManager', 'ServiceItemEditForm', 'FirstTimeForm', 'FirstTimeLanguageForm', 'ThemeForm',
'ServiceItemEditForm', 'FirstTimeForm'] 'ThemeLayoutForm', 'FileRenameForm', 'StartTimeForm', 'MainDisplay', 'Display', 'ServiceNoteForm',
'SlideController', 'DisplayController', 'GeneralTab', 'ThemesTab', 'AdvancedTab', 'PluginForm',
'FormattingTagForm', 'ShortcutListForm']

View File

@ -34,7 +34,14 @@ from openlp.core.lib.ui import create_button, create_button_box
class Ui_AboutDialog(object): class Ui_AboutDialog(object):
"""
The actual GUI widgets for the About form.
"""
def setupUi(self, aboutDialog): def setupUi(self, aboutDialog):
"""
Set up the UI for the dialog.
"""
aboutDialog.setObjectName(u'aboutDialog') aboutDialog.setObjectName(u'aboutDialog')
aboutDialog.setWindowIcon(build_icon(u':/icon/openlp-logo-16x16.png')) aboutDialog.setWindowIcon(build_icon(u':/icon/openlp-logo-16x16.png'))
self.aboutDialogLayout = QtGui.QVBoxLayout(aboutDialog) self.aboutDialogLayout = QtGui.QVBoxLayout(aboutDialog)
@ -80,6 +87,9 @@ class Ui_AboutDialog(object):
self.aboutNotebook.setCurrentIndex(0) self.aboutNotebook.setCurrentIndex(0)
def retranslateUi(self, aboutDialog): def retranslateUi(self, aboutDialog):
"""
Dynamically translate the UI.
"""
aboutDialog.setWindowTitle(u'%s OpenLP' % UiStrings().About) aboutDialog.setWindowTitle(u'%s OpenLP' % UiStrings().About)
self.aboutTextEdit.setPlainText(translate('OpenLP.AboutForm', self.aboutTextEdit.setPlainText(translate('OpenLP.AboutForm',
'OpenLP <version><revision> - Open Source Lyrics ' 'OpenLP <version><revision> - Open Source Lyrics '
@ -134,17 +144,17 @@ class Ui_AboutDialog(object):
u'en_ZA': [u'Raoul "superfly" Snyman', u'en_ZA': [u'Raoul "superfly" Snyman',
u'Johan "nuvolari" Mynhardt'], u'Johan "nuvolari" Mynhardt'],
u'el': [u'Alexander Siozos'], u'el': [u'Alexander Siozos'],
u'es': [u'Josu\xe9 Z\xfa\xf1iga',u'Christian Gonzalez'], u'es': [u'Josu\xe9 Z\xfa\xf1iga', u'Christian Gonzalez'],
u'et': [u'Mattias "mahfiaz" P\xf5ldaru'], u'et': [u'Mattias "mahfiaz" P\xf5ldaru'],
u'fi': [u'Jori "joribu" Brander', u'Tobbe "tobbeb" Bildo'], u'fi': [u'Jori "joribu" Brander', u'Tobbe "tobbeb" Bildo'],
u'fr': [u'Stephan\xe9 "stbrunner" Brunner', u'Jeremie "jnau05"', u'fr': [u'Stephan\xe9 "stbrunner" Brunner', u'Jeremie "jnau05"',
u'Carl "carl.fischer" Fischer'], u'Carl "carl.fischer" Fischer'],
u'hu': [u'Gyuris Gell\xe9rt'], u'hu': [u'Gyuris Gell\xe9rt'],
u'id': [u'Mico "bangmico" Siahaan' ,u' ign_christian'], u'id': [u'Mico "bangmico" Siahaan', u' ign_christian'],
u'ja': [u'Kunio "Kunio" Nakamaru', u'Chris Haris'], u'ja': [u'Kunio "Kunio" Nakamaru', u'Chris Haris'],
u'nb': [u'Atle "pendlaren" Weibell', u'Frode "frodus" Woldsund'], u'nb': [u'Atle "pendlaren" Weibell', u'Frode "frodus" Woldsund'],
u'nl': [u'Arjen "typovar" van Voorst'], u'nl': [u'Arjen "typovar" van Voorst'],
u'pt_BR': [u'David Mederiros',u'Rafael "rafaellerm" Lerm', u'pt_BR': [u'David Mederiros', u'Rafael "rafaellerm" Lerm',
u'Eduardo Levi Chaves', u'Eduardo Levi Chaves',
u'Gustavo Bim', u'Rog\xeanio Bel\xe9m', u'Samuel' u'Gustavo Bim', u'Rog\xeanio Bel\xe9m', u'Samuel'
u'Simon "samscudder" Scudder', u'Van Der Fran'], u'Simon "samscudder" Scudder', u'Van Der Fran'],
@ -260,7 +270,7 @@ class Ui_AboutDialog(object):
u'\n '.join(documentors))) u'\n '.join(documentors)))
self.aboutNotebook.setTabText(self.aboutNotebook.indexOf(self.creditsTab), self.aboutNotebook.setTabText(self.aboutNotebook.indexOf(self.creditsTab),
translate('OpenLP.AboutForm', 'Credits')) translate('OpenLP.AboutForm', 'Credits'))
copyright = translate('OpenLP.AboutForm', copyright_note = translate('OpenLP.AboutForm',
'Copyright \xa9 2004-2013 %s\n' 'Copyright \xa9 2004-2013 %s\n'
'Portions copyright \xa9 2004-2013 %s') % (u'Raoul Snyman', 'Portions copyright \xa9 2004-2013 %s') % (u'Raoul Snyman',
u'Tim Bentley, Gerald Britton, Jonathan Corwin, Samuel Findlay, ' u'Tim Bentley, Gerald Britton, Jonathan Corwin, Samuel Findlay, '
@ -652,7 +662,7 @@ class Ui_AboutDialog(object):
'linking proprietary applications with the library. If this is ' 'linking proprietary applications with the library. If this is '
'what you want to do, use the GNU Lesser General Public License ' 'what you want to do, use the GNU Lesser General Public License '
'instead of this License.') 'instead of this License.')
self.licenseTextEdit.setPlainText(u'%s\n\n%s\n\n%s\n\n\n%s' % (copyright, licence, disclaimer, gpltext)) self.licenseTextEdit.setPlainText(u'%s\n\n%s\n\n%s\n\n\n%s' % (copyright_note, licence, disclaimer, gpltext))
self.aboutNotebook.setTabText(self.aboutNotebook.indexOf(self.licenseTab), self.aboutNotebook.setTabText(self.aboutNotebook.indexOf(self.licenseTab),
translate('OpenLP.AboutForm', 'License')) translate('OpenLP.AboutForm', 'License'))
self.volunteerButton.setText(translate('OpenLP.AboutForm', 'Volunteer')) self.volunteerButton.setText(translate('OpenLP.AboutForm', 'Volunteer'))

View File

@ -26,6 +26,9 @@
# 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 About dialog.
"""
from PyQt4 import QtCore, QtGui from PyQt4 import QtCore, QtGui
@ -33,6 +36,7 @@ from aboutdialog import Ui_AboutDialog
from openlp.core.lib import translate from openlp.core.lib import translate
from openlp.core.utils import get_application_version from openlp.core.utils import get_application_version
class AboutForm(QtGui.QDialog, Ui_AboutDialog): class AboutForm(QtGui.QDialog, Ui_AboutDialog):
""" """
The About dialog The About dialog

View File

@ -36,7 +36,7 @@ import sys
from PyQt4 import QtCore, QtGui from PyQt4 import QtCore, QtGui
from openlp.core.lib import SettingsTab, translate, build_icon, Receiver, Settings, UiStrings from openlp.core.lib import SettingsTab, Receiver, Settings, UiStrings, translate, build_icon
from openlp.core.utils import get_images_filter, AppLocation, format_time from openlp.core.utils import get_images_filter, AppLocation, format_time
from openlp.core.lib import SlideLimits from openlp.core.lib import SlideLimits
@ -137,7 +137,7 @@ class AdvancedTab(SettingsTab):
self.dataDirectoryLayout = QtGui.QFormLayout(self.dataDirectoryGroupBox) self.dataDirectoryLayout = QtGui.QFormLayout(self.dataDirectoryGroupBox)
self.dataDirectoryLayout.setObjectName(u'dataDirectoryLayout') self.dataDirectoryLayout.setObjectName(u'dataDirectoryLayout')
self.dataDirectoryCurrentLabel = QtGui.QLabel(self.dataDirectoryGroupBox) self.dataDirectoryCurrentLabel = QtGui.QLabel(self.dataDirectoryGroupBox)
self.dataDirectoryCurrentLabel.setObjectName( u'dataDirectoryCurrentLabel') self.dataDirectoryCurrentLabel.setObjectName(u'dataDirectoryCurrentLabel')
self.dataDirectoryLabel = QtGui.QLabel(self.dataDirectoryGroupBox) self.dataDirectoryLabel = QtGui.QLabel(self.dataDirectoryGroupBox)
self.dataDirectoryLabel.setObjectName(u'dataDirectoryLabel') self.dataDirectoryLabel.setObjectName(u'dataDirectoryLabel')
self.dataDirectoryNewLabel = QtGui.QLabel(self.dataDirectoryGroupBox) self.dataDirectoryNewLabel = QtGui.QLabel(self.dataDirectoryGroupBox)
@ -299,7 +299,8 @@ class AdvancedTab(SettingsTab):
self.serviceNameLabel.setText(translate('OpenLP.AdvancedTab', 'Name:')) self.serviceNameLabel.setText(translate('OpenLP.AdvancedTab', 'Name:'))
self.serviceNameEdit.setToolTip(translate('OpenLP.AdvancedTab', 'Consult the OpenLP manual for usage.')) self.serviceNameEdit.setToolTip(translate('OpenLP.AdvancedTab', 'Consult the OpenLP manual for usage.'))
self.serviceNameRevertButton.setToolTip( self.serviceNameRevertButton.setToolTip(
translate('OpenLP.AdvancedTab', 'Revert to the default service name "%s".') % UiStrings().DefaultServiceName) translate('OpenLP.AdvancedTab', 'Revert to the default service name "%s".') %
UiStrings().DefaultServiceName)
self.serviceNameExampleLabel.setText(translate('OpenLP.AdvancedTab', 'Example:')) self.serviceNameExampleLabel.setText(translate('OpenLP.AdvancedTab', 'Example:'))
self.hideMouseGroupBox.setTitle(translate('OpenLP.AdvancedTab', 'Mouse Cursor')) self.hideMouseGroupBox.setTitle(translate('OpenLP.AdvancedTab', 'Mouse Cursor'))
self.hideMouseCheckBox.setText(translate('OpenLP.AdvancedTab', 'Hide mouse cursor when over display window')) self.hideMouseCheckBox.setText(translate('OpenLP.AdvancedTab', 'Hide mouse cursor when over display window'))
@ -324,7 +325,7 @@ class AdvancedTab(SettingsTab):
translate('OpenLP.AdvancedTab', '<strong>WARNING:</strong> New data directory location contains ' translate('OpenLP.AdvancedTab', '<strong>WARNING:</strong> New data directory location contains '
'OpenLP data files. These files WILL be replaced during a copy.')) 'OpenLP data files. These files WILL be replaced during a copy.'))
self.x11GroupBox.setTitle(translate('OpenLP.AdvancedTab', 'X11')) self.x11GroupBox.setTitle(translate('OpenLP.AdvancedTab', 'X11'))
self.x11BypassCheckBox.setText(translate('OpenLP.AdvancedTab','Bypass X11 Window Manager')) self.x11BypassCheckBox.setText(translate('OpenLP.AdvancedTab', 'Bypass X11 Window Manager'))
# Slide Limits # Slide Limits
self.slideGroupBox.setTitle(translate('OpenLP.GeneralTab', 'Service Item Slide Limits')) self.slideGroupBox.setTitle(translate('OpenLP.GeneralTab', 'Service Item Slide Limits'))
self.slideLabel.setText(translate('OpenLP.GeneralTab', 'Behavior of next/previous on the last/first slide:')) self.slideLabel.setText(translate('OpenLP.GeneralTab', 'Behavior of next/previous on the last/first slide:'))
@ -440,11 +441,16 @@ class AdvancedTab(SettingsTab):
Receiver.send_message(u'slidecontroller_update_slide_limits') Receiver.send_message(u'slidecontroller_update_slide_limits')
def cancel(self): def cancel(self):
# Dialogue was cancelled, remove any pending data path change. """
Dialogue was cancelled, remove any pending data path change.
"""
self.onDataDirectoryCancelButtonClicked() self.onDataDirectoryCancelButtonClicked()
SettingsTab.cancel(self) SettingsTab.cancel(self)
def serviceNameCheckBoxToggled(self, default_service_enabled): def serviceNameCheckBoxToggled(self, default_service_enabled):
"""
Toggle the service name check box.
"""
self.serviceNameDay.setEnabled(default_service_enabled) self.serviceNameDay.setEnabled(default_service_enabled)
time_enabled = default_service_enabled and self.serviceNameDay.currentIndex() is not 7 time_enabled = default_service_enabled and self.serviceNameDay.currentIndex() is not 7
self.serviceNameTime.setEnabled(time_enabled) self.serviceNameTime.setEnabled(time_enabled)
@ -452,6 +458,9 @@ class AdvancedTab(SettingsTab):
self.serviceNameRevertButton.setEnabled(default_service_enabled) self.serviceNameRevertButton.setEnabled(default_service_enabled)
def generateServiceNameExample(self): def generateServiceNameExample(self):
"""
Generate an example service name.
"""
preset_is_valid = True preset_is_valid = True
if self.serviceNameDay.currentIndex() == 7: if self.serviceNameDay.currentIndex() == 7:
local_time = datetime.now() local_time = datetime.now()
@ -461,8 +470,10 @@ class AdvancedTab(SettingsTab):
if day_delta < 0: if day_delta < 0:
day_delta += 7 day_delta += 7
time = now + timedelta(days=day_delta) time = now + timedelta(days=day_delta)
local_time = time.replace(hour = self.serviceNameTime.time().hour(), local_time = time.replace(
minute = self.serviceNameTime.time().minute()) hour=self.serviceNameTime.time().hour(),
minute=self.serviceNameTime.time().minute()
)
try: try:
service_name_example = format_time(unicode(self.serviceNameEdit.text()), local_time) service_name_example = format_time(unicode(self.serviceNameEdit.text()), local_time)
except ValueError: except ValueError:
@ -471,20 +482,32 @@ class AdvancedTab(SettingsTab):
return preset_is_valid, service_name_example return preset_is_valid, service_name_example
def updateServiceNameExample(self, returned_value): def updateServiceNameExample(self, returned_value):
"""
Update the example service name.
"""
if not self.shouldUpdateServiceNameExample: if not self.shouldUpdateServiceNameExample:
return return
name_example = self.generateServiceNameExample()[1] name_example = self.generateServiceNameExample()[1]
self.serviceNameExample.setText(name_example) self.serviceNameExample.setText(name_example)
def onServiceNameDayChanged(self, service_day): def onServiceNameDayChanged(self, service_day):
"""
React to the day of the service name changing.
"""
self.serviceNameTime.setEnabled(service_day is not 7) self.serviceNameTime.setEnabled(service_day is not 7)
self.updateServiceNameExample(None) self.updateServiceNameExample(None)
def onServiceNameRevertButtonClicked(self): def onServiceNameRevertButtonClicked(self):
"""
Revert to the default service name.
"""
self.serviceNameEdit.setText(UiStrings().DefaultServiceName) self.serviceNameEdit.setText(UiStrings().DefaultServiceName)
self.serviceNameEdit.setFocus() self.serviceNameEdit.setFocus()
def onDefaultColorButtonClicked(self): def onDefaultColorButtonClicked(self):
"""
Select the background colour of the default display screen.
"""
new_color = QtGui.QColorDialog.getColor( new_color = QtGui.QColorDialog.getColor(
QtGui.QColor(self.defaultColor), self) QtGui.QColor(self.defaultColor), self)
if new_color.isValid(): if new_color.isValid():
@ -492,6 +515,9 @@ class AdvancedTab(SettingsTab):
self.defaultColorButton.setStyleSheet(u'background-color: %s' % self.defaultColor) self.defaultColorButton.setStyleSheet(u'background-color: %s' % self.defaultColor)
def onDefaultBrowseButtonClicked(self): def onDefaultBrowseButtonClicked(self):
"""
Select an image for the default display screen.
"""
file_filters = u'%s;;%s (*.*) (*)' % (get_images_filter(), file_filters = u'%s;;%s (*.*) (*)' % (get_images_filter(),
UiStrings().AllFiles) UiStrings().AllFiles)
filename = QtGui.QFileDialog.getOpenFileName(self, filename = QtGui.QFileDialog.getOpenFileName(self,
@ -506,9 +532,9 @@ class AdvancedTab(SettingsTab):
""" """
old_root_path = unicode(self.dataDirectoryLabel.text()) old_root_path = unicode(self.dataDirectoryLabel.text())
# Get the new directory location. # Get the new directory location.
new_data_path = QtGui.QFileDialog.getExistingDirectory(self, new_data_path = QtGui.QFileDialog.getExistingDirectory(
translate('OpenLP.AdvancedTab', 'Select Data Directory Location'), old_root_path, self, translate('OpenLP.AdvancedTab', 'Select Data Directory Location'), old_root_path,
options = QtGui.QFileDialog.ShowDirsOnly) options=QtGui.QFileDialog.ShowDirsOnly)
# Set the new data path. # Set the new data path.
if new_data_path: if new_data_path:
new_data_path = os.path.normpath(new_data_path) new_data_path = os.path.normpath(new_data_path)
@ -558,6 +584,9 @@ class AdvancedTab(SettingsTab):
self.onDataDirectoryCancelButtonClicked() self.onDataDirectoryCancelButtonClicked()
def onDataDirectoryCopyCheckBoxToggled(self): def onDataDirectoryCopyCheckBoxToggled(self):
"""
Copy existing data when you change your data directory.
"""
Receiver.send_message(u'set_copy_data', Receiver.send_message(u'set_copy_data',
self.dataDirectoryCopyCheckBox.isChecked()) self.dataDirectoryCopyCheckBox.isChecked())
if self.dataExists: if self.dataExists:
@ -566,7 +595,10 @@ class AdvancedTab(SettingsTab):
else: else:
self.newDataDirectoryHasFilesLabel.hide() self.newDataDirectoryHasFilesLabel.hide()
def checkDataOverwrite(self, data_path ): def checkDataOverwrite(self, data_path):
"""
Check if there's already data in the target directory.
"""
test_path = os.path.join(data_path, u'songs') test_path = os.path.join(data_path, u'songs')
self.dataDirectoryCopyCheckBox.show() self.dataDirectoryCopyCheckBox.show()
if os.path.exists(test_path): if os.path.exists(test_path):
@ -602,6 +634,9 @@ class AdvancedTab(SettingsTab):
self.newDataDirectoryHasFilesLabel.hide() self.newDataDirectoryHasFilesLabel.hide()
def onDefaultRevertButtonClicked(self): def onDefaultRevertButtonClicked(self):
"""
Revert the default screen back to the default settings.
"""
self.defaultFileEdit.setText(u':/graphics/openlp-splash-screen.png') self.defaultFileEdit.setText(u':/graphics/openlp-splash-screen.png')
self.defaultFileEdit.setFocus() self.defaultFileEdit.setFocus()
@ -615,10 +650,19 @@ class AdvancedTab(SettingsTab):
self.displayChanged = True self.displayChanged = True
def onEndSlideButtonClicked(self): def onEndSlideButtonClicked(self):
"""
Set the slide wrap option.
"""
self.slide_limits = SlideLimits.End self.slide_limits = SlideLimits.End
def onWrapSlideButtonClicked(self): def onWrapSlideButtonClicked(self):
"""
Set the slide wrap option.
"""
self.slide_limits = SlideLimits.Wrap self.slide_limits = SlideLimits.Wrap
def onnextItemButtonClicked(self): def onnextItemButtonClicked(self):
"""
Set the slide wrap option.
"""
self.slide_limits = SlideLimits.Next self.slide_limits = SlideLimits.Next

View File

@ -26,14 +26,24 @@
# 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 GUI widgets of the exception dialog.
"""
from PyQt4 import QtCore, QtGui from PyQt4 import QtCore, QtGui
from openlp.core.lib import translate from openlp.core.lib import translate
from openlp.core.lib.ui import create_button, create_button_box from openlp.core.lib.ui import create_button, create_button_box
class Ui_ExceptionDialog(object): class Ui_ExceptionDialog(object):
"""
The GUI widgets of the exception dialog.
"""
def setupUi(self, exceptionDialog): def setupUi(self, exceptionDialog):
"""
Set up the UI.
"""
exceptionDialog.setObjectName(u'exceptionDialog') exceptionDialog.setObjectName(u'exceptionDialog')
self.exceptionLayout = QtGui.QVBoxLayout(exceptionDialog) self.exceptionLayout = QtGui.QVBoxLayout(exceptionDialog)
self.exceptionLayout.setObjectName(u'exceptionLayout') self.exceptionLayout.setObjectName(u'exceptionLayout')
@ -66,7 +76,7 @@ class Ui_ExceptionDialog(object):
self.exceptionLayout.addWidget(self.exceptionTextEdit) self.exceptionLayout.addWidget(self.exceptionTextEdit)
self.sendReportButton = create_button(exceptionDialog, u'sendReportButton', self.sendReportButton = create_button(exceptionDialog, u'sendReportButton',
icon=u':/general/general_email.png', click=self.onSendReportButtonClicked) icon=u':/general/general_email.png', click=self.onSendReportButtonClicked)
self.saveReportButton = create_button(exceptionDialog,u'saveReportButton', self.saveReportButton = create_button(exceptionDialog, u'saveReportButton',
icon=u':/general/general_save.png', click=self.onSaveReportButtonClicked) icon=u':/general/general_save.png', click=self.onSaveReportButtonClicked)
self.attachFileButton = create_button(exceptionDialog, u'attachFileButton', self.attachFileButton = create_button(exceptionDialog, u'attachFileButton',
icon=u':/general/general_open.png', click=self.onAttachFileButtonClicked) icon=u':/general/general_open.png', click=self.onAttachFileButtonClicked)
@ -79,6 +89,9 @@ class Ui_ExceptionDialog(object):
QtCore.SIGNAL(u'textChanged()'), self.onDescriptionUpdated) QtCore.SIGNAL(u'textChanged()'), self.onDescriptionUpdated)
def retranslateUi(self, exceptionDialog): def retranslateUi(self, exceptionDialog):
"""
Translate the widgets on the fly.
"""
exceptionDialog.setWindowTitle(translate('OpenLP.ExceptionDialog', 'Error Occurred')) exceptionDialog.setWindowTitle(translate('OpenLP.ExceptionDialog', 'Error Occurred'))
self.descriptionExplanation.setText(translate('OpenLP.ExceptionDialog', self.descriptionExplanation.setText(translate('OpenLP.ExceptionDialog',
'Please enter a description of what you were doing to cause this ' 'Please enter a description of what you were doing to cause this '

View File

@ -26,6 +26,9 @@
# 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 actual exception dialog form.
"""
import logging import logging
import re import re
import os import os
@ -92,22 +95,32 @@ from exceptiondialog import Ui_ExceptionDialog
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
class ExceptionForm(QtGui.QDialog, Ui_ExceptionDialog): class ExceptionForm(QtGui.QDialog, Ui_ExceptionDialog):
""" """
The exception dialog The exception dialog
""" """
def __init__(self, parent): def __init__(self, parent):
"""
Constructor.
"""
QtGui.QDialog.__init__(self, parent) QtGui.QDialog.__init__(self, parent)
self.setupUi(self) self.setupUi(self)
self.settingsSection = u'crashreport' self.settingsSection = u'crashreport'
def exec_(self): def exec_(self):
"""
Show the dialog.
"""
self.descriptionTextEdit.setPlainText(u'') self.descriptionTextEdit.setPlainText(u'')
self.onDescriptionUpdated() self.onDescriptionUpdated()
self.fileAttachment = None self.fileAttachment = None
return QtGui.QDialog.exec_(self) return QtGui.QDialog.exec_(self)
def _createReport(self): def _createReport(self):
"""
Create an exception report.
"""
openlp_version = get_application_version() openlp_version = get_application_version()
description = self.descriptionTextEdit.toPlainText() description = self.descriptionTextEdit.toPlainText()
traceback = self.exceptionTextEdit.toPlainText() traceback = self.exceptionTextEdit.toPlainText()
@ -199,6 +212,9 @@ class ExceptionForm(QtGui.QDialog, Ui_ExceptionDialog):
QtGui.QDesktopServices.openUrl(mailto_url) QtGui.QDesktopServices.openUrl(mailto_url)
def onDescriptionUpdated(self): def onDescriptionUpdated(self):
"""
Update the minimum number of characters needed in the description.
"""
count = int(20 - len(self.descriptionTextEdit.toPlainText())) count = int(20 - len(self.descriptionTextEdit.toPlainText()))
if count < 0: if count < 0:
count = 0 count = 0
@ -209,6 +225,9 @@ class ExceptionForm(QtGui.QDialog, Ui_ExceptionDialog):
translate('OpenLP.ExceptionDialog', 'Description characters to enter : %s') % count) translate('OpenLP.ExceptionDialog', 'Description characters to enter : %s') % count)
def onAttachFileButtonClicked(self): def onAttachFileButtonClicked(self):
"""
Attache files to the bug report e-mail.
"""
files = QtGui.QFileDialog.getOpenFileName( files = QtGui.QFileDialog.getOpenFileName(
self, translate('ImagePlugin.ExceptionDialog', 'Select Attachment'), self, translate('ImagePlugin.ExceptionDialog', 'Select Attachment'),
Settings().value(self.settingsSection + u'/last directory'), u'%s (*.*) (*)' % UiStrings().AllFiles) Settings().value(self.settingsSection + u'/last directory'), u'%s (*.*) (*)' % UiStrings().AllFiles)
@ -217,6 +236,8 @@ class ExceptionForm(QtGui.QDialog, Ui_ExceptionDialog):
self.fileAttachment = unicode(files) self.fileAttachment = unicode(files)
def __buttonState(self, state): def __buttonState(self, state):
"""
Toggle the button state.
"""
self.saveReportButton.setEnabled(state) self.saveReportButton.setEnabled(state)
self.sendReportButton.setEnabled(state) self.sendReportButton.setEnabled(state)

View File

@ -26,14 +26,23 @@
# 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 UI widgets for the rename dialog
"""
from PyQt4 import QtCore, QtGui from PyQt4 import QtCore, QtGui
from openlp.core.lib import translate from openlp.core.lib import translate
from openlp.core.lib.ui import create_button_box from openlp.core.lib.ui import create_button_box
class Ui_FileRenameDialog(object): class Ui_FileRenameDialog(object):
"""
The UI widgets for the rename dialog
"""
def setupUi(self, fileRenameDialog): def setupUi(self, fileRenameDialog):
"""
Set up the UI
"""
fileRenameDialog.setObjectName(u'fileRenameDialog') fileRenameDialog.setObjectName(u'fileRenameDialog')
fileRenameDialog.resize(300, 10) fileRenameDialog.resize(300, 10)
self.dialogLayout = QtGui.QGridLayout(fileRenameDialog) self.dialogLayout = QtGui.QGridLayout(fileRenameDialog)
@ -51,4 +60,7 @@ class Ui_FileRenameDialog(object):
self.setMaximumHeight(self.sizeHint().height()) self.setMaximumHeight(self.sizeHint().height())
def retranslateUi(self, fileRenameDialog): def retranslateUi(self, fileRenameDialog):
"""
Translate the UI on the fly.
"""
self.fileNameLabel.setText(translate('OpenLP.FileRenameForm', 'New File Name:')) self.fileNameLabel.setText(translate('OpenLP.FileRenameForm', 'New File Name:'))