bibles and themes work

This commit is contained in:
Tim Bentley 2011-03-05 09:23:47 +00:00
parent 21d4e7228a
commit cb661bf1ce
5 changed files with 85 additions and 35 deletions

View File

@ -151,7 +151,7 @@ class OpenLP(QtGui.QApplication):
log.info(u'Openlp version %s' % app_version[u'version']) log.info(u'Openlp version %s' % app_version[u'version'])
return app_version return app_version
def run(self, screens): def run(self):
""" """
Run the OpenLP application. Run the OpenLP application.
""" """
@ -167,6 +167,13 @@ class OpenLP(QtGui.QApplication):
self.setOrganizationDomain(u'openlp.org') self.setOrganizationDomain(u'openlp.org')
self.setApplicationName(u'OpenLP') self.setApplicationName(u'OpenLP')
self.setApplicationVersion(app_version[u'version']) self.setApplicationVersion(app_version[u'version'])
# Decide how many screens we have and their size
screens = ScreenList(self.desktop())
# First time checks in settings
firstTime = QtCore.QSettings().value(
u'general/first time', QtCore.QVariant(True)).toBool()
# if firstTime:
# FirstTimeForm(screens).exec_()
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(
@ -178,7 +185,8 @@ class OpenLP(QtGui.QApplication):
self.processEvents() self.processEvents()
# start the main app window # start the main app window
self.appClipboard = self.clipboard() self.appClipboard = self.clipboard()
self.mainWindow = MainWindow(screens, app_version, self.appClipboard) self.mainWindow = MainWindow(screens, app_version, self.appClipboard,
firstTime)
self.mainWindow.show() self.mainWindow.show()
if show_splash: if show_splash:
# now kill the splashscreen # now kill the splashscreen
@ -265,11 +273,11 @@ def main():
# Define the settings environment # Define the settings environment
QtCore.QSettings(u'OpenLP', u'OpenLP') QtCore.QSettings(u'OpenLP', u'OpenLP')
# First time checks in settings # First time checks in settings
if QtCore.QSettings().value( # if QtCore.QSettings().value(
u'general/first time', QtCore.QVariant(True)).toBool(): # u'general/first time', QtCore.QVariant(True)).toBool():
if not FirstTimeLanguageForm().exec_(): # if not FirstTimeLanguageForm().exec_():
# if cancel then stop processing # # if cancel then stop processing
sys.exit() # sys.exit()
if sys.platform == u'darwin': if sys.platform == u'darwin':
OpenLP.addLibraryPath(QtGui.QApplication.applicationDirPath() OpenLP.addLibraryPath(QtGui.QApplication.applicationDirPath()
+ "/qt4_plugins") + "/qt4_plugins")
@ -277,15 +285,9 @@ def main():
language = LanguageManager.get_language() language = LanguageManager.get_language()
appTranslator = LanguageManager.get_translator(language) appTranslator = LanguageManager.get_translator(language)
app.installTranslator(appTranslator) app.installTranslator(appTranslator)
# Decide how many screens we have and their size
screens = ScreenList(app.desktop())
# First time checks in settings
if QtCore.QSettings().value(
u'general/first time', QtCore.QVariant(True)).toBool():
FirstTimeForm(screens).exec_()
if not options.no_error_form: if not options.no_error_form:
sys.excepthook = app.hookException sys.excepthook = app.hookException
sys.exit()#(app.run(screens)) sys.exit(app.run())
if __name__ == u'__main__': if __name__ == u'__main__':
""" """

View File

@ -34,7 +34,7 @@ from PyQt4 import QtCore, QtGui
from firsttimewizard import Ui_FirstTimeWizard from firsttimewizard import Ui_FirstTimeWizard
from openlp.core.lib import translate, PluginStatus, check_directory_exists from openlp.core.lib import translate, PluginStatus, check_directory_exists, Receiver
from openlp.core.utils import get_web_page, AppLocation from openlp.core.utils import get_web_page, AppLocation
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
@ -58,6 +58,17 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard):
self.setupUi(self) self.setupUi(self)
for screen in screens.get_screen_list(): for screen in screens.get_screen_list():
self.displaySelectionComboBox.addItem(screen) self.displaySelectionComboBox.addItem(screen)
self.songsText = translate('OpenLP.FirstTimeWizard', 'Songs')
self.biblesText = translate('OpenLP.FirstTimeWizard', 'Bibles')
self.themesText = translate('OpenLP.FirstTimeWizard', 'Themes')
self.startUpdates = translate('OpenLP.FirstTimeWizard',
'Starting Updates')
self.downloadSongs = unicode(translate('OpenLP.FirstTimeWizard',
'Downloading Songs.'))
self.downloadBible = unicode(translate('OpenLP.FirstTimeWizard',
'Downloading bible'))
self.downloadTheme = unicode(translate('OpenLP.FirstTimeWizard',
'Downloading theme'))
def exec_(self, edit=False): def exec_(self, edit=False):
""" """
@ -76,13 +87,13 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard):
self.internetGroupBox.setVisible(True) self.internetGroupBox.setVisible(True)
self.noInternetLabel.setVisible(False) self.noInternetLabel.setVisible(False)
treewidgetitem = QtGui.QTreeWidgetItem(self.selectionTreeWidget) treewidgetitem = QtGui.QTreeWidgetItem(self.selectionTreeWidget)
treewidgetitem.setText(0, u'Songs') treewidgetitem.setText(0, self.songsText)
self.__loadChild(treewidgetitem, u'songs', u'languages', u'songs') self.__loadChild(treewidgetitem, u'songs', u'languages', u'songs')
treewidgetitem = QtGui.QTreeWidgetItem(self.selectionTreeWidget) treewidgetitem = QtGui.QTreeWidgetItem(self.selectionTreeWidget)
treewidgetitem.setText(0, u'Bibles') treewidgetitem.setText(0, self.biblesText)
self.__loadChild(treewidgetitem, u'bibles', u'translations', u'bible') self.__loadChild(treewidgetitem, u'bibles', u'translations', u'bible')
treewidgetitem = QtGui.QTreeWidgetItem(self.selectionTreeWidget) treewidgetitem = QtGui.QTreeWidgetItem(self.selectionTreeWidget)
treewidgetitem.setText(0, u'Themes') treewidgetitem.setText(0, self.themesText)
self.__loadChild(treewidgetitem, u'themes', u'files', 'theme') self.__loadChild(treewidgetitem, u'themes', u'files', 'theme')
else: else:
self.internetGroupBox.setVisible(False) self.internetGroupBox.setVisible(False)
@ -94,9 +105,11 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard):
for file in files: for file in files:
if file: if file:
child = QtGui.QTreeWidgetItem(tree) child = QtGui.QTreeWidgetItem(tree)
child.setText(0, self.config.get(u'%s_%s' %(root, file), u'title')) child.setText(0, self.config.get(u'%s_%s'
% (root, file), u'title'))
child.setData(0, QtCore.Qt.UserRole, child.setData(0, QtCore.Qt.UserRole,
QtCore.QVariant(self.config.get(u'%s_%s' %(root, file), u'filename'))) QtCore.QVariant(self.config.get(u'%s_%s'
% (root, file), u'filename')))
child.setCheckState(0, QtCore.Qt.Unchecked) child.setCheckState(0, QtCore.Qt.Unchecked)
child.setFlags(QtCore.Qt.ItemIsUserCheckable | child.setFlags(QtCore.Qt.ItemIsUserCheckable |
QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled) QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled)
@ -107,15 +120,18 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard):
""" """
wizardPage = self.page(id) wizardPage = self.page(id)
if wizardPage == self.DefaultsPage: if wizardPage == self.DefaultsPage:
listIterator = QtGui.QTreeWidgetItemIterator(self.selectionTreeWidget) listIterator = QtGui.QTreeWidgetItemIterator(
self.selectionTreeWidget)
while listIterator.value(): while listIterator.value():
parent = listIterator.value().parent() parent = listIterator.value().parent()
if parent and listIterator.value().checkState(0) == QtCore.Qt.Checked: if parent and listIterator.value().checkState(0) \
if unicode(parent.text(0)) == u'Themes': == QtCore.Qt.Checked:
if unicode(parent.text(0)) == self.themesText:
self.themeSelectionComboBox.addItem(listIterator.value().text(0)) self.themeSelectionComboBox.addItem(listIterator.value().text(0))
listIterator += 1 listIterator += 1
def accept(self): def accept(self):
self.__updateMessage(self.startUpdates)
self.__pluginStatus(self.songsCheckBox, u'songs/status') self.__pluginStatus(self.songsCheckBox, u'songs/status')
self.__pluginStatus(self.bibleCheckBox, u'bibles/status') self.__pluginStatus(self.bibleCheckBox, u'bibles/status')
self.__pluginStatus(self.presentationCheckBox, u'presentations/status') self.__pluginStatus(self.presentationCheckBox, u'presentations/status')
@ -138,14 +154,18 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard):
if listIterator.value().parent(): if listIterator.value().parent():
if listIterator.value().checkState(0) == QtCore.Qt.Checked: if listIterator.value().checkState(0) == QtCore.Qt.Checked:
# Install # Install
if unicode(type.text(0)) == u'Bibles': if unicode(type.text(0)) == self.biblesText:
theme = unicode(listIterator.value().data(0, bible = unicode(listIterator.value().data(0,
QtCore.Qt.UserRole).toString()) QtCore.Qt.UserRole).toString())
urllib.urlretrieve(u'%s%s' % (self.web, theme), message = u'%s %s' % (self.downloadBible, bible)
os.path.join(bibleDestination, theme)) self.__updateMessage(message)
if unicode(type.text(0)) == u'Themes': urllib.urlretrieve(u'%s%s' % (self.web, bible),
os.path.join(bibleDestination, bible))
if unicode(type.text(0)) == self.themesText:
theme = unicode(listIterator.value().data(0, theme = unicode(listIterator.value().data(0,
QtCore.Qt.UserRole).toString()) QtCore.Qt.UserRole).toString())
message = u'%s %s' % (self.downloadTheme, bible)
self.__updateMessage(message)
urllib.urlretrieve(u'%s%s' % (self.web, theme), urllib.urlretrieve(u'%s%s' % (self.web, theme),
os.path.join(themeDestination, theme)) os.path.join(themeDestination, theme))
listIterator += 1 listIterator += 1
@ -155,3 +175,7 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard):
status = PluginStatus.Active if field.checkState() \ status = PluginStatus.Active if field.checkState() \
== QtCore.Qt.Checked else PluginStatus.Inactive == QtCore.Qt.Checked else PluginStatus.Inactive
QtCore.QSettings().setValue(tag, QtCore.QVariant(status)) QtCore.QSettings().setValue(tag, QtCore.QVariant(status))
def __updateMessage(self, text):
self.updateLabel.setText(text)
Receiver.send_message(u'openlp_process_events')

View File

@ -163,13 +163,16 @@ class Ui_FirstTimeWizard(object):
QtGui.QComboBox.AdjustToContents) QtGui.QComboBox.AdjustToContents)
self.themeSelectionComboBox.setObjectName(u'themeSelectionComboBox') self.themeSelectionComboBox.setObjectName(u'themeSelectionComboBox')
self.gridLayout.addWidget(self.themeSelectionComboBox, 1, 1, 1, 1) self.gridLayout.addWidget(self.themeSelectionComboBox, 1, 1, 1, 1)
self.label = QtGui.QLabel(self.DefaultsPage) self.messageLabel = QtGui.QLabel(self.DefaultsPage)
self.label.setGeometry(QtCore.QRect(40, 190, 471, 17)) self.messageLabel.setGeometry(QtCore.QRect(60, 160, 471, 17))
self.label.setObjectName(u'label') self.messageLabel.setObjectName(u'messageLabel')
self.updateLabel = QtGui.QLabel(self.DefaultsPage)
self.updateLabel.setGeometry(QtCore.QRect(60, 220, 351, 17))
self.updateLabel.setObjectName(u'updateLabel')
FirstTimeWizard.addPage(self.DefaultsPage) FirstTimeWizard.addPage(self.DefaultsPage)
self.retranslateUi(FirstTimeWizard) self.retranslateUi(FirstTimeWizard)
QtCore.QMetaObject.connectSlotsByName(OpenLP.FirstTimeWizard) QtCore.QMetaObject.connectSlotsByName(FirstTimeWizard)
def retranslateUi(self, FirstTimeWizard): def retranslateUi(self, FirstTimeWizard):
FirstTimeWizard.setWindowTitle(translate( FirstTimeWizard.setWindowTitle(translate(
@ -220,5 +223,5 @@ class Ui_FirstTimeWizard(object):
'Default output display')) 'Default output display'))
self.themeSelectionLabel.setText(translate('OpenLP.FirstTimeWizard', self.themeSelectionLabel.setText(translate('OpenLP.FirstTimeWizard',
'Select the default Theme')) 'Select the default Theme'))
self.label.setText(translate('OpenLP.FirstTimeWizard', self.messageLabel.setText(translate('OpenLP.FirstTimeWizard',
'Press Finish to apply all you changes and start OpenLP')) 'Press Finish to apply all you changes and start OpenLP'))

View File

@ -461,7 +461,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
actionList = ActionList() actionList = ActionList()
def __init__(self, screens, applicationVersion, clipboard): def __init__(self, screens, applicationVersion, clipboard, firstTime):
""" """
This constructor sets up the interface, the various managers, and the This constructor sets up the interface, the various managers, and the
plugins. plugins.
@ -626,6 +626,9 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
self.MediaToolBox.setCurrentIndex(savedPlugin) self.MediaToolBox.setCurrentIndex(savedPlugin)
self.settingsForm.postSetUp() self.settingsForm.postSetUp()
Receiver.send_message(u'cursor_normal') Receiver.send_message(u'cursor_normal')
# Import themes if first time
# if firstTime:
# self.themeManagerContents.firstTime()
def setAutoLanguage(self, value): def setAutoLanguage(self, value):
self.LanguageGroup.setDisabled(value) self.LanguageGroup.setDisabled(value)

View File

@ -145,6 +145,20 @@ class ThemeManager(QtGui.QWidget):
# Last little bits of setting up # Last little bits of setting up
self.configUpdated() self.configUpdated()
def firstTime(self):
"""
Import new themes downloaded by the first time wizard
"""
Receiver.send_message(u'cursor_busy')
encoding = get_filesystem_encoding()
files = SettingsManager.get_files(self.settingsSection, u'.otz')
for file in files:
file = os.path.join(self.path, file).encode(encoding)
self.unzipTheme(file, self.path)
delete_file(file)
self.loadThemes()
Receiver.send_message(u'cursor_normal')
def configUpdated(self, firstTime=False): def configUpdated(self, firstTime=False):
""" """
Triggered when Config dialog is updated. Triggered when Config dialog is updated.
@ -370,6 +384,7 @@ class ThemeManager(QtGui.QWidget):
'Save Theme - (%s)')) % theme, 'Save Theme - (%s)')) % theme,
SettingsManager.get_last_dir(self.settingsSection, 1)) SettingsManager.get_last_dir(self.settingsSection, 1))
path = unicode(path) path = unicode(path)
Receiver.send_message(u'cursor_busy')
if path: if path:
SettingsManager.set_last_dir(self.settingsSection, path, 1) SettingsManager.set_last_dir(self.settingsSection, path, 1)
themePath = os.path.join(path, theme + u'.otz') themePath = os.path.join(path, theme + u'.otz')
@ -395,6 +410,7 @@ class ThemeManager(QtGui.QWidget):
finally: finally:
if zip: if zip:
zip.close() zip.close()
Receiver.send_message(u'cursor_normal')
def onImportTheme(self): def onImportTheme(self):
""" """
@ -408,12 +424,14 @@ class ThemeManager(QtGui.QWidget):
unicode(translate('OpenLP.ThemeManager', unicode(translate('OpenLP.ThemeManager',
'OpenLP Themes (*.theme *.otz)'))) 'OpenLP Themes (*.theme *.otz)')))
log.info(u'New Themes %s', unicode(files)) log.info(u'New Themes %s', unicode(files))
Receiver.send_message(u'cursor_busy')
if files: if files:
for file in files: for file in files:
SettingsManager.set_last_dir( SettingsManager.set_last_dir(
self.settingsSection, unicode(file)) self.settingsSection, unicode(file))
self.unzipTheme(file, self.path) self.unzipTheme(file, self.path)
self.loadThemes() self.loadThemes()
Receiver.send_message(u'cursor_normal')
def loadThemes(self): def loadThemes(self):
""" """