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

View File

@ -34,7 +34,7 @@ from PyQt4 import QtCore, QtGui
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
log = logging.getLogger(__name__)
@ -58,6 +58,17 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard):
self.setupUi(self)
for screen in screens.get_screen_list():
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):
"""
@ -76,13 +87,13 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard):
self.internetGroupBox.setVisible(True)
self.noInternetLabel.setVisible(False)
treewidgetitem = QtGui.QTreeWidgetItem(self.selectionTreeWidget)
treewidgetitem.setText(0, u'Songs')
treewidgetitem.setText(0, self.songsText)
self.__loadChild(treewidgetitem, u'songs', u'languages', u'songs')
treewidgetitem = QtGui.QTreeWidgetItem(self.selectionTreeWidget)
treewidgetitem.setText(0, u'Bibles')
treewidgetitem.setText(0, self.biblesText)
self.__loadChild(treewidgetitem, u'bibles', u'translations', u'bible')
treewidgetitem = QtGui.QTreeWidgetItem(self.selectionTreeWidget)
treewidgetitem.setText(0, u'Themes')
treewidgetitem.setText(0, self.themesText)
self.__loadChild(treewidgetitem, u'themes', u'files', 'theme')
else:
self.internetGroupBox.setVisible(False)
@ -94,9 +105,11 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard):
for file in files:
if file:
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,
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.setFlags(QtCore.Qt.ItemIsUserCheckable |
QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled)
@ -107,15 +120,18 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard):
"""
wizardPage = self.page(id)
if wizardPage == self.DefaultsPage:
listIterator = QtGui.QTreeWidgetItemIterator(self.selectionTreeWidget)
listIterator = QtGui.QTreeWidgetItemIterator(
self.selectionTreeWidget)
while listIterator.value():
parent = listIterator.value().parent()
if parent and listIterator.value().checkState(0) == QtCore.Qt.Checked:
if unicode(parent.text(0)) == u'Themes':
if parent and listIterator.value().checkState(0) \
== QtCore.Qt.Checked:
if unicode(parent.text(0)) == self.themesText:
self.themeSelectionComboBox.addItem(listIterator.value().text(0))
listIterator += 1
def accept(self):
self.__updateMessage(self.startUpdates)
self.__pluginStatus(self.songsCheckBox, u'songs/status')
self.__pluginStatus(self.bibleCheckBox, u'bibles/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().checkState(0) == QtCore.Qt.Checked:
# Install
if unicode(type.text(0)) == u'Bibles':
theme = unicode(listIterator.value().data(0,
QtCore.Qt.UserRole).toString())
urllib.urlretrieve(u'%s%s' % (self.web, theme),
os.path.join(bibleDestination, theme))
if unicode(type.text(0)) == u'Themes':
if unicode(type.text(0)) == self.biblesText:
bible = unicode(listIterator.value().data(0,
QtCore.Qt.UserRole).toString())
message = u'%s %s' % (self.downloadBible, bible)
self.__updateMessage(message)
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,
QtCore.Qt.UserRole).toString())
message = u'%s %s' % (self.downloadTheme, bible)
self.__updateMessage(message)
urllib.urlretrieve(u'%s%s' % (self.web, theme),
os.path.join(themeDestination, theme))
listIterator += 1
@ -155,3 +175,7 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard):
status = PluginStatus.Active if field.checkState() \
== QtCore.Qt.Checked else PluginStatus.Inactive
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)
self.themeSelectionComboBox.setObjectName(u'themeSelectionComboBox')
self.gridLayout.addWidget(self.themeSelectionComboBox, 1, 1, 1, 1)
self.label = QtGui.QLabel(self.DefaultsPage)
self.label.setGeometry(QtCore.QRect(40, 190, 471, 17))
self.label.setObjectName(u'label')
self.messageLabel = QtGui.QLabel(self.DefaultsPage)
self.messageLabel.setGeometry(QtCore.QRect(60, 160, 471, 17))
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)
self.retranslateUi(FirstTimeWizard)
QtCore.QMetaObject.connectSlotsByName(OpenLP.FirstTimeWizard)
QtCore.QMetaObject.connectSlotsByName(FirstTimeWizard)
def retranslateUi(self, FirstTimeWizard):
FirstTimeWizard.setWindowTitle(translate(
@ -220,5 +223,5 @@ class Ui_FirstTimeWizard(object):
'Default output display'))
self.themeSelectionLabel.setText(translate('OpenLP.FirstTimeWizard',
'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'))

View File

@ -461,7 +461,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
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
plugins.
@ -626,6 +626,9 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
self.MediaToolBox.setCurrentIndex(savedPlugin)
self.settingsForm.postSetUp()
Receiver.send_message(u'cursor_normal')
# Import themes if first time
# if firstTime:
# self.themeManagerContents.firstTime()
def setAutoLanguage(self, value):
self.LanguageGroup.setDisabled(value)

View File

@ -145,6 +145,20 @@ class ThemeManager(QtGui.QWidget):
# Last little bits of setting up
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):
"""
Triggered when Config dialog is updated.
@ -370,6 +384,7 @@ class ThemeManager(QtGui.QWidget):
'Save Theme - (%s)')) % theme,
SettingsManager.get_last_dir(self.settingsSection, 1))
path = unicode(path)
Receiver.send_message(u'cursor_busy')
if path:
SettingsManager.set_last_dir(self.settingsSection, path, 1)
themePath = os.path.join(path, theme + u'.otz')
@ -395,6 +410,7 @@ class ThemeManager(QtGui.QWidget):
finally:
if zip:
zip.close()
Receiver.send_message(u'cursor_normal')
def onImportTheme(self):
"""
@ -408,12 +424,14 @@ class ThemeManager(QtGui.QWidget):
unicode(translate('OpenLP.ThemeManager',
'OpenLP Themes (*.theme *.otz)')))
log.info(u'New Themes %s', unicode(files))
Receiver.send_message(u'cursor_busy')
if files:
for file in files:
SettingsManager.set_last_dir(
self.settingsSection, unicode(file))
self.unzipTheme(file, self.path)
self.loadThemes()
Receiver.send_message(u'cursor_normal')
def loadThemes(self):
"""