This commit is contained in:
Andreas Preikschat 2011-01-27 17:01:19 +01:00
commit f27d90ea9e
23 changed files with 181 additions and 166 deletions

View File

@ -194,7 +194,10 @@ class OpenLP(QtGui.QApplication):
# now kill the splashscreen # now kill the splashscreen
self.splash.finish(self.mainWindow) self.splash.finish(self.mainWindow)
self.mainWindow.repaint() 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_() return self.exec_()
def hookException(self, exctype, value, traceback): def hookException(self, exctype, value, traceback):
@ -280,4 +283,4 @@ if __name__ == u'__main__':
""" """
Instantiate and run the application. Instantiate and run the application.
""" """
main() main()

View File

@ -314,7 +314,7 @@ body {
</html> </html>
""" """
def build_html(item, screen, alert, islive): def build_html(item, screen, alert, islive, background):
""" """
Build the full web paged structure for display Build the full web paged structure for display
@ -332,7 +332,9 @@ def build_html(item, screen, alert, islive):
theme = item.themedata theme = item.themedata
webkitvers = webkit_version() webkitvers = webkit_version()
# Image generated and poked in # 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 image = u'src="data:image/png;base64,%s"' % item.bg_image_bytes
else: else:
image = u'style="display:none;"' image = u'style="display:none;"'

View File

@ -98,13 +98,9 @@ class MediaManagerItem(QtGui.QWidget):
visible_title = self.plugin.getString(StringContent.VisibleName) visible_title = self.plugin.getString(StringContent.VisibleName)
self.title = unicode(visible_title[u'title']) self.title = unicode(visible_title[u'title'])
self.settingsSection = self.plugin.name.lower() self.settingsSection = self.plugin.name.lower()
if isinstance(icon, QtGui.QIcon): self.icon = None
self.icon = icon if icon:
elif isinstance(icon, basestring): self.icon = build_icon(icon)
self.icon.addPixmap(QtGui.QPixmap.fromImage(QtGui.QImage(icon)),
QtGui.QIcon.Normal, QtGui.QIcon.Off)
else:
self.icon = None
self.toolbar = None self.toolbar = None
self.remoteTriggered = None self.remoteTriggered = None
self.serviceItemIconName = None self.serviceItemIconName = None

View File

@ -47,13 +47,16 @@ class SpellTextEdit(QtGui.QPlainTextEdit):
# Default dictionary based on the current locale. # Default dictionary based on the current locale.
if ENCHANT_AVAILABLE: if ENCHANT_AVAILABLE:
try: try:
self.dict = enchant.Dict() self.dictionary = enchant.Dict()
except DictNotFoundError: except DictNotFoundError:
self.dict = enchant.Dict(u'en_US') self.dictionary = enchant.Dict(u'en_US')
self.highlighter = Highlighter(self.document()) self.highlighter = Highlighter(self.document())
self.highlighter.setDict(self.dict) self.highlighter.spellingDictionary = self.dictionary
def mousePressEvent(self, event): def mousePressEvent(self, event):
"""
Handle mouse clicks within the text edit region.
"""
if event.button() == QtCore.Qt.RightButton: if event.button() == QtCore.Qt.RightButton:
# Rewrite the mouse event to a left button event so the cursor is # Rewrite the mouse event to a left button event so the cursor is
# moved to the location of the pointer. # moved to the location of the pointer.
@ -63,6 +66,9 @@ class SpellTextEdit(QtGui.QPlainTextEdit):
QtGui.QPlainTextEdit.mousePressEvent(self, event) QtGui.QPlainTextEdit.mousePressEvent(self, event)
def contextMenuEvent(self, event): def contextMenuEvent(self, event):
"""
Provide the context menu for the text edit region.
"""
popupMenu = self.createStandardContextMenu() popupMenu = self.createStandardContextMenu()
# Select the word under the cursor. # Select the word under the cursor.
cursor = self.textCursor() cursor = self.textCursor()
@ -74,10 +80,10 @@ class SpellTextEdit(QtGui.QPlainTextEdit):
# suggestions if it is. # suggestions if it is.
if ENCHANT_AVAILABLE and self.textCursor().hasSelection(): if ENCHANT_AVAILABLE and self.textCursor().hasSelection():
text = unicode(self.textCursor().selectedText()) text = unicode(self.textCursor().selectedText())
if not self.dict.check(text): if not self.dictionary.check(text):
spell_menu = QtGui.QMenu(translate('OpenLP.SpellTextEdit', spell_menu = QtGui.QMenu(translate('OpenLP.SpellTextEdit',
'Spelling Suggestions')) 'Spelling Suggestions'))
for word in self.dict.suggest(text): for word in self.dictionary.suggest(text):
action = SpellAction(word, spell_menu) action = SpellAction(word, spell_menu)
action.correct.connect(self.correctWord) action.correct.connect(self.correctWord)
spell_menu.addAction(action) spell_menu.addAction(action)
@ -126,28 +132,32 @@ class SpellTextEdit(QtGui.QPlainTextEdit):
cursor.insertText(html[u'start tag']) cursor.insertText(html[u'start tag'])
cursor.insertText(html[u'end 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\']+' WORDS = u'(?iu)[\w\']+'
def __init__(self, *args): def __init__(self, *args):
QtGui.QSyntaxHighlighter.__init__(self, *args) QtGui.QSyntaxHighlighter.__init__(self, *args)
self.dict = None self.spellingDictionary = None
def setDict(self, dict):
self.dict = dict
def highlightBlock(self, text): def highlightBlock(self, text):
if not self.dict: """
Highlight misspelt words in a block of text
"""
if not self.spellingDictionary:
return return
text = unicode(text) text = unicode(text)
format = QtGui.QTextCharFormat() charFormat = QtGui.QTextCharFormat()
format.setUnderlineColor(QtCore.Qt.red) charFormat.setUnderlineColor(QtCore.Qt.red)
format.setUnderlineStyle(QtGui.QTextCharFormat.SpellCheckUnderline) charFormat.setUnderlineStyle(QtGui.QTextCharFormat.SpellCheckUnderline)
for word_object in re.finditer(self.WORDS, text): 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(), self.setFormat(word_object.start(),
word_object.end() - word_object.start(), format) word_object.end() - word_object.start(), charFormat)
class SpellAction(QtGui.QAction): class SpellAction(QtGui.QAction):
""" """

View File

@ -113,6 +113,9 @@ class GeneralTab(SettingsTab):
self.showSplashCheckBox = QtGui.QCheckBox(self.startupGroupBox) self.showSplashCheckBox = QtGui.QCheckBox(self.startupGroupBox)
self.showSplashCheckBox.setObjectName(u'showSplashCheckBox') self.showSplashCheckBox.setObjectName(u'showSplashCheckBox')
self.startupLayout.addWidget(self.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.leftLayout.addWidget(self.startupGroupBox)
self.settingsGroupBox = QtGui.QGroupBox(self.leftColumn) self.settingsGroupBox = QtGui.QGroupBox(self.leftColumn)
self.settingsGroupBox.setObjectName(u'settingsGroupBox') self.settingsGroupBox.setObjectName(u'settingsGroupBox')
@ -249,6 +252,8 @@ class GeneralTab(SettingsTab):
'Automatically open the last service')) 'Automatically open the last service'))
self.showSplashCheckBox.setText( self.showSplashCheckBox.setText(
translate('OpenLP.GeneralTab', 'Show the splash screen')) translate('OpenLP.GeneralTab', 'Show the splash screen'))
self.checkForUpdatesCheckBox.setText(
translate('OpenLP.GeneralTab', 'Check for updates to OpenLP'))
self.settingsGroupBox.setTitle( self.settingsGroupBox.setTitle(
translate('OpenLP.GeneralTab', 'Application Settings')) translate('OpenLP.GeneralTab', 'Application Settings'))
self.saveCheckServiceCheckBox.setText(translate('OpenLP.GeneralTab', self.saveCheckServiceCheckBox.setText(translate('OpenLP.GeneralTab',
@ -317,6 +322,8 @@ class GeneralTab(SettingsTab):
QtCore.QVariant(False)).toBool()) QtCore.QVariant(False)).toBool())
self.showSplashCheckBox.setChecked(settings.value(u'show splash', self.showSplashCheckBox.setChecked(settings.value(u'show splash',
QtCore.QVariant(True)).toBool()) QtCore.QVariant(True)).toBool())
self.checkForUpdatesCheckBox.setChecked(settings.value(u'update check',
QtCore.QVariant(True)).toBool())
self.autoPreviewCheckBox.setChecked(settings.value(u'auto preview', self.autoPreviewCheckBox.setChecked(settings.value(u'auto preview',
QtCore.QVariant(False)).toBool()) QtCore.QVariant(False)).toBool())
self.timeoutSpinBox.setValue(settings.value(u'loop delay', self.timeoutSpinBox.setValue(settings.value(u'loop delay',
@ -363,6 +370,8 @@ class GeneralTab(SettingsTab):
QtCore.QVariant(self.autoOpenCheckBox.isChecked())) QtCore.QVariant(self.autoOpenCheckBox.isChecked()))
settings.setValue(u'show splash', settings.setValue(u'show splash',
QtCore.QVariant(self.showSplashCheckBox.isChecked())) QtCore.QVariant(self.showSplashCheckBox.isChecked()))
settings.setValue(u'update check',
QtCore.QVariant(self.checkForUpdatesCheckBox.isChecked()))
settings.setValue(u'save prompt', settings.setValue(u'save prompt',
QtCore.QVariant(self.saveCheckServiceCheckBox.isChecked())) QtCore.QVariant(self.saveCheckServiceCheckBox.isChecked()))
settings.setValue(u'auto preview', settings.setValue(u'auto preview',

View File

@ -67,6 +67,7 @@ class MainDisplay(DisplayWidget):
self.isLive = live self.isLive = live
self.alertTab = None self.alertTab = None
self.hideMode = None self.hideMode = None
self.override = {}
mainIcon = build_icon(u':/icon/openlp-logo-16x16.png') mainIcon = build_icon(u':/icon/openlp-logo-16x16.png')
self.setWindowIcon(mainIcon) self.setWindowIcon(mainIcon)
self.retranslateUi() self.retranslateUi()
@ -111,7 +112,7 @@ class MainDisplay(DisplayWidget):
self.page = self.webView.page() self.page = self.webView.page()
self.frame = self.page.mainFrame() self.frame = self.page.mainFrame()
QtCore.QObject.connect(self.webView, 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.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
self.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) self.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
self.frame.setScrollBarPolicy(QtCore.Qt.Vertical, self.frame.setScrollBarPolicy(QtCore.Qt.Vertical,
@ -137,14 +138,14 @@ class MainDisplay(DisplayWidget):
painter_image.begin(initialFrame) painter_image.begin(initialFrame)
painter_image.fillRect(initialFrame.rect(), QtCore.Qt.white) painter_image.fillRect(initialFrame.rect(), QtCore.Qt.white)
painter_image.drawImage( painter_image.drawImage(
(self.screens.current[u'size'].width() - (self.screens.current[u'size'].width() -
splash_image.width()) / 2, splash_image.width()) / 2,
(self.screens.current[u'size'].height() (self.screens.current[u'size'].height()
- splash_image.height()) / 2, splash_image) - splash_image.height()) / 2, splash_image)
serviceItem = ServiceItem() serviceItem = ServiceItem()
serviceItem.bg_image_bytes = image_to_byte(initialFrame) serviceItem.bg_image_bytes = image_to_byte(initialFrame)
self.webView.setHtml(build_html(serviceItem, self.screen, self.webView.setHtml(build_html(serviceItem, self.screen,
self.parent.alertTab, self.isLive)) self.parent.alertTab, self.isLive, None))
self.initialFrame = True self.initialFrame = True
# To display or not to display? # To display or not to display?
if not self.screen[u'primary']: if not self.screen[u'primary']:
@ -162,7 +163,7 @@ class MainDisplay(DisplayWidget):
""" """
log.debug(u'text to display') log.debug(u'text to display')
# Wait for the webview to update before displaying text. # Wait for the webview to update before displaying text.
while not self.loaded: while not self.webLoaded:
Receiver.send_message(u'openlp_process_events') Receiver.send_message(u'openlp_process_events')
self.frame.evaluateJavaScript(u'show_text("%s")' % \ self.frame.evaluateJavaScript(u'show_text("%s")' % \
slide.replace(u'\\', u'\\\\').replace(u'\"', u'\\\"')) slide.replace(u'\\', u'\\\\').replace(u'\"', u'\\\"'))
@ -204,14 +205,17 @@ class MainDisplay(DisplayWidget):
""" """
self.imageManager.add_image(name, path) self.imageManager.add_image(name, path)
self.image(name) 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): def image(self, name):
""" """
Add an image as the background. The image is converted to a bytestream Add an image as the background. The image has already been added
on route. to the cache.
`Image` `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') log.debug(u'image to display')
image = self.imageManager.get_image_bytes(name) image = self.imageManager.get_image_bytes(name)
@ -244,6 +248,7 @@ class MainDisplay(DisplayWidget):
self.displayImage(self.serviceItem.bg_image_bytes) self.displayImage(self.serviceItem.bg_image_bytes)
else: else:
self.displayImage(None) self.displayImage(None)
self.override = {}
# Update the preview frame. # Update the preview frame.
Receiver.send_message(u'maindisplay_active') Receiver.send_message(u'maindisplay_active')
@ -260,6 +265,7 @@ class MainDisplay(DisplayWidget):
self.phononActive = False self.phononActive = False
else: else:
self.frame.evaluateJavaScript(u'show_video("close");') self.frame.evaluateJavaScript(u'show_video("close");')
self.override = {}
# Update the preview frame. # Update the preview frame.
Receiver.send_message(u'maindisplay_active') 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 Loads and starts a video to run with the option of sound
""" """
log.debug(u'video') 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) vol = float(volume)/float(10)
if isBackground or not self.usePhonon: if isBackground or not self.usePhonon:
js = u'show_video("init", "%s", %s, true); show_video("play");' % \ js = u'show_video("init", "%s", %s, true); show_video("play");' % \
@ -333,12 +342,12 @@ class MainDisplay(DisplayWidget):
Receiver.send_message(u'maindisplay_active') Receiver.send_message(u'maindisplay_active')
return self.preview() return self.preview()
def isLoaded(self): def isWebLoaded(self):
""" """
Called by webView event to show display is fully loaded Called by webView event to show display is fully loaded
""" """
log.debug(u'loaded') log.debug(u'Webloaded')
self.loaded = True self.webLoaded = True
def preview(self): def preview(self):
""" """
@ -357,7 +366,7 @@ class MainDisplay(DisplayWidget):
Receiver.send_message(u'openlp_process_events') Receiver.send_message(u'openlp_process_events')
# Wait for the webview to update before geting the preview. # Wait for the webview to update before geting the preview.
# Important otherwise first preview will miss the background ! # Important otherwise first preview will miss the background !
while not self.loaded: while not self.webLoaded:
Receiver.send_message(u'openlp_process_events') Receiver.send_message(u'openlp_process_events')
# if was hidden keep it hidden # if was hidden keep it hidden
if self.isLive: if self.isLive:
@ -379,18 +388,32 @@ class MainDisplay(DisplayWidget):
HTML to the display HTML to the display
""" """
log.debug(u'buildHtml') log.debug(u'buildHtml')
self.loaded = False self.webLoaded = False
self.initialFrame = False self.initialFrame = False
self.serviceItem = serviceItem 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: if self.serviceItem.themedata.background_filename:
self.serviceItem.bg_image_bytes = self.imageManager. \ self.serviceItem.bg_image_bytes = self.imageManager. \
get_image_bytes(self.serviceItem.themedata.theme_name) get_image_bytes(self.serviceItem.themedata.theme_name)
html = build_html(self.serviceItem, self.screen, self.parent.alertTab, html = build_html(self.serviceItem, self.screen, self.parent.alertTab,
self.isLive) self.isLive, background)
log.debug(u'buildHtml - pre setHtml') log.debug(u'buildHtml - pre setHtml')
self.webView.setHtml(html) self.webView.setHtml(html)
log.debug(u'buildHtml - post setHtml') log.debug(u'buildHtml - post setHtml')
if serviceItem.foot_text and serviceItem.foot_text: if serviceItem.foot_text:
self.footer(serviceItem.foot_text) self.footer(serviceItem.foot_text)
# if was hidden keep it hidden # if was hidden keep it hidden
if self.hideMode and self.isLive: if self.hideMode and self.isLive:

View File

@ -563,10 +563,10 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
self.ServiceManagerContents.onLoadServiceClicked) self.ServiceManagerContents.onLoadServiceClicked)
QtCore.QObject.connect(self.FileSaveItem, QtCore.QObject.connect(self.FileSaveItem,
QtCore.SIGNAL(u'triggered()'), QtCore.SIGNAL(u'triggered()'),
self.ServiceManagerContents.onSaveServiceClicked) self.ServiceManagerContents.saveFile)
QtCore.QObject.connect(self.FileSaveAsItem, QtCore.QObject.connect(self.FileSaveAsItem,
QtCore.SIGNAL(u'triggered()'), QtCore.SIGNAL(u'triggered()'),
self.ServiceManagerContents.onSaveServiceAsClicked) self.ServiceManagerContents.saveFileAs)
# i18n set signals for languages # i18n set signals for languages
QtCore.QObject.connect(self.AutoLanguageItem, QtCore.QObject.connect(self.AutoLanguageItem,
QtCore.SIGNAL(u'toggled(bool)'), self.setAutoLanguage) QtCore.SIGNAL(u'toggled(bool)'), self.setAutoLanguage)
@ -807,15 +807,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
Hook to close the main window and display windows on exit Hook to close the main window and display windows on exit
""" """
if self.ServiceManagerContents.isModified(): if self.ServiceManagerContents.isModified():
ret = QtGui.QMessageBox.question(self, ret = self.ServiceManagerContents.saveModifiedService()
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)
if ret == QtGui.QMessageBox.Save: if ret == QtGui.QMessageBox.Save:
if self.ServiceManagerContents.saveFile(): if self.ServiceManagerContents.saveFile():
self.cleanUp() self.cleanUp()
@ -847,7 +839,6 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
self.cleanUp() self.cleanUp()
event.accept() event.accept()
def cleanUp(self): def cleanUp(self):
""" """
Runs all the cleanup code before OpenLP shuts down Runs all the cleanup code before OpenLP shuts down

View File

@ -108,7 +108,7 @@ class ServiceManager(QtGui.QWidget):
translate('OpenLP.ServiceManager', 'Save Service'), translate('OpenLP.ServiceManager', 'Save Service'),
u':/general/general_save.png', u':/general/general_save.png',
translate('OpenLP.ServiceManager', 'Save this service'), translate('OpenLP.ServiceManager', 'Save this service'),
self.onSaveServiceClicked) self.saveFile)
self.toolbar.addSeparator() self.toolbar.addSeparator()
self.themeLabel = QtGui.QLabel(translate('OpenLP.ServiceManager', self.themeLabel = QtGui.QLabel(translate('OpenLP.ServiceManager',
'Theme:'), self) 'Theme:'), self)
@ -361,12 +361,7 @@ class ServiceManager(QtGui.QWidget):
Create a new service. Create a new service.
""" """
if self.isModified(): if self.isModified():
result = QtGui.QMessageBox.question(self.mainwindow, result = self.saveModifiedService()
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)
if result == QtGui.QMessageBox.Cancel: if result == QtGui.QMessageBox.Cancel:
return False return False
elif result == QtGui.QMessageBox.Save: elif result == QtGui.QMessageBox.Save:
@ -376,12 +371,7 @@ class ServiceManager(QtGui.QWidget):
def onLoadServiceClicked(self): def onLoadServiceClicked(self):
if self.isModified(): if self.isModified():
result = QtGui.QMessageBox.question(self.mainwindow, result = self.saveModifiedService()
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)
if result == QtGui.QMessageBox.Cancel: if result == QtGui.QMessageBox.Cancel:
return False return False
elif result == QtGui.QMessageBox.Save: elif result == QtGui.QMessageBox.Save:
@ -397,11 +387,13 @@ class ServiceManager(QtGui.QWidget):
split_filename(fileName)[0]) split_filename(fileName)[0])
self.loadFile(fileName) self.loadFile(fileName)
def onSaveServiceClicked(self): def saveModifiedService(self):
self.saveFile() return QtGui.QMessageBox.question(self.mainwindow,
translate('OpenLP.ServiceManager', 'Modified Service'),
def onSaveServiceAsClicked(self): translate('OpenLP.ServiceManager', 'The current service has '
self.saveFileAs() 'been modified. Would you like to save this service?'),
QtGui.QMessageBox.Save | QtGui.QMessageBox.Discard |
QtGui.QMessageBox.Cancel, QtGui.QMessageBox.Save)
def onRecentServiceClicked(self): def onRecentServiceClicked(self):
sender = self.sender() sender = self.sender()

View File

@ -55,7 +55,6 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard):
self.thememanager = parent self.thememanager = parent
self.setupUi(self) self.setupUi(self)
self.registerFields() self.registerFields()
self.accepted = False
self.updateThemeAllowed = True self.updateThemeAllowed = True
QtCore.QObject.connect(self.backgroundComboBox, QtCore.QObject.connect(self.backgroundComboBox,
QtCore.SIGNAL(u'currentIndexChanged(int)'), QtCore.SIGNAL(u'currentIndexChanged(int)'),
@ -120,14 +119,12 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard):
QtCore.QObject.connect(self.mainFontComboBox, QtCore.QObject.connect(self.mainFontComboBox,
QtCore.SIGNAL(u'activated(int)'), QtCore.SIGNAL(u'activated(int)'),
self.calculateLines) self.calculateLines)
QtCore.QObject.connect(self, QtCore.SIGNAL(u'accepted()'), self.accept)
def setDefaults(self): def setDefaults(self):
""" """
Set up display at start of theme edit. Set up display at start of theme edit.
""" """
self.restart() self.restart()
self.accepted = False
self.setBackgroundPageValues() self.setBackgroundPageValues()
self.setMainAreaPageValues() self.setMainAreaPageValues()
self.setFooterAreaPageValues() self.setFooterAreaPageValues()
@ -250,25 +247,27 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard):
""" """
Change state as Outline check box changed Change state as Outline check box changed
""" """
if state == QtCore.Qt.Checked: if self.updateThemeAllowed:
self.theme.font_main_outline = True if state == QtCore.Qt.Checked:
else: self.theme.font_main_outline = True
self.theme.font_main_outline = False else:
self.outlineColorButton.setEnabled(self.theme.font_main_outline) self.theme.font_main_outline = False
self.outlineSizeSpinBox.setEnabled(self.theme.font_main_outline) self.outlineColorButton.setEnabled(self.theme.font_main_outline)
self.calculateLines() self.outlineSizeSpinBox.setEnabled(self.theme.font_main_outline)
self.calculateLines()
def onShadowCheckCheckBoxStateChanged(self, state): def onShadowCheckCheckBoxStateChanged(self, state):
""" """
Change state as Shadow check box changed Change state as Shadow check box changed
""" """
if state == QtCore.Qt.Checked: if self.updateThemeAllowed:
self.theme.font_main_shadow = True if state == QtCore.Qt.Checked:
else: self.theme.font_main_shadow = True
self.theme.font_main_shadow = False else:
self.shadowColorButton.setEnabled(self.theme.font_main_shadow) self.theme.font_main_shadow = False
self.shadowSizeSpinBox.setEnabled(self.theme.font_main_shadow) self.shadowColorButton.setEnabled(self.theme.font_main_shadow)
self.calculateLines() self.shadowSizeSpinBox.setEnabled(self.theme.font_main_shadow)
self.calculateLines()
def onMainPositionCheckBoxStateChanged(self, value): def onMainPositionCheckBoxStateChanged(self, value):
""" """
@ -446,9 +445,10 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard):
""" """
Background gradient Combo box has changed. Background gradient Combo box has changed.
""" """
self.theme.background_direction = \ if self.updateThemeAllowed:
BackgroundGradientType.to_string(index) self.theme.background_direction = \
self.setBackgroundPageValues() BackgroundGradientType.to_string(index)
self.setBackgroundPageValues()
def onColorButtonClicked(self): def onColorButtonClicked(self):
""" """
@ -560,13 +560,8 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard):
""" """
Lets save the them as Finish has been pressed 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 # Save the theme name
self.theme.theme_name = \ self.theme.theme_name = unicode(self.field(u'name').toString())
unicode(self.field(u'name').toString())
if not self.theme.theme_name: if not self.theme.theme_name:
criticalErrorMessageBox( criticalErrorMessageBox(
translate('OpenLP.ThemeForm', 'Theme Name Missing'), translate('OpenLP.ThemeForm', 'Theme Name Missing'),
@ -590,7 +585,6 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard):
if not self.edit_mode and \ if not self.edit_mode and \
not self.thememanager.checkIfThemeExists(self.theme.theme_name): not self.thememanager.checkIfThemeExists(self.theme.theme_name):
return return
self.accepted = True
self.thememanager.saveTheme(self.theme, saveFrom, saveTo) self.thememanager.saveTheme(self.theme, saveFrom, saveTo)
return QtGui.QDialog.accept(self) return QtGui.QDialog.accept(self)

View File

@ -137,10 +137,7 @@ class AppLocation(object):
os.path.split(openlp.__file__)[0]) os.path.split(openlp.__file__)[0])
return os.path.join(app_path, u'i18n') return os.path.join(app_path, u'i18n')
else: else:
return _get_os_dir_path(u'openlp', return _get_os_dir_path(dir_type)
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)
@staticmethod @staticmethod
def get_data_path(): def get_data_path():
@ -163,17 +160,18 @@ class AppLocation(object):
os.makedirs(path) os.makedirs(path)
return path return path
def _get_os_dir_path(win_option, darwin_option, base_dir_option, def _get_os_dir_path(dir_type):
non_base_dir_option, dir_type=1):
""" """
Return a path based on which OS and environment we are running in. Return a path based on which OS and environment we are running in.
""" """
if sys.platform == u'win32': 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': elif sys.platform == u'darwin':
if dir_type == AppLocation.DataDir: if dir_type == AppLocation.DataDir:
return os.path.join(darwin_option, u'Data') return os.path.join(os.getenv(u'HOME'), u'Library',
return darwin_option u'Application Support', u'openlp', u'Data')
return os.path.join(os.getenv(u'HOME'), u'Library',
u'Application Support', u'openlp')
else: else:
if XDG_BASE_AVAILABLE: if XDG_BASE_AVAILABLE:
if dir_type == AppLocation.ConfigDir: 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: elif dir_type == AppLocation.CacheDir:
return os.path.join(BaseDirectory.xdg_cache_home, u'openlp') return os.path.join(BaseDirectory.xdg_cache_home, u'openlp')
else: 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): def _get_frozen_path(frozen_option, non_frozen_option):
""" """

View File

@ -45,15 +45,14 @@ class AlertsPlugin(Plugin):
self.icon = build_icon(u':/plugins/plugin_alerts.png') self.icon = build_icon(u':/plugins/plugin_alerts.png')
self.alertsmanager = AlertsManager(self) self.alertsmanager = AlertsManager(self)
self.manager = Manager(u'alerts', init_schema) self.manager = Manager(u'alerts', init_schema)
visible_name = self.getString(StringContent.VisibleName) self.visible_name = self.getString(StringContent.VisibleName)
self.alertForm = AlertForm(self, visible_name[u'title']) self.alertForm = AlertForm(self)
def getSettingsTab(self): def getSettingsTab(self):
""" """
Return the settings tab for the Alerts plugin Return the settings tab for the Alerts plugin
""" """
visible_name = self.getString(StringContent.VisibleName) self.alertsTab = AlertsTab(self, self.visible_name[u'title'])
self.alertsTab = AlertsTab(self, visible_name[u'title'])
return self.alertsTab return self.alertsTab
def addToolsMenuItem(self, tools_menu): def addToolsMenuItem(self, tools_menu):

View File

@ -35,7 +35,7 @@ class AlertForm(QtGui.QDialog, Ui_AlertDialog):
""" """
Provide UI for the alert system Provide UI for the alert system
""" """
def __init__(self, plugin, visible_title): def __init__(self, plugin):
""" """
Initialise the alert form Initialise the alert form
""" """

View File

@ -92,7 +92,7 @@ class BibleFormat(object):
return None return None
@staticmethod @staticmethod
def list(): def get_formats_list():
""" """
Return a list of the supported Bible formats. Return a list of the supported Bible formats.
""" """

View File

@ -19,7 +19,7 @@ IBS-fordítás (Új Károli), KAR
King James Version, KJV King James Version, KJV
Luther 1984, LUT Luther 1984, LUT
Septuaginta, LXX Septuaginta, LXX
Neue Genfer Übersetzung, NGÜ Neue Genfer Übersetzung, NGU
New International Readers Version, NIRV New International Readers Version, NIRV
New International Version, NIV New International Version, NIV
Neues Leben, NL Neues Leben, NL

1 عربي ARA
19 King James Version KJV
20 Luther 1984 LUT
21 Septuaginta LXX
22 Neue Genfer Übersetzung NGÜ NGU
23 New International Readers Version NIRV
24 New International Version NIV
25 Neues Leben NL

View File

@ -68,9 +68,6 @@ class CustomMediaItem(MediaManagerItem):
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'custom_preview'), self.onPreviewClick) QtCore.SIGNAL(u'custom_preview'), self.onPreviewClick)
def requiredIcons(self):
MediaManagerItem.requiredIcons(self)
def initialise(self): def initialise(self):
self.loadCustomListView(self.manager.get_all_objects( self.loadCustomListView(self.manager.get_all_objects(
CustomSlide, order_by_ref=CustomSlide.title)) CustomSlide, order_by_ref=CustomSlide.title))
@ -182,4 +179,4 @@ class CustomMediaItem(MediaManagerItem):
else: else:
raw_footer.append(u'') raw_footer.append(u'')
service_item.raw_footer = raw_footer service_item.raw_footer = raw_footer
return True return True

View File

@ -31,7 +31,7 @@ from PyQt4 import QtCore, QtGui
from openlp.core.lib import MediaManagerItem, BaseListWithDnD, build_icon, \ from openlp.core.lib import MediaManagerItem, BaseListWithDnD, build_icon, \
ItemCapabilities, SettingsManager, translate, check_item_selected, \ ItemCapabilities, SettingsManager, translate, check_item_selected, \
check_directory_exists check_directory_exists, Receiver
from openlp.core.ui import criticalErrorMessageBox from openlp.core.ui import criticalErrorMessageBox
from openlp.core.utils import AppLocation, delete_file, get_images_filter from openlp.core.utils import AppLocation, delete_file, get_images_filter
@ -44,7 +44,6 @@ class ImageListView(BaseListWithDnD):
self.PluginName = u'Images' self.PluginName = u'Images'
BaseListWithDnD.__init__(self, parent) BaseListWithDnD.__init__(self, parent)
class ImageMediaItem(MediaManagerItem): class ImageMediaItem(MediaManagerItem):
""" """
This is the custom media manager item for images. This is the custom media manager item for images.
@ -57,6 +56,8 @@ class ImageMediaItem(MediaManagerItem):
# be instanced by the base MediaManagerItem. # be instanced by the base MediaManagerItem.
self.ListViewWithDnD_class = ImageListView self.ListViewWithDnD_class = ImageListView
MediaManagerItem.__init__(self, parent, self, icon) MediaManagerItem.__init__(self, parent, self, icon)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'live_theme_changed'), self.liveThemeChanged)
def retranslateUi(self): def retranslateUi(self):
self.OnNewPrompt = translate('ImagePlugin.MediaItem', self.OnNewPrompt = translate('ImagePlugin.MediaItem',
@ -193,6 +194,12 @@ class ImageMediaItem(MediaManagerItem):
self.resetAction.setVisible(False) self.resetAction.setVisible(False)
self.parent.liveController.display.resetImage() 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): def onReplaceClick(self):
""" """
Called to replace Live backgound with the image selected. Called to replace Live backgound with the image selected.
@ -213,6 +220,3 @@ class ImageMediaItem(MediaManagerItem):
unicode(translate('ImagePlugin.MediaItem', unicode(translate('ImagePlugin.MediaItem',
'There was a problem replacing your background, ' 'There was a problem replacing your background, '
'the image file "%s" no longer exists.')) % filename) 'the image file "%s" no longer exists.')) % filename)
def onPreviewClick(self):
MediaManagerItem.onPreviewClick(self)

View File

@ -30,7 +30,7 @@ import os
from PyQt4 import QtCore, QtGui from PyQt4 import QtCore, QtGui
from openlp.core.lib import MediaManagerItem, BaseListWithDnD, build_icon, \ 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 from openlp.core.ui import criticalErrorMessageBox
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
@ -58,6 +58,9 @@ class MediaMediaItem(MediaManagerItem):
MediaManagerItem.__init__(self, parent, self, icon) MediaManagerItem.__init__(self, parent, self, icon)
self.singleServiceItem = False self.singleServiceItem = False
self.serviceItemIconName = u':/media/image_clapperboard.png' self.serviceItemIconName = u':/media/image_clapperboard.png'
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'video_background_replaced'),
self.videobackgroundReplaced)
def retranslateUi(self): def retranslateUi(self):
self.OnNewPrompt = translate('MediaPlugin.MediaItem', 'Select Media') self.OnNewPrompt = translate('MediaPlugin.MediaItem', 'Select Media')
@ -99,6 +102,12 @@ class MediaMediaItem(MediaManagerItem):
self.resetAction.setVisible(False) self.resetAction.setVisible(False)
self.parent.liveController.display.resetVideo() self.parent.liveController.display.resetVideo()
def videobackgroundReplaced(self):
"""
Triggered by main display on change of serviceitem
"""
self.resetAction.setVisible(False)
def onReplaceClick(self): def onReplaceClick(self):
""" """
Called to replace Live backgound with the media selected. Called to replace Live backgound with the media selected.

View File

@ -171,11 +171,11 @@ class ImpressController(PresentationController):
desktop = self.get_com_desktop() desktop = self.get_com_desktop()
#Sometimes we get a failure and desktop is None #Sometimes we get a failure and desktop is None
if not desktop: if not desktop:
log.exception(u'Failed to terminate OpenOffice') log.exception(u'Failed to find an OpenOffice desktop to terminate')
return return
docs = desktop.getComponents() docs = desktop.getComponents()
if docs.hasElements(): if docs.hasElements():
log.debug(u'OpenOffice not terminated') log.debug(u'OpenOffice not terminated as docs are still open')
else: else:
try: try:
desktop.terminate() desktop.terminate()

View File

@ -314,11 +314,11 @@ class EasiSlidesImport(SongImport):
pass pass
def _listHas(self, lst, subitems): def _listHas(self, lst, subitems):
for i in subitems: for subitem in subitems:
if type(lst) == type({}) and lst.has_key(i): if isinstance(lst, dict) and lst.has_key(subitem):
lst = lst[i] lst = lst[subitem]
elif type(lst) == type([]) and i in lst: elif isinstance(lst, list) and subitem in lst:
lst = lst[i] lst = lst[subitem]
else: else:
return False return False
return True return True

View File

@ -105,7 +105,7 @@ class SongFormat(object):
return None return None
@staticmethod @staticmethod
def list(): def get_formats_list():
""" """
Return a list of the supported song formats. Return a list of the supported song formats.
""" """

View File

@ -68,9 +68,6 @@ class SongMediaItem(MediaManagerItem):
self.editItem = None self.editItem = None
self.whitespace = re.compile(r'\W+', re.UNICODE) self.whitespace = re.compile(r'\W+', re.UNICODE)
def requiredIcons(self):
MediaManagerItem.requiredIcons(self)
def addEndHeaderBar(self): def addEndHeaderBar(self):
self.addToolbarSeparator() self.addToolbarSeparator()
## Song Maintenance Button ## ## Song Maintenance Button ##

View File

@ -66,31 +66,34 @@ class OooImport(SongImport):
QtCore.SIGNAL(u'openlp_stop_wizard'), self.stop_import) QtCore.SIGNAL(u'openlp_stop_wizard'), self.stop_import)
def do_import(self): def do_import(self):
self.abort = False self.stop_import_flag = False
self.import_wizard.progressBar.setMaximum(0) self.import_wizard.progressBar.setMaximum(0)
self.start_ooo() self.start_ooo()
for filename in self.filenames: for filename in self.filenames:
if self.abort: if self.stop_import_flag:
self.import_wizard.incrementProgressBar(u'Import cancelled', 0) self.import_wizard.incrementProgressBar(u'Import cancelled', 0)
return return
filename = unicode(filename) filename = unicode(filename)
if os.path.isfile(filename): if os.path.isfile(filename):
self.open_ooo_file(filename) self.open_ooo_file(filename)
if self.document: if self.document:
if self.document.supportsService( self.process_ooo_document()
"com.sun.star.presentation.PresentationDocument"):
self.process_pres()
if self.document.supportsService(
"com.sun.star.text.TextDocument"):
self.process_doc()
self.close_ooo_file() self.close_ooo_file()
self.close_ooo() self.close_ooo()
self.import_wizard.progressBar.setMaximum(1) self.import_wizard.progressBar.setMaximum(1)
self.import_wizard.incrementProgressBar(u'', 1) self.import_wizard.incrementProgressBar(u'', 1)
return True return True
def stop_import(self): def process_ooo_document(self):
self.abort = True """
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): def start_ooo(self):
""" """
@ -180,7 +183,7 @@ class OooImport(SongImport):
slides = doc.getDrawPages() slides = doc.getDrawPages()
text = u'' text = u''
for slide_no in range(slides.getCount()): for slide_no in range(slides.getCount()):
if self.abort: if self.stop_import_flag:
self.import_wizard.incrementProgressBar(u'Import cancelled', 0) self.import_wizard.incrementProgressBar(u'Import cancelled', 0)
return return
slide = slides.getByIndex(slide_no) slide = slides.getByIndex(slide_no)

View File

@ -75,23 +75,11 @@ class SofImport(OooImport):
""" """
OooImport.__init__(self, master_manager, **kwargs) OooImport.__init__(self, master_manager, **kwargs)
def do_import(self): def process_ooo_document(self):
self.abort = False """
self.start_ooo() Handle the import process for SoF files.
for filename in self.filenames: """
if self.abort: self.process_sof_file()
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_sof_file(self): def process_sof_file(self):
""" """
@ -101,7 +89,7 @@ class SofImport(OooImport):
self.new_song() self.new_song()
paragraphs = self.document.getText().createEnumeration() paragraphs = self.document.getText().createEnumeration()
while paragraphs.hasMoreElements(): while paragraphs.hasMoreElements():
if self.abort: if self.stop_import_flag:
self.import_wizard.incrementProgressBar(u'Import cancelled', 0) self.import_wizard.incrementProgressBar(u'Import cancelled', 0)
return return
paragraph = paragraphs.nextElement() paragraph = paragraphs.nextElement()