This commit is contained in:
rimach 2011-11-02 21:39:18 +01:00
commit 1c35195f6a
9 changed files with 87 additions and 37 deletions

View File

@ -52,6 +52,24 @@ class HideMode(object):
Theme = 2 Theme = 2
Screen = 3 Screen = 3
class AlertLocation(object):
"""
This is an enumeration class which controls where Alerts are placed on the
screen.
``Top``
Place the text at the top of the screen.
``Middle``
Place the text in the middle of the screen.
``Bottom``
Place the text at the bottom of the screen.
"""
Top = 0
Middle = 1
Bottom = 2
from firsttimeform import FirstTimeForm from firsttimeform import FirstTimeForm
from firsttimelanguageform import FirstTimeLanguageForm from firsttimelanguageform import FirstTimeLanguageForm
from themelayoutform import ThemeLayoutForm from themelayoutform import ThemeLayoutForm

View File

@ -37,7 +37,7 @@ from PyQt4.phonon import Phonon
from openlp.core.lib import Receiver, build_html, ServiceItem, image_to_byte, \ from openlp.core.lib import Receiver, build_html, ServiceItem, image_to_byte, \
translate, PluginManager translate, PluginManager
from openlp.core.ui import HideMode, ScreenList from openlp.core.ui import HideMode, ScreenList, AlertLocation
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
@ -53,7 +53,7 @@ class Display(QtGui.QGraphicsView):
def __init__(self, parent, live, controller): def __init__(self, parent, live, controller):
if live: if live:
QtGui.QGraphicsView.__init__(self) QtGui.QGraphicsView.__init__(self)
# Do not overwrite the parent() method. # Overwrite the parent() method.
self.parent = lambda: parent self.parent = lambda: parent
else: else:
QtGui.QGraphicsView.__init__(self, parent) QtGui.QGraphicsView.__init__(self, parent)
@ -191,7 +191,7 @@ class MainDisplay(Display):
serviceItem = ServiceItem() serviceItem = ServiceItem()
serviceItem.bg_image_bytes = image_to_byte(self.initialFrame) serviceItem.bg_image_bytes = image_to_byte(self.initialFrame)
self.webView.setHtml(build_html(serviceItem, self.screen, self.webView.setHtml(build_html(serviceItem, self.screen,
self.isLive, None)) self.isLive, None, plugins=self.plugins))
self.__hideMouse() self.__hideMouse()
# To display or not to display? # To display or not to display?
if not self.screen[u'primary']: if not self.screen[u'primary']:
@ -215,7 +215,7 @@ class MainDisplay(Display):
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'\\\"'))
def alert(self, text): def alert(self, text, location):
""" """
Display an alert. Display an alert.
@ -239,10 +239,10 @@ class MainDisplay(Display):
alert_height = int(height.toString()) alert_height = int(height.toString())
self.resize(self.width(), alert_height) self.resize(self.width(), alert_height)
self.setVisible(True) self.setVisible(True)
if self.alertTab.location == 1: if location == AlertLocation.Middle:
self.move(self.screen[u'size'].left(), self.move(self.screen[u'size'].left(),
(self.screen[u'size'].height() - alert_height) / 2) (self.screen[u'size'].height() - alert_height) / 2)
elif self.alertTab.location == 2: elif location == AlertLocation.Bottom:
self.move(self.screen[u'size'].left(), self.move(self.screen[u'size'].left(),
self.screen[u'size'].height() - alert_height) self.screen[u'size'].height() - alert_height)
else: else:

View File

@ -71,11 +71,24 @@ JAVASCRIPT = """
function update_css(align, font, size, color, bgcolor){ function update_css(align, font, size, color, bgcolor){
var text = document.getElementById('alert'); var text = document.getElementById('alert');
text.style.verticalAlign = align;
text.style.fontSize = size + "pt"; text.style.fontSize = size + "pt";
text.style.fontFamily = font; text.style.fontFamily = font;
text.style.color = color; text.style.color = color;
text.style.backgroundColor = bgcolor; text.style.backgroundColor = bgcolor;
switch(align)
{
case 'top':
text.style.top = '0px';
break;
case 'middle':
text.style.top = ((window.innerHeight - text.clientHeight) / 2)
+ 'px';
break;
case 'bottom':
text.style.top = (window.innerHeight - text.clientHeight)
+ 'px';
break;
}
} }
""" """
CSS = """ CSS = """

View File

@ -85,7 +85,7 @@ class AlertsManager(QtCore.QObject):
return return
text = self.alertList.pop(0) text = self.alertList.pop(0)
alertTab = self.parent().settings_tab alertTab = self.parent().settings_tab
self.parent().liveController.display.alert(text) self.parent().liveController.display.alert(text, alertTab.location)
# Check to see if we have a timer running. # Check to see if we have a timer running.
if self.timer_id == 0: if self.timer_id == 0:
self.timer_id = self.startTimer(int(alertTab.timeout) * 1000) self.timer_id = self.startTimer(int(alertTab.timeout) * 1000)
@ -100,7 +100,8 @@ class AlertsManager(QtCore.QObject):
""" """
log.debug(u'timer event') log.debug(u'timer event')
if event.timerId() == self.timer_id: if event.timerId() == self.timer_id:
self.parent().liveController.display.alert(u'') alertTab = self.parent().settings_tab
self.parent().liveController.display.alert(u'', alertTab.location)
self.killTimer(self.timer_id) self.killTimer(self.timer_id)
self.timer_id = 0 self.timer_id = 0
self.generateAlert() self.generateAlert()

View File

@ -28,6 +28,7 @@
from PyQt4 import QtCore, QtGui from PyQt4 import QtCore, QtGui
from openlp.core.lib import SettingsTab, translate, Receiver from openlp.core.lib import SettingsTab, translate, Receiver
from openlp.core.ui import AlertLocation
from openlp.core.lib.ui import UiStrings, create_valign_combo from openlp.core.lib.ui import UiStrings, create_valign_combo
class AlertsTab(SettingsTab): class AlertsTab(SettingsTab):
@ -159,7 +160,7 @@ class AlertsTab(SettingsTab):
self.font_face = unicode(settings.value( self.font_face = unicode(settings.value(
u'font face', QtCore.QVariant(QtGui.QFont().family())).toString()) u'font face', QtCore.QVariant(QtGui.QFont().family())).toString())
self.location = settings.value( self.location = settings.value(
u'location', QtCore.QVariant(1)).toInt()[0] u'location', QtCore.QVariant(AlertLocation.Bottom)).toInt()[0]
settings.endGroup() settings.endGroup()
self.fontSizeSpinBox.setValue(self.font_size) self.fontSizeSpinBox.setValue(self.font_size)
self.timeoutSpinBox.setValue(self.timeout) self.timeoutSpinBox.setValue(self.timeout)

View File

@ -419,8 +419,7 @@ class SongMediaItem(MediaManagerItem):
item_id = (self.editItem.data(QtCore.Qt.UserRole)).toInt()[0] item_id = (self.editItem.data(QtCore.Qt.UserRole)).toInt()[0]
old_song = self.plugin.manager.get_object(Song, item_id) old_song = self.plugin.manager.get_object(Song, item_id)
song_xml = self.openLyrics.song_to_xml(old_song) song_xml = self.openLyrics.song_to_xml(old_song)
new_song_id = self.openLyrics.xml_to_song(song_xml) new_song = self.openLyrics.xml_to_song(song_xml)
new_song = self.plugin.manager.get_object(Song, new_song_id)
new_song.title = u'%s <%s>' % (new_song.title, new_song.title = u'%s <%s>' % (new_song.title,
translate('SongsPlugin.MediaItem', 'copy', translate('SongsPlugin.MediaItem', 'copy',
'For song cloning')) 'For song cloning'))

View File

@ -78,30 +78,35 @@ class OpenLP1SongImport(SongImport):
connection = sqlite.connect(self.importSource, mode=0444, connection = sqlite.connect(self.importSource, mode=0444,
encoding=(encoding, 'replace')) encoding=(encoding, 'replace'))
cursor = connection.cursor() cursor = connection.cursor()
# Determine if we're using a new or an old DB. # Determine if the db supports linking audio to songs.
cursor.execute(u'SELECT name FROM sqlite_master ' cursor.execute(u'SELECT name FROM sqlite_master '
u'WHERE type = \'table\' AND name = \'tracks\'') u'WHERE type = \'table\' AND name = \'tracks\'')
new_db = len(cursor.fetchall()) > 0 db_has_tracks = len(cursor.fetchall()) > 0
# Determine if the db contains theme information.
cursor.execute(u'SELECT name FROM sqlite_master '
u'WHERE type = \'table\' AND name = \'settings\'')
db_has_themes = len(cursor.fetchall()) > 0
# "cache" our list of authors. # "cache" our list of authors.
cursor.execute(u'-- types int, unicode') cursor.execute(u'-- types int, unicode')
cursor.execute(u'SELECT authorid, authorname FROM authors') cursor.execute(u'SELECT authorid, authorname FROM authors')
authors = cursor.fetchall() authors = cursor.fetchall()
if new_db: if db_has_tracks:
# "cache" our list of tracks. # "cache" our list of tracks.
cursor.execute(u'-- types int, unicode') cursor.execute(u'-- types int, unicode')
cursor.execute(u'SELECT trackid, fulltrackname FROM tracks') cursor.execute(u'SELECT trackid, fulltrackname FROM tracks')
tracks = cursor.fetchall() tracks = cursor.fetchall()
# "cache" our list of themes. if db_has_themes:
cursor.execute(u'-- types int, unicode') # "cache" our list of themes.
cursor.execute(u'SELECT settingsid, settingsname FROM settings') themes = {}
themes = {} cursor.execute(u'-- types int, unicode')
for theme_id, theme_name in cursor.fetchall(): cursor.execute(u'SELECT settingsid, settingsname FROM settings')
if theme_name in self.availableThemes: for theme_id, theme_name in cursor.fetchall():
themes[theme_id] = theme_name if theme_name in self.availableThemes:
themes[theme_id] = theme_name
# Import the songs. # Import the songs.
cursor.execute(u'-- types int, unicode, unicode, unicode, int') cursor.execute(u'-- types int, unicode, unicode, unicode')
cursor.execute(u'SELECT songid, songtitle, lyrics || \'\' AS lyrics, ' cursor.execute(u'SELECT songid, songtitle, lyrics || \'\' AS ' \
u'copyrightinfo, settingsid FROM songs') u'lyrics, copyrightinfo FROM songs')
songs = cursor.fetchall() songs = cursor.fetchall()
self.importWizard.progressBar.setMaximum(len(songs)) self.importWizard.progressBar.setMaximum(len(songs))
for song in songs: for song in songs:
@ -112,8 +117,13 @@ class OpenLP1SongImport(SongImport):
self.title = song[1] self.title = song[1]
lyrics = song[2].replace(u'\r\n', u'\n') lyrics = song[2].replace(u'\r\n', u'\n')
self.addCopyright(song[3]) self.addCopyright(song[3])
if themes.has_key(song[4]): if db_has_themes:
self.themeName = themes[song[4]] cursor.execute(u'-- types int')
cursor.execute(
u'SELECT settingsid FROM songs WHERE songid = %s' % song_id)
theme_id = cursor.fetchone()[0]
if themes.has_key(theme_id):
self.themeName = themes[theme_id]
verses = lyrics.split(u'\n\n') verses = lyrics.split(u'\n\n')
for verse in verses: for verse in verses:
if verse.strip(): if verse.strip():
@ -131,7 +141,7 @@ class OpenLP1SongImport(SongImport):
break break
if self.stopImportFlag: if self.stopImportFlag:
break break
if new_db: if db_has_tracks:
cursor.execute(u'-- types int, int') cursor.execute(u'-- types int, int')
cursor.execute(u'SELECT trackid, listindex ' cursor.execute(u'SELECT trackid, listindex '
u'FROM songtracks ' u'FROM songtracks '

View File

@ -65,7 +65,7 @@ class OooImport(SongImport):
if not isinstance(self.importSource, list): if not isinstance(self.importSource, list):
return return
try: try:
self.start_ooo() self.startOoo()
except NoConnectException as exc: except NoConnectException as exc:
self.logError( self.logError(
self.importSource[0], self.importSource[0],
@ -145,7 +145,7 @@ class OooImport(SongImport):
process.waitForStarted() process.waitForStarted()
self.processStarted = True self.processStarted = True
except: except:
log.exception("start_ooo_process failed") log.exception("startOooProcess failed")
def openOooFile(self, filepath): def openOooFile(self, filepath):
""" """
@ -171,7 +171,7 @@ class OooImport(SongImport):
self.importWizard.incrementProgressBar( self.importWizard.incrementProgressBar(
u'Processing file ' + filepath, 0) u'Processing file ' + filepath, 0)
except AttributeError: except AttributeError:
log.exception("open_ooo_file failed: %s", url) log.exception("openOooFile failed: %s", url)
return return
def closeOooFile(self): def closeOooFile(self):

View File

@ -67,7 +67,7 @@ Name: quicklaunchicon; Description: {cm:CreateQuickLaunchIcon}; GroupDescription
Source: ..\..\dist\OpenLP\*; DestDir: {app}; Flags: ignoreversion recursesubdirs createallsubdirs Source: ..\..\dist\OpenLP\*; DestDir: {app}; Flags: ignoreversion recursesubdirs createallsubdirs
; DLL used to check if the target program is running at install time ; DLL used to check if the target program is running at install time
Source: psvince.dll; flags: dontcopy Source: psvince.dll; flags: dontcopy
; psvince is installed in {app} folder, so it will be loaded at ; psvince is installed in {app} folder, so it will be loaded at
; uninstall time to check if the target program is running ; uninstall time to check if the target program is running
Source: psvince.dll; DestDir: {app} Source: psvince.dll; DestDir: {app}
@ -84,10 +84,16 @@ Name: {userappdata}\Microsoft\Internet Explorer\Quick Launch\{#AppName}; Filenam
Filename: {app}\{#AppExeName}; Description: {cm:LaunchProgram,{#AppName}}; Flags: nowait postinstall skipifsilent Filename: {app}\{#AppExeName}; Description: {cm:LaunchProgram,{#AppName}}; Flags: nowait postinstall skipifsilent
[Registry] [Registry]
Root: HKCR; Subkey: ".osz"; ValueType: string; ValueName: ""; ValueData: "OpenLP"; Flags: uninsdeletevalue Root: HKCR; Subkey: .osz; ValueType: string; ValueName: ; ValueData: OpenLP; Flags: uninsdeletevalue
Root: HKCR; Subkey: "OpenLP"; ValueType: string; ValueName: ""; ValueData: "OpenLP Service"; Flags: uninsdeletekey Root: HKCR; Subkey: OpenLP; ValueType: string; ValueName: ; ValueData: OpenLP Service; Flags: uninsdeletekey
Root: HKCR; Subkey: "OpenLP\DefaultIcon"; ValueType: string; ValueName: ""; ValueData: "{app}\OpenLP.exe,0" Root: HKCR; Subkey: OpenLP\DefaultIcon; ValueType: string; ValueName: ; ValueData: {app}\OpenLP.exe,0
Root: HKCR; Subkey: "OpenLP\shell\open\command"; ValueType: string; ValueName: ""; ValueData: """{app}\OpenLP.exe"" ""%1""" Root: HKCR; Subkey: OpenLP\shell\open\command; ValueType: string; ValueName: ; ValueData: """{app}\OpenLP.exe"" ""%1"""
[UninstallDelete]
; Remove support directory created when program is run:
Type: filesandordirs; Name: {app}\support
; Remove program directory if empty:
Name: {app}; Type: dirifempty
[Code] [Code]
// Function to call psvince.dll at install time // Function to call psvince.dll at install time
@ -173,4 +179,6 @@ begin
Result := false; Result := false;
end; end;
end; end;
end; // Unload psvince.dll, otherwise it is not deleted
UnloadDLL(ExpandConstant('{app}\psvince.dll'));
end;