More truth testing cleanup - core

This commit is contained in:
Jon Tibble 2009-11-03 18:14:25 +00:00
parent 51915d0e97
commit 84ce96f989
19 changed files with 68 additions and 63 deletions

View File

@ -110,7 +110,7 @@ def contextMenuAction(base, icon, text, slot):
Utility method to help build context menus for plugins Utility method to help build context menus for plugins
""" """
action = QtGui.QAction(text, base) action = QtGui.QAction(text, base)
if icon is not None: if icon:
action.setIcon(buildIcon(icon)) action.setIcon(buildIcon(icon))
QtCore.QObject.connect(action, QtCore.SIGNAL(u'triggered()'), slot) QtCore.QObject.connect(action, QtCore.SIGNAL(u'triggered()'), slot)
return action return action

View File

@ -36,7 +36,7 @@ class OpenLPDockWidget(QtGui.QDockWidget):
""" """
QtGui.QDockWidget.__init__(self, parent) QtGui.QDockWidget.__init__(self, parent)
self.parent = parent self.parent = parent
if name is not None: if name:
self.setObjectName(name) self.setObjectName(name)
self.setFloating(False) self.setFloating(False)
self.log = logging.getLogger(u'OpenLPDockWidget') self.log = logging.getLogger(u'OpenLPDockWidget')

View File

@ -110,7 +110,7 @@ class MediaManagerItem(QtGui.QWidget):
QtGui.QIcon.Normal, QtGui.QIcon.Off) QtGui.QIcon.Normal, QtGui.QIcon.Off)
else: else:
self.icon = None self.icon = None
if title is not None: if title:
self.title = title self.title = title
self.Toolbar = None self.Toolbar = None
self.ServiceItemIconName = None self.ServiceItemIconName = None
@ -364,7 +364,7 @@ class MediaManagerItem(QtGui.QWidget):
self.trUtf8(u'You must select one or more items')) self.trUtf8(u'You must select one or more items'))
log.debug(self.PluginNameShort + u' Preview Requested') log.debug(self.PluginNameShort + u' Preview Requested')
service_item = self.buildServiceItem() service_item = self.buildServiceItem()
if service_item is not None: if service_item:
service_item.fromPlugin = True service_item.fromPlugin = True
self.parent.preview_controller.addServiceItem(service_item) self.parent.preview_controller.addServiceItem(service_item)
@ -375,7 +375,7 @@ class MediaManagerItem(QtGui.QWidget):
self.trUtf8(u'You must select one or more items')) self.trUtf8(u'You must select one or more items'))
log.debug(self.PluginNameShort + u' Live Requested') log.debug(self.PluginNameShort + u' Live Requested')
service_item = self.buildServiceItem() service_item = self.buildServiceItem()
if service_item is not None: if service_item:
service_item.fromPlugin = True service_item.fromPlugin = True
service_item.uuid = unicode(uuid.uuid1()) service_item.uuid = unicode(uuid.uuid1())
self.parent.live_controller.addServiceItem(service_item) self.parent.live_controller.addServiceItem(service_item)
@ -387,7 +387,7 @@ class MediaManagerItem(QtGui.QWidget):
self.trUtf8(u'You must select one or more items')) self.trUtf8(u'You must select one or more items'))
log.debug(self.PluginNameShort + u' Add Requested') log.debug(self.PluginNameShort + u' Add Requested')
service_item = self.buildServiceItem() service_item = self.buildServiceItem()
if service_item is not None: if service_item:
service_item.fromPlugin = False service_item.fromPlugin = False
service_item.uuid = unicode(uuid.uuid1()) service_item.uuid = unicode(uuid.uuid1())
self.parent.service_manager.addServiceItem(service_item) self.parent.service_manager.addServiceItem(service_item)
@ -397,7 +397,7 @@ class MediaManagerItem(QtGui.QWidget):
Common method for generating a service item Common method for generating a service item
""" """
service_item = ServiceItem(self.parent) service_item = ServiceItem(self.parent)
if self.ServiceItemIconName is not None: if self.ServiceItemIconName:
service_item.addIcon(self.ServiceItemIconName) service_item.addIcon(self.ServiceItemIconName)
else: else:
service_item.addIcon( service_item.addIcon(

View File

@ -112,7 +112,7 @@ class Plugin(QtCore.QObject):
""" """
QtCore.QObject.__init__(self) QtCore.QObject.__init__(self)
self.name = name self.name = name
if version is not None: if version:
self.version = version self.version = version
self.icon = None self.icon = None
self.config = PluginConfig(self.name) self.config = PluginConfig(self.name)
@ -236,7 +236,7 @@ class Plugin(QtCore.QObject):
""" """
Called by the plugin Manager to initialise anything it needs. Called by the plugin Manager to initialise anything it needs.
""" """
if self.media_item is not None: if self.media_item:
self.media_item.initialise() self.media_item.initialise()
def finalise(self): def finalise(self):
@ -256,7 +256,7 @@ class Plugin(QtCore.QObject):
""" """
Called by plugin to replace toolbar Called by plugin to replace toolbar
""" """
if self.media_item is not None: if self.media_item:
self.mediadock.insert_dock(self.media_item, self.icon, self.weight) self.mediadock.insert_dock(self.media_item, self.icon, self.weight)
if self.settings_tab is not None: if self.settings_tab:
self.settings.insertTab(self.settings_tab, self.weight) self.settings.insertTab(self.settings_tab, self.weight)

View File

@ -107,7 +107,7 @@ class PluginConfig(object):
files = os.listdir(self.get_data_path()) files = os.listdir(self.get_data_path())
except: except:
return [] return []
if suffix is not None: if suffix:
return_files = [] return_files = []
for file in files: for file in files:
if file.find(u'.') != -1: if file.find(u'.') != -1:
@ -131,7 +131,7 @@ class PluginConfig(object):
The name of the list. The name of the list.
""" """
list_count = self.get_config(u'%s count' % name) list_count = self.get_config(u'%s count' % name)
if list_count is not None: if list_count:
list_count = int(list_count) list_count = int(list_count)
else: else:
list_count = 0 list_count = 0
@ -169,12 +169,12 @@ class PluginConfig(object):
``num`` ``num``
Defaults to *None*. A further qualifier. Defaults to *None*. A further qualifier.
""" """
if num is not None: if num:
name = u'last directory %d' % num name = u'last directory %d' % num
else: else:
name = u'last directory' name = u'last directory'
last_dir = self.get_config(name) last_dir = self.get_config(name)
if last_dir is None: if not last_dir:
last_dir = u'' last_dir = u''
return last_dir return last_dir
@ -185,7 +185,7 @@ class PluginConfig(object):
``num`` ``num``
Defaults to *None*. A further qualifier. Defaults to *None*. A further qualifier.
""" """
if num is not None: if num:
name = u'last directory %d' % num name = u'last directory %d' % num
else: else:
name = u'last directory' name = u'last directory'

View File

@ -149,8 +149,9 @@ class PluginManager(object):
for plugin in self.plugins: for plugin in self.plugins:
if plugin.status is not PluginStatus.Disabled: if plugin.status is not PluginStatus.Disabled:
plugin.settings_tab = plugin.get_settings_tab() plugin.settings_tab = plugin.get_settings_tab()
if plugin.settings_tab is not None: if plugin.settings_tab:
log.debug(u'Inserting settings tab item from %s' % plugin.name) log.debug(u'Inserting settings tab item from %s' %
plugin.name)
settingsform.addTab(plugin.name, plugin.settings_tab) settingsform.addTab(plugin.name, plugin.settings_tab)
else: else:
log.debug(u'No tab settings in %s' % plugin.name) log.debug(u'No tab settings in %s' % plugin.name)

View File

@ -76,7 +76,7 @@ class Renderer(object):
self.theme_name = theme.theme_name self.theme_name = theme.theme_name
self._set_theme_font() self._set_theme_font()
if theme.background_type == u'image': if theme.background_type == u'image':
if theme.background_filename is not None: if theme.background_filename:
self.set_bg_image(theme.background_filename) self.set_bg_image(theme.background_filename)
def set_bg_image(self, filename): def set_bg_image(self, filename):
@ -88,7 +88,7 @@ class Renderer(object):
""" """
log.debug(u'set bg image %s', filename) log.debug(u'set bg image %s', filename)
self._bg_image_filename = unicode(filename) self._bg_image_filename = unicode(filename)
if self._frame is not None: if self._frame:
self.scale_bg_image() self.scale_bg_image()
def scale_bg_image(self): def scale_bg_image(self):
@ -134,7 +134,7 @@ class Renderer(object):
frame_height) frame_height)
self._frame = QtGui.QImage(frame_width, frame_height, self._frame = QtGui.QImage(frame_width, frame_height,
QtGui.QImage.Format_ARGB32_Premultiplied) QtGui.QImage.Format_ARGB32_Premultiplied)
if self._bg_image_filename is not None and self.bg_image is None: if self._bg_image_filename and not self.bg_image:
self.scale_bg_image() self.scale_bg_image()
if self.bg_frame is None: if self.bg_frame is None:
self._generate_background_frame() self._generate_background_frame()
@ -241,13 +241,13 @@ class Renderer(object):
""" """
log.debug(u'generate_frame_from_lines - Start') log.debug(u'generate_frame_from_lines - Start')
bbox = self._render_lines_unaligned(lines, False) bbox = self._render_lines_unaligned(lines, False)
if footer_lines is not None: if footer_lines:
bbox1 = self._render_lines_unaligned(footer_lines, True) bbox1 = self._render_lines_unaligned(footer_lines, True)
# reset the frame. first time do not worry about what you paint on. # reset the frame. first time do not worry about what you paint on.
self._frame = QtGui.QImage(self.bg_frame) self._frame = QtGui.QImage(self.bg_frame)
x, y = self._correctAlignment(self._rect, bbox) x, y = self._correctAlignment(self._rect, bbox)
bbox = self._render_lines_unaligned(lines, False, (x, y), True) bbox = self._render_lines_unaligned(lines, False, (x, y), True)
if footer_lines is not None: if footer_lines:
bbox = self._render_lines_unaligned(footer_lines, True, bbox = self._render_lines_unaligned(footer_lines, True,
(self._rect_footer.left(), self._rect_footer.top()), True) (self._rect_footer.left(), self._rect_footer.top()), True)
log.debug(u'generate_frame_from_lines - Finish') log.debug(u'generate_frame_from_lines - Finish')
@ -305,7 +305,7 @@ class Renderer(object):
elif self._theme.background_type == u'image': elif self._theme.background_type == u'image':
# image # image
painter.fillRect(self._frame.rect(), QtCore.Qt.black) painter.fillRect(self._frame.rect(), QtCore.Qt.black)
if self.bg_image is not None: if self.bg_image:
painter.drawImage(0, 0, self.bg_image) painter.drawImage(0, 0, self.bg_image)
painter.end() painter.end()
log.debug(u'render background End') log.debug(u'render background End')
@ -321,13 +321,13 @@ class Renderer(object):
Footer dimensions? Footer dimensions?
""" """
x = rect.left() x = rect.left()
if int(self._theme.display_verticalAlign) == 0: if self._theme.display_verticalAlign == 0:
# top align # top align
y = rect.top() y = rect.top()
elif int(self._theme.display_verticalAlign) == 2: elif self._theme.display_verticalAlign == 2:
# bottom align # bottom align
y = rect.bottom() - bbox.height() y = rect.bottom() - bbox.height()
elif int(self._theme.display_verticalAlign) == 1: elif self._theme.display_verticalAlign == 1:
# centre align # centre align
y = rect.top() + (rect.height() - bbox.height()) / 2 y = rect.top() + (rect.height() - bbox.height()) / 2
else: else:
@ -571,5 +571,5 @@ class Renderer(object):
Defaults to *None*. Another image to save to disk. Defaults to *None*. Another image to save to disk.
""" """
image.save(u'renderer.png', u'png') image.save(u'renderer.png', u'png')
if image2 is not None: if image2:
image2.save(u'renderer2.png', u'png') image2.save(u'renderer2.png', u'png')

View File

@ -121,7 +121,7 @@ class RenderManager(object):
else: else:
self.theme = self.service_theme self.theme = self.service_theme
else: else:
if theme is not None: if theme:
self.theme = theme self.theme = theme
elif self.global_style == u'Song' or \ elif self.global_style == u'Song' or \
self.global_style == u'Service': self.global_style == u'Service':
@ -139,17 +139,19 @@ class RenderManager(object):
self.renderer.set_theme(self.themedata) self.renderer.set_theme(self.themedata)
self.build_text_rectangle(self.themedata) self.build_text_rectangle(self.themedata)
#Replace the backgrount image from renderer with one from image #Replace the backgrount image from renderer with one from image
if self.override_background is not None: if self.override_background:
if self.save_bg_frame is None: if self.save_bg_frame is None:
self.save_bg_frame = self.renderer.bg_frame self.save_bg_frame = self.renderer.bg_frame
if self.override_background_changed: if self.override_background_changed:
self.renderer.bg_frame = self.resize_image(self.override_background) self.renderer.bg_frame = self.resize_image(
self.override_background)
self.override_background_changed = False self.override_background_changed = False
else: else:
if self.override_background_changed: if self.override_background_changed:
self.renderer.bg_frame = self.resize_image(self.override_background) self.renderer.bg_frame = self.resize_image(
self.override_background)
self.override_background_changed = False self.override_background_changed = False
if self.save_bg_frame is not None: if self.save_bg_frame:
self.renderer.bg_frame = self.save_bg_frame self.renderer.bg_frame = self.save_bg_frame
self.save_bg_frame = None self.save_bg_frame = None

View File

@ -57,7 +57,7 @@ class ServiceItem(object):
The plugin that this service item belongs to. The plugin that this service item belongs to.
""" """
self.plugin = hostplugin self.plugin = hostplugin
if hostplugin is not None: if hostplugin:
self.RenderManager = self.plugin.render_manager self.RenderManager = self.plugin.render_manager
self.shortname = hostplugin.name self.shortname = hostplugin.name
self.name = self.plugin.name self.name = self.plugin.name

View File

@ -91,7 +91,7 @@ class ThemeXML(object):
``path`` ``path``
The path name to be added. The path name to be added.
""" """
if self.background_filename is not None and path is not None: if self.background_filename and path:
self.theme_name = self.theme_name.rstrip().lstrip() self.theme_name = self.theme_name.rstrip().lstrip()
self.background_filename = self.background_filename.rstrip().lstrip() self.background_filename = self.background_filename.rstrip().lstrip()
self.background_filename = os.path.join(path, self.theme_name, self.background_filename = os.path.join(path, self.theme_name,
@ -371,7 +371,7 @@ class ThemeXML(object):
else: else:
setattr(self, field, e[1]) setattr(self, field, e[1])
else: else:
if element.tag is not None: if element.tag:
field = master + element.tag field = master + element.tag
if element.text == u'True' or element.text == u'False': if element.text == u'True' or element.text == u'False':
setattr(self, field, str_to_bool(element.text)) setattr(self, field, str_to_bool(element.text))

View File

@ -68,12 +68,12 @@ class OpenLPToolbar(QtGui.QToolBar):
The name of the object, as used in `<button>.setObjectName()`. The name of the object, as used in `<button>.setObjectName()`.
""" """
ButtonIcon = buildIcon(icon) ButtonIcon = buildIcon(icon)
if ButtonIcon is not None: if ButtonIcon:
if slot is not None: if slot:
ToolbarButton = self.addAction(ButtonIcon, title, slot) ToolbarButton = self.addAction(ButtonIcon, title, slot)
else: else:
ToolbarButton = self.addAction(ButtonIcon, title) ToolbarButton = self.addAction(ButtonIcon, title)
if tooltip is not None: if tooltip:
ToolbarButton.setToolTip(tooltip) ToolbarButton.setToolTip(tooltip)
self.icons[title] = ButtonIcon self.icons[title] = ButtonIcon
self.actions[title] = ToolbarButton self.actions[title] = ToolbarButton

View File

@ -208,7 +208,7 @@ class MainDisplay(DisplayLabel):
self.display.setPixmap(QtGui.QPixmap.fromImage(self.blankFrame)) self.display.setPixmap(QtGui.QPixmap.fromImage(self.blankFrame))
else: else:
self.displayBlank = False self.displayBlank = False
if self.frame is not None: if self.frame:
self.frameView(self.frame) self.frameView(self.frame)
if self.parent.LiveController.blackPushButton.isChecked() != \ if self.parent.LiveController.blackPushButton.isChecked() != \
self.displayBlank: self.displayBlank:

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expanddock textwidth=80 dockstop=4 softdockstop=4 # vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
############################################################################### ###############################################################################
# OpenLP - Open Source Lyrics Projection # # OpenLP - Open Source Lyrics Projection #
@ -54,7 +54,7 @@ class MediaDockManager(object):
def remove_dock(self, name): def remove_dock(self, name):
log.debug(u'remove %s dock' % name) log.debug(u'remove %s dock' % name)
for dock_index in range(0, self.media_dock.count()): for dock_index in range(0, self.media_dock.count()):
if self.media_dock.widget(dock_index) is not None: if self.media_dock.widget(dock_index):
if self.media_dock.widget(dock_index).ConfigSection == name: if self.media_dock.widget(dock_index).ConfigSection == name:
self.media_dock.widget(dock_index).hide() self.media_dock.widget(dock_index).hide()
self.media_dock.removeItem(dock_index) self.media_dock.removeItem(dock_index)

View File

@ -71,7 +71,7 @@ class PluginForm(QtGui.QDialog, Ui_PluginViewDialog):
status_text = 'Disabled' status_text = 'Disabled'
item.setText(u'%s (%s)' % (plugin.name, status_text)) item.setText(u'%s (%s)' % (plugin.name, status_text))
# If the plugin has an icon, set it! # If the plugin has an icon, set it!
if plugin.icon is not None: if plugin.icon:
item.setIcon(plugin.icon) item.setIcon(plugin.icon)
self.PluginListWidget.addItem(item) self.PluginListWidget.addItem(item)
@ -101,7 +101,7 @@ class PluginForm(QtGui.QDialog, Ui_PluginViewDialog):
if plugin.name == plugin_name: if plugin.name == plugin_name:
self.activePlugin = plugin self.activePlugin = plugin
break break
if self.activePlugin is not None: if self.activePlugin:
self._setDetails() self._setDetails()
else: else:
self._clearDetails() self._clearDetails()

View File

@ -246,7 +246,7 @@ class ServiceManager(QtGui.QWidget):
serviceIterator.setSelected(False) serviceIterator.setSelected(False)
if serviceIterator.isSelected(): if serviceIterator.isSelected():
#We are on the first record #We are on the first record
if tempItem is not None: if tempItem:
tempItem.setSelected(True) tempItem.setSelected(True)
serviceIterator.setSelected(False) serviceIterator.setSelected(False)
else: else:

View File

@ -54,12 +54,13 @@ class SettingsForm(QtGui.QDialog, Ui_SettingsDialog):
def insertTab(self, tab, location): def insertTab(self, tab, location):
log.debug(u'Inserting %s tab' % tab.tabTitle) log.debug(u'Inserting %s tab' % tab.tabTitle)
#13 : There are 3 tables currently and locations starts at -10 #13 : There are 3 tables currently and locations starts at -10
self.SettingsTabWidget.insertTab(location + 13, tab, tab.tabTitleVisible) self.SettingsTabWidget.insertTab(
location + 13, tab, tab.tabTitleVisible)
def removeTab(self, name): def removeTab(self, name):
log.debug(u'remove %s tab' % name) log.debug(u'remove %s tab' % name)
for tab_index in range(0, self.SettingsTabWidget.count()): for tab_index in range(0, self.SettingsTabWidget.count()):
if self.SettingsTabWidget.widget(tab_index) is not None: if self.SettingsTabWidget.widget(tab_index):
if self.SettingsTabWidget.widget(tab_index).tabTitle == name: if self.SettingsTabWidget.widget(tab_index).tabTitle == name:
self.SettingsTabWidget.removeTab(tab_index) self.SettingsTabWidget.removeTab(tab_index)

View File

@ -302,7 +302,7 @@ class SlideController(QtGui.QWidget):
str_to_bool(self.songsconfig.get_config(u'display songbar', True)): str_to_bool(self.songsconfig.get_config(u'display songbar', True)):
for action in self.Songbar.actions: for action in self.Songbar.actions:
self.Songbar.actions[action].setVisible(False) self.Songbar.actions[action].setVisible(False)
if item.verse_order is not None: if item.verse_order:
verses = item.verse_order.split(u' ') verses = item.verse_order.split(u' ')
for verse in verses: for verse in verses:
try: try:
@ -336,7 +336,7 @@ class SlideController(QtGui.QWidget):
""" """
log.debug(u'addServiceItem') log.debug(u'addServiceItem')
#If old item was a command tell it to stop #If old item was a command tell it to stop
if self.commandItem is not None and \ if self.commandItem and \
self.commandItem.service_item_type == ServiceItemType.Command: self.commandItem.service_item_type == ServiceItemType.Command:
Receiver().send_message(u'%s_stop'% self.commandItem.name.lower()) Receiver().send_message(u'%s_stop'% self.commandItem.name.lower())
self.commandItem = item self.commandItem = item
@ -358,7 +358,7 @@ class SlideController(QtGui.QWidget):
""" """
Replacement item following a remote edit Replacement item following a remote edit
""" """
if self.commandItem is not None and \ if self.commandItem and \
item.uuid == self.commandItem.uuid: item.uuid == self.commandItem.uuid:
self.addServiceManagerItem(item, self.PreviewListWidget.currentRow()) self.addServiceManagerItem(item, self.PreviewListWidget.currentRow())
@ -370,7 +370,7 @@ class SlideController(QtGui.QWidget):
""" """
log.debug(u'addServiceManagerItem') log.debug(u'addServiceManagerItem')
#If old item was a command tell it to stop #If old item was a command tell it to stop
if self.commandItem is not None and \ if self.commandItem and \
self.commandItem.service_item_type == ServiceItemType.Command: self.commandItem.service_item_type == ServiceItemType.Command:
Receiver().send_message(u'%s_stop'% self.commandItem.name.lower()) Receiver().send_message(u'%s_stop'% self.commandItem.name.lower())
self.commandItem = item self.commandItem = item
@ -413,7 +413,7 @@ class SlideController(QtGui.QWidget):
self.PreviewListWidget.setItem(framenumber, 0, item) self.PreviewListWidget.setItem(framenumber, 0, item)
if slide_height != 0: if slide_height != 0:
self.PreviewListWidget.setRowHeight(framenumber, slide_height) self.PreviewListWidget.setRowHeight(framenumber, slide_height)
if self.serviceitem.frames[0][u'text'] is not None: if self.serviceitem.frames[0][u'text']:
self.PreviewListWidget.resizeRowsToContents() self.PreviewListWidget.resizeRowsToContents()
self.PreviewListWidget.setColumnWidth( self.PreviewListWidget.setColumnWidth(
0, self.PreviewListWidget.viewport().size().width()) 0, self.PreviewListWidget.viewport().size().width())
@ -433,7 +433,7 @@ class SlideController(QtGui.QWidget):
""" """
Go to the first slide. Go to the first slide.
""" """
if self.commandItem is not None and \ if self.commandItem and \
self.commandItem.service_item_type == ServiceItemType.Command: self.commandItem.service_item_type == ServiceItemType.Command:
Receiver().send_message(u'%s_first'% self.commandItem.name.lower()) Receiver().send_message(u'%s_first'% self.commandItem.name.lower())
QtCore.QTimer.singleShot(0.5, self.grabMainDisplay) QtCore.QTimer.singleShot(0.5, self.grabMainDisplay)
@ -445,7 +445,7 @@ class SlideController(QtGui.QWidget):
""" """
Blank the screen. Blank the screen.
""" """
if self.commandItem is not None and \ if self.commandItem and \
self.commandItem.service_item_type == ServiceItemType.Command: self.commandItem.service_item_type == ServiceItemType.Command:
if blanked: if blanked:
Receiver().send_message(u'%s_blank'% self.commandItem.name.lower()) Receiver().send_message(u'%s_blank'% self.commandItem.name.lower())
@ -499,7 +499,7 @@ class SlideController(QtGui.QWidget):
""" """
Go to the next slide. Go to the next slide.
""" """
if self.commandItem is not None and \ if self.commandItem and \
self.commandItem.service_item_type == ServiceItemType.Command: self.commandItem.service_item_type == ServiceItemType.Command:
Receiver().send_message(u'%s_next'% self.commandItem.name.lower()) Receiver().send_message(u'%s_next'% self.commandItem.name.lower())
QtCore.QTimer.singleShot(0.5, self.grabMainDisplay) QtCore.QTimer.singleShot(0.5, self.grabMainDisplay)
@ -514,7 +514,7 @@ class SlideController(QtGui.QWidget):
""" """
Go to the previous slide. Go to the previous slide.
""" """
if self.commandItem is not None and \ if self.commandItem and \
self.commandItem.service_item_type == ServiceItemType.Command: self.commandItem.service_item_type == ServiceItemType.Command:
Receiver().send_message( Receiver().send_message(
u'%s_previous'% self.commandItem.name.lower()) u'%s_previous'% self.commandItem.name.lower())
@ -530,7 +530,7 @@ class SlideController(QtGui.QWidget):
""" """
Go to the last slide. Go to the last slide.
""" """
if self.commandItem is not None and \ if self.commandItem and \
self.commandItem.service_item_type == ServiceItemType.Command: self.commandItem.service_item_type == ServiceItemType.Command:
Receiver().send_message(u'%s_last'% self.commandItem.name.lower()) Receiver().send_message(u'%s_last'% self.commandItem.name.lower())
QtCore.QTimer.singleShot(0.5, self.grabMainDisplay) QtCore.QTimer.singleShot(0.5, self.grabMainDisplay)

View File

@ -148,17 +148,18 @@ class ThemeManager(QtGui.QWidget):
def onEditTheme(self): def onEditTheme(self):
item = self.ThemeListWidget.currentItem() item = self.ThemeListWidget.currentItem()
if item is not None: if item:
self.amendThemeForm.loadTheme( self.amendThemeForm.loadTheme(
unicode(item.data(QtCore.Qt.UserRole).toString())) unicode(item.data(QtCore.Qt.UserRole).toString()))
self.saveThemeName = unicode(item.data(QtCore.Qt.UserRole).toString()) self.saveThemeName = unicode(
item.data(QtCore.Qt.UserRole).toString())
self.amendThemeForm.exec_() self.amendThemeForm.exec_()
def onDeleteTheme(self): def onDeleteTheme(self):
self.global_theme = unicode( self.global_theme = unicode(
self.config.get_config(u'theme global theme', u'')) self.config.get_config(u'theme global theme', u''))
item = self.ThemeListWidget.currentItem() item = self.ThemeListWidget.currentItem()
if item is not None: if item:
theme = unicode(item.text()) theme = unicode(item.text())
# should be the same unless default # should be the same unless default
if theme != unicode(item.data(QtCore.Qt.UserRole).toString()): if theme != unicode(item.data(QtCore.Qt.UserRole).toString()):
@ -406,7 +407,7 @@ class ThemeManager(QtGui.QWidget):
outfile = open(theme_file, u'w') outfile = open(theme_file, u'w')
outfile.write(theme_pretty_xml) outfile.write(theme_pretty_xml)
outfile.close() outfile.close()
if image_from is not None and image_from != image_to: if image_from and image_from != image_to:
print "if", image_from print "if", image_from
print "it", image_to print "it", image_to
shutil.copyfile(image_from, image_to) shutil.copyfile(image_from, image_to)

View File

@ -57,7 +57,7 @@ class ConfigHelper(object):
if reg.has_value(section, key): if reg.has_value(section, key):
return reg.get_value(section, key, default) return reg.get_value(section, key, default)
else: else:
if default is not None: if default:
ConfigHelper.set_config(section, key, default) ConfigHelper.set_config(section, key, default)
return default return default