forked from openlp/openlp
Head
This commit is contained in:
commit
3ea9ed2643
@ -229,7 +229,7 @@ def context_menu_separator(base):
|
||||
|
||||
def image_to_byte(image):
|
||||
"""
|
||||
Resize an image to fit on the current screen for the web and retuns
|
||||
Resize an image to fit on the current screen for the web and returns
|
||||
it as a byte stream.
|
||||
|
||||
``image``
|
||||
@ -253,12 +253,16 @@ def resize_image(image, width, height, background=QtCore.Qt.black):
|
||||
|
||||
``image``
|
||||
The image to resize.
|
||||
|
||||
``width``
|
||||
The new image width.
|
||||
|
||||
``height``
|
||||
The new image height.
|
||||
``background ``
|
||||
|
||||
``background``
|
||||
The background colour defaults to black.
|
||||
|
||||
"""
|
||||
preview = QtGui.QImage(image)
|
||||
if not preview.isNull():
|
||||
|
@ -253,7 +253,7 @@ Therefore one table for text, one for outline and one for shadow.
|
||||
</html>
|
||||
"""
|
||||
|
||||
def build_html(item, screen, alert):
|
||||
def build_html(item, screen, alert, islive):
|
||||
"""
|
||||
Build the full web paged structure for display
|
||||
|
||||
@ -274,11 +274,11 @@ def build_html(item, screen, alert):
|
||||
html = HTMLSRC % (width, height,
|
||||
build_alert(alert, width),
|
||||
build_footer(item),
|
||||
build_lyrics(item),
|
||||
build_lyrics(item, islive),
|
||||
image)
|
||||
return html
|
||||
|
||||
def build_lyrics(item):
|
||||
def build_lyrics(item, islive):
|
||||
"""
|
||||
Build the video display div
|
||||
|
||||
@ -307,10 +307,10 @@ td.fadeout { opacity: 0; }
|
||||
transition = u''
|
||||
if theme:
|
||||
lyricscommon = u'width: %spx; height: %spx; word-wrap: break-word; ' \
|
||||
u'font-family: %s; font-size: %spx; color: %s; line-height: %d%%;' % \
|
||||
(item.main.width(), item.main.height(),
|
||||
theme.font_main_name, theme.font_main_proportion,
|
||||
theme.font_main_color, 100 + int(theme.font_main_line_adjustment))
|
||||
u'font-family: %s; font-size: %spt; color: %s; line-height: %d%%;' \
|
||||
% (item.main.width(), item.main.height(), theme.font_main_name,
|
||||
theme.font_main_proportion, theme.font_main_color,
|
||||
100 + int(theme.font_main_line_adjustment))
|
||||
lyricstable = u'left: %spx; top: %spx;' % \
|
||||
(item.main.x(), item.main.y())
|
||||
outlinetable = u'left: %spx; top: %spx;' % \
|
||||
@ -319,7 +319,7 @@ td.fadeout { opacity: 0; }
|
||||
(item.main.x() + float(theme.display_shadow_size),
|
||||
item.main.y() + float(theme.display_shadow_size))
|
||||
align = u''
|
||||
if theme.display_slideTransition:
|
||||
if theme.display_slideTransition and islive:
|
||||
transition = u'-webkit-transition: opacity 5s ease-in-out;'
|
||||
if theme.display_horizontalAlign == 2:
|
||||
align = u'text-align:center;'
|
||||
@ -341,7 +341,7 @@ td.fadeout { opacity: 0; }
|
||||
theme.display_outline_color)
|
||||
if theme.display_shadow:
|
||||
shadow = u'-webkit-text-stroke: %sem %s; ' \
|
||||
u'-webkit-text-fill-color: %s; '% \
|
||||
u'-webkit-text-fill-color: %s; ' % \
|
||||
(float(theme.display_outline_size) / 16,
|
||||
theme.display_shadow_color, theme.display_shadow_color)
|
||||
else:
|
||||
@ -364,7 +364,7 @@ top: %spx;
|
||||
width: %spx;
|
||||
height: %spx;
|
||||
font-family: %s;
|
||||
font-size: %spx;
|
||||
font-size: %spt;
|
||||
color: %s;
|
||||
text-align: %s;
|
||||
"""
|
||||
@ -393,7 +393,7 @@ def build_alert(alertTab, width):
|
||||
width: %s;
|
||||
vertical-align: %s;
|
||||
font-family: %s;
|
||||
font-size: %spx;
|
||||
font-size: %spt;
|
||||
color: %s;
|
||||
background-color: %s;
|
||||
"""
|
||||
|
@ -200,7 +200,7 @@ class RenderManager(object):
|
||||
serviceItem.raw_footer = footer
|
||||
serviceItem.render(True)
|
||||
self.display.buildHtml(serviceItem)
|
||||
frame, raw_html = serviceItem.get_rendered_frame(0)
|
||||
raw_html = serviceItem.get_rendered_frame(0)[1]
|
||||
preview = self.display.text(raw_html)
|
||||
# Reset the real screen size for subsequent render requests
|
||||
self.calculate_default(self.screens.current[u'size'])
|
||||
|
@ -204,7 +204,7 @@ class Theme(object):
|
||||
val = element_text
|
||||
if (element.tag.find(u'Color') > 0 or
|
||||
(element.tag.find(u'BackgroundParameter') == 0 and
|
||||
isinstance(int, val))):
|
||||
isinstance(val, int))):
|
||||
# convert to a wx.Colour
|
||||
if not delphi_color_change:
|
||||
val = QtGui.QColor(
|
||||
|
@ -41,7 +41,6 @@ from PyQt4 import QtCore, QtGui
|
||||
from openlp.core.lib import html_expands, translate, context_menu_action
|
||||
|
||||
class SpellTextEdit(QtGui.QPlainTextEdit):
|
||||
|
||||
def __init__(self, *args):
|
||||
QtGui.QPlainTextEdit.__init__(self, *args)
|
||||
# Default dictionary based on the current locale.
|
||||
@ -54,18 +53,17 @@ class SpellTextEdit(QtGui.QPlainTextEdit):
|
||||
if event.button() == QtCore.Qt.RightButton:
|
||||
# Rewrite the mouse event to a left button event so the cursor is
|
||||
# moved to the location of the pointer.
|
||||
event = QtGui.QMouseEvent(QtCore.QEvent.MouseButtonPress, event.pos(),
|
||||
QtCore.Qt.LeftButton, QtCore.Qt.LeftButton, QtCore.Qt.NoModifier)
|
||||
event = QtGui.QMouseEvent(QtCore.QEvent.MouseButtonPress,
|
||||
event.pos(), QtCore.Qt.LeftButton, QtCore.Qt.LeftButton,
|
||||
QtCore.Qt.NoModifier)
|
||||
QtGui.QPlainTextEdit.mousePressEvent(self, event)
|
||||
|
||||
def contextMenuEvent(self, event):
|
||||
popup_menu = self.createStandardContextMenu()
|
||||
|
||||
# Select the word under the cursor.
|
||||
cursor = self.textCursor()
|
||||
cursor.select(QtGui.QTextCursor.WordUnderCursor)
|
||||
self.setTextCursor(cursor)
|
||||
|
||||
# Check if the selected word is misspelled and offer spelling
|
||||
# suggestions if it is.
|
||||
if enchant_available and self.textCursor().hasSelection():
|
||||
@ -94,9 +92,9 @@ class SpellTextEdit(QtGui.QPlainTextEdit):
|
||||
popup_menu.exec_(event.globalPos())
|
||||
|
||||
def correctWord(self, word):
|
||||
'''
|
||||
"""
|
||||
Replaces the selected text with word.
|
||||
'''
|
||||
"""
|
||||
cursor = self.textCursor()
|
||||
cursor.beginEditBlock()
|
||||
|
||||
@ -106,9 +104,9 @@ class SpellTextEdit(QtGui.QPlainTextEdit):
|
||||
cursor.endEditBlock()
|
||||
|
||||
def htmlTag(self, tag):
|
||||
'''
|
||||
"""
|
||||
Replaces the selected text with word.
|
||||
'''
|
||||
"""
|
||||
for html in html_expands:
|
||||
if tag == html[u'desc']:
|
||||
cursor = self.textCursor()
|
||||
@ -153,9 +151,9 @@ class Highlighter(QtGui.QSyntaxHighlighter):
|
||||
word_object.end() - word_object.start(), format)
|
||||
|
||||
class SpellAction(QtGui.QAction):
|
||||
'''
|
||||
"""
|
||||
A special QAction that returns the text in a signal.
|
||||
'''
|
||||
"""
|
||||
correct = QtCore.pyqtSignal(unicode)
|
||||
|
||||
def __init__(self, *args):
|
||||
|
@ -31,7 +31,7 @@ from PyQt4 import QtCore, QtGui, QtWebKit
|
||||
from PyQt4.phonon import Phonon
|
||||
|
||||
from openlp.core.lib import Receiver, resize_image, build_html, ServiceItem, \
|
||||
image_to_byte
|
||||
image_to_byte
|
||||
from openlp.core.ui import HideMode
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
@ -58,6 +58,9 @@ class DisplayWidget(QtGui.QGraphicsView):
|
||||
self.setStyleSheet(u'border: none;')
|
||||
|
||||
def keyPressEvent(self, event):
|
||||
"""
|
||||
Handle key events from display screen
|
||||
"""
|
||||
# Key events only needed for live
|
||||
if not self.live:
|
||||
return
|
||||
@ -104,6 +107,9 @@ class MainDisplay(DisplayWidget):
|
||||
QtCore.SIGNAL(u'maindisplay_show'), self.showDisplay)
|
||||
|
||||
def setup(self):
|
||||
"""
|
||||
Set up and build the output screen
|
||||
"""
|
||||
log.debug(u'Setup live = %s for %s ' % (self.isLive,
|
||||
self.screens.monitor_number))
|
||||
self.screen = self.screens.current
|
||||
@ -146,12 +152,12 @@ class MainDisplay(DisplayWidget):
|
||||
splash_image)
|
||||
serviceItem = ServiceItem()
|
||||
serviceItem.bg_frame = initialFrame
|
||||
self.webView.setHtml(build_html(serviceItem, self.screen, \
|
||||
self.parent.alertTab))
|
||||
self.webView.setHtml(build_html(serviceItem, self.screen,
|
||||
self.parent.alertTab, self.isLive))
|
||||
self.initialFrame = True
|
||||
self.show()
|
||||
# To display or not to display?
|
||||
if not self.screen[u'primary']:
|
||||
self.show()
|
||||
self.primary = False
|
||||
else:
|
||||
self.primary = True
|
||||
@ -291,13 +297,14 @@ class MainDisplay(DisplayWidget):
|
||||
Generates a preview of the image displayed.
|
||||
"""
|
||||
log.debug(u'preview for %s', self.isLive)
|
||||
# Wait for the fade to finish before geting the preview.
|
||||
# Important otherwise preview will have incorrect text if at all !
|
||||
if self.serviceItem.themedata and \
|
||||
self.serviceItem.themedata.display_slideTransition:
|
||||
while self.frame.evaluateJavaScript(u'show_text_complete()') \
|
||||
.toString() == u'false':
|
||||
Receiver.send_message(u'openlp_process_events')
|
||||
if self.isLive:
|
||||
# Wait for the fade to finish before geting the preview.
|
||||
# Important otherwise preview will have incorrect text if at all !
|
||||
if self.serviceItem.themedata and \
|
||||
self.serviceItem.themedata.display_slideTransition:
|
||||
while self.frame.evaluateJavaScript(u'show_text_complete()') \
|
||||
.toString() == u'false':
|
||||
Receiver.send_message(u'openlp_process_events')
|
||||
# Wait for the webview to update before geting the preview.
|
||||
# Important otherwise first preview will miss the background !
|
||||
while not self.loaded:
|
||||
@ -326,12 +333,16 @@ class MainDisplay(DisplayWidget):
|
||||
self.loaded = False
|
||||
self.initialFrame = False
|
||||
self.serviceItem = serviceItem
|
||||
html = build_html(self.serviceItem, self.screen, self.parent.alertTab)
|
||||
html = build_html(self.serviceItem, self.screen, self.parent.alertTab,\
|
||||
self.isLive)
|
||||
self.webView.setHtml(html)
|
||||
if serviceItem.foot_text and serviceItem.foot_text:
|
||||
self.footer(serviceItem.foot_text)
|
||||
|
||||
def footer(self, text):
|
||||
"""
|
||||
Display the Footer
|
||||
"""
|
||||
log.debug(u'footer')
|
||||
js = "show_footer('" + \
|
||||
text.replace("\\", "\\\\").replace("\'", "\\\'") + "')"
|
||||
|
@ -94,8 +94,10 @@ class Ui_MainWindow(object):
|
||||
self.ControlSplitter.setObjectName(u'ControlSplitter')
|
||||
self.MainContentLayout.addWidget(self.ControlSplitter)
|
||||
# Create slide controllers
|
||||
self.PreviewController = SlideController(self, self.settingsmanager, self.screens)
|
||||
self.LiveController = SlideController(self, self.settingsmanager, self.screens, True)
|
||||
self.PreviewController = SlideController(self, self.settingsmanager,
|
||||
self.screens)
|
||||
self.LiveController = SlideController(self, self.settingsmanager,
|
||||
self.screens, True)
|
||||
# Create menu
|
||||
self.MenuBar = QtGui.QMenuBar(MainWindow)
|
||||
self.MenuBar.setGeometry(QtCore.QRect(0, 0, 1087, 27))
|
||||
|
@ -117,7 +117,8 @@ class SlideController(QtGui.QWidget):
|
||||
self.split = 1
|
||||
self.typePrefix = u'live'
|
||||
else:
|
||||
self.TypeLabel.setText(translate('OpenLP.SlideController', 'Preview'))
|
||||
self.TypeLabel.setText(translate('OpenLP.SlideController',
|
||||
'Preview'))
|
||||
self.split = 0
|
||||
self.typePrefix = u'preview'
|
||||
self.TypeLabel.setStyleSheet(u'font-weight: bold; font-size: 12pt;')
|
||||
@ -199,7 +200,8 @@ class SlideController(QtGui.QWidget):
|
||||
QtCore.SIGNAL("triggered(bool)"), self.onThemeDisplay)
|
||||
if self.screens.display_count > 1:
|
||||
self.DesktopScreen = QtGui.QAction(QtGui.QIcon(
|
||||
u':/slides/slide_desktop.png'), u'Show Desktop', self.HideMenu)
|
||||
u':/slides/slide_desktop.png'), u'Show Desktop',
|
||||
self.HideMenu)
|
||||
self.DesktopScreen.setCheckable(True)
|
||||
QtCore.QObject.connect(self.DesktopScreen,
|
||||
QtCore.SIGNAL("triggered(bool)"), self.onHideDisplay)
|
||||
@ -212,7 +214,8 @@ class SlideController(QtGui.QWidget):
|
||||
self.Toolbar.addToolbarSeparator(u'Close Separator')
|
||||
self.Toolbar.addToolbarButton(
|
||||
u'Go Live', u':/general/general_live.png',
|
||||
translate('OpenLP.SlideController', 'Move to live'), self.onGoLive)
|
||||
translate('OpenLP.SlideController', 'Move to live'),
|
||||
self.onGoLive)
|
||||
self.Toolbar.addToolbarSeparator(u'Close Separator')
|
||||
self.Toolbar.addToolbarButton(
|
||||
u'Edit Song', u':/general/general_edit.png',
|
||||
@ -233,7 +236,8 @@ class SlideController(QtGui.QWidget):
|
||||
self.DelaySpinBox.setMaximum(180)
|
||||
self.Toolbar.addToolbarWidget(
|
||||
u'Image SpinBox', self.DelaySpinBox)
|
||||
self.DelaySpinBox.setSuffix(translate('OpenLP.SlideController', 's'))
|
||||
self.DelaySpinBox.setSuffix(translate('OpenLP.SlideController',
|
||||
's'))
|
||||
self.DelaySpinBox.setToolTip(translate('OpenLP.SlideController',
|
||||
'Delay between slides in seconds'))
|
||||
self.ControllerLayout.addWidget(self.Toolbar)
|
||||
@ -274,11 +278,13 @@ class SlideController(QtGui.QWidget):
|
||||
# Build the Song Toolbar
|
||||
if isLive:
|
||||
self.SongMenu = QtGui.QToolButton(self.Toolbar)
|
||||
self.SongMenu.setText(translate('OpenLP.SlideController', 'Go to Verse'))
|
||||
self.SongMenu.setText(translate('OpenLP.SlideController',
|
||||
'Go to Verse'))
|
||||
self.SongMenu.setPopupMode(QtGui.QToolButton.InstantPopup)
|
||||
self.Toolbar.addToolbarWidget(u'Song Menu', self.SongMenu)
|
||||
self.SongMenu.setMenu(QtGui.QMenu(
|
||||
translate('OpenLP.SlideController', 'Go to Verse'), self.Toolbar))
|
||||
translate('OpenLP.SlideController', 'Go to Verse'),
|
||||
self.Toolbar))
|
||||
self.Toolbar.makeWidgetsInvisible([u'Song Menu'])
|
||||
# Screen preview area
|
||||
self.PreviewFrame = QtGui.QFrame(self.Splitter)
|
||||
@ -317,7 +323,7 @@ class SlideController(QtGui.QWidget):
|
||||
self.SlidePreview.setSizePolicy(sizePolicy)
|
||||
self.SlidePreview.setFixedSize(
|
||||
QtCore.QSize(self.settingsmanager.slidecontroller_image,
|
||||
self.settingsmanager.slidecontroller_image / self.ratio ))
|
||||
self.settingsmanager.slidecontroller_image / self.ratio))
|
||||
self.SlidePreview.setFrameShape(QtGui.QFrame.Box)
|
||||
self.SlidePreview.setFrameShadow(QtGui.QFrame.Plain)
|
||||
self.SlidePreview.setLineWidth(1)
|
||||
@ -404,7 +410,7 @@ class SlideController(QtGui.QWidget):
|
||||
self.display.setup()
|
||||
self.SlidePreview.setFixedSize(
|
||||
QtCore.QSize(self.settingsmanager.slidecontroller_image,
|
||||
self.settingsmanager.slidecontroller_image / self.ratio ))
|
||||
self.settingsmanager.slidecontroller_image / self.ratio))
|
||||
|
||||
def widthChanged(self):
|
||||
"""
|
||||
|
@ -139,13 +139,13 @@ class ThemeManager(QtGui.QWidget):
|
||||
"""
|
||||
log.debug(u'changeGlobalFromTab %s', themeName)
|
||||
for count in range (0, self.themeListWidget.count()):
|
||||
#reset the old name
|
||||
# reset the old name
|
||||
item = self.themeListWidget.item(count)
|
||||
oldName = item.text()
|
||||
newName = unicode(item.data(QtCore.Qt.UserRole).toString())
|
||||
if oldName != newName:
|
||||
self.themeListWidget.item(count).setText(newName)
|
||||
#Set the new name
|
||||
# Set the new name
|
||||
if themeName == newName:
|
||||
name = unicode(translate('OpenLP.ThemeManager',
|
||||
'%s (default)')) % newName
|
||||
@ -161,11 +161,11 @@ class ThemeManager(QtGui.QWidget):
|
||||
for count in range (0, self.themeListWidget.count()):
|
||||
item = self.themeListWidget.item(count)
|
||||
oldName = item.text()
|
||||
#reset the old name
|
||||
# reset the old name
|
||||
if oldName != unicode(item.data(QtCore.Qt.UserRole).toString()):
|
||||
self.themeListWidget.item(count).setText(
|
||||
unicode(item.data(QtCore.Qt.UserRole).toString()))
|
||||
#Set the new name
|
||||
# Set the new name
|
||||
if count == selected_row:
|
||||
self.global_theme = unicode(
|
||||
self.themeListWidget.item(count).text())
|
||||
@ -295,7 +295,7 @@ class ThemeManager(QtGui.QWidget):
|
||||
path = unicode(path)
|
||||
if path:
|
||||
SettingsManager.set_last_dir(self.settingsSection, path, 1)
|
||||
themePath = os.path.join(path, theme + u'.thz')
|
||||
themePath = os.path.join(path, theme + u'.otz')
|
||||
zip = None
|
||||
try:
|
||||
zip = zipfile.ZipFile(themePath, u'w')
|
||||
@ -346,11 +346,10 @@ class ThemeManager(QtGui.QWidget):
|
||||
log.debug(u'Load themes from dir')
|
||||
self.themelist = []
|
||||
self.themeListWidget.clear()
|
||||
#root, dirs, files = os.walk(self.path)
|
||||
dirList = os.listdir(self.path)
|
||||
for name in dirList:
|
||||
if name.endswith(u'.png'):
|
||||
#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)
|
||||
if os.path.exists(theme):
|
||||
textName = os.path.splitext(name)[0]
|
||||
@ -731,8 +730,6 @@ class ThemeManager(QtGui.QWidget):
|
||||
theme.display_slideTransition = theme.display_slideTransition
|
||||
theme.font_footer_color = theme.font_footer_color.strip()
|
||||
theme.font_footer_height = int(theme.font_footer_height.strip())
|
||||
# theme.font_footer_indentation = \
|
||||
# int(theme.font_footer_indentation.strip())
|
||||
theme.font_footer_italics = str_to_bool(theme.font_footer_italics)
|
||||
theme.font_footer_name = theme.font_footer_name.strip()
|
||||
#theme.font_footer_override
|
||||
@ -745,7 +742,6 @@ class ThemeManager(QtGui.QWidget):
|
||||
theme.font_main_color = theme.font_main_color.strip()
|
||||
theme.font_main_height = int(theme.font_main_height.strip())
|
||||
theme.font_main_italics = str_to_bool(theme.font_main_italics)
|
||||
# theme.font_main_indentation = int(theme.font_main_indentation)
|
||||
theme.font_main_name = theme.font_main_name.strip()
|
||||
#theme.font_main_override
|
||||
theme.font_main_proportion = int(theme.font_main_proportion.strip())
|
||||
|
@ -83,7 +83,7 @@ class AlertsPlugin(Plugin):
|
||||
self.liveController.alertTab = self.alertsTab
|
||||
|
||||
def finalise(self):
|
||||
log.info(u'Alerts Finaliseing')
|
||||
log.info(u'Alerts Finalising')
|
||||
Plugin.finalise(self)
|
||||
self.toolsAlertItem.setVisible(False)
|
||||
|
||||
|
@ -465,9 +465,9 @@ class BibleMediaItem(MediaManagerItem):
|
||||
self.displayResults(bible, dual_bible)
|
||||
|
||||
def generateSlideData(self, service_item, item=None):
|
||||
'''
|
||||
"""
|
||||
Generates and formats the slides for the service item.
|
||||
'''
|
||||
"""
|
||||
log.debug(u'generating slide data')
|
||||
items = self.listView.selectedIndexes()
|
||||
if len(items) == 0:
|
||||
@ -551,7 +551,8 @@ class BibleMediaItem(MediaManagerItem):
|
||||
if isinstance(reference, QtCore.QVariant):
|
||||
reference = reference.toPyObject()
|
||||
bible_new = self._decodeQtObject(reference, 'bible')
|
||||
dual_bible_new = self._decodeQtObject(reference, 'dual_bible')
|
||||
dual_bible_new = self._decodeQtObject(reference,
|
||||
'dual_bible')
|
||||
if dual_bible_new:
|
||||
raw_slides.append(bible_text)
|
||||
bible_text = u''
|
||||
@ -639,10 +640,10 @@ class BibleMediaItem(MediaManagerItem):
|
||||
combo.addItem(unicode(i))
|
||||
|
||||
def displayResults(self, bible, dual_bible=None):
|
||||
'''
|
||||
Displays the search results in the media manager. All data needed for further
|
||||
action is saved for/in each row.
|
||||
'''
|
||||
"""
|
||||
Displays the search results in the media manager. All data needed for
|
||||
further action is saved for/in each row.
|
||||
"""
|
||||
version = self.parent.manager.get_meta_data(bible, u'Version')
|
||||
copyright = self.parent.manager.get_meta_data(bible, u'Copyright')
|
||||
#permission = self.parent.manager.get_meta_data(bible, u'Permissions')
|
||||
|
@ -263,8 +263,8 @@ class Ui_EditSongDialog(object):
|
||||
self.SongbookLayout.setSpacing(8)
|
||||
self.SongbookLayout.setObjectName(u'SongbookLayout')
|
||||
self.SongbookCombo = QtGui.QComboBox(self.SongBookGroup)
|
||||
sizePolicy = QtGui.QSizePolicy(
|
||||
QtGui.QSizePolicy.MinimumExpanding, QtGui.QSizePolicy.Fixed)
|
||||
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.MinimumExpanding,
|
||||
QtGui.QSizePolicy.Fixed)
|
||||
sizePolicy.setHorizontalStretch(0)
|
||||
sizePolicy.setVerticalStretch(0)
|
||||
sizePolicy.setHeightForWidth(
|
||||
@ -273,6 +273,12 @@ class Ui_EditSongDialog(object):
|
||||
self.SongbookCombo.setSizePolicy(sizePolicy)
|
||||
self.SongbookCombo.setObjectName(u'SongbookCombo')
|
||||
self.SongbookLayout.addWidget(self.SongbookCombo, 0, 0, 1, 1)
|
||||
self.songBookNumberLabel = QtGui.QLabel(self.SongBookGroup)
|
||||
self.SongbookLayout.addWidget(self.songBookNumberLabel, 0, 1, 1, 1)
|
||||
self.songBookNumberEdit = QtGui.QLineEdit(self.SongBookGroup)
|
||||
self.songBookNumberLabel.setBuddy(self.songBookNumberEdit)
|
||||
self.songBookNumberEdit.setMaximumWidth(35)
|
||||
self.SongbookLayout.addWidget(self.songBookNumberEdit, 0, 2, 1, 1)
|
||||
self.TopicBookLayout.addWidget(self.SongBookGroup)
|
||||
self.AuthorsTabLayout.addWidget(self.TopicBookWidget)
|
||||
self.SongTabWidget.addTab(self.AuthorsTab, u'')
|
||||
@ -440,6 +446,8 @@ class Ui_EditSongDialog(object):
|
||||
translate('SongsPlugin.EditSongForm', 'R&emove'))
|
||||
self.SongBookGroup.setTitle(
|
||||
translate('SongsPlugin.EditSongForm', 'Song Book'))
|
||||
self.songBookNumberLabel.setText(translate('SongsPlugin.EditSongForm',
|
||||
'Song No.:'))
|
||||
self.SongTabWidget.setTabText(
|
||||
self.SongTabWidget.indexOf(self.AuthorsTab),
|
||||
translate('SongsPlugin.EditSongForm',
|
||||
|
@ -49,6 +49,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
||||
"""
|
||||
QtGui.QDialog.__init__(self, parent)
|
||||
self.parent = parent
|
||||
self.song = None
|
||||
# can this be automated?
|
||||
self.width = 400
|
||||
self.setupUi(self)
|
||||
@ -83,10 +84,6 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
||||
QtCore.QObject.connect(self.VerseListWidget,
|
||||
QtCore.SIGNAL(u'itemClicked(QTableWidgetItem*)'),
|
||||
self.onVerseListViewPressed)
|
||||
QtCore.QObject.connect(self.SongbookCombo,
|
||||
QtCore.SIGNAL(u'activated(int)'), self.onSongBookComboChanged)
|
||||
QtCore.QObject.connect(self.ThemeSelectionComboItem,
|
||||
QtCore.SIGNAL(u'activated(int)'), self.onThemeComboChanged)
|
||||
QtCore.QObject.connect(self.ThemeAddButton,
|
||||
QtCore.SIGNAL(u'clicked()'),
|
||||
self.parent.parent.renderManager.theme_manager.onAddTheme)
|
||||
@ -157,7 +154,6 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
||||
def newSong(self):
|
||||
log.debug(u'New Song')
|
||||
self.SongTabWidget.setCurrentIndex(0)
|
||||
self.song = Song()
|
||||
self.TitleEditItem.setText(u'')
|
||||
self.AlternativeEdit.setText(u'')
|
||||
self.CopyrightEditItem.setText(u'')
|
||||
@ -298,8 +294,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
||||
else:
|
||||
author = Author.populate(first_name=text.rsplit(u' ', 1)[0],
|
||||
last_name=text.rsplit(u' ', 1)[1], display_name=text)
|
||||
self.songmanager.save_object(author, False)
|
||||
self.song.authors.append(author)
|
||||
self.songmanager.save_object(author)
|
||||
author_item = QtGui.QListWidgetItem(
|
||||
unicode(author.display_name))
|
||||
author_item.setData(QtCore.Qt.UserRole,
|
||||
@ -312,13 +307,13 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
||||
elif item > 0:
|
||||
item_id = (self.AuthorsSelectionComboItem.itemData(item)).toInt()[0]
|
||||
author = self.songmanager.get_object(Author, item_id)
|
||||
if author in self.song.authors:
|
||||
if self.AuthorsListView.findItems(unicode(author.display_name),
|
||||
QtCore.Qt.MatchExactly):
|
||||
QtGui.QMessageBox.warning(self,
|
||||
translate('SongsPlugin.EditSongForm', 'Error'),
|
||||
translate('SongsPlugin.EditSongForm', 'This author is '
|
||||
'already in the list.'))
|
||||
else:
|
||||
self.song.authors.append(author)
|
||||
author_item = QtGui.QListWidgetItem(unicode(
|
||||
author.display_name))
|
||||
author_item.setData(QtCore.Qt.UserRole,
|
||||
@ -340,9 +335,6 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
||||
def onAuthorRemoveButtonClicked(self):
|
||||
self.AuthorRemoveButton.setEnabled(False)
|
||||
item = self.AuthorsListView.currentItem()
|
||||
author_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
|
||||
author = self.songmanager.get_object(Author, author_id)
|
||||
self.song.authors.remove(author)
|
||||
row = self.AuthorsListView.row(item)
|
||||
self.AuthorsListView.takeItem(row)
|
||||
|
||||
@ -357,8 +349,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
||||
QtGui.QMessageBox.Yes | QtGui.QMessageBox.No,
|
||||
QtGui.QMessageBox.Yes) == QtGui.QMessageBox.Yes:
|
||||
topic = Topic.populate(name=text)
|
||||
self.songmanager.save_object(topic, False)
|
||||
self.song.topics.append(topic)
|
||||
self.songmanager.save_object(topic)
|
||||
topic_item = QtGui.QListWidgetItem(unicode(topic.name))
|
||||
topic_item.setData(QtCore.Qt.UserRole,
|
||||
QtCore.QVariant(topic.id))
|
||||
@ -370,13 +361,13 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
||||
elif item > 0:
|
||||
item_id = (self.SongTopicCombo.itemData(item)).toInt()[0]
|
||||
topic = self.songmanager.get_object(Topic, item_id)
|
||||
if topic in self.song.topics:
|
||||
if self.TopicsListView.findItems(unicode(topic.name),
|
||||
QtCore.Qt.MatchExactly):
|
||||
QtGui.QMessageBox.warning(self,
|
||||
translate('SongsPlugin.EditSongForm', 'Error'),
|
||||
translate('SongsPlugin.EditSongForm', 'This topic is '
|
||||
'already in the list.'))
|
||||
else:
|
||||
self.song.topics.append(topic)
|
||||
topic_item = QtGui.QListWidgetItem(unicode(topic.name))
|
||||
topic_item.setData(QtCore.Qt.UserRole,
|
||||
QtCore.QVariant(topic.id))
|
||||
@ -396,27 +387,9 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
||||
def onTopicRemoveButtonClicked(self):
|
||||
self.TopicRemoveButton.setEnabled(False)
|
||||
item = self.TopicsListView.currentItem()
|
||||
topic_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
|
||||
topic = self.songmanager.get_object(Topic, topic_id)
|
||||
self.song.topics.remove(topic)
|
||||
row = self.TopicsListView.row(item)
|
||||
self.TopicsListView.takeItem(row)
|
||||
|
||||
def onSongBookComboChanged(self, item):
|
||||
if item >= 1:
|
||||
self.song.song_book_id = \
|
||||
(self.SongbookCombo.itemData(item)).toInt()[0]
|
||||
else:
|
||||
self.song.song_book_id = 0
|
||||
|
||||
def onThemeComboChanged(self, item):
|
||||
if item == 0:
|
||||
# None means no Theme
|
||||
self.song.theme_name = None
|
||||
else:
|
||||
them_name = unicode(self.ThemeSelectionComboItem.itemText(item))
|
||||
self.song.theme_name = them_name
|
||||
|
||||
def onVerseListViewPressed(self):
|
||||
self.VerseEditButton.setEnabled(True)
|
||||
self.VerseDeleteButton.setEnabled(True)
|
||||
@ -602,10 +575,17 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
||||
self.CopyrightEditItem.setCursorPosition(pos + 1)
|
||||
|
||||
def onMaintenanceButtonClicked(self):
|
||||
temp_song_book = None
|
||||
item = int(self.SongbookCombo.currentIndex())
|
||||
text = unicode(self.SongbookCombo.currentText())
|
||||
if item == 0 and text:
|
||||
temp_song_book = text
|
||||
self.parent.song_maintenance_form.exec_()
|
||||
self.loadAuthors()
|
||||
self.loadBooks()
|
||||
self.loadTopics()
|
||||
if temp_song_book:
|
||||
self.SongbookCombo.setEditText(temp_song_book)
|
||||
|
||||
def onPreview(self, button):
|
||||
"""
|
||||
@ -622,6 +602,8 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
||||
|
||||
def accept(self):
|
||||
log.debug(u'accept')
|
||||
if not self.song:
|
||||
self.song = Song()
|
||||
item = int(self.SongbookCombo.currentIndex())
|
||||
text = unicode(self.SongbookCombo.currentText())
|
||||
if item == 0 and text:
|
||||
@ -634,7 +616,6 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
||||
book = Book.populate(name=text, publisher=u'')
|
||||
self.songmanager.save_object(book)
|
||||
self.song.book = book
|
||||
self.loadBooks()
|
||||
else:
|
||||
return
|
||||
if self.saveSong():
|
||||
@ -650,9 +631,22 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
||||
self.song.comments = unicode(self.CommentsEdit.toPlainText())
|
||||
self.song.verse_order = unicode(self.VerseOrderEdit.text())
|
||||
self.song.ccli_number = unicode(self.CCLNumberEdit.text())
|
||||
self.song.song_number = unicode(self.songBookNumberEdit.text())
|
||||
if self._validate_song():
|
||||
self.processLyrics()
|
||||
self.processTitle()
|
||||
self.song.authors = []
|
||||
for row in range(self.AuthorsListView.count()):
|
||||
item = self.AuthorsListView.item(row)
|
||||
authorId = (item.data(QtCore.Qt.UserRole)).toInt()[0]
|
||||
self.song.authors.append(self.songmanager.get_object(Author,
|
||||
authorId))
|
||||
self.song.topics = []
|
||||
for row in range(self.TopicsListView.count()):
|
||||
item = self.TopicsListView.item(row)
|
||||
topicId = (item.data(QtCore.Qt.UserRole)).toInt()[0]
|
||||
self.song.topics.append(self.songmanager.get_object(Topic,
|
||||
topicId))
|
||||
self.songmanager.save_object(self.song)
|
||||
return True
|
||||
return False
|
||||
@ -684,5 +678,5 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
||||
|
||||
def processTitle(self):
|
||||
log.debug(u'processTitle')
|
||||
self.song.search_title = \
|
||||
re.sub(r'[\'"`,;:(){}?]+', u'', unicode(self.song.search_title))
|
||||
self.song.search_title = re.sub(r'[\'"`,;:(){}?]+', u'',
|
||||
unicode(self.song.search_title))
|
||||
|
@ -31,77 +31,78 @@ from openlp.core.ui import SpellTextEdit
|
||||
from openlp.plugins.songs.lib import VerseType
|
||||
|
||||
class Ui_EditVerseDialog(object):
|
||||
def setupUi(self, EditVerseDialog):
|
||||
EditVerseDialog.setObjectName(u'EditVerseDialog')
|
||||
EditVerseDialog.resize(474, 442)
|
||||
EditVerseDialog.setModal(True)
|
||||
self.EditVerseLayout = QtGui.QVBoxLayout(EditVerseDialog)
|
||||
self.EditVerseLayout.setSpacing(8)
|
||||
self.EditVerseLayout.setMargin(8)
|
||||
self.EditVerseLayout.setObjectName(u'EditVerseLayout')
|
||||
self.VerseTextEdit = SpellTextEdit(EditVerseDialog)
|
||||
self.VerseTextEdit.setObjectName(u'VerseTextEdit')
|
||||
self.EditVerseLayout.addWidget(self.VerseTextEdit)
|
||||
self.VerseTypeLayout = QtGui.QHBoxLayout()
|
||||
self.VerseTypeLayout.setSpacing(8)
|
||||
self.VerseTypeLayout.setObjectName(u'VerseTypeLayout')
|
||||
self.VerseTypeLabel = QtGui.QLabel(EditVerseDialog)
|
||||
self.VerseTypeLabel.setObjectName(u'VerseTypeLabel')
|
||||
self.VerseTypeLayout.addWidget(self.VerseTypeLabel)
|
||||
self.VerseTypeComboBox = QtGui.QComboBox(EditVerseDialog)
|
||||
self.VerseTypeComboBox.setObjectName(u'VerseTypeComboBox')
|
||||
self.VerseTypeComboBox.addItem(u'')
|
||||
self.VerseTypeComboBox.addItem(u'')
|
||||
self.VerseTypeComboBox.addItem(u'')
|
||||
self.VerseTypeComboBox.addItem(u'')
|
||||
self.VerseTypeComboBox.addItem(u'')
|
||||
self.VerseTypeComboBox.addItem(u'')
|
||||
self.VerseTypeComboBox.addItem(u'')
|
||||
self.VerseTypeLayout.addWidget(self.VerseTypeComboBox)
|
||||
self.VerseNumberBox = QtGui.QSpinBox(EditVerseDialog)
|
||||
self.VerseNumberBox.setMinimum(1)
|
||||
self.VerseNumberBox.setObjectName(u'VerseNumberBox')
|
||||
self.VerseTypeLayout.addWidget(self.VerseNumberBox)
|
||||
self.InsertButton = QtGui.QPushButton(EditVerseDialog)
|
||||
self.InsertButton.setIcon(build_icon(u':/general/general_add.png'))
|
||||
self.InsertButton.setObjectName(u'InsertButton')
|
||||
self.VerseTypeLayout.addWidget(self.InsertButton)
|
||||
self.VerseTypeSpacer = QtGui.QSpacerItem(40, 20,
|
||||
def setupUi(self, editVerseDialog):
|
||||
editVerseDialog.setObjectName(u'editVerseDialog')
|
||||
editVerseDialog.resize(474, 442)
|
||||
editVerseDialog.setModal(True)
|
||||
self.editVerseLayout = QtGui.QVBoxLayout(editVerseDialog)
|
||||
self.editVerseLayout.setSpacing(8)
|
||||
self.editVerseLayout.setMargin(8)
|
||||
self.editVerseLayout.setObjectName(u'editVerseLayout')
|
||||
self.verseTextEdit = SpellTextEdit(editVerseDialog)
|
||||
self.verseTextEdit.setObjectName(u'verseTextEdit')
|
||||
self.editVerseLayout.addWidget(self.verseTextEdit)
|
||||
self.verseTypeLayout = QtGui.QHBoxLayout()
|
||||
self.verseTypeLayout.setSpacing(8)
|
||||
self.verseTypeLayout.setObjectName(u'verseTypeLayout')
|
||||
self.verseTypeLabel = QtGui.QLabel(editVerseDialog)
|
||||
self.verseTypeLabel.setObjectName(u'verseTypeLabel')
|
||||
self.verseTypeLayout.addWidget(self.verseTypeLabel)
|
||||
self.verseTypeComboBox = QtGui.QComboBox(editVerseDialog)
|
||||
self.verseTypeComboBox.setObjectName(u'verseTypeComboBox')
|
||||
self.verseTypeLabel.setBuddy(self.verseTypeComboBox)
|
||||
self.verseTypeComboBox.addItem(u'')
|
||||
self.verseTypeComboBox.addItem(u'')
|
||||
self.verseTypeComboBox.addItem(u'')
|
||||
self.verseTypeComboBox.addItem(u'')
|
||||
self.verseTypeComboBox.addItem(u'')
|
||||
self.verseTypeComboBox.addItem(u'')
|
||||
self.verseTypeComboBox.addItem(u'')
|
||||
self.verseTypeLayout.addWidget(self.verseTypeComboBox)
|
||||
self.verseNumberBox = QtGui.QSpinBox(editVerseDialog)
|
||||
self.verseNumberBox.setMinimum(1)
|
||||
self.verseNumberBox.setObjectName(u'verseNumberBox')
|
||||
self.verseTypeLayout.addWidget(self.verseNumberBox)
|
||||
self.insertButton = QtGui.QPushButton(editVerseDialog)
|
||||
self.insertButton.setIcon(build_icon(u':/general/general_add.png'))
|
||||
self.insertButton.setObjectName(u'insertButton')
|
||||
self.verseTypeLayout.addWidget(self.insertButton)
|
||||
self.verseTypeSpacer = QtGui.QSpacerItem(40, 20,
|
||||
QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
|
||||
self.VerseTypeLayout.addItem(self.VerseTypeSpacer)
|
||||
self.EditVerseLayout.addLayout(self.VerseTypeLayout)
|
||||
self.EditButtonBox = QtGui.QDialogButtonBox(EditVerseDialog)
|
||||
self.EditButtonBox.setOrientation(QtCore.Qt.Horizontal)
|
||||
self.EditButtonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel |
|
||||
self.verseTypeLayout.addItem(self.verseTypeSpacer)
|
||||
self.editVerseLayout.addLayout(self.verseTypeLayout)
|
||||
self.editButtonBox = QtGui.QDialogButtonBox(editVerseDialog)
|
||||
self.editButtonBox.setOrientation(QtCore.Qt.Horizontal)
|
||||
self.editButtonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel |
|
||||
QtGui.QDialogButtonBox.Save)
|
||||
self.EditButtonBox.setObjectName(u'EditButtonBox')
|
||||
self.EditVerseLayout.addWidget(self.EditButtonBox)
|
||||
self.editButtonBox.setObjectName(u'editButtonBox')
|
||||
self.editVerseLayout.addWidget(self.editButtonBox)
|
||||
|
||||
self.retranslateUi(EditVerseDialog)
|
||||
QtCore.QObject.connect(self.EditButtonBox, QtCore.SIGNAL(u'accepted()'),
|
||||
EditVerseDialog.accept)
|
||||
QtCore.QObject.connect(self.EditButtonBox, QtCore.SIGNAL(u'rejected()'),
|
||||
EditVerseDialog.reject)
|
||||
QtCore.QMetaObject.connectSlotsByName(EditVerseDialog)
|
||||
self.retranslateUi(editVerseDialog)
|
||||
QtCore.QObject.connect(self.editButtonBox, QtCore.SIGNAL(u'accepted()'),
|
||||
editVerseDialog.accept)
|
||||
QtCore.QObject.connect(self.editButtonBox, QtCore.SIGNAL(u'rejected()'),
|
||||
editVerseDialog.reject)
|
||||
QtCore.QMetaObject.connectSlotsByName(editVerseDialog)
|
||||
|
||||
def retranslateUi(self, EditVerseDialog):
|
||||
EditVerseDialog.setWindowTitle(
|
||||
def retranslateUi(self, editVerseDialog):
|
||||
editVerseDialog.setWindowTitle(
|
||||
translate('SongsPlugin.EditVerseForm', 'Edit Verse'))
|
||||
self.VerseTypeLabel.setText(
|
||||
self.verseTypeLabel.setText(
|
||||
translate('SongsPlugin.EditVerseForm', '&Verse type:'))
|
||||
self.VerseTypeComboBox.setItemText(0,
|
||||
self.verseTypeComboBox.setItemText(0,
|
||||
VerseType.to_string(VerseType.Verse))
|
||||
self.VerseTypeComboBox.setItemText(1,
|
||||
self.verseTypeComboBox.setItemText(1,
|
||||
VerseType.to_string(VerseType.Chorus))
|
||||
self.VerseTypeComboBox.setItemText(2,
|
||||
self.verseTypeComboBox.setItemText(2,
|
||||
VerseType.to_string(VerseType.Bridge))
|
||||
self.VerseTypeComboBox.setItemText(3,
|
||||
self.verseTypeComboBox.setItemText(3,
|
||||
VerseType.to_string(VerseType.PreChorus))
|
||||
self.VerseTypeComboBox.setItemText(4,
|
||||
self.verseTypeComboBox.setItemText(4,
|
||||
VerseType.to_string(VerseType.Intro))
|
||||
self.VerseTypeComboBox.setItemText(5,
|
||||
self.verseTypeComboBox.setItemText(5,
|
||||
VerseType.to_string(VerseType.Ending))
|
||||
self.VerseTypeComboBox.setItemText(6,
|
||||
self.verseTypeComboBox.setItemText(6,
|
||||
VerseType.to_string(VerseType.Other))
|
||||
self.InsertButton.setText(
|
||||
self.insertButton.setText(
|
||||
translate('SongsPlugin.EditVerseForm', '&Insert'))
|
||||
|
@ -45,19 +45,14 @@ class EditVerseForm(QtGui.QDialog, Ui_EditVerseDialog):
|
||||
"""
|
||||
QtGui.QDialog.__init__(self, parent)
|
||||
self.setupUi(self)
|
||||
QtCore.QObject.connect(self.VerseTextEdit,
|
||||
QtCore.QObject.connect(self.verseTextEdit,
|
||||
QtCore.SIGNAL('customContextMenuRequested(QPoint)'),
|
||||
self.contextMenu)
|
||||
QtCore.QObject.connect(
|
||||
self.InsertButton,
|
||||
QtCore.SIGNAL(u'clicked()'),
|
||||
self.onInsertButtonClicked
|
||||
)
|
||||
QtCore.QObject.connect(
|
||||
self.VerseTextEdit,
|
||||
QtCore.QObject.connect(self.insertButton, QtCore.SIGNAL(u'clicked()'),
|
||||
self.onInsertButtonClicked)
|
||||
QtCore.QObject.connect(self.verseTextEdit,
|
||||
QtCore.SIGNAL(u'cursorPositionChanged()'),
|
||||
self.onCursorPositionChanged
|
||||
)
|
||||
self.onCursorPositionChanged)
|
||||
self.verse_regex = re.compile(r'---\[([-\w]+):([\d]+)\]---')
|
||||
|
||||
def contextMenu(self, point):
|
||||
@ -65,21 +60,21 @@ class EditVerseForm(QtGui.QDialog, Ui_EditVerseDialog):
|
||||
print item
|
||||
|
||||
def insertVerse(self, title, num=1):
|
||||
if self.VerseTextEdit.textCursor().columnNumber() != 0:
|
||||
self.VerseTextEdit.insertPlainText(u'\n')
|
||||
self.VerseTextEdit.insertPlainText(u'---[%s:%s]---\n' % (title, num))
|
||||
self.VerseTextEdit.setFocus()
|
||||
if self.verseTextEdit.textCursor().columnNumber() != 0:
|
||||
self.verseTextEdit.insertPlainText(u'\n')
|
||||
self.verseTextEdit.insertPlainText(u'---[%s:%s]---\n' % (title, num))
|
||||
self.verseTextEdit.setFocus()
|
||||
|
||||
def onInsertButtonClicked(self):
|
||||
if self.VerseTextEdit.textCursor().columnNumber() != 0:
|
||||
self.VerseTextEdit.insertPlainText(u'\n')
|
||||
verse_type = self.VerseTypeComboBox.currentIndex()
|
||||
if self.verseTextEdit.textCursor().columnNumber() != 0:
|
||||
self.verseTextEdit.insertPlainText(u'\n')
|
||||
verse_type = self.verseTypeComboBox.currentIndex()
|
||||
if verse_type == VerseType.Verse:
|
||||
self.insertVerse(VerseType.to_string(VerseType.Verse),
|
||||
self.VerseNumberBox.value())
|
||||
self.verseNumberBox.value())
|
||||
elif verse_type == VerseType.Chorus:
|
||||
self.insertVerse(VerseType.to_string(VerseType.Chorus),
|
||||
self.VerseNumberBox.value())
|
||||
self.verseNumberBox.value())
|
||||
elif verse_type == VerseType.Bridge:
|
||||
self.insertVerse(VerseType.to_string(VerseType.Bridge))
|
||||
elif verse_type == VerseType.PreChorus:
|
||||
@ -92,12 +87,12 @@ class EditVerseForm(QtGui.QDialog, Ui_EditVerseDialog):
|
||||
self.insertVerse(VerseType.to_string(VerseType.Other))
|
||||
|
||||
def onCursorPositionChanged(self):
|
||||
position = self.VerseTextEdit.textCursor().position()
|
||||
text = unicode(self.VerseTextEdit.toPlainText())
|
||||
position = self.verseTextEdit.textCursor().position()
|
||||
text = unicode(self.verseTextEdit.toPlainText())
|
||||
if not text:
|
||||
return
|
||||
if text.rfind(u'[', 0, position) > text.rfind(u']', 0, position) and \
|
||||
text.find(u']', position) < text.find(u'[', position):
|
||||
text.find(u']', position) < text.find(u'[', position):
|
||||
return
|
||||
position = text.rfind(u'---[', 0, position)
|
||||
if position == -1:
|
||||
@ -113,8 +108,8 @@ class EditVerseForm(QtGui.QDialog, Ui_EditVerseDialog):
|
||||
verse_number = int(match.group(2))
|
||||
verse_type_index = VerseType.from_string(verse_type)
|
||||
if verse_type_index is not None:
|
||||
self.VerseTypeComboBox.setCurrentIndex(verse_type_index)
|
||||
self.VerseNumberBox.setValue(verse_number)
|
||||
self.verseTypeComboBox.setCurrentIndex(verse_type_index)
|
||||
self.verseNumberBox.setValue(verse_number)
|
||||
|
||||
def setVerse(self, text, single=False,
|
||||
tag=u'%s:1' % VerseType.to_string(VerseType.Verse)):
|
||||
@ -122,26 +117,26 @@ class EditVerseForm(QtGui.QDialog, Ui_EditVerseDialog):
|
||||
verse_type, verse_number = tag.split(u':')
|
||||
verse_type_index = VerseType.from_string(verse_type)
|
||||
if verse_type_index is not None:
|
||||
self.VerseTypeComboBox.setCurrentIndex(verse_type_index)
|
||||
self.VerseNumberBox.setValue(int(verse_number))
|
||||
self.InsertButton.setVisible(False)
|
||||
self.verseTypeComboBox.setCurrentIndex(verse_type_index)
|
||||
self.verseNumberBox.setValue(int(verse_number))
|
||||
self.insertButton.setVisible(False)
|
||||
else:
|
||||
if not text:
|
||||
text = u'---[%s:1]---\n' % VerseType.to_string(VerseType.Verse)
|
||||
self.VerseTypeComboBox.setCurrentIndex(0)
|
||||
self.VerseNumberBox.setValue(1)
|
||||
self.InsertButton.setVisible(True)
|
||||
self.VerseTextEdit.setPlainText(text)
|
||||
self.VerseTextEdit.setFocus(QtCore.Qt.OtherFocusReason)
|
||||
self.VerseTextEdit.moveCursor(QtGui.QTextCursor.End)
|
||||
self.verseTypeComboBox.setCurrentIndex(0)
|
||||
self.verseNumberBox.setValue(1)
|
||||
self.insertButton.setVisible(True)
|
||||
self.verseTextEdit.setPlainText(text)
|
||||
self.verseTextEdit.setFocus(QtCore.Qt.OtherFocusReason)
|
||||
self.verseTextEdit.moveCursor(QtGui.QTextCursor.End)
|
||||
|
||||
def getVerse(self):
|
||||
return self.VerseTextEdit.toPlainText(), \
|
||||
VerseType.to_string(self.VerseTypeComboBox.currentIndex()), \
|
||||
unicode(self.VerseNumberBox.value())
|
||||
return self.verseTextEdit.toPlainText(), \
|
||||
VerseType.to_string(self.verseTypeComboBox.currentIndex()), \
|
||||
unicode(self.verseNumberBox.value())
|
||||
|
||||
def getVerseAll(self):
|
||||
text = self.VerseTextEdit.toPlainText()
|
||||
text = self.verseTextEdit.toPlainText()
|
||||
if not text.startsWith(u'---['):
|
||||
text = u'---[%s:1]---\n%s' % (VerseType.to_string(VerseType.Verse),
|
||||
text)
|
||||
|
@ -302,8 +302,8 @@ class ImportWizardForm(QtGui.QWizard, Ui_SongImportWizard):
|
||||
Stop the import on pressing the cancel button.
|
||||
"""
|
||||
log.debug('Cancel button pressed!')
|
||||
if self.currentId() == 3:
|
||||
Receiver.send_message(u'song_stop_import')
|
||||
if self.currentId() == 2:
|
||||
Receiver.send_message(u'songs_stop_import')
|
||||
|
||||
def onCurrentIdChanged(self, id):
|
||||
if id == 2:
|
||||
|
@ -215,25 +215,32 @@ class Ui_SongImportWizard(object):
|
||||
self.wordsOfWorshipLayout.setSpacing(8)
|
||||
self.wordsOfWorshipLayout.setMargin(0)
|
||||
self.wordsOfWorshipLayout.setObjectName(u'wordsOfWorshipLayout')
|
||||
self.wordsOfWorshipFileListWidget = QtGui.QListWidget(self.wordsOfWorshipPage)
|
||||
self.wordsOfWorshipFileListWidget = QtGui.QListWidget(
|
||||
self.wordsOfWorshipPage)
|
||||
self.wordsOfWorshipFileListWidget.setSelectionMode(
|
||||
QtGui.QAbstractItemView.ExtendedSelection)
|
||||
self.wordsOfWorshipFileListWidget.setObjectName(u'wordsOfWorshipFileListWidget')
|
||||
self.wordsOfWorshipFileListWidget.setObjectName(
|
||||
u'wordsOfWorshipFileListWidget')
|
||||
self.wordsOfWorshipLayout.addWidget(self.wordsOfWorshipFileListWidget)
|
||||
self.wordsOfWorshipButtonLayout = QtGui.QHBoxLayout()
|
||||
self.wordsOfWorshipButtonLayout.setSpacing(8)
|
||||
self.wordsOfWorshipButtonLayout.setObjectName(u'wordsOfWorshipButtonLayout')
|
||||
self.wordsOfWorshipAddButton = QtGui.QPushButton(self.wordsOfWorshipPage)
|
||||
self.wordsOfWorshipButtonLayout.setObjectName(
|
||||
u'wordsOfWorshipButtonLayout')
|
||||
self.wordsOfWorshipAddButton = QtGui.QPushButton(
|
||||
self.wordsOfWorshipPage)
|
||||
self.wordsOfWorshipAddButton.setIcon(openIcon)
|
||||
self.wordsOfWorshipAddButton.setObjectName(u'wordsOfWorshipAddButton')
|
||||
self.wordsOfWorshipButtonLayout.addWidget(self.wordsOfWorshipAddButton)
|
||||
self.wordsOfWorshipButtonSpacer = QtGui.QSpacerItem(40, 20,
|
||||
QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
|
||||
self.wordsOfWorshipButtonLayout.addItem(self.wordsOfWorshipButtonSpacer)
|
||||
self.wordsOfWorshipRemoveButton = QtGui.QPushButton(self.wordsOfWorshipPage)
|
||||
self.wordsOfWorshipRemoveButton = QtGui.QPushButton(
|
||||
self.wordsOfWorshipPage)
|
||||
self.wordsOfWorshipRemoveButton.setIcon(deleteIcon)
|
||||
self.wordsOfWorshipRemoveButton.setObjectName(u'wordsOfWorshipRemoveButton')
|
||||
self.wordsOfWorshipButtonLayout.addWidget(self.wordsOfWorshipRemoveButton)
|
||||
self.wordsOfWorshipRemoveButton.setObjectName(
|
||||
u'wordsOfWorshipRemoveButton')
|
||||
self.wordsOfWorshipButtonLayout.addWidget(
|
||||
self.wordsOfWorshipRemoveButton)
|
||||
self.wordsOfWorshipLayout.addLayout(self.wordsOfWorshipButtonLayout)
|
||||
self.formatStackedWidget.addWidget(self.wordsOfWorshipPage)
|
||||
# CCLI File import
|
||||
@ -267,30 +274,43 @@ class Ui_SongImportWizard(object):
|
||||
# Songs of Fellowship
|
||||
self.songsOfFellowshipPage = QtGui.QWidget()
|
||||
self.songsOfFellowshipPage.setObjectName(u'songsOfFellowshipPage')
|
||||
self.songsOfFellowshipLayout = QtGui.QVBoxLayout(self.songsOfFellowshipPage)
|
||||
self.songsOfFellowshipLayout = QtGui.QVBoxLayout(
|
||||
self.songsOfFellowshipPage)
|
||||
self.songsOfFellowshipLayout.setMargin(0)
|
||||
self.songsOfFellowshipLayout.setSpacing(8)
|
||||
self.songsOfFellowshipLayout.setObjectName(u'songsOfFellowshipLayout')
|
||||
self.songsOfFellowshipFileListWidget = QtGui.QListWidget(self.songsOfFellowshipPage)
|
||||
self.songsOfFellowshipFileListWidget = QtGui.QListWidget(
|
||||
self.songsOfFellowshipPage)
|
||||
self.songsOfFellowshipFileListWidget.setSelectionMode(
|
||||
QtGui.QAbstractItemView.ExtendedSelection)
|
||||
self.songsOfFellowshipFileListWidget.setObjectName(u'songsOfFellowshipFileListWidget')
|
||||
self.songsOfFellowshipLayout.addWidget(self.songsOfFellowshipFileListWidget)
|
||||
self.songsOfFellowshipFileListWidget.setObjectName(
|
||||
u'songsOfFellowshipFileListWidget')
|
||||
self.songsOfFellowshipLayout.addWidget(
|
||||
self.songsOfFellowshipFileListWidget)
|
||||
self.songsOfFellowshipButtonLayout = QtGui.QHBoxLayout()
|
||||
self.songsOfFellowshipButtonLayout.setSpacing(8)
|
||||
self.songsOfFellowshipButtonLayout.setObjectName(u'songsOfFellowshipButtonLayout')
|
||||
self.songsOfFellowshipAddButton = QtGui.QPushButton(self.songsOfFellowshipPage)
|
||||
self.songsOfFellowshipButtonLayout.setObjectName(
|
||||
u'songsOfFellowshipButtonLayout')
|
||||
self.songsOfFellowshipAddButton = QtGui.QPushButton(
|
||||
self.songsOfFellowshipPage)
|
||||
self.songsOfFellowshipAddButton.setIcon(openIcon)
|
||||
self.songsOfFellowshipAddButton.setObjectName(u'songsOfFellowshipAddButton')
|
||||
self.songsOfFellowshipButtonLayout.addWidget(self.songsOfFellowshipAddButton)
|
||||
self.songsOfFellowshipAddButton.setObjectName(
|
||||
u'songsOfFellowshipAddButton')
|
||||
self.songsOfFellowshipButtonLayout.addWidget(
|
||||
self.songsOfFellowshipAddButton)
|
||||
self.songsOfFellowshipButtonSpacer = QtGui.QSpacerItem(40, 20,
|
||||
QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
|
||||
self.songsOfFellowshipButtonLayout.addItem(self.songsOfFellowshipButtonSpacer)
|
||||
self.songsOfFellowshipRemoveButton = QtGui.QPushButton(self.songsOfFellowshipPage)
|
||||
self.songsOfFellowshipButtonLayout.addItem(
|
||||
self.songsOfFellowshipButtonSpacer)
|
||||
self.songsOfFellowshipRemoveButton = QtGui.QPushButton(
|
||||
self.songsOfFellowshipPage)
|
||||
self.songsOfFellowshipRemoveButton.setIcon(deleteIcon)
|
||||
self.songsOfFellowshipRemoveButton.setObjectName(u'songsOfFellowshipRemoveButton')
|
||||
self.songsOfFellowshipButtonLayout.addWidget(self.songsOfFellowshipRemoveButton)
|
||||
self.songsOfFellowshipLayout.addLayout(self.songsOfFellowshipButtonLayout)
|
||||
self.songsOfFellowshipRemoveButton.setObjectName(
|
||||
u'songsOfFellowshipRemoveButton')
|
||||
self.songsOfFellowshipButtonLayout.addWidget(
|
||||
self.songsOfFellowshipRemoveButton)
|
||||
self.songsOfFellowshipLayout.addLayout(
|
||||
self.songsOfFellowshipButtonLayout)
|
||||
self.formatStackedWidget.addWidget(self.songsOfFellowshipPage)
|
||||
# Generic Document/Presentation import
|
||||
self.genericPage = QtGui.QWidget()
|
||||
|
@ -404,12 +404,12 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog):
|
||||
book.publisher = temp_publisher
|
||||
|
||||
def mergeAuthors(self, old_author):
|
||||
'''
|
||||
"""
|
||||
Merges two authors into one author.
|
||||
|
||||
``old_author``
|
||||
The author which will be deleted afterwards.
|
||||
'''
|
||||
"""
|
||||
existing_author = self.songmanager.get_object_filtered(Author,
|
||||
and_(Author.first_name == old_author.first_name,
|
||||
Author.last_name == old_author.last_name,
|
||||
@ -426,12 +426,12 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog):
|
||||
self.songmanager.delete_object(Author, old_author.id)
|
||||
|
||||
def mergeTopics(self, old_topic):
|
||||
'''
|
||||
"""
|
||||
Merges two topics into one topic.
|
||||
|
||||
``old_topic``
|
||||
The topic which will be deleted afterwards.
|
||||
'''
|
||||
"""
|
||||
existing_topic = self.songmanager.get_object_filtered(Topic,
|
||||
Topic.name == old_topic.name)
|
||||
songs = self.songmanager.get_all_objects(Song,
|
||||
@ -446,12 +446,12 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog):
|
||||
self.songmanager.delete_object(Topic, old_topic.id)
|
||||
|
||||
def mergeBooks(self, old_book):
|
||||
'''
|
||||
"""
|
||||
Merges two books into one book.
|
||||
|
||||
``old_book``
|
||||
The book which will be deleted afterwards.
|
||||
'''
|
||||
"""
|
||||
existing_book = self.songmanager.get_object_filtered(Book,
|
||||
and_(Book.name == old_book.name,
|
||||
Book.publisher == old_book.publisher))
|
||||
|
@ -72,7 +72,7 @@ def init_schema(url):
|
||||
``url``
|
||||
The database to setup
|
||||
"""
|
||||
session, metadata = init_db(url, auto_flush=False)
|
||||
session, metadata = init_db(url)
|
||||
|
||||
# Definition of the "authors" table
|
||||
authors_table = Table(u'authors', metadata,
|
||||
|
@ -75,18 +75,17 @@ class OpenLPSongImport(SongImport):
|
||||
The :class:`OpenLPSongImport` class provides OpenLP with the ability to
|
||||
import song databases from other installations of OpenLP.
|
||||
"""
|
||||
def __init__(self, master_manager, **kwargs):
|
||||
def __init__(self, manager, **kwargs):
|
||||
"""
|
||||
Initialise the import.
|
||||
|
||||
``master_manager``
|
||||
``manager``
|
||||
The song manager for the running OpenLP installation.
|
||||
|
||||
``source_db``
|
||||
The database providing the data to import.
|
||||
"""
|
||||
SongImport.__init__(self, master_manager)
|
||||
self.master_manager = master_manager
|
||||
SongImport.__init__(self, manager)
|
||||
self.import_source = u'sqlite:///%s' % kwargs[u'filename']
|
||||
log.debug(self.import_source)
|
||||
self.source_session = None
|
||||
@ -145,7 +144,12 @@ class OpenLPSongImport(SongImport):
|
||||
mapper(OldTopic, source_topics_table)
|
||||
|
||||
source_songs = self.source_session.query(OldSong).all()
|
||||
song_total = len(source_songs)
|
||||
self.import_wizard.importProgressBar.setMaximum(song_total)
|
||||
song_count = 1
|
||||
for song in source_songs:
|
||||
self.import_wizard.incrementProgressBar(
|
||||
u'Importing song %s of %s' % (song_count, song_total))
|
||||
new_song = Song()
|
||||
new_song.title = song.title
|
||||
if has_media_files:
|
||||
@ -167,7 +171,7 @@ class OpenLPSongImport(SongImport):
|
||||
new_song.ccli_number = song.ccli_number
|
||||
if song.authors:
|
||||
for author in song.authors:
|
||||
existing_author = self.master_manager.get_object_filtered(
|
||||
existing_author = self.manager.get_object_filtered(
|
||||
Author, Author.display_name == author.display_name)
|
||||
if existing_author:
|
||||
new_song.authors.append(existing_author)
|
||||
@ -177,7 +181,7 @@ class OpenLPSongImport(SongImport):
|
||||
last_name=author.last_name,
|
||||
display_name=author.display_name))
|
||||
else:
|
||||
au = self.master_manager.get_object_filtered(Author,
|
||||
au = self.manager.get_object_filtered(Author,
|
||||
Author.display_name == u'Author Unknown')
|
||||
if au:
|
||||
new_song.authors.append(au)
|
||||
@ -185,7 +189,7 @@ class OpenLPSongImport(SongImport):
|
||||
new_song.authors.append(Author.populate(
|
||||
display_name=u'Author Unknown'))
|
||||
if song.book:
|
||||
existing_song_book = self.master_manager.get_object_filtered(
|
||||
existing_song_book = self.manager.get_object_filtered(
|
||||
Book, Book.name == song.book.name)
|
||||
if existing_song_book:
|
||||
new_song.book = existing_song_book
|
||||
@ -194,7 +198,7 @@ class OpenLPSongImport(SongImport):
|
||||
publisher=song.book.publisher)
|
||||
if song.topics:
|
||||
for topic in song.topics:
|
||||
existing_topic = self.master_manager.get_object_filtered(
|
||||
existing_topic = self.manager.get_object_filtered(
|
||||
Topic, Topic.name == topic.name)
|
||||
if existing_topic:
|
||||
new_song.topics.append(existing_topic)
|
||||
@ -204,12 +208,16 @@ class OpenLPSongImport(SongImport):
|
||||
# if song.media_files:
|
||||
# for media_file in song.media_files:
|
||||
# existing_media_file = \
|
||||
# self.master_manager.get_object_filtered(MediaFile,
|
||||
# self.manager.get_object_filtered(MediaFile,
|
||||
# MediaFile.file_name == media_file.file_name)
|
||||
# if existing_media_file:
|
||||
# new_song.media_files.append(existing_media_file)
|
||||
# else:
|
||||
# new_song.media_files.append(MediaFile.populate(
|
||||
# file_name=media_file.file_name))
|
||||
self.master_manager.save_object(new_song)
|
||||
self.manager.save_object(new_song)
|
||||
song_count += 1
|
||||
if self.stop_import_flag:
|
||||
return False
|
||||
engine.dispose()
|
||||
return True
|
||||
|
@ -24,14 +24,18 @@
|
||||
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
||||
###############################################################################
|
||||
|
||||
import logging
|
||||
import re
|
||||
from PyQt4 import QtCore
|
||||
|
||||
from openlp.core.lib import translate
|
||||
from openlp.core.lib import Receiver, translate
|
||||
from openlp.plugins.songs.lib import VerseType
|
||||
from openlp.plugins.songs.lib.db import Song, Author, Topic, Book
|
||||
from openlp.plugins.songs.lib.xml import SongXMLBuilder
|
||||
|
||||
class SongImport(object):
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
class SongImport(QtCore.QObject):
|
||||
"""
|
||||
Helper class for import a song from a third party source into OpenLP
|
||||
|
||||
@ -39,7 +43,6 @@ class SongImport(object):
|
||||
whether the authors etc already exist and add them or refer to them
|
||||
as necessary
|
||||
"""
|
||||
|
||||
def __init__(self, manager):
|
||||
"""
|
||||
Initialise and create defaults for properties
|
||||
@ -48,6 +51,7 @@ class SongImport(object):
|
||||
database access is performed
|
||||
"""
|
||||
self.manager = manager
|
||||
self.stop_import_flag = False
|
||||
self.title = u''
|
||||
self.song_number = u''
|
||||
self.alternate_title = u''
|
||||
@ -67,6 +71,15 @@ class SongImport(object):
|
||||
'SongsPlugin.SongImport', 'copyright'))
|
||||
self.copyright_symbol = unicode(translate(
|
||||
'SongsPlugin.SongImport', '\xa9'))
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'songs_stop_import'), self.stop_import)
|
||||
|
||||
def stop_import(self):
|
||||
"""
|
||||
Sets the flag for importers to stop their import
|
||||
"""
|
||||
log.debug(u'Stopping songs import')
|
||||
self.stop_import_flag = True
|
||||
|
||||
def register(self, import_wizard):
|
||||
self.import_wizard = import_wizard
|
||||
|
Loading…
Reference in New Issue
Block a user