forked from openlp/openlp
Linting cleanups.
This commit is contained in:
parent
b0b89fdc05
commit
18034a2f6a
@ -34,4 +34,3 @@ import core
|
||||
import plugins
|
||||
|
||||
__all__ = [u'core', u'plugins']
|
||||
|
||||
|
@ -172,6 +172,19 @@ class OpenLP(QtGui.QApplication):
|
||||
return False
|
||||
|
||||
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'):
|
||||
log.exception(''.join(format_exception(exctype, value, traceback)))
|
||||
return
|
||||
@ -283,7 +296,7 @@ def main(args=None):
|
||||
else:
|
||||
app.setApplicationName(u'OpenLP')
|
||||
set_up_logging(AppLocation.get_directory(AppLocation.CacheDir))
|
||||
registry = Registry.create()
|
||||
Registry.create()
|
||||
app.setApplicationVersion(get_application_version()[u'version'])
|
||||
# Instance check
|
||||
if not options.testing:
|
||||
|
@ -45,6 +45,7 @@ from openlp.core.utils import AppLocation, delete_file
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def init_db(url, auto_flush=True, auto_commit=False):
|
||||
"""
|
||||
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):
|
||||
log.debug(u'Running upgrade_%d', version)
|
||||
try:
|
||||
getattr(upgrade, u'upgrade_%d' % version) (session, metadata, tables)
|
||||
getattr(upgrade, u'upgrade_%d' % version)(session, metadata, tables)
|
||||
except (SQLAlchemyError, DBAPIError):
|
||||
log.exception(u'Could not run database upgrade script '
|
||||
'"upgrade_%s", upgrade process has been halted.', version)
|
||||
@ -156,6 +157,7 @@ class BaseModel(object):
|
||||
instance.__setattr__(key, value)
|
||||
return instance
|
||||
|
||||
|
||||
class Manager(object):
|
||||
"""
|
||||
Provide generic object persistence management
|
||||
@ -205,12 +207,9 @@ class Manager(object):
|
||||
if db_ver > up_ver:
|
||||
critical_error_message_box(
|
||||
translate('OpenLP.Manager', 'Database Error'),
|
||||
translate('OpenLP.Manager', 'The database being '
|
||||
'loaded was created in a more recent version of '
|
||||
'OpenLP. The database is version %d, while OpenLP '
|
||||
'expects version %d. The database will not be loaded.'
|
||||
'\n\nDatabase: %s') % \
|
||||
(db_ver, up_ver, self.db_url)
|
||||
translate('OpenLP.Manager', 'The database being loaded was created in a more recent version of '
|
||||
'OpenLP. The database is version %d, while OpenLP expects version %d. The database will not '
|
||||
'be loaded.\n\nDatabase: %s') % (db_ver, up_ver, self.db_url)
|
||||
)
|
||||
return
|
||||
try:
|
||||
|
@ -39,6 +39,7 @@ from openlp.core.lib import build_icon, ScreenList
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class OpenLPDockWidget(QtGui.QDockWidget):
|
||||
"""
|
||||
Custom DockWidget class to handle events
|
||||
|
@ -35,6 +35,7 @@ from PyQt4 import QtCore
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class EventReceiver(QtCore.QObject):
|
||||
"""
|
||||
Class to allow events to be passed from different parts of the system. This
|
||||
|
@ -33,6 +33,7 @@ import cPickle
|
||||
|
||||
from openlp.core.lib import translate, Settings
|
||||
|
||||
|
||||
class FormattingTags(object):
|
||||
"""
|
||||
Static Class to HTML Tags to be access around the code the list is managed
|
||||
|
@ -207,6 +207,7 @@ sup {
|
||||
</html>
|
||||
"""
|
||||
|
||||
|
||||
def build_html(item, screen, islive, background, image=None,
|
||||
plugins=None):
|
||||
"""
|
||||
@ -264,6 +265,7 @@ def build_html(item, screen, islive, background, image=None,
|
||||
build_lyrics_html(item, webkitvers))
|
||||
return html
|
||||
|
||||
|
||||
def webkit_version():
|
||||
"""
|
||||
Return the Webkit version in use.
|
||||
@ -276,6 +278,7 @@ def webkit_version():
|
||||
webkitvers = 0
|
||||
return webkitvers
|
||||
|
||||
|
||||
def build_background_css(item, width, height):
|
||||
"""
|
||||
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)
|
||||
return background
|
||||
|
||||
|
||||
def build_lyrics_css(item, webkitvers):
|
||||
"""
|
||||
Build the lyrics display css
|
||||
@ -384,6 +388,7 @@ def build_lyrics_css(item, webkitvers):
|
||||
lyrics_css = style % (lyricstable, lyrics, lyricsmain, outline, shadow)
|
||||
return lyrics_css
|
||||
|
||||
|
||||
def build_lyrics_outline_css(theme, is_shadow=False):
|
||||
"""
|
||||
Build the css which controls the theme outline
|
||||
@ -407,6 +412,7 @@ def build_lyrics_outline_css(theme, is_shadow=False):
|
||||
else:
|
||||
return u''
|
||||
|
||||
|
||||
def build_lyrics_format_css(theme, width, height):
|
||||
"""
|
||||
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; '
|
||||
return lyrics
|
||||
|
||||
|
||||
def build_lyrics_html(item, webkitvers):
|
||||
"""
|
||||
Build the HTML required to show the lyrics
|
||||
@ -480,6 +487,7 @@ def build_lyrics_html(item, webkitvers):
|
||||
u'class="lyricscell lyricsmain"></div></div>'
|
||||
return lyrics
|
||||
|
||||
|
||||
def build_footer_css(item, height):
|
||||
"""
|
||||
Build the display of the item footer
|
||||
|
@ -43,12 +43,19 @@ from openlp.core.lib import resize_image, image_to_byte, Receiver, Registry, Scr
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class ImageThread(QtCore.QThread):
|
||||
"""
|
||||
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.
|
||||
"""
|
||||
def __init__(self, manager):
|
||||
"""
|
||||
Constructor for the thread class.
|
||||
|
||||
``manager``
|
||||
The image manager.
|
||||
"""
|
||||
QtCore.QThread.__init__(self, None)
|
||||
self.imageManager = manager
|
||||
|
||||
@ -181,6 +188,9 @@ class ImageManager(QtCore.QObject):
|
||||
log.info(u'Image Manager loaded')
|
||||
|
||||
def __init__(self):
|
||||
"""
|
||||
Consutructor for the image manager.
|
||||
"""
|
||||
QtCore.QObject.__init__(self)
|
||||
Registry().register(u'image_manager', self)
|
||||
currentScreen = ScreenList().current
|
||||
|
@ -35,6 +35,7 @@ from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.lib import Receiver
|
||||
|
||||
|
||||
class ListWidgetWithDnD(QtGui.QListWidget):
|
||||
"""
|
||||
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):
|
||||
"""
|
||||
Drag and drop event does not care what data is selected
|
||||
as the recipient will use events to request the data move
|
||||
just tell it what plugin to call
|
||||
Drag and drop event does not care what data is selected as the recipient will use events to request the data
|
||||
move just tell it what plugin to call
|
||||
"""
|
||||
if event.buttons() != QtCore.Qt.LeftButton:
|
||||
event.ignore()
|
||||
@ -75,12 +75,18 @@ class ListWidgetWithDnD(QtGui.QListWidget):
|
||||
drag.start(QtCore.Qt.CopyAction)
|
||||
|
||||
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():
|
||||
event.accept()
|
||||
else:
|
||||
event.ignore()
|
||||
|
||||
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():
|
||||
event.setDropAction(QtCore.Qt.CopyAction)
|
||||
event.accept()
|
||||
|
@ -35,14 +35,14 @@ import re
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.lib import OpenLPToolbar, ServiceItem, StringContent, build_icon, translate, Receiver, \
|
||||
ListWidgetWithDnD, ServiceItemContext, Settings, Registry, UiStrings
|
||||
from openlp.core.lib import OpenLPToolbar, ServiceItem, StringContent, Receiver, ListWidgetWithDnD, \
|
||||
ServiceItemContext, Settings, Registry, UiStrings, build_icon, translate
|
||||
from openlp.core.lib.searchedit import SearchEdit
|
||||
from openlp.core.lib.ui import create_widget_action, critical_error_message_box
|
||||
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class MediaManagerItem(QtGui.QWidget):
|
||||
"""
|
||||
MediaManagerItem is a helper widget for plugins.
|
||||
@ -345,15 +345,15 @@ class MediaManagerItem(QtGui.QWidget):
|
||||
"""
|
||||
new_files = []
|
||||
error_shown = False
|
||||
for file in files:
|
||||
type = file.split(u'.')[-1]
|
||||
if type.lower() not in self.onNewFileMasks:
|
||||
for file_name in files:
|
||||
file_type = file_name.split(u'.')[-1]
|
||||
if file_type.lower() not in self.onNewFileMasks:
|
||||
if not error_shown:
|
||||
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
|
||||
else:
|
||||
new_files.append(file)
|
||||
new_files.append(file_name)
|
||||
if 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.'))
|
||||
|
||||
def contextMenu(self, point):
|
||||
"""
|
||||
Display a context menu
|
||||
"""
|
||||
item = self.listView.itemAt(point)
|
||||
# Decide if we have to show the context menu or not.
|
||||
if item is None:
|
||||
@ -412,6 +415,9 @@ class MediaManagerItem(QtGui.QWidget):
|
||||
return file_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')
|
||||
|
||||
def onNewClick(self):
|
||||
@ -427,6 +433,9 @@ class MediaManagerItem(QtGui.QWidget):
|
||||
pass
|
||||
|
||||
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')
|
||||
|
||||
def onFocus(self):
|
||||
@ -438,6 +447,9 @@ class MediaManagerItem(QtGui.QWidget):
|
||||
|
||||
def generateSlideData(self, serviceItem, item=None, xmlVersion=False, remote=False,
|
||||
context=ServiceItemContext.Live):
|
||||
"""
|
||||
Generate the slide data. Needs to be implemented by the plugin.
|
||||
"""
|
||||
raise NotImplementedError(u'MediaManagerItem.generateSlideData needs to be defined by the plugin')
|
||||
|
||||
def onDoubleClicked(self):
|
||||
@ -486,6 +498,9 @@ class MediaManagerItem(QtGui.QWidget):
|
||||
self.goLive()
|
||||
|
||||
def goLive(self, item_id=None, remote=False):
|
||||
"""
|
||||
Make the currently selected item go live.
|
||||
"""
|
||||
log.debug(u'%s Live requested', self.plugin.name)
|
||||
item = None
|
||||
if item_id:
|
||||
@ -499,6 +514,9 @@ class MediaManagerItem(QtGui.QWidget):
|
||||
self.live_controller.add_service_item(serviceItem)
|
||||
|
||||
def createItemFromId(self, item_id):
|
||||
"""
|
||||
Create a media item from an item id.
|
||||
"""
|
||||
item = QtGui.QListWidgetItem()
|
||||
item.setData(QtCore.Qt.UserRole, item_id)
|
||||
return item
|
||||
@ -522,6 +540,9 @@ class MediaManagerItem(QtGui.QWidget):
|
||||
self.addToService(item)
|
||||
|
||||
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)
|
||||
if serviceItem:
|
||||
serviceItem.from_plugin = False
|
||||
@ -687,4 +708,3 @@ class MediaManagerItem(QtGui.QWidget):
|
||||
return self._service_manager
|
||||
|
||||
service_manager = property(_get_service_manager)
|
||||
|
||||
|
@ -38,6 +38,7 @@ from openlp.core.utils import get_application_version
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class PluginStatus(object):
|
||||
"""
|
||||
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.endGroup()
|
||||
|
||||
|
||||
def usesTheme(self, 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
|
||||
|
||||
main_window = property(_get_main_window)
|
||||
|
||||
|
@ -37,6 +37,7 @@ from openlp.core.lib import Plugin, PluginStatus, Registry
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class PluginManager(object):
|
||||
"""
|
||||
This is the Plugin manager, which loads all the plugins,
|
||||
|
@ -34,6 +34,7 @@ import sys
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class Registry(object):
|
||||
"""
|
||||
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
|
||||
|
||||
def __new__(cls):
|
||||
"""
|
||||
Re-implement the __new__ method to make sure we create a true singleton.
|
||||
"""
|
||||
if not cls.__instance__:
|
||||
cls.__instance__ = object.__new__(cls)
|
||||
return cls.__instance__
|
||||
@ -61,7 +65,6 @@ class Registry(object):
|
||||
registry.running_under_test = True
|
||||
return registry
|
||||
|
||||
|
||||
def get(self, key):
|
||||
"""
|
||||
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
|
||||
(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)
|
||||
raise KeyError(u'Invalid Method call for key %s' % key)
|
||||
return
|
||||
if key in self.service_list:
|
||||
del self.service_list[key]
|
||||
|
||||
del self.service_list[key]
|
||||
|
@ -315,7 +315,7 @@ class Renderer(object):
|
||||
if text_contains_split:
|
||||
text = slides[-1] + u'\n[---]\n' + text
|
||||
else:
|
||||
text = slides[-1] + u'\n'+ text
|
||||
text = slides[-1] + u'\n' + text
|
||||
text = text.replace(u'<br>', u'\n')
|
||||
else:
|
||||
pages.extend(slides)
|
||||
@ -543,7 +543,7 @@ class Renderer(object):
|
||||
end_tags.reverse()
|
||||
# Remove the indexes.
|
||||
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):
|
||||
"""
|
||||
|
@ -37,7 +37,6 @@ from PyQt4 import QtCore
|
||||
|
||||
from openlp.core.lib import Receiver, translate
|
||||
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@ -51,6 +50,9 @@ class ScreenList(object):
|
||||
__instance__ = None
|
||||
|
||||
def __new__(cls):
|
||||
"""
|
||||
Re-implement __new__ to create a true singleton.
|
||||
"""
|
||||
if not cls.__instance__:
|
||||
cls.__instance__ = object.__new__(cls)
|
||||
return cls.__instance__
|
||||
|
@ -36,6 +36,7 @@ from openlp.core.lib.ui import create_widget_action
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class SearchEdit(QtGui.QLineEdit):
|
||||
"""
|
||||
This is a specialised QLineEdit with a "clear" button inside for searches.
|
||||
|
@ -43,6 +43,7 @@ from openlp.core.lib import build_icon, clean_tags, expand_tags, translate, Imag
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class ServiceItemType(object):
|
||||
"""
|
||||
Defines the type of service item
|
||||
@ -607,7 +608,7 @@ class ServiceItem(object):
|
||||
``theme``
|
||||
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._new_item()
|
||||
self.render()
|
||||
|
@ -127,8 +127,8 @@ class Settings(QtCore.QSettings):
|
||||
u'general/enable slide loop': True,
|
||||
u'general/show splash': True,
|
||||
u'general/screen blank': False,
|
||||
# The oder display settings (display position and dimensions) are defined in the ScreenList class due to crycle
|
||||
# dependency.
|
||||
# The other display settings (display position and dimensions) are defined in the ScreenList class due to a
|
||||
# circular dependency.
|
||||
u'general/override position': False,
|
||||
u'general/loop delay': 5,
|
||||
u'general/songselect username': u'',
|
||||
@ -276,6 +276,9 @@ class Settings(QtCore.QSettings):
|
||||
Settings.__default_settings__[u'advanced/default service name'] = UiStrings().DefaultServiceName
|
||||
|
||||
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:
|
||||
QtCore.QSettings.__init__(self, Settings.__file_path__, Settings.IniFormat)
|
||||
else:
|
||||
@ -340,4 +343,3 @@ class Settings(QtCore.QSettings):
|
||||
if isinstance(default_value, int):
|
||||
return int(setting)
|
||||
return setting
|
||||
|
||||
|
@ -33,9 +33,6 @@ format.
|
||||
"""
|
||||
import os
|
||||
|
||||
from PyQt4 import QtCore
|
||||
|
||||
from openlp.core.lib import Settings
|
||||
from openlp.core.utils import AppLocation
|
||||
|
||||
|
||||
|
@ -26,9 +26,14 @@
|
||||
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
|
||||
# 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
|
||||
|
||||
|
||||
class SettingsTab(QtGui.QWidget):
|
||||
"""
|
||||
SettingsTab is a helper widget for plugins to define Tabs for the settings
|
||||
|
@ -26,6 +26,10 @@
|
||||
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
|
||||
# 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 re
|
||||
|
||||
@ -47,11 +51,15 @@ from openlp.core.lib.ui import create_action
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class SpellTextEdit(QtGui.QPlainTextEdit):
|
||||
"""
|
||||
Spell checking widget based on QPlanTextEdit.
|
||||
"""
|
||||
def __init__(self, parent=None, formattingTagsAllowed=True):
|
||||
"""
|
||||
Constructor.
|
||||
"""
|
||||
global ENCHANT_AVAILABLE
|
||||
QtGui.QPlainTextEdit.__init__(self, parent)
|
||||
self.formattingTagsAllowed = formattingTagsAllowed
|
||||
@ -171,6 +179,9 @@ class Highlighter(QtGui.QSyntaxHighlighter):
|
||||
WORDS = u'(?iu)[\w\']+'
|
||||
|
||||
def __init__(self, *args):
|
||||
"""
|
||||
Constructor
|
||||
"""
|
||||
QtGui.QSyntaxHighlighter.__init__(self, *args)
|
||||
self.spellingDictionary = None
|
||||
|
||||
@ -197,5 +208,8 @@ class SpellAction(QtGui.QAction):
|
||||
correct = QtCore.pyqtSignal(unicode)
|
||||
|
||||
def __init__(self, *args):
|
||||
"""
|
||||
Constructor
|
||||
"""
|
||||
QtGui.QAction.__init__(self, *args)
|
||||
self.triggered.connect(lambda x: self.correct.emit(self.text()))
|
||||
|
@ -86,6 +86,7 @@ BLANK_THEME_XML = \
|
||||
</theme>
|
||||
'''
|
||||
|
||||
|
||||
class ThemeLevel(object):
|
||||
"""
|
||||
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]+)')
|
||||
SECOND_CAMEL_REGEX = re.compile(u'([a-z0-9])([A-Z])')
|
||||
|
||||
def __init__(self):
|
||||
"""
|
||||
Initialise the theme object.
|
||||
@ -608,13 +610,15 @@ class ThemeXML(object):
|
||||
self.add_background_gradient(
|
||||
self.background_start_color,
|
||||
self.background_end_color,
|
||||
self.background_direction)
|
||||
self.background_direction
|
||||
)
|
||||
elif self.background_type == BackgroundType.to_string(BackgroundType.Image):
|
||||
filename = os.path.split(self.background_filename)[1]
|
||||
self.add_background_image(filename, self.background_border_color)
|
||||
elif self.background_type == BackgroundType.to_string(BackgroundType.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_size,
|
||||
self.font_main_override, u'main',
|
||||
@ -630,14 +634,16 @@ class ThemeXML(object):
|
||||
self.font_main_outline_size,
|
||||
self.font_main_shadow,
|
||||
self.font_main_shadow_color,
|
||||
self.font_main_shadow_size)
|
||||
self.add_font(self.font_footer_name,
|
||||
self.font_main_shadow_size
|
||||
)
|
||||
self.add_font(
|
||||
self.font_footer_name,
|
||||
self.font_footer_color,
|
||||
self.font_footer_size,
|
||||
self.font_footer_override, u'footer',
|
||||
self.font_footer_bold,
|
||||
self.font_footer_italics,
|
||||
0, # line adjustment
|
||||
0, # line adjustment
|
||||
self.font_footer_x,
|
||||
self.font_footer_y,
|
||||
self.font_footer_width,
|
||||
@ -647,7 +653,10 @@ class ThemeXML(object):
|
||||
self.font_footer_outline_size,
|
||||
self.font_footer_shadow,
|
||||
self.font_footer_shadow_color,
|
||||
self.font_footer_shadow_size)
|
||||
self.add_display(self.display_horizontal_align,
|
||||
self.font_footer_shadow_size
|
||||
)
|
||||
self.add_display(
|
||||
self.display_horizontal_align,
|
||||
self.display_vertical_align,
|
||||
self.display_slide_transition)
|
||||
self.display_slide_transition
|
||||
)
|
||||
|
@ -37,6 +37,7 @@ from openlp.core.lib.ui import create_widget_action
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class OpenLPToolbar(QtGui.QToolBar):
|
||||
"""
|
||||
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)
|
||||
else:
|
||||
log.warn(u'No handle "%s" in actions list.', unicode(handle))
|
||||
|
||||
|
@ -111,8 +111,8 @@ class UiStrings(object):
|
||||
self.OLPV2x = translate('OpenLP.Ui', 'OpenLP 2.1')
|
||||
self.OpenLPStart = translate('OpenLP.Ui', 'OpenLP is already running. Do you wish to continue?')
|
||||
self.OpenService = translate('OpenLP.Ui', 'Open service.')
|
||||
self.PlaySlidesInLoop = translate('OpenLP.Ui','Play Slides in Loop')
|
||||
self.PlaySlidesToEnd = translate('OpenLP.Ui','Play Slides to End')
|
||||
self.PlaySlidesInLoop = translate('OpenLP.Ui', 'Play Slides in Loop')
|
||||
self.PlaySlidesToEnd = translate('OpenLP.Ui', 'Play Slides to End')
|
||||
self.Preview = translate('OpenLP.Ui', 'Preview')
|
||||
self.PrintService = translate('OpenLP.Ui', 'Print Service')
|
||||
self.ReplaceBG = translate('OpenLP.Ui', 'Replace Background')
|
||||
@ -144,4 +144,3 @@ class UiStrings(object):
|
||||
self.Version = translate('OpenLP.Ui', 'Version')
|
||||
self.View = translate('OpenLP.Ui', 'View')
|
||||
self.ViewMode = translate('OpenLP.Ui', 'View Mode')
|
||||
|
||||
|
@ -32,3 +32,5 @@ OpenLP when displaying a song or a scripture.
|
||||
"""
|
||||
|
||||
from openlp.core.theme.theme import Theme
|
||||
|
||||
__all__ = ['Theme']
|
||||
|
@ -37,11 +37,21 @@ from xml.etree.ElementTree import ElementTree, XML
|
||||
from PyQt4 import QtGui
|
||||
|
||||
DELPHI_COLORS = {
|
||||
u'clAqua': 0x00FFFF, u'clBlack': 0x000000, u'clBlue': 0x0000FF,
|
||||
u'clFuchsia': 0xFF00FF, 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'clAqua': 0x00FFFF,
|
||||
u'clBlack': 0x000000,
|
||||
u'clBlue': 0x0000FF,
|
||||
u'clFuchsia': 0xFF00FF,
|
||||
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
|
||||
}
|
||||
|
||||
@ -66,6 +76,7 @@ BLANK_STYLE_XML = \
|
||||
</Theme>
|
||||
'''
|
||||
|
||||
|
||||
class Theme(object):
|
||||
"""
|
||||
Provide a class wrapper storing data from an XML theme
|
||||
@ -205,10 +216,12 @@ class Theme(object):
|
||||
val = element_text
|
||||
# strings need special handling to sort the colours out
|
||||
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:
|
||||
val = int(element_text[1:], 16)
|
||||
except ValueError: # nope
|
||||
except ValueError:
|
||||
# nope
|
||||
pass
|
||||
elif element_text in DELPHI_COLORS:
|
||||
val = DELPHI_COLORS[element_text]
|
||||
@ -222,9 +235,9 @@ class Theme(object):
|
||||
isinstance(val, int))):
|
||||
# convert to a wx.Colour
|
||||
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:
|
||||
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)
|
||||
|
||||
def __str__(self):
|
||||
|
@ -31,7 +31,6 @@ The :mod:`ui` module provides the core user interface for OpenLP
|
||||
"""
|
||||
|
||||
|
||||
|
||||
class HideMode(object):
|
||||
"""
|
||||
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 thememanager import ThemeManager
|
||||
|
||||
__all__ = ['SplashScreen', 'AboutForm', 'SettingsForm', 'MainDisplay',
|
||||
'SlideController', 'ServiceManager', 'ThemeManager', 'MediaDockManager',
|
||||
'ServiceItemEditForm', 'FirstTimeForm']
|
||||
__all__ = ['SplashScreen', 'AboutForm', 'SettingsForm', 'MainDisplay', 'SlideController', 'ServiceManager',
|
||||
'ThemeManager', 'MediaDockManager', 'ServiceItemEditForm', 'FirstTimeForm', 'FirstTimeLanguageForm', 'ThemeForm',
|
||||
'ThemeLayoutForm', 'FileRenameForm', 'StartTimeForm', 'MainDisplay', 'Display', 'ServiceNoteForm',
|
||||
'SlideController', 'DisplayController', 'GeneralTab', 'ThemesTab', 'AdvancedTab', 'PluginForm',
|
||||
'FormattingTagForm', 'ShortcutListForm']
|
||||
|
@ -34,7 +34,14 @@ from openlp.core.lib.ui import create_button, create_button_box
|
||||
|
||||
|
||||
class Ui_AboutDialog(object):
|
||||
"""
|
||||
The actual GUI widgets for the About form.
|
||||
"""
|
||||
|
||||
def setupUi(self, aboutDialog):
|
||||
"""
|
||||
Set up the UI for the dialog.
|
||||
"""
|
||||
aboutDialog.setObjectName(u'aboutDialog')
|
||||
aboutDialog.setWindowIcon(build_icon(u':/icon/openlp-logo-16x16.png'))
|
||||
self.aboutDialogLayout = QtGui.QVBoxLayout(aboutDialog)
|
||||
@ -80,6 +87,9 @@ class Ui_AboutDialog(object):
|
||||
self.aboutNotebook.setCurrentIndex(0)
|
||||
|
||||
def retranslateUi(self, aboutDialog):
|
||||
"""
|
||||
Dynamically translate the UI.
|
||||
"""
|
||||
aboutDialog.setWindowTitle(u'%s OpenLP' % UiStrings().About)
|
||||
self.aboutTextEdit.setPlainText(translate('OpenLP.AboutForm',
|
||||
'OpenLP <version><revision> - Open Source Lyrics '
|
||||
@ -134,17 +144,17 @@ class Ui_AboutDialog(object):
|
||||
u'en_ZA': [u'Raoul "superfly" Snyman',
|
||||
u'Johan "nuvolari" Mynhardt'],
|
||||
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'fi': [u'Jori "joribu" Brander', u'Tobbe "tobbeb" Bildo'],
|
||||
u'fr': [u'Stephan\xe9 "stbrunner" Brunner', u'Jeremie "jnau05"',
|
||||
u'Carl "carl.fischer" Fischer'],
|
||||
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'nb': [u'Atle "pendlaren" Weibell', u'Frode "frodus" Woldsund'],
|
||||
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'Gustavo Bim', u'Rog\xeanio Bel\xe9m', u'Samuel'
|
||||
u'Simon "samscudder" Scudder', u'Van Der Fran'],
|
||||
@ -260,7 +270,7 @@ class Ui_AboutDialog(object):
|
||||
u'\n '.join(documentors)))
|
||||
self.aboutNotebook.setTabText(self.aboutNotebook.indexOf(self.creditsTab),
|
||||
translate('OpenLP.AboutForm', 'Credits'))
|
||||
copyright = translate('OpenLP.AboutForm',
|
||||
copyright_note = translate('OpenLP.AboutForm',
|
||||
'Copyright \xa9 2004-2013 %s\n'
|
||||
'Portions copyright \xa9 2004-2013 %s') % (u'Raoul Snyman',
|
||||
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 '
|
||||
'what you want to do, use the GNU Lesser General Public 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),
|
||||
translate('OpenLP.AboutForm', 'License'))
|
||||
self.volunteerButton.setText(translate('OpenLP.AboutForm', 'Volunteer'))
|
||||
|
@ -26,6 +26,9 @@
|
||||
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
|
||||
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
||||
###############################################################################
|
||||
"""
|
||||
The About dialog.
|
||||
"""
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
@ -33,6 +36,7 @@ from aboutdialog import Ui_AboutDialog
|
||||
from openlp.core.lib import translate
|
||||
from openlp.core.utils import get_application_version
|
||||
|
||||
|
||||
class AboutForm(QtGui.QDialog, Ui_AboutDialog):
|
||||
"""
|
||||
The About dialog
|
||||
|
@ -36,7 +36,7 @@ import sys
|
||||
|
||||
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.lib import SlideLimits
|
||||
|
||||
@ -137,7 +137,7 @@ class AdvancedTab(SettingsTab):
|
||||
self.dataDirectoryLayout = QtGui.QFormLayout(self.dataDirectoryGroupBox)
|
||||
self.dataDirectoryLayout.setObjectName(u'dataDirectoryLayout')
|
||||
self.dataDirectoryCurrentLabel = QtGui.QLabel(self.dataDirectoryGroupBox)
|
||||
self.dataDirectoryCurrentLabel.setObjectName( u'dataDirectoryCurrentLabel')
|
||||
self.dataDirectoryCurrentLabel.setObjectName(u'dataDirectoryCurrentLabel')
|
||||
self.dataDirectoryLabel = QtGui.QLabel(self.dataDirectoryGroupBox)
|
||||
self.dataDirectoryLabel.setObjectName(u'dataDirectoryLabel')
|
||||
self.dataDirectoryNewLabel = QtGui.QLabel(self.dataDirectoryGroupBox)
|
||||
@ -299,7 +299,8 @@ class AdvancedTab(SettingsTab):
|
||||
self.serviceNameLabel.setText(translate('OpenLP.AdvancedTab', 'Name:'))
|
||||
self.serviceNameEdit.setToolTip(translate('OpenLP.AdvancedTab', 'Consult the OpenLP manual for usage.'))
|
||||
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.hideMouseGroupBox.setTitle(translate('OpenLP.AdvancedTab', 'Mouse Cursor'))
|
||||
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 '
|
||||
'OpenLP data files. These files WILL be replaced during a copy.'))
|
||||
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
|
||||
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:'))
|
||||
@ -440,11 +441,16 @@ class AdvancedTab(SettingsTab):
|
||||
Receiver.send_message(u'slidecontroller_update_slide_limits')
|
||||
|
||||
def cancel(self):
|
||||
# Dialogue was cancelled, remove any pending data path change.
|
||||
"""
|
||||
Dialogue was cancelled, remove any pending data path change.
|
||||
"""
|
||||
self.onDataDirectoryCancelButtonClicked()
|
||||
SettingsTab.cancel(self)
|
||||
|
||||
def serviceNameCheckBoxToggled(self, default_service_enabled):
|
||||
"""
|
||||
Toggle the service name check box.
|
||||
"""
|
||||
self.serviceNameDay.setEnabled(default_service_enabled)
|
||||
time_enabled = default_service_enabled and self.serviceNameDay.currentIndex() is not 7
|
||||
self.serviceNameTime.setEnabled(time_enabled)
|
||||
@ -452,6 +458,9 @@ class AdvancedTab(SettingsTab):
|
||||
self.serviceNameRevertButton.setEnabled(default_service_enabled)
|
||||
|
||||
def generateServiceNameExample(self):
|
||||
"""
|
||||
Generate an example service name.
|
||||
"""
|
||||
preset_is_valid = True
|
||||
if self.serviceNameDay.currentIndex() == 7:
|
||||
local_time = datetime.now()
|
||||
@ -461,8 +470,10 @@ class AdvancedTab(SettingsTab):
|
||||
if day_delta < 0:
|
||||
day_delta += 7
|
||||
time = now + timedelta(days=day_delta)
|
||||
local_time = time.replace(hour = self.serviceNameTime.time().hour(),
|
||||
minute = self.serviceNameTime.time().minute())
|
||||
local_time = time.replace(
|
||||
hour=self.serviceNameTime.time().hour(),
|
||||
minute=self.serviceNameTime.time().minute()
|
||||
)
|
||||
try:
|
||||
service_name_example = format_time(unicode(self.serviceNameEdit.text()), local_time)
|
||||
except ValueError:
|
||||
@ -471,20 +482,32 @@ class AdvancedTab(SettingsTab):
|
||||
return preset_is_valid, service_name_example
|
||||
|
||||
def updateServiceNameExample(self, returned_value):
|
||||
"""
|
||||
Update the example service name.
|
||||
"""
|
||||
if not self.shouldUpdateServiceNameExample:
|
||||
return
|
||||
name_example = self.generateServiceNameExample()[1]
|
||||
self.serviceNameExample.setText(name_example)
|
||||
|
||||
def onServiceNameDayChanged(self, service_day):
|
||||
"""
|
||||
React to the day of the service name changing.
|
||||
"""
|
||||
self.serviceNameTime.setEnabled(service_day is not 7)
|
||||
self.updateServiceNameExample(None)
|
||||
|
||||
def onServiceNameRevertButtonClicked(self):
|
||||
"""
|
||||
Revert to the default service name.
|
||||
"""
|
||||
self.serviceNameEdit.setText(UiStrings().DefaultServiceName)
|
||||
self.serviceNameEdit.setFocus()
|
||||
|
||||
def onDefaultColorButtonClicked(self):
|
||||
"""
|
||||
Select the background colour of the default display screen.
|
||||
"""
|
||||
new_color = QtGui.QColorDialog.getColor(
|
||||
QtGui.QColor(self.defaultColor), self)
|
||||
if new_color.isValid():
|
||||
@ -492,6 +515,9 @@ class AdvancedTab(SettingsTab):
|
||||
self.defaultColorButton.setStyleSheet(u'background-color: %s' % self.defaultColor)
|
||||
|
||||
def onDefaultBrowseButtonClicked(self):
|
||||
"""
|
||||
Select an image for the default display screen.
|
||||
"""
|
||||
file_filters = u'%s;;%s (*.*) (*)' % (get_images_filter(),
|
||||
UiStrings().AllFiles)
|
||||
filename = QtGui.QFileDialog.getOpenFileName(self,
|
||||
@ -506,9 +532,9 @@ class AdvancedTab(SettingsTab):
|
||||
"""
|
||||
old_root_path = unicode(self.dataDirectoryLabel.text())
|
||||
# Get the new directory location.
|
||||
new_data_path = QtGui.QFileDialog.getExistingDirectory(self,
|
||||
translate('OpenLP.AdvancedTab', 'Select Data Directory Location'), old_root_path,
|
||||
options = QtGui.QFileDialog.ShowDirsOnly)
|
||||
new_data_path = QtGui.QFileDialog.getExistingDirectory(
|
||||
self, translate('OpenLP.AdvancedTab', 'Select Data Directory Location'), old_root_path,
|
||||
options=QtGui.QFileDialog.ShowDirsOnly)
|
||||
# Set the new data path.
|
||||
if new_data_path:
|
||||
new_data_path = os.path.normpath(new_data_path)
|
||||
@ -558,6 +584,9 @@ class AdvancedTab(SettingsTab):
|
||||
self.onDataDirectoryCancelButtonClicked()
|
||||
|
||||
def onDataDirectoryCopyCheckBoxToggled(self):
|
||||
"""
|
||||
Copy existing data when you change your data directory.
|
||||
"""
|
||||
Receiver.send_message(u'set_copy_data',
|
||||
self.dataDirectoryCopyCheckBox.isChecked())
|
||||
if self.dataExists:
|
||||
@ -566,7 +595,10 @@ class AdvancedTab(SettingsTab):
|
||||
else:
|
||||
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')
|
||||
self.dataDirectoryCopyCheckBox.show()
|
||||
if os.path.exists(test_path):
|
||||
@ -602,6 +634,9 @@ class AdvancedTab(SettingsTab):
|
||||
self.newDataDirectoryHasFilesLabel.hide()
|
||||
|
||||
def onDefaultRevertButtonClicked(self):
|
||||
"""
|
||||
Revert the default screen back to the default settings.
|
||||
"""
|
||||
self.defaultFileEdit.setText(u':/graphics/openlp-splash-screen.png')
|
||||
self.defaultFileEdit.setFocus()
|
||||
|
||||
@ -615,10 +650,19 @@ class AdvancedTab(SettingsTab):
|
||||
self.displayChanged = True
|
||||
|
||||
def onEndSlideButtonClicked(self):
|
||||
"""
|
||||
Set the slide wrap option.
|
||||
"""
|
||||
self.slide_limits = SlideLimits.End
|
||||
|
||||
def onWrapSlideButtonClicked(self):
|
||||
"""
|
||||
Set the slide wrap option.
|
||||
"""
|
||||
self.slide_limits = SlideLimits.Wrap
|
||||
|
||||
def onnextItemButtonClicked(self):
|
||||
"""
|
||||
Set the slide wrap option.
|
||||
"""
|
||||
self.slide_limits = SlideLimits.Next
|
||||
|
@ -26,14 +26,24 @@
|
||||
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
|
||||
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
||||
###############################################################################
|
||||
"""
|
||||
The GUI widgets of the exception dialog.
|
||||
"""
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.lib import translate
|
||||
from openlp.core.lib.ui import create_button, create_button_box
|
||||
|
||||
|
||||
class Ui_ExceptionDialog(object):
|
||||
"""
|
||||
The GUI widgets of the exception dialog.
|
||||
"""
|
||||
def setupUi(self, exceptionDialog):
|
||||
"""
|
||||
Set up the UI.
|
||||
"""
|
||||
exceptionDialog.setObjectName(u'exceptionDialog')
|
||||
self.exceptionLayout = QtGui.QVBoxLayout(exceptionDialog)
|
||||
self.exceptionLayout.setObjectName(u'exceptionLayout')
|
||||
@ -66,7 +76,7 @@ class Ui_ExceptionDialog(object):
|
||||
self.exceptionLayout.addWidget(self.exceptionTextEdit)
|
||||
self.sendReportButton = create_button(exceptionDialog, u'sendReportButton',
|
||||
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)
|
||||
self.attachFileButton = create_button(exceptionDialog, u'attachFileButton',
|
||||
icon=u':/general/general_open.png', click=self.onAttachFileButtonClicked)
|
||||
@ -79,6 +89,9 @@ class Ui_ExceptionDialog(object):
|
||||
QtCore.SIGNAL(u'textChanged()'), self.onDescriptionUpdated)
|
||||
|
||||
def retranslateUi(self, exceptionDialog):
|
||||
"""
|
||||
Translate the widgets on the fly.
|
||||
"""
|
||||
exceptionDialog.setWindowTitle(translate('OpenLP.ExceptionDialog', 'Error Occurred'))
|
||||
self.descriptionExplanation.setText(translate('OpenLP.ExceptionDialog',
|
||||
'Please enter a description of what you were doing to cause this '
|
||||
|
@ -26,6 +26,9 @@
|
||||
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
|
||||
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
||||
###############################################################################
|
||||
"""
|
||||
The actual exception dialog form.
|
||||
"""
|
||||
import logging
|
||||
import re
|
||||
import os
|
||||
@ -92,22 +95,32 @@ from exceptiondialog import Ui_ExceptionDialog
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class ExceptionForm(QtGui.QDialog, Ui_ExceptionDialog):
|
||||
"""
|
||||
The exception dialog
|
||||
"""
|
||||
def __init__(self, parent):
|
||||
"""
|
||||
Constructor.
|
||||
"""
|
||||
QtGui.QDialog.__init__(self, parent)
|
||||
self.setupUi(self)
|
||||
self.settingsSection = u'crashreport'
|
||||
|
||||
def exec_(self):
|
||||
"""
|
||||
Show the dialog.
|
||||
"""
|
||||
self.descriptionTextEdit.setPlainText(u'')
|
||||
self.onDescriptionUpdated()
|
||||
self.fileAttachment = None
|
||||
return QtGui.QDialog.exec_(self)
|
||||
|
||||
def _createReport(self):
|
||||
"""
|
||||
Create an exception report.
|
||||
"""
|
||||
openlp_version = get_application_version()
|
||||
description = self.descriptionTextEdit.toPlainText()
|
||||
traceback = self.exceptionTextEdit.toPlainText()
|
||||
@ -199,6 +212,9 @@ class ExceptionForm(QtGui.QDialog, Ui_ExceptionDialog):
|
||||
QtGui.QDesktopServices.openUrl(mailto_url)
|
||||
|
||||
def onDescriptionUpdated(self):
|
||||
"""
|
||||
Update the minimum number of characters needed in the description.
|
||||
"""
|
||||
count = int(20 - len(self.descriptionTextEdit.toPlainText()))
|
||||
if count < 0:
|
||||
count = 0
|
||||
@ -209,6 +225,9 @@ class ExceptionForm(QtGui.QDialog, Ui_ExceptionDialog):
|
||||
translate('OpenLP.ExceptionDialog', 'Description characters to enter : %s') % count)
|
||||
|
||||
def onAttachFileButtonClicked(self):
|
||||
"""
|
||||
Attache files to the bug report e-mail.
|
||||
"""
|
||||
files = QtGui.QFileDialog.getOpenFileName(
|
||||
self, translate('ImagePlugin.ExceptionDialog', 'Select Attachment'),
|
||||
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)
|
||||
|
||||
def __buttonState(self, state):
|
||||
"""
|
||||
Toggle the button state.
|
||||
"""
|
||||
self.saveReportButton.setEnabled(state)
|
||||
self.sendReportButton.setEnabled(state)
|
||||
|
||||
|
@ -26,14 +26,23 @@
|
||||
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
|
||||
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
||||
###############################################################################
|
||||
|
||||
"""
|
||||
The UI widgets for the rename dialog
|
||||
"""
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.lib import translate
|
||||
from openlp.core.lib.ui import create_button_box
|
||||
|
||||
|
||||
class Ui_FileRenameDialog(object):
|
||||
"""
|
||||
The UI widgets for the rename dialog
|
||||
"""
|
||||
def setupUi(self, fileRenameDialog):
|
||||
"""
|
||||
Set up the UI
|
||||
"""
|
||||
fileRenameDialog.setObjectName(u'fileRenameDialog')
|
||||
fileRenameDialog.resize(300, 10)
|
||||
self.dialogLayout = QtGui.QGridLayout(fileRenameDialog)
|
||||
@ -51,4 +60,7 @@ class Ui_FileRenameDialog(object):
|
||||
self.setMaximumHeight(self.sizeHint().height())
|
||||
|
||||
def retranslateUi(self, fileRenameDialog):
|
||||
"""
|
||||
Translate the UI on the fly.
|
||||
"""
|
||||
self.fileNameLabel.setText(translate('OpenLP.FileRenameForm', 'New File Name:'))
|
||||
|
Loading…
Reference in New Issue
Block a user