openlp/openlp/core/ui/firsttimeform.py

494 lines
22 KiB
Python
Raw Normal View History

2011-02-26 11:16:21 +00:00
# -*- coding: utf-8 -*-
2012-12-29 13:15:42 +00:00
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
2011-02-26 11:16:21 +00:00
###############################################################################
# OpenLP - Open Source Lyrics Projection #
# --------------------------------------------------------------------------- #
2012-12-29 20:56:56 +00:00
# Copyright (c) 2008-2013 Raoul Snyman #
# Portions copyright (c) 2008-2013 Tim Bentley, Gerald Britton, Jonathan #
# Corwin, Samuel Findlay, Michael Gorven, Scott Guerrieri, Matthias Hub, #
2012-11-11 21:16:14 +00:00
# Meinert Jordan, Armin Köhler, Erik Lundin, Edwin Lunando, Brian T. Meyer. #
2012-10-21 13:16:22 +00:00
# Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias Põldaru, #
# Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, #
# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Dave Warnock, #
# Frode Woldsund, Martin Zibricky, Patrick Zimmermann #
2011-02-26 11:16:21 +00:00
# --------------------------------------------------------------------------- #
# 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 #
###############################################################################
2013-02-01 20:36:27 +00:00
"""
This module contains the first time wizard.
"""
2011-03-02 19:01:18 +00:00
import io
2011-02-26 15:19:43 +00:00
import logging
2011-09-17 22:33:03 +00:00
import os
import sys
2011-12-29 12:26:37 +00:00
import time
2011-09-17 22:33:03 +00:00
import urllib
import urllib2
2011-03-10 19:48:15 +00:00
from tempfile import gettempdir
2011-03-10 13:15:49 +00:00
from ConfigParser import SafeConfigParser
2011-02-26 15:19:43 +00:00
2011-02-26 16:51:00 +00:00
from PyQt4 import QtCore, QtGui
2011-02-26 11:16:21 +00:00
2013-02-07 08:42:17 +00:00
from openlp.core.lib import PluginStatus, Settings, Registry, build_icon, check_directory_exists, translate
2013-02-05 08:05:28 +00:00
from openlp.core.utils import AppLocation, get_web_page, get_filesystem_encoding
from firsttimewizard import Ui_FirstTimeWizard, FirstTimePage
2011-02-26 11:16:21 +00:00
2011-03-06 19:44:33 +00:00
log = logging.getLogger(__name__)
2011-02-26 15:19:43 +00:00
2013-02-01 20:36:27 +00:00
2011-12-29 12:26:37 +00:00
class ThemeScreenshotThread(QtCore.QThread):
"""
This thread downloads the theme screenshots.
"""
def run(self):
2013-02-01 20:36:27 +00:00
"""
Overridden method to run the thread.
"""
2011-12-29 12:26:37 +00:00
themes = self.parent().config.get(u'themes', u'files')
themes = themes.split(u',')
config = self.parent().config
for theme in themes:
# Stop if the wizard has been cancelled.
2013-02-09 14:13:38 +00:00
if self.parent().was_download_cancelled:
return
2011-12-29 12:26:37 +00:00
title = config.get(u'theme_%s' % theme, u'title')
filename = config.get(u'theme_%s' % theme, u'filename')
screenshot = config.get(u'theme_%s' % theme, u'screenshot')
urllib.urlretrieve(u'%s%s' % (self.parent().web, screenshot),
2012-12-29 13:15:42 +00:00
os.path.join(unicode(gettempdir(), get_filesystem_encoding()), u'openlp', screenshot))
2011-12-29 12:26:37 +00:00
item = QtGui.QListWidgetItem(title, self.parent().themesListWidget)
2012-05-17 15:13:09 +00:00
item.setData(QtCore.Qt.UserRole, filename)
2011-12-29 12:26:37 +00:00
item.setCheckState(QtCore.Qt.Unchecked)
item.setFlags(item.flags() | QtCore.Qt.ItemIsUserCheckable)
2011-02-26 15:19:43 +00:00
class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard):
"""
This is the Theme Import Wizard, which allows easy creation and editing of
OpenLP themes.
"""
log.info(u'ThemeWizardForm loaded')
2011-02-26 11:16:21 +00:00
2011-03-06 19:44:33 +00:00
def __init__(self, screens, parent=None):
2013-02-01 20:36:27 +00:00
"""
Create and set up the first time wizard.
"""
super(FirstTimeForm, self).__init__(parent)
self.setupUi(self)
self.screens = screens
2011-02-26 11:16:21 +00:00
# check to see if we have web access
2011-03-04 18:22:44 +00:00
self.web = u'http://openlp.org/files/frw/'
2011-03-10 13:15:49 +00:00
self.config = SafeConfigParser()
2013-02-09 14:13:38 +00:00
self.web_access = get_web_page(u'%s%s' % (self.web, u'download.cfg'))
if self.web_access:
files = self.web_access.read()
2011-03-02 19:01:18 +00:00
self.config.readfp(io.BytesIO(files))
2013-02-07 11:33:47 +00:00
self.update_screen_list_combo()
self.was_download_cancelled = False
2012-12-29 18:13:08 +00:00
self.downloading = translate('OpenLP.FirstTimeWizard', 'Downloading %s...')
2013-03-05 13:55:50 +00:00
self.cancelButton.clicked.connect(self.onCancelButtonClicked)
self.noInternetFinishButton.clicked.connect(self.onNoInternetFinishButtonClicked)
self.currentIdChanged.connect(self.onCurrentIdChanged)
2013-02-07 11:33:47 +00:00
Registry().register_function(u'config_screen_changed', self.update_screen_list_combo)
2011-02-26 15:19:43 +00:00
2012-09-26 14:13:42 +00:00
def exec_(self):
2011-02-26 20:52:26 +00:00
"""
Run the wizard.
"""
self.setDefaults()
return QtGui.QWizard.exec_(self)
def setDefaults(self):
"""
Set up display at start of theme edit.
"""
self.restart()
2013-02-09 14:13:38 +00:00
check_directory_exists(os.path.join(unicode(gettempdir(), get_filesystem_encoding()), u'openlp'))
self.noInternetFinishButton.setVisible(False)
# Check if this is a re-run of the wizard.
self.hasRunWizard = Settings().value(u'general/has run wizard')
2011-02-27 14:29:19 +00:00
# Sort out internet access for downloads
2013-02-09 14:13:38 +00:00
if self.web_access:
2011-03-10 13:15:49 +00:00
songs = self.config.get(u'songs', u'languages')
songs = songs.split(u',')
for song in songs:
2012-12-29 13:15:42 +00:00
title = unicode(self.config.get(u'songs_%s' % song, u'title'), u'utf8')
filename = unicode(self.config.get(u'songs_%s' % song, u'filename'), u'utf8')
2011-03-10 13:15:49 +00:00
item = QtGui.QListWidgetItem(title, self.songsListWidget)
2012-05-17 15:13:09 +00:00
item.setData(QtCore.Qt.UserRole, filename)
2011-03-10 13:15:49 +00:00
item.setCheckState(QtCore.Qt.Unchecked)
item.setFlags(item.flags() | QtCore.Qt.ItemIsUserCheckable)
bible_languages = self.config.get(u'bibles', u'languages')
bible_languages = bible_languages.split(u',')
2011-03-10 19:48:15 +00:00
for lang in bible_languages:
2012-12-29 13:15:42 +00:00
language = unicode(self.config.get(u'bibles_%s' % lang, u'title'), u'utf8')
langItem = QtGui.QTreeWidgetItem(self.biblesTreeWidget, [language])
2011-03-10 13:15:49 +00:00
bibles = self.config.get(u'bibles_%s' % lang, u'translations')
bibles = bibles.split(u',')
for bible in bibles:
2012-12-29 13:15:42 +00:00
title = unicode(self.config.get(u'bible_%s' % bible, u'title'), u'utf8')
filename = unicode(self.config.get(u'bible_%s' % bible, u'filename'))
2012-05-19 15:10:05 +00:00
item = QtGui.QTreeWidgetItem(langItem, [title])
2012-05-17 15:13:09 +00:00
item.setData(0, QtCore.Qt.UserRole, filename)
2011-03-10 13:15:49 +00:00
item.setCheckState(0, QtCore.Qt.Unchecked)
item.setFlags(item.flags() | QtCore.Qt.ItemIsUserCheckable)
self.biblesTreeWidget.expandAll()
2011-12-29 12:26:37 +00:00
# Download the theme screenshots.
self.themeScreenshotThread = ThemeScreenshotThread(self)
self.themeScreenshotThread.start()
2013-02-03 19:23:12 +00:00
self.application.set_normal_cursor()
2011-02-26 20:52:26 +00:00
def nextId(self):
"""
Determine the next page in the Wizard to go to.
"""
2013-02-03 19:23:12 +00:00
self.application.process_events()
if self.currentId() == FirstTimePage.Plugins:
2013-02-09 14:13:38 +00:00
if not self.web_access:
return FirstTimePage.NoInternet
else:
return FirstTimePage.Songs
2011-03-11 10:20:09 +00:00
elif self.currentId() == FirstTimePage.Progress:
return -1
elif self.currentId() == FirstTimePage.NoInternet:
return FirstTimePage.Progress
2011-12-29 12:26:37 +00:00
elif self.currentId() == FirstTimePage.Themes:
2013-02-03 19:23:12 +00:00
self.application.set_busy_cursor()
2011-12-29 12:26:37 +00:00
while not self.themeScreenshotThread.isFinished():
time.sleep(0.1)
2013-02-03 19:23:12 +00:00
self.application.process_events()
2011-12-29 12:26:37 +00:00
# Build the screenshot icons, as this can not be done in the thread.
2011-12-29 19:41:25 +00:00
self._buildThemeScreenshots()
2013-02-03 19:23:12 +00:00
self.application.set_normal_cursor()
2011-12-29 12:26:37 +00:00
return FirstTimePage.Defaults
else:
return self.currentId() + 1
2011-03-07 19:58:51 +00:00
def onCurrentIdChanged(self, pageId):
2011-03-02 21:47:55 +00:00
"""
Detects Page changes and updates as appropriate.
2011-03-02 21:47:55 +00:00
"""
# Keep track of the page we are at. Triggering "Cancel" causes pageId
# to be a -1.
2013-02-03 19:23:12 +00:00
self.application.process_events()
if pageId != -1:
self.lastId = pageId
if pageId == FirstTimePage.Plugins:
# Set the no internet page text.
if self.hasRunWizard:
self.noInternetLabel.setText(self.noInternetText)
else:
2012-12-29 13:15:42 +00:00
self.noInternetLabel.setText(self.noInternetText + self.cancelWizardText)
elif pageId == FirstTimePage.Defaults:
2011-03-10 13:15:49 +00:00
self.themeComboBox.clear()
2011-03-10 19:48:15 +00:00
for iter in xrange(self.themesListWidget.count()):
item = self.themesListWidget.item(iter)
if item.checkState() == QtCore.Qt.Checked:
self.themeComboBox.addItem(item.text())
if self.hasRunWizard:
# Add any existing themes to list.
2013-02-02 07:34:42 +00:00
for theme in self.theme_manager.get_themes():
index = self.themeComboBox.findText(theme)
if index == -1:
self.themeComboBox.addItem(theme)
default_theme = Settings().value(u'themes/global theme')
# Pre-select the current default theme.
index = self.themeComboBox.findText(default_theme)
self.themeComboBox.setCurrentIndex(index)
elif pageId == FirstTimePage.NoInternet:
self.backButton.setVisible(False)
self.nextButton.setVisible(False)
self.noInternetFinishButton.setVisible(True)
if self.hasRunWizard:
self.cancelButton.setVisible(False)
2011-03-11 10:20:09 +00:00
elif pageId == FirstTimePage.Progress:
2013-02-03 19:23:12 +00:00
self.application.set_busy_cursor()
self.repaint()
2013-02-03 19:23:12 +00:00
self.application.process_events()
# Try to give the wizard a chance to redraw itself
time.sleep(0.2)
2011-03-11 10:20:09 +00:00
self._preWizard()
self._performWizard()
self._postWizard()
2013-02-03 19:23:12 +00:00
self.application.set_normal_cursor()
2011-03-02 21:47:55 +00:00
2013-02-07 11:33:47 +00:00
def update_screen_list_combo(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())
2011-03-21 11:51:14 +00:00
self.displayComboBox.setCurrentIndex(self.displayComboBox.count() - 1)
def onCancelButtonClicked(self):
"""
Process the triggering of the cancel button.
"""
2013-02-09 14:13:38 +00:00
if self.lastId == FirstTimePage.NoInternet or (self.lastId <= FirstTimePage.Plugins and not self.hasRunWizard):
QtCore.QCoreApplication.exit()
sys.exit()
self.was_download_cancelled = True
while self.themeScreenshotThread.isRunning():
time.sleep(0.1)
2013-02-03 19:23:12 +00:00
self.application.set_normal_cursor()
def onNoInternetFinishButtonClicked(self):
"""
Process the triggering of the "Finish" button on the No Internet page.
"""
2013-02-03 19:23:12 +00:00
self.application.set_busy_cursor()
self._performWizard()
2013-02-03 19:23:12 +00:00
self.application.set_normal_cursor()
2012-05-17 15:13:09 +00:00
Settings().setValue(u'general/has run wizard', True)
self.close()
def urlGetFile(self, url, fpath):
""""
Download a file given a URL. The file is retrieved in chunks, giving
the ability to cancel the download at any point.
"""
block_count = 0
block_size = 4096
urlfile = urllib2.urlopen(url)
filename = open(fpath, "wb")
# Download until finished or canceled.
while not self.was_download_cancelled:
data = urlfile.read(block_size)
if not data:
break
filename.write(data)
block_count += 1
2012-09-26 14:13:42 +00:00
self._downloadProgress(block_count, block_size)
filename.close()
# Delete file if cancelled, it may be a partial file.
if self.was_download_cancelled:
os.remove(fpath)
2011-12-29 19:41:25 +00:00
def _buildThemeScreenshots(self):
2011-12-29 12:26:37 +00:00
"""
This method builds the theme screenshots' icons for all items in the
``self.themesListWidget``.
"""
themes = self.config.get(u'themes', u'files')
themes = themes.split(u',')
for theme in themes:
filename = self.config.get(u'theme_%s' % theme, u'filename')
screenshot = self.config.get(u'theme_%s' % theme, u'screenshot')
for index in xrange(self.themesListWidget.count()):
item = self.themesListWidget.item(index)
2012-05-17 15:13:09 +00:00
if item.data(QtCore.Qt.UserRole) == filename:
2011-12-29 12:26:37 +00:00
break
2013-02-05 21:42:15 +00:00
item.setIcon(build_icon(os.path.join(unicode(gettempdir(),
get_filesystem_encoding()), u'openlp', screenshot)))
2011-12-29 12:26:37 +00:00
2011-03-17 13:03:57 +00:00
def _getFileSize(self, url):
2013-02-01 20:36:27 +00:00
"""
Get the size of a file.
``url``
The URL of the file we want to download.
"""
2011-03-17 13:03:57 +00:00
site = urllib.urlopen(url)
meta = site.info()
return int(meta.getheaders("Content-Length")[0])
2012-09-26 14:13:42 +00:00
def _downloadProgress(self, count, block_size):
2013-02-01 20:36:27 +00:00
"""
Calculate and display the download progress.
"""
2011-03-17 13:03:57 +00:00
increment = (count * block_size) - self.previous_size
self._incrementProgressBar(None, increment)
self.previous_size = count * block_size
2011-12-29 12:26:37 +00:00
2011-03-11 10:20:09 +00:00
def _incrementProgressBar(self, status_text, increment=1):
"""
Update the wizard progress page.
``status_text``
Current status information to display.
``increment``
The value to increment the progress bar by.
"""
if status_text:
self.progressLabel.setText(status_text)
if increment > 0:
self.progressBar.setValue(self.progressBar.value() + increment)
2013-02-03 19:23:12 +00:00
self.application.process_events()
2011-03-11 10:20:09 +00:00
def _preWizard(self):
"""
Prepare the UI for the process.
"""
2011-06-09 22:03:30 +00:00
self.max_progress = 0
self.finishButton.setVisible(False)
2013-02-03 19:23:12 +00:00
self.application.process_events()
2011-03-11 10:20:09 +00:00
# Loop through the songs list and increase for each selected item
for i in xrange(self.songsListWidget.count()):
2013-02-03 19:23:12 +00:00
self.application.process_events()
2011-03-17 13:03:57 +00:00
item = self.songsListWidget.item(i)
if item.checkState() == QtCore.Qt.Checked:
2012-05-19 15:10:05 +00:00
filename = item.data(QtCore.Qt.UserRole)
2011-03-17 13:03:57 +00:00
size = self._getFileSize(u'%s%s' % (self.web, filename))
2011-06-09 22:03:30 +00:00
self.max_progress += size
2011-03-11 10:20:09 +00:00
# Loop through the Bibles list and increase for each selected item
iterator = QtGui.QTreeWidgetItemIterator(self.biblesTreeWidget)
while iterator.value():
2013-02-03 19:23:12 +00:00
self.application.process_events()
2011-03-11 10:20:09 +00:00
item = iterator.value()
if item.parent() and item.checkState(0) == QtCore.Qt.Checked:
2012-05-19 15:10:05 +00:00
filename = item.data(0, QtCore.Qt.UserRole)
2011-03-17 13:03:57 +00:00
size = self._getFileSize(u'%s%s' % (self.web, filename))
2011-06-09 22:03:30 +00:00
self.max_progress += size
2011-03-11 10:20:09 +00:00
iterator += 1
# Loop through the themes list and increase for each selected item
for i in xrange(self.themesListWidget.count()):
2013-02-03 19:23:12 +00:00
self.application.process_events()
2011-03-17 13:03:57 +00:00
item = self.themesListWidget.item(i)
if item.checkState() == QtCore.Qt.Checked:
2012-05-19 15:10:05 +00:00
filename = item.data(QtCore.Qt.UserRole)
2011-03-17 13:03:57 +00:00
size = self._getFileSize(u'%s%s' % (self.web, filename))
2011-06-09 22:03:30 +00:00
self.max_progress += size
if self.max_progress:
# Add on 2 for plugins status setting plus a "finished" point.
2013-02-04 21:26:27 +00:00
self.max_progress += 2
2011-06-09 22:03:30 +00:00
self.progressBar.setValue(0)
self.progressBar.setMinimum(0)
self.progressBar.setMaximum(self.max_progress)
2012-12-29 13:15:42 +00:00
self.progressPage.setTitle(translate('OpenLP.FirstTimeWizard', 'Setting Up And Downloading'))
self.progressPage.setSubTitle(
translate('OpenLP.FirstTimeWizard', 'Please wait while OpenLP is set up and your data is downloaded.'))
2011-06-09 22:03:30 +00:00
else:
self.progressBar.setVisible(False)
2012-12-29 13:15:42 +00:00
self.progressPage.setTitle(translate('OpenLP.FirstTimeWizard', 'Setting Up'))
2011-06-09 22:03:30 +00:00
self.progressPage.setSubTitle(u'Setup complete.')
self.repaint()
2013-02-03 19:23:12 +00:00
self.application.process_events()
# Try to give the wizard a chance to repaint itself
time.sleep(0.1)
2011-03-11 10:20:09 +00:00
def _postWizard(self):
"""
Clean up the UI after the process has finished.
"""
2011-06-09 22:03:30 +00:00
if self.max_progress:
self.progressBar.setValue(self.progressBar.maximum())
if self.hasRunWizard:
self.progressLabel.setText(translate('OpenLP.FirstTimeWizard',
2012-12-29 18:13:08 +00:00
'Download complete. Click the finish button to return to OpenLP.'))
else:
self.progressLabel.setText(translate('OpenLP.FirstTimeWizard',
2012-12-29 13:15:42 +00:00
'Download complete. Click the finish button to start OpenLP.'))
2011-06-09 22:03:30 +00:00
else:
if self.hasRunWizard:
self.progressLabel.setText(translate('OpenLP.FirstTimeWizard',
'Click the finish button to return to OpenLP.'))
else:
self.progressLabel.setText(translate('OpenLP.FirstTimeWizard',
'Click the finish button to start OpenLP.'))
2011-03-11 10:20:09 +00:00
self.finishButton.setVisible(True)
self.finishButton.setEnabled(True)
self.cancelButton.setVisible(False)
self.nextButton.setVisible(False)
2013-02-03 19:23:12 +00:00
self.application.process_events()
2011-03-11 10:20:09 +00:00
def _performWizard(self):
"""
Run the tasks in the wizard.
"""
# Set plugin states
2012-12-29 13:15:42 +00:00
self._incrementProgressBar(translate('OpenLP.FirstTimeWizard', 'Enabling selected plugins...'))
2011-03-11 10:20:09 +00:00
self._setPluginStatus(self.songsCheckBox, u'songs/status')
self._setPluginStatus(self.bibleCheckBox, u'bibles/status')
2012-10-17 22:00:44 +00:00
# TODO Presentation plugin is not yet working on Mac OS X.
# For now just ignore it.
if sys.platform != 'darwin':
2012-12-29 13:15:42 +00:00
self._setPluginStatus(self.presentationCheckBox, u'presentations/status')
2011-03-11 10:20:09 +00:00
self._setPluginStatus(self.imageCheckBox, u'images/status')
self._setPluginStatus(self.mediaCheckBox, u'media/status')
self._setPluginStatus(self.remoteCheckBox, u'remotes/status')
self._setPluginStatus(self.customCheckBox, u'custom/status')
self._setPluginStatus(self.songUsageCheckBox, u'songusage/status')
self._setPluginStatus(self.alertCheckBox, u'alerts/status')
2013-02-09 14:13:38 +00:00
if self.web_access:
# Build directories for downloads
2012-06-22 20:12:43 +00:00
songs_destination = os.path.join(
unicode(gettempdir(), get_filesystem_encoding()), u'openlp')
bibles_destination = AppLocation.get_section_data_path(u'bibles')
themes_destination = AppLocation.get_section_data_path(u'themes')
# Download songs
for i in xrange(self.songsListWidget.count()):
item = self.songsListWidget.item(i)
if item.checkState() == QtCore.Qt.Checked:
2012-05-19 15:10:05 +00:00
filename = item.data(QtCore.Qt.UserRole)
self._incrementProgressBar(self.downloading % filename, 0)
self.previous_size = 0
2012-12-29 13:15:42 +00:00
destination = os.path.join(songs_destination, unicode(filename))
self.urlGetFile(u'%s%s' % (self.web, filename), destination)
# Download Bibles
bibles_iterator = QtGui.QTreeWidgetItemIterator(
self.biblesTreeWidget)
while bibles_iterator.value():
item = bibles_iterator.value()
if item.parent() and item.checkState(0) == QtCore.Qt.Checked:
2012-05-19 15:10:05 +00:00
bible = item.data(0, QtCore.Qt.UserRole)
self._incrementProgressBar(self.downloading % bible, 0)
self.previous_size = 0
2012-12-29 13:15:42 +00:00
self.urlGetFile(u'%s%s' % (self.web, bible), os.path.join(bibles_destination, bible))
bibles_iterator += 1
# Download themes
for i in xrange(self.themesListWidget.count()):
item = self.themesListWidget.item(i)
if item.checkState() == QtCore.Qt.Checked:
2012-05-19 15:10:05 +00:00
theme = item.data(QtCore.Qt.UserRole)
self._incrementProgressBar(self.downloading % theme, 0)
self.previous_size = 0
2012-12-29 13:15:42 +00:00
self.urlGetFile(u'%s%s' % (self.web, theme), os.path.join(themes_destination, theme))
2011-03-06 13:44:35 +00:00
# Set Default Display
2011-03-10 13:15:49 +00:00
if self.displayComboBox.currentIndex() != -1:
2012-12-29 13:15:42 +00:00
Settings().setValue(u'General/monitor', self.displayComboBox.currentIndex())
self.screens.set_current_display(self.displayComboBox.currentIndex())
2011-03-06 13:44:35 +00:00
# Set Global Theme
2011-03-10 13:15:49 +00:00
if self.themeComboBox.currentIndex() != -1:
2012-12-29 13:15:42 +00:00
Settings().setValue(u'themes/global theme', self.themeComboBox.currentText())
2011-02-26 16:51:00 +00:00
2011-03-11 10:20:09 +00:00
def _setPluginStatus(self, field, tag):
2013-02-01 20:36:27 +00:00
"""
Set the status of a plugin.
"""
2012-12-29 13:15:42 +00:00
status = PluginStatus.Active if field.checkState() == QtCore.Qt.Checked else PluginStatus.Inactive
2012-05-17 15:13:09 +00:00
Settings().setValue(tag, status)
2013-02-02 07:34:42 +00:00
def _get_theme_manager(self):
"""
Adds the theme manager to the class dynamically
"""
if not hasattr(self, u'_theme_manager'):
self._theme_manager = Registry().get(u'theme_manager')
return self._theme_manager
theme_manager = property(_get_theme_manager)
2013-02-03 09:07:31 +00:00
2013-02-03 19:23:12 +00:00
def _get_application(self):
2013-02-03 09:07:31 +00:00
"""
Adds the openlp to the class dynamically
"""
2013-02-03 19:23:12 +00:00
if not hasattr(self, u'_application'):
self._application = Registry().get(u'application')
return self._application
2013-02-03 09:07:31 +00:00
2013-02-03 19:23:12 +00:00
application = property(_get_application)