This commit is contained in:
Andreas Preikschat 2012-06-04 11:53:34 +02:00
commit 8f0ddfac9d
5 changed files with 44 additions and 13 deletions

View File

@ -109,6 +109,7 @@ class Renderer(object):
self.global_theme_data = \ self.global_theme_data = \
self.themeManager.getThemeData(self.global_theme) self.themeManager.getThemeData(self.global_theme)
self.theme_data = None self.theme_data = None
self._cache_background_image(self.global_theme_data)
def set_service_theme(self, service_theme): def set_service_theme(self, service_theme):
""" """
@ -119,6 +120,21 @@ class Renderer(object):
""" """
self.service_theme = service_theme self.service_theme = service_theme
self.theme_data = None self.theme_data = None
self._cache_background_image(self.themeManager.getThemeData
(service_theme))
def _cache_background_image(self, temp_theme):
"""
Adds a background image to the image cache if necessary.
``temp_theme``
The theme object containing the theme data.
"""
# if No file do not update cache
if temp_theme.background_filename:
self.imageManager.add_image(temp_theme.theme_name,
temp_theme.background_filename, u'theme',
QtGui.QColor(temp_theme.background_border_color))
def set_override_theme(self, override_theme, override_levels=False): def set_override_theme(self, override_theme, override_levels=False):
""" """
@ -163,11 +179,7 @@ class Renderer(object):
self.theme_data = self.themeManager.getThemeData(theme) self.theme_data = self.themeManager.getThemeData(theme)
self._calculate_default() self._calculate_default()
self._build_text_rectangle(self.theme_data) self._build_text_rectangle(self.theme_data)
# if No file do not update cache self._cache_background_image(self.theme_data)
if self.theme_data.background_filename:
self.imageManager.add_image(self.theme_data.theme_name,
self.theme_data.background_filename, u'theme',
QtGui.QColor(self.theme_data.background_border_color))
return self._rect, self._rect_footer return self._rect, self._rect_footer
def generate_preview(self, theme_data, force_page=False): def generate_preview(self, theme_data, force_page=False):

View File

@ -444,6 +444,20 @@ class ThemeXML(object):
element.appendChild(child) element.appendChild(child)
return child return child
def set_default_header_footer(self):
"""
Set the header and footer size into the current primary screen.
10 px on each side is removed to allow for a border.
"""
from openlp.core.ui import ScreenList
current_screen = ScreenList().current
self.font_main_y = 0
self.font_main_width = current_screen[u'size'].width() - 20
self.font_main_height = current_screen[u'size'].height() * 9 / 10
self.font_footer_width = current_screen[u'size'].width() - 20
self.font_footer_y = current_screen[u'size'].height() * 9 / 10
self.font_footer_height = current_screen[u'size'].height() / 10
def dump_xml(self): def dump_xml(self):
""" """
Dump the XML to file used for debugging Dump the XML to file used for debugging

View File

@ -56,6 +56,9 @@ class ThemeScreenshotThread(QtCore.QThread):
themes = themes.split(u',') themes = themes.split(u',')
config = self.parent().config config = self.parent().config
for theme in themes: for theme in themes:
# Stop if the wizard has been cancelled.
if self.parent().downloadCancelled:
return
title = config.get(u'theme_%s' % theme, u'title') title = config.get(u'theme_%s' % theme, u'title')
filename = config.get(u'theme_%s' % theme, u'filename') filename = config.get(u'theme_%s' % theme, u'filename')
screenshot = config.get(u'theme_%s' % theme, u'screenshot') screenshot = config.get(u'theme_%s' % theme, u'screenshot')
@ -86,7 +89,7 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard):
files = self.webAccess.read() files = self.webAccess.read()
self.config.readfp(io.BytesIO(files)) self.config.readfp(io.BytesIO(files))
self.updateScreenListCombo() self.updateScreenListCombo()
self.downloadCanceled = False self.downloadCancelled = False
self.downloading = unicode(translate('OpenLP.FirstTimeWizard', self.downloading = unicode(translate('OpenLP.FirstTimeWizard',
'Downloading %s...')) 'Downloading %s...'))
QtCore.QObject.connect(self.cancelButton, QtCore.SIGNAL('clicked()'), QtCore.QObject.connect(self.cancelButton, QtCore.SIGNAL('clicked()'),
@ -242,11 +245,12 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard):
Process the triggering of the cancel button. Process the triggering of the cancel button.
""" """
if self.lastId == FirstTimePage.NoInternet or \ if self.lastId == FirstTimePage.NoInternet or \
(self.lastId <= FirstTimePage.Plugins and \ (self.lastId <= FirstTimePage.Plugins and not self.hasRunWizard):
not self.hasRunWizard):
QtCore.QCoreApplication.exit() QtCore.QCoreApplication.exit()
sys.exit() sys.exit()
self.downloadCanceled = True self.downloadCancelled = True
while self.themeScreenshotThread.isRunning():
time.sleep(0.1)
Receiver.send_message(u'cursor_normal') Receiver.send_message(u'cursor_normal')
def onNoInternetFinishButtonClicked(self): def onNoInternetFinishButtonClicked(self):
@ -272,7 +276,7 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard):
filesize = urlfile.headers["Content-Length"] filesize = urlfile.headers["Content-Length"]
filename = open(fpath, "wb") filename = open(fpath, "wb")
# Download until finished or canceled. # Download until finished or canceled.
while not self.downloadCanceled: while not self.downloadCancelled:
data = urlfile.read(block_size) data = urlfile.read(block_size)
if not data: if not data:
break break
@ -280,8 +284,8 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard):
block_count += 1 block_count += 1
self._downloadProgress(block_count, block_size, filesize) self._downloadProgress(block_count, block_size, filesize)
filename.close() filename.close()
# Delete file if canceled, it may be a partial file. # Delete file if cancelled, it may be a partial file.
if self.downloadCanceled: if self.downloadCancelled:
os.remove(fpath) os.remove(fpath)
def _buildThemeScreenshots(self): def _buildThemeScreenshots(self):

View File

@ -257,6 +257,7 @@ class ThemeManager(QtGui.QWidget):
editing form for the user to make their customisations. editing form for the user to make their customisations.
""" """
theme = ThemeXML() theme = ThemeXML()
theme.set_default_header_footer()
self.themeForm.theme = theme self.themeForm.theme = theme
self.themeForm.exec_() self.themeForm.exec_()

View File

@ -164,7 +164,7 @@
<input type="search" name="search-text" id="search-text" value="" /> <input type="search" name="search-text" id="search-text" value="" />
</div> </div>
<a href="#" id="search-submit" data-role="button">${search}</a> <a href="#" id="search-submit" data-role="button">${search}</a>
<ul data-role="listview" data-inset="true"> <ul data-role="listview" data-inset="true"/>
</div> </div>
</div> </div>
<div data-role="page" id="options"> <div data-role="page" id="options">