This commit is contained in:
Raoul Snyman 2011-03-24 19:18:42 +02:00
commit a9443ba08e
25 changed files with 7297 additions and 6651 deletions

View File

@ -170,7 +170,9 @@ class OpenLP(QtGui.QApplication):
has_run_wizard = QtCore.QSettings().value( has_run_wizard = QtCore.QSettings().value(
u'general/has run wizard', QtCore.QVariant(False)).toBool() u'general/has run wizard', QtCore.QVariant(False)).toBool()
if not has_run_wizard: if not has_run_wizard:
FirstTimeForm(screens).exec_() if FirstTimeForm(screens).exec_() == QtGui.QDialog.Accepted:
QtCore.QSettings().setValue(u'general/has run wizard',
QtCore.QVariant(True))
if os.name == u'nt': if os.name == u'nt':
self.setStyleSheet(application_stylesheet) self.setStyleSheet(application_stylesheet)
show_splash = QtCore.QSettings().value( show_splash = QtCore.QSettings().value(

View File

@ -33,7 +33,8 @@ from ConfigParser import SafeConfigParser
from PyQt4 import QtCore, QtGui from PyQt4 import QtCore, QtGui
from openlp.core.lib import translate, PluginStatus, Receiver, build_icon from openlp.core.lib import translate, PluginStatus, Receiver, build_icon, \
check_directory_exists
from openlp.core.utils import get_web_page, AppLocation from openlp.core.utils import get_web_page, AppLocation
from firsttimewizard import Ui_FirstTimeWizard, FirstTimePage from firsttimewizard import Ui_FirstTimeWizard, FirstTimePage
@ -49,6 +50,7 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard):
def __init__(self, screens, parent=None): def __init__(self, screens, parent=None):
QtGui.QWizard.__init__(self, parent) QtGui.QWizard.__init__(self, parent)
self.setupUi(self) self.setupUi(self)
self.screens = screens
# check to see if we have web access # check to see if we have web access
self.web = u'http://openlp.org/files/frw/' self.web = u'http://openlp.org/files/frw/'
self.config = SafeConfigParser() self.config = SafeConfigParser()
@ -56,12 +58,13 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard):
if self.webAccess: if self.webAccess:
files = self.webAccess.read() files = self.webAccess.read()
self.config.readfp(io.BytesIO(files)) self.config.readfp(io.BytesIO(files))
self.displayComboBox.addItems(screens.get_screen_list()) self.updateScreenListCombo()
self.downloading = unicode(translate('OpenLP.FirstTimeWizard', self.downloading = unicode(translate('OpenLP.FirstTimeWizard',
'Downloading %s...')) 'Downloading %s...'))
QtCore.QObject.connect(self, QtCore.QObject.connect(self,
QtCore.SIGNAL(u'currentIdChanged(int)'), QtCore.SIGNAL(u'currentIdChanged(int)'), self.onCurrentIdChanged)
self.onCurrentIdChanged) QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'config_screen_changed'), self.updateScreenListCombo)
def exec_(self, edit=False): def exec_(self, edit=False):
""" """
@ -75,6 +78,7 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard):
Set up display at start of theme edit. Set up display at start of theme edit.
""" """
self.restart() self.restart()
check_directory_exists(os.path.join(gettempdir(), u'openlp'))
# Sort out internet access for downloads # Sort out internet access for downloads
if self.webAccess: if self.webAccess:
songs = self.config.get(u'songs', u'languages') songs = self.config.get(u'songs', u'languages')
@ -111,8 +115,6 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard):
self.biblesTreeWidget.expandAll() self.biblesTreeWidget.expandAll()
themes = self.config.get(u'themes', u'files') themes = self.config.get(u'themes', u'files')
themes = themes.split(u',') themes = themes.split(u',')
if not os.path.exists(os.path.join(gettempdir(), u'openlp')):
os.makedirs(os.path.join(gettempdir(), u'openlp'))
for theme in themes: for theme in themes:
title = self.config.get(u'theme_%s' % theme, u'title') title = self.config.get(u'theme_%s' % theme, u'title')
filename = self.config.get(u'theme_%s' % theme, u'filename') filename = self.config.get(u'theme_%s' % theme, u'filename')
@ -160,6 +162,15 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard):
self._performWizard() self._performWizard()
self._postWizard() self._postWizard()
def updateScreenListCombo(self):
"""
The user changed screen resolution or enabled/disabled more screens, so
we need to update the combo box.
"""
self.displayComboBox.clear()
self.displayComboBox.addItems(self.screens.get_screen_list())
self.displayComboBox.setCurrentIndex(self.displayComboBox.count() - 1)
def _getFileSize(self, url): def _getFileSize(self, url):
site = urllib.urlopen(url) site = urllib.urlopen(url)
meta = site.info() meta = site.info()
@ -294,8 +305,6 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard):
if self.themeComboBox.currentIndex() != -1: if self.themeComboBox.currentIndex() != -1:
QtCore.QSettings().setValue(u'themes/global theme', QtCore.QSettings().setValue(u'themes/global theme',
QtCore.QVariant(self.themeComboBox.currentText())) QtCore.QVariant(self.themeComboBox.currentText()))
QtCore.QSettings().setValue(u'general/has run wizard',
QtCore.QVariant(True))
def _setPluginStatus(self, field, tag): def _setPluginStatus(self, field, tag):
status = PluginStatus.Active if field.checkState() \ status = PluginStatus.Active if field.checkState() \

View File

@ -158,8 +158,6 @@ class Ui_FirstTimeWizard(object):
self.displayComboBox = QtGui.QComboBox(self.defaultsPage) self.displayComboBox = QtGui.QComboBox(self.defaultsPage)
self.displayComboBox.setEditable(False) self.displayComboBox.setEditable(False)
self.displayComboBox.setInsertPolicy(QtGui.QComboBox.NoInsert) self.displayComboBox.setInsertPolicy(QtGui.QComboBox.NoInsert)
self.displayComboBox.setSizeAdjustPolicy(
QtGui.QComboBox.AdjustToContents)
self.displayComboBox.setObjectName(u'displayComboBox') self.displayComboBox.setObjectName(u'displayComboBox')
self.defaultsLayout.addRow(self.displayLabel, self.displayComboBox) self.defaultsLayout.addRow(self.displayLabel, self.displayComboBox)
self.themeLabel = QtGui.QLabel(self.defaultsPage) self.themeLabel = QtGui.QLabel(self.defaultsPage)

View File

@ -46,7 +46,6 @@ class SlideList(QtGui.QTableWidget):
QtGui.QTableWidget.__init__(self, parent.controller) QtGui.QTableWidget.__init__(self, parent.controller)
self.parent = parent self.parent = parent
class SlideController(QtGui.QWidget): class SlideController(QtGui.QWidget):
""" """
SlideController is the slide controller widget. This widget is what the SlideController is the slide controller widget. This widget is what the
@ -858,6 +857,7 @@ class SlideController(QtGui.QWidget):
self.serviceItem.bg_image_bytes = None self.serviceItem.bg_image_bytes = None
self.slidePreview.setPixmap(QtGui.QPixmap.fromImage(frame)) self.slidePreview.setPixmap(QtGui.QPixmap.fromImage(frame))
self.selectedRow = row self.selectedRow = row
self.__checkUpdateSelectedSlide(row)
Receiver.send_message(u'slidecontroller_%s_changed' % self.typePrefix, Receiver.send_message(u'slidecontroller_%s_changed' % self.typePrefix,
row) row)

View File

@ -268,6 +268,7 @@ class SearchResults(object):
return len(self.verselist) > 0 return len(self.verselist) > 0
from versereferencelist import VerseReferenceList
from manager import BibleManager from manager import BibleManager
from biblestab import BiblesTab from biblestab import BiblesTab
from mediaitem import BibleMediaItem from mediaitem import BibleMediaItem

View File

@ -35,7 +35,7 @@ from openlp.core.lib.ui import UiStrings, add_widget_completer, \
media_item_combo_box, critical_error_message_box media_item_combo_box, critical_error_message_box
from openlp.plugins.bibles.forms import BibleImportForm from openlp.plugins.bibles.forms import BibleImportForm
from openlp.plugins.bibles.lib import LayoutStyle, DisplayStyle, \ from openlp.plugins.bibles.lib import LayoutStyle, DisplayStyle, \
get_reference_match VerseReferenceList, get_reference_match
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
@ -637,6 +637,7 @@ class BibleMediaItem(MediaManagerItem):
old_chapter = -1 old_chapter = -1
raw_slides = [] raw_slides = []
raw_title = [] raw_title = []
verses = VerseReferenceList()
for item in items: for item in items:
bitem = self.listView.item(item.row()) bitem = self.listView.item(item.row())
book = self._decodeQtObject(bitem, 'book') book = self._decodeQtObject(bitem, 'book')
@ -653,15 +654,9 @@ class BibleMediaItem(MediaManagerItem):
second_permissions = \ second_permissions = \
self._decodeQtObject(bitem, 'second_permissions') self._decodeQtObject(bitem, 'second_permissions')
second_text = self._decodeQtObject(bitem, 'second_text') second_text = self._decodeQtObject(bitem, 'second_text')
verses.add(book, chapter, verse, version, copyright, permissions)
verse_text = self.formatVerse(old_chapter, chapter, verse) verse_text = self.formatVerse(old_chapter, chapter, verse)
footer = u'%s (%s %s %s)' % (book, version, copyright, permissions)
if footer not in service_item.raw_footer:
service_item.raw_footer.append(footer)
if second_bible: if second_bible:
footer = u'%s (%s %s %s)' % (book, second_version,
second_copyright, second_permissions)
if footer not in service_item.raw_footer:
service_item.raw_footer.append(footer)
bible_text = u'%s %s\n\n%s %s' % (verse_text, text, bible_text = u'%s %s\n\n%s %s' % (verse_text, text,
verse_text, second_text) verse_text, second_text)
raw_slides.append(bible_text.rstrip()) raw_slides.append(bible_text.rstrip())
@ -684,6 +679,12 @@ class BibleMediaItem(MediaManagerItem):
start_item = item start_item = item
old_item = item old_item = item
old_chapter = chapter old_chapter = chapter
# Add footer
service_item.raw_footer.append(verses.format_verses())
if second_bible:
verses.add_version(second_version, second_copyright,
second_permissions)
service_item.raw_footer.append(verses.format_versions())
raw_title.append(self.formatTitle(start_item, item)) raw_title.append(self.formatTitle(start_item, item))
# If there are no more items we check whether we have to add bible_text. # If there are no more items we check whether we have to add bible_text.
if bible_text: if bible_text:

View File

@ -0,0 +1,99 @@
# -*- 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, Armin Köhler, 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 #
###############################################################################
class VerseReferenceList(object):
"""
The VerseReferenceList class encapsulates a list of verse references, but
maintains the order in which they were added.
"""
def __init__(self):
self.verse_list = []
self.version_list = []
self.current_index = -1
def add(self, book, chapter, verse, version, copyright, permission):
self.add_version(version, copyright, permission)
if not self.verse_list or \
self.verse_list[self.current_index][u'book'] != book:
self.verse_list.append({u'version': version, u'book': book,
u'chapter': chapter, u'start': verse, u'end': verse})
self.current_index += 1
elif self.verse_list[self.current_index][u'chapter'] != chapter:
self.verse_list.append({u'version': version, u'book': book,
u'chapter': chapter, u'start': verse, u'end': verse})
self.current_index += 1
elif (self.verse_list[self.current_index][u'end'] + 1) == verse:
self.verse_list[self.current_index][u'end'] = verse
else:
self.verse_list.append({u'version': version, u'book': book,
u'chapter': chapter, u'start': verse, u'end': verse})
self.current_index += 1
def add_version(self, version, copyright, permission):
for bible_version in self.version_list:
if bible_version[u'version'] == version:
return
self.version_list.append({u'version': version, u'copyright': copyright,
u'permission': permission})
def format_verses(self):
result = u''
for index, verse in enumerate(self.verse_list):
if index == 0:
result = u'%s %s:%s' % (verse[u'book'], verse[u'chapter'],
verse[u'start'])
if verse[u'start'] != verse[u'end']:
result = u'%s-%s' % (result, verse[u'end'])
continue
prev = index - 1
if self.verse_list[prev][u'version'] != verse[u'version']:
result = u'%s (%s)' % (result, self.verse_list[prev][u'version'])
result = result + u', '
if self.verse_list[prev][u'book'] != verse[u'book']:
result = u'%s%s %s:' % (result, verse[u'book'],
verse[u'chapter'])
elif self.verse_list[prev][u'chapter'] != verse[u'chapter']:
result = u'%s%s:' % (result, verse[u'chapter'])
result = result + str(verse[u'start'])
if verse[u'start'] != verse[u'end']:
result = u'%s-%s' % (result, verse[u'end'])
if len(self.version_list) > 1:
result = u'%s (%s)' % (result, verse[u'version'])
return result
def format_versions(self):
result = u''
for index, version in enumerate(self.version_list):
if index > 0:
if result[-1] not in [u';', u',', u'.']:
result = result + u';'
result = result + u' '
result = u'%s%s, %s' % (result, version[u'version'],
version[u'copyright'])
if version[u'permission'].strip():
result = result + u', ' + version[u'permission']
return result

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff