forked from openlp/openlp
Head r1210
This commit is contained in:
commit
6e41a1c898
@ -266,7 +266,7 @@ class MediaManagerItem(QtGui.QWidget):
|
|||||||
"""
|
"""
|
||||||
Creates the main widget for listing items the media item is tracking
|
Creates the main widget for listing items the media item is tracking
|
||||||
"""
|
"""
|
||||||
#Add the List widget
|
# Add the List widget
|
||||||
self.listView = self.ListViewWithDnD_class(self)
|
self.listView = self.ListViewWithDnD_class(self)
|
||||||
self.listView.uniformItemSizes = True
|
self.listView.uniformItemSizes = True
|
||||||
self.listView.setSpacing(1)
|
self.listView.setSpacing(1)
|
||||||
@ -275,9 +275,9 @@ class MediaManagerItem(QtGui.QWidget):
|
|||||||
self.listView.setAlternatingRowColors(True)
|
self.listView.setAlternatingRowColors(True)
|
||||||
self.listView.setDragEnabled(True)
|
self.listView.setDragEnabled(True)
|
||||||
self.listView.setObjectName(u'%sListView' % self.plugin.name)
|
self.listView.setObjectName(u'%sListView' % self.plugin.name)
|
||||||
#Add to pageLayout
|
# Add to pageLayout
|
||||||
self.pageLayout.addWidget(self.listView)
|
self.pageLayout.addWidget(self.listView)
|
||||||
#define and add the context menu
|
# define and add the context menu
|
||||||
self.listView.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu)
|
self.listView.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu)
|
||||||
name_string = self.plugin.getString(StringContent.Name)
|
name_string = self.plugin.getString(StringContent.Name)
|
||||||
if self.hasEditIcon:
|
if self.hasEditIcon:
|
||||||
|
@ -69,7 +69,7 @@ class ThemeManager(QtGui.QWidget):
|
|||||||
u':/themes/theme_edit.png',
|
u':/themes/theme_edit.png',
|
||||||
translate('OpenLP.ThemeManager', 'Edit a theme.'),
|
translate('OpenLP.ThemeManager', 'Edit a theme.'),
|
||||||
self.onEditTheme)
|
self.onEditTheme)
|
||||||
self.toolbar.addToolbarButton(
|
self.deleteToolbarAction = self.toolbar.addToolbarButton(
|
||||||
translate('OpenLP.ThemeManager', 'Delete Theme'),
|
translate('OpenLP.ThemeManager', 'Delete Theme'),
|
||||||
u':/general/general_delete.png',
|
u':/general/general_delete.png',
|
||||||
translate('OpenLP.ThemeManager', 'Delete a theme.'),
|
translate('OpenLP.ThemeManager', 'Delete a theme.'),
|
||||||
@ -124,6 +124,9 @@ class ThemeManager(QtGui.QWidget):
|
|||||||
QtCore.QObject.connect(self.themeListWidget,
|
QtCore.QObject.connect(self.themeListWidget,
|
||||||
QtCore.SIGNAL(u'doubleClicked(QModelIndex)'),
|
QtCore.SIGNAL(u'doubleClicked(QModelIndex)'),
|
||||||
self.changeGlobalFromScreen)
|
self.changeGlobalFromScreen)
|
||||||
|
QtCore.QObject.connect(self.themeListWidget,
|
||||||
|
QtCore.SIGNAL(u'itemClicked(QListWidgetItem *)'),
|
||||||
|
self.checkListState)
|
||||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||||
QtCore.SIGNAL(u'theme_update_global'), self.changeGlobalFromTab)
|
QtCore.SIGNAL(u'theme_update_global'), self.changeGlobalFromTab)
|
||||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||||
@ -147,6 +150,18 @@ class ThemeManager(QtGui.QWidget):
|
|||||||
self.settingsSection + u'/global theme',
|
self.settingsSection + u'/global theme',
|
||||||
QtCore.QVariant(u'')).toString())
|
QtCore.QVariant(u'')).toString())
|
||||||
|
|
||||||
|
def checkListState(self, item):
|
||||||
|
"""
|
||||||
|
If Default theme selected remove delete button.
|
||||||
|
"""
|
||||||
|
realThemeName = unicode(item.data(QtCore.Qt.UserRole).toString())
|
||||||
|
themeName = unicode(item.text())
|
||||||
|
# If default theme restrict actions
|
||||||
|
if realThemeName == themeName:
|
||||||
|
self.deleteToolbarAction.setVisible(True)
|
||||||
|
else:
|
||||||
|
self.deleteToolbarAction.setVisible(False)
|
||||||
|
|
||||||
def contextMenu(self, point):
|
def contextMenu(self, point):
|
||||||
"""
|
"""
|
||||||
Build the Right Click Context menu and set state depending on
|
Build the Right Click Context menu and set state depending on
|
||||||
|
@ -207,7 +207,7 @@ def check_latest_version(current_version):
|
|||||||
The current version of OpenLP.
|
The current version of OpenLP.
|
||||||
"""
|
"""
|
||||||
version_string = current_version[u'full']
|
version_string = current_version[u'full']
|
||||||
#set to prod in the distribution config file.
|
# set to prod in the distribution config file.
|
||||||
settings = QtCore.QSettings()
|
settings = QtCore.QSettings()
|
||||||
settings.beginGroup(u'general')
|
settings.beginGroup(u'general')
|
||||||
last_test = unicode(settings.value(u'last version test',
|
last_test = unicode(settings.value(u'last version test',
|
||||||
|
@ -448,7 +448,7 @@ class SongMediaItem(MediaManagerItem):
|
|||||||
if self.addSongFromService:
|
if self.addSongFromService:
|
||||||
editId = self.openLyrics.xml_to_song(item.xml_version)
|
editId = self.openLyrics.xml_to_song(item.xml_version)
|
||||||
# Update service with correct song id.
|
# Update service with correct song id.
|
||||||
if editId != 0:
|
if editId:
|
||||||
Receiver.send_message(u'service_item_update',
|
Receiver.send_message(u'service_item_update',
|
||||||
u'%s:%s' % (editId, item._uuid))
|
u'%s:%s' % (editId, item._uuid))
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ class OpenLyricsImport(SongImport):
|
|||||||
parser = etree.XMLParser(remove_blank_text=True)
|
parser = etree.XMLParser(remove_blank_text=True)
|
||||||
file = etree.parse(file_path, parser)
|
file = etree.parse(file_path, parser)
|
||||||
xml = unicode(etree.tostring(file))
|
xml = unicode(etree.tostring(file))
|
||||||
if self.openLyrics.xml_to_song(xml) == 0:
|
if self.openLyrics.xml_to_song(xml) is None:
|
||||||
log.debug(u'File could not be imported: %s' % file_path)
|
log.debug(u'File could not be imported: %s' % file_path)
|
||||||
# Importing this song failed! For now we stop import.
|
# Importing this song failed! For now we stop import.
|
||||||
return False
|
return False
|
||||||
|
@ -143,10 +143,11 @@ class SongXML(object):
|
|||||||
|
|
||||||
class OpenLyrics(object):
|
class OpenLyrics(object):
|
||||||
"""
|
"""
|
||||||
This class represents the converter for OpenLyrics XML to/from a song.
|
This class represents the converter for OpenLyrics XML (version 0.7)
|
||||||
|
to/from a song.
|
||||||
|
|
||||||
As OpenLyrics has a rich set of different features, we cannot support them
|
As OpenLyrics has a rich set of different features, we cannot support them
|
||||||
all. The following features are supported by the :class:`OpenLyricsParser`::
|
all. The following features are supported by the :class:`OpenLyrics`::
|
||||||
|
|
||||||
*<authors>*
|
*<authors>*
|
||||||
OpenLP does not support the attribute *type* and *lang*.
|
OpenLP does not support the attribute *type* and *lang*.
|
||||||
@ -203,7 +204,7 @@ class OpenLyrics(object):
|
|||||||
def __init__(self, manager):
|
def __init__(self, manager):
|
||||||
self.manager = manager
|
self.manager = manager
|
||||||
|
|
||||||
def song_to_xml(self, song, pretty_print=False):
|
def song_to_xml(self, song):
|
||||||
"""
|
"""
|
||||||
Convert the song to OpenLyrics Format.
|
Convert the song to OpenLyrics Format.
|
||||||
"""
|
"""
|
||||||
@ -253,7 +254,7 @@ class OpenLyrics(object):
|
|||||||
element = self._add_text_to_element(u'lines', element)
|
element = self._add_text_to_element(u'lines', element)
|
||||||
for line in unicode(verse[1]).split(u'\n'):
|
for line in unicode(verse[1]).split(u'\n'):
|
||||||
self._add_text_to_element(u'line', element, line)
|
self._add_text_to_element(u'line', element, line)
|
||||||
return self._extract_xml(song_xml, pretty_print)
|
return self._extract_xml(song_xml)
|
||||||
|
|
||||||
def xml_to_song(self, xml):
|
def xml_to_song(self, xml):
|
||||||
"""
|
"""
|
||||||
@ -266,7 +267,7 @@ class OpenLyrics(object):
|
|||||||
"""
|
"""
|
||||||
# No xml get out of here.
|
# No xml get out of here.
|
||||||
if not xml:
|
if not xml:
|
||||||
return 0
|
return None
|
||||||
song = Song()
|
song = Song()
|
||||||
if xml[:5] == u'<?xml':
|
if xml[:5] == u'<?xml':
|
||||||
xml = xml[38:]
|
xml = xml[38:]
|
||||||
@ -296,12 +297,12 @@ class OpenLyrics(object):
|
|||||||
parent.append(element)
|
parent.append(element)
|
||||||
return element
|
return element
|
||||||
|
|
||||||
def _extract_xml(self, xml, pretty_print):
|
def _extract_xml(self, xml):
|
||||||
"""
|
"""
|
||||||
Extract our newly created XML song.
|
Extract our newly created XML song.
|
||||||
"""
|
"""
|
||||||
return etree.tostring(xml, encoding=u'UTF-8',
|
return etree.tostring(xml, encoding=u'UTF-8',
|
||||||
xml_declaration=True, pretty_print=pretty_print)
|
xml_declaration=True)
|
||||||
|
|
||||||
def _get(self, element, attribute):
|
def _get(self, element, attribute):
|
||||||
"""
|
"""
|
||||||
@ -495,7 +496,7 @@ class OpenLyrics(object):
|
|||||||
song.song_number = self._get(songbook, u'entry')
|
song.song_number = self._get(songbook, u'entry')
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
pass
|
pass
|
||||||
# We does only support one song book, so take the first one.
|
# We only support one song book, so take the first one.
|
||||||
break
|
break
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
pass
|
pass
|
||||||
|
Loading…
Reference in New Issue
Block a user