forked from openlp/openlp
Variable cleanup
This commit is contained in:
parent
3678ea5ea2
commit
dc96d471e6
@ -28,10 +28,8 @@ import os
|
|||||||
|
|
||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
|
|
||||||
from openlp.core.lib.toolbar import *
|
|
||||||
from openlp.core.lib import contextMenuAction, contextMenuSeparator, \
|
from openlp.core.lib import contextMenuAction, contextMenuSeparator, \
|
||||||
SettingsManager
|
SettingsManager, OpenLPToolbar, ServiceItem
|
||||||
from serviceitem import ServiceItem
|
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -38,30 +38,32 @@ class PluginManager(object):
|
|||||||
"""
|
"""
|
||||||
log.info(u'Plugin manager loaded')
|
log.info(u'Plugin manager loaded')
|
||||||
|
|
||||||
def __init__(self, dir):
|
def __init__(self, plugin_dir):
|
||||||
"""
|
"""
|
||||||
The constructor for the plugin manager. Passes the controllers on to
|
The constructor for the plugin manager. Passes the controllers on to
|
||||||
the plugins for them to interact with via their ServiceItems.
|
the plugins for them to interact with via their ServiceItems.
|
||||||
|
|
||||||
``dir``
|
``plugin_dir``
|
||||||
The directory to search for plugins.
|
The directory to search for plugins.
|
||||||
"""
|
"""
|
||||||
log.info(u'Plugin manager initing')
|
log.info(u'Plugin manager initing')
|
||||||
if not dir in sys.path:
|
if not plugin_dir in sys.path:
|
||||||
log.debug(u'Inserting %s into sys.path', dir)
|
log.debug(u'Inserting %s into sys.path', plugin_dir)
|
||||||
sys.path.insert(0, dir)
|
sys.path.insert(0, plugin_dir)
|
||||||
self.basepath = os.path.abspath(dir)
|
self.basepath = os.path.abspath(plugin_dir)
|
||||||
log.debug(u'Base path %s ', self.basepath)
|
log.debug(u'Base path %s ', self.basepath)
|
||||||
|
self.plugin_helpers = []
|
||||||
self.plugins = []
|
self.plugins = []
|
||||||
# this has to happen after the UI is sorted self.find_plugins(dir)
|
# this has to happen after the UI is sorted
|
||||||
|
# self.find_plugins(plugin_dir)
|
||||||
log.info(u'Plugin manager Initialised')
|
log.info(u'Plugin manager Initialised')
|
||||||
|
|
||||||
def find_plugins(self, dir, plugin_helpers):
|
def find_plugins(self, plugin_dir, plugin_helpers):
|
||||||
"""
|
"""
|
||||||
Scan the directory ``dir`` for objects inheriting from the ``Plugin``
|
Scan the directory ``plugin_dir`` for objects inheriting from the
|
||||||
class.
|
``Plugin`` class.
|
||||||
|
|
||||||
``dir``
|
``plugin_dir``
|
||||||
The directory to scan.
|
The directory to scan.
|
||||||
|
|
||||||
``plugin_helpers``
|
``plugin_helpers``
|
||||||
@ -69,10 +71,11 @@ class PluginManager(object):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
self.plugin_helpers = plugin_helpers
|
self.plugin_helpers = plugin_helpers
|
||||||
startdepth = len(os.path.abspath(dir).split(os.sep))
|
startdepth = len(os.path.abspath(plugin_dir).split(os.sep))
|
||||||
log.debug(u'find plugins %s at depth %d', unicode(dir), startdepth)
|
log.debug(u'finding plugins in %s at depth %d',
|
||||||
|
unicode(plugin_dir), startdepth)
|
||||||
|
|
||||||
for root, dirs, files in os.walk(dir):
|
for root, dirs, files in os.walk(plugin_dir):
|
||||||
for name in files:
|
for name in files:
|
||||||
if name.endswith(u'.py') and not name.startswith(u'__'):
|
if name.endswith(u'.py') and not name.startswith(u'__'):
|
||||||
path = os.path.abspath(os.path.join(root, name))
|
path = os.path.abspath(os.path.join(root, name))
|
||||||
@ -80,7 +83,7 @@ class PluginManager(object):
|
|||||||
if thisdepth - startdepth > 2:
|
if thisdepth - startdepth > 2:
|
||||||
# skip anything lower down
|
# skip anything lower down
|
||||||
continue
|
continue
|
||||||
modulename, pyext = os.path.splitext(path)
|
modulename = os.path.splitext(path)[0]
|
||||||
prefix = os.path.commonprefix([self.basepath, path])
|
prefix = os.path.commonprefix([self.basepath, path])
|
||||||
# hack off the plugin base path
|
# hack off the plugin base path
|
||||||
modulename = modulename[len(prefix) + 1:]
|
modulename = modulename[len(prefix) + 1:]
|
||||||
@ -91,8 +94,8 @@ class PluginManager(object):
|
|||||||
try:
|
try:
|
||||||
__import__(modulename, globals(), locals(), [])
|
__import__(modulename, globals(), locals(), [])
|
||||||
except ImportError, e:
|
except ImportError, e:
|
||||||
log.exception(u'Failed to import module %s on path %s for reason %s',
|
log.exception(u'Failed to import module %s on path %s '
|
||||||
modulename, path, e.args[0])
|
'for reason %s', modulename, path, e.args[0])
|
||||||
plugin_classes = Plugin.__subclasses__()
|
plugin_classes = Plugin.__subclasses__()
|
||||||
plugin_objects = []
|
plugin_objects = []
|
||||||
for p in plugin_classes:
|
for p in plugin_classes:
|
||||||
@ -214,3 +217,4 @@ class PluginManager(object):
|
|||||||
if plugin.is_active():
|
if plugin.is_active():
|
||||||
plugin.finalise()
|
plugin.finalise()
|
||||||
log.info(u'Finalisation Complete for %s ' % plugin.name)
|
log.info(u'Finalisation Complete for %s ' % plugin.name)
|
||||||
|
|
||||||
|
@ -172,11 +172,12 @@ class SettingsManager(object):
|
|||||||
path = os.path.join(path, section)
|
path = os.path.join(path, section)
|
||||||
try:
|
try:
|
||||||
files = os.listdir(path)
|
files = os.listdir(path)
|
||||||
except:
|
except OSError:
|
||||||
return []
|
return []
|
||||||
if extension:
|
if extension:
|
||||||
return [file for file in files
|
return [filename for filename in files
|
||||||
if extension == os.path.splitext(file)[1]]
|
if extension == os.path.splitext(filename)[1]]
|
||||||
else:
|
else:
|
||||||
# no filtering required
|
# no filtering required
|
||||||
return files
|
return files
|
||||||
|
|
||||||
|
@ -136,7 +136,7 @@ class SongXMLParser(object):
|
|||||||
try:
|
try:
|
||||||
self.song_xml = ElementTree(
|
self.song_xml = ElementTree(
|
||||||
element=XML(unicode(xml).encode('unicode-escape')))
|
element=XML(unicode(xml).encode('unicode-escape')))
|
||||||
except:
|
except ExpatError:
|
||||||
log.exception(u'Invalid xml %s', xml)
|
log.exception(u'Invalid xml %s', xml)
|
||||||
|
|
||||||
def get_verses(self):
|
def get_verses(self):
|
||||||
@ -144,9 +144,9 @@ class SongXMLParser(object):
|
|||||||
Iterates through the verses in the XML and returns a list of verses
|
Iterates through the verses in the XML and returns a list of verses
|
||||||
and their attributes.
|
and their attributes.
|
||||||
"""
|
"""
|
||||||
iter = self.song_xml.getiterator()
|
xml_iter = self.song_xml.getiterator()
|
||||||
verse_list = []
|
verse_list = []
|
||||||
for element in iter:
|
for element in xml_iter:
|
||||||
if element.tag == u'verse':
|
if element.tag == u'verse':
|
||||||
if element.text is None:
|
if element.text is None:
|
||||||
element.text = u''
|
element.text = u''
|
||||||
|
@ -97,7 +97,8 @@ class ThemeXML(object):
|
|||||||
"""
|
"""
|
||||||
if self.background_filename and path:
|
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,
|
||||||
self.background_filename)
|
self.background_filename)
|
||||||
|
|
||||||
@ -244,7 +245,8 @@ class ThemeXML(object):
|
|||||||
background.appendChild(element)
|
background.appendChild(element)
|
||||||
|
|
||||||
def add_display(self, shadow, shadow_color, outline, outline_color,
|
def add_display(self, shadow, shadow_color, outline, outline_color,
|
||||||
horizontal, vertical, wrap, transition, shadow_pixel=5, outline_pixel=2):
|
horizontal, vertical, wrap, transition, shadow_pixel=5,
|
||||||
|
outline_pixel=2):
|
||||||
"""
|
"""
|
||||||
Add a Display options.
|
Add a Display options.
|
||||||
|
|
||||||
@ -349,7 +351,6 @@ class ThemeXML(object):
|
|||||||
"""
|
"""
|
||||||
self.base_parse_xml()
|
self.base_parse_xml()
|
||||||
self.parse_xml(xml)
|
self.parse_xml(xml)
|
||||||
self.theme_filename_extended = False
|
|
||||||
|
|
||||||
def base_parse_xml(self):
|
def base_parse_xml(self):
|
||||||
"""
|
"""
|
||||||
@ -409,3 +410,4 @@ class ThemeXML(object):
|
|||||||
if key[0:1] != u'_':
|
if key[0:1] != u'_':
|
||||||
theme_strings.append(u'%30s: %s' % (key, getattr(self, key)))
|
theme_strings.append(u'%30s: %s' % (key, getattr(self, key)))
|
||||||
return u'\n'.join(theme_strings)
|
return u'\n'.join(theme_strings)
|
||||||
|
|
||||||
|
@ -115,26 +115,27 @@ class Theme(object):
|
|||||||
for element in iter:
|
for element in iter:
|
||||||
delphiColorChange = False
|
delphiColorChange = False
|
||||||
if element.tag != u'Theme':
|
if element.tag != u'Theme':
|
||||||
t = element.text
|
element_text = element.text
|
||||||
val = 0
|
val = 0
|
||||||
# easy!
|
# easy!
|
||||||
if type(t) == type(None):
|
if element_text is None:
|
||||||
val = t
|
val = element_text
|
||||||
# strings need special handling to sort the colours out
|
# strings need special handling to sort the colours out
|
||||||
if type(t) is types.StringType or type(t) is types.UnicodeType:
|
if type(element_text) is types.StringType or \
|
||||||
if t[0] == u'$': # might be a hex number
|
type(element_text) is types.UnicodeType:
|
||||||
|
if element_text[0] == u'$': # might be a hex number
|
||||||
try:
|
try:
|
||||||
val = int(t[1:], 16)
|
val = int(element_text[1:], 16)
|
||||||
except ValueError: # nope
|
except ValueError: # nope
|
||||||
pass
|
pass
|
||||||
elif DelphiColors.has_key(t):
|
elif DelphiColors.has_key(element_text):
|
||||||
val = DelphiColors[t]
|
val = DelphiColors[element_text]
|
||||||
delphiColorChange = True
|
delphiColorChange = True
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
val = int(t)
|
val = int(element_text)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
val = t
|
val = element_text
|
||||||
if (element.tag.find(u'Color') > 0 or
|
if (element.tag.find(u'Color') > 0 or
|
||||||
(element.tag.find(u'BackgroundParameter') == 0 and
|
(element.tag.find(u'BackgroundParameter') == 0 and
|
||||||
type(val) == type(0))):
|
type(val) == type(0))):
|
||||||
|
@ -154,8 +154,8 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog):
|
|||||||
unicode(self.theme.background_endColor),
|
unicode(self.theme.background_endColor),
|
||||||
self.theme.background_direction)
|
self.theme.background_direction)
|
||||||
else:
|
else:
|
||||||
(path, filename) = \
|
filename = \
|
||||||
os.path.split(unicode(self.theme.background_filename))
|
os.path.split(unicode(self.theme.background_filename))[0]
|
||||||
new_theme.add_background_image(filename)
|
new_theme.add_background_image(filename)
|
||||||
save_to = os.path.join(self.path, theme_name, filename)
|
save_to = os.path.join(self.path, theme_name, filename)
|
||||||
save_from = self.theme.background_filename
|
save_from = self.theme.background_filename
|
||||||
|
@ -147,9 +147,11 @@ class ServiceManager(QtGui.QWidget):
|
|||||||
self.ServiceManagerList.setAlternatingRowColors(True)
|
self.ServiceManagerList.setAlternatingRowColors(True)
|
||||||
self.ServiceManagerList.setHeaderHidden(True)
|
self.ServiceManagerList.setHeaderHidden(True)
|
||||||
self.ServiceManagerList.setExpandsOnDoubleClick(False)
|
self.ServiceManagerList.setExpandsOnDoubleClick(False)
|
||||||
self.ServiceManagerList.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
|
self.ServiceManagerList.setContextMenuPolicy(
|
||||||
|
QtCore.Qt.CustomContextMenu)
|
||||||
QtCore.QObject.connect(self.ServiceManagerList,
|
QtCore.QObject.connect(self.ServiceManagerList,
|
||||||
QtCore.SIGNAL('customContextMenuRequested(QPoint)'), self.contextMenu)
|
QtCore.SIGNAL('customContextMenuRequested(QPoint)'),
|
||||||
|
self.contextMenu)
|
||||||
self.ServiceManagerList.setObjectName(u'ServiceManagerList')
|
self.ServiceManagerList.setObjectName(u'ServiceManagerList')
|
||||||
# enable drop
|
# enable drop
|
||||||
self.ServiceManagerList.__class__.dragEnterEvent = self.dragEnterEvent
|
self.ServiceManagerList.__class__.dragEnterEvent = self.dragEnterEvent
|
||||||
@ -172,7 +174,8 @@ class ServiceManager(QtGui.QWidget):
|
|||||||
self.trUtf8('Move to end'), self.onServiceEnd)
|
self.trUtf8('Move to end'), self.onServiceEnd)
|
||||||
self.OrderToolbar.addSeparator()
|
self.OrderToolbar.addSeparator()
|
||||||
self.OrderToolbar.addToolbarButton(
|
self.OrderToolbar.addToolbarButton(
|
||||||
self.trUtf8('&Delete From Service'), u':/general/general_delete.png',
|
self.trUtf8('&Delete From Service'),
|
||||||
|
u':/general/general_delete.png',
|
||||||
self.trUtf8('Delete From Service'), self.onDeleteFromService)
|
self.trUtf8('Delete From Service'), self.onDeleteFromService)
|
||||||
self.Layout.addWidget(self.OrderToolbar)
|
self.Layout.addWidget(self.OrderToolbar)
|
||||||
# Connect up our signals and slots
|
# Connect up our signals and slots
|
||||||
@ -205,7 +208,8 @@ class ServiceManager(QtGui.QWidget):
|
|||||||
self.dndMenu = QtGui.QMenu()
|
self.dndMenu = QtGui.QMenu()
|
||||||
self.newAction = self.dndMenu.addAction(self.trUtf8('&Add New Item'))
|
self.newAction = self.dndMenu.addAction(self.trUtf8('&Add New Item'))
|
||||||
self.newAction.setIcon(build_icon(u':/general/general_edit.png'))
|
self.newAction.setIcon(build_icon(u':/general/general_edit.png'))
|
||||||
self.addToAction = self.dndMenu.addAction(self.trUtf8('&Add to Selected Item'))
|
self.addToAction = self.dndMenu.addAction(
|
||||||
|
self.trUtf8('&Add to Selected Item'))
|
||||||
self.addToAction.setIcon(build_icon(u':/general/general_edit.png'))
|
self.addToAction.setIcon(build_icon(u':/general/general_edit.png'))
|
||||||
#build the context menu
|
#build the context menu
|
||||||
self.menu = QtGui.QMenu()
|
self.menu = QtGui.QMenu()
|
||||||
@ -269,7 +273,7 @@ class ServiceManager(QtGui.QWidget):
|
|||||||
self.makeLive()
|
self.makeLive()
|
||||||
|
|
||||||
def onServiceItemNoteForm(self):
|
def onServiceItemNoteForm(self):
|
||||||
item, count = self.findServiceItem()
|
item = self.findServiceItem()[0]
|
||||||
self.serviceNoteForm.textEdit.setPlainText(
|
self.serviceNoteForm.textEdit.setPlainText(
|
||||||
self.serviceItems[item][u'service_item'].notes)
|
self.serviceItems[item][u'service_item'].notes)
|
||||||
if self.serviceNoteForm.exec_():
|
if self.serviceNoteForm.exec_():
|
||||||
@ -278,7 +282,7 @@ class ServiceManager(QtGui.QWidget):
|
|||||||
self.repaintServiceList(item, 0)
|
self.repaintServiceList(item, 0)
|
||||||
|
|
||||||
def onServiceItemEditForm(self):
|
def onServiceItemEditForm(self):
|
||||||
item, count = self.findServiceItem()
|
item = self.findServiceItem()[0]
|
||||||
self.serviceItemEditForm.setServiceItem(
|
self.serviceItemEditForm.setServiceItem(
|
||||||
self.serviceItems[item][u'service_item'])
|
self.serviceItems[item][u'service_item'])
|
||||||
if self.serviceItemEditForm.exec_():
|
if self.serviceItemEditForm.exec_():
|
||||||
@ -477,7 +481,7 @@ class ServiceManager(QtGui.QWidget):
|
|||||||
"""
|
"""
|
||||||
Remove the current ServiceItem from the list
|
Remove the current ServiceItem from the list
|
||||||
"""
|
"""
|
||||||
item, count = self.findServiceItem()
|
item = self.findServiceItem()[0]
|
||||||
if item is not -1:
|
if item is not -1:
|
||||||
self.serviceItems.remove(self.serviceItems[item])
|
self.serviceItems.remove(self.serviceItems[item])
|
||||||
self.repaintServiceList(0, 0)
|
self.repaintServiceList(0, 0)
|
||||||
@ -514,7 +518,8 @@ class ServiceManager(QtGui.QWidget):
|
|||||||
else:
|
else:
|
||||||
treewidgetitem.setIcon(0, serviceitem.iconic_representation)
|
treewidgetitem.setIcon(0, serviceitem.iconic_representation)
|
||||||
else:
|
else:
|
||||||
treewidgetitem.setIcon(0, build_icon(u':/general/general_delete.png'))
|
treewidgetitem.setIcon(
|
||||||
|
0, build_icon(u':/general/general_delete.png'))
|
||||||
treewidgetitem.setText(0, serviceitem.title)
|
treewidgetitem.setText(0, serviceitem.title)
|
||||||
treewidgetitem.setToolTip(0, serviceitem.notes)
|
treewidgetitem.setToolTip(0, serviceitem.notes)
|
||||||
treewidgetitem.setData(0, QtCore.Qt.UserRole,
|
treewidgetitem.setData(0, QtCore.Qt.UserRole,
|
||||||
@ -576,7 +581,7 @@ class ServiceManager(QtGui.QWidget):
|
|||||||
cPickle.dump(service, file)
|
cPickle.dump(service, file)
|
||||||
file.close()
|
file.close()
|
||||||
zip.write(servicefile)
|
zip.write(servicefile)
|
||||||
except:
|
except IOError:
|
||||||
log.exception(u'Failed to save service to disk')
|
log.exception(u'Failed to save service to disk')
|
||||||
finally:
|
finally:
|
||||||
if file:
|
if file:
|
||||||
@ -585,7 +590,7 @@ class ServiceManager(QtGui.QWidget):
|
|||||||
zip.close()
|
zip.close()
|
||||||
try:
|
try:
|
||||||
os.remove(servicefile)
|
os.remove(servicefile)
|
||||||
except:
|
except IOError:
|
||||||
pass #if not present do not worry
|
pass #if not present do not worry
|
||||||
name = filename.split(os.path.sep)
|
name = filename.split(os.path.sep)
|
||||||
self.serviceName = name[-1]
|
self.serviceName = name[-1]
|
||||||
@ -636,23 +641,23 @@ class ServiceManager(QtGui.QWidget):
|
|||||||
self.parent.serviceSettingsSection,
|
self.parent.serviceSettingsSection,
|
||||||
os.path.split(filename)[0])
|
os.path.split(filename)[0])
|
||||||
zip = None
|
zip = None
|
||||||
f = None
|
file_to = None
|
||||||
try:
|
try:
|
||||||
zip = zipfile.ZipFile(unicode(filename))
|
zip = zipfile.ZipFile(unicode(filename))
|
||||||
for file in zip.namelist():
|
for file in zip.namelist():
|
||||||
osfile = unicode(QtCore.QDir.toNativeSeparators(file))
|
osfile = unicode(QtCore.QDir.toNativeSeparators(file))
|
||||||
names = osfile.split(os.path.sep)
|
names = osfile.split(os.path.sep)
|
||||||
file_to = os.path.join(self.servicePath,
|
file_path = os.path.join(self.servicePath,
|
||||||
names[len(names) - 1])
|
names[len(names) - 1])
|
||||||
f = open(file_to, u'wb')
|
file_to = open(file_path, u'wb')
|
||||||
f.write(zip.read(file))
|
file_to.write(zip.read(file))
|
||||||
f.flush()
|
file_to.flush()
|
||||||
f.close()
|
file_to.close()
|
||||||
if file_to.endswith(u'osd'):
|
if file_path.endswith(u'osd'):
|
||||||
p_file = file_to
|
p_file = file_path
|
||||||
f = open(p_file, u'r')
|
file_to = open(p_file, u'r')
|
||||||
items = cPickle.load(f)
|
items = cPickle.load(file_to)
|
||||||
f.close()
|
file_to.close()
|
||||||
self.onNewService()
|
self.onNewService()
|
||||||
for item in items:
|
for item in items:
|
||||||
serviceitem = ServiceItem()
|
serviceitem = ServiceItem()
|
||||||
@ -663,13 +668,13 @@ class ServiceManager(QtGui.QWidget):
|
|||||||
try:
|
try:
|
||||||
if os.path.isfile(p_file):
|
if os.path.isfile(p_file):
|
||||||
os.remove(p_file)
|
os.remove(p_file)
|
||||||
except:
|
except IOError:
|
||||||
log.exception(u'Failed to remove osd file')
|
log.exception(u'Failed to remove osd file')
|
||||||
except:
|
except IOError:
|
||||||
log.exception(u'Problem loading a service file')
|
log.exception(u'Problem loading a service file')
|
||||||
finally:
|
finally:
|
||||||
if f:
|
if file_to:
|
||||||
f.close()
|
file_to.close()
|
||||||
if zip:
|
if zip:
|
||||||
zip.close()
|
zip.close()
|
||||||
self.isNew = False
|
self.isNew = False
|
||||||
@ -737,7 +742,7 @@ class ServiceManager(QtGui.QWidget):
|
|||||||
Service Item to be added
|
Service Item to be added
|
||||||
|
|
||||||
"""
|
"""
|
||||||
sitem, count = self.findServiceItem()
|
sitem = self.findServiceItem()[0]
|
||||||
item.render()
|
item.render()
|
||||||
if replace:
|
if replace:
|
||||||
item.merge(self.serviceItems[sitem][u'service_item'])
|
item.merge(self.serviceItems[sitem][u'service_item'])
|
||||||
@ -789,7 +794,7 @@ class ServiceManager(QtGui.QWidget):
|
|||||||
"""
|
"""
|
||||||
Send the current item to the Preview slide controller
|
Send the current item to the Preview slide controller
|
||||||
"""
|
"""
|
||||||
item, count = self.findServiceItem()
|
item = self.findServiceItem()[0]
|
||||||
if item == -1:
|
if item == -1:
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
@ -825,7 +830,7 @@ class ServiceManager(QtGui.QWidget):
|
|||||||
"""
|
"""
|
||||||
Posts a remote edit message to a plugin to allow item to be edited.
|
Posts a remote edit message to a plugin to allow item to be edited.
|
||||||
"""
|
"""
|
||||||
item, count = self.findServiceItem()
|
item = self.findServiceItem()[0]
|
||||||
if self.serviceItems[item][u'service_item']\
|
if self.serviceItems[item][u'service_item']\
|
||||||
.is_capable(ItemCapabilities.AllowsEdit):
|
.is_capable(ItemCapabilities.AllowsEdit):
|
||||||
Receiver.send_message(u'%s_edit' %
|
Receiver.send_message(u'%s_edit' %
|
||||||
@ -942,7 +947,7 @@ class ServiceManager(QtGui.QWidget):
|
|||||||
|
|
||||||
def onThemeChangeAction(self):
|
def onThemeChangeAction(self):
|
||||||
theme = unicode(self.sender().text())
|
theme = unicode(self.sender().text())
|
||||||
item, count = self.findServiceItem()
|
item = self.findServiceItem()[0]
|
||||||
self.serviceItems[item][u'service_item'].theme = theme
|
self.serviceItems[item][u'service_item'].theme = theme
|
||||||
self.regenerateServiceItems()
|
self.regenerateServiceItems()
|
||||||
|
|
||||||
@ -955,7 +960,7 @@ class ServiceManager(QtGui.QWidget):
|
|||||||
|
|
||||||
def listRequest(self, message=None):
|
def listRequest(self, message=None):
|
||||||
data = []
|
data = []
|
||||||
curindex, count = self.findServiceItem()
|
curindex = self.findServiceItem()[0]
|
||||||
if curindex >= 0 and curindex < len(self.serviceItems):
|
if curindex >= 0 and curindex < len(self.serviceItems):
|
||||||
curitem = self.serviceItems[curindex]
|
curitem = self.serviceItems[curindex]
|
||||||
else:
|
else:
|
||||||
@ -969,3 +974,4 @@ class ServiceManager(QtGui.QWidget):
|
|||||||
data_item[u'selected'] = (item == curitem)
|
data_item[u'selected'] = (item == curitem)
|
||||||
data.append(data_item)
|
data.append(data_item)
|
||||||
Receiver.send_message(u'servicemanager_list_response', data)
|
Receiver.send_message(u'servicemanager_list_response', data)
|
||||||
|
|
||||||
|
@ -233,7 +233,7 @@ class ThemeManager(QtGui.QWidget):
|
|||||||
try:
|
try:
|
||||||
zip = zipfile.ZipFile(themePath, u'w')
|
zip = zipfile.ZipFile(themePath, u'w')
|
||||||
source = os.path.join(self.path, theme)
|
source = os.path.join(self.path, theme)
|
||||||
for root, dirs, files in os.walk(source):
|
for files in os.walk(source)[2]:
|
||||||
for name in files:
|
for name in files:
|
||||||
zip.write(
|
zip.write(
|
||||||
os.path.join(source, name),
|
os.path.join(source, name),
|
||||||
@ -272,11 +272,9 @@ class ThemeManager(QtGui.QWidget):
|
|||||||
#check to see file is in theme root directory
|
#check to see file is in theme root directory
|
||||||
theme = os.path.join(self.path, name)
|
theme = os.path.join(self.path, name)
|
||||||
if os.path.exists(theme):
|
if os.path.exists(theme):
|
||||||
(path, filename) = os.path.split(unicode(file))
|
|
||||||
textName = os.path.splitext(name)[0]
|
textName = os.path.splitext(name)[0]
|
||||||
if textName == self.global_theme:
|
if textName == self.global_theme:
|
||||||
name = u'%s (%s)' % (textName,
|
name = u'%s (%s)' % (textName, self.trUtf8('default'))
|
||||||
self.trUtf8('default'))
|
|
||||||
else:
|
else:
|
||||||
name = textName
|
name = textName
|
||||||
thumb = os.path.join(self.thumbPath, u'%s.png' % textName)
|
thumb = os.path.join(self.thumbPath, u'%s.png' % textName)
|
||||||
@ -567,3 +565,4 @@ class ThemeManager(QtGui.QWidget):
|
|||||||
#theme.theme_mode
|
#theme.theme_mode
|
||||||
theme.theme_name = theme.theme_name.strip()
|
theme.theme_name = theme.theme_name.strip()
|
||||||
#theme.theme_version
|
#theme.theme_version
|
||||||
|
|
||||||
|
@ -126,7 +126,7 @@ class ImageMediaItem(MediaManagerItem):
|
|||||||
|
|
||||||
def loadList(self, list):
|
def loadList(self, list):
|
||||||
for file in list:
|
for file in list:
|
||||||
(path, filename) = os.path.split(unicode(file))
|
filename = os.path.split(unicode(file))[1]
|
||||||
thumb = os.path.join(self.servicePath, filename)
|
thumb = os.path.join(self.servicePath, filename)
|
||||||
if os.path.exists(thumb):
|
if os.path.exists(thumb):
|
||||||
if self.validate(file, thumb):
|
if self.validate(file, thumb):
|
||||||
|
@ -143,7 +143,7 @@ class MediaMediaItem(MediaManagerItem):
|
|||||||
|
|
||||||
def loadList(self, list):
|
def loadList(self, list):
|
||||||
for file in list:
|
for file in list:
|
||||||
(path, filename) = os.path.split(unicode(file))
|
filename = os.path.split(unicode(file))[1]
|
||||||
item_name = QtGui.QListWidgetItem(filename)
|
item_name = QtGui.QListWidgetItem(filename)
|
||||||
img = QtGui.QPixmap(u':/media/media_video.png').toImage()
|
img = QtGui.QPixmap(u':/media/media_video.png').toImage()
|
||||||
item_name.setIcon(build_icon(img))
|
item_name.setIcon(build_icon(img))
|
||||||
|
@ -131,7 +131,7 @@ class PresentationMediaItem(MediaManagerItem):
|
|||||||
for file in list:
|
for file in list:
|
||||||
if currlist.count(file) > 0:
|
if currlist.count(file) > 0:
|
||||||
continue
|
continue
|
||||||
(path, filename) = os.path.split(unicode(file))
|
filename = os.path.split(unicode(file))[1]
|
||||||
if titles.count(filename) > 0:
|
if titles.count(filename) > 0:
|
||||||
QtGui.QMessageBox.critical(
|
QtGui.QMessageBox.critical(
|
||||||
self, self.trUtf8('File exists'), self.trUtf8(
|
self, self.trUtf8('File exists'), self.trUtf8(
|
||||||
|
@ -256,35 +256,35 @@ class MessageListener(object):
|
|||||||
self.previewHandler.slide(slide, isLive)
|
self.previewHandler.slide(slide, isLive)
|
||||||
|
|
||||||
def first(self, message):
|
def first(self, message):
|
||||||
isLive, item = self.decode_message(message)
|
isLive = self.decode_message(message)[0]
|
||||||
if isLive:
|
if isLive:
|
||||||
self.liveHandler.first()
|
self.liveHandler.first()
|
||||||
else:
|
else:
|
||||||
self.previewHandler.first()
|
self.previewHandler.first()
|
||||||
|
|
||||||
def last(self, message):
|
def last(self, message):
|
||||||
isLive, item = self.decode_message(message)
|
isLive = self.decode_message(message)[0]
|
||||||
if isLive:
|
if isLive:
|
||||||
self.liveHandler.last()
|
self.liveHandler.last()
|
||||||
else:
|
else:
|
||||||
self.previewHandler.last()
|
self.previewHandler.last()
|
||||||
|
|
||||||
def next(self, message):
|
def next(self, message):
|
||||||
isLive, item = self.decode_message(message)
|
isLive = self.decode_message(message)[0]
|
||||||
if isLive:
|
if isLive:
|
||||||
self.liveHandler.next()
|
self.liveHandler.next()
|
||||||
else:
|
else:
|
||||||
self.previewHandler.next()
|
self.previewHandler.next()
|
||||||
|
|
||||||
def previous(self, message):
|
def previous(self, message):
|
||||||
isLive, item = self.decode_message(message)
|
isLive = self.decode_message(message)[0]
|
||||||
if isLive:
|
if isLive:
|
||||||
self.liveHandler.previous()
|
self.liveHandler.previous()
|
||||||
else:
|
else:
|
||||||
self.previewHandler.previous()
|
self.previewHandler.previous()
|
||||||
|
|
||||||
def shutdown(self, message):
|
def shutdown(self, message):
|
||||||
isLive, item = self.decode_message(message)
|
isLive = self.decode_message(message)[0]
|
||||||
if isLive:
|
if isLive:
|
||||||
Receiver.send_message(u'maindisplay_show')
|
Receiver.send_message(u'maindisplay_show')
|
||||||
self.liveHandler.shutdown()
|
self.liveHandler.shutdown()
|
||||||
@ -292,17 +292,17 @@ class MessageListener(object):
|
|||||||
self.previewHandler.shutdown()
|
self.previewHandler.shutdown()
|
||||||
|
|
||||||
def hide(self, message):
|
def hide(self, message):
|
||||||
isLive, item = self.decode_message(message)
|
isLive = self.decode_message(message)[0]
|
||||||
if isLive:
|
if isLive:
|
||||||
self.liveHandler.stop()
|
self.liveHandler.stop()
|
||||||
|
|
||||||
def blank(self, message):
|
def blank(self, message):
|
||||||
isLive, item = self.decode_message(message)
|
isLive = self.decode_message(message)[0]
|
||||||
if isLive:
|
if isLive:
|
||||||
self.liveHandler.blank()
|
self.liveHandler.blank()
|
||||||
|
|
||||||
def unblank(self, message):
|
def unblank(self, message):
|
||||||
isLive, item = self.decode_message(message)
|
isLive = self.decode_message(message)[0]
|
||||||
if isLive:
|
if isLive:
|
||||||
self.liveHandler.unblank()
|
self.liveHandler.unblank()
|
||||||
|
|
||||||
|
@ -191,7 +191,7 @@ class HttpConnection(object):
|
|||||||
path = os.path.normpath(os.path.join(self.parent.html_dir, filename))
|
path = os.path.normpath(os.path.join(self.parent.html_dir, filename))
|
||||||
if not path.startswith(self.parent.html_dir):
|
if not path.startswith(self.parent.html_dir):
|
||||||
return None
|
return None
|
||||||
(fileroot, ext) = os.path.splitext(filename)
|
ext = os.path.splitext(filename)[1]
|
||||||
if ext == u'.html':
|
if ext == u'.html':
|
||||||
mimetype = u'text/html'
|
mimetype = u'text/html'
|
||||||
elif ext == u'.css':
|
elif ext == u'.css':
|
||||||
|
Loading…
Reference in New Issue
Block a user