trivial clean ups

This commit is contained in:
Andreas Preikschat 2012-04-16 09:02:24 +02:00
parent 01b2b4e5bf
commit 0fdf3b7f7c
5 changed files with 45 additions and 51 deletions

View File

@ -364,7 +364,7 @@ class Renderer(object):
self.web.setVisible(False)
self.web.resize(self.page_width, self.page_height)
self.web_frame = self.web.page().mainFrame()
# Adjust width and height to account for shadow. outline done in css
# Adjust width and height to account for shadow. outline done in css.
html = u"""<!DOCTYPE html><html><head><script>
function show_text(newtext) {
var main = document.getElementById('main');

View File

@ -104,7 +104,7 @@ class SettingsManager(object):
u'%s count' % name, QtCore.QVariant(0)).toInt()[0]
new_count = len(list)
settings.setValue(u'%s count' % name, QtCore.QVariant(new_count))
for counter in range (0, new_count):
for counter in range(new_count):
settings.setValue(
u'%s %d' % (name, counter), QtCore.QVariant(list[counter-1]))
if old_count > new_count:
@ -130,7 +130,7 @@ class SettingsManager(object):
u'%s count' % name, QtCore.QVariant(0)).toInt()[0]
list = []
if list_count:
for counter in range(0, list_count):
for counter in range(list_count):
item = unicode(
settings.value(u'%s %d' % (name, counter)).toString())
if item:

View File

@ -145,11 +145,10 @@ class BiblePlugin(Plugin):
def usesTheme(self, theme):
"""
Called to find out if the bible plugin is currently using a theme.
Returns True if the theme is being used, otherwise returns False.
Returns ``True`` if the theme is being used, otherwise returns
``False``.
"""
if unicode(self.settings_tab.bible_theme) == theme:
return True
return False
return unicode(self.settings_tab.bible_theme) == theme
def renameTheme(self, oldTheme, newTheme):
"""

View File

@ -263,50 +263,48 @@ class PresentationMediaItem(MediaManagerItem):
service_item.add_capability(ItemCapabilities.ProvidesOwnDisplay)
service_item.add_capability(ItemCapabilities.HasDetailedTitleDisplay)
shortname = service_item.shortname
if shortname:
for bitem in items:
filename = unicode(bitem.data(QtCore.Qt.UserRole).toString())
if os.path.exists(filename):
if shortname == self.Automatic:
service_item.shortname = \
self.findControllerByType(filename)
if not service_item.shortname:
return False
controller = self.controllers[service_item.shortname]
(path, name) = os.path.split(filename)
doc = controller.add_document(filename)
if doc.get_thumbnail_path(1, True) is None:
doc.load_presentation()
i = 1
img = doc.get_thumbnail_path(i, True)
if img:
while img:
service_item.add_from_command(path, name, img)
i = i + 1
img = doc.get_thumbnail_path(i, True)
doc.close_presentation()
return True
else:
# File is no longer present
if not remote:
critical_error_message_box(
translate('PresentationPlugin.MediaItem',
'Missing Presentation'),
unicode(translate(
'PresentationPlugin.MediaItem',
'The Presentation %s is incomplete,'
' please reload.')) % filename)
if not shortname:
return False
for bitem in items:
filename = unicode(bitem.data(QtCore.Qt.UserRole).toString())
if os.path.exists(filename):
if shortname == self.Automatic:
service_item.shortname = self.findControllerByType(filename)
if not service_item.shortname:
return False
controller = self.controllers[service_item.shortname]
(path, name) = os.path.split(filename)
doc = controller.add_document(filename)
if doc.get_thumbnail_path(1, True) is None:
doc.load_presentation()
i = 1
img = doc.get_thumbnail_path(i, True)
if img:
while img:
service_item.add_from_command(path, name, img)
i = i + 1
img = doc.get_thumbnail_path(i, True)
doc.close_presentation()
return True
else:
# File is no longer present
critical_error_message_box(
translate('PresentationPlugin.MediaItem',
'Missing Presentation'),
unicode(translate('PresentationPlugin.MediaItem',
'The Presentation %s no longer exists.')) % filename)
if not remote:
critical_error_message_box(
translate('PresentationPlugin.MediaItem',
'Missing Presentation'),
unicode(translate(
'PresentationPlugin.MediaItem',
'The Presentation %s is incomplete,'
' please reload.')) % filename)
return False
else:
return False
else:
# File is no longer present
critical_error_message_box(
translate('PresentationPlugin.MediaItem',
'Missing Presentation'),
unicode(translate('PresentationPlugin.MediaItem',
'The Presentation %s no longer exists.')) % filename)
return False
def findControllerByType(self, filename):
"""

View File

@ -134,10 +134,7 @@ class PresentationPlugin(Plugin):
for controller_class in controller_classes:
controller = controller_class(self)
self.registerControllers(controller)
if self.controllers:
return True
else:
return False
return bool(self.controllers)
def about(self):
"""