This commit is contained in:
Raoul Snyman 2011-05-24 22:53:41 +02:00
commit 8c9728c3b2
7 changed files with 86 additions and 35 deletions

View File

@ -336,7 +336,7 @@ class Renderer(object):
styled_text += styled_line
html = self.page_shell + styled_text + HTML_END
self.web.setHtml(html)
# Text too long so go to next page
# Text too long so go to next page.
if self.web_frame.contentsSize().height() > self.page_height:
if force_page and line_count > 0:
Receiver.send_message(u'theme_line_count', line_count)
@ -367,7 +367,7 @@ class Renderer(object):
"""
log.debug(u'_paginate_slide_words - Start')
line_end = u''
line_end = u' '
if line_break:
line_end = u'<br>'
formatted = []
@ -375,10 +375,11 @@ class Renderer(object):
previous_raw = u''
lines = text.split(u'\n')
for line in lines:
line = line.strip()
styled_line = expand_tags(line)
html = self.page_shell + previous_html + styled_line + HTML_END
self.web.setHtml(html)
# Text too long so go to next page
# Text too long so go to next page.
if self.web_frame.contentsSize().height() > self.page_height:
# Check if there was a verse before the current one and append
# it, when it fits on the page.
@ -402,24 +403,56 @@ class Renderer(object):
previous_html = styled_line + line_end
previous_raw = line + line_end
continue
words = self._words_split(line)
for word in words:
styled_word = expand_tags(word)
html = self.page_shell + previous_html + styled_word + \
HTML_END
# Figure out how many words of the line will fit on screen by
# using the algorithm known as "binary chop".
raw_words = self._words_split(line)
html_words = [expand_tags(word) for word in raw_words]
smallest_index = 0
highest_index = len(html_words) - 1
index = int(highest_index / 2)
while True:
html = self.page_shell + previous_html + \
u''.join(html_words[:index + 1]).strip() + HTML_END
self.web.setHtml(html)
# Text too long so go to next page
if self.web_frame.contentsSize().height() > \
self.page_height:
while previous_raw.endswith(u'<br>'):
previous_raw = previous_raw[:-4]
formatted.append(previous_raw)
# We know that it does not fit, so change/calculate the
# new index and highest_index accordingly.
highest_index = index
index = int(index - (index - smallest_index) / 2)
else:
smallest_index = index
index = int(index + (highest_index - index) / 2)
# We found the number of words which will fit.
if smallest_index == index or highest_index == index:
index = smallest_index
formatted.append(previous_raw.rstrip(u'<br>') +
u''.join(raw_words[:index + 1]))
previous_html = u''
previous_raw = u''
previous_html += styled_word
previous_raw += word
previous_html += line_end
previous_raw += line_end
else:
continue
# Check if the rest of the line fits on the slide. If it
# does we do not have to do the much more intensive "word by
# word" checking.
html = self.page_shell + \
u''.join(html_words[index + 1:]).strip() + HTML_END
self.web.setHtml(html)
if self.web_frame.contentsSize().height() <= \
self.page_height:
previous_html = \
u''.join(html_words[index + 1:]).strip() + line_end
previous_raw = \
u''.join(raw_words[index + 1:]).strip() + line_end
break
else:
# The other words do not fit, thus reset the indexes,
# create a new list and continue with "word by word".
raw_words = raw_words[index + 1:]
html_words = html_words[index + 1:]
smallest_index = 0
highest_index = len(html_words) - 1
index = int(highest_index / 2)
else:
previous_html += styled_line + line_end
previous_raw += line + line_end

View File

@ -26,6 +26,7 @@
###############################################################################
import logging
import locale
from PyQt4 import QtCore, QtGui
from sqlalchemy.sql import or_, func
@ -134,15 +135,19 @@ class CustomMediaItem(MediaManagerItem):
self.onPreviewClick()
self.onRemoteEditClear()
def loadList(self, list):
def loadList(self, custom_slides):
self.listView.clear()
for customSlide in list:
custom_name = QtGui.QListWidgetItem(customSlide.title)
# Sort the customs by its title considering language specific
# characters. lower() is needed for windows!
custom_slides.sort(
cmp=locale.strcoll, key=lambda custom: custom.title.lower())
for custom_slide in custom_slides:
custom_name = QtGui.QListWidgetItem(custom_slide.title)
custom_name.setData(
QtCore.Qt.UserRole, QtCore.QVariant(customSlide.id))
QtCore.Qt.UserRole, QtCore.QVariant(custom_slide.id))
self.listView.addItem(custom_name)
# Auto-select the item if name has been set
if customSlide.title == self.autoSelectItem :
if custom_slide.title == self.autoSelectItem:
self.listView.setCurrentItem(custom_name)
def onNewClick(self):

View File

@ -150,20 +150,18 @@ class PresentationMediaItem(MediaManagerItem):
else:
self.presentationWidget.hide()
def loadList(self, list, initialLoad=False):
def loadList(self, files, initialLoad=False):
"""
Add presentations into the media manager
This is called both on initial load of the plugin to populate with
existing files, and when the user adds new files via the media manager
"""
currlist = self.getFileList()
titles = []
for file in currlist:
titles.append(os.path.split(file)[1])
titles = [os.path.split(file)[1] for file in currlist]
Receiver.send_message(u'cursor_busy')
if not initialLoad:
self.parent.formparent.displayProgressBar(len(list))
for file in list:
self.parent.formparent.displayProgressBar(len(files))
for file in files:
if not initialLoad:
self.parent.formparent.incrementProgressBar()
if currlist.count(file) > 0:

View File

@ -230,7 +230,10 @@ class SongMediaItem(MediaManagerItem):
def displayResultsSong(self, searchresults):
log.debug(u'display results Song')
self.listView.clear()
searchresults.sort(cmp=self.collateSongTitles)
# Sort the songs by its title considering language specific characters.
# lower() is needed for windows!
searchresults.sort(
cmp=locale.strcoll, key=lambda song: song.title.lower())
for song in searchresults:
author_list = [author.display_name for author in song.authors]
song_title = unicode(song.title)
@ -476,13 +479,6 @@ class SongMediaItem(MediaManagerItem):
Receiver.send_message(u'service_item_update',
u'%s:%s' % (editId, item._uuid))
def collateSongTitles(self, song_1, song_2):
"""
Locale aware collation of song titles
"""
return locale.strcoll(unicode(song_1.title.lower()),
unicode(song_2.title.lower()))
def search(self, string):
"""
Search for some songs

View File

@ -65,6 +65,7 @@ Name: quicklaunchicon; Description: {cm:CreateQuickLaunchIcon}; GroupDescription
[Files]
Source: ..\..\dist\OpenLP\*; DestDir: {app}; Flags: ignoreversion recursesubdirs createallsubdirs
Source: psvince.dll; Flags: dontcopy
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
[Icons]
@ -86,6 +87,9 @@ Root: HKCR; Subkey: "OpenLP\DefaultIcon"; ValueType: string; ValueName: ""; Valu
Root: HKCR; Subkey: "OpenLP\shell\open\command"; ValueType: string; ValueName: ""; ValueData: """{app}\OpenLP.exe"" ""%1"""
[Code]
function IsModuleLoaded(modulename: String ): Boolean;
external 'IsModuleLoaded@files:psvince.dll stdcall';
function GetUninstallString(): String;
var
sUnInstPath: String;
@ -126,6 +130,19 @@ begin
Result := 1;
end;
function InitializeSetup(): Boolean;
begin
Result := true;
while IsModuleLoaded( 'OpenLP.exe' ) and Result do
begin
if MsgBox( 'Openlp is currently running, please close it to continue the install.',
mbError, MB_OKCANCEL ) = IDCANCEL then
begin
Result := false;
end;
end;
end;
procedure CurStepChanged(CurStep: TSetupStep);
begin
if (CurStep=ssInstall) then

Binary file not shown.

View File

@ -226,6 +226,8 @@ def copy_windows_files():
os.path.join(dist_path, u'OpenLP.ico'))
copy(os.path.join(winres_path, u'LICENSE.txt'),
os.path.join(dist_path, u'LICENSE.txt'))
copy(os.path.join(winres_path, u'psvince.dll'),
os.path.join(dist_path, u'psvince.dll'))
if os.path.isfile(os.path.join(helpfile_path, u'Openlp.chm')):
print u' Windows help file found'
copy(os.path.join(helpfile_path, u'Openlp.chm'),