forked from openlp/openlp
r1259
This commit is contained in:
commit
ffd7a3808b
@ -194,7 +194,10 @@ class OpenLP(QtGui.QApplication):
|
||||
# now kill the splashscreen
|
||||
self.splash.finish(self.mainWindow)
|
||||
self.mainWindow.repaint()
|
||||
VersionThread(self.mainWindow, app_version).start()
|
||||
update_check = QtCore.QSettings().value(
|
||||
u'general/update check', QtCore.QVariant(True)).toBool()
|
||||
if update_check:
|
||||
VersionThread(self.mainWindow, app_version).start()
|
||||
return self.exec_()
|
||||
|
||||
def hookException(self, exctype, value, traceback):
|
||||
@ -280,4 +283,4 @@ if __name__ == u'__main__':
|
||||
"""
|
||||
Instantiate and run the application.
|
||||
"""
|
||||
main()
|
||||
main()
|
||||
|
@ -315,10 +315,24 @@ def check_directory_exists(dir):
|
||||
``dir``
|
||||
Theme directory to make sure exists
|
||||
"""
|
||||
log.debug(u'check_directory_exists')
|
||||
log.debug(u'check_directory_exists %s' % dir)
|
||||
if not os.path.exists(dir):
|
||||
os.makedirs(dir)
|
||||
|
||||
def save_cancel_button_box(parent):
|
||||
"""
|
||||
Return a standard dialog button box with save and cancel buttons.
|
||||
"""
|
||||
button_box = QtGui.QDialogButtonBox(parent)
|
||||
button_box.setStandardButtons(QtGui.QDialogButtonBox.Save |
|
||||
QtGui.QDialogButtonBox.Cancel)
|
||||
button_box.setObjectName(u'%sButtonBox' % parent)
|
||||
QtCore.QObject.connect(button_box, QtCore.SIGNAL(u'accepted()'),
|
||||
parent.accept)
|
||||
QtCore.QObject.connect(button_box, QtCore.SIGNAL(u'rejected()'),
|
||||
parent.reject)
|
||||
return button_box
|
||||
|
||||
from theme import ThemeLevel, ThemeXML, BackgroundGradientType, \
|
||||
BackgroundType, HorizontalType, VerticalType
|
||||
from displaytags import DisplayTags
|
||||
|
@ -314,7 +314,7 @@ body {
|
||||
</html>
|
||||
"""
|
||||
|
||||
def build_html(item, screen, alert, islive):
|
||||
def build_html(item, screen, alert, islive, background):
|
||||
"""
|
||||
Build the full web paged structure for display
|
||||
|
||||
@ -332,7 +332,9 @@ def build_html(item, screen, alert, islive):
|
||||
theme = item.themedata
|
||||
webkitvers = webkit_version()
|
||||
# Image generated and poked in
|
||||
if item.bg_image_bytes:
|
||||
if background:
|
||||
image = u'src="data:image/png;base64,%s"' % background
|
||||
elif item.bg_image_bytes:
|
||||
image = u'src="data:image/png;base64,%s"' % item.bg_image_bytes
|
||||
else:
|
||||
image = u'style="display:none;"'
|
||||
|
@ -98,16 +98,11 @@ class MediaManagerItem(QtGui.QWidget):
|
||||
visible_title = self.plugin.getString(StringContent.VisibleName)
|
||||
self.title = unicode(visible_title[u'title'])
|
||||
self.settingsSection = self.plugin.name.lower()
|
||||
if isinstance(icon, QtGui.QIcon):
|
||||
self.icon = icon
|
||||
elif isinstance(icon, basestring):
|
||||
self.icon.addPixmap(QtGui.QPixmap.fromImage(QtGui.QImage(icon)),
|
||||
QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
||||
else:
|
||||
self.icon = None
|
||||
self.icon = None
|
||||
if icon:
|
||||
self.icon = build_icon(icon)
|
||||
self.toolbar = None
|
||||
self.remoteTriggered = None
|
||||
self.serviceItemIconName = None
|
||||
self.singleServiceItem = True
|
||||
self.pageLayout = QtGui.QVBoxLayout(self)
|
||||
self.pageLayout.setSpacing(0)
|
||||
@ -529,10 +524,7 @@ class MediaManagerItem(QtGui.QWidget):
|
||||
Common method for generating a service item
|
||||
"""
|
||||
serviceItem = ServiceItem(self.parent)
|
||||
if self.serviceItemIconName:
|
||||
serviceItem.add_icon(self.serviceItemIconName)
|
||||
else:
|
||||
serviceItem.add_icon(self.parent.icon_path)
|
||||
serviceItem.add_icon(self.parent.icon_path)
|
||||
if self.generateSlideData(serviceItem, item, xmlVersion):
|
||||
return serviceItem
|
||||
else:
|
||||
@ -544,3 +536,25 @@ class MediaManagerItem(QtGui.QWidget):
|
||||
individual service items need to be processed by the plugins
|
||||
"""
|
||||
pass
|
||||
|
||||
def _getIdOfItemToGenerate(self, item, remoteItem):
|
||||
"""
|
||||
Utility method to check items being submitted for slide generation.
|
||||
|
||||
``item``
|
||||
The item to check.
|
||||
|
||||
``remoteItem``
|
||||
The id to assign if the slide generation was remotely triggered.
|
||||
"""
|
||||
if item is None:
|
||||
if self.remoteTriggered is None:
|
||||
item = self.listView.currentItem()
|
||||
if item is None:
|
||||
return False
|
||||
item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
|
||||
else:
|
||||
item_id = remoteItem
|
||||
else:
|
||||
item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
|
||||
return item_id
|
||||
|
@ -59,6 +59,7 @@ class ItemCapabilities(object):
|
||||
OnLoadUpdate = 8
|
||||
AddIfNewItem = 9
|
||||
ProvidesOwnDisplay = 10
|
||||
AllowsDetailedTitleDisplay = 11
|
||||
|
||||
|
||||
class ServiceItem(object):
|
||||
@ -314,6 +315,20 @@ class ServiceItem(object):
|
||||
path, text_image[u'title'], text_image[u'image'] )
|
||||
self._new_item()
|
||||
|
||||
def get_display_title(self):
|
||||
"""
|
||||
Returns the title of the service item.
|
||||
"""
|
||||
if self.is_text():
|
||||
return self.title
|
||||
else:
|
||||
if ItemCapabilities.AllowsDetailedTitleDisplay in self.capabilities:
|
||||
return self._raw_frames[0][u'title']
|
||||
elif len(self._raw_frames) > 1:
|
||||
return self.title
|
||||
else:
|
||||
return self._raw_frames[0][u'title']
|
||||
|
||||
def merge(self, other):
|
||||
"""
|
||||
Updates the _uuid with the value from the original one
|
||||
|
@ -47,13 +47,16 @@ class SpellTextEdit(QtGui.QPlainTextEdit):
|
||||
# Default dictionary based on the current locale.
|
||||
if ENCHANT_AVAILABLE:
|
||||
try:
|
||||
self.dict = enchant.Dict()
|
||||
self.dictionary = enchant.Dict()
|
||||
except DictNotFoundError:
|
||||
self.dict = enchant.Dict(u'en_US')
|
||||
self.dictionary = enchant.Dict(u'en_US')
|
||||
self.highlighter = Highlighter(self.document())
|
||||
self.highlighter.setDict(self.dict)
|
||||
self.highlighter.spellingDictionary = self.dictionary
|
||||
|
||||
def mousePressEvent(self, event):
|
||||
"""
|
||||
Handle mouse clicks within the text edit region.
|
||||
"""
|
||||
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.
|
||||
@ -63,6 +66,9 @@ class SpellTextEdit(QtGui.QPlainTextEdit):
|
||||
QtGui.QPlainTextEdit.mousePressEvent(self, event)
|
||||
|
||||
def contextMenuEvent(self, event):
|
||||
"""
|
||||
Provide the context menu for the text edit region.
|
||||
"""
|
||||
popupMenu = self.createStandardContextMenu()
|
||||
# Select the word under the cursor.
|
||||
cursor = self.textCursor()
|
||||
@ -74,10 +80,10 @@ class SpellTextEdit(QtGui.QPlainTextEdit):
|
||||
# suggestions if it is.
|
||||
if ENCHANT_AVAILABLE and self.textCursor().hasSelection():
|
||||
text = unicode(self.textCursor().selectedText())
|
||||
if not self.dict.check(text):
|
||||
if not self.dictionary.check(text):
|
||||
spell_menu = QtGui.QMenu(translate('OpenLP.SpellTextEdit',
|
||||
'Spelling Suggestions'))
|
||||
for word in self.dict.suggest(text):
|
||||
for word in self.dictionary.suggest(text):
|
||||
action = SpellAction(word, spell_menu)
|
||||
action.correct.connect(self.correctWord)
|
||||
spell_menu.addAction(action)
|
||||
@ -126,28 +132,32 @@ class SpellTextEdit(QtGui.QPlainTextEdit):
|
||||
cursor.insertText(html[u'start tag'])
|
||||
cursor.insertText(html[u'end tag'])
|
||||
|
||||
class Highlighter(QtGui.QSyntaxHighlighter):
|
||||
|
||||
class Highlighter(QtGui.QSyntaxHighlighter):
|
||||
"""
|
||||
Provides a text highlighter for pointing out spelling errors in text.
|
||||
"""
|
||||
WORDS = u'(?iu)[\w\']+'
|
||||
|
||||
def __init__(self, *args):
|
||||
QtGui.QSyntaxHighlighter.__init__(self, *args)
|
||||
self.dict = None
|
||||
|
||||
def setDict(self, dict):
|
||||
self.dict = dict
|
||||
self.spellingDictionary = None
|
||||
|
||||
def highlightBlock(self, text):
|
||||
if not self.dict:
|
||||
"""
|
||||
Highlight misspelt words in a block of text
|
||||
"""
|
||||
if not self.spellingDictionary:
|
||||
return
|
||||
text = unicode(text)
|
||||
format = QtGui.QTextCharFormat()
|
||||
format.setUnderlineColor(QtCore.Qt.red)
|
||||
format.setUnderlineStyle(QtGui.QTextCharFormat.SpellCheckUnderline)
|
||||
charFormat = QtGui.QTextCharFormat()
|
||||
charFormat.setUnderlineColor(QtCore.Qt.red)
|
||||
charFormat.setUnderlineStyle(QtGui.QTextCharFormat.SpellCheckUnderline)
|
||||
for word_object in re.finditer(self.WORDS, text):
|
||||
if not self.dict.check(word_object.group()):
|
||||
if not self.spellingDictionary.check(word_object.group()):
|
||||
self.setFormat(word_object.start(),
|
||||
word_object.end() - word_object.start(), format)
|
||||
word_object.end() - word_object.start(), charFormat)
|
||||
|
||||
|
||||
class SpellAction(QtGui.QAction):
|
||||
"""
|
||||
|
@ -156,7 +156,7 @@ class VerticalType(object):
|
||||
Middle = 1
|
||||
Bottom = 2
|
||||
|
||||
boolean_list = [u'italics', u'override', u'outline', u'shadow',
|
||||
boolean_list = [u'bold', u'italics', u'override', u'outline', u'shadow',
|
||||
u'slide_transition']
|
||||
|
||||
integer_list = [u'size', u'line_adjustment', u'x', u'height', u'y',
|
||||
|
@ -73,13 +73,13 @@ class OpenLPToolbar(QtGui.QToolBar):
|
||||
``checkable``
|
||||
If *True* the button has two, *off* and *on*, states. Default is
|
||||
*False*, which means the buttons has only one state.
|
||||
|
||||
|
||||
``shortcut``
|
||||
The primary shortcut for this action
|
||||
|
||||
|
||||
``alternate``
|
||||
The alternate shortcut for this action
|
||||
|
||||
|
||||
``context``
|
||||
Specify the context in which this shortcut is valid
|
||||
"""
|
||||
|
@ -80,6 +80,16 @@ class AdvancedTab(SettingsTab):
|
||||
self.hideMouseCheckBox.setObjectName(u'hideMouseCheckBox')
|
||||
self.hideMouseLayout.addWidget(self.hideMouseCheckBox)
|
||||
self.leftLayout.addWidget(self.hideMouseGroupBox)
|
||||
self.serviceOrderGroupBox = QtGui.QGroupBox(self.leftColumn)
|
||||
self.serviceOrderGroupBox.setObjectName(u'serviceOrderGroupBox')
|
||||
self.serviceOrderLayout = QtGui.QVBoxLayout(self.serviceOrderGroupBox)
|
||||
self.serviceOrderLayout.setObjectName(u'serviceOrderLayout')
|
||||
self.detailedServicePrintCheckBox = QtGui.QCheckBox(
|
||||
self.serviceOrderGroupBox)
|
||||
self.detailedServicePrintCheckBox.setObjectName(
|
||||
u'detailedServicePrintCheckBox')
|
||||
self.serviceOrderLayout.addWidget(self.detailedServicePrintCheckBox)
|
||||
self.leftLayout.addWidget(self.serviceOrderGroupBox)
|
||||
# self.sharedDirGroupBox = QtGui.QGroupBox(self.leftColumn)
|
||||
# self.sharedDirGroupBox.setObjectName(u'sharedDirGroupBox')
|
||||
# self.sharedDirLayout = QtGui.QFormLayout(self.sharedDirGroupBox)
|
||||
@ -129,6 +139,10 @@ class AdvancedTab(SettingsTab):
|
||||
'Mouse Cursor'))
|
||||
self.hideMouseCheckBox.setText(translate('OpenLP.AdvancedTab',
|
||||
'Hide the mouse cursor when moved over the display window'))
|
||||
self.serviceOrderGroupBox.setTitle(translate('OpenLP.AdvancedTab',
|
||||
'Service Order Print'))
|
||||
self.detailedServicePrintCheckBox.setText(translate('OpenLP.AdvancedTab',
|
||||
'Print slide texts and service item notes as well'))
|
||||
# self.sharedDirGroupBox.setTitle(
|
||||
# translate('AdvancedTab', 'Central Data Store'))
|
||||
# self.sharedCheckBox.setText(
|
||||
@ -164,6 +178,8 @@ class AdvancedTab(SettingsTab):
|
||||
QtCore.QVariant(True)).toBool())
|
||||
self.hideMouseCheckBox.setChecked(
|
||||
settings.value(u'hide mouse', QtCore.QVariant(False)).toBool())
|
||||
self.detailedServicePrintCheckBox.setChecked(settings.value(
|
||||
u'detailed service print', QtCore.QVariant(False)).toBool())
|
||||
settings.endGroup()
|
||||
|
||||
def save(self):
|
||||
@ -184,6 +200,8 @@ class AdvancedTab(SettingsTab):
|
||||
QtCore.QVariant(self.enableAutoCloseCheckBox.isChecked()))
|
||||
settings.setValue(u'hide mouse',
|
||||
QtCore.QVariant(self.hideMouseCheckBox.isChecked()))
|
||||
settings.setValue(u'detailed service print',
|
||||
QtCore.QVariant(self.detailedServicePrintCheckBox.isChecked()))
|
||||
settings.endGroup()
|
||||
|
||||
# def onSharedCheckBoxChanged(self, checked):
|
||||
|
@ -51,6 +51,7 @@ class ValidEdit(QtGui.QLineEdit):
|
||||
else:
|
||||
return self.text()
|
||||
|
||||
|
||||
class GeneralTab(SettingsTab):
|
||||
"""
|
||||
GeneralTab is the general settings tab in the settings dialog.
|
||||
@ -113,6 +114,9 @@ class GeneralTab(SettingsTab):
|
||||
self.showSplashCheckBox = QtGui.QCheckBox(self.startupGroupBox)
|
||||
self.showSplashCheckBox.setObjectName(u'showSplashCheckBox')
|
||||
self.startupLayout.addWidget(self.showSplashCheckBox)
|
||||
self.checkForUpdatesCheckBox = QtGui.QCheckBox(self.startupGroupBox)
|
||||
self.checkForUpdatesCheckBox.setObjectName(u'checkForUpdatesCheckBox')
|
||||
self.startupLayout.addWidget(self.checkForUpdatesCheckBox)
|
||||
self.leftLayout.addWidget(self.startupGroupBox)
|
||||
self.settingsGroupBox = QtGui.QGroupBox(self.leftColumn)
|
||||
self.settingsGroupBox.setObjectName(u'settingsGroupBox')
|
||||
@ -249,6 +253,8 @@ class GeneralTab(SettingsTab):
|
||||
'Automatically open the last service'))
|
||||
self.showSplashCheckBox.setText(
|
||||
translate('OpenLP.GeneralTab', 'Show the splash screen'))
|
||||
self.checkForUpdatesCheckBox.setText(
|
||||
translate('OpenLP.GeneralTab', 'Check for updates to OpenLP'))
|
||||
self.settingsGroupBox.setTitle(
|
||||
translate('OpenLP.GeneralTab', 'Application Settings'))
|
||||
self.saveCheckServiceCheckBox.setText(translate('OpenLP.GeneralTab',
|
||||
@ -317,6 +323,8 @@ class GeneralTab(SettingsTab):
|
||||
QtCore.QVariant(False)).toBool())
|
||||
self.showSplashCheckBox.setChecked(settings.value(u'show splash',
|
||||
QtCore.QVariant(True)).toBool())
|
||||
self.checkForUpdatesCheckBox.setChecked(settings.value(u'update check',
|
||||
QtCore.QVariant(True)).toBool())
|
||||
self.autoPreviewCheckBox.setChecked(settings.value(u'auto preview',
|
||||
QtCore.QVariant(False)).toBool())
|
||||
self.timeoutSpinBox.setValue(settings.value(u'loop delay',
|
||||
@ -363,6 +371,8 @@ class GeneralTab(SettingsTab):
|
||||
QtCore.QVariant(self.autoOpenCheckBox.isChecked()))
|
||||
settings.setValue(u'show splash',
|
||||
QtCore.QVariant(self.showSplashCheckBox.isChecked()))
|
||||
settings.setValue(u'update check',
|
||||
QtCore.QVariant(self.checkForUpdatesCheckBox.isChecked()))
|
||||
settings.setValue(u'save prompt',
|
||||
QtCore.QVariant(self.saveCheckServiceCheckBox.isChecked()))
|
||||
settings.setValue(u'auto preview',
|
||||
|
@ -67,6 +67,7 @@ class MainDisplay(DisplayWidget):
|
||||
self.isLive = live
|
||||
self.alertTab = None
|
||||
self.hideMode = None
|
||||
self.override = {}
|
||||
mainIcon = build_icon(u':/icon/openlp-logo-16x16.png')
|
||||
self.setWindowIcon(mainIcon)
|
||||
self.retranslateUi()
|
||||
@ -111,7 +112,7 @@ class MainDisplay(DisplayWidget):
|
||||
self.page = self.webView.page()
|
||||
self.frame = self.page.mainFrame()
|
||||
QtCore.QObject.connect(self.webView,
|
||||
QtCore.SIGNAL(u'loadFinished(bool)'), self.isLoaded)
|
||||
QtCore.SIGNAL(u'loadFinished(bool)'), self.isWebLoaded)
|
||||
self.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
|
||||
self.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
|
||||
self.frame.setScrollBarPolicy(QtCore.Qt.Vertical,
|
||||
@ -137,14 +138,14 @@ class MainDisplay(DisplayWidget):
|
||||
painter_image.begin(initialFrame)
|
||||
painter_image.fillRect(initialFrame.rect(), QtCore.Qt.white)
|
||||
painter_image.drawImage(
|
||||
(self.screens.current[u'size'].width() -
|
||||
(self.screens.current[u'size'].width() -
|
||||
splash_image.width()) / 2,
|
||||
(self.screens.current[u'size'].height()
|
||||
- splash_image.height()) / 2, splash_image)
|
||||
serviceItem = ServiceItem()
|
||||
serviceItem.bg_image_bytes = image_to_byte(initialFrame)
|
||||
self.webView.setHtml(build_html(serviceItem, self.screen,
|
||||
self.parent.alertTab, self.isLive))
|
||||
self.parent.alertTab, self.isLive, None))
|
||||
self.initialFrame = True
|
||||
# To display or not to display?
|
||||
if not self.screen[u'primary']:
|
||||
@ -162,7 +163,7 @@ class MainDisplay(DisplayWidget):
|
||||
"""
|
||||
log.debug(u'text to display')
|
||||
# Wait for the webview to update before displaying text.
|
||||
while not self.loaded:
|
||||
while not self.webLoaded:
|
||||
Receiver.send_message(u'openlp_process_events')
|
||||
self.frame.evaluateJavaScript(u'show_text("%s")' % \
|
||||
slide.replace(u'\\', u'\\\\').replace(u'\"', u'\\\"'))
|
||||
@ -204,14 +205,17 @@ class MainDisplay(DisplayWidget):
|
||||
"""
|
||||
self.imageManager.add_image(name, path)
|
||||
self.image(name)
|
||||
if hasattr(self, u'serviceItem'):
|
||||
self.override[u'image'] = name
|
||||
self.override[u'theme'] = self.serviceItem.themedata.theme_name
|
||||
|
||||
def image(self, name):
|
||||
"""
|
||||
Add an image as the background. The image is converted to a bytestream
|
||||
on route.
|
||||
Add an image as the background. The image has already been added
|
||||
to the cache.
|
||||
|
||||
`Image`
|
||||
The Image to be displayed can be QImage or QPixmap
|
||||
The name of the image to be displayed
|
||||
"""
|
||||
log.debug(u'image to display')
|
||||
image = self.imageManager.get_image_bytes(name)
|
||||
@ -244,6 +248,7 @@ class MainDisplay(DisplayWidget):
|
||||
self.displayImage(self.serviceItem.bg_image_bytes)
|
||||
else:
|
||||
self.displayImage(None)
|
||||
self.override = {}
|
||||
# Update the preview frame.
|
||||
Receiver.send_message(u'maindisplay_active')
|
||||
|
||||
@ -260,6 +265,7 @@ class MainDisplay(DisplayWidget):
|
||||
self.phononActive = False
|
||||
else:
|
||||
self.frame.evaluateJavaScript(u'show_video("close");')
|
||||
self.override = {}
|
||||
# Update the preview frame.
|
||||
Receiver.send_message(u'maindisplay_active')
|
||||
|
||||
@ -313,7 +319,10 @@ class MainDisplay(DisplayWidget):
|
||||
Loads and starts a video to run with the option of sound
|
||||
"""
|
||||
log.debug(u'video')
|
||||
self.loaded = True
|
||||
self.webLoaded = True
|
||||
# We are running a background theme
|
||||
self.override[u'theme'] = u''
|
||||
self.override[u'video'] = True
|
||||
vol = float(volume)/float(10)
|
||||
if isBackground or not self.usePhonon:
|
||||
js = u'show_video("init", "%s", %s, true); show_video("play");' % \
|
||||
@ -333,12 +342,12 @@ class MainDisplay(DisplayWidget):
|
||||
Receiver.send_message(u'maindisplay_active')
|
||||
return self.preview()
|
||||
|
||||
def isLoaded(self):
|
||||
def isWebLoaded(self):
|
||||
"""
|
||||
Called by webView event to show display is fully loaded
|
||||
"""
|
||||
log.debug(u'loaded')
|
||||
self.loaded = True
|
||||
log.debug(u'Webloaded')
|
||||
self.webLoaded = True
|
||||
|
||||
def preview(self):
|
||||
"""
|
||||
@ -357,7 +366,7 @@ class MainDisplay(DisplayWidget):
|
||||
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:
|
||||
while not self.webLoaded:
|
||||
Receiver.send_message(u'openlp_process_events')
|
||||
# if was hidden keep it hidden
|
||||
if self.isLive:
|
||||
@ -379,18 +388,32 @@ class MainDisplay(DisplayWidget):
|
||||
HTML to the display
|
||||
"""
|
||||
log.debug(u'buildHtml')
|
||||
self.loaded = False
|
||||
self.webLoaded = False
|
||||
self.initialFrame = False
|
||||
self.serviceItem = serviceItem
|
||||
background = None
|
||||
# We have an image override so keep the image till the theme changes
|
||||
if self.override:
|
||||
# We have an video override so allow it to be stopped
|
||||
if u'video' in self.override:
|
||||
Receiver.send_message(u'video_background_replaced')
|
||||
self.override = {}
|
||||
elif self.override[u'theme'] != \
|
||||
serviceItem.themedata.theme_name:
|
||||
Receiver.send_message(u'live_theme_changed')
|
||||
self.override = {}
|
||||
else:
|
||||
background = self.imageManager. \
|
||||
get_image_bytes(self.override[u'image'])
|
||||
if self.serviceItem.themedata.background_filename:
|
||||
self.serviceItem.bg_image_bytes = self.imageManager. \
|
||||
get_image_bytes(self.serviceItem.themedata.theme_name)
|
||||
html = build_html(self.serviceItem, self.screen, self.parent.alertTab,
|
||||
self.isLive)
|
||||
self.isLive, background)
|
||||
log.debug(u'buildHtml - pre setHtml')
|
||||
self.webView.setHtml(html)
|
||||
log.debug(u'buildHtml - post setHtml')
|
||||
if serviceItem.foot_text and serviceItem.foot_text:
|
||||
if serviceItem.foot_text:
|
||||
self.footer(serviceItem.foot_text)
|
||||
# if was hidden keep it hidden
|
||||
if self.hideMode and self.isLive:
|
||||
|
@ -87,10 +87,10 @@ class Ui_MainWindow(object):
|
||||
self.screens, True)
|
||||
previewVisible = QtCore.QSettings().value(
|
||||
u'user interface/preview panel', QtCore.QVariant(True)).toBool()
|
||||
self.previewController.Panel.setVisible(previewVisible)
|
||||
self.previewController.panel.setVisible(previewVisible)
|
||||
liveVisible = QtCore.QSettings().value(u'user interface/live panel',
|
||||
QtCore.QVariant(True)).toBool()
|
||||
self.liveController.Panel.setVisible(liveVisible)
|
||||
self.liveController.panel.setVisible(liveVisible)
|
||||
# Create menu
|
||||
self.MenuBar = QtGui.QMenuBar(mainWindow)
|
||||
self.MenuBar.setObjectName(u'MenuBar')
|
||||
@ -175,6 +175,10 @@ class Ui_MainWindow(object):
|
||||
self.FileSaveAsItem = QtGui.QAction(mainWindow)
|
||||
self.FileSaveAsItem.setObjectName(u'FileSaveAsItem')
|
||||
mainWindow.actionList.add_action(self.FileSaveAsItem, u'File')
|
||||
self.printServiceOrderItem = QtGui.QAction(mainWindow)
|
||||
self.printServiceOrderItem.setObjectName(u'printServiceItem')
|
||||
mainWindow.actionList.add_action(
|
||||
self.printServiceOrderItem, u'Print Service Order')
|
||||
self.FileExitItem = QtGui.QAction(mainWindow)
|
||||
self.FileExitItem.setIcon(build_icon(u':/system/system_exit.png'))
|
||||
self.FileExitItem.setObjectName(u'FileExitItem')
|
||||
@ -302,8 +306,8 @@ class Ui_MainWindow(object):
|
||||
(self.ExportThemeItem, self.ExportLanguageItem))
|
||||
self.FileMenuActions = (self.FileNewItem, self.FileOpenItem,
|
||||
self.FileSaveItem, self.FileSaveAsItem, None,
|
||||
self.FileImportMenu.menuAction(), self.FileExportMenu.menuAction(),
|
||||
self.FileExitItem)
|
||||
self.printServiceOrderItem, None, self.FileImportMenu.menuAction(),
|
||||
self.FileExportMenu.menuAction(), self.FileExitItem)
|
||||
add_actions(self.ViewModeMenu, (self.ModeDefaultItem,
|
||||
self.ModeSetupItem, self.ModeLiveItem))
|
||||
add_actions(self.ViewMenu, (self.ViewModeMenu.menuAction(),
|
||||
@ -381,6 +385,12 @@ class Ui_MainWindow(object):
|
||||
'Save the current service under a new name.'))
|
||||
self.FileSaveAsItem.setShortcut(
|
||||
translate('OpenLP.MainWindow', 'Ctrl+Shift+S'))
|
||||
self.printServiceOrderItem.setText(
|
||||
translate('OpenLP.MainWindow', 'Print Service Order'))
|
||||
self.printServiceOrderItem.setStatusTip(translate('OpenLP.MainWindow',
|
||||
'Print the current Service Order.'))
|
||||
self.printServiceOrderItem.setShortcut(
|
||||
translate('OpenLP.MainWindow', 'Ctrl+P'))
|
||||
self.FileExitItem.setText(
|
||||
translate('OpenLP.MainWindow', 'E&xit'))
|
||||
self.FileExitItem.setStatusTip(
|
||||
@ -563,10 +573,13 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
||||
self.ServiceManagerContents.onLoadServiceClicked)
|
||||
QtCore.QObject.connect(self.FileSaveItem,
|
||||
QtCore.SIGNAL(u'triggered()'),
|
||||
self.ServiceManagerContents.onSaveServiceClicked)
|
||||
self.ServiceManagerContents.saveFile)
|
||||
QtCore.QObject.connect(self.FileSaveAsItem,
|
||||
QtCore.SIGNAL(u'triggered()'),
|
||||
self.ServiceManagerContents.onSaveServiceAsClicked)
|
||||
self.ServiceManagerContents.saveFileAs)
|
||||
QtCore.QObject.connect(self.printServiceOrderItem,
|
||||
QtCore.SIGNAL(u'triggered()'),
|
||||
self.ServiceManagerContents.printServiceOrder)
|
||||
# i18n set signals for languages
|
||||
QtCore.QObject.connect(self.AutoLanguageItem,
|
||||
QtCore.SIGNAL(u'toggled(bool)'), self.setAutoLanguage)
|
||||
@ -807,15 +820,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
||||
Hook to close the main window and display windows on exit
|
||||
"""
|
||||
if self.ServiceManagerContents.isModified():
|
||||
ret = QtGui.QMessageBox.question(self,
|
||||
translate('OpenLP.MainWindow', 'Save Changes to Service?'),
|
||||
translate('OpenLP.MainWindow', 'Your service has changed. '
|
||||
'Do you want to save those changes?'),
|
||||
QtGui.QMessageBox.StandardButtons(
|
||||
QtGui.QMessageBox.Cancel |
|
||||
QtGui.QMessageBox.Discard |
|
||||
QtGui.QMessageBox.Save),
|
||||
QtGui.QMessageBox.Save)
|
||||
ret = self.ServiceManagerContents.saveModifiedService()
|
||||
if ret == QtGui.QMessageBox.Save:
|
||||
if self.ServiceManagerContents.saveFile():
|
||||
self.cleanUp()
|
||||
@ -847,7 +852,6 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
||||
self.cleanUp()
|
||||
event.accept()
|
||||
|
||||
|
||||
def cleanUp(self):
|
||||
"""
|
||||
Runs all the cleanup code before OpenLP shuts down
|
||||
@ -935,7 +939,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
||||
True - Visible
|
||||
False - Hidden
|
||||
"""
|
||||
self.previewController.Panel.setVisible(visible)
|
||||
self.previewController.panel.setVisible(visible)
|
||||
QtCore.QSettings().setValue(u'user interface/preview panel',
|
||||
QtCore.QVariant(visible))
|
||||
self.ViewPreviewPanel.setChecked(visible)
|
||||
@ -950,7 +954,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
||||
True - Visible
|
||||
False - Hidden
|
||||
"""
|
||||
self.liveController.Panel.setVisible(visible)
|
||||
self.liveController.panel.setVisible(visible)
|
||||
QtCore.QSettings().setValue(u'user interface/live panel',
|
||||
QtCore.QVariant(visible))
|
||||
self.ViewLivePanel.setChecked(visible)
|
||||
|
@ -26,7 +26,7 @@
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.lib import translate, build_icon
|
||||
from openlp.core.lib import translate, build_icon, save_cancel_button_box
|
||||
|
||||
class Ui_ServiceItemEditDialog(object):
|
||||
def setupUi(self, serviceItemEditDialog):
|
||||
@ -52,12 +52,8 @@ class Ui_ServiceItemEditDialog(object):
|
||||
self.downButton.setObjectName(u'downButton')
|
||||
self.buttonLayout.addWidget(self.downButton)
|
||||
self.dialogLayout.addLayout(self.buttonLayout, 0, 1)
|
||||
self.buttonBox = QtGui.QDialogButtonBox(serviceItemEditDialog)
|
||||
self.buttonBox.setStandardButtons(
|
||||
QtGui.QDialogButtonBox.Cancel | QtGui.QDialogButtonBox.Save)
|
||||
self.buttonBox.setObjectName(u'buttonBox')
|
||||
self.dialogLayout.addWidget(self.buttonBox, 1, 0, 1, 2)
|
||||
|
||||
self.dialogLayout.addWidget(
|
||||
save_cancel_button_box(serviceItemEditDialog), 1, 0, 1, 2)
|
||||
self.retranslateUi(serviceItemEditDialog)
|
||||
QtCore.QMetaObject.connectSlotsByName(serviceItemEditDialog)
|
||||
|
||||
|
@ -46,10 +46,6 @@ class ServiceItemEditForm(QtGui.QDialog, Ui_ServiceItemEditDialog):
|
||||
QtCore.SIGNAL(u'clicked()'), self.onItemDown)
|
||||
QtCore.QObject.connect(self.deleteButton,
|
||||
QtCore.SIGNAL(u'clicked()'), self.onItemDelete)
|
||||
QtCore.QObject.connect(self.buttonBox,
|
||||
QtCore.SIGNAL(u'accepted()'), self.accept)
|
||||
QtCore.QObject.connect(self.buttonBox,
|
||||
QtCore.SIGNAL(u'rejected()'), self.reject)
|
||||
QtCore.QObject.connect(self.listWidget,
|
||||
QtCore.SIGNAL(u'currentRowChanged(int)'), self.onCurrentRowChanged)
|
||||
|
||||
@ -100,27 +96,30 @@ class ServiceItemEditForm(QtGui.QDialog, Ui_ServiceItemEditDialog):
|
||||
"""
|
||||
Move the current row up in the list.
|
||||
"""
|
||||
item = self.listWidget.currentItem()
|
||||
if not item:
|
||||
return
|
||||
row = self.listWidget.row(item)
|
||||
temp = self.itemList[row]
|
||||
self.itemList.remove(self.itemList[row])
|
||||
self.itemList.insert(row - 1, temp)
|
||||
self.loadData()
|
||||
self.listWidget.setCurrentRow(row - 1)
|
||||
self.__moveItem(u'up')
|
||||
|
||||
def onItemDown(self):
|
||||
"""
|
||||
Move the current row down in the list
|
||||
"""
|
||||
self.__moveItem(u'down')
|
||||
|
||||
def __moveItem(self, direction=u''):
|
||||
"""
|
||||
Move the current item.
|
||||
"""
|
||||
if not direction:
|
||||
return
|
||||
item = self.listWidget.currentItem()
|
||||
if not item:
|
||||
return
|
||||
row = self.listWidget.row(item)
|
||||
temp = self.itemList[row]
|
||||
self.itemList.remove(self.itemList[row])
|
||||
self.itemList.insert(row + 1, temp)
|
||||
if direction == u'up':
|
||||
self.itemList.insert(row - 1, temp)
|
||||
else:
|
||||
self.itemList.insert(row + 1, temp)
|
||||
self.loadData()
|
||||
self.listWidget.setCurrentRow(row + 1)
|
||||
|
||||
|
@ -108,7 +108,7 @@ class ServiceManager(QtGui.QWidget):
|
||||
translate('OpenLP.ServiceManager', 'Save Service'),
|
||||
u':/general/general_save.png',
|
||||
translate('OpenLP.ServiceManager', 'Save this service'),
|
||||
self.onSaveServiceClicked)
|
||||
self.saveFile)
|
||||
self.toolbar.addSeparator()
|
||||
self.themeLabel = QtGui.QLabel(translate('OpenLP.ServiceManager',
|
||||
'Theme:'), self)
|
||||
@ -178,8 +178,8 @@ class ServiceManager(QtGui.QWidget):
|
||||
translate('OpenLP.ServiceManager', 'Move &down'),
|
||||
None,
|
||||
translate('OpenLP.ServiceManager',
|
||||
'Moves the selection up the window.'),
|
||||
self.onMoveSelectionDown, shortcut=QtCore.Qt.Key_Up)
|
||||
'Moves the selection down the window.'),
|
||||
self.onMoveSelectionDown, shortcut=QtCore.Qt.Key_Down)
|
||||
self.serviceManagerList.down.setVisible(False)
|
||||
self.serviceManagerList.up = self.orderToolbar.addToolbarButton(
|
||||
translate('OpenLP.ServiceManager', 'Move up'),
|
||||
@ -361,12 +361,7 @@ class ServiceManager(QtGui.QWidget):
|
||||
Create a new service.
|
||||
"""
|
||||
if self.isModified():
|
||||
result = QtGui.QMessageBox.question(self.mainwindow,
|
||||
translate('OpenLP.ServiceManager', 'Save Changes'),
|
||||
translate('OpenLP.ServiceManager', 'The current service has '
|
||||
'been modified, would you like to save it?'),
|
||||
QtGui.QMessageBox.Save | QtGui.QMessageBox.Discard |
|
||||
QtGui.QMessageBox.Cancel, QtGui.QMessageBox.Save)
|
||||
result = self.saveModifiedService()
|
||||
if result == QtGui.QMessageBox.Cancel:
|
||||
return False
|
||||
elif result == QtGui.QMessageBox.Save:
|
||||
@ -376,12 +371,7 @@ class ServiceManager(QtGui.QWidget):
|
||||
|
||||
def onLoadServiceClicked(self):
|
||||
if self.isModified():
|
||||
result = QtGui.QMessageBox.question(self.mainwindow,
|
||||
translate('OpenLP.ServiceManager', 'Save Changes'),
|
||||
translate('OpenLP.ServiceManager', 'The current service has '
|
||||
'been modified, would you like to save it?'),
|
||||
QtGui.QMessageBox.Save | QtGui.QMessageBox.Discard |
|
||||
QtGui.QMessageBox.Cancel, QtGui.QMessageBox.Save)
|
||||
result = self.saveModifiedService()
|
||||
if result == QtGui.QMessageBox.Cancel:
|
||||
return False
|
||||
elif result == QtGui.QMessageBox.Save:
|
||||
@ -397,11 +387,13 @@ class ServiceManager(QtGui.QWidget):
|
||||
split_filename(fileName)[0])
|
||||
self.loadFile(fileName)
|
||||
|
||||
def onSaveServiceClicked(self):
|
||||
self.saveFile()
|
||||
|
||||
def onSaveServiceAsClicked(self):
|
||||
self.saveFileAs()
|
||||
def saveModifiedService(self):
|
||||
return QtGui.QMessageBox.question(self.mainwindow,
|
||||
translate('OpenLP.ServiceManager', 'Modified Service'),
|
||||
translate('OpenLP.ServiceManager', 'The current service has '
|
||||
'been modified. Would you like to save this service?'),
|
||||
QtGui.QMessageBox.Save | QtGui.QMessageBox.Discard |
|
||||
QtGui.QMessageBox.Cancel, QtGui.QMessageBox.Save)
|
||||
|
||||
def onRecentServiceClicked(self):
|
||||
sender = self.sender()
|
||||
@ -603,7 +595,7 @@ class ServiceManager(QtGui.QWidget):
|
||||
if self.serviceNoteForm.exec_():
|
||||
self.serviceItems[item][u'service_item'].notes = \
|
||||
self.serviceNoteForm.textEdit.toPlainText()
|
||||
self.repaintServiceList(item, 0)
|
||||
self.repaintServiceList(item, -1)
|
||||
|
||||
def onServiceItemEditForm(self):
|
||||
item = self.findServiceItem()[0]
|
||||
@ -615,8 +607,7 @@ class ServiceManager(QtGui.QWidget):
|
||||
|
||||
def nextItem(self):
|
||||
"""
|
||||
Called by the SlideController to select the
|
||||
next service item
|
||||
Called by the SlideController to select the next service item.
|
||||
"""
|
||||
if len(self.serviceManagerList.selectedItems()) == 0:
|
||||
return
|
||||
@ -634,8 +625,7 @@ class ServiceManager(QtGui.QWidget):
|
||||
|
||||
def previousItem(self):
|
||||
"""
|
||||
Called by the SlideController to select the
|
||||
previous service item
|
||||
Called by the SlideController to select the previous service item.
|
||||
"""
|
||||
if len(self.serviceManagerList.selectedItems()) == 0:
|
||||
return
|
||||
@ -654,13 +644,13 @@ class ServiceManager(QtGui.QWidget):
|
||||
|
||||
def onSetItem(self, message):
|
||||
"""
|
||||
Called by a signal to select a specific item
|
||||
Called by a signal to select a specific item.
|
||||
"""
|
||||
self.setItem(int(message[0]))
|
||||
|
||||
def setItem(self, index):
|
||||
"""
|
||||
Makes a specific item in the service live
|
||||
Makes a specific item in the service live.
|
||||
"""
|
||||
if index >= 0 and index < self.serviceManagerList.topLevelItemCount:
|
||||
item = self.serviceManagerList.topLevelItem(index)
|
||||
@ -669,8 +659,7 @@ class ServiceManager(QtGui.QWidget):
|
||||
|
||||
def onMoveSelectionUp(self):
|
||||
"""
|
||||
Moves the selection up the window
|
||||
Called by the up arrow
|
||||
Moves the selection up the window. Called by the up arrow.
|
||||
"""
|
||||
serviceIterator = QtGui.QTreeWidgetItemIterator(self.serviceManagerList)
|
||||
tempItem = None
|
||||
@ -695,8 +684,7 @@ class ServiceManager(QtGui.QWidget):
|
||||
|
||||
def onMoveSelectionDown(self):
|
||||
"""
|
||||
Moves the selection down the window
|
||||
Called by the down arrow
|
||||
Moves the selection down the window. Called by the down arrow.
|
||||
"""
|
||||
serviceIterator = QtGui.QTreeWidgetItemIterator(self.serviceManagerList)
|
||||
firstItem = None
|
||||
@ -718,7 +706,7 @@ class ServiceManager(QtGui.QWidget):
|
||||
|
||||
def onCollapseAll(self):
|
||||
"""
|
||||
Collapse all the service items
|
||||
Collapse all the service items.
|
||||
"""
|
||||
for item in self.serviceItems:
|
||||
item[u'expanded'] = False
|
||||
@ -726,15 +714,15 @@ class ServiceManager(QtGui.QWidget):
|
||||
|
||||
def collapsed(self, item):
|
||||
"""
|
||||
Record if an item is collapsed
|
||||
Used when repainting the list to get the correct state
|
||||
Record if an item is collapsed. Used when repainting the list to get the
|
||||
correct state.
|
||||
"""
|
||||
pos = item.data(0, QtCore.Qt.UserRole).toInt()[0]
|
||||
self.serviceItems[pos -1 ][u'expanded'] = False
|
||||
|
||||
def onExpandAll(self):
|
||||
"""
|
||||
Collapse all the service items
|
||||
Collapse all the service items.
|
||||
"""
|
||||
for item in self.serviceItems:
|
||||
item[u'expanded'] = True
|
||||
@ -742,70 +730,68 @@ class ServiceManager(QtGui.QWidget):
|
||||
|
||||
def expanded(self, item):
|
||||
"""
|
||||
Record if an item is collapsed
|
||||
Used when repainting the list to get the correct state
|
||||
Record if an item is collapsed. Used when repainting the list to get the
|
||||
correct state.
|
||||
"""
|
||||
pos = item.data(0, QtCore.Qt.UserRole).toInt()[0]
|
||||
self.serviceItems[pos -1 ][u'expanded'] = True
|
||||
|
||||
def onServiceTop(self):
|
||||
"""
|
||||
Move the current ServiceItem to the top of the list
|
||||
Move the current ServiceItem to the top of the list.
|
||||
"""
|
||||
item, count = self.findServiceItem()
|
||||
item, child = self.findServiceItem()
|
||||
if item < len(self.serviceItems) and item is not -1:
|
||||
temp = self.serviceItems[item]
|
||||
self.serviceItems.remove(self.serviceItems[item])
|
||||
self.serviceItems.insert(0, temp)
|
||||
self.repaintServiceList(0, count)
|
||||
self.repaintServiceList(0, child)
|
||||
self.setModified(True)
|
||||
|
||||
def onServiceUp(self):
|
||||
"""
|
||||
Move the current ServiceItem up in the list
|
||||
Note move up means move to top of area ie 0.
|
||||
Move the current ServiceItem one position up in the list.
|
||||
"""
|
||||
item, count = self.findServiceItem()
|
||||
item, child = self.findServiceItem()
|
||||
if item > 0:
|
||||
temp = self.serviceItems[item]
|
||||
self.serviceItems.remove(self.serviceItems[item])
|
||||
self.serviceItems.insert(item - 1, temp)
|
||||
self.repaintServiceList(item - 1, count)
|
||||
self.repaintServiceList(item - 1, child)
|
||||
self.setModified(True)
|
||||
|
||||
def onServiceDown(self):
|
||||
"""
|
||||
Move the current ServiceItem down in the list
|
||||
Note move down means move to bottom of area i.e len().
|
||||
Move the current ServiceItem one position down in the list.
|
||||
"""
|
||||
item, count = self.findServiceItem()
|
||||
item, child = self.findServiceItem()
|
||||
if item < len(self.serviceItems) and item is not -1:
|
||||
temp = self.serviceItems[item]
|
||||
self.serviceItems.remove(self.serviceItems[item])
|
||||
self.serviceItems.insert(item + 1, temp)
|
||||
self.repaintServiceList(item + 1, count)
|
||||
self.repaintServiceList(item + 1, child)
|
||||
self.setModified(True)
|
||||
|
||||
def onServiceEnd(self):
|
||||
"""
|
||||
Move the current ServiceItem to the bottom of the list
|
||||
Move the current ServiceItem to the bottom of the list.
|
||||
"""
|
||||
item, count = self.findServiceItem()
|
||||
item, child = self.findServiceItem()
|
||||
if item < len(self.serviceItems) and item is not -1:
|
||||
temp = self.serviceItems[item]
|
||||
self.serviceItems.remove(self.serviceItems[item])
|
||||
self.serviceItems.insert(len(self.serviceItems), temp)
|
||||
self.repaintServiceList(len(self.serviceItems) - 1, count)
|
||||
self.repaintServiceList(len(self.serviceItems) - 1, child)
|
||||
self.setModified(True)
|
||||
|
||||
def onDeleteFromService(self):
|
||||
"""
|
||||
Remove the current ServiceItem from the list
|
||||
Remove the current ServiceItem from the list.
|
||||
"""
|
||||
item = self.findServiceItem()[0]
|
||||
if item is not -1:
|
||||
if item != -1:
|
||||
self.serviceItems.remove(self.serviceItems[item])
|
||||
self.repaintServiceList(0, 0)
|
||||
self.repaintServiceList(item - 1, -1)
|
||||
self.setModified(True)
|
||||
|
||||
def repaintServiceList(self, serviceItem, serviceItemChild):
|
||||
@ -847,7 +833,7 @@ class ServiceManager(QtGui.QWidget):
|
||||
else:
|
||||
treewidgetitem.setIcon(0,
|
||||
build_icon(u':/general/general_delete.png'))
|
||||
treewidgetitem.setText(0, serviceitem.title)
|
||||
treewidgetitem.setText(0, serviceitem.get_display_title())
|
||||
treewidgetitem.setToolTip(0, serviceitem.notes)
|
||||
treewidgetitem.setData(0, QtCore.Qt.UserRole,
|
||||
QtCore.QVariant(item[u'order']))
|
||||
@ -867,16 +853,16 @@ class ServiceManager(QtGui.QWidget):
|
||||
def validateItem(self, serviceItem):
|
||||
"""
|
||||
Validates the service item and if the suffix matches an accepted
|
||||
one it allows the item to be displayed
|
||||
one it allows the item to be displayed.
|
||||
"""
|
||||
if serviceItem.is_command():
|
||||
type = serviceItem._raw_frames[0][u'title'].split(u'.')[1]
|
||||
type = serviceItem._raw_frames[0][u'title'].split(u'.')[-1]
|
||||
if type not in self.suffixes:
|
||||
serviceItem.is_valid = False
|
||||
|
||||
def cleanUp(self):
|
||||
"""
|
||||
Empties the servicePath of temporary files
|
||||
Empties the servicePath of temporary files.
|
||||
"""
|
||||
for file in os.listdir(self.servicePath):
|
||||
file_path = os.path.join(self.servicePath, file)
|
||||
@ -884,7 +870,7 @@ class ServiceManager(QtGui.QWidget):
|
||||
|
||||
def onThemeComboBoxSelected(self, currentIndex):
|
||||
"""
|
||||
Set the theme for the current service
|
||||
Set the theme for the current service.
|
||||
"""
|
||||
log.debug(u'onThemeComboBoxSelected')
|
||||
self.service_theme = unicode(self.themeComboBox.currentText())
|
||||
@ -967,12 +953,12 @@ class ServiceManager(QtGui.QWidget):
|
||||
# if not passed set to config value
|
||||
if expand is None:
|
||||
expand = self.expandTabs
|
||||
sitem = self.findServiceItem()[0]
|
||||
item.render()
|
||||
if replace:
|
||||
sitem, child = self.findServiceItem()
|
||||
item.merge(self.serviceItems[sitem][u'service_item'])
|
||||
self.serviceItems[sitem][u'service_item'] = item
|
||||
self.repaintServiceList(sitem, 0)
|
||||
self.repaintServiceList(sitem, child)
|
||||
self.mainwindow.liveController.replaceServiceManagerItem(item)
|
||||
else:
|
||||
# nothing selected for dnd
|
||||
@ -981,17 +967,17 @@ class ServiceManager(QtGui.QWidget):
|
||||
for inditem in item:
|
||||
self.serviceItems.append({u'service_item': inditem,
|
||||
u'order': len(self.serviceItems) + 1,
|
||||
u'expanded':expand})
|
||||
u'expanded': expand})
|
||||
else:
|
||||
self.serviceItems.append({u'service_item': item,
|
||||
u'order': len(self.serviceItems) + 1,
|
||||
u'expanded':expand})
|
||||
self.repaintServiceList(len(self.serviceItems) + 1, 0)
|
||||
u'expanded': expand})
|
||||
self.repaintServiceList(len(self.serviceItems) - 1, -1)
|
||||
else:
|
||||
self.serviceItems.insert(self.dropPosition,
|
||||
{u'service_item': item, u'order': self.dropPosition,
|
||||
u'expanded':expand})
|
||||
self.repaintServiceList(self.dropPosition, 0)
|
||||
u'expanded': expand})
|
||||
self.repaintServiceList(self.dropPosition, -1)
|
||||
# if rebuilding list make sure live is fixed.
|
||||
if rebuild:
|
||||
self.mainwindow.liveController.replaceServiceManagerItem(item)
|
||||
@ -1002,15 +988,15 @@ class ServiceManager(QtGui.QWidget):
|
||||
"""
|
||||
Send the current item to the Preview slide controller
|
||||
"""
|
||||
item, count = self.findServiceItem()
|
||||
item, child = self.findServiceItem()
|
||||
if self.serviceItems[item][u'service_item'].is_valid:
|
||||
self.mainwindow.previewController.addServiceManagerItem(
|
||||
self.serviceItems[item][u'service_item'], count)
|
||||
self.serviceItems[item][u'service_item'], child)
|
||||
else:
|
||||
criticalErrorMessageBox(
|
||||
translate('OpenLP.ServiceManager', 'Missing Display Handler'),
|
||||
translate('OpenLP.ServiceManager', 'Your item cannot be '
|
||||
'displayed as there is no handler to display it'))
|
||||
'displayed as there is no handler to display it'))
|
||||
|
||||
def getServiceItem(self):
|
||||
"""
|
||||
@ -1026,10 +1012,10 @@ class ServiceManager(QtGui.QWidget):
|
||||
"""
|
||||
Send the current item to the Live slide controller
|
||||
"""
|
||||
item, count = self.findServiceItem()
|
||||
item, child = self.findServiceItem()
|
||||
if self.serviceItems[item][u'service_item'].is_valid:
|
||||
self.mainwindow.liveController.addServiceManagerItem(
|
||||
self.serviceItems[item][u'service_item'], count)
|
||||
self.serviceItems[item][u'service_item'], child)
|
||||
if QtCore.QSettings().value(
|
||||
self.mainwindow.generalSettingsSection + u'/auto preview',
|
||||
QtCore.QVariant(False)).toBool():
|
||||
@ -1060,26 +1046,26 @@ class ServiceManager(QtGui.QWidget):
|
||||
|
||||
def findServiceItem(self):
|
||||
"""
|
||||
Finds a ServiceItem in the list and returns the position of the
|
||||
serviceitem and its selected child item. For example, if the third child
|
||||
item (in the Slidecontroller known as slide) in the second service item
|
||||
is selected this will return::
|
||||
Finds the selected ServiceItem in the list and returns the position of
|
||||
the serviceitem and its selected child item. For example, if the third
|
||||
child item (in the Slidecontroller known as slide) in the second service
|
||||
item is selected this will return::
|
||||
|
||||
(1, 2)
|
||||
"""
|
||||
items = self.serviceManagerList.selectedItems()
|
||||
pos = 0
|
||||
count = -1
|
||||
serviceItem = 0
|
||||
serviceItemChild = -1
|
||||
for item in items:
|
||||
parentitem = item.parent()
|
||||
if parentitem is None:
|
||||
pos = item.data(0, QtCore.Qt.UserRole).toInt()[0]
|
||||
serviceItem = item.data(0, QtCore.Qt.UserRole).toInt()[0]
|
||||
else:
|
||||
pos = parentitem.data(0, QtCore.Qt.UserRole).toInt()[0]
|
||||
count = item.data(0, QtCore.Qt.UserRole).toInt()[0]
|
||||
# adjust for zero based arrays
|
||||
pos = pos - 1
|
||||
return pos, count
|
||||
serviceItem = parentitem.data(0, QtCore.Qt.UserRole).toInt()[0]
|
||||
serviceItemChild = item.data(0, QtCore.Qt.UserRole).toInt()[0]
|
||||
# Adjust for zero based arrays.
|
||||
serviceItem -= 1
|
||||
return serviceItem, serviceItemChild
|
||||
|
||||
def dragEnterEvent(self, event):
|
||||
"""
|
||||
@ -1105,7 +1091,7 @@ class ServiceManager(QtGui.QWidget):
|
||||
item = self.serviceManagerList.itemAt(event.pos())
|
||||
# ServiceManager started the drag and drop
|
||||
if plugin == u'ServiceManager':
|
||||
startpos, startCount = self.findServiceItem()
|
||||
startpos, child = self.findServiceItem()
|
||||
# If no items selected
|
||||
if startpos == -1:
|
||||
return
|
||||
@ -1116,7 +1102,7 @@ class ServiceManager(QtGui.QWidget):
|
||||
serviceItem = self.serviceItems[startpos]
|
||||
self.serviceItems.remove(serviceItem)
|
||||
self.serviceItems.insert(endpos, serviceItem)
|
||||
self.repaintServiceList(endpos, startCount)
|
||||
self.repaintServiceList(endpos, child)
|
||||
else:
|
||||
# we are not over anything so drop
|
||||
replace = False
|
||||
@ -1182,17 +1168,60 @@ class ServiceManager(QtGui.QWidget):
|
||||
|
||||
def listRequest(self, message=None):
|
||||
data = []
|
||||
curindex = self.findServiceItem()[0]
|
||||
if curindex >= 0 and curindex < len(self.serviceItems):
|
||||
curitem = self.serviceItems[curindex]
|
||||
item = self.findServiceItem()[0]
|
||||
if item >= 0 and item < len(self.serviceItems):
|
||||
curitem = self.serviceItems[item]
|
||||
else:
|
||||
curitem = None
|
||||
for item in self.serviceItems:
|
||||
service_item = item[u'service_item']
|
||||
data_item = {}
|
||||
data_item[u'title'] = unicode(service_item.title)
|
||||
data_item[u'title'] = unicode(service_item.get_display_title())
|
||||
data_item[u'plugin'] = unicode(service_item.name)
|
||||
data_item[u'notes'] = unicode(service_item.notes)
|
||||
data_item[u'selected'] = (item == curitem)
|
||||
data.append(data_item)
|
||||
Receiver.send_message(u'servicemanager_list_response', data)
|
||||
|
||||
def printServiceOrder(self):
|
||||
"""
|
||||
Print a Service Order Sheet.
|
||||
"""
|
||||
if not self.serviceItems:
|
||||
criticalErrorMessageBox(
|
||||
message=translate('OpenLP.ServiceManager',
|
||||
'There is no service item in this service.'))
|
||||
return
|
||||
printDialog = QtGui.QPrintDialog()
|
||||
if not printDialog.exec_():
|
||||
return
|
||||
text = u'<h2>%s</h2>' % translate('OpenLP.ServiceManager',
|
||||
'Service Order Sheet')
|
||||
for item in self.serviceItems:
|
||||
item = item[u'service_item']
|
||||
# add the title
|
||||
text += u'<h4><img src="%s" /> %s</h4>' % (item.icon,
|
||||
item.get_display_title())
|
||||
if not QtCore.QSettings().value(u'advanced' +
|
||||
u'/detailed service print', QtCore.QVariant(True)).toBool():
|
||||
continue
|
||||
if item.is_text():
|
||||
# Add the text of the service item.
|
||||
for slide in item.get_frames():
|
||||
text += u'<p>' + slide[u'text'] + u'</p>'
|
||||
elif item.is_image():
|
||||
# Add the image names of the service item.
|
||||
text += u'<ol>'
|
||||
for slide in range(len(item.get_frames())):
|
||||
text += u'<li><p>%s</p></li>' % item.get_frame_title(slide)
|
||||
text += u'</ol>'
|
||||
if item.foot_text:
|
||||
# add footer
|
||||
text += u'<p>%s</p>' % item.foot_text
|
||||
if item.notes:
|
||||
# add notes
|
||||
text += u'<p><b>%s</b> %s</p>' % (translate(
|
||||
'OpenLP.ServiceManager', 'Notes:'), item.notes)
|
||||
serviceDocument = QtGui.QTextDocument()
|
||||
serviceDocument.setHtml(text)
|
||||
serviceDocument.print_(printDialog.printer())
|
||||
|
@ -1,48 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
|
||||
|
||||
###############################################################################
|
||||
# OpenLP - Open Source Lyrics Projection #
|
||||
# --------------------------------------------------------------------------- #
|
||||
# Copyright (c) 2008-2011 Raoul Snyman #
|
||||
# Portions copyright (c) 2008-2011 Tim Bentley, Jonathan Corwin, Michael #
|
||||
# Gorven, Scott Guerrieri, Meinert Jordan, Andreas Preikschat, Christian #
|
||||
# Richter, Philip Ridout, Maikel Stuivenberg, Martin Thompson, Jon Tibble, #
|
||||
# Carsten Tinggaard, Frode Woldsund #
|
||||
# --------------------------------------------------------------------------- #
|
||||
# This program is free software; you can redistribute it and/or modify it #
|
||||
# under the terms of the GNU General Public License as published by the Free #
|
||||
# Software Foundation; version 2 of the License. #
|
||||
# #
|
||||
# This program is distributed in the hope that it will be useful, but WITHOUT #
|
||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
|
||||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for #
|
||||
# more details. #
|
||||
# #
|
||||
# You should have received a copy of the GNU General Public License along #
|
||||
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
|
||||
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
||||
###############################################################################
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
from openlp.core.lib import translate
|
||||
|
||||
class Ui_ServiceNoteEdit(object):
|
||||
def setupUi(self, serviceNoteEdit):
|
||||
serviceNoteEdit.setObjectName(u'serviceNoteEdit')
|
||||
self.dialogLayout = QtGui.QVBoxLayout(serviceNoteEdit)
|
||||
self.dialogLayout.setObjectName(u'verticalLayout')
|
||||
self.textEdit = QtGui.QTextEdit(serviceNoteEdit)
|
||||
self.textEdit.setObjectName(u'textEdit')
|
||||
self.dialogLayout.addWidget(self.textEdit)
|
||||
self.buttonBox = QtGui.QDialogButtonBox(serviceNoteEdit)
|
||||
self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel |
|
||||
QtGui.QDialogButtonBox.Save)
|
||||
self.buttonBox.setObjectName(u'buttonBox')
|
||||
self.dialogLayout.addWidget(self.buttonBox)
|
||||
self.retranslateUi(serviceNoteEdit)
|
||||
QtCore.QMetaObject.connectSlotsByName(serviceNoteEdit)
|
||||
|
||||
def retranslateUi(self, serviceNoteEdit):
|
||||
serviceNoteEdit.setWindowTitle(
|
||||
translate('OpenLP.ServiceNoteForm', 'Service Item Notes'))
|
@ -26,9 +26,9 @@
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from servicenotedialog import Ui_ServiceNoteEdit
|
||||
from openlp.core.lib import save_cancel_button_box, translate
|
||||
|
||||
class ServiceNoteForm(QtGui.QDialog, Ui_ServiceNoteEdit):
|
||||
class ServiceNoteForm(QtGui.QDialog):
|
||||
"""
|
||||
This is the form that is used to edit the verses of the song.
|
||||
"""
|
||||
@ -37,8 +37,19 @@ class ServiceNoteForm(QtGui.QDialog, Ui_ServiceNoteEdit):
|
||||
Constructor
|
||||
"""
|
||||
QtGui.QDialog.__init__(self, parent)
|
||||
self.setupUi(self)
|
||||
QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(u'accepted()'),
|
||||
self.accept)
|
||||
QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(u'rejected()'),
|
||||
self.reject)
|
||||
self.setupUi()
|
||||
self.retranslateUi()
|
||||
|
||||
def setupUi(self):
|
||||
self.setObjectName(u'serviceNoteEdit')
|
||||
self.dialogLayout = QtGui.QVBoxLayout(self)
|
||||
self.dialogLayout.setObjectName(u'verticalLayout')
|
||||
self.textEdit = QtGui.QTextEdit(self)
|
||||
self.textEdit.setObjectName(u'textEdit')
|
||||
self.dialogLayout.addWidget(self.textEdit)
|
||||
self.dialogLayout.addWidget(save_cancel_button_box(self))
|
||||
QtCore.QMetaObject.connectSlotsByName(self)
|
||||
|
||||
def retranslateUi(self):
|
||||
self.setWindowTitle(
|
||||
translate('OpenLP.ServiceNoteForm', 'Service Item Notes'))
|
||||
|
@ -77,14 +77,14 @@ class SlideController(QtGui.QWidget):
|
||||
self.selectedRow = 0
|
||||
self.serviceItem = None
|
||||
self.alertTab = None
|
||||
self.Panel = QtGui.QWidget(parent.ControlSplitter)
|
||||
self.panel = QtGui.QWidget(parent.ControlSplitter)
|
||||
self.slideList = {}
|
||||
# Layout for holding panel
|
||||
self.panelLayout = QtGui.QVBoxLayout(self.Panel)
|
||||
self.panelLayout = QtGui.QVBoxLayout(self.panel)
|
||||
self.panelLayout.setSpacing(0)
|
||||
self.panelLayout.setMargin(0)
|
||||
# Type label for the top of the slide controller
|
||||
self.typeLabel = QtGui.QLabel(self.Panel)
|
||||
self.typeLabel = QtGui.QLabel(self.panel)
|
||||
if self.isLive:
|
||||
self.typeLabel.setText(translate('OpenLP.SlideController', 'Live'))
|
||||
self.split = 1
|
||||
@ -98,7 +98,7 @@ class SlideController(QtGui.QWidget):
|
||||
self.typeLabel.setAlignment(QtCore.Qt.AlignCenter)
|
||||
self.panelLayout.addWidget(self.typeLabel)
|
||||
# Splitter
|
||||
self.splitter = QtGui.QSplitter(self.Panel)
|
||||
self.splitter = QtGui.QSplitter(self.panel)
|
||||
self.splitter.setOrientation(QtCore.Qt.Vertical)
|
||||
self.panelLayout.addWidget(self.splitter)
|
||||
# Actual controller section
|
||||
@ -119,6 +119,8 @@ class SlideController(QtGui.QWidget):
|
||||
self.previewListWidget.isLive = self.isLive
|
||||
self.previewListWidget.setObjectName(u'PreviewListWidget')
|
||||
self.previewListWidget.setSelectionBehavior(1)
|
||||
self.previewListWidget.setSelectionMode(
|
||||
QtGui.QAbstractItemView.SingleSelection)
|
||||
self.previewListWidget.setEditTriggers(
|
||||
QtGui.QAbstractItemView.NoEditTriggers)
|
||||
self.previewListWidget.setHorizontalScrollBarPolicy(
|
||||
@ -183,13 +185,13 @@ class SlideController(QtGui.QWidget):
|
||||
u'Stop Loop', u':/media/media_stop.png',
|
||||
translate('OpenLP.SlideController', 'Stop continuous loop'),
|
||||
self.onStopLoop)
|
||||
self.DelaySpinBox = QtGui.QSpinBox()
|
||||
self.DelaySpinBox.setMinimum(1)
|
||||
self.DelaySpinBox.setMaximum(180)
|
||||
self.toolbar.addToolbarWidget(u'Image SpinBox', self.DelaySpinBox)
|
||||
self.DelaySpinBox.setSuffix(translate('OpenLP.SlideController',
|
||||
self.delaySpinBox = QtGui.QSpinBox()
|
||||
self.delaySpinBox.setMinimum(1)
|
||||
self.delaySpinBox.setMaximum(180)
|
||||
self.toolbar.addToolbarWidget(u'Image SpinBox', self.delaySpinBox)
|
||||
self.delaySpinBox.setSuffix(translate('OpenLP.SlideController',
|
||||
's'))
|
||||
self.DelaySpinBox.setToolTip(translate('OpenLP.SlideController',
|
||||
self.delaySpinBox.setToolTip(translate('OpenLP.SlideController',
|
||||
'Delay between slides in seconds'))
|
||||
else:
|
||||
self.toolbar.addToolbarSeparator(u'Close Separator')
|
||||
@ -480,18 +482,11 @@ class SlideController(QtGui.QWidget):
|
||||
def onSongBarHandler(self):
|
||||
request = unicode(self.sender().text())
|
||||
slideno = self.slideList[request]
|
||||
if slideno > self.previewListWidget.rowCount():
|
||||
self.previewListWidget.selectRow(
|
||||
self.previewListWidget.rowCount() - 1)
|
||||
else:
|
||||
if slideno + 1 < self.previewListWidget.rowCount():
|
||||
self.previewListWidget.scrollToItem(
|
||||
self.previewListWidget.item(slideno + 1, 0))
|
||||
self.previewListWidget.selectRow(slideno)
|
||||
self.__updatePreviewSelection(slideno)
|
||||
self.onSlideSelected()
|
||||
|
||||
def receiveSpinDelay(self, value):
|
||||
self.DelaySpinBox.setValue(int(value))
|
||||
self.delaySpinBox.setValue(int(value))
|
||||
|
||||
def enableToolBar(self, item):
|
||||
"""
|
||||
@ -663,14 +658,7 @@ class SlideController(QtGui.QWidget):
|
||||
self.previewListWidget.resizeRowsToContents()
|
||||
self.previewListWidget.setColumnWidth(0,
|
||||
self.previewListWidget.viewport().size().width())
|
||||
if slideno > self.previewListWidget.rowCount():
|
||||
self.previewListWidget.selectRow(
|
||||
self.previewListWidget.rowCount() - 1)
|
||||
else:
|
||||
if slideno + 1 < self.previewListWidget.rowCount():
|
||||
self.previewListWidget.scrollToItem(
|
||||
self.previewListWidget.item(slideno + 1, 0))
|
||||
self.previewListWidget.selectRow(slideno)
|
||||
self.__updatePreviewSelection(slideno)
|
||||
self.enableToolBar(serviceItem)
|
||||
# Pass to display for viewing
|
||||
self.display.buildHtml(self.serviceItem)
|
||||
@ -681,6 +669,19 @@ class SlideController(QtGui.QWidget):
|
||||
Receiver.send_message(u'slidecontroller_%s_started' % self.typePrefix,
|
||||
[serviceItem])
|
||||
|
||||
def __updatePreviewSelection(self, slideno):
|
||||
"""
|
||||
Utility method to update the selected slide in the list.
|
||||
"""
|
||||
if slideno > self.previewListWidget.rowCount():
|
||||
self.previewListWidget.selectRow(
|
||||
self.previewListWidget.rowCount() - 1)
|
||||
else:
|
||||
if slideno + 1 < self.previewListWidget.rowCount():
|
||||
self.previewListWidget.scrollToItem(
|
||||
self.previewListWidget.item(slideno + 1, 0))
|
||||
self.previewListWidget.selectRow(slideno)
|
||||
|
||||
def onTextRequest(self):
|
||||
"""
|
||||
Return the text for the current item in controller
|
||||
@ -997,7 +998,7 @@ class SlideController(QtGui.QWidget):
|
||||
"""
|
||||
if self.previewListWidget.rowCount() > 1:
|
||||
self.timer_id = self.startTimer(
|
||||
int(self.DelaySpinBox.value()) * 1000)
|
||||
int(self.delaySpinBox.value()) * 1000)
|
||||
self.toolbar.actions[u'Stop Loop'].setVisible(True)
|
||||
self.toolbar.actions[u'Start Loop'].setVisible(False)
|
||||
|
||||
|
@ -55,7 +55,6 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard):
|
||||
self.thememanager = parent
|
||||
self.setupUi(self)
|
||||
self.registerFields()
|
||||
self.accepted = False
|
||||
self.updateThemeAllowed = True
|
||||
QtCore.QObject.connect(self.backgroundComboBox,
|
||||
QtCore.SIGNAL(u'currentIndexChanged(int)'),
|
||||
@ -120,14 +119,12 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard):
|
||||
QtCore.QObject.connect(self.mainFontComboBox,
|
||||
QtCore.SIGNAL(u'activated(int)'),
|
||||
self.calculateLines)
|
||||
QtCore.QObject.connect(self, QtCore.SIGNAL(u'accepted()'), self.accept)
|
||||
|
||||
def setDefaults(self):
|
||||
"""
|
||||
Set up display at start of theme edit.
|
||||
"""
|
||||
self.restart()
|
||||
self.accepted = False
|
||||
self.setBackgroundPageValues()
|
||||
self.setMainAreaPageValues()
|
||||
self.setFooterAreaPageValues()
|
||||
@ -250,37 +247,43 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard):
|
||||
"""
|
||||
Change state as Outline check box changed
|
||||
"""
|
||||
if state == QtCore.Qt.Checked:
|
||||
self.theme.font_main_outline = True
|
||||
else:
|
||||
self.theme.font_main_outline = False
|
||||
self.outlineColorButton.setEnabled(self.theme.font_main_outline)
|
||||
self.outlineSizeSpinBox.setEnabled(self.theme.font_main_outline)
|
||||
self.calculateLines()
|
||||
if self.updateThemeAllowed:
|
||||
if state == QtCore.Qt.Checked:
|
||||
self.theme.font_main_outline = True
|
||||
else:
|
||||
self.theme.font_main_outline = False
|
||||
self.outlineColorButton.setEnabled(self.theme.font_main_outline)
|
||||
self.outlineSizeSpinBox.setEnabled(self.theme.font_main_outline)
|
||||
self.calculateLines()
|
||||
|
||||
def onShadowCheckCheckBoxStateChanged(self, state):
|
||||
"""
|
||||
Change state as Shadow check box changed
|
||||
"""
|
||||
if state == QtCore.Qt.Checked:
|
||||
self.theme.font_main_shadow = True
|
||||
else:
|
||||
self.theme.font_main_shadow = False
|
||||
self.shadowColorButton.setEnabled(self.theme.font_main_shadow)
|
||||
self.shadowSizeSpinBox.setEnabled(self.theme.font_main_shadow)
|
||||
self.calculateLines()
|
||||
if self.updateThemeAllowed:
|
||||
if state == QtCore.Qt.Checked:
|
||||
self.theme.font_main_shadow = True
|
||||
else:
|
||||
self.theme.font_main_shadow = False
|
||||
self.shadowColorButton.setEnabled(self.theme.font_main_shadow)
|
||||
self.shadowSizeSpinBox.setEnabled(self.theme.font_main_shadow)
|
||||
self.calculateLines()
|
||||
|
||||
def onMainPositionCheckBoxStateChanged(self, value):
|
||||
"""
|
||||
Change state as Main Area Position check box changed
|
||||
NOTE the font_main_override is the inverse of the check box value
|
||||
"""
|
||||
self.theme.font_main_override = (value == QtCore.Qt.Checked)
|
||||
if self.updateThemeAllowed:
|
||||
self.theme.font_main_override = not (value == QtCore.Qt.Checked)
|
||||
|
||||
def onFooterPositionCheckBoxStateChanged(self, value):
|
||||
"""
|
||||
Change state as Footer Area Position check box changed
|
||||
NOTE the font_footer_override is the inverse of the check box value
|
||||
"""
|
||||
self.theme.font_footer_override = (value == QtCore.Qt.Checked)
|
||||
if self.updateThemeAllowed:
|
||||
self.theme.font_footer_override = not (value == QtCore.Qt.Checked)
|
||||
|
||||
def exec_(self, edit=False):
|
||||
"""
|
||||
@ -446,9 +449,10 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard):
|
||||
"""
|
||||
Background gradient Combo box has changed.
|
||||
"""
|
||||
self.theme.background_direction = \
|
||||
BackgroundGradientType.to_string(index)
|
||||
self.setBackgroundPageValues()
|
||||
if self.updateThemeAllowed:
|
||||
self.theme.background_direction = \
|
||||
BackgroundGradientType.to_string(index)
|
||||
self.setBackgroundPageValues()
|
||||
|
||||
def onColorButtonClicked(self):
|
||||
"""
|
||||
@ -560,13 +564,8 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard):
|
||||
"""
|
||||
Lets save the them as Finish has been pressed
|
||||
"""
|
||||
# Some reason getting double submission.
|
||||
# Hack to stop it for now.
|
||||
if self.accepted:
|
||||
return
|
||||
# Save the theme name
|
||||
self.theme.theme_name = \
|
||||
unicode(self.field(u'name').toString())
|
||||
self.theme.theme_name = unicode(self.field(u'name').toString())
|
||||
if not self.theme.theme_name:
|
||||
criticalErrorMessageBox(
|
||||
translate('OpenLP.ThemeForm', 'Theme Name Missing'),
|
||||
@ -590,7 +589,6 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard):
|
||||
if not self.edit_mode and \
|
||||
not self.thememanager.checkIfThemeExists(self.theme.theme_name):
|
||||
return
|
||||
self.accepted = True
|
||||
self.thememanager.saveTheme(self.theme, saveFrom, saveTo)
|
||||
return QtGui.QDialog.accept(self)
|
||||
|
||||
|
@ -165,13 +165,7 @@ class ThemesTab(SettingsTab):
|
||||
self.global_theme = unicode(self.DefaultComboBox.currentText())
|
||||
self.parent.renderManager.set_global_theme(
|
||||
self.global_theme, self.theme_level)
|
||||
image = self.parent.ThemeManagerContents.getPreviewImage(
|
||||
self.global_theme)
|
||||
preview = QtGui.QPixmap(unicode(image))
|
||||
if not preview.isNull():
|
||||
preview = preview.scaled(300, 255, QtCore.Qt.KeepAspectRatio,
|
||||
QtCore.Qt.SmoothTransformation)
|
||||
self.DefaultListView.setPixmap(preview)
|
||||
self.__previewGlobalTheme()
|
||||
|
||||
def updateThemeList(self, theme_list):
|
||||
"""
|
||||
@ -198,10 +192,16 @@ class ThemesTab(SettingsTab):
|
||||
self.parent.renderManager.set_global_theme(
|
||||
self.global_theme, self.theme_level)
|
||||
if self.global_theme is not u'':
|
||||
image = self.parent.ThemeManagerContents.getPreviewImage(
|
||||
self.global_theme)
|
||||
preview = QtGui.QPixmap(unicode(image))
|
||||
if not preview.isNull():
|
||||
preview = preview.scaled(300, 255, QtCore.Qt.KeepAspectRatio,
|
||||
QtCore.Qt.SmoothTransformation)
|
||||
self.DefaultListView.setPixmap(preview)
|
||||
self.__previewGlobalTheme()
|
||||
|
||||
def __previewGlobalTheme(self):
|
||||
"""
|
||||
Utility method to update the global theme preview image.
|
||||
"""
|
||||
image = self.parent.ThemeManagerContents.getPreviewImage(
|
||||
self.global_theme)
|
||||
preview = QtGui.QPixmap(unicode(image))
|
||||
if not preview.isNull():
|
||||
preview = preview.scaled(300, 255, QtCore.Qt.KeepAspectRatio,
|
||||
QtCore.Qt.SmoothTransformation)
|
||||
self.DefaultListView.setPixmap(preview)
|
||||
|
@ -29,12 +29,11 @@ from PyQt4 import QtCore, QtGui
|
||||
from openlp.core.lib import translate, build_icon
|
||||
|
||||
class Ui_ThemeWizard(object):
|
||||
def setupUi(self, ThemeWizard):
|
||||
ThemeWizard.setObjectName(u'OpenLP.ThemeWizard')
|
||||
ThemeWizard.setModal(True)
|
||||
ThemeWizard.setWizardStyle(QtGui.QWizard.ModernStyle)
|
||||
ThemeWizard.setOptions(
|
||||
QtGui.QWizard.IndependentPages |
|
||||
def setupUi(self, themeWizard):
|
||||
themeWizard.setObjectName(u'OpenLP.ThemeWizard')
|
||||
themeWizard.setModal(True)
|
||||
themeWizard.setWizardStyle(QtGui.QWizard.ModernStyle)
|
||||
themeWizard.setOptions(QtGui.QWizard.IndependentPages |
|
||||
QtGui.QWizard.NoBackButtonOnStartPage)
|
||||
# Welcome Page
|
||||
self.welcomePage = QtGui.QWizardPage()
|
||||
@ -52,7 +51,7 @@ class Ui_ThemeWizard(object):
|
||||
self.informationLabel.setObjectName(u'InformationLabel')
|
||||
self.welcomeLayout.addWidget(self.informationLabel)
|
||||
self.welcomeLayout.addStretch()
|
||||
ThemeWizard.addPage(self.welcomePage)
|
||||
themeWizard.addPage(self.welcomePage)
|
||||
# Background Page
|
||||
self.backgroundPage = QtGui.QWizardPage()
|
||||
self.backgroundPage.setObjectName(u'BackgroundPage')
|
||||
@ -142,7 +141,7 @@ class Ui_ThemeWizard(object):
|
||||
self.imageSpacer)
|
||||
self.backgroundStack.addWidget(self.imageWidget)
|
||||
self.backgroundLayout.addLayout(self.backgroundStack)
|
||||
ThemeWizard.addPage(self.backgroundPage)
|
||||
themeWizard.addPage(self.backgroundPage)
|
||||
# Main Area Page
|
||||
self.mainAreaPage = QtGui.QWizardPage()
|
||||
self.mainAreaPage.setObjectName(u'MainAreaPage')
|
||||
@ -225,7 +224,7 @@ class Ui_ThemeWizard(object):
|
||||
self.shadowSizeSpinBox.setObjectName(u'ShadowSizeSpinBox')
|
||||
self.shadowLayout.addWidget(self.shadowSizeSpinBox)
|
||||
self.mainAreaLayout.addRow(self.shadowCheckBox, self.shadowLayout)
|
||||
ThemeWizard.addPage(self.mainAreaPage)
|
||||
themeWizard.addPage(self.mainAreaPage)
|
||||
# Footer Area Page
|
||||
self.footerAreaPage = QtGui.QWizardPage()
|
||||
self.footerAreaPage.setObjectName(u'FooterAreaPage')
|
||||
@ -251,7 +250,7 @@ class Ui_ThemeWizard(object):
|
||||
self.footerSizeSpinBox.setObjectName(u'FooterSizeSpinBox')
|
||||
self.footerAreaLayout.addRow(self.footerSizeLabel,
|
||||
self.footerSizeSpinBox)
|
||||
ThemeWizard.addPage(self.footerAreaPage)
|
||||
themeWizard.addPage(self.footerAreaPage)
|
||||
# Alignment Page
|
||||
self.alignmentPage = QtGui.QWizardPage()
|
||||
self.alignmentPage.setObjectName(u'AlignmentPage')
|
||||
@ -276,7 +275,7 @@ class Ui_ThemeWizard(object):
|
||||
self.transitionsCheckBox.setObjectName(u'TransitionsCheckBox')
|
||||
self.alignmentLayout.addRow(self.transitionsLabel,
|
||||
self.transitionsCheckBox)
|
||||
ThemeWizard.addPage(self.alignmentPage)
|
||||
themeWizard.addPage(self.alignmentPage)
|
||||
# Area Position Page
|
||||
self.areaPositionPage = QtGui.QWizardPage()
|
||||
self.areaPositionPage.setObjectName(u'AreaPositionPage')
|
||||
@ -352,7 +351,7 @@ class Ui_ThemeWizard(object):
|
||||
self.footerPositionLayout.addRow(self.footerHeightLabel,
|
||||
self.footerHeightSpinBox)
|
||||
self.areaPositionLayout.addWidget(self.footerPositionGroupBox)
|
||||
ThemeWizard.addPage(self.areaPositionPage)
|
||||
themeWizard.addPage(self.areaPositionPage)
|
||||
# Preview Page
|
||||
self.previewPage = QtGui.QWizardPage()
|
||||
self.previewPage.setObjectName(u'PreviewPage')
|
||||
@ -381,9 +380,8 @@ class Ui_ThemeWizard(object):
|
||||
self.previewBoxLabel.setObjectName(u'PreviewBoxLabel')
|
||||
self.previewAreaLayout.addWidget(self.previewBoxLabel)
|
||||
self.previewLayout.addWidget(self.previewArea)
|
||||
ThemeWizard.addPage(self.previewPage)
|
||||
|
||||
self.retranslateUi(ThemeWizard)
|
||||
themeWizard.addPage(self.previewPage)
|
||||
self.retranslateUi(themeWizard)
|
||||
QtCore.QObject.connect(self.backgroundComboBox,
|
||||
QtCore.SIGNAL(u'currentIndexChanged(int)'), self.backgroundStack,
|
||||
QtCore.SLOT(u'setCurrentIndex(int)'))
|
||||
@ -423,10 +421,10 @@ class Ui_ThemeWizard(object):
|
||||
QtCore.QObject.connect(self.footerPositionCheckBox,
|
||||
QtCore.SIGNAL(u'toggled(bool)'), self.footerHeightSpinBox,
|
||||
QtCore.SLOT(u'setDisabled(bool)'))
|
||||
QtCore.QMetaObject.connectSlotsByName(ThemeWizard)
|
||||
QtCore.QMetaObject.connectSlotsByName(themeWizard)
|
||||
|
||||
def retranslateUi(self, ThemeWizard):
|
||||
ThemeWizard.setWindowTitle(
|
||||
def retranslateUi(self, themeWizard):
|
||||
themeWizard.setWindowTitle(
|
||||
translate('OpenLP.ThemeWizard', 'Theme Wizard'))
|
||||
self.titleLabel.setText(
|
||||
u'<span style="font-size:14pt; font-weight:600;">%s</span>' % \
|
||||
|
@ -137,10 +137,7 @@ class AppLocation(object):
|
||||
os.path.split(openlp.__file__)[0])
|
||||
return os.path.join(app_path, u'i18n')
|
||||
else:
|
||||
return _get_os_dir_path(u'openlp',
|
||||
os.path.join(os.getenv(u'HOME'), u'Library',
|
||||
u'Application Support', u'openlp'),
|
||||
None, os.path.join(os.getenv(u'HOME'), u'.openlp'), dir_type)
|
||||
return _get_os_dir_path(dir_type)
|
||||
|
||||
@staticmethod
|
||||
def get_data_path():
|
||||
@ -163,17 +160,18 @@ class AppLocation(object):
|
||||
os.makedirs(path)
|
||||
return path
|
||||
|
||||
def _get_os_dir_path(win_option, darwin_option, base_dir_option,
|
||||
non_base_dir_option, dir_type=1):
|
||||
def _get_os_dir_path(dir_type):
|
||||
"""
|
||||
Return a path based on which OS and environment we are running in.
|
||||
"""
|
||||
if sys.platform == u'win32':
|
||||
return os.path.join(os.getenv(u'APPDATA'), win_option)
|
||||
return os.path.join(os.getenv(u'APPDATA'), u'openlp')
|
||||
elif sys.platform == u'darwin':
|
||||
if dir_type == AppLocation.DataDir:
|
||||
return os.path.join(darwin_option, u'Data')
|
||||
return darwin_option
|
||||
return os.path.join(os.getenv(u'HOME'), u'Library',
|
||||
u'Application Support', u'openlp', u'Data')
|
||||
return os.path.join(os.getenv(u'HOME'), u'Library',
|
||||
u'Application Support', u'openlp')
|
||||
else:
|
||||
if XDG_BASE_AVAILABLE:
|
||||
if dir_type == AppLocation.ConfigDir:
|
||||
@ -183,7 +181,7 @@ def _get_os_dir_path(win_option, darwin_option, base_dir_option,
|
||||
elif dir_type == AppLocation.CacheDir:
|
||||
return os.path.join(BaseDirectory.xdg_cache_home, u'openlp')
|
||||
else:
|
||||
return non_base_dir_option
|
||||
return os.path.join(os.getenv(u'HOME'), u'.openlp')
|
||||
|
||||
def _get_frozen_path(frozen_option, non_frozen_option):
|
||||
"""
|
||||
|
@ -45,15 +45,14 @@ class AlertsPlugin(Plugin):
|
||||
self.icon = build_icon(u':/plugins/plugin_alerts.png')
|
||||
self.alertsmanager = AlertsManager(self)
|
||||
self.manager = Manager(u'alerts', init_schema)
|
||||
visible_name = self.getString(StringContent.VisibleName)
|
||||
self.alertForm = AlertForm(self, visible_name[u'title'])
|
||||
self.visible_name = self.getString(StringContent.VisibleName)
|
||||
self.alertForm = AlertForm(self)
|
||||
|
||||
def getSettingsTab(self):
|
||||
"""
|
||||
Return the settings tab for the Alerts plugin
|
||||
"""
|
||||
visible_name = self.getString(StringContent.VisibleName)
|
||||
self.alertsTab = AlertsTab(self, visible_name[u'title'])
|
||||
self.alertsTab = AlertsTab(self, self.visible_name[u'title'])
|
||||
return self.alertsTab
|
||||
|
||||
def addToolsMenuItem(self, tools_menu):
|
||||
|
@ -35,7 +35,7 @@ class AlertForm(QtGui.QDialog, Ui_AlertDialog):
|
||||
"""
|
||||
Provide UI for the alert system
|
||||
"""
|
||||
def __init__(self, plugin, visible_title):
|
||||
def __init__(self, plugin):
|
||||
"""
|
||||
Initialise the alert form
|
||||
"""
|
||||
|
@ -124,9 +124,12 @@ class BibleImportForm(OpenLPWizard):
|
||||
QtCore.QObject.connect(self.osisBrowseButton,
|
||||
QtCore.SIGNAL(u'clicked()'),
|
||||
self.onOsisBrowseButtonClicked)
|
||||
QtCore.QObject.connect(self.csvTestamentsButton,
|
||||
QtCore.SIGNAL(u'clicked()'),
|
||||
self.onCsvTestamentsBrowseButtonClicked)
|
||||
QtCore.QObject.connect(self.csvBooksButton,
|
||||
QtCore.SIGNAL(u'clicked()'),
|
||||
self.onBooksBrowseButtonClicked)
|
||||
self.onCsvBooksBrowseButtonClicked)
|
||||
QtCore.QObject.connect(self.csvVersesButton,
|
||||
QtCore.SIGNAL(u'clicked()'),
|
||||
self.onCsvVersesBrowseButtonClicked)
|
||||
@ -187,6 +190,18 @@ class BibleImportForm(OpenLPWizard):
|
||||
self.csvLayout = QtGui.QFormLayout(self.csvWidget)
|
||||
self.csvLayout.setMargin(0)
|
||||
self.csvLayout.setObjectName(u'CsvLayout')
|
||||
self.csvTestamentsLabel = QtGui.QLabel(self.csvWidget)
|
||||
self.csvTestamentsLabel.setObjectName(u'CsvTestamentsLabel')
|
||||
self.csvTestamentsLayout = QtGui.QHBoxLayout()
|
||||
self.csvTestamentsLayout.setObjectName(u'CsvTestamentsLayout')
|
||||
self.csvTestamentsEdit = QtGui.QLineEdit(self.csvWidget)
|
||||
self.csvTestamentsEdit.setObjectName(u'CsvTestamentsEdit')
|
||||
self.csvTestamentsLayout.addWidget(self.csvTestamentsEdit)
|
||||
self.csvTestamentsButton = QtGui.QToolButton(self.csvWidget)
|
||||
self.csvTestamentsButton.setIcon(self.openIcon)
|
||||
self.csvTestamentsButton.setObjectName(u'CsvTestamentsButton')
|
||||
self.csvTestamentsLayout.addWidget(self.csvTestamentsButton)
|
||||
self.csvLayout.addRow(self.csvTestamentsLabel, self.csvTestamentsLayout)
|
||||
self.csvBooksLabel = QtGui.QLabel(self.csvWidget)
|
||||
self.csvBooksLabel.setObjectName(u'CsvBooksLabel')
|
||||
self.csvBooksLayout = QtGui.QHBoxLayout()
|
||||
@ -213,7 +228,7 @@ class BibleImportForm(OpenLPWizard):
|
||||
self.csvLayout.addRow(self.csvVersesLabel, self.csvVersesLayout)
|
||||
self.csvSpacer = QtGui.QSpacerItem(10, 0, QtGui.QSizePolicy.Fixed,
|
||||
QtGui.QSizePolicy.Minimum)
|
||||
self.csvLayout.setItem(2, QtGui.QFormLayout.LabelRole, self.csvSpacer)
|
||||
self.csvLayout.setItem(3, QtGui.QFormLayout.LabelRole, self.csvSpacer)
|
||||
self.selectStack.addWidget(self.csvWidget)
|
||||
self.openSongWidget = QtGui.QWidget(self.selectPage)
|
||||
self.openSongWidget.setObjectName(u'OpenSongWidget')
|
||||
@ -389,6 +404,8 @@ class BibleImportForm(OpenLPWizard):
|
||||
translate('BiblesPlugin.ImportWizardForm', 'File location:'))
|
||||
self.osisFileLabel.setText(
|
||||
translate('BiblesPlugin.ImportWizardForm', 'File location:'))
|
||||
self.csvTestamentsLabel.setText(
|
||||
translate('BiblesPlugin.ImportWizardForm', 'Testaments location:'))
|
||||
self.csvBooksLabel.setText(
|
||||
translate('BiblesPlugin.ImportWizardForm', 'Books location:'))
|
||||
self.csvVersesLabel.setText(
|
||||
@ -478,7 +495,16 @@ class BibleImportForm(OpenLPWizard):
|
||||
self.osisFileEdit.setFocus()
|
||||
return False
|
||||
elif self.field(u'source_format').toInt()[0] == BibleFormat.CSV:
|
||||
if not self.field(u'csv_booksfile').toString():
|
||||
if not self.field(u'csv_testamentsfile').toString():
|
||||
answer = criticalErrorMessageBox(translate(
|
||||
'BiblesPlugin.ImportWizardForm', 'No Testaments File'),
|
||||
translate('BiblesPlugin.ImportWizardForm',
|
||||
'You have not specified a testaments file. Do you '
|
||||
'want to proceed with the import?'), question=True)
|
||||
if answer == QtGui.QMessageBox.No:
|
||||
self.csvTestamentsEdit.setFocus()
|
||||
return False
|
||||
elif not self.field(u'csv_booksfile').toString():
|
||||
criticalErrorMessageBox(
|
||||
translate('BiblesPlugin.ImportWizardForm',
|
||||
'Invalid Books File'),
|
||||
@ -572,7 +598,15 @@ class BibleImportForm(OpenLPWizard):
|
||||
translate('BiblesPlugin.ImportWizardForm', 'Open OSIS File'),
|
||||
self.osisFileEdit)
|
||||
|
||||
def onBooksBrowseButtonClicked(self):
|
||||
def onCsvTestamentsBrowseButtonClicked(self):
|
||||
"""
|
||||
Show the file open dialog for the testaments CSV file.
|
||||
"""
|
||||
self.getFileName(translate('BiblesPlugin.ImportWizardForm',
|
||||
'Open Testaments CSV File'), self.csvTestamentsEdit, u'%s (*.csv)'
|
||||
% translate('BiblesPlugin.ImportWizardForm', 'CSV File'))
|
||||
|
||||
def onCsvBooksBrowseButtonClicked(self):
|
||||
"""
|
||||
Show the file open dialog for the books CSV file.
|
||||
"""
|
||||
@ -613,12 +647,14 @@ class BibleImportForm(OpenLPWizard):
|
||||
"""
|
||||
self.selectPage.registerField(u'source_format', self.formatComboBox)
|
||||
self.selectPage.registerField(u'osis_location', self.osisFileEdit)
|
||||
self.selectPage.registerField(
|
||||
u'csv_testamentsfile', self.csvTestamentsEdit)
|
||||
self.selectPage.registerField(u'csv_booksfile', self.csvBooksEdit)
|
||||
self.selectPage.registerField(u'csv_versefile', self.csvVersesEdit)
|
||||
self.selectPage.registerField(u'opensong_file', self.openSongFileEdit)
|
||||
self.selectPage.registerField(u'web_location', self.webSourceComboBox)
|
||||
self.selectPage.registerField(u'web_biblename',
|
||||
self.webTranslationComboBox)
|
||||
self.selectPage.registerField(
|
||||
u'web_biblename', self.webTranslationComboBox)
|
||||
self.selectPage.registerField(u'proxy_server', self.webServerEdit)
|
||||
self.selectPage.registerField(u'proxy_username', self.webUserEdit)
|
||||
self.selectPage.registerField(u'proxy_password', self.webPasswordEdit)
|
||||
@ -641,6 +677,7 @@ class BibleImportForm(OpenLPWizard):
|
||||
self.cancelButton.setVisible(True)
|
||||
self.setField(u'source_format', QtCore.QVariant(0))
|
||||
self.setField(u'osis_location', QtCore.QVariant(''))
|
||||
self.setField(u'csv_testamentsfile', QtCore.QVariant(''))
|
||||
self.setField(u'csv_booksfile', QtCore.QVariant(''))
|
||||
self.setField(u'csv_versefile', QtCore.QVariant(''))
|
||||
self.setField(u'opensong_file', QtCore.QVariant(''))
|
||||
@ -770,7 +807,8 @@ class BibleImportForm(OpenLPWizard):
|
||||
elif bible_type == BibleFormat.CSV:
|
||||
# Import a CSV bible.
|
||||
importer = self.manager.import_bible(BibleFormat.CSV,
|
||||
name=license_version,
|
||||
name=license_version, testamentsfile=unicode(
|
||||
self.field(u'csv_testamentsfile').toString()),
|
||||
booksfile=unicode(self.field(u'csv_booksfile').toString()),
|
||||
versefile=unicode(self.field(u'csv_versefile').toString())
|
||||
)
|
||||
@ -795,8 +833,7 @@ class BibleImportForm(OpenLPWizard):
|
||||
bible = \
|
||||
self.web_bible_list[WebDownload.Bibleserver][bible_version]
|
||||
importer = self.manager.import_bible(
|
||||
BibleFormat.WebDownload,
|
||||
name=license_version,
|
||||
BibleFormat.WebDownload, name=license_version,
|
||||
download_source=WebDownload.get_name(download_location),
|
||||
download_name=bible,
|
||||
proxy_server=unicode(self.field(u'proxy_server').toString()),
|
||||
|
@ -23,7 +23,48 @@
|
||||
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
|
||||
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
||||
###############################################################################
|
||||
"""
|
||||
The :mod:`cvsbible` modules provides a facility to import bibles from a set of
|
||||
CSV files.
|
||||
|
||||
The module expects two mandatory files containing the books and the verses and
|
||||
will accept an optional third file containing the testaments.
|
||||
|
||||
The format of the testament file is:
|
||||
|
||||
<testament_id>,<testament_name>
|
||||
|
||||
For example:
|
||||
|
||||
1,Old Testament
|
||||
2,New Testament
|
||||
|
||||
The format of the books file is:
|
||||
|
||||
<book_id>,<testament_id>,<book_name>,<book_abbreviation>
|
||||
|
||||
For example
|
||||
|
||||
1,1,Genesis,Gen
|
||||
2,1,Exodus,Exod
|
||||
...
|
||||
40,2,Matthew,Matt
|
||||
|
||||
There are two acceptable formats of the verses file. They are:
|
||||
|
||||
<book_id>,<chapter_number>,<verse_number>,<verse_text>
|
||||
or
|
||||
<book_name>,<chapter_number>,<verse_number>,<verse_text>
|
||||
|
||||
For example:
|
||||
|
||||
1,1,1,"In the beginning God created the heaven and the earth."
|
||||
or
|
||||
"Genesis",1,2,"And the earth was without form, and void; and...."
|
||||
|
||||
All CSV files are expected to use a comma (',') as the delimeter and double
|
||||
quotes ('"') as the quote symbol.
|
||||
"""
|
||||
import logging
|
||||
import chardet
|
||||
import csv
|
||||
@ -31,7 +72,7 @@ import csv
|
||||
from PyQt4 import QtCore
|
||||
|
||||
from openlp.core.lib import Receiver, translate
|
||||
from openlp.plugins.bibles.lib.db import BibleDB
|
||||
from openlp.plugins.bibles.lib.db import BibleDB, Testament
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
@ -39,68 +80,120 @@ class CSVBible(BibleDB):
|
||||
"""
|
||||
This class provides a specialisation for importing of CSV Bibles.
|
||||
"""
|
||||
|
||||
def __init__(self, parent, **kwargs):
|
||||
"""
|
||||
Loads a Bible from a pair of CVS files passed in
|
||||
Loads a Bible from a set of CVS files.
|
||||
This class assumes the files contain all the information and
|
||||
a clean bible is being loaded.
|
||||
"""
|
||||
log.info(self.__class__.__name__)
|
||||
BibleDB.__init__(self, parent, **kwargs)
|
||||
try:
|
||||
self.testamentsfile = kwargs[u'testamentsfile']
|
||||
except KeyError:
|
||||
self.testamentsfile = None
|
||||
self.booksfile = kwargs[u'booksfile']
|
||||
self.versesfile = kwargs[u'versefile']
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'openlp_stop_wizard'), self.stop_import)
|
||||
|
||||
def setup_testaments(self):
|
||||
"""
|
||||
Overrides parent method so we can handle importing a testament file.
|
||||
"""
|
||||
if self.testamentsfile:
|
||||
self.wizard.progressBar.setMinimum(0)
|
||||
self.wizard.progressBar.setMaximum(2)
|
||||
self.wizard.progressBar.setValue(0)
|
||||
testaments_file = None
|
||||
try:
|
||||
details = get_file_encoding(self.testamentsfile)
|
||||
testaments_file = open(self.testamentsfile, 'rb')
|
||||
testaments_reader = csv.reader(testaments_file, delimiter=',',
|
||||
quotechar='"')
|
||||
for line in testaments_reader:
|
||||
if self.stop_import_flag:
|
||||
break
|
||||
self.wizard.incrementProgressBar(unicode(
|
||||
translate('BibleDB.Wizard',
|
||||
'Importing testaments... %s')) %
|
||||
unicode(line[1], details['encoding']), 0)
|
||||
self.save_object(Testament.populate(
|
||||
name=unicode(line[1], details['encoding'])))
|
||||
Receiver.send_message(u'openlp_process_events')
|
||||
except (IOError, IndexError):
|
||||
log.exception(u'Loading testaments from file failed')
|
||||
finally:
|
||||
if testaments_file:
|
||||
testaments_file.close()
|
||||
self.wizard.incrementProgressBar(unicode(translate(
|
||||
'BibleDB.Wizard', 'Importing testaments... done.')), 2)
|
||||
else:
|
||||
BibleDB.setup_testaments(self)
|
||||
|
||||
def do_import(self):
|
||||
"""
|
||||
Import the bible books and verses.
|
||||
"""
|
||||
self.wizard.progressBar.setValue(0)
|
||||
self.wizard.progressBar.setMinimum(0)
|
||||
self.wizard.progressBar.setMaximum(66)
|
||||
success = True
|
||||
books_file = None
|
||||
book_ptr = None
|
||||
verse_file = None
|
||||
book_list = {}
|
||||
# Populate the Tables
|
||||
try:
|
||||
details = get_file_encoding(self.booksfile)
|
||||
books_file = open(self.booksfile, 'r')
|
||||
dialect = csv.Sniffer().sniff(books_file.read(1024))
|
||||
books_file.seek(0)
|
||||
books_reader = csv.reader(books_file, dialect)
|
||||
books_reader = csv.reader(books_file, delimiter=',', quotechar='"')
|
||||
for line in books_reader:
|
||||
# cancel pressed
|
||||
if self.stop_import_flag:
|
||||
break
|
||||
details = chardet.detect(line[1])
|
||||
self.create_book(unicode(line[1], details['encoding']),
|
||||
line[2], int(line[0]))
|
||||
Receiver.send_message(u'openlp_process_events')
|
||||
self.wizard.incrementProgressBar(unicode(
|
||||
translate('BibleDB.Wizard', 'Importing books... %s')) %
|
||||
unicode(line[2], details['encoding']))
|
||||
self.create_book(unicode(line[2], details['encoding']),
|
||||
unicode(line[3], details['encoding']), int(line[1]))
|
||||
book_list[int(line[0])] = unicode(line[2], details['encoding'])
|
||||
Receiver.send_message(u'openlp_process_events')
|
||||
except (IOError, IndexError):
|
||||
log.exception(u'Loading books from file failed')
|
||||
success = False
|
||||
finally:
|
||||
if books_file:
|
||||
books_file.close()
|
||||
if not success:
|
||||
if self.stop_import_flag or not success:
|
||||
return False
|
||||
self.wizard.progressBar.setValue(0)
|
||||
self.wizard.progressBar.setMaximum(67)
|
||||
verse_file = None
|
||||
try:
|
||||
verse_file = open(self.versesfile, 'r')
|
||||
dialect = csv.Sniffer().sniff(verse_file.read(1024))
|
||||
verse_file.seek(0)
|
||||
verse_reader = csv.reader(verse_file, dialect)
|
||||
book_ptr = None
|
||||
details = get_file_encoding(self.versesfile)
|
||||
verse_file = open(self.versesfile, 'rb')
|
||||
verse_reader = csv.reader(verse_file, delimiter=',', quotechar='"')
|
||||
for line in verse_reader:
|
||||
if self.stop_import_flag:
|
||||
# cancel pressed
|
||||
break
|
||||
details = chardet.detect(line[3])
|
||||
if book_ptr != line[0]:
|
||||
book = self.get_book(line[0])
|
||||
try:
|
||||
line_book = book_list[int(line[0])]
|
||||
except ValueError:
|
||||
line_book = unicode(line[0], details['encoding'])
|
||||
if book_ptr != line_book:
|
||||
book = self.get_book(line_book)
|
||||
book_ptr = book.name
|
||||
self.wizard.incrementProgressBar(unicode(translate(
|
||||
'BiblesPlugin.CSVImport', 'Importing %s %s...',
|
||||
'Importing <book name> <chapter>...')) %
|
||||
(book.name, int(line[1])))
|
||||
'BibleDB.Wizard', 'Importing verses from %s...',
|
||||
'Importing verses from <book name>...')) % book.name)
|
||||
self.session.commit()
|
||||
self.create_verse(book.id, line[1], line[2],
|
||||
unicode(line[3], details['encoding']))
|
||||
Receiver.send_message(u'openlp_process_events')
|
||||
try:
|
||||
verse_text = unicode(line[3], details['encoding'])
|
||||
except UnicodeError:
|
||||
verse_text = unicode(line[3], u'cp1252')
|
||||
self.create_verse(book.id, line[1], line[2], verse_text)
|
||||
self.wizard.incrementProgressBar(translate('BibleDB.Wizard',
|
||||
'Importing verses... done.'))
|
||||
Receiver.send_message(u'openlp_process_events')
|
||||
self.session.commit()
|
||||
except IOError:
|
||||
log.exception(u'Loading verses from file failed')
|
||||
@ -112,3 +205,18 @@ class CSVBible(BibleDB):
|
||||
return False
|
||||
else:
|
||||
return success
|
||||
|
||||
def get_file_encoding(filename):
|
||||
"""
|
||||
Utility function to get the file encoding.
|
||||
"""
|
||||
detect_file = None
|
||||
try:
|
||||
detect_file = open(filename, 'r')
|
||||
details = chardet.detect(detect_file.read(1024))
|
||||
except IOError:
|
||||
log.exception(u'Error detecting file encoding')
|
||||
finally:
|
||||
if detect_file:
|
||||
detect_file.close()
|
||||
return details
|
||||
|
@ -206,10 +206,16 @@ class BibleDB(QtCore.QObject, Manager):
|
||||
"""
|
||||
self.wizard = wizard
|
||||
self.create_meta(u'dbversion', u'2')
|
||||
self.setup_testaments()
|
||||
return self.name
|
||||
|
||||
def setup_testaments(self):
|
||||
"""
|
||||
Initialise the testaments section of a bible with suitable defaults.
|
||||
"""
|
||||
self.save_object(Testament.populate(name=u'Old Testament'))
|
||||
self.save_object(Testament.populate(name=u'New Testament'))
|
||||
self.save_object(Testament.populate(name=u'Apocrypha'))
|
||||
return self.name
|
||||
|
||||
def create_book(self, name, abbrev, testament=1):
|
||||
"""
|
||||
|
@ -210,7 +210,8 @@ class BGExtract(object):
|
||||
cleaner = [(re.compile(' |<br />|\'\+\''), lambda match: '')]
|
||||
soup = get_soup_for_bible_ref(
|
||||
u'http://www.biblegateway.com/passage/?%s' % url_params,
|
||||
cleaner=cleaner)
|
||||
pre_parse_regex=r'<meta name.*?/>', pre_parse_substitute='',
|
||||
cleaner=cleaner)
|
||||
if not soup:
|
||||
return None
|
||||
Receiver.send_message(u'openlp_process_events')
|
||||
@ -499,7 +500,8 @@ class HTTPBible(BibleDB):
|
||||
"""
|
||||
return HTTPBooks.get_verse_count(book, chapter)
|
||||
|
||||
def get_soup_for_bible_ref(reference_url, header=None, cleaner=None):
|
||||
def get_soup_for_bible_ref(reference_url, header=None, pre_parse_regex=None,
|
||||
pre_parse_substitute=None, cleaner=None):
|
||||
"""
|
||||
Gets a webpage and returns a parsed and optionally cleaned soup or None.
|
||||
|
||||
@ -509,6 +511,13 @@ def get_soup_for_bible_ref(reference_url, header=None, cleaner=None):
|
||||
``header``
|
||||
An optional HTTP header to pass to the bible web server.
|
||||
|
||||
``pre_parse_regex``
|
||||
A regular expression to run on the webpage. Allows manipulation of the
|
||||
webpage before passing to BeautifulSoup for parsing.
|
||||
|
||||
``pre_parse_substitute``
|
||||
The text to replace any matches to the regular expression with.
|
||||
|
||||
``cleaner``
|
||||
An optional regex to use during webpage parsing.
|
||||
"""
|
||||
@ -518,12 +527,15 @@ def get_soup_for_bible_ref(reference_url, header=None, cleaner=None):
|
||||
if not page:
|
||||
send_error_message(u'download')
|
||||
return None
|
||||
page_source = page.read()
|
||||
if pre_parse_regex and pre_parse_substitute is not None:
|
||||
page_source = re.sub(pre_parse_regex, pre_parse_substitute, page_source)
|
||||
soup = None
|
||||
try:
|
||||
if cleaner:
|
||||
soup = BeautifulSoup(page, markupMassage=cleaner)
|
||||
soup = BeautifulSoup(page_source, markupMassage=cleaner)
|
||||
else:
|
||||
soup = BeautifulSoup(page)
|
||||
soup = BeautifulSoup(page_source)
|
||||
except HTMLParseError:
|
||||
log.exception(u'BeautifulSoup could not parse the bible page.')
|
||||
if not soup:
|
||||
|
@ -92,7 +92,7 @@ class BibleFormat(object):
|
||||
return None
|
||||
|
||||
@staticmethod
|
||||
def list():
|
||||
def get_formats_list():
|
||||
"""
|
||||
Return a list of the supported Bible formats.
|
||||
"""
|
||||
|
@ -254,9 +254,6 @@ class BibleMediaItem(MediaManagerItem):
|
||||
QtCore.QObject.connect(self.quickSearchEdit,
|
||||
QtCore.SIGNAL(u'returnPressed()'), self.onQuickSearchButton)
|
||||
|
||||
def addListViewToToolBar(self):
|
||||
MediaManagerItem.addListViewToToolBar(self)
|
||||
|
||||
def configUpdated(self):
|
||||
log.debug(u'configUpdated')
|
||||
if QtCore.QSettings().value(self.settingsSection + u'/second bibles',
|
||||
@ -528,19 +525,7 @@ class BibleMediaItem(MediaManagerItem):
|
||||
if self.advancedClearComboBox.currentIndex() == 0:
|
||||
self.listView.clear()
|
||||
if self.listView.count() != 0:
|
||||
# Check if the first item is a second bible item or not.
|
||||
bitem = self.listView.item(0)
|
||||
item_second_bible = self._decodeQtObject(bitem, 'second_bible')
|
||||
if item_second_bible and second_bible or not item_second_bible and \
|
||||
not second_bible:
|
||||
self.displayResults(bible, second_bible)
|
||||
elif criticalErrorMessageBox(
|
||||
message=translate('BiblePlugin.MediaItem',
|
||||
'You cannot combine single and second bible verses. Do you '
|
||||
'want to delete your search results and start a new search?'),
|
||||
parent=self, question=True) == QtGui.QMessageBox.Yes:
|
||||
self.listView.clear()
|
||||
self.displayResults(bible, second_bible)
|
||||
self.__checkSecondBible(bible, second_bible)
|
||||
else:
|
||||
self.displayResults(bible, second_bible)
|
||||
Receiver.send_message(u'cursor_normal')
|
||||
@ -580,24 +565,29 @@ class BibleMediaItem(MediaManagerItem):
|
||||
if self.quickClearComboBox.currentIndex() == 0:
|
||||
self.listView.clear()
|
||||
if self.listView.count() != 0 and self.search_results:
|
||||
bitem = self.listView.item(0)
|
||||
item_second_bible = self._decodeQtObject(bitem, 'second_bible')
|
||||
if item_second_bible and second_bible or not item_second_bible and \
|
||||
not second_bible:
|
||||
self.displayResults(bible, second_bible)
|
||||
elif criticalErrorMessageBox(
|
||||
message=translate('BiblePlugin.MediaItem',
|
||||
'You cannot combine single and second bible verses. Do you '
|
||||
'want to delete your search results and start a new search?'),
|
||||
parent=self, question=True) == QtGui.QMessageBox.Yes:
|
||||
self.listView.clear()
|
||||
self.displayResults(bible, second_bible)
|
||||
self.__checkSecondBible(bible, second_bible)
|
||||
elif self.search_results:
|
||||
self.displayResults(bible, second_bible)
|
||||
self.quickSearchButton.setEnabled(True)
|
||||
Receiver.send_message(u'cursor_normal')
|
||||
Receiver.send_message(u'openlp_process_events')
|
||||
|
||||
def __checkSecondBible(self, bible, second_bible):
|
||||
"""
|
||||
Check if the first item is a second bible item or not.
|
||||
"""
|
||||
bitem = self.listView.item(0)
|
||||
item_second_bible = self._decodeQtObject(bitem, 'second_bible')
|
||||
if item_second_bible and second_bible or not item_second_bible and \
|
||||
not second_bible:
|
||||
self.displayResults(bible, second_bible)
|
||||
elif criticalErrorMessageBox(message=translate('BiblePlugin.MediaItem',
|
||||
'You cannot combine single and second bible verses. Do you '
|
||||
'want to delete your search results and start a new search?'),
|
||||
parent=self, question=True) == QtGui.QMessageBox.Yes:
|
||||
self.listView.clear()
|
||||
self.displayResults(bible, second_bible)
|
||||
|
||||
def displayResults(self, bible, second_bible=u''):
|
||||
"""
|
||||
Displays the search results in the media manager. All data needed for
|
||||
|
@ -19,7 +19,7 @@ IBS-fordítás (Új Károli), KAR
|
||||
King James Version, KJV
|
||||
Luther 1984, LUT
|
||||
Septuaginta, LXX
|
||||
Neue Genfer Übersetzung, NGÜ
|
||||
Neue Genfer Übersetzung, NGU
|
||||
New International Readers Version, NIRV
|
||||
New International Version, NIV
|
||||
Neues Leben, NL
|
||||
|
|
@ -26,7 +26,7 @@
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.lib import build_icon, translate
|
||||
from openlp.core.lib import build_icon, translate, save_cancel_button_box
|
||||
|
||||
class Ui_CustomEditDialog(object):
|
||||
def setupUi(self, customEditDialog):
|
||||
@ -93,16 +93,9 @@ class Ui_CustomEditDialog(object):
|
||||
self.creditLabel.setBuddy(self.creditEdit)
|
||||
self.bottomFormLayout.addRow(self.creditLabel, self.creditEdit)
|
||||
self.dialogLayout.addLayout(self.bottomFormLayout)
|
||||
self.buttonBox = QtGui.QDialogButtonBox(customEditDialog)
|
||||
self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel |
|
||||
QtGui.QDialogButtonBox.Save)
|
||||
self.buttonBox.setObjectName(u'buttonBox')
|
||||
self.buttonBox = save_cancel_button_box(customEditDialog)
|
||||
self.dialogLayout.addWidget(self.buttonBox)
|
||||
self.retranslateUi(customEditDialog)
|
||||
QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(u'accepted()'),
|
||||
customEditDialog.accept)
|
||||
QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(u'rejected()'),
|
||||
customEditDialog.closePressed)
|
||||
QtCore.QMetaObject.connectSlotsByName(customEditDialog)
|
||||
|
||||
def retranslateUi(self, customEditDialog):
|
||||
|
@ -136,7 +136,7 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog):
|
||||
if preview:
|
||||
self.previewButton.setVisible(True)
|
||||
|
||||
def closePressed(self):
|
||||
def reject(self):
|
||||
Receiver.send_message(u'custom_edit_clear')
|
||||
self.close()
|
||||
|
||||
|
@ -26,7 +26,7 @@
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.lib import translate, SpellTextEdit
|
||||
from openlp.core.lib import translate, SpellTextEdit, save_cancel_button_box
|
||||
|
||||
class Ui_CustomSlideEditDialog(object):
|
||||
def setupUi(self, customSlideEditDialog):
|
||||
@ -36,20 +36,13 @@ class Ui_CustomSlideEditDialog(object):
|
||||
self.slideTextEdit = SpellTextEdit(self)
|
||||
self.slideTextEdit.setObjectName(u'slideTextEdit')
|
||||
self.dialogLayout.addWidget(self.slideTextEdit)
|
||||
self.buttonBox = QtGui.QDialogButtonBox(customSlideEditDialog)
|
||||
self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel |
|
||||
QtGui.QDialogButtonBox.Save)
|
||||
self.buttonBox.setObjectName(u'buttonBox')
|
||||
self.buttonBox = save_cancel_button_box(customSlideEditDialog)
|
||||
self.splitButton = QtGui.QPushButton(customSlideEditDialog)
|
||||
self.splitButton.setObjectName(u'splitButton')
|
||||
self.buttonBox.addButton(self.splitButton,
|
||||
QtGui.QDialogButtonBox.ActionRole)
|
||||
self.dialogLayout.addWidget(self.buttonBox)
|
||||
self.retranslateUi(customSlideEditDialog)
|
||||
QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(u'accepted()'),
|
||||
customSlideEditDialog.accept)
|
||||
QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(u'rejected()'),
|
||||
customSlideEditDialog.reject)
|
||||
QtCore.QMetaObject.connectSlotsByName(customSlideEditDialog)
|
||||
|
||||
def retranslateUi(self, customSlideEditDialog):
|
||||
|
@ -68,9 +68,6 @@ class CustomMediaItem(MediaManagerItem):
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'custom_preview'), self.onPreviewClick)
|
||||
|
||||
def requiredIcons(self):
|
||||
MediaManagerItem.requiredIcons(self)
|
||||
|
||||
def initialise(self):
|
||||
self.loadCustomListView(self.manager.get_all_objects(
|
||||
CustomSlide, order_by_ref=CustomSlide.title))
|
||||
@ -149,16 +146,7 @@ class CustomMediaItem(MediaManagerItem):
|
||||
raw_footer = []
|
||||
slide = None
|
||||
theme = None
|
||||
if item is None:
|
||||
if self.remoteTriggered is None:
|
||||
item = self.listView.currentItem()
|
||||
if item is None:
|
||||
return False
|
||||
item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
|
||||
else:
|
||||
item_id = self.remoteCustom
|
||||
else:
|
||||
item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
|
||||
item_id = self._getIdOfItemToGenerate(item, self.remoteCustom)
|
||||
service_item.add_capability(ItemCapabilities.AllowsEdit)
|
||||
service_item.add_capability(ItemCapabilities.AllowsPreview)
|
||||
service_item.add_capability(ItemCapabilities.AllowsLoop)
|
||||
@ -182,4 +170,4 @@ class CustomMediaItem(MediaManagerItem):
|
||||
else:
|
||||
raw_footer.append(u'')
|
||||
service_item.raw_footer = raw_footer
|
||||
return True
|
||||
return True
|
||||
|
@ -31,7 +31,7 @@ from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.lib import MediaManagerItem, BaseListWithDnD, build_icon, \
|
||||
ItemCapabilities, SettingsManager, translate, check_item_selected, \
|
||||
check_directory_exists
|
||||
check_directory_exists, Receiver
|
||||
from openlp.core.ui import criticalErrorMessageBox
|
||||
from openlp.core.utils import AppLocation, delete_file, get_images_filter
|
||||
|
||||
@ -44,7 +44,6 @@ class ImageListView(BaseListWithDnD):
|
||||
self.PluginName = u'Images'
|
||||
BaseListWithDnD.__init__(self, parent)
|
||||
|
||||
|
||||
class ImageMediaItem(MediaManagerItem):
|
||||
"""
|
||||
This is the custom media manager item for images.
|
||||
@ -57,6 +56,8 @@ class ImageMediaItem(MediaManagerItem):
|
||||
# be instanced by the base MediaManagerItem.
|
||||
self.ListViewWithDnD_class = ImageListView
|
||||
MediaManagerItem.__init__(self, parent, self, icon)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'live_theme_changed'), self.liveThemeChanged)
|
||||
|
||||
def retranslateUi(self):
|
||||
self.OnNewPrompt = translate('ImagePlugin.MediaItem',
|
||||
@ -95,7 +96,6 @@ class ImageMediaItem(MediaManagerItem):
|
||||
|
||||
def addListViewToToolBar(self):
|
||||
MediaManagerItem.addListViewToToolBar(self)
|
||||
self.listView.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu)
|
||||
self.listView.addAction(self.replaceAction)
|
||||
|
||||
def addEndHeaderBar(self):
|
||||
@ -142,7 +142,7 @@ class ImageMediaItem(MediaManagerItem):
|
||||
items = self.listView.selectedIndexes()
|
||||
if items:
|
||||
service_item.title = unicode(
|
||||
translate('ImagePlugin.MediaItem', 'Image(s)'))
|
||||
translate('ImagePlugin.MediaItem', 'Images'))
|
||||
service_item.add_capability(ItemCapabilities.AllowsMaintain)
|
||||
service_item.add_capability(ItemCapabilities.AllowsPreview)
|
||||
service_item.add_capability(ItemCapabilities.AllowsLoop)
|
||||
@ -193,6 +193,12 @@ class ImageMediaItem(MediaManagerItem):
|
||||
self.resetAction.setVisible(False)
|
||||
self.parent.liveController.display.resetImage()
|
||||
|
||||
def liveThemeChanged(self):
|
||||
"""
|
||||
Triggered by the change of theme in the slide controller
|
||||
"""
|
||||
self.resetAction.setVisible(False)
|
||||
|
||||
def onReplaceClick(self):
|
||||
"""
|
||||
Called to replace Live backgound with the image selected.
|
||||
@ -213,6 +219,3 @@ class ImageMediaItem(MediaManagerItem):
|
||||
unicode(translate('ImagePlugin.MediaItem',
|
||||
'There was a problem replacing your background, '
|
||||
'the image file "%s" no longer exists.')) % filename)
|
||||
|
||||
def onPreviewClick(self):
|
||||
MediaManagerItem.onPreviewClick(self)
|
||||
|
@ -30,7 +30,7 @@ import os
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.lib import MediaManagerItem, BaseListWithDnD, build_icon, \
|
||||
ItemCapabilities, SettingsManager, translate, check_item_selected
|
||||
ItemCapabilities, SettingsManager, translate, check_item_selected, Receiver
|
||||
from openlp.core.ui import criticalErrorMessageBox
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
@ -57,7 +57,9 @@ class MediaMediaItem(MediaManagerItem):
|
||||
u':/media/media_video.png').toImage()
|
||||
MediaManagerItem.__init__(self, parent, self, icon)
|
||||
self.singleServiceItem = False
|
||||
self.serviceItemIconName = u':/media/image_clapperboard.png'
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'video_background_replaced'),
|
||||
self.videobackgroundReplaced)
|
||||
|
||||
def retranslateUi(self):
|
||||
self.OnNewPrompt = translate('MediaPlugin.MediaItem', 'Select Media')
|
||||
@ -81,7 +83,6 @@ class MediaMediaItem(MediaManagerItem):
|
||||
|
||||
def addListViewToToolBar(self):
|
||||
MediaManagerItem.addListViewToToolBar(self)
|
||||
self.listView.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu)
|
||||
self.listView.addAction(self.replaceAction)
|
||||
|
||||
def addEndHeaderBar(self):
|
||||
@ -99,6 +100,12 @@ class MediaMediaItem(MediaManagerItem):
|
||||
self.resetAction.setVisible(False)
|
||||
self.parent.liveController.display.resetVideo()
|
||||
|
||||
def videobackgroundReplaced(self):
|
||||
"""
|
||||
Triggered by main display on change of serviceitem
|
||||
"""
|
||||
self.resetAction.setVisible(False)
|
||||
|
||||
def onReplaceClick(self):
|
||||
"""
|
||||
Called to replace Live backgound with the media selected.
|
||||
|
@ -171,11 +171,11 @@ class ImpressController(PresentationController):
|
||||
desktop = self.get_com_desktop()
|
||||
#Sometimes we get a failure and desktop is None
|
||||
if not desktop:
|
||||
log.exception(u'Failed to terminate OpenOffice')
|
||||
log.exception(u'Failed to find an OpenOffice desktop to terminate')
|
||||
return
|
||||
docs = desktop.getComponents()
|
||||
if docs.hasElements():
|
||||
log.debug(u'OpenOffice not terminated')
|
||||
log.debug(u'OpenOffice not terminated as docs are still open')
|
||||
else:
|
||||
try:
|
||||
desktop.terminate()
|
||||
|
@ -250,6 +250,7 @@ class PresentationMediaItem(MediaManagerItem):
|
||||
service_item.title = unicode(self.displayTypeComboBox.currentText())
|
||||
service_item.shortname = unicode(self.displayTypeComboBox.currentText())
|
||||
service_item.add_capability(ItemCapabilities.ProvidesOwnDisplay)
|
||||
service_item.add_capability(ItemCapabilities.AllowsDetailedTitleDisplay)
|
||||
shortname = service_item.shortname
|
||||
if shortname:
|
||||
for item in items:
|
||||
|
@ -116,7 +116,7 @@ class Controller(object):
|
||||
|
||||
def last(self):
|
||||
"""
|
||||
Based on the handler passed at startup triggers the first slide
|
||||
Based on the handler passed at startup triggers the last slide
|
||||
"""
|
||||
log.debug(u'Live = %s, last' % self.is_live)
|
||||
if not self.is_live:
|
||||
|
@ -26,7 +26,7 @@
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.lib import translate
|
||||
from openlp.core.lib import translate, save_cancel_button_box
|
||||
|
||||
class Ui_AuthorsDialog(object):
|
||||
def setupUi(self, authorsDialog):
|
||||
@ -55,17 +55,9 @@ class Ui_AuthorsDialog(object):
|
||||
self.displayLabel.setBuddy(self.displayEdit)
|
||||
self.authorLayout.addRow(self.displayLabel, self.displayEdit)
|
||||
self.dialogLayout.addLayout(self.authorLayout)
|
||||
self.buttonBox = QtGui.QDialogButtonBox(authorsDialog)
|
||||
self.buttonBox.setStandardButtons(
|
||||
QtGui.QDialogButtonBox.Save | QtGui.QDialogButtonBox.Cancel)
|
||||
self.buttonBox.setObjectName(u'buttonBox')
|
||||
self.dialogLayout.addWidget(self.buttonBox)
|
||||
self.dialogLayout.addWidget(save_cancel_button_box(authorsDialog))
|
||||
self.retranslateUi(authorsDialog)
|
||||
authorsDialog.setMaximumHeight(authorsDialog.sizeHint().height())
|
||||
QtCore.QObject.connect(self.buttonBox,
|
||||
QtCore.SIGNAL(u'accepted()'), authorsDialog.accept)
|
||||
QtCore.QObject.connect(self.buttonBox,
|
||||
QtCore.SIGNAL(u'rejected()'), authorsDialog.reject)
|
||||
QtCore.QMetaObject.connectSlotsByName(authorsDialog)
|
||||
|
||||
def retranslateUi(self, authorsDialog):
|
||||
|
@ -26,7 +26,7 @@
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.lib import build_icon, translate
|
||||
from openlp.core.lib import build_icon, translate, save_cancel_button_box
|
||||
|
||||
class Ui_EditSongDialog(object):
|
||||
def setupUi(self, editSongDialog):
|
||||
@ -264,16 +264,9 @@ class Ui_EditSongDialog(object):
|
||||
self.themeTabLayout.addWidget(self.commentsGroupBox)
|
||||
self.songTabWidget.addTab(self.themeTab, u'')
|
||||
self.dialogLayout.addWidget(self.songTabWidget)
|
||||
self.buttonBox = QtGui.QDialogButtonBox(editSongDialog)
|
||||
self.buttonBox.setStandardButtons(
|
||||
QtGui.QDialogButtonBox.Cancel | QtGui.QDialogButtonBox.Save)
|
||||
self.buttonBox.setObjectName(u'buttonBox')
|
||||
self.buttonBox = save_cancel_button_box(editSongDialog)
|
||||
self.dialogLayout.addWidget(self.buttonBox)
|
||||
self.retranslateUi(editSongDialog)
|
||||
QtCore.QObject.connect(self.buttonBox,
|
||||
QtCore.SIGNAL(u'rejected()'), editSongDialog.closePressed)
|
||||
QtCore.QObject.connect(self.buttonBox,
|
||||
QtCore.SIGNAL(u'accepted()'), editSongDialog.accept)
|
||||
QtCore.QMetaObject.connectSlotsByName(editSongDialog)
|
||||
|
||||
def retranslateUi(self, editSongDialog):
|
||||
|
@ -333,11 +333,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
||||
author = Author.populate(first_name=text.rsplit(u' ', 1)[0],
|
||||
last_name=text.rsplit(u' ', 1)[1], display_name=text)
|
||||
self.manager.save_object(author)
|
||||
author_item = QtGui.QListWidgetItem(
|
||||
unicode(author.display_name))
|
||||
author_item.setData(QtCore.Qt.UserRole,
|
||||
QtCore.QVariant(author.id))
|
||||
self.authorsListView.addItem(author_item)
|
||||
self.__addAuthorToList(author)
|
||||
self.loadAuthors()
|
||||
self.authorsComboBox.setCurrentIndex(0)
|
||||
else:
|
||||
@ -351,11 +347,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
||||
message=translate('SongsPlugin.EditSongForm',
|
||||
'This author is already in the list.'))
|
||||
else:
|
||||
author_item = QtGui.QListWidgetItem(unicode(
|
||||
author.display_name))
|
||||
author_item.setData(QtCore.Qt.UserRole,
|
||||
QtCore.QVariant(author.id))
|
||||
self.authorsListView.addItem(author_item)
|
||||
self.__addAuthorToList(author)
|
||||
self.authorsComboBox.setCurrentIndex(0)
|
||||
else:
|
||||
QtGui.QMessageBox.warning(self,
|
||||
@ -365,6 +357,14 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
||||
'or type in a new author and click the "Add Author to '
|
||||
'Song" button to add the new author.'))
|
||||
|
||||
def __addAuthorToList(self, author):
|
||||
"""
|
||||
Add an author to the author list.
|
||||
"""
|
||||
author_item = QtGui.QListWidgetItem(unicode(author.display_name))
|
||||
author_item.setData(QtCore.Qt.UserRole, QtCore.QVariant(author.id))
|
||||
self.authorsListView.addItem(author_item)
|
||||
|
||||
def onAuthorsListViewPressed(self):
|
||||
if self.authorsListView.count() > 1:
|
||||
self.authorRemoveButton.setEnabled(True)
|
||||
@ -648,29 +648,31 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
||||
"""
|
||||
Free up autocompletion memory on dialog exit
|
||||
"""
|
||||
log.debug (u'SongEditForm.clearCaches')
|
||||
self.authors = []
|
||||
self.themes = []
|
||||
self.books = []
|
||||
self.topics = []
|
||||
|
||||
def closePressed(self):
|
||||
def reject(self):
|
||||
"""
|
||||
Exit Dialog and do not save
|
||||
"""
|
||||
log.debug (u'SongEditForm.reject')
|
||||
Receiver.send_message(u'songs_edit_clear')
|
||||
self.clearCaches()
|
||||
self.close()
|
||||
QtGui.QDialog.reject(self)
|
||||
|
||||
def accept(self):
|
||||
"""
|
||||
Exit Dialog and save song if valid
|
||||
"""
|
||||
log.debug(u'accept')
|
||||
log.debug(u'SongEditForm.accept')
|
||||
self.clearCaches()
|
||||
if self._validate_song():
|
||||
self.saveSong()
|
||||
Receiver.send_message(u'songs_load_list')
|
||||
self.close()
|
||||
QtGui.QDialog.accept(self)
|
||||
|
||||
def saveSong(self, preview=False):
|
||||
"""
|
||||
|
@ -26,7 +26,8 @@
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.lib import build_icon, translate, SpellTextEdit
|
||||
from openlp.core.lib import build_icon, save_cancel_button_box, translate, \
|
||||
SpellTextEdit
|
||||
from openlp.plugins.songs.lib import VerseType
|
||||
|
||||
class Ui_EditVerseDialog(object):
|
||||
@ -59,17 +60,8 @@ class Ui_EditVerseDialog(object):
|
||||
self.verseTypeLayout.addWidget(self.insertButton)
|
||||
self.verseTypeLayout.addStretch()
|
||||
self.dialogLayout.addLayout(self.verseTypeLayout)
|
||||
self.buttonBox = QtGui.QDialogButtonBox(editVerseDialog)
|
||||
self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
|
||||
self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel |
|
||||
QtGui.QDialogButtonBox.Save)
|
||||
self.buttonBox.setObjectName(u'buttonBox')
|
||||
self.dialogLayout.addWidget(self.buttonBox)
|
||||
self.dialogLayout.addWidget(save_cancel_button_box(editVerseDialog))
|
||||
self.retranslateUi(editVerseDialog)
|
||||
QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(u'accepted()'),
|
||||
editVerseDialog.accept)
|
||||
QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(u'rejected()'),
|
||||
editVerseDialog.reject)
|
||||
QtCore.QMetaObject.connectSlotsByName(editVerseDialog)
|
||||
|
||||
def retranslateUi(self, editVerseDialog):
|
||||
|
@ -26,7 +26,7 @@
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.lib import translate
|
||||
from openlp.core.lib import translate, save_cancel_button_box
|
||||
|
||||
class Ui_SongBookDialog(object):
|
||||
def setupUi(self, songBookDialog):
|
||||
@ -49,17 +49,9 @@ class Ui_SongBookDialog(object):
|
||||
self.publisherLabel.setBuddy(self.publisherEdit)
|
||||
self.bookLayout.addRow(self.publisherLabel, self.publisherEdit)
|
||||
self.dialogLayout.addLayout(self.bookLayout)
|
||||
self.buttonBox = QtGui.QDialogButtonBox(songBookDialog)
|
||||
self.buttonBox.setStandardButtons(
|
||||
QtGui.QDialogButtonBox.Save | QtGui.QDialogButtonBox.Cancel)
|
||||
self.buttonBox.setObjectName(u'buttonBox')
|
||||
self.dialogLayout.addWidget(self.buttonBox)
|
||||
self.dialogLayout.addWidget(save_cancel_button_box(songBookDialog))
|
||||
self.retranslateUi(songBookDialog)
|
||||
songBookDialog.setMaximumHeight(songBookDialog.sizeHint().height())
|
||||
QtCore.QObject.connect(self.buttonBox,
|
||||
QtCore.SIGNAL(u'accepted()'), songBookDialog.accept)
|
||||
QtCore.QObject.connect(self.buttonBox,
|
||||
QtCore.SIGNAL(u'rejected()'), songBookDialog.reject)
|
||||
QtCore.QMetaObject.connectSlotsByName(songBookDialog)
|
||||
|
||||
def retranslateUi(self, songBookDialog):
|
||||
|
@ -94,8 +94,8 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog):
|
||||
self.typeListWidget.setFocus()
|
||||
return QtGui.QDialog.exec_(self)
|
||||
|
||||
def _getCurrentItemId(self, ListWidget):
|
||||
item = ListWidget.currentItem()
|
||||
def _getCurrentItemId(self, listWidget):
|
||||
item = listWidget.currentItem()
|
||||
if item:
|
||||
item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
|
||||
return item_id
|
||||
@ -278,117 +278,128 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog):
|
||||
|
||||
def onAuthorEditButtonClick(self):
|
||||
author_id = self._getCurrentItemId(self.authorsListWidget)
|
||||
if author_id != -1:
|
||||
author = self.manager.get_object(Author, author_id)
|
||||
self.authorform.setAutoDisplayName(False)
|
||||
self.authorform.firstNameEdit.setText(author.first_name)
|
||||
self.authorform.lastNameEdit.setText(author.last_name)
|
||||
self.authorform.displayEdit.setText(author.display_name)
|
||||
# Save the author's first and last name as well as the display name
|
||||
# for the case that they have to be restored.
|
||||
temp_first_name = author.first_name
|
||||
temp_last_name = author.last_name
|
||||
temp_display_name = author.display_name
|
||||
if self.authorform.exec_(False):
|
||||
author.first_name = unicode(
|
||||
self.authorform.firstNameEdit.text())
|
||||
author.last_name = unicode(self.authorform.lastNameEdit.text())
|
||||
author.display_name = unicode(
|
||||
self.authorform.displayEdit.text())
|
||||
if self.checkAuthor(author, True):
|
||||
if self.manager.save_object(author):
|
||||
self.resetAuthors()
|
||||
Receiver.send_message(u'songs_load_list')
|
||||
else:
|
||||
criticalErrorMessageBox(
|
||||
message=translate('SongsPlugin.SongMaintenanceForm',
|
||||
'Could not save your changes.'))
|
||||
elif criticalErrorMessageBox(message=unicode(translate(
|
||||
'SongsPlugin.SongMaintenanceForm', 'The author %s already '
|
||||
'exists. Would you like to make songs with author %s use '
|
||||
'the existing author %s?')) % (author.display_name,
|
||||
temp_display_name, author.display_name),
|
||||
parent=self, question=True) == QtGui.QMessageBox.Yes:
|
||||
self.mergeAuthors(author)
|
||||
if author_id == -1:
|
||||
return
|
||||
author = self.manager.get_object(Author, author_id)
|
||||
self.authorform.setAutoDisplayName(False)
|
||||
self.authorform.firstNameEdit.setText(author.first_name)
|
||||
self.authorform.lastNameEdit.setText(author.last_name)
|
||||
self.authorform.displayEdit.setText(author.display_name)
|
||||
# Save the author's first and last name as well as the display name
|
||||
# for the case that they have to be restored.
|
||||
temp_first_name = author.first_name
|
||||
temp_last_name = author.last_name
|
||||
temp_display_name = author.display_name
|
||||
if self.authorform.exec_(False):
|
||||
author.first_name = unicode(
|
||||
self.authorform.firstNameEdit.text())
|
||||
author.last_name = unicode(self.authorform.lastNameEdit.text())
|
||||
author.display_name = unicode(
|
||||
self.authorform.displayEdit.text())
|
||||
if self.checkAuthor(author, True):
|
||||
if self.manager.save_object(author):
|
||||
self.resetAuthors()
|
||||
Receiver.send_message(u'songs_load_list')
|
||||
else:
|
||||
# We restore the author's old first and last name as well as
|
||||
# his display name.
|
||||
author.first_name = temp_first_name
|
||||
author.last_name = temp_last_name
|
||||
author.display_name = temp_display_name
|
||||
criticalErrorMessageBox(
|
||||
message=translate('SongsPlugin.SongMaintenanceForm',
|
||||
'Could not save your modified author, because the '
|
||||
'author already exists.'))
|
||||
'Could not save your changes.'))
|
||||
elif criticalErrorMessageBox(message=unicode(translate(
|
||||
'SongsPlugin.SongMaintenanceForm', 'The author %s already '
|
||||
'exists. Would you like to make songs with author %s use '
|
||||
'the existing author %s?')) % (author.display_name,
|
||||
temp_display_name, author.display_name),
|
||||
parent=self, question=True) == QtGui.QMessageBox.Yes:
|
||||
self.__mergeObjects(author, self.mergeAuthors,
|
||||
self.resetAuthors)
|
||||
else:
|
||||
# We restore the author's old first and last name as well as
|
||||
# his display name.
|
||||
author.first_name = temp_first_name
|
||||
author.last_name = temp_last_name
|
||||
author.display_name = temp_display_name
|
||||
criticalErrorMessageBox(
|
||||
message=translate('SongsPlugin.SongMaintenanceForm',
|
||||
'Could not save your modified author, because the '
|
||||
'author already exists.'))
|
||||
|
||||
def onTopicEditButtonClick(self):
|
||||
topic_id = self._getCurrentItemId(self.topicsListWidget)
|
||||
if topic_id != -1:
|
||||
topic = self.manager.get_object(Topic, topic_id)
|
||||
self.topicform.nameEdit.setText(topic.name)
|
||||
# Save the topic's name for the case that he has to be restored.
|
||||
temp_name = topic.name
|
||||
if self.topicform.exec_(False):
|
||||
topic.name = unicode(self.topicform.nameEdit.text())
|
||||
if self.checkTopic(topic, True):
|
||||
if self.manager.save_object(topic):
|
||||
self.resetTopics()
|
||||
else:
|
||||
criticalErrorMessageBox(
|
||||
message=translate('SongsPlugin.SongMaintenanceForm',
|
||||
'Could not save your changes.'))
|
||||
elif criticalErrorMessageBox(
|
||||
message=unicode(translate('SongsPlugin.SongMaintenanceForm',
|
||||
'The topic %s already exists. Would you like to make songs '
|
||||
'with topic %s use the existing topic %s?')) % (topic.name,
|
||||
temp_name, topic.name),
|
||||
parent=self, question=True) == QtGui.QMessageBox.Yes:
|
||||
self.mergeTopics(topic)
|
||||
if topic_id == -1:
|
||||
return
|
||||
topic = self.manager.get_object(Topic, topic_id)
|
||||
self.topicform.nameEdit.setText(topic.name)
|
||||
# Save the topic's name for the case that he has to be restored.
|
||||
temp_name = topic.name
|
||||
if self.topicform.exec_(False):
|
||||
topic.name = unicode(self.topicform.nameEdit.text())
|
||||
if self.checkTopic(topic, True):
|
||||
if self.manager.save_object(topic):
|
||||
self.resetTopics()
|
||||
else:
|
||||
# We restore the topics's old name.
|
||||
topic.name = temp_name
|
||||
criticalErrorMessageBox(
|
||||
message=translate('SongsPlugin.SongMaintenanceForm',
|
||||
'Could not save your modified topic, because it '
|
||||
'already exists.'))
|
||||
'Could not save your changes.'))
|
||||
elif criticalErrorMessageBox(
|
||||
message=unicode(translate('SongsPlugin.SongMaintenanceForm',
|
||||
'The topic %s already exists. Would you like to make songs '
|
||||
'with topic %s use the existing topic %s?')) % (topic.name,
|
||||
temp_name, topic.name),
|
||||
parent=self, question=True) == QtGui.QMessageBox.Yes:
|
||||
self.__mergeObjects(topic, self.mergeTopics, self.resetTopics)
|
||||
else:
|
||||
# We restore the topics's old name.
|
||||
topic.name = temp_name
|
||||
criticalErrorMessageBox(
|
||||
message=translate('SongsPlugin.SongMaintenanceForm',
|
||||
'Could not save your modified topic, because it '
|
||||
'already exists.'))
|
||||
|
||||
def onBookEditButtonClick(self):
|
||||
book_id = self._getCurrentItemId(self.booksListWidget)
|
||||
if book_id != -1:
|
||||
book = self.manager.get_object(Book, book_id)
|
||||
if book.publisher is None:
|
||||
book.publisher = u''
|
||||
self.bookform.nameEdit.setText(book.name)
|
||||
self.bookform.publisherEdit.setText(book.publisher)
|
||||
# Save the book's name and publisher for the case that they have to
|
||||
# be restored.
|
||||
temp_name = book.name
|
||||
temp_publisher = book.publisher
|
||||
if self.bookform.exec_(False):
|
||||
book.name = unicode(self.bookform.nameEdit.text())
|
||||
book.publisher = unicode(self.bookform.publisherEdit.text())
|
||||
if self.checkBook(book, True):
|
||||
if self.manager.save_object(book):
|
||||
self.resetBooks()
|
||||
else:
|
||||
criticalErrorMessageBox(
|
||||
message=translate('SongsPlugin.SongMaintenanceForm',
|
||||
'Could not save your changes.'))
|
||||
elif criticalErrorMessageBox(
|
||||
message=unicode(translate('SongsPlugin.SongMaintenanceForm',
|
||||
'The book %s already exists. Would you like to make songs '
|
||||
'with book %s use the existing book %s?')) % (book.name,
|
||||
temp_name, book.name),
|
||||
parent=self, question=True) == QtGui.QMessageBox.Yes:
|
||||
self.mergeBooks(book)
|
||||
if book_id == -1:
|
||||
return
|
||||
book = self.manager.get_object(Book, book_id)
|
||||
if book.publisher is None:
|
||||
book.publisher = u''
|
||||
self.bookform.nameEdit.setText(book.name)
|
||||
self.bookform.publisherEdit.setText(book.publisher)
|
||||
# Save the book's name and publisher for the case that they have to
|
||||
# be restored.
|
||||
temp_name = book.name
|
||||
temp_publisher = book.publisher
|
||||
if self.bookform.exec_(False):
|
||||
book.name = unicode(self.bookform.nameEdit.text())
|
||||
book.publisher = unicode(self.bookform.publisherEdit.text())
|
||||
if self.checkBook(book, True):
|
||||
if self.manager.save_object(book):
|
||||
self.resetBooks()
|
||||
else:
|
||||
# We restore the book's old name and publisher.
|
||||
book.name = temp_name
|
||||
book.publisher = temp_publisher
|
||||
criticalErrorMessageBox(
|
||||
message=translate('SongsPlugin.SongMaintenanceForm',
|
||||
'Could not save your changes.'))
|
||||
elif criticalErrorMessageBox(
|
||||
message=unicode(translate('SongsPlugin.SongMaintenanceForm',
|
||||
'The book %s already exists. Would you like to make songs '
|
||||
'with book %s use the existing book %s?')) % (book.name,
|
||||
temp_name, book.name),
|
||||
parent=self, question=True) == QtGui.QMessageBox.Yes:
|
||||
self.__mergeObjects(book, self.mergeBooks, self.resetBooks)
|
||||
else:
|
||||
# We restore the book's old name and publisher.
|
||||
book.name = temp_name
|
||||
book.publisher = temp_publisher
|
||||
|
||||
def __mergeObjects(self, dbObject, merge, reset):
|
||||
"""
|
||||
Utility method to merge two objects to leave one in the database.
|
||||
"""
|
||||
Receiver.send_message(u'cursor_busy')
|
||||
Receiver.send_message(u'openlp_process_events')
|
||||
merge(dbObject)
|
||||
reset()
|
||||
Receiver.send_message(u'songs_load_list')
|
||||
Receiver.send_message(u'cursor_normal')
|
||||
|
||||
def mergeAuthors(self, old_author):
|
||||
"""
|
||||
@ -496,42 +507,32 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog):
|
||||
|
||||
def onAuthorsListRowChanged(self, row):
|
||||
"""
|
||||
Called when the *authorsListWidget* current's row has changed.
|
||||
|
||||
``row``
|
||||
The current row. If there is no current row, the value is -1
|
||||
Called when the *authorsListWidget*s current row has changed.
|
||||
"""
|
||||
if row == -1:
|
||||
self.authorsDeleteButton.setEnabled(False)
|
||||
self.authorsEditButton.setEnabled(False)
|
||||
else:
|
||||
self.authorsDeleteButton.setEnabled(True)
|
||||
self.authorsEditButton.setEnabled(True)
|
||||
self.__rowChange(row, self.authorsEditButton, self.authorsDeleteButton)
|
||||
|
||||
def onTopicsListRowChanged(self, row):
|
||||
"""
|
||||
Called when the *booksListWidget* current's row has changed.
|
||||
|
||||
``row``
|
||||
The current row. If there is no current row, the value is -1.
|
||||
Called when the *topicsListWidget*s current row has changed.
|
||||
"""
|
||||
if row == -1:
|
||||
self.topicsDeleteButton.setEnabled(False)
|
||||
self.topicsEditButton.setEnabled(False)
|
||||
else:
|
||||
self.topicsDeleteButton.setEnabled(True)
|
||||
self.topicsEditButton.setEnabled(True)
|
||||
self.__rowChange(row, self.topicsEditButton, self.topicsDeleteButton)
|
||||
|
||||
def onBooksListRowChanged(self, row):
|
||||
"""
|
||||
Called when the *booksListWidget* current's row has changed.
|
||||
Called when the *booksListWidget*s current row has changed.
|
||||
"""
|
||||
self.__rowChange(row, self.booksEditButton, self.booksDeleteButton)
|
||||
|
||||
def __rowChange(self, row, editButton, deleteButton):
|
||||
"""
|
||||
Utility method to toggle if buttons are enabled.
|
||||
|
||||
``row``
|
||||
The current row. If there is no current row, the value is -1.
|
||||
"""
|
||||
if row == -1:
|
||||
self.booksDeleteButton.setEnabled(False)
|
||||
self.booksEditButton.setEnabled(False)
|
||||
deleteButton.setEnabled(False)
|
||||
editButton.setEnabled(False)
|
||||
else:
|
||||
self.booksDeleteButton.setEnabled(True)
|
||||
self.booksEditButton.setEnabled(True)
|
||||
deleteButton.setEnabled(True)
|
||||
editButton.setEnabled(True)
|
||||
|
@ -26,7 +26,7 @@
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.lib import translate
|
||||
from openlp.core.lib import translate, save_cancel_button_box
|
||||
|
||||
class Ui_TopicsDialog(object):
|
||||
def setupUi(self, topicsDialog):
|
||||
@ -43,17 +43,9 @@ class Ui_TopicsDialog(object):
|
||||
self.nameLabel.setBuddy(self.nameEdit)
|
||||
self.nameLayout.addRow(self.nameLabel, self.nameEdit)
|
||||
self.dialogLayout.addLayout(self.nameLayout)
|
||||
self.buttonBox = QtGui.QDialogButtonBox(topicsDialog)
|
||||
self.buttonBox.setStandardButtons(
|
||||
QtGui.QDialogButtonBox.Save | QtGui.QDialogButtonBox.Cancel)
|
||||
self.buttonBox.setObjectName(u'buttonBox')
|
||||
self.dialogLayout.addWidget(self.buttonBox)
|
||||
self.dialogLayout.addWidget(save_cancel_button_box(topicsDialog))
|
||||
self.retranslateUi(topicsDialog)
|
||||
topicsDialog.setMaximumHeight(topicsDialog.sizeHint().height())
|
||||
QtCore.QObject.connect(self.buttonBox,
|
||||
QtCore.SIGNAL(u'accepted()'), topicsDialog.accept)
|
||||
QtCore.QObject.connect(self.buttonBox,
|
||||
QtCore.SIGNAL(u'rejected()'), topicsDialog.reject)
|
||||
QtCore.QMetaObject.connectSlotsByName(topicsDialog)
|
||||
|
||||
def retranslateUi(self, topicsDialog):
|
||||
|
@ -133,29 +133,37 @@ class EasiSlidesImport(SongImport):
|
||||
pass
|
||||
|
||||
def _add_copyright(self, song):
|
||||
copyright = []
|
||||
"""
|
||||
Assign the copyright information from the import to the song being
|
||||
created.
|
||||
|
||||
``song``
|
||||
The current song being imported.
|
||||
"""
|
||||
copyright_list = []
|
||||
self.__add_copyright_element(copyright_list, song.Copyright)
|
||||
self.__add_copyright_element(copyright_list, song.LicenceAdmin1)
|
||||
self.__add_copyright_element(copyright_list, song.LicenceAdmin2)
|
||||
self.add_copyright(u' '.join(copyright_list))
|
||||
|
||||
def __add_copyright_element(self, copyright_list, element):
|
||||
"""
|
||||
Add a piece of copyright to the total copyright information for the
|
||||
song.
|
||||
|
||||
``copyright_list``
|
||||
The array to add the information to.
|
||||
|
||||
``element``
|
||||
The imported variable to get the data from.
|
||||
"""
|
||||
try:
|
||||
copyright.append(unicode(song.Copyright).strip())
|
||||
copyright_list.append(unicode(element).strip())
|
||||
except UnicodeDecodeError:
|
||||
log.exception(u'Unicode decode error while decoding Copyright')
|
||||
log.exception(u'Unicode error decoding %s' % element)
|
||||
self._success = False
|
||||
except AttributeError:
|
||||
pass
|
||||
try:
|
||||
copyright.append(unicode(song.LicenceAdmin1).strip())
|
||||
except UnicodeDecodeError:
|
||||
log.exception(u'Unicode decode error while decoding LicenceAdmin1')
|
||||
self._success = False
|
||||
except AttributeError:
|
||||
pass
|
||||
try:
|
||||
copyright.append(unicode(song.LicenceAdmin2).strip())
|
||||
except UnicodeDecodeError:
|
||||
log.exception(u'Unicode decode error while decoding LicenceAdmin2')
|
||||
self._success = False
|
||||
except AttributeError:
|
||||
pass
|
||||
self.add_copyright(u' '.join(copyright))
|
||||
|
||||
def _parse_and_add_lyrics(self, song):
|
||||
try:
|
||||
@ -314,11 +322,11 @@ class EasiSlidesImport(SongImport):
|
||||
pass
|
||||
|
||||
def _listHas(self, lst, subitems):
|
||||
for i in subitems:
|
||||
if type(lst) == type({}) and lst.has_key(i):
|
||||
lst = lst[i]
|
||||
elif type(lst) == type([]) and i in lst:
|
||||
lst = lst[i]
|
||||
for subitem in subitems:
|
||||
if isinstance(lst, dict) and lst.has_key(subitem):
|
||||
lst = lst[subitem]
|
||||
elif isinstance(lst, list) and subitem in lst:
|
||||
lst = lst[subitem]
|
||||
else:
|
||||
return False
|
||||
return True
|
||||
|
@ -105,7 +105,7 @@ class SongFormat(object):
|
||||
return None
|
||||
|
||||
@staticmethod
|
||||
def list():
|
||||
def get_formats_list():
|
||||
"""
|
||||
Return a list of the supported song formats.
|
||||
"""
|
||||
|
@ -68,9 +68,6 @@ class SongMediaItem(MediaManagerItem):
|
||||
self.editItem = None
|
||||
self.whitespace = re.compile(r'\W+', re.UNICODE)
|
||||
|
||||
def requiredIcons(self):
|
||||
MediaManagerItem.requiredIcons(self)
|
||||
|
||||
def addEndHeaderBar(self):
|
||||
self.addToolbarSeparator()
|
||||
## Song Maintenance Button ##
|
||||
@ -340,16 +337,7 @@ class SongMediaItem(MediaManagerItem):
|
||||
author_list = u''
|
||||
author_audit = []
|
||||
ccli = u''
|
||||
if item is None:
|
||||
if self.remoteTriggered is None:
|
||||
item = self.listView.currentItem()
|
||||
if item is None:
|
||||
return False
|
||||
item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
|
||||
else:
|
||||
item_id = self.remoteSong
|
||||
else:
|
||||
item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
|
||||
item_id = self._getIdOfItemToGenerate(item, self.remoteSong)
|
||||
service_item.add_capability(ItemCapabilities.AllowsEdit)
|
||||
service_item.add_capability(ItemCapabilities.AllowsPreview)
|
||||
service_item.add_capability(ItemCapabilities.AllowsLoop)
|
||||
|
@ -66,31 +66,34 @@ class OooImport(SongImport):
|
||||
QtCore.SIGNAL(u'openlp_stop_wizard'), self.stop_import)
|
||||
|
||||
def do_import(self):
|
||||
self.abort = False
|
||||
self.stop_import_flag = False
|
||||
self.import_wizard.progressBar.setMaximum(0)
|
||||
self.start_ooo()
|
||||
for filename in self.filenames:
|
||||
if self.abort:
|
||||
if self.stop_import_flag:
|
||||
self.import_wizard.incrementProgressBar(u'Import cancelled', 0)
|
||||
return
|
||||
filename = unicode(filename)
|
||||
if os.path.isfile(filename):
|
||||
self.open_ooo_file(filename)
|
||||
if self.document:
|
||||
if self.document.supportsService(
|
||||
"com.sun.star.presentation.PresentationDocument"):
|
||||
self.process_pres()
|
||||
if self.document.supportsService(
|
||||
"com.sun.star.text.TextDocument"):
|
||||
self.process_doc()
|
||||
self.process_ooo_document()
|
||||
self.close_ooo_file()
|
||||
self.close_ooo()
|
||||
self.import_wizard.progressBar.setMaximum(1)
|
||||
self.import_wizard.incrementProgressBar(u'', 1)
|
||||
return True
|
||||
|
||||
def stop_import(self):
|
||||
self.abort = True
|
||||
def process_ooo_document(self):
|
||||
"""
|
||||
Handle the import process for OpenOffice files. This method facilitates
|
||||
allowing subclasses to handle specific types of OpenOffice files.
|
||||
"""
|
||||
if self.document.supportsService(
|
||||
"com.sun.star.presentation.PresentationDocument"):
|
||||
self.process_pres()
|
||||
if self.document.supportsService("com.sun.star.text.TextDocument"):
|
||||
self.process_doc()
|
||||
|
||||
def start_ooo(self):
|
||||
"""
|
||||
@ -180,7 +183,7 @@ class OooImport(SongImport):
|
||||
slides = doc.getDrawPages()
|
||||
text = u''
|
||||
for slide_no in range(slides.getCount()):
|
||||
if self.abort:
|
||||
if self.stop_import_flag:
|
||||
self.import_wizard.incrementProgressBar(u'Import cancelled', 0)
|
||||
return
|
||||
slide = slides.getByIndex(slide_no)
|
||||
|
@ -39,9 +39,7 @@ from oooimport import OooImport
|
||||
if os.name == u'nt':
|
||||
BOLD = 150.0
|
||||
ITALIC = 2
|
||||
PAGE_BEFORE = 4
|
||||
PAGE_AFTER = 5
|
||||
PAGE_BOTH = 6
|
||||
from oooimport import PAGE_BEFORE, PAGE_AFTER, PAGE_BOTH
|
||||
else:
|
||||
try:
|
||||
from com.sun.star.awt.FontWeight import BOLD
|
||||
@ -75,23 +73,11 @@ class SofImport(OooImport):
|
||||
"""
|
||||
OooImport.__init__(self, master_manager, **kwargs)
|
||||
|
||||
def do_import(self):
|
||||
self.abort = False
|
||||
self.start_ooo()
|
||||
for filename in self.filenames:
|
||||
if self.abort:
|
||||
self.import_wizard.incrementProgressBar(u'Import cancelled', 0)
|
||||
return
|
||||
filename = unicode(filename)
|
||||
if os.path.isfile(filename):
|
||||
self.open_ooo_file(filename)
|
||||
if self.document:
|
||||
self.process_sof_file()
|
||||
self.close_ooo_file()
|
||||
self.close_ooo()
|
||||
self.import_wizard.progressBar.setMaximum(1)
|
||||
self.import_wizard.incrementProgressBar(u'', 1)
|
||||
return True
|
||||
def process_ooo_document(self):
|
||||
"""
|
||||
Handle the import process for SoF files.
|
||||
"""
|
||||
self.process_sof_file()
|
||||
|
||||
def process_sof_file(self):
|
||||
"""
|
||||
@ -101,7 +87,7 @@ class SofImport(OooImport):
|
||||
self.new_song()
|
||||
paragraphs = self.document.getText().createEnumeration()
|
||||
while paragraphs.hasMoreElements():
|
||||
if self.abort:
|
||||
if self.stop_import_flag:
|
||||
self.import_wizard.incrementProgressBar(u'Import cancelled', 0)
|
||||
return
|
||||
paragraph = paragraphs.nextElement()
|
||||
@ -318,7 +304,6 @@ class SofImport(OooImport):
|
||||
self.currentverse = u''
|
||||
self.is_chorus = False
|
||||
|
||||
|
||||
def uncap_text(self, text):
|
||||
"""
|
||||
Words in the title are in all capitals, so we lowercase them.
|
||||
|
@ -227,7 +227,7 @@ class SongImport(QtCore.QObject):
|
||||
self.versecounts[versetag[0]] = int(versetag[1:])
|
||||
self.verses.append([versetag, versetext.rstrip(), lang])
|
||||
self.verse_order_list.append(versetag)
|
||||
if versetag.startswith(u'V') and self.contains_verse(u'C1'):
|
||||
if versetag.startswith(u'V') and u'C1' in self.verse_order_list:
|
||||
self.verse_order_list.append(u'C1')
|
||||
|
||||
def repeat_verse(self):
|
||||
@ -236,9 +236,6 @@ class SongImport(QtCore.QObject):
|
||||
"""
|
||||
self.verse_order_list.append(self.verse_order_list[-1])
|
||||
|
||||
def contains_verse(self, versetag):
|
||||
return versetag in self.verse_order_list
|
||||
|
||||
def check_complete(self):
|
||||
"""
|
||||
Check the mandatory fields are entered (i.e. title and a verse)
|
||||
|
@ -26,7 +26,7 @@
|
||||
|
||||
from PyQt4 import QtGui
|
||||
|
||||
from openlp.core.lib import translate
|
||||
from openlp.core.lib import translate, Receiver
|
||||
from openlp.plugins.songusage.lib.db import SongUsageItem
|
||||
from songusagedeletedialog import Ui_SongUsageDeleteDialog
|
||||
|
||||
@ -55,4 +55,9 @@ class SongUsageDeleteForm(QtGui.QDialog, Ui_SongUsageDeleteDialog):
|
||||
deleteDate = self.deleteCalendar.selectedDate().toPyDate()
|
||||
self.manager.delete_all_objects(SongUsageItem,
|
||||
SongUsageItem.usagedate <= deleteDate)
|
||||
self.close()
|
||||
Receiver.send_message(u'openlp_information_message', {
|
||||
u'title': translate('SongUsagePlugin.SongUsageDeleteForm',
|
||||
'Deletion Successful'),
|
||||
u'message': translate('SongUsagePlugin.SongUsageDeleteForm',
|
||||
'All requested data has been deleted successfully. ')})
|
||||
self.close()
|
||||
|
@ -60,10 +60,12 @@ class Ui_SongUsageDetailDialog(object):
|
||||
self.horizontalLayout.setObjectName(u'horizontalLayout')
|
||||
self.fileLineEdit = QtGui.QLineEdit(self.fileGroupBox)
|
||||
self.fileLineEdit.setObjectName(u'fileLineEdit')
|
||||
self.fileLineEdit.setReadOnly(True)
|
||||
self.fileLineEdit.setEnabled(False)
|
||||
self.horizontalLayout.addWidget(self.fileLineEdit)
|
||||
self.saveFilePushButton = QtGui.QPushButton(self.fileGroupBox)
|
||||
self.saveFilePushButton.setIcon(
|
||||
build_icon(u':/general/general_load.png'))
|
||||
build_icon(u':/general/general_open.png'))
|
||||
self.saveFilePushButton.setObjectName(u'saveFilePushButton')
|
||||
self.horizontalLayout.addWidget(self.saveFilePushButton)
|
||||
self.verticalLayout4.addLayout(self.horizontalLayout)
|
||||
@ -96,4 +98,4 @@ class Ui_SongUsageDetailDialog(object):
|
||||
translate('SongUsagePlugin.SongUsageDetailForm', 'to'))
|
||||
self.fileGroupBox.setTitle(
|
||||
translate('SongUsagePlugin.SongUsageDetailForm',
|
||||
'Report Location'))
|
||||
'Report Location'))
|
||||
|
@ -30,7 +30,8 @@ import os
|
||||
from PyQt4 import QtCore, QtGui
|
||||
from sqlalchemy.sql import and_
|
||||
|
||||
from openlp.core.lib import SettingsManager, translate
|
||||
from openlp.core.lib import SettingsManager, translate, Receiver, \
|
||||
check_directory_exists
|
||||
from openlp.plugins.songusage.lib.db import SongUsageItem
|
||||
from songusagedetaildialog import Ui_SongUsageDetailDialog
|
||||
|
||||
@ -51,49 +52,74 @@ class SongUsageDetailForm(QtGui.QDialog, Ui_SongUsageDetailDialog):
|
||||
self.setupUi(self)
|
||||
|
||||
def initialise(self):
|
||||
"""
|
||||
We need to set up the screen
|
||||
"""
|
||||
year = QtCore.QDate().currentDate().year()
|
||||
if QtCore.QDate().currentDate().month() < 9:
|
||||
year -= 1
|
||||
toDate = QtCore.QDate(year, 8, 31)
|
||||
fromDate = QtCore.QDate(year - 1, 9, 1)
|
||||
toDate = QtCore.QSettings().value(
|
||||
u'songusage/to date',
|
||||
QtCore.QVariant(QtCore.QDate(year, 8, 31))).toDate()
|
||||
fromDate = QtCore.QSettings().value(
|
||||
u'songusage/from date',
|
||||
QtCore.QVariant(QtCore.QDate(year - 1, 9, 1))).toDate()
|
||||
self.fromDate.setSelectedDate(fromDate)
|
||||
self.toDate.setSelectedDate(toDate)
|
||||
self.fileLineEdit.setText(
|
||||
SettingsManager.get_last_dir(self.plugin.settingsSection, 1))
|
||||
|
||||
def defineOutputLocation(self):
|
||||
"""
|
||||
Triggered when the Directory selection button is pressed
|
||||
"""
|
||||
path = QtGui.QFileDialog.getExistingDirectory(self,
|
||||
translate('SongUsagePlugin.SongUsageDetailForm',
|
||||
'Output File Location'),
|
||||
SettingsManager.get_last_dir(self.plugin.settingsSection, 1))
|
||||
path = unicode(path)
|
||||
if path != u'':
|
||||
if path:
|
||||
SettingsManager.set_last_dir(self.plugin.settingsSection, path, 1)
|
||||
self.fileLineEdit.setText(path)
|
||||
|
||||
def accept(self):
|
||||
log.debug(u'Detailed report generated')
|
||||
"""
|
||||
Ok was pressed so lets save the data and run the report
|
||||
"""
|
||||
log.debug(u'accept')
|
||||
path = unicode(self.fileLineEdit.text())
|
||||
check_directory_exists(path)
|
||||
filename = unicode(translate('SongUsagePlugin.SongUsageDetailForm',
|
||||
'usage_detail_%s_%s.txt')) % (
|
||||
self.fromDate.selectedDate().toString(u'ddMMyyyy'),
|
||||
self.toDate.selectedDate().toString(u'ddMMyyyy'))
|
||||
QtCore.QSettings().setValue(u'songusage/from date',
|
||||
QtCore.QVariant(self.fromDate.selectedDate()))
|
||||
QtCore.QSettings().setValue(u'songusage/to date',
|
||||
QtCore.QVariant(self.toDate.selectedDate()))
|
||||
usage = self.plugin.manager.get_all_objects(
|
||||
SongUsageItem, and_(
|
||||
SongUsageItem.usagedate >= self.fromDate.selectedDate().toPyDate(),
|
||||
SongUsageItem.usagedate < self.toDate.selectedDate().toPyDate()),
|
||||
[SongUsageItem.usagedate, SongUsageItem.usagetime])
|
||||
outname = os.path.join(unicode(self.fileLineEdit.text()), filename)
|
||||
file = None
|
||||
outname = os.path.join(path, filename)
|
||||
fileHandle = None
|
||||
try:
|
||||
file = open(outname, u'w')
|
||||
fileHandle = open(outname, u'w')
|
||||
for instance in usage:
|
||||
record = u'\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\"\n' % (
|
||||
instance.usagedate, instance.usagetime, instance.title,
|
||||
instance.copyright, instance.ccl_number, instance.authors)
|
||||
file.write(record)
|
||||
fileHandle.write(record.encode(u'utf-8'))
|
||||
Receiver.send_message(u'openlp_information_message', {
|
||||
u'title': translate('SongUsagePlugin.SongUsageDetailForm',
|
||||
'Report Creation'),
|
||||
u'message': unicode(translate(
|
||||
'SongUsagePlugin.SongUsageDetailForm', 'Report \n%s \n'
|
||||
'has been successfully created. ')) % outname})
|
||||
except IOError:
|
||||
log.exception(u'Failed to write out song usage records')
|
||||
finally:
|
||||
if file:
|
||||
file.close()
|
||||
if fileHandle:
|
||||
fileHandle.close()
|
||||
self.close()
|
||||
|
Loading…
Reference in New Issue
Block a user