From 2d99f59c843d08baaaf6302fe79ab86a4d2c9cac Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Thu, 17 May 2012 17:13:09 +0200 Subject: [PATCH 01/53] started to use QString v2 api --- openlp.pyw | 2 + openlp/core/__init__.py | 20 ++- openlp/core/lib/__init__.py | 16 +++ openlp/core/lib/db.py | 18 ++- openlp/core/lib/formattingtags.py | 9 +- openlp/core/lib/mediamanageritem.py | 11 +- openlp/core/lib/plugin.py | 12 +- openlp/core/lib/settingsmanager.py | 27 ++-- openlp/core/lib/ui.py | 3 +- openlp/core/ui/advancedtab.py | 70 +++++----- openlp/core/ui/firsttimeform.py | 46 ++++--- openlp/core/ui/generaltab.py | 103 +++++++-------- openlp/core/ui/maindisplay.py | 36 +++--- openlp/core/ui/mainwindow.py | 121 ++++++++---------- openlp/core/ui/media/__init__.py | 16 ++- openlp/core/ui/media/mediacontroller.py | 5 +- openlp/core/ui/media/vlcplayer.py | 5 +- openlp/core/ui/printserviceform.py | 31 ++--- openlp/core/ui/screen.py | 24 ++-- openlp/core/ui/servicemanager.py | 58 ++++----- openlp/core/ui/shortcutlistform.py | 10 +- openlp/core/ui/slidecontroller.py | 52 ++++---- openlp/core/ui/themeform.py | 79 +++++------- openlp/core/ui/thememanager.py | 24 ++-- openlp/core/ui/themestab.py | 23 ++-- openlp/core/utils/__init__.py | 8 +- openlp/core/utils/actions.py | 7 +- openlp/core/utils/languagemanager.py | 23 ++-- openlp/plugins/alerts/alertsplugin.py | 7 +- openlp/plugins/alerts/forms/alertform.py | 2 +- openlp/plugins/alerts/lib/alertstab.py | 36 +++--- openlp/plugins/bibles/bibleplugin.py | 7 +- .../plugins/bibles/forms/bibleimportform.py | 38 +++--- .../plugins/bibles/forms/bibleupgradeform.py | 4 +- openlp/plugins/bibles/lib/__init__.py | 12 +- openlp/plugins/bibles/lib/biblestab.py | 41 +++--- openlp/plugins/bibles/lib/manager.py | 21 ++- openlp/plugins/bibles/lib/mediaitem.py | 82 ++++++------ openlp/plugins/custom/lib/customtab.py | 11 +- openlp/plugins/custom/lib/mediaitem.py | 19 ++- openlp/plugins/images/imageplugin.py | 8 +- openlp/plugins/images/lib/imagetab.py | 11 +- openlp/plugins/images/lib/mediaitem.py | 13 +- openlp/plugins/media/lib/mediaitem.py | 4 +- openlp/plugins/media/lib/mediatab.py | 13 +- openlp/plugins/media/mediaplugin.py | 8 +- openlp/plugins/presentations/lib/mediaitem.py | 8 +- .../lib/presentationcontroller.py | 8 +- .../presentations/lib/presentationtab.py | 23 ++-- openlp/plugins/remotes/lib/httpserver.py | 25 ++-- openlp/plugins/remotes/lib/remotetab.py | 35 +++-- openlp/plugins/songs/forms/editsongform.py | 34 ++--- openlp/plugins/songs/forms/songexportform.py | 10 +- openlp/plugins/songs/forms/songimportform.py | 6 +- .../songs/forms/songmaintenanceform.py | 6 +- openlp/plugins/songs/lib/mediaitem.py | 43 +++---- openlp/plugins/songs/lib/songstab.py | 28 ++-- .../songusage/forms/songusagedetailform.py | 19 ++- openlp/plugins/songusage/songusageplugin.py | 13 +- 59 files changed, 668 insertions(+), 786 deletions(-) diff --git a/openlp.pyw b/openlp.pyw index cc58c6a21..41462b3cf 100755 --- a/openlp.pyw +++ b/openlp.pyw @@ -26,6 +26,8 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### +import sip +sip.setapi(u'QString', 2) # Import uuid now, to avoid the rare bug described in the support system: # http://support.openlp.org/issues/102 # If https://bugs.gentoo.org/show_bug.cgi?id=317557 is fixed, the import can be diff --git a/openlp/core/__init__.py b/openlp/core/__init__.py index 71c27a1d0..5d0bb1e0e 100644 --- a/openlp/core/__init__.py +++ b/openlp/core/__init__.py @@ -40,7 +40,7 @@ from traceback import format_exception from PyQt4 import QtCore, QtGui -from openlp.core.lib import Receiver, check_directory_exists +from openlp.core.lib import Receiver, Settings, check_directory_exists, Settings from openlp.core.lib.ui import UiStrings from openlp.core.resources import qInitResources from openlp.core.ui.mainwindow import MainWindow @@ -78,7 +78,6 @@ QToolBar } """ - class OpenLP(QtGui.QApplication): """ The core application class. This class inherits from Qt's QApplication @@ -98,6 +97,7 @@ class OpenLP(QtGui.QApplication): """ Run the OpenLP application. """ + # On Windows, the args passed into the constructor are # ignored. Not very handy, so set the ones we want to use. self.args.extend(args) @@ -111,16 +111,14 @@ class OpenLP(QtGui.QApplication): # Decide how many screens we have and their size screens = ScreenList(self.desktop()) # First time checks in settings - has_run_wizard = QtCore.QSettings().value( - u'general/has run wizard', QtCore.QVariant(False)).toBool() + has_run_wizard = Settings().value( + u'general/has run wizard', False) if not has_run_wizard: if FirstTimeForm(screens).exec_() == QtGui.QDialog.Accepted: - QtCore.QSettings().setValue(u'general/has run wizard', - QtCore.QVariant(True)) + Settings().setValue(u'general/has run wizard', True) if os.name == u'nt': self.setStyleSheet(application_stylesheet) - show_splash = QtCore.QSettings().value( - u'general/show splash', QtCore.QVariant(True)).toBool() + show_splash = Settings().value(u'general/show splash', True) if show_splash: self.splash = SplashScreen() self.splash.show() @@ -139,8 +137,7 @@ class OpenLP(QtGui.QApplication): self.processEvents() if not has_run_wizard: self.mainWindow.firstTime() - update_check = QtCore.QSettings().value( - u'general/update check', QtCore.QVariant(True)).toBool() + update_check = Settings().value(u'general/update check', True) if update_check: VersionThread(self.mainWindow).start() Receiver.send_message(u'live_display_blank_check') @@ -264,8 +261,7 @@ def main(args=None): if app.isAlreadyRunning(): sys.exit() # First time checks in settings - if not QtCore.QSettings().value(u'general/has run wizard', - QtCore.QVariant(False)).toBool(): + if not Settings().value(u'general/has run wizard', False): if not FirstTimeLanguageForm().exec_(): # if cancel then stop processing sys.exit() diff --git a/openlp/core/lib/__init__.py b/openlp/core/lib/__init__.py index 9af8debb8..d16adda3c 100644 --- a/openlp/core/lib/__init__.py +++ b/openlp/core/lib/__init__.py @@ -63,6 +63,22 @@ class ServiceItemAction(object): Next = 3 +class Settings(QtCore.QSettings): + def __init__(self, *args): + QtCore.QSettings.__init__(self, *args) + import copy + self.value_ = copy.deepcopy(self.value) + self.value = copy.deepcopy(self.value2) + + def value2(self, key, defaultValue): + setting = self.value_(key, defaultValue) + if isinstance(defaultValue, int): + return setting.toInt()[0] + if isinstance(defaultValue, basestring): + return setting.toString() + if isinstance(defaultValue, bool): + return setting.toBool() + def translate(context, text, comment=None, encoding=QtCore.QCoreApplication.CodecForTr, n=-1, translate=QtCore.QCoreApplication.translate): diff --git a/openlp/core/lib/db.py b/openlp/core/lib/db.py index e097983eb..0af1fe995 100644 --- a/openlp/core/lib/db.py +++ b/openlp/core/lib/db.py @@ -38,7 +38,7 @@ from sqlalchemy.exc import SQLAlchemyError, InvalidRequestError, DBAPIError, \ from sqlalchemy.orm import scoped_session, sessionmaker, mapper from sqlalchemy.pool import NullPool -from openlp.core.lib import translate +from openlp.core.lib import translate, Settings from openlp.core.lib.ui import critical_error_message_box from openlp.core.utils import AppLocation, delete_file @@ -179,13 +179,12 @@ class Manager(object): The file name to use for this database. Defaults to None resulting in the plugin_name being used. """ - settings = QtCore.QSettings() + settings = Settings() settings.beginGroup(plugin_name) self.db_url = u'' self.is_dirty = False self.session = None - db_type = unicode( - settings.value(u'db type', QtCore.QVariant(u'sqlite')).toString()) + db_type = unicode(settings.value(u'db type', u'sqlite')) if db_type == u'sqlite': if db_file_name: self.db_url = u'sqlite:///%s/%s' % ( @@ -196,13 +195,12 @@ class Manager(object): AppLocation.get_section_data_path(plugin_name), plugin_name) else: self.db_url = u'%s://%s:%s@%s/%s' % (db_type, - urlquote(unicode(settings.value(u'db username').toString())), - urlquote(unicode(settings.value(u'db password').toString())), - urlquote(unicode(settings.value(u'db hostname').toString())), - urlquote(unicode(settings.value(u'db database').toString()))) + urlquote(unicode(settings.value(u'db username'))), + urlquote(unicode(settings.value(u'db password'))), + urlquote(unicode(settings.value(u'db hostname'))), + urlquote(unicode(settings.value(u'db database')))) if db_type == u'mysql': - db_encoding = unicode( - settings.value(u'db encoding', u'utf8').toString()) + db_encoding = unicode(settings.value(u'db encoding', u'utf8')) self.db_url += u'?charset=%s' % urlquote(db_encoding) settings.endGroup() if upgrade_mod: diff --git a/openlp/core/lib/formattingtags.py b/openlp/core/lib/formattingtags.py index 11fd898c3..2404f3ad7 100644 --- a/openlp/core/lib/formattingtags.py +++ b/openlp/core/lib/formattingtags.py @@ -31,7 +31,7 @@ import cPickle from PyQt4 import QtCore -from openlp.core.lib import translate +from openlp.core.lib import translate, Settings class FormattingTags(object): @@ -68,8 +68,8 @@ class FormattingTags(object): if isinstance(tag[element], unicode): tag[element] = tag[element].encode('utf8') # Formatting Tags were also known as display tags. - QtCore.QSettings().setValue(u'displayTags/html_tags', - QtCore.QVariant(cPickle.dumps(tags) if tags else u'')) + Settings().setValue(u'displayTags/html_tags', + cPickle.dumps(tags) if tags else u'') @staticmethod def load_tags(): @@ -164,8 +164,7 @@ class FormattingTags(object): FormattingTags.add_html_tags(temporary_tags) # Formatting Tags were also known as display tags. - user_expands = QtCore.QSettings().value(u'displayTags/html_tags', - QtCore.QVariant(u'')).toString() + user_expands = Settings().value(u'displayTags/html_tags', u'') # cPickle only accepts str not unicode strings user_expands_string = str(user_expands) if user_expands_string: diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index 9bd6fc2a7..aee0af32d 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -34,7 +34,7 @@ import re from PyQt4 import QtCore, QtGui from openlp.core.lib import SettingsManager, OpenLPToolbar, ServiceItem, \ - StringContent, build_icon, translate, Receiver, ListWidgetWithDnD + StringContent, build_icon, translate, Receiver, ListWidgetWithDnD, Settings from openlp.core.lib.searchedit import SearchEdit from openlp.core.lib.ui import UiStrings, create_widget_action, \ critical_error_message_box @@ -462,8 +462,7 @@ class MediaManagerItem(QtGui.QWidget): """ Allows the list click action to be determined dynamically """ - if QtCore.QSettings().value(u'advanced/double click live', - QtCore.QVariant(False)).toBool(): + if Settings().value(u'advanced/double click live', False): self.onLiveClick() else: self.onPreviewClick() @@ -472,8 +471,8 @@ class MediaManagerItem(QtGui.QWidget): """ Allows the change of current item in the list to be actioned """ - if QtCore.QSettings().value(u'advanced/single click preview', - QtCore.QVariant(False)).toBool() and self.quickPreviewAllowed \ + if Settings().value(u'advanced/single click preview', + False) and self.quickPreviewAllowed \ and self.listView.selectedIndexes() \ and self.autoSelectId == -1: self.onPreviewClick(True) @@ -521,7 +520,7 @@ class MediaManagerItem(QtGui.QWidget): def createItemFromId(self, item_id): item = QtGui.QListWidgetItem() - item.setData(QtCore.Qt.UserRole, QtCore.QVariant(item_id)) + item.setData(QtCore.Qt.UserRole, item_id) return item def onAddClick(self): diff --git a/openlp/core/lib/plugin.py b/openlp/core/lib/plugin.py index a27e496cf..e060b4f85 100644 --- a/openlp/core/lib/plugin.py +++ b/openlp/core/lib/plugin.py @@ -31,7 +31,7 @@ import logging from PyQt4 import QtCore -from openlp.core.lib import Receiver +from openlp.core.lib import Receiver, Settings from openlp.core.lib.ui import UiStrings from openlp.core.utils import get_application_version @@ -190,17 +190,17 @@ class Plugin(QtCore.QObject): """ Sets the status of the plugin """ - self.status = QtCore.QSettings().value( - self.settingsSection + u'/status', - QtCore.QVariant(PluginStatus.Inactive)).toInt()[0] + #TODO: check if [0] is needed. + self.status = Settings().value( + self.settingsSection + u'/status', PluginStatus.Inactive) def toggleStatus(self, new_status): """ Changes the status of the plugin and remembers it """ self.status = new_status - QtCore.QSettings().setValue( - self.settingsSection + u'/status', QtCore.QVariant(self.status)) + Settings().setValue( + self.settingsSection + u'/status', self.status) if new_status == PluginStatus.Active: self.initialise() elif new_status == PluginStatus.Inactive: diff --git a/openlp/core/lib/settingsmanager.py b/openlp/core/lib/settingsmanager.py index 0fc4cac96..a77df513f 100644 --- a/openlp/core/lib/settingsmanager.py +++ b/openlp/core/lib/settingsmanager.py @@ -34,6 +34,7 @@ import os from PyQt4 import QtCore +from openlp.core.lib import Settings from openlp.core.utils import AppLocation class SettingsManager(object): @@ -58,9 +59,7 @@ class SettingsManager(object): name = u'last directory %d' % num else: name = u'last directory' - last_dir = unicode(QtCore.QSettings().value( - section + u'/' + name, QtCore.QVariant(u'')).toString()) - return last_dir + return unicode(Settings().value(section + u'/' + name, u'')) @staticmethod def set_last_dir(section, directory, num=None): @@ -81,8 +80,7 @@ class SettingsManager(object): name = u'last directory %d' % num else: name = u'last directory' - QtCore.QSettings().setValue( - section + u'/' + name, QtCore.QVariant(directory)) + Settings().setValue(section + u'/' + name, directory) @staticmethod def set_list(section, name, list): @@ -98,15 +96,14 @@ class SettingsManager(object): ``list`` The list of values to save. """ - settings = QtCore.QSettings() + settings = Settings() settings.beginGroup(section) - old_count = settings.value( - u'%s count' % name, QtCore.QVariant(0)).toInt()[0] + #TODO: check if [0] is needed. + old_count = settings.value(u'%s count' % name, 0) new_count = len(list) - settings.setValue(u'%s count' % name, QtCore.QVariant(new_count)) + settings.setValue(u'%s count' % name, new_count) for counter in range(new_count): - settings.setValue( - u'%s %d' % (name, counter), QtCore.QVariant(list[counter-1])) + settings.setValue(u'%s %d' % (name, counter), list[counter - 1]) if old_count > new_count: # Tidy up any old list items for counter in range(new_count, old_count): @@ -124,15 +121,13 @@ class SettingsManager(object): ``name`` The name of the list. """ - settings = QtCore.QSettings() + settings = Settings() settings.beginGroup(section) - list_count = settings.value( - u'%s count' % name, QtCore.QVariant(0)).toInt()[0] + list_count = settings.value(u'%s count' % name, 0) list = [] if list_count: for counter in range(list_count): - item = unicode( - settings.value(u'%s %d' % (name, counter)).toString()) + item = unicode(settings.value(u'%s %d' % (name, counter))) if item: list.append(item) settings.endGroup() diff --git a/openlp/core/lib/ui.py b/openlp/core/lib/ui.py index c4b1181b1..3f81af279 100644 --- a/openlp/core/lib/ui.py +++ b/openlp/core/lib/ui.py @@ -365,6 +365,7 @@ def create_action(parent, name, **kwargs): ``separator`` True in case the action will be considered a separator. + #FIXME: check ``data`` Data which is set as QVariant type. @@ -400,7 +401,7 @@ def create_action(parent, name, **kwargs): if kwargs.pop(u'separator', False): action.setSeparator(True) if u'data' in kwargs: - action.setData(QtCore.QVariant(kwargs.pop(u'data'))) + action.setData(kwargs.pop(u'data')) if kwargs.get(u'shortcuts'): action.setShortcuts(kwargs.pop(u'shortcuts')) if u'context' in kwargs: diff --git a/openlp/core/ui/advancedtab.py b/openlp/core/ui/advancedtab.py index 8b60a55ee..d44758c22 100644 --- a/openlp/core/ui/advancedtab.py +++ b/openlp/core/ui/advancedtab.py @@ -31,7 +31,8 @@ from datetime import datetime, timedelta from PyQt4 import QtCore, QtGui -from openlp.core.lib import SettingsTab, translate, build_icon, Receiver +from openlp.core.lib import Receiver, Settings, SettingsTab, translate, \ + build_icon from openlp.core.lib.ui import UiStrings from openlp.core.lib import SlideLimits from openlp.core.utils import get_images_filter @@ -340,56 +341,52 @@ class AdvancedTab(SettingsTab): """ Load settings from disk. """ - settings = QtCore.QSettings() + settings = Settings() settings.beginGroup(self.settingsSection) # The max recent files value does not have an interface and so never # gets actually stored in the settings therefore the default value of # 20 will always be used. - self.recentSpinBox.setMaximum(QtCore.QSettings().value( - u'max recent files', QtCore.QVariant(20)).toInt()[0]) + self.recentSpinBox.setMaximum(Settings().value( + u'max recent files', 20)) self.recentSpinBox.setValue(settings.value(u'recent file count', - QtCore.QVariant(4)).toInt()[0]) + 4)) self.mediaPluginCheckBox.setChecked( settings.value(u'save current plugin', - QtCore.QVariant(False)).toBool()) + False)) self.doubleClickLiveCheckBox.setChecked( settings.value(u'double click live', - QtCore.QVariant(False)).toBool()) + False)) self.singleClickPreviewCheckBox.setChecked( settings.value(u'single click preview', - QtCore.QVariant(False)).toBool()) + False)) self.expandServiceItemCheckBox.setChecked( settings.value(u'expand service item', - QtCore.QVariant(False)).toBool()) + False)) self.enableAutoCloseCheckBox.setChecked( settings.value(u'enable exit confirmation', - QtCore.QVariant(True)).toBool()) + True)) self.hideMouseCheckBox.setChecked( - settings.value(u'hide mouse', QtCore.QVariant(False)).toBool()) + settings.value(u'hide mouse', False)) self.serviceNameDay.setCurrentIndex( settings.value(u'default service day', - QtCore.QVariant(self.defaultServiceDay)).toInt()[0]) + self.defaultServiceDay)) self.serviceNameTime.setTime(QtCore.QTime( - settings.value(u'default service hour', - self.defaultServiceHour).toInt()[0], + settings.value(u'default service hour', self.defaultServiceHour), settings.value(u'default service minute', - self.defaultServiceMinute).toInt()[0])) + self.defaultServiceMinute))) self.shouldUpdateServiceNameExample = True self.serviceNameEdit.setText(settings.value(u'default service name', - self.defaultServiceName).toString()) - default_service_enabled = settings.value(u'default service enabled', - QtCore.QVariant(True)).toBool() + self.defaultServiceName)) + default_service_enabled = settings.value( + u'default service enabled', True) self.serviceNameCheckBox.setChecked(default_service_enabled) self.serviceNameCheckBoxToggled(default_service_enabled) self.x11BypassCheckBox.setChecked( - settings.value(u'x11 bypass wm', QtCore.QVariant(True)).toBool()) - self.defaultColor = settings.value(u'default color', - QtCore.QVariant(u'#ffffff')).toString() + settings.value(u'x11 bypass wm', True)) + self.defaultColor = settings.value(u'default color', u'#ffffff') self.defaultFileEdit.setText(settings.value(u'default image', - QtCore.QVariant(u':/graphics/openlp-splash-screen.png'))\ - .toString()) - self.slide_limits = settings.value( - u'slide limits', QtCore.QVariant(SlideLimits.End)).toInt()[0] + u':/graphics/openlp-splash-screen.png')) + self.slide_limits = settings.value(u'slide limits', SlideLimits.End) if self.slide_limits == SlideLimits.End: self.endSlideRadioButton.setChecked(True) elif self.slide_limits == SlideLimits.Wrap: @@ -404,7 +401,7 @@ class AdvancedTab(SettingsTab): """ Save settings to disk. """ - settings = QtCore.QSettings() + settings = Settings() settings.beginGroup(self.settingsSection) settings.setValue(u'default service enabled', self.serviceNameCheckBox.isChecked()) @@ -421,25 +418,22 @@ class AdvancedTab(SettingsTab): self.serviceNameTime.time().hour()) settings.setValue(u'default service minute', self.serviceNameTime.time().minute()) - settings.setValue(u'recent file count', - QtCore.QVariant(self.recentSpinBox.value())) + settings.setValue(u'recent file count', self.recentSpinBox.value()) settings.setValue(u'save current plugin', - QtCore.QVariant(self.mediaPluginCheckBox.isChecked())) + self.mediaPluginCheckBox.isChecked()) settings.setValue(u'double click live', - QtCore.QVariant(self.doubleClickLiveCheckBox.isChecked())) + self.doubleClickLiveCheckBox.isChecked()) settings.setValue(u'single click preview', - QtCore.QVariant(self.singleClickPreviewCheckBox.isChecked())) + self.singleClickPreviewCheckBox.isChecked()) settings.setValue(u'expand service item', - QtCore.QVariant(self.expandServiceItemCheckBox.isChecked())) + self.expandServiceItemCheckBox.isChecked()) settings.setValue(u'enable exit confirmation', - QtCore.QVariant(self.enableAutoCloseCheckBox.isChecked())) - settings.setValue(u'hide mouse', - QtCore.QVariant(self.hideMouseCheckBox.isChecked())) - settings.setValue(u'x11 bypass wm', - QtCore.QVariant(self.x11BypassCheckBox.isChecked())) + self.enableAutoCloseCheckBox.isChecked()) + settings.setValue(u'hide mouse', self.hideMouseCheckBox.isChecked()) + settings.setValue(u'x11 bypass wm', self.x11BypassCheckBox.isChecked()) settings.setValue(u'default color', self.defaultColor) settings.setValue(u'default image', self.defaultFileEdit.text()) - settings.setValue(u'slide limits', QtCore.QVariant(self.slide_limits)) + settings.setValue(u'slide limits', self.slide_limits) settings.endGroup() if self.displayChanged: Receiver.send_message(u'config_screen_changed') diff --git a/openlp/core/ui/firsttimeform.py b/openlp/core/ui/firsttimeform.py index 5926733a8..e14db5ae7 100644 --- a/openlp/core/ui/firsttimeform.py +++ b/openlp/core/ui/firsttimeform.py @@ -38,7 +38,7 @@ from ConfigParser import SafeConfigParser from PyQt4 import QtCore, QtGui from openlp.core.lib import translate, PluginStatus, Receiver, build_icon, \ - check_directory_exists + check_directory_exists, Settings from openlp.core.utils import get_web_page, AppLocation from firsttimewizard import Ui_FirstTimeWizard, FirstTimePage @@ -62,7 +62,7 @@ class ThemeScreenshotThread(QtCore.QThread): urllib.urlretrieve(u'%s%s' % (self.parent().web, screenshot), os.path.join(gettempdir(), u'openlp', screenshot)) item = QtGui.QListWidgetItem(title, self.parent().themesListWidget) - item.setData(QtCore.Qt.UserRole, QtCore.QVariant(filename)) + item.setData(QtCore.Qt.UserRole, filename) item.setCheckState(QtCore.Qt.Unchecked) item.setFlags(item.flags() | QtCore.Qt.ItemIsUserCheckable) @@ -113,8 +113,8 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): check_directory_exists(os.path.join(gettempdir(), u'openlp')) self.noInternetFinishButton.setVisible(False) # Check if this is a re-run of the wizard. - self.hasRunWizard = QtCore.QSettings().value( - u'general/has run wizard', QtCore.QVariant(False)).toBool() + self.hasRunWizard = Settings().value( + u'general/has run wizard', False) # Sort out internet access for downloads if self.webAccess: songs = self.config.get(u'songs', u'languages') @@ -125,7 +125,7 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): filename = unicode(self.config.get( u'songs_%s' % song, u'filename'), u'utf8') item = QtGui.QListWidgetItem(title, self.songsListWidget) - item.setData(QtCore.Qt.UserRole, QtCore.QVariant(filename)) + item.setData(QtCore.Qt.UserRole, filename) item.setCheckState(QtCore.Qt.Unchecked) item.setFlags(item.flags() | QtCore.Qt.ItemIsUserCheckable) bible_languages = self.config.get(u'bibles', u'languages') @@ -133,8 +133,9 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): for lang in bible_languages: language = unicode(self.config.get( u'bibles_%s' % lang, u'title'), u'utf8') + # FIXME langItem = QtGui.QTreeWidgetItem( - self.biblesTreeWidget, QtCore.QStringList(language)) + self.biblesTreeWidget, language) bibles = self.config.get(u'bibles_%s' % lang, u'translations') bibles = bibles.split(u',') for bible in bibles: @@ -142,10 +143,9 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): u'bible_%s' % bible, u'title'), u'utf8') filename = unicode(self.config.get( u'bible_%s' % bible, u'filename')) - item = QtGui.QTreeWidgetItem( - langItem, QtCore.QStringList(title)) - item.setData(0, QtCore.Qt.UserRole, - QtCore.QVariant(filename)) + # FIXME + item = QtGui.QTreeWidgetItem(langItem, title) + item.setData(0, QtCore.Qt.UserRole, filename) item.setCheckState(0, QtCore.Qt.Unchecked) item.setFlags(item.flags() | QtCore.Qt.ItemIsUserCheckable) self.biblesTreeWidget.expandAll() @@ -206,9 +206,8 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): index = self.themeComboBox.findText(theme) if index == -1: self.themeComboBox.addItem(theme) - default_theme = unicode(QtCore.QSettings().value( - u'themes/global theme', - QtCore.QVariant(u'')).toString()) + default_theme = unicode(Settings().value( + u'themes/global theme', u'')) # Pre-select the current default theme. index = self.themeComboBox.findText(default_theme) self.themeComboBox.setCurrentIndex(index) @@ -257,8 +256,7 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): self._performWizard() Receiver.send_message(u'openlp_process_events') Receiver.send_message(u'cursor_normal') - QtCore.QSettings().setValue(u'general/has run wizard', - QtCore.QVariant(True)) + Settings().setValue(u'general/has run wizard', True) self.close() def urlGetFile(self, url, fpath): @@ -296,7 +294,7 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): screenshot = self.config.get(u'theme_%s' % theme, u'screenshot') for index in xrange(self.themesListWidget.count()): item = self.themesListWidget.item(index) - if item.data(QtCore.Qt.UserRole) == QtCore.QVariant(filename): + if item.data(QtCore.Qt.UserRole) == filename: break item.setIcon(build_icon( os.path.join(gettempdir(), u'openlp', screenshot))) @@ -456,16 +454,16 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): os.path.join(themes_destination, theme)) # Set Default Display if self.displayComboBox.currentIndex() != -1: - QtCore.QSettings().setValue(u'General/monitor', - QtCore.QVariant(self.displayComboBox.currentIndex())) + Settings().setValue(u'General/monitor', + self.displayComboBox.currentIndex()) self.screens.set_current_display( - self.displayComboBox.currentIndex()) + self.displayComboBox.currentIndex()) # Set Global Theme if self.themeComboBox.currentIndex() != -1: - QtCore.QSettings().setValue(u'themes/global theme', - QtCore.QVariant(self.themeComboBox.currentText())) + Settings().setValue(u'themes/global theme', + self.themeComboBox.currentText()) def _setPluginStatus(self, field, tag): - status = PluginStatus.Active if field.checkState() \ - == QtCore.Qt.Checked else PluginStatus.Inactive - QtCore.QSettings().setValue(tag, QtCore.QVariant(status)) + status = PluginStatus.Active if field.checkState() == QtCore.Qt.Checked\ + else PluginStatus.Inactive + Settings().setValue(tag, status) diff --git a/openlp/core/ui/generaltab.py b/openlp/core/ui/generaltab.py index baf28f40f..6c6fec519 100644 --- a/openlp/core/ui/generaltab.py +++ b/openlp/core/ui/generaltab.py @@ -28,7 +28,7 @@ import logging from PyQt4 import QtCore, QtGui -from openlp.core.lib import SettingsTab, Receiver, translate +from openlp.core.lib import Receiver, Settings, SettingsTab, translate from openlp.core.lib.ui import UiStrings from openlp.core.ui import ScreenList @@ -265,53 +265,50 @@ class GeneralTab(SettingsTab): """ Load the settings to populate the form """ - settings = QtCore.QSettings() + settings = Settings() settings.beginGroup(self.settingsSection) self.monitorComboBox.clear() self.monitorComboBox.addItems(self.screens.get_screen_list()) - monitorNumber = settings.value(u'monitor', - QtCore.QVariant(self.screens.display_count - 1)).toInt()[0] + monitorNumber = settings.value( + u'monitor', self.screens.display_count - 1) self.monitorComboBox.setCurrentIndex(monitorNumber) - self.numberEdit.setText(unicode(settings.value( - u'ccli number', QtCore.QVariant(u'')).toString())) - self.usernameEdit.setText(unicode(settings.value( - u'songselect username', QtCore.QVariant(u'')).toString())) - self.passwordEdit.setText(unicode(settings.value( - u'songselect password', QtCore.QVariant(u'')).toString())) + self.numberEdit.setText(settings.value(u'ccli number', u'')) + self.usernameEdit.setText(settings.value(u'songselect username', u'')) + self.passwordEdit.setText(settings.value(u'songselect password', u'')) self.saveCheckServiceCheckBox.setChecked(settings.value(u'save prompt', - QtCore.QVariant(False)).toBool()) + False)) self.autoUnblankCheckBox.setChecked(settings.value(u'auto unblank', - QtCore.QVariant(False)).toBool()) + False)) self.displayOnMonitorCheck.setChecked(self.screens.display) self.warningCheckBox.setChecked(settings.value(u'blank warning', - QtCore.QVariant(False)).toBool()) + False)) self.autoOpenCheckBox.setChecked(settings.value(u'auto open', - QtCore.QVariant(False)).toBool()) + False)) self.showSplashCheckBox.setChecked(settings.value(u'show splash', - QtCore.QVariant(True)).toBool()) + True)) self.checkForUpdatesCheckBox.setChecked(settings.value(u'update check', - QtCore.QVariant(True)).toBool()) + True)) self.autoPreviewCheckBox.setChecked(settings.value(u'auto preview', - QtCore.QVariant(False)).toBool()) + False)) self.timeoutSpinBox.setValue(settings.value(u'loop delay', - QtCore.QVariant(5)).toInt()[0]) + 5)) self.monitorRadioButton.setChecked( not settings.value(u'override position', - QtCore.QVariant(False)).toBool()) + False)) self.overrideRadioButton.setChecked(settings.value(u'override position', - QtCore.QVariant(False)).toBool()) + False)) self.customXValueEdit.setValue(settings.value(u'x position', - QtCore.QVariant(self.screens.current[u'size'].x())).toInt()[0]) + self.screens.current[u'size'].x())) self.customYValueEdit.setValue(settings.value(u'y position', - QtCore.QVariant(self.screens.current[u'size'].y())).toInt()[0]) + self.screens.current[u'size'].y())) self.customHeightValueEdit.setValue(settings.value(u'height', - QtCore.QVariant(self.screens.current[u'size'].height())).toInt()[0]) + self.screens.current[u'size'].height())) self.customWidthValueEdit.setValue(settings.value(u'width', - QtCore.QVariant(self.screens.current[u'size'].width())).toInt()[0]) + self.screens.current[u'size'].width())) self.startPausedCheckBox.setChecked(settings.value( - u'audio start paused', QtCore.QVariant(True)).toBool()) + u'audio start paused', True)) self.repeatListCheckBox.setChecked(settings.value( - u'audio repeat list', QtCore.QVariant(False)).toBool()) + u'audio repeat list', False)) settings.endGroup() self.monitorComboBox.setDisabled(self.overrideRadioButton.isChecked()) self.customXValueEdit.setEnabled(self.overrideRadioButton.isChecked()) @@ -327,48 +324,36 @@ class GeneralTab(SettingsTab): """ Save the settings from the form """ - settings = QtCore.QSettings() + settings = Settings() settings.beginGroup(self.settingsSection) - settings.setValue(u'monitor', - QtCore.QVariant(self.monitorComboBox.currentIndex())) + settings.setValue(u'monitor', self.monitorComboBox.currentIndex()) settings.setValue(u'display on monitor', - QtCore.QVariant(self.displayOnMonitorCheck.isChecked())) - settings.setValue(u'blank warning', - QtCore.QVariant(self.warningCheckBox.isChecked())) - settings.setValue(u'auto open', - QtCore.QVariant(self.autoOpenCheckBox.isChecked())) - settings.setValue(u'show splash', - QtCore.QVariant(self.showSplashCheckBox.isChecked())) + self.displayOnMonitorCheck.isChecked()) + settings.setValue(u'blank warning', self.warningCheckBox.isChecked()) + settings.setValue(u'auto open', self.autoOpenCheckBox.isChecked()) + settings.setValue(u'show splash', self.showSplashCheckBox.isChecked()) settings.setValue(u'update check', - QtCore.QVariant(self.checkForUpdatesCheckBox.isChecked())) + self.checkForUpdatesCheckBox.isChecked()) settings.setValue(u'save prompt', - QtCore.QVariant(self.saveCheckServiceCheckBox.isChecked())) - settings.setValue(u'auto unblank', - QtCore.QVariant(self.autoUnblankCheckBox.isChecked())) - settings.setValue(u'auto preview', - QtCore.QVariant(self.autoPreviewCheckBox.isChecked())) - settings.setValue(u'loop delay', - QtCore.QVariant(self.timeoutSpinBox.value())) - settings.setValue(u'ccli number', - QtCore.QVariant(self.numberEdit.displayText())) + self.saveCheckServiceCheckBox.isChecked()) + settings.setValue(u'auto unblank', self.autoUnblankCheckBox.isChecked()) + settings.setValue(u'auto preview', self.autoPreviewCheckBox.isChecked()) + settings.setValue(u'loop delay', self.timeoutSpinBox.value()) + settings.setValue(u'ccli number', self.numberEdit.displayText()) settings.setValue(u'songselect username', - QtCore.QVariant(self.usernameEdit.displayText())) + self.usernameEdit.displayText()) settings.setValue(u'songselect password', - QtCore.QVariant(self.passwordEdit.displayText())) - settings.setValue(u'x position', - QtCore.QVariant(self.customXValueEdit.value())) - settings.setValue(u'y position', - QtCore.QVariant(self.customYValueEdit.value())) - settings.setValue(u'height', - QtCore.QVariant(self.customHeightValueEdit.value())) - settings.setValue(u'width', - QtCore.QVariant(self.customWidthValueEdit.value())) + self.passwordEdit.displayText()) + settings.setValue(u'x position', self.customXValueEdit.value()) + settings.setValue(u'y position', self.customYValueEdit.value()) + settings.setValue(u'height', self.customHeightValueEdit.value()) + settings.setValue(u'width', self.customWidthValueEdit.value()) settings.setValue(u'override position', - QtCore.QVariant(self.overrideRadioButton.isChecked())) + self.overrideRadioButton.isChecked()) settings.setValue(u'audio start paused', - QtCore.QVariant(self.startPausedCheckBox.isChecked())) + self.startPausedCheckBox.isChecked()) settings.setValue(u'audio repeat list', - QtCore.QVariant(self.repeatListCheckBox.isChecked())) + self.repeatListCheckBox.isChecked()) settings.endGroup() # On save update the screens as well self.postSetUp(True) diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index 15fb9eefe..dd20230fe 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -36,7 +36,7 @@ from PyQt4 import QtCore, QtGui, QtWebKit, QtOpenGL from PyQt4.phonon import Phonon from openlp.core.lib import Receiver, build_html, ServiceItem, image_to_byte, \ - translate, PluginManager, expand_tags + translate, PluginManager, expand_tags, Settings from openlp.core.lib.theme import BackgroundType from openlp.core.ui import HideMode, ScreenList, AlertLocation @@ -134,8 +134,7 @@ class MainDisplay(Display): self.setStyleSheet(u'border: 0px; margin: 0px; padding: 0px;') windowFlags = QtCore.Qt.FramelessWindowHint | QtCore.Qt.Tool | \ QtCore.Qt.WindowStaysOnTopHint - if QtCore.QSettings().value(u'advanced/x11 bypass wm', - QtCore.QVariant(True)).toBool(): + if Settings().value(u'advanced/x11 bypass wm', True): windowFlags |= QtCore.Qt.X11BypassWindowManagerHint # FIXME: QtCore.Qt.SplashScreen is workaround to make display screen # stay always on top on Mac OS X. For details see bug 906926. @@ -195,13 +194,12 @@ class MainDisplay(Display): Display.setup(self) if self.isLive: # Build the initial frame. - image_file = QtCore.QSettings().value(u'advanced/default image', - QtCore.QVariant(u':/graphics/openlp-splash-screen.png'))\ - .toString() + image_file = Settings().value(u'advanced/default image', + u':/graphics/openlp-splash-screen.png') background_color = QtGui.QColor() - background_color.setNamedColor(QtCore.QSettings().value( + background_color.setNamedColor(Settings().value( u'advanced/default color', - QtCore.QVariant(u'#ffffff')).toString()) + u'#ffffff')) if not background_color.isValid(): background_color = QtCore.Qt.white splash_image = QtGui.QImage(image_file) @@ -260,7 +258,7 @@ class MainDisplay(Display): height = self.frame.evaluateJavaScript(js) if shrink: if text: - alert_height = int(height.toString()) + alert_height = int(height) self.resize(self.width(), alert_height) self.setVisible(True) if location == AlertLocation.Middle: @@ -352,8 +350,8 @@ class MainDisplay(Display): # Single screen active if self.screens.display_count == 1: # Only make visible if setting enabled. - if QtCore.QSettings().value(u'general/display on monitor', - QtCore.QVariant(True)).toBool(): + if Settings().value( + u'general/display on monitor', True): self.setVisible(True) else: self.setVisible(True) @@ -401,8 +399,8 @@ class MainDisplay(Display): self.footer(serviceItem.foot_text) # if was hidden keep it hidden if self.hideMode and self.isLive and not serviceItem.is_media(): - if QtCore.QSettings().value(u'general/auto unblank', - QtCore.QVariant(False)).toBool(): + if Settings().value(u'general/auto unblank', + False): Receiver.send_message(u'slidecontroller_live_unblank') else: self.hideDisplay(self.hideMode) @@ -425,8 +423,8 @@ class MainDisplay(Display): log.debug(u'hideDisplay mode = %d', mode) if self.screens.display_count == 1: # Only make visible if setting enabled. - if not QtCore.QSettings().value(u'general/display on monitor', - QtCore.QVariant(True)).toBool(): + if not Settings().value(u'general/display on monitor', + True): return if mode == HideMode.Screen: self.frame.evaluateJavaScript(u'show_blank("desktop");') @@ -450,8 +448,8 @@ class MainDisplay(Display): log.debug(u'showDisplay') if self.screens.display_count == 1: # Only make visible if setting enabled. - if not QtCore.QSettings().value(u'general/display on monitor', - QtCore.QVariant(True)).toBool(): + if not Settings().value(u'general/display on monitor', + True): return self.frame.evaluateJavaScript('show_blank("show");') if self.isHidden(): @@ -465,8 +463,8 @@ class MainDisplay(Display): """ Hide mouse cursor when moved over display. """ - if QtCore.QSettings().value(u'advanced/hide mouse', - QtCore.QVariant(False)).toBool(): + if Settings().value(u'advanced/hide mouse', + False): self.setCursor(QtCore.Qt.BlankCursor) self.frame.evaluateJavaScript('document.body.style.cursor = "none"') else: diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index e4a4e1616..64167d194 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -37,7 +37,7 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import Renderer, build_icon, OpenLPDockWidget, \ PluginManager, Receiver, translate, ImageManager, PluginStatus from openlp.core.lib.ui import UiStrings, create_action -from openlp.core.lib import SlideLimits +from openlp.core.lib import SlideLimits, Settings from openlp.core.ui import AboutForm, SettingsForm, ServiceManager, \ ThemeManager, SlideController, PluginForm, MediaDockManager, \ ShortcutListForm, FormattingTagForm @@ -99,13 +99,13 @@ class Ui_MainWindow(object): # Create slide controllers self.previewController = SlideController(self) self.liveController = SlideController(self, True) - previewVisible = QtCore.QSettings().value( - u'user interface/preview panel', QtCore.QVariant(True)).toBool() + previewVisible = Settings().value( + u'user interface/preview panel', True) self.previewController.panel.setVisible(previewVisible) - liveVisible = QtCore.QSettings().value(u'user interface/live panel', - QtCore.QVariant(True)).toBool() - panelLocked = QtCore.QSettings().value(u'user interface/lock panel', - QtCore.QVariant(False)).toBool() + liveVisible = Settings().value(u'user interface/live panel', + True) + panelLocked = Settings().value(u'user interface/lock panel', + False) self.liveController.panel.setVisible(liveVisible) # Create menu self.menuBar = QtGui.QMenuBar(mainWindow) @@ -684,10 +684,9 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): self.previewController.screenSizeChanged() self.liveController.screenSizeChanged() log.info(u'Load data from Settings') - if QtCore.QSettings().value(u'advanced/save current plugin', - QtCore.QVariant(False)).toBool(): - savedPlugin = QtCore.QSettings().value( - u'advanced/current media plugin', QtCore.QVariant()).toInt()[0] + if Settings().value(u'advanced/save current plugin', False): + savedPlugin = Settings().value( + u'advanced/current media plugin', ) if savedPlugin != -1: self.mediaToolBox.setCurrentIndex(savedPlugin) self.settingsForm.postSetUp() @@ -738,12 +737,12 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): if not isinstance(filename, unicode): filename = unicode(filename, sys.getfilesystemencoding()) self.serviceManagerContents.loadFile(filename) - elif QtCore.QSettings().value( + elif Settings().value( self.generalSettingsSection + u'/auto open', - QtCore.QVariant(False)).toBool(): + False): self.serviceManagerContents.loadLastFile() - view_mode = QtCore.QSettings().value(u'%s/view mode' % \ - self.generalSettingsSection, u'default').toString() + view_mode = Settings().value(u'%s/view mode' % \ + self.generalSettingsSection, u'default') if view_mode == u'default': self.modeDefaultItem.setChecked(True) elif view_mode == u'setup': @@ -820,12 +819,12 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): """ Check and display message if screen blank on setup. """ - settings = QtCore.QSettings() + settings = Settings() self.liveController.mainDisplaySetBackground() if settings.value(u'%s/screen blank' % self.generalSettingsSection, - QtCore.QVariant(False)).toBool(): + False): if settings.value(u'%s/blank warning' % self.generalSettingsSection, - QtCore.QVariant(False)).toBool(): + False): QtGui.QMessageBox.question(self, translate('OpenLP.MainWindow', 'OpenLP Main Display Blanked'), @@ -954,8 +953,8 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): # Add plugin sections. for plugin in self.pluginManager.plugins: setting_sections.extend([plugin.name]) - settings = QtCore.QSettings() - import_settings = QtCore.QSettings(import_file_name, + settings = Settings() + import_settings = Settings(import_file_name, QtCore.QSettings.IniFormat) import_keys = import_settings.allKeys() for section_key in import_keys: @@ -985,11 +984,10 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): # We have a good file, import it. for section_key in import_keys: value = import_settings.value(section_key) - settings.setValue(u'%s' % (section_key), - QtCore.QVariant(value)) + settings.setValue(u'%s' % (section_key), value) now = datetime.now() settings.beginGroup(self.headerSection) - settings.setValue(u'file_imported', QtCore.QVariant(import_file_name)) + settings.setValue(u'file_imported', import_file_name) settings.setValue(u'file_date_imported', now.strftime("%Y-%m-%d %H:%M")) settings.endGroup() @@ -1041,11 +1039,11 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): os.remove(temp_file) if os.path.exists(export_file_name): os.remove(export_file_name) - settings = QtCore.QSettings() + settings = Settings() settings.remove(self.headerSection) # Get the settings. keys = settings.allKeys() - export_settings = QtCore.QSettings(temp_file, + export_settings = Settings(temp_file, QtCore.QSettings.IniFormat) # Add a header section. # This is to insure it's our conf file for import. @@ -1104,7 +1102,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): Set OpenLP to a different view mode. """ if mode: - settings = QtCore.QSettings() + settings = Settings() settings.setValue(u'%s/view mode' % self.generalSettingsSection, mode) self.mediaManagerDock.setVisible(media) @@ -1149,8 +1147,8 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): else: event.ignore() else: - if QtCore.QSettings().value(u'advanced/enable exit confirmation', - QtCore.QVariant(True)).toBool(): + if Settings().value(u'advanced/enable exit confirmation', + True): ret = QtGui.QMessageBox.question(self, translate('OpenLP.MainWindow', 'Close OpenLP'), translate('OpenLP.MainWindow', @@ -1174,10 +1172,10 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): """ # Clean temporary files used by services self.serviceManagerContents.cleanUp() - if QtCore.QSettings().value(u'advanced/save current plugin', - QtCore.QVariant(False)).toBool(): - QtCore.QSettings().setValue(u'advanced/current media plugin', - QtCore.QVariant(self.mediaToolBox.currentIndex())) + if Settings().value(u'advanced/save current plugin', + False): + Settings().setValue(u'advanced/current media plugin', + self.mediaToolBox.currentIndex()) # Call the cleanup method to shutdown plugins. log.info(u'cleanup plugins') self.pluginManager.finalise_plugins() @@ -1254,8 +1252,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): False - Hidden """ self.previewController.panel.setVisible(visible) - QtCore.QSettings().setValue(u'user interface/preview panel', - QtCore.QVariant(visible)) + Settings().setValue(u'user interface/preview panel', visible) self.viewPreviewPanel.setChecked(visible) def setLockPanel(self, lock): @@ -1286,8 +1283,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): self.viewThemeManagerItem.setEnabled(True) self.viewPreviewPanel.setEnabled(True) self.viewLivePanel.setEnabled(True) - QtCore.QSettings().setValue(u'user interface/lock panel', - QtCore.QVariant(lock)) + Settings().setValue(u'user interface/lock panel', lock) def setLivePanelVisibility(self, visible): """ @@ -1300,8 +1296,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): False - Hidden """ self.liveController.panel.setVisible(visible) - QtCore.QSettings().setValue(u'user interface/live panel', - QtCore.QVariant(visible)) + Settings().setValue(u'user interface/live panel', visible) self.viewLivePanel.setChecked(visible) def loadSettings(self): @@ -1310,19 +1305,19 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): """ log.debug(u'Loading QSettings') # Migrate Wrap Settings to Slide Limits Settings - if QtCore.QSettings().contains(self.generalSettingsSection + + if Settings().contains(self.generalSettingsSection + u'/enable slide loop'): - if QtCore.QSettings().value(self.generalSettingsSection + - u'/enable slide loop', QtCore.QVariant(True)).toBool(): - QtCore.QSettings().setValue(self.advancedSettingsSection + - u'/slide limits', QtCore.QVariant(SlideLimits.Wrap)) + if Settings().value(self.generalSettingsSection + + u'/enable slide loop', True): + Settings().setValue(self.advancedSettingsSection + + u'/slide limits', SlideLimits.Wrap) else: - QtCore.QSettings().setValue(self.advancedSettingsSection + - u'/slide limits', QtCore.QVariant(SlideLimits.End)) - QtCore.QSettings().remove(self.generalSettingsSection + + Settings().setValue(self.advancedSettingsSection + + u'/slide limits', SlideLimits.End) + Settings().remove(self.generalSettingsSection + u'/enable slide loop') Receiver.send_message(u'slidecontroller_update_slide_limits') - settings = QtCore.QSettings() + settings = Settings() # Remove obsolete entries. settings.remove(u'custom slide') settings.remove(u'service') @@ -1331,7 +1326,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): settings.endGroup() settings.beginGroup(self.uiSettingsSection) self.move(settings.value(u'main window position', - QtCore.QVariant(QtCore.QPoint(0, 0))).toPoint()) + QtCore.QPoint(0, 0))).toPoint() self.restoreGeometry( settings.value(u'main window geometry').toByteArray()) self.restoreState(settings.value(u'main window state').toByteArray()) @@ -1351,25 +1346,21 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): if self.settingsImported: return log.debug(u'Saving QSettings') - settings = QtCore.QSettings() + settings = Settings() settings.beginGroup(self.generalSettingsSection) - recentFiles = QtCore.QVariant(self.recentFiles) \ - if self.recentFiles else QtCore.QVariant() + recentFiles = self.recentFiles if self.recentFiles else u'' settings.setValue(u'recent files', recentFiles) settings.endGroup() settings.beginGroup(self.uiSettingsSection) - settings.setValue(u'main window position', - QtCore.QVariant(self.pos())) - settings.setValue(u'main window state', - QtCore.QVariant(self.saveState())) - settings.setValue(u'main window geometry', - QtCore.QVariant(self.saveGeometry())) + settings.setValue(u'main window position', self.pos()) + settings.setValue(u'main window state', self.saveState()) + settings.setValue(u'main window geometry', self.saveGeometry()) settings.setValue(u'live splitter geometry', - QtCore.QVariant(self.liveController.splitter.saveState())) + self.liveController.splitter.saveState()) settings.setValue(u'preview splitter geometry', - QtCore.QVariant(self.previewController.splitter.saveState())) + self.previewController.splitter.saveState()) settings.setValue(u'mainwindow splitter geometry', - QtCore.QVariant(self.controlSplitter.saveState())) + self.controlSplitter.saveState()) settings.endGroup() def updateRecentFilesMenu(self): @@ -1377,8 +1368,8 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): Updates the recent file menu with the latest list of service files accessed. """ - recentFileCount = QtCore.QSettings().value( - u'advanced/recent file count', QtCore.QVariant(4)).toInt()[0] + recentFileCount = Settings().value( + u'advanced/recent file count', 4) existingRecentFiles = [recentFile for recentFile in self.recentFiles if os.path.isfile(unicode(recentFile))] recentFilesToDisplay = existingRecentFiles[0:recentFileCount] @@ -1410,8 +1401,8 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): # The maxRecentFiles value does not have an interface and so never gets # actually stored in the settings therefore the default value of 20 will # always be used. - maxRecentFiles = QtCore.QSettings().value(u'advanced/max recent files', - QtCore.QVariant(20)).toInt()[0] + maxRecentFiles = Settings().value( + u'advanced/max recent files', 20) if filename: # Add some cleanup to reduce duplication in the recent file list filename = os.path.abspath(filename) @@ -1422,7 +1413,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): position = self.recentFiles.indexOf(filename) if position != -1: self.recentFiles.removeAt(position) - self.recentFiles.insert(0, QtCore.QString(filename)) + self.recentFiles.insert(0, filename) while self.recentFiles.count() > maxRecentFiles: # Don't care what API says takeLast works, removeLast doesn't! self.recentFiles.takeLast() diff --git a/openlp/core/ui/media/__init__.py b/openlp/core/ui/media/__init__.py index 5c4428a61..7fb5ccd04 100644 --- a/openlp/core/ui/media/__init__.py +++ b/openlp/core/ui/media/__init__.py @@ -26,6 +26,8 @@ ############################################################################### import logging +from openlp.core.lib import Settings + from PyQt4 import QtCore log = logging.getLogger(__name__) @@ -78,12 +80,12 @@ def get_media_players(): Here an special media player is chosen for all media actions. """ log.debug(u'get_media_players') - players = unicode(QtCore.QSettings().value(u'media/players').toString()) + players = Settings().value(u'media/players') if not players: players = u'webkit' reg_ex = QtCore.QRegExp(".*\[(.*)\].*") - if QtCore.QSettings().value(u'media/override player', - QtCore.QVariant(QtCore.Qt.Unchecked)).toInt()[0] == QtCore.Qt.Checked: + if Settings().value(u'media/override player', + QtCore.Qt.Unchecked) == QtCore.Qt.Checked: if reg_ex.exactMatch(players): overridden_player = u'%s' % reg_ex.cap(1) else: @@ -107,10 +109,10 @@ def set_media_players(players_list, overridden_player=u'auto'): """ log.debug(u'set_media_players') players = u','.join(players_list) - if QtCore.QSettings().value(u'media/override player', - QtCore.QVariant(QtCore.Qt.Unchecked)).toInt()[0] == \ - QtCore.Qt.Checked and overridden_player != u'auto': + if Settings().value(u'media/override player', + QtCore.Qt.Unchecked) == QtCore.Qt.Checked and \ + overridden_player != u'auto': players = players.replace(overridden_player, u'[%s]' % overridden_player) - QtCore.QSettings().setValue(u'media/players', QtCore.QVariant(players)) + Settings().setValue(u'media/players', players) from mediacontroller import MediaController diff --git a/openlp/core/ui/media/mediacontroller.py b/openlp/core/ui/media/mediacontroller.py index b7356fcf5..2fb0c6fd4 100644 --- a/openlp/core/ui/media/mediacontroller.py +++ b/openlp/core/ui/media/mediacontroller.py @@ -332,9 +332,8 @@ class MediaController(object): display.frame.evaluateJavaScript(u'show_video( \ "setBackBoard", null, null, null,"visible");') # now start playing - if controller.isLive and \ - (QtCore.QSettings().value(u'general/auto unblank', - QtCore.QVariant(False)).toBool() or \ + if controller.isLive and (Settings().value( + u'general/auto unblank', False) or controller.media_info.is_background == True) or \ controller.isLive == False: if not self.video_play([controller]): diff --git a/openlp/core/ui/media/vlcplayer.py b/openlp/core/ui/media/vlcplayer.py index 6d26f3b34..93a06b0b3 100644 --- a/openlp/core/ui/media/vlcplayer.py +++ b/openlp/core/ui/media/vlcplayer.py @@ -33,7 +33,7 @@ import sys from PyQt4 import QtCore, QtGui -from openlp.core.lib import Receiver +from openlp.core.lib import Receiver, Settings from openlp.core.lib.mediaplayer import MediaPlayer from openlp.core.ui.media import MediaState @@ -114,8 +114,7 @@ class VlcPlayer(MediaPlayer): command_line_options = u'--no-video-title-show' if not display.hasAudio: command_line_options += u' --no-audio --no-video-title-show' - if QtCore.QSettings().value(u'advanced/hide mouse', - QtCore.QVariant(False)).toBool() and \ + if Settings().value(u'advanced/hide mouse', False) and \ display.controller.isLive: command_line_options += u' --mouse-hide-timeout=0' display.vlcInstance = vlc.Instance(command_line_options) diff --git a/openlp/core/ui/printserviceform.py b/openlp/core/ui/printserviceform.py index 943f8daff..3cf55713b 100644 --- a/openlp/core/ui/printserviceform.py +++ b/openlp/core/ui/printserviceform.py @@ -31,7 +31,7 @@ import os from PyQt4 import QtCore, QtGui from lxml import html -from openlp.core.lib import translate, get_text_file_string, Receiver +from openlp.core.lib import translate, get_text_file_string, Receiver, Settings from openlp.core.lib.ui import UiStrings from openlp.core.ui.printservicedialog import Ui_PrintServiceDialog, ZoomSize from openlp.core.utils import AppLocation @@ -120,20 +120,18 @@ class PrintServiceForm(QtGui.QDialog, Ui_PrintServiceDialog): self.zoom = 0 self.setupUi(self) # Load the settings for the dialog. - settings = QtCore.QSettings() + settings = Settings() settings.beginGroup(u'advanced') self.slideTextCheckBox.setChecked(settings.value( - u'print slide text', QtCore.QVariant(False)).toBool()) + u'print slide text', False)) self.pageBreakAfterText.setChecked(settings.value( - u'add page break', QtCore.QVariant(False)).toBool()) + u'add page break', False)) if not self.slideTextCheckBox.isChecked(): self.pageBreakAfterText.setDisabled(True) self.metaDataCheckBox.setChecked(settings.value( - u'print file meta data', QtCore.QVariant(False)).toBool()) - self.notesCheckBox.setChecked(settings.value( - u'print notes', QtCore.QVariant(False)).toBool()) - self.zoomComboBox.setCurrentIndex(settings.value( - u'display size', QtCore.QVariant(0)).toInt()[0]) + u'print file meta data', False)) + self.notesCheckBox.setChecked(settings.value(u'print notes', False)) + self.zoomComboBox.setCurrentIndex(settings.value(u'display size', 0)) settings.endGroup() # Signals QtCore.QObject.connect(self.printButton, @@ -318,9 +316,9 @@ class PrintServiceForm(QtGui.QDialog, Ui_PrintServiceDialog): elif display == ZoomSize.TwentyFive: self.previewWidget.fitToWidth() self.previewWidget.zoomIn(0.25) - settings = QtCore.QSettings() + settings = Settings() settings.beginGroup(u'advanced') - settings.setValue(u'display size', QtCore.QVariant(display)) + settings.setValue(u'display size', display) settings.endGroup() def copyText(self): @@ -389,16 +387,15 @@ class PrintServiceForm(QtGui.QDialog, Ui_PrintServiceDialog): Save the settings and close the dialog. """ # Save the settings for this dialog. - settings = QtCore.QSettings() + settings = Settings() settings.beginGroup(u'advanced') settings.setValue(u'print slide text', - QtCore.QVariant(self.slideTextCheckBox.isChecked())) + self.slideTextCheckBox.isChecked()) settings.setValue(u'add page break', - QtCore.QVariant(self.pageBreakAfterText.isChecked())) + self.pageBreakAfterText.isChecked()) settings.setValue(u'print file meta data', - QtCore.QVariant(self.metaDataCheckBox.isChecked())) - settings.setValue(u'print notes', - QtCore.QVariant(self.notesCheckBox.isChecked())) + self.metaDataCheckBox.isChecked()) + settings.setValue(u'print notes', self.notesCheckBox.isChecked()) settings.endGroup() def update_song_usage(self): diff --git a/openlp/core/ui/screen.py b/openlp/core/ui/screen.py index 21fbd6144..c603e1904 100644 --- a/openlp/core/ui/screen.py +++ b/openlp/core/ui/screen.py @@ -33,7 +33,7 @@ import copy from PyQt4 import QtCore -from openlp.core.lib import Receiver, translate +from openlp.core.lib import Receiver, translate, Settings log = logging.getLogger(__name__) @@ -241,22 +241,16 @@ class ScreenList(object): """ Loads the screen size and the monitor number from the settings. """ - settings = QtCore.QSettings() + settings = Settings() settings.beginGroup(u'general') self.set_current_display(settings.value(u'monitor', - QtCore.QVariant(self.display_count - 1)).toInt()[0]) - self.display = settings.value( - u'display on monitor', QtCore.QVariant(True)).toBool() - override_display = settings.value( - u'override position', QtCore.QVariant(False)).toBool() - x = settings.value(u'x position', - QtCore.QVariant(self.current[u'size'].x())).toInt()[0] - y = settings.value(u'y position', - QtCore.QVariant(self.current[u'size'].y())).toInt()[0] - width = settings.value(u'width', - QtCore.QVariant(self.current[u'size'].width())).toInt()[0] - height = settings.value(u'height', - QtCore.QVariant(self.current[u'size'].height())).toInt()[0] + self.display_count - 1)) + self.display = settings.value(u'display on monitor', True) + override_display = settings.value(u'override position', False) + x = settings.value(u'x position', self.current[u'size'].x()) + y = settings.value(u'y position', self.current[u'size'].y()) + width = settings.value(u'width', self.current[u'size'].width()) + height = settings.value(u'height', self.current[u'size'].height()) self.override[u'size'] = QtCore.QRect(x, y, width, height) self.override[u'primary'] = False settings.endGroup() diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 79faad819..ae76ccd44 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -38,7 +38,7 @@ log = logging.getLogger(__name__) from PyQt4 import QtCore, QtGui from openlp.core.lib import OpenLPToolbar, ServiceItem, Receiver, build_icon, \ - ItemCapabilities, SettingsManager, translate, str_to_bool + ItemCapabilities, SettingsManager, translate, str_to_bool, Settings from openlp.core.lib.theme import ThemeLevel from openlp.core.lib.ui import UiStrings, critical_error_message_box, \ create_widget_action, find_and_set_in_combo_box @@ -274,9 +274,9 @@ class ServiceManager(QtGui.QWidget): QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'service_item_update'), self.serviceItemUpdate) # Last little bits of setting up - self.service_theme = unicode(QtCore.QSettings().value( + self.service_theme = unicode(Settings().value( self.mainwindow.serviceManagerSettingsSection + u'/service theme', - QtCore.QVariant(u'')).toString()) + u'')) self.servicePath = AppLocation.get_section_data_path(u'servicemanager') # build the drag and drop context menu self.dndMenu = QtGui.QMenu() @@ -350,10 +350,9 @@ class ServiceManager(QtGui.QWidget): Setter for service file. """ self._fileName = unicode(fileName) - self.mainwindow.setServiceModified(self.isModified(), - self.shortFileName()) - QtCore.QSettings(). \ - setValue(u'servicemanager/last file',QtCore.QVariant(fileName)) + self.mainwindow.setServiceModified( + self.isModified(), self.shortFileName()) + Settings().setValue(u'servicemanager/last file', fileName) def fileName(self): """ @@ -371,9 +370,8 @@ class ServiceManager(QtGui.QWidget): """ Triggered when Config dialog is updated. """ - self.expandTabs = QtCore.QSettings().value( - u'advanced/expand service item', - QtCore.QVariant(u'False')).toBool() + self.expandTabs = Settings().value( + u'advanced/expand service item', False) def supportedSuffixes(self, suffix): self.suffixes.append(suffix) @@ -433,7 +431,7 @@ class ServiceManager(QtGui.QWidget): def onRecentServiceClicked(self): sender = self.sender() - self.loadFile(sender.data().toString()) + self.loadFile(sender.data()) def newFile(self): """ @@ -444,8 +442,7 @@ class ServiceManager(QtGui.QWidget): self.setFileName(u'') self.serviceId += 1 self.setModified(False) - QtCore.QSettings(). \ - setValue(u'servicemanager/last file',QtCore.QVariant(u'')) + Settings().setValue(u'servicemanager/last file', u'') Receiver.send_message(u'servicemanager_new_service') def saveFile(self): @@ -593,17 +590,17 @@ class ServiceManager(QtGui.QWidget): Get a file name and then call :func:`ServiceManager.saveFile` to save the file. """ - default_service_enabled = QtCore.QSettings().value( - u'advanced/default service enabled', QtCore.QVariant(True)).toBool() + default_service_enabled = Settings().value( + u'advanced/default service enabled', True) if default_service_enabled: - service_day = QtCore.QSettings().value( + service_day = Settings().value( u'advanced/default service day', 7).toInt()[0] if service_day == 7: time = datetime.now() else: - service_hour = QtCore.QSettings().value( + service_hour = Settings().value( u'advanced/default service hour', 11).toInt()[0] - service_minute = QtCore.QSettings().value( + service_minute = Settings().value( u'advanced/default service minute', 0).toInt()[0] now = datetime.now() day_delta = service_day - now.weekday() @@ -611,13 +608,13 @@ class ServiceManager(QtGui.QWidget): day_delta += 7 time = now + timedelta(days=day_delta) time = time.replace(hour=service_hour, minute=service_minute) - default_pattern = unicode(QtCore.QSettings().value( + default_pattern = unicode(Settings().value( u'advanced/default service name', translate('OpenLP.AdvancedTab', 'Service %Y-%m-%d %H-%M', 'This may not contain any of the following characters: ' '/\\?*|<>\[\]":+\nSee http://docs.python.org/library/' 'datetime.html#strftime-strptime-behavior for more ' - 'information.')).toString()) + 'information.'))) default_filename = time.strftime(default_pattern) else: default_filename = u'' @@ -692,8 +689,8 @@ class ServiceManager(QtGui.QWidget): self.setFileName(fileName) self.mainwindow.addRecentFile(fileName) self.setModified(False) - QtCore.QSettings().setValue( - 'servicemanager/last file', QtCore.QVariant(fileName)) + Settings().setValue( + 'servicemanager/last file', fileName) else: critical_error_message_box( message=translate('OpenLP.ServiceManager', @@ -734,8 +731,7 @@ class ServiceManager(QtGui.QWidget): service was last closed. Can be blank if there was no service present. """ - fileName = QtCore.QSettings(). \ - value(u'servicemanager/last file',QtCore.QVariant(u'')).toString() + fileName = Settings().value(u'servicemanager/last file', u'') if fileName: self.loadFile(fileName) @@ -1062,15 +1058,14 @@ class ServiceManager(QtGui.QWidget): .is_capable(ItemCapabilities.HasVariableStartTime): tips.append(item[u'service_item'].get_media_time()) treewidgetitem.setToolTip(0, u'
'.join(tips)) - treewidgetitem.setData(0, QtCore.Qt.UserRole, - QtCore.QVariant(item[u'order'])) + treewidgetitem.setData(0, QtCore.Qt.UserRole, item[u'order']) treewidgetitem.setSelected(item[u'selected']) # Add the children to their parent treewidgetitem. for count, frame in enumerate(serviceitem.get_frames()): child = QtGui.QTreeWidgetItem(treewidgetitem) text = frame[u'title'].replace(u'\n', u' ') child.setText(0, text[:40]) - child.setData(0, QtCore.Qt.UserRole, QtCore.QVariant(count)) + child.setData(0, QtCore.Qt.UserRole, count) if serviceItem == itemcount: if item[u'expanded'] and serviceItemChild == count: self.serviceManagerList.setCurrentItem(child) @@ -1106,10 +1101,9 @@ class ServiceManager(QtGui.QWidget): log.debug(u'onThemeComboBoxSelected') self.service_theme = unicode(self.themeComboBox.currentText()) self.mainwindow.renderer.set_service_theme(self.service_theme) - QtCore.QSettings().setValue( + Settings().setValue( self.mainwindow.serviceManagerSettingsSection + - u'/service theme', - QtCore.QVariant(self.service_theme)) + u'/service theme', self.service_theme) self.regenerateServiceItems(True) def themeChange(self): @@ -1287,9 +1281,9 @@ class ServiceManager(QtGui.QWidget): if self.serviceItems[item][u'service_item'].is_valid: self.mainwindow.liveController.addServiceManagerItem( self.serviceItems[item][u'service_item'], child) - if QtCore.QSettings().value( + if Settings().value( self.mainwindow.generalSettingsSection + u'/auto preview', - QtCore.QVariant(False)).toBool(): + False): item += 1 if self.serviceItems and item < len(self.serviceItems) and \ self.serviceItems[item][u'service_item'].is_capable( diff --git a/openlp/core/ui/shortcutlistform.py b/openlp/core/ui/shortcutlistform.py index 457525dc0..377da339f 100644 --- a/openlp/core/ui/shortcutlistform.py +++ b/openlp/core/ui/shortcutlistform.py @@ -30,7 +30,7 @@ import re from PyQt4 import QtCore, QtGui -from openlp.core.lib import Receiver +from openlp.core.lib import Receiver, Settings from openlp.core.utils import translate from openlp.core.utils.actions import ActionList from shortcutlistdialog import Ui_ShortcutListDialog @@ -131,8 +131,7 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): actionText = REMOVE_AMPERSAND.sub('', unicode(action.text())) actionItem = QtGui.QTreeWidgetItem([actionText]) actionItem.setIcon(0, action.icon()) - actionItem.setData(0, - QtCore.Qt.UserRole, QtCore.QVariant(action)) + actionItem.setData(0, QtCore.Qt.UserRole, action) item.addChild(actionItem) self.treeWidget.addTopLevelItem(item) item.setExpanded(True) @@ -337,7 +336,7 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): Save the shortcuts. **Note**, that we do not have to load the shortcuts, as they are loaded in :class:`~openlp.core.utils.ActionList`. """ - settings = QtCore.QSettings() + settings = Settings() settings.beginGroup(u'shortcuts') for category in self.action_list.categories: # Check if the category is for internal use only. @@ -349,8 +348,7 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): map(QtGui.QKeySequence.toString, action.shortcuts())) action.setShortcuts(self.changedActions[action]) self.action_list.update_shortcut_map(action, old_shortcuts) - settings.setValue( - action.objectName(), QtCore.QVariant(action.shortcuts())) + settings.setValue(action.objectName(), action.shortcuts()) settings.endGroup() def onClearPrimaryButtonClicked(self, toggled): diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index 1dc005aa6..2dff89bc3 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -35,7 +35,7 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import OpenLPToolbar, Receiver, ItemCapabilities, \ translate, build_icon, build_html, PluginManager, ServiceItem from openlp.core.lib.ui import UiStrings, create_action -from openlp.core.lib import SlideLimits, ServiceItemAction +from openlp.core.lib import SlideLimits, ServiceItemAction, Settings from openlp.core.ui import HideMode, MainDisplay, Display, ScreenList from openlp.core.utils.actions import ActionList, CategoryOrder @@ -236,8 +236,8 @@ class SlideController(Controller): text=UiStrings().PlaySlidesToEnd, icon=u':/media/media_time.png', checked=False, shortcuts=[], category=self.category, triggers=self.onPlaySlidesOnce) - if QtCore.QSettings().value(self.parent().generalSettingsSection + - u'/enable slide loop', QtCore.QVariant(True)).toBool(): + if Settings().value(self.parent().generalSettingsSection + + u'/enable slide loop', True): self.playSlidesMenu.setDefaultAction(self.playSlidesLoop) else: self.playSlidesMenu.setDefaultAction(self.playSlidesOnce) @@ -662,9 +662,9 @@ class SlideController(Controller): """ Updates the Slide Limits variable from the settings. """ - self.slide_limits = QtCore.QSettings().value( + self.slide_limits = Settings().value( self.parent().advancedSettingsSection + u'/slide limits', - QtCore.QVariant(SlideLimits.End)).toInt()[0] + SlideLimits.End) def enableToolBar(self, item): """ @@ -692,9 +692,9 @@ class SlideController(Controller): self.playSlidesLoop.setChecked(False) self.playSlidesLoop.setIcon(build_icon(u':/media/media_time.png')) if item.is_text(): - if QtCore.QSettings().value( + if Settings().value( self.parent().songsSettingsSection + u'/display songbar', - QtCore.QVariant(True)).toBool() and self.slideList: + True) and self.slideList: self.songMenu.show() if item.is_capable(ItemCapabilities.CanLoop) and \ len(item.get_frames()) > 1: @@ -813,14 +813,14 @@ class SlideController(Controller): QtCore.QObject.connect(action, QtCore.SIGNAL(u'triggered(bool)'), self.onTrackTriggered) - self.display.audioPlayer.repeat = QtCore.QSettings().value( + self.display.audioPlayer.repeat = Settings().value( self.parent().generalSettingsSection + \ u'/audio repeat list', - QtCore.QVariant(False)).toBool() - if QtCore.QSettings().value( + False) + if Settings().value( self.parent().generalSettingsSection + \ u'/audio start paused', - QtCore.QVariant(True)).toBool(): + True): self.audioPauseItem.setChecked(True) self.display.audioPlayer.pause() else: @@ -930,9 +930,8 @@ class SlideController(Controller): Allow the main display to blank the main display at startup time """ log.debug(u'mainDisplaySetBackground live = %s' % self.isLive) - display_type = QtCore.QSettings().value( - self.parent().generalSettingsSection + u'/screen blank', - QtCore.QVariant(u'')).toString() + display_type = Settings().value( + self.parent().generalSettingsSection + u'/screen blank', u'') if self.screens.which_screen(self.window()) != \ self.screens.which_screen(self.display): # Order done to handle initial conversion @@ -971,11 +970,11 @@ class SlideController(Controller): self.themeScreen.setChecked(False) self.desktopScreen.setChecked(False) if checked: - QtCore.QSettings().setValue( + Settings().setValue( self.parent().generalSettingsSection + u'/screen blank', - QtCore.QVariant(u'blanked')) + u'blanked') else: - QtCore.QSettings().remove( + Settings().remove( self.parent().generalSettingsSection + u'/screen blank') self.blankPlugin() self.updatePreview() @@ -992,11 +991,11 @@ class SlideController(Controller): self.themeScreen.setChecked(checked) self.desktopScreen.setChecked(False) if checked: - QtCore.QSettings().setValue( + Settings().setValue( self.parent().generalSettingsSection + u'/screen blank', - QtCore.QVariant(u'themed')) + u'themed') else: - QtCore.QSettings().remove( + Settings().remove( self.parent().generalSettingsSection + u'/screen blank') self.blankPlugin() self.updatePreview() @@ -1013,11 +1012,11 @@ class SlideController(Controller): self.themeScreen.setChecked(False) self.desktopScreen.setChecked(checked) if checked: - QtCore.QSettings().setValue( + Settings().setValue( self.parent().generalSettingsSection + u'/screen blank', - QtCore.QVariant(u'hidden')) + u'hidden') else: - QtCore.QSettings().remove( + Settings().remove( self.parent().generalSettingsSection + u'/screen blank') self.hidePlugin(checked) self.updatePreview() @@ -1311,8 +1310,8 @@ class SlideController(Controller): """ triggered by clicking the Preview slide items """ - if QtCore.QSettings().value(u'advanced/double click live', - QtCore.QVariant(False)).toBool(): + if Settings().value(u'advanced/double click live', + False): # Live and Preview have issues if we have video or presentations # playing in both at the same time. if self.serviceItem.is_command(): @@ -1397,5 +1396,4 @@ class SlideController(Controller): def onTrackTriggered(self): action = self.sender() - index = action.data().toInt()[0] - self.display.audioPlayer.goTo(index) + self.display.audioPlayer.goTo(action.data()) diff --git a/openlp/core/ui/themeform.py b/openlp/core/ui/themeform.py index f8c061851..1a9f142f7 100644 --- a/openlp/core/ui/themeform.py +++ b/openlp/core/ui/themeform.py @@ -350,38 +350,38 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard): if self.theme.background_type == \ BackgroundType.to_string(BackgroundType.Solid): self.colorButton.setStyleSheet(u'background-color: %s' % - self.theme.background_color) - self.setField(u'background_type', QtCore.QVariant(0)) + self.theme.background_color) + self.setField(u'background_type', 0) elif self.theme.background_type == \ BackgroundType.to_string(BackgroundType.Gradient): self.gradientStartButton.setStyleSheet(u'background-color: %s' % self.theme.background_start_color) self.gradientEndButton.setStyleSheet(u'background-color: %s' % self.theme.background_end_color) - self.setField(u'background_type', QtCore.QVariant(1)) + self.setField(u'background_type', 1) elif self.theme.background_type == \ BackgroundType.to_string(BackgroundType.Image): self.imageColorButton.setStyleSheet(u'background-color: %s' % self.theme.background_border_color) self.imageFileEdit.setText(self.theme.background_filename) - self.setField(u'background_type', QtCore.QVariant(2)) + self.setField(u'background_type', 2) elif self.theme.background_type == \ BackgroundType.to_string(BackgroundType.Transparent): - self.setField(u'background_type', QtCore.QVariant(3)) + self.setField(u'background_type', 3) if self.theme.background_direction == \ BackgroundGradientType.to_string(BackgroundGradientType.Horizontal): - self.setField(u'gradient', QtCore.QVariant(0)) + self.setField(u'gradient', 0) elif self.theme.background_direction == \ BackgroundGradientType.to_string(BackgroundGradientType.Vertical): - self.setField(u'gradient', QtCore.QVariant(1)) + self.setField(u'gradient', 1) elif self.theme.background_direction == \ BackgroundGradientType.to_string(BackgroundGradientType.Circular): - self.setField(u'gradient', QtCore.QVariant(2)) + self.setField(u'gradient', 2) elif self.theme.background_direction == \ BackgroundGradientType.to_string(BackgroundGradientType.LeftTop): - self.setField(u'gradient', QtCore.QVariant(3)) + self.setField(u'gradient', 3) else: - self.setField(u'gradient', QtCore.QVariant(4)) + self.setField(u'gradient', 4) def setMainAreaPageValues(self): """ @@ -391,26 +391,19 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard): QtGui.QFont(self.theme.font_main_name)) self.mainColorButton.setStyleSheet(u'background-color: %s' % self.theme.font_main_color) - self.setField(u'mainSizeSpinBox', - QtCore.QVariant(self.theme.font_main_size)) + self.setField(u'mainSizeSpinBox', self.theme.font_main_size) self.setField(u'lineSpacingSpinBox', - QtCore.QVariant(self.theme.font_main_line_adjustment)) - self.setField(u'outlineCheckBox', - QtCore.QVariant(self.theme.font_main_outline)) + self.theme.font_main_line_adjustment) + self.setField(u'outlineCheckBox', self.theme.font_main_outline) self.outlineColorButton.setStyleSheet(u'background-color: %s' % self.theme.font_main_outline_color) - self.setField(u'outlineSizeSpinBox', - QtCore.QVariant(self.theme.font_main_outline_size)) - self.setField(u'shadowCheckBox', - QtCore.QVariant(self.theme.font_main_shadow)) + self.setField(u'outlineSizeSpinBox', self.theme.font_main_outline_size) + self.setField(u'shadowCheckBox', self.theme.font_main_shadow) self.shadowColorButton.setStyleSheet(u'background-color: %s' % self.theme.font_main_shadow_color) - self.setField(u'shadowSizeSpinBox', - QtCore.QVariant(self.theme.font_main_shadow_size)) - self.setField(u'mainBoldCheckBox', - QtCore.QVariant(self.theme.font_main_bold)) - self.setField(u'mainItalicsCheckBox', - QtCore.QVariant(self.theme.font_main_italics)) + self.setField(u'shadowSizeSpinBox', self.theme.font_main_shadow_size) + self.setField(u'mainBoldCheckBox', self.theme.font_main_bold) + self.setField(u'mainItalicsCheckBox', self.theme.font_main_italics) def setFooterAreaPageValues(self): """ @@ -420,8 +413,7 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard): QtGui.QFont(self.theme.font_footer_name)) self.footerColorButton.setStyleSheet(u'background-color: %s' % self.theme.font_footer_color) - self.setField(u'footerSizeSpinBox', - QtCore.QVariant(self.theme.font_footer_size)) + self.setField(u'footerSizeSpinBox', self.theme.font_footer_size) def setPositionPageValues(self): """ @@ -429,40 +421,31 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard): """ # Main Area self.mainPositionCheckBox.setChecked(not self.theme.font_main_override) - self.setField(u'mainPositionX', QtCore.QVariant(self.theme.font_main_x)) - self.setField(u'mainPositionY', QtCore.QVariant(self.theme.font_main_y)) - self.setField(u'mainPositionHeight', - QtCore.QVariant(self.theme.font_main_height)) - self.setField(u'mainPositionWidth', - QtCore.QVariant(self.theme.font_main_width)) + self.setField(u'mainPositionX', self.theme.font_main_x) + self.setField(u'mainPositionY', self.theme.font_main_y) + self.setField(u'mainPositionHeight', self.theme.font_main_height) + self.setField(u'mainPositionWidth', self.theme.font_main_width) # Footer self.footerPositionCheckBox.setChecked( not self.theme.font_footer_override) - self.setField(u'footerPositionX', - QtCore.QVariant(self.theme.font_footer_x)) - self.setField(u'footerPositionY', - QtCore.QVariant(self.theme.font_footer_y)) - self.setField(u'footerPositionHeight', - QtCore.QVariant(self.theme.font_footer_height)) - self.setField(u'footerPositionWidth', - QtCore.QVariant(self.theme.font_footer_width)) + self.setField(u'footerPositionX', self.theme.font_footer_x) + self.setField(u'footerPositionY', self.theme.font_footer_y) + self.setField(u'footerPositionHeight', self.theme.font_footer_height) + self.setField(u'footerPositionWidth', self.theme.font_footer_width) def setAlignmentPageValues(self): """ Handle the display and state of the Alignments page. """ - self.setField(u'horizontal', - QtCore.QVariant(self.theme.display_horizontal_align)) - self.setField(u'vertical', - QtCore.QVariant(self.theme.display_vertical_align)) - self.setField(u'slideTransition', - QtCore.QVariant(self.theme.display_slide_transition)) + self.setField(u'horizontal', self.theme.display_horizontal_align) + self.setField(u'vertical', self.theme.display_vertical_align) + self.setField(u'slideTransition', self.theme.display_slide_transition) def setPreviewPageValues(self): """ Handle the display and state of the Preview page. """ - self.setField(u'name', QtCore.QVariant(self.theme.theme_name)) + self.setField(u'name', self.theme.theme_name) def onBackgroundComboBoxCurrentIndexChanged(self, index): """ diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index 665c435b9..f4235e2b4 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -36,7 +36,7 @@ from xml.etree.ElementTree import ElementTree, XML from PyQt4 import QtCore, QtGui from openlp.core.lib import OpenLPToolbar, get_text_file_string, build_icon, \ - Receiver, SettingsManager, translate, check_item_selected, \ + Receiver, Settings, SettingsManager, translate, check_item_selected, \ check_directory_exists, create_thumb, validate_thumb from openlp.core.lib.theme import ThemeXML, BackgroundType, VerticalType, \ BackgroundGradientType @@ -164,9 +164,8 @@ class ThemeManager(QtGui.QWidget): """ Triggered when Config dialog is updated. """ - self.global_theme = unicode(QtCore.QSettings().value( - self.settingsSection + u'/global theme', - QtCore.QVariant(u'')).toString()) + self.global_theme = Settings().value( + self.settingsSection + u'/global theme', u'') def checkListState(self, item): """ @@ -244,9 +243,8 @@ class ThemeManager(QtGui.QWidget): name = unicode(translate('OpenLP.ThemeManager', '%s (default)')) % self.global_theme self.themeListWidget.item(count).setText(name) - QtCore.QSettings().setValue( - self.settingsSection + u'/global theme', - QtCore.QVariant(self.global_theme)) + Settings().setValue( + self.settingsSection + u'/global theme', self.global_theme) Receiver.send_message(u'theme_update_global', self.global_theme) self._pushThemes() @@ -448,9 +446,8 @@ class ThemeManager(QtGui.QWidget): theme = ThemeXML() theme.theme_name = UiStrings().Default self._writeTheme(theme, None, None) - QtCore.QSettings().setValue( - self.settingsSection + u'/global theme', - QtCore.QVariant(theme.theme_name)) + Settings().setValue( + self.settingsSection + u'/global theme', theme.theme_name) self.configUpdated() files = SettingsManager.get_files(self.settingsSection, u'.png') # Sort the themes by its name considering language specific characters. @@ -475,7 +472,7 @@ class ThemeManager(QtGui.QWidget): else: icon = create_thumb(theme, thumb) item_name.setIcon(icon) - item_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(text_name)) + item_name.setData(QtCore.Qt.UserRole, text_name) self.themeListWidget.addItem(item_name) self.theme_list.append(text_name) self._pushThemes() @@ -767,9 +764,8 @@ class ThemeManager(QtGui.QWidget): Check to see if theme has been selected and the destructive action is allowed. """ - self.global_theme = unicode(QtCore.QSettings().value( - self.settingsSection + u'/global theme', - QtCore.QVariant(u'')).toString()) + self.global_theme = unicode(Settings().value( + self.settingsSection + u'/global theme', u'')) if check_item_selected(self.themeListWidget, select_text): item = self.themeListWidget.currentItem() theme = unicode(item.text()) diff --git a/openlp/core/ui/themestab.py b/openlp/core/ui/themestab.py index f763a9e74..d078cfdac 100644 --- a/openlp/core/ui/themestab.py +++ b/openlp/core/ui/themestab.py @@ -27,7 +27,7 @@ from PyQt4 import QtCore, QtGui -from openlp.core.lib import SettingsTab, Receiver, translate +from openlp.core.lib import Receiver, Settings, SettingsTab, translate from openlp.core.lib.theme import ThemeLevel from openlp.core.lib.ui import UiStrings, find_and_set_in_combo_box @@ -132,11 +132,11 @@ class ThemesTab(SettingsTab): 'any themes associated with either the service or the songs.')) def load(self): - settings = QtCore.QSettings() + settings = Settings() settings.beginGroup(self.settingsSection) - self.theme_level = settings.value( - u'theme level', ThemeLevel.Song).toInt()[0] - self.global_theme = unicode(settings.value(u'global theme').toString()) + self.theme_level = settings.value(u'theme level', ThemeLevel.Song) + # TODO: check empty string (logic). + self.global_theme = settings.value(u'global theme', u'') settings.endGroup() if self.theme_level == ThemeLevel.Global: self.GlobalLevelRadioButton.setChecked(True) @@ -146,10 +146,10 @@ class ThemesTab(SettingsTab): self.SongLevelRadioButton.setChecked(True) def save(self): - settings = QtCore.QSettings() + settings = Settings() settings.beginGroup(self.settingsSection) - settings.setValue(u'theme level', QtCore.QVariant(self.theme_level)) - settings.setValue(u'global theme', QtCore.QVariant(self.global_theme)) + settings.setValue(u'theme level', self.theme_level) + settings.setValue(u'global theme', self.global_theme) settings.endGroup() self.mainwindow.renderer.set_global_theme( self.global_theme, self.theme_level) @@ -183,15 +183,14 @@ class ThemesTab(SettingsTab): [u'Bible Theme', u'Song Theme'] """ # Reload as may have been triggered by the ThemeManager. - self.global_theme = unicode(QtCore.QSettings().value( - self.settingsSection + u'/global theme', - QtCore.QVariant(u'')).toString()) + self.global_theme = Settings().value( + self.settingsSection + u'/global theme', u'') self.DefaultComboBox.clear() self.DefaultComboBox.addItems(theme_list) find_and_set_in_combo_box(self.DefaultComboBox, self.global_theme) self.mainwindow.renderer.set_global_theme( self.global_theme, self.theme_level) - if self.global_theme is not u'': + if self.global_theme: self.__previewGlobalTheme() def __previewGlobalTheme(self): diff --git a/openlp/core/utils/__init__.py b/openlp/core/utils/__init__.py index 9d00e22b7..57d0a33c6 100644 --- a/openlp/core/utils/__init__.py +++ b/openlp/core/utils/__init__.py @@ -37,6 +37,8 @@ import sys import time import urllib2 +from openlp.core.lib import Settings + from PyQt4 import QtGui, QtCore if sys.platform != u'win32' and sys.platform != u'darwin': @@ -281,12 +283,12 @@ def check_latest_version(current_version): """ version_string = current_version[u'full'] # set to prod in the distribution config file. - settings = QtCore.QSettings() + settings = Settings() settings.beginGroup(u'general') last_test = unicode(settings.value(u'last version test', - QtCore.QVariant(datetime.now().date())).toString()) + datetime.now().date())) this_test = unicode(datetime.now().date()) - settings.setValue(u'last version test', QtCore.QVariant(this_test)) + settings.setValue(u'last version test', this_test) settings.endGroup() if last_test != this_test: if current_version[u'build']: diff --git a/openlp/core/utils/actions.py b/openlp/core/utils/actions.py index 271a7c884..961037675 100644 --- a/openlp/core/utils/actions.py +++ b/openlp/core/utils/actions.py @@ -28,6 +28,8 @@ The :mod:`~openlp.core.utils.actions` module provides action list classes used by the shortcuts system. """ +from openlp.core.lib import Settings + from PyQt4 import QtCore, QtGui class ActionCategory(object): @@ -226,10 +228,9 @@ class ActionList(object): else: self.categories[category].actions.add(action, weight) # Load the shortcut from the config. - settings = QtCore.QSettings() + settings = Settings() settings.beginGroup(u'shortcuts') - shortcuts = settings.value(action.objectName(), - QtCore.QVariant(action.shortcuts())).toStringList() + shortcuts = settings.value(action.objectName(), action.shortcuts()) settings.endGroup() if not shortcuts: action.setShortcuts([]) diff --git a/openlp/core/utils/languagemanager.py b/openlp/core/utils/languagemanager.py index 929105ad2..65582885a 100644 --- a/openlp/core/utils/languagemanager.py +++ b/openlp/core/utils/languagemanager.py @@ -34,7 +34,7 @@ import sys from PyQt4 import QtCore, QtGui from openlp.core.utils import AppLocation -from openlp.core.lib import translate +from openlp.core.lib import translate, Settings log = logging.getLogger(__name__) @@ -75,13 +75,16 @@ class LanguageManager(object): AppLocation.LanguageDir)) trans_dir = QtCore.QDir(AppLocation.get_directory( AppLocation.LanguageDir)) - file_names = trans_dir.entryList(QtCore.QStringList(u'*.qm'), - QtCore.QDir.Files, QtCore.QDir.Name) + file_names = trans_dir.entryList( + u'*.qm', QtCore.QDir.Files, QtCore.QDir.Name) # Remove qm files from the list which start with "qt_". - file_names = file_names.filter(QtCore.QRegExp("^(?!qt_)")) + file_names = filter( + lambda file_: not file_.startswith(u'qt_'), file_names) + names = [] for name in file_names: - file_names.replaceInStrings(name, trans_dir.filePath(name)) - return file_names + names.append(trans_dir.filePath(name)) + #file_names.replaceInStrings(name, trans_dir.filePath(name)) + return names @staticmethod def language_name(qm_file): @@ -101,9 +104,8 @@ class LanguageManager(object): """ Retrieve a saved language to use from settings """ - settings = QtCore.QSettings() - language = unicode(settings.value( - u'general/language', QtCore.QVariant(u'[en]')).toString()) + settings = Settings() + language = unicode(settings.value(u'general/language', u'[en]')) log.info(u'Language file: \'%s\' Loaded from conf file' % language) reg_ex = QtCore.QRegExp("^\[(.*)\]") if reg_ex.exactMatch(language): @@ -133,8 +135,7 @@ class LanguageManager(object): language = unicode(qm_list[action_name]) if LanguageManager.auto_language: language = u'[%s]' % language - QtCore.QSettings().setValue( - u'general/language', QtCore.QVariant(language)) + Settings().setValue(u'general/language', language) log.info(u'Language file: \'%s\' written to conf file' % language) if message: QtGui.QMessageBox.information(None, diff --git a/openlp/plugins/alerts/alertsplugin.py b/openlp/plugins/alerts/alertsplugin.py index ebaabb214..03078b5cb 100644 --- a/openlp/plugins/alerts/alertsplugin.py +++ b/openlp/plugins/alerts/alertsplugin.py @@ -29,7 +29,8 @@ import logging from PyQt4 import QtCore -from openlp.core.lib import Plugin, StringContent, build_icon, translate +from openlp.core.lib import Plugin, StringContent, build_icon, translate, \ + Settings from openlp.core.lib.db import Manager from openlp.core.lib.ui import create_action, UiStrings from openlp.core.lib.theme import VerticalType @@ -160,8 +161,8 @@ class AlertsPlugin(Plugin): def toggleAlertsState(self): self.alertsActive = not self.alertsActive - QtCore.QSettings().setValue(self.settingsSection + u'/active', - QtCore.QVariant(self.alertsActive)) + Settings().setValue(self.settingsSection + u'/active', + self.alertsActive) def onAlertsTrigger(self): self.alertForm.loadList() diff --git a/openlp/plugins/alerts/forms/alertform.py b/openlp/plugins/alerts/forms/alertform.py index 4f7633062..d494d2a4d 100644 --- a/openlp/plugins/alerts/forms/alertform.py +++ b/openlp/plugins/alerts/forms/alertform.py @@ -77,7 +77,7 @@ class AlertForm(QtGui.QDialog, Ui_AlertDialog): order_by_ref=AlertItem.text) for alert in alerts: item_name = QtGui.QListWidgetItem(alert.text) - item_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(alert.id)) + item_name.setData(QtCore.Qt.UserRole, alert.id) self.alertListWidget.addItem(item_name) def onDisplayClicked(self): diff --git a/openlp/plugins/alerts/lib/alertstab.py b/openlp/plugins/alerts/lib/alertstab.py index 22346b0aa..cf0c88409 100644 --- a/openlp/plugins/alerts/lib/alertstab.py +++ b/openlp/plugins/alerts/lib/alertstab.py @@ -27,7 +27,7 @@ from PyQt4 import QtCore, QtGui -from openlp.core.lib import SettingsTab, translate, Receiver +from openlp.core.lib import SettingsTab, translate, Receiver, Settings from openlp.core.ui import AlertLocation from openlp.core.lib.ui import UiStrings, create_valign_selection_widgets @@ -152,19 +152,15 @@ class AlertsTab(SettingsTab): self.updateDisplay() def load(self): - settings = QtCore.QSettings() + settings = Settings() settings.beginGroup(self.settingsSection) - self.timeout = settings.value(u'timeout', QtCore.QVariant(5)).toInt()[0] - self.font_color = unicode(settings.value( - u'font color', QtCore.QVariant(u'#ffffff')).toString()) - self.font_size = settings.value( - u'font size', QtCore.QVariant(40)).toInt()[0] - self.bg_color = unicode(settings.value( - u'background color', QtCore.QVariant(u'#660000')).toString()) + self.timeout = settings.value(u'timeout', 5) + self.font_color = unicode(settings.value(u'font color', u'#ffffff')) + self.font_size = settings.value(u'font size', 40) + self.bg_color = unicode(settings.value(u'background color', u'#660000')) self.font_face = unicode(settings.value( - u'font face', QtCore.QVariant(QtGui.QFont().family())).toString()) - self.location = settings.value( - u'location', QtCore.QVariant(AlertLocation.Bottom)).toInt()[0] + u'font face', QtGui.QFont().family())) + self.location = settings.value(u'location', AlertLocation.Bottom) settings.endGroup() self.fontSizeSpinBox.setValue(self.font_size) self.timeoutSpinBox.setValue(self.timeout) @@ -180,20 +176,20 @@ class AlertsTab(SettingsTab): self.changed = False def save(self): - settings = QtCore.QSettings() + settings = Settings() settings.beginGroup(self.settingsSection) # Check value has changed as no event handles this field - if settings.value(u'location', QtCore.QVariant(1)).toInt()[0] != \ + if settings.value(u'location', 1) != \ self.verticalComboBox.currentIndex(): self.changed = True - settings.setValue(u'background color', QtCore.QVariant(self.bg_color)) - settings.setValue(u'font color', QtCore.QVariant(self.font_color)) - settings.setValue(u'font size', QtCore.QVariant(self.font_size)) + settings.setValue(u'background color', self.bg_color) + settings.setValue(u'font color', self.font_color) + settings.setValue(u'font size', self.font_size) self.font_face = self.fontComboBox.currentFont().family() - settings.setValue(u'font face', QtCore.QVariant(self.font_face)) - settings.setValue(u'timeout', QtCore.QVariant(self.timeout)) + settings.setValue(u'font face', self.font_face) + settings.setValue(u'timeout', self.timeout) self.location = self.verticalComboBox.currentIndex() - settings.setValue(u'location', QtCore.QVariant(self.location)) + settings.setValue(u'location', self.location) settings.endGroup() if self.changed: Receiver.send_message(u'update_display_css') diff --git a/openlp/plugins/bibles/bibleplugin.py b/openlp/plugins/bibles/bibleplugin.py index 0dddab214..193960102 100644 --- a/openlp/plugins/bibles/bibleplugin.py +++ b/openlp/plugins/bibles/bibleplugin.py @@ -29,7 +29,8 @@ import logging from PyQt4 import QtCore, QtGui -from openlp.core.lib import Plugin, StringContent, build_icon, translate +from openlp.core.lib import Plugin, StringContent, build_icon, translate, \ + Settings from openlp.core.lib.ui import create_action, UiStrings from openlp.core.utils.actions import ActionList from openlp.plugins.bibles.lib import BibleManager, BiblesTab, BibleMediaItem @@ -91,11 +92,11 @@ class BiblePlugin(Plugin): QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes | QtGui.QMessageBox.No)) == QtGui.QMessageBox.Yes: self.onToolsUpgradeItemTriggered() - settings = QtCore.QSettings() + settings = Settings() settings.beginGroup(self.settingsSection) if settings.contains(u'bookname language'): settings.setValue(u'book name language', settings.value( - u'bookname language', QtCore.QVariant(0)).toInt()[0]) + u'bookname language', 0)) settings.remove(u'bookname language') settings.endGroup() diff --git a/openlp/plugins/bibles/forms/bibleimportform.py b/openlp/plugins/bibles/forms/bibleimportform.py index cc50fdf9b..299c7430a 100644 --- a/openlp/plugins/bibles/forms/bibleimportform.py +++ b/openlp/plugins/bibles/forms/bibleimportform.py @@ -33,7 +33,7 @@ import locale from PyQt4 import QtCore, QtGui -from openlp.core.lib import Receiver, translate +from openlp.core.lib import Receiver, translate, Settings from openlp.core.lib.db import delete_database from openlp.core.lib.ui import UiStrings, critical_error_message_box from openlp.core.ui.wizard import OpenLPWizard, WizardStrings @@ -590,32 +590,26 @@ class BibleImportForm(OpenLPWizard): """ Set default values for the wizard pages. """ - settings = QtCore.QSettings() + settings = Settings() settings.beginGroup(self.plugin.settingsSection) self.restart() self.finishButton.setVisible(False) self.cancelButton.setVisible(True) - self.setField(u'source_format', QtCore.QVariant(0)) - self.setField(u'osis_location', QtCore.QVariant('')) - self.setField(u'csv_booksfile', QtCore.QVariant('')) - self.setField(u'csv_versefile', QtCore.QVariant('')) - self.setField(u'opensong_file', QtCore.QVariant('')) - self.setField(u'web_location', QtCore.QVariant(WebDownload.Crosswalk)) + self.setField(u'source_format', 0) + self.setField(u'osis_location', '') + self.setField(u'csv_booksfile', '') + self.setField(u'csv_versefile', '') + self.setField(u'opensong_file', '') + self.setField(u'web_location', WebDownload.Crosswalk) self.setField(u'web_biblename', - QtCore.QVariant(self.webTranslationComboBox.currentIndex())) - self.setField(u'proxy_server', - settings.value(u'proxy address', QtCore.QVariant(u''))) - self.setField(u'proxy_username', - settings.value(u'proxy username', QtCore.QVariant(u''))) - self.setField(u'proxy_password', - settings.value(u'proxy password', QtCore.QVariant(u''))) - self.setField(u'openlp1_location', QtCore.QVariant('')) - self.setField(u'license_version', - QtCore.QVariant(self.versionNameEdit.text())) - self.setField(u'license_copyright', - QtCore.QVariant(self.copyrightEdit.text())) - self.setField(u'license_permissions', - QtCore.QVariant(self.permissionsEdit.text())) + self.webTranslationComboBox.currentIndex()) + self.setField(u'proxy_server', settings.value(u'proxy address', u'')) + self.setField(u'proxy_username', settings.value(u'proxy username', u'')) + self.setField(u'proxy_password', settings.value(u'proxy password', u'')) + self.setField(u'openlp1_location', '') + self.setField(u'license_version', self.versionNameEdit.text()) + self.setField(u'license_copyright', self.copyrightEdit.text()) + self.setField(u'license_permissions', self.permissionsEdit.text()) self.onWebSourceComboBoxIndexChanged(WebDownload.Crosswalk) settings.endGroup() diff --git a/openlp/plugins/bibles/forms/bibleupgradeform.py b/openlp/plugins/bibles/forms/bibleupgradeform.py index 88bbd8c63..fddefec36 100644 --- a/openlp/plugins/bibles/forms/bibleupgradeform.py +++ b/openlp/plugins/bibles/forms/bibleupgradeform.py @@ -34,7 +34,7 @@ from tempfile import gettempdir from PyQt4 import QtCore, QtGui from openlp.core.lib import Receiver, SettingsManager, translate, \ - check_directory_exists + check_directory_exists, Settings from openlp.core.lib.ui import UiStrings, critical_error_message_box from openlp.core.ui.wizard import OpenLPWizard, WizardStrings from openlp.core.utils import AppLocation, delete_file @@ -341,7 +341,7 @@ class BibleUpgradeForm(OpenLPWizard): Set default values for the wizard pages. """ log.debug(u'BibleUpgrade setDefaults') - settings = QtCore.QSettings() + settings = Settings() settings.beginGroup(self.plugin.settingsSection) self.stop_import_flag = False self.success.clear() diff --git a/openlp/plugins/bibles/lib/__init__.py b/openlp/plugins/bibles/lib/__init__.py index 6cd8b8d8e..b5dc0087a 100644 --- a/openlp/plugins/bibles/lib/__init__.py +++ b/openlp/plugins/bibles/lib/__init__.py @@ -33,7 +33,7 @@ import re from PyQt4 import QtCore -from openlp.core.lib import translate +from openlp.core.lib import translate, Settings from openlp.plugins.bibles.lib.db import BiblesResourcesDB log = logging.getLogger(__name__) @@ -185,13 +185,13 @@ def update_reference_separators(): ':|v|V|verse|verses;;-|to;;,|and;;end', 'Double-semicolon delimited separators for parsing references. ' 'Consult the developers for further information.')).split(u';;') - settings = QtCore.QSettings() + settings = Settings() settings.beginGroup(u'bibles') custom_separators = [ - unicode(settings.value(u'verse separator').toString()), - unicode(settings.value(u'range separator').toString()), - unicode(settings.value(u'list separator').toString()), - unicode(settings.value(u'end separator').toString())] + settings.value(u'verse separator'), + settings.value(u'range separator'), + settings.value(u'list separator'), + settings.value(u'end separator')] settings.endGroup() for index, role in enumerate([u'v', u'r', u'l', u'e']): if custom_separators[index].strip(u'|') == u'': diff --git a/openlp/plugins/bibles/lib/biblestab.py b/openlp/plugins/bibles/lib/biblestab.py index c352a5faf..148b75cd5 100644 --- a/openlp/plugins/bibles/lib/biblestab.py +++ b/openlp/plugins/bibles/lib/biblestab.py @@ -29,7 +29,7 @@ import logging from PyQt4 import QtCore, QtGui -from openlp.core.lib import Receiver, SettingsTab, translate +from openlp.core.lib import Receiver, SettingsTab, translate, Settings from openlp.core.lib.ui import UiStrings, find_and_set_in_combo_box from openlp.plugins.bibles.lib import LayoutStyle, DisplayStyle, \ update_reference_separators, get_reference_separator, LanguageSelection @@ -414,18 +414,14 @@ class BiblesTab(SettingsTab): self.getGreyTextPalette(True)) def load(self): - settings = QtCore.QSettings() + settings = Settings() settings.beginGroup(self.settingsSection) - self.show_new_chapters = settings.value( - u'display new chapter', QtCore.QVariant(False)).toBool() - self.display_style = settings.value( - u'display brackets', QtCore.QVariant(0)).toInt()[0] - self.layout_style = settings.value( - u'verse layout style', QtCore.QVariant(0)).toInt()[0] - self.bible_theme = unicode( - settings.value(u'bible theme', QtCore.QVariant(u'')).toString()) - self.second_bibles = settings.value( - u'second bibles', QtCore.QVariant(True)).toBool() + self.show_new_chapters = settings.value(u'display new chapter', False) + self.display_style = settings.value(u'display brackets', 0) + self.layout_style = settings.value(u'verse layout style', 0) + #TODO: Check + self.bible_theme = unicode(settings.value(u'bible theme', u'')) + self.second_bibles = settings.value(u'second bibles', True) self.newChaptersCheckBox.setChecked(self.show_new_chapters) self.displayStyleComboBox.setCurrentIndex(self.display_style) self.layoutStyleComboBox.setCurrentIndex(self.layout_style) @@ -482,24 +478,19 @@ class BiblesTab(SettingsTab): self.endSeparatorLineEdit.setPalette( self.getGreyTextPalette(False)) self.endSeparatorCheckBox.setChecked(True) - self.language_selection = settings.value( - u'book name language', QtCore.QVariant(0)).toInt()[0] + self.language_selection = settings.value(u'book name language', 0) self.languageSelectionComboBox.setCurrentIndex(self.language_selection) settings.endGroup() def save(self): - settings = QtCore.QSettings() + settings = Settings() settings.beginGroup(self.settingsSection) - settings.setValue(u'display new chapter', - QtCore.QVariant(self.show_new_chapters)) - settings.setValue(u'display brackets', - QtCore.QVariant(self.display_style)) - settings.setValue(u'verse layout style', - QtCore.QVariant(self.layout_style)) - settings.setValue(u'book name language', - QtCore.QVariant(self.language_selection)) - settings.setValue(u'second bibles', QtCore.QVariant(self.second_bibles)) - settings.setValue(u'bible theme', QtCore.QVariant(self.bible_theme)) + settings.setValue(u'display new chapter', self.show_new_chapters) + settings.setValue(u'display brackets', self.display_style) + settings.setValue(u'verse layout style', self.layout_style) + settings.setValue(u'book name language', self.language_selection) + settings.setValue(u'second bibles', self.second_bibles) + settings.setValue(u'bible theme', self.bible_theme) if self.verseSeparatorCheckBox.isChecked(): settings.setValue(u'verse separator', self.verseSeparatorLineEdit.text()) diff --git a/openlp/plugins/bibles/lib/manager.py b/openlp/plugins/bibles/lib/manager.py index 9a82cc388..03382c572 100644 --- a/openlp/plugins/bibles/lib/manager.py +++ b/openlp/plugins/bibles/lib/manager.py @@ -30,7 +30,7 @@ import os from PyQt4 import QtCore -from openlp.core.lib import Receiver, SettingsManager, translate +from openlp.core.lib import Receiver, SettingsManager, translate, Settings from openlp.core.utils import AppLocation, delete_file from openlp.plugins.bibles.lib import parse_reference, \ get_reference_separator, LanguageSelection @@ -125,9 +125,8 @@ class BibleManager(object): self.web = u'Web' self.db_cache = None self.path = AppLocation.get_section_data_path(self.settingsSection) - self.proxy_name = unicode( - QtCore.QSettings().value(self.settingsSection + u'/proxy name', - QtCore.QVariant(u'')).toString()) + self.proxy_name = unicode(Settings().value( + self.settingsSection + u'/proxy name', u'')) self.suffix = u'.sqlite' self.import_wizard = None self.reload_bibles() @@ -334,9 +333,8 @@ class BibleManager(object): if language_selection: language_selection = int(language_selection.value) if language_selection is None or language_selection == -1: - language_selection = QtCore.QSettings().value( - self.settingsSection + u'/bookname language', - QtCore.QVariant(0)).toInt()[0] + language_selection = Settings().value( + self.settingsSection + u'/bookname language', 0) reflist = parse_reference(versetext, self.db_cache[bible], language_selection, book_ref_id) if reflist: @@ -381,9 +379,8 @@ class BibleManager(object): if language_selection and language_selection.value != u'None': return int(language_selection.value) if language_selection is None or language_selection.value == u'None': - return QtCore.QSettings().value( - self.settingsSection + u'/bookname language', - QtCore.QVariant(0)).toInt()[0] + return Settings().value( + self.settingsSection + u'/bookname language', 0) def verse_search(self, bible, second_bible, text): """ @@ -437,7 +434,7 @@ class BibleManager(object): }) return None - def save_meta_data(self, bible, version, copyright, permissions, + def save_meta_data(self, bible, version, copyright, permissions, book_name_language=None): """ Saves the bibles meta data. @@ -456,7 +453,7 @@ class BibleManager(object): """ log.debug(u'get_meta %s,%s', bible, key) return self.db_cache[bible].get_object(BibleMeta, key) - + def update_book(self, bible, book): """ Update a book of the bible. diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index 3c723d760..09c59fdf9 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -31,7 +31,7 @@ import locale from PyQt4 import QtCore, QtGui from openlp.core.lib import MediaManagerItem, Receiver, ItemCapabilities, \ - translate, create_separated_list + translate, create_separated_list, Settings from openlp.core.lib.searchedit import SearchEdit from openlp.core.lib.ui import UiStrings, set_case_insensitive_completer, \ create_horizontal_adjusting_combo_box, critical_error_message_box, \ @@ -101,7 +101,7 @@ class BibleMediaItem(MediaManagerItem): reference = bitem.data(QtCore.Qt.UserRole) if isinstance(reference, QtCore.QVariant): reference = reference.toPyObject() - obj = reference[QtCore.QString(key)] + obj = reference[unicode(key)] if isinstance(obj, QtCore.QVariant): obj = obj.toPyObject() return unicode(obj).strip() @@ -294,8 +294,8 @@ class BibleMediaItem(MediaManagerItem): def configUpdated(self): log.debug(u'configUpdated') - if QtCore.QSettings().value(self.settingsSection + u'/second bibles', - QtCore.QVariant(True)).toBool(): + if Settings().value(self.settingsSection + u'/second bibles', + True): self.advancedSecondLabel.setVisible(True) self.advancedSecondComboBox.setVisible(True) self.quickSecondLabel.setVisible(True) @@ -362,9 +362,9 @@ class BibleMediaItem(MediaManagerItem): translate('BiblesPlugin.MediaItem', 'Text Search'), translate('BiblesPlugin.MediaItem', 'Search Text...')) ]) - self.quickSearchEdit.setCurrentSearchType(QtCore.QSettings().value( + self.quickSearchEdit.setCurrentSearchType(Settings().value( u'%s/last search type' % self.settingsSection, - QtCore.QVariant(BibleSearch.Reference)).toInt()[0]) + BibleSearch.Reference)) self.configUpdated() log.debug(u'bible manager initialise complete') @@ -386,17 +386,16 @@ class BibleMediaItem(MediaManagerItem): self.advancedVersionComboBox.addItems(bibles) self.advancedSecondComboBox.addItems(bibles) # set the default value - bible = QtCore.QSettings().value( - self.settingsSection + u'/advanced bible', - QtCore.QVariant(u'')).toString() + bible = Settings().value( + self.settingsSection + u'/advanced bible', u'') if bible in bibles: find_and_set_in_combo_box(self.advancedVersionComboBox, bible) self.initialiseAdvancedBible(unicode(bible)) elif bibles: self.initialiseAdvancedBible(bibles[0]) - bible = QtCore.QSettings().value( - self.settingsSection + u'/quick bible', QtCore.QVariant( - self.quickVersionComboBox.currentText())).toString() + bible = Settings().value( + self.settingsSection + u'/quick bible', + self.quickVersionComboBox.currentText()) find_and_set_in_combo_box(self.quickVersionComboBox, bible) def reloadBibles(self, process=False): @@ -417,7 +416,7 @@ class BibleMediaItem(MediaManagerItem): ``bible`` The bible to initialise (unicode). - + ``last_book_id`` The "book reference id" of the book which is choosen at the moment. (int) @@ -453,14 +452,14 @@ class BibleMediaItem(MediaManagerItem): book[u'book_reference_id']) self.advancedBookComboBox.addItem(data[u'name']) self.advancedBookComboBox.setItemData( - row, QtCore.QVariant(book[u'book_reference_id'])) + row, book[u'book_reference_id']) if first: first = False first_book = book initialise_chapter_verse = True if last_book_id and last_book_id == int(book[u'book_reference_id']): index = self.advancedBookComboBox.findData( - QtCore.QVariant(book[u'book_reference_id'])) + book[u'book_reference_id']) if index == -1: # Not Found. index = 0 @@ -497,12 +496,11 @@ class BibleMediaItem(MediaManagerItem): """ log.debug(u'updateAutoCompleter') # Save the current search type to the configuration. - QtCore.QSettings().setValue(u'%s/last search type' % - self.settingsSection, - QtCore.QVariant(self.quickSearchEdit.currentSearchType())) + Settings().setValue(u'%s/last search type' % + self.settingsSection, self.quickSearchEdit.currentSearchType()) # Save the current bible to the configuration. - QtCore.QSettings().setValue(self.settingsSection + u'/quick bible', - QtCore.QVariant(self.quickVersionComboBox.currentText())) + Settings().setValue(self.settingsSection + u'/quick bible', + self.quickVersionComboBox.currentText()) books = [] # We have to do a 'Reference Search'. if self.quickSearchEdit.currentSearchType() == BibleSearch.Reference: @@ -596,22 +594,22 @@ class BibleMediaItem(MediaManagerItem): self.advancedStyleComboBox.setCurrentIndex(self.settings.layout_style) self.settings.layoutStyleComboBox.setCurrentIndex( self.settings.layout_style) - QtCore.QSettings().setValue( + Settings().setValue( self.settingsSection + u'/verse layout style', - QtCore.QVariant(self.settings.layout_style)) + self.settings.layout_style) def onAdvancedStyleComboBoxChanged(self): self.settings.layout_style = self.advancedStyleComboBox.currentIndex() self.quickStyleComboBox.setCurrentIndex(self.settings.layout_style) self.settings.layoutStyleComboBox.setCurrentIndex( self.settings.layout_style) - QtCore.QSettings().setValue( + Settings().setValue( self.settingsSection + u'/verse layout style', - QtCore.QVariant(self.settings.layout_style)) + self.settings.layout_style) def onAdvancedVersionComboBox(self): - QtCore.QSettings().setValue(self.settingsSection + u'/advanced bible', - QtCore.QVariant(self.advancedVersionComboBox.currentText())) + Settings().setValue(self.settingsSection + u'/advanced bible', + self.advancedVersionComboBox.currentText()) self.initialiseAdvancedBible( unicode(self.advancedVersionComboBox.currentText()), self.advancedBookComboBox.itemData( @@ -855,24 +853,24 @@ class BibleMediaItem(MediaManagerItem): verse.book.book_reference_id) book = data[u'name'] data = { - 'book': QtCore.QVariant(book), - 'chapter': QtCore.QVariant(verse.chapter), - 'verse': QtCore.QVariant(verse.verse), - 'bible': QtCore.QVariant(bible), - 'version': QtCore.QVariant(version), - 'copyright': QtCore.QVariant(copyright), - 'permissions': QtCore.QVariant(permissions), - 'text': QtCore.QVariant(verse.text), - 'second_bible': QtCore.QVariant(second_bible), - 'second_version': QtCore.QVariant(second_version), - 'second_copyright': QtCore.QVariant(second_copyright), - 'second_permissions': QtCore.QVariant(second_permissions), - 'second_text': QtCore.QVariant(u'') + 'book': book, + 'chapter': verse.chapter, + 'verse': verse.verse, + 'bible': bible, + 'version': version, + 'copyright': copyright, + 'permissions': permissions, + 'text': verse.text, + 'second_bible': second_bible, + 'second_version': second_version, + 'second_copyright': second_copyright, + 'second_permissions': second_permissions, + 'second_text': u'' } if second_bible: try: - data[u'second_text'] = QtCore.QVariant( - self.second_search_results[count].text) + data[u'second_text'] = \ + self.second_search_results[count].text except IndexError: log.exception(u'The second_search_results does not have as ' 'many verses as the search_results.') @@ -883,7 +881,7 @@ class BibleMediaItem(MediaManagerItem): bible_text = u'%s %d%s%d (%s)' % (book, verse.chapter, verse_separator, verse.verse, version) bible_verse = QtGui.QListWidgetItem(bible_text) - bible_verse.setData(QtCore.Qt.UserRole, QtCore.QVariant(data)) + bible_verse.setData(QtCore.Qt.UserRole, data) items.append(bible_verse) return items diff --git a/openlp/plugins/custom/lib/customtab.py b/openlp/plugins/custom/lib/customtab.py index 0466cf696..d3f5f2b46 100644 --- a/openlp/plugins/custom/lib/customtab.py +++ b/openlp/plugins/custom/lib/customtab.py @@ -27,7 +27,7 @@ from PyQt4 import QtCore, QtGui -from openlp.core.lib import SettingsTab, translate +from openlp.core.lib import SettingsTab, translate, Settings class CustomTab(SettingsTab): """ @@ -66,11 +66,10 @@ class CustomTab(SettingsTab): self.displayFooter = True def load(self): - self.displayFooter = QtCore.QSettings().value( - self.settingsSection + u'/display footer', - QtCore.QVariant(True)).toBool() + self.displayFooter = Settings().value( + self.settingsSection + u'/display footer', True) self.displayFooterCheckBox.setChecked(self.displayFooter) def save(self): - QtCore.QSettings().setValue(self.settingsSection + u'/display footer', - QtCore.QVariant(self.displayFooter)) + Settings().setValue(self.settingsSection + u'/display footer', + self.displayFooter) diff --git a/openlp/plugins/custom/lib/mediaitem.py b/openlp/plugins/custom/lib/mediaitem.py index af2f261ca..bea2858d8 100644 --- a/openlp/plugins/custom/lib/mediaitem.py +++ b/openlp/plugins/custom/lib/mediaitem.py @@ -32,7 +32,7 @@ from PyQt4 import QtCore, QtGui from sqlalchemy.sql import or_, func from openlp.core.lib import MediaManagerItem, Receiver, ItemCapabilities, \ - check_item_selected, translate + check_item_selected, translate, Settings from openlp.core.lib.ui import UiStrings from openlp.plugins.custom.forms import EditCustomForm from openlp.plugins.custom.lib import CustomXMLParser @@ -99,9 +99,8 @@ class CustomMediaItem(MediaManagerItem): ]) self.loadList(self.manager.get_all_objects( CustomSlide, order_by_ref=CustomSlide.title)) - self.searchTextEdit.setCurrentSearchType(QtCore.QSettings().value( - u'%s/last search type' % self.settingsSection, - QtCore.QVariant(CustomSearch.Titles)).toInt()[0]) + self.searchTextEdit.setCurrentSearchType(Settings().value( + u'%s/last search type' % self.settingsSection, CustomSearch.Titles)) def loadList(self, custom_slides): # Sort out what custom we want to select after loading the list. @@ -113,8 +112,7 @@ class CustomMediaItem(MediaManagerItem): cmp=locale.strcoll, key=lambda custom: custom.title.lower()) for custom_slide in custom_slides: custom_name = QtGui.QListWidgetItem(custom_slide.title) - custom_name.setData( - QtCore.Qt.UserRole, QtCore.QVariant(custom_slide.id)) + custom_name.setData(QtCore.Qt.UserRole, custom_slide.id) self.listView.addItem(custom_name) # Auto-select the custom. if custom_slide.id == self.autoSelectId: @@ -218,8 +216,8 @@ class CustomMediaItem(MediaManagerItem): service_item.title = title for slide in raw_slides: service_item.add_from_text(slide[:30], slide) - if QtCore.QSettings().value(self.settingsSection + u'/display footer', - QtCore.QVariant(True)).toBool() or credit: + if Settings().value(self.settingsSection + u'/display footer', + True) or credit: raw_footer.append(title + u' ' + credit) else: raw_footer.append(u'') @@ -228,9 +226,8 @@ class CustomMediaItem(MediaManagerItem): def onSearchTextButtonClicked(self): # Save the current search type to the configuration. - QtCore.QSettings().setValue(u'%s/last search type' % - self.settingsSection, - QtCore.QVariant(self.searchTextEdit.currentSearchType())) + Settings().setValue(u'%s/last search type' % + self.settingsSection, self.searchTextEdit.currentSearchType()) # Reload the list considering the new search type. search_keywords = unicode(self.searchTextEdit.displayText()) search_results = [] diff --git a/openlp/plugins/images/imageplugin.py b/openlp/plugins/images/imageplugin.py index 53f825916..e547a34cc 100644 --- a/openlp/plugins/images/imageplugin.py +++ b/openlp/plugins/images/imageplugin.py @@ -29,8 +29,8 @@ from PyQt4 import QtCore, QtGui import logging -from openlp.core.lib import Plugin, StringContent, build_icon, translate, \ - Receiver +from openlp.core.lib import build_icon, Plugin, Receiver, Settings, \ + StringContent, translate from openlp.plugins.images.lib import ImageMediaItem, ImageTab log = logging.getLogger(__name__) @@ -94,6 +94,6 @@ class ImagePlugin(Plugin): image manager to require updates. Actual update is triggered by the last part of saving the config. """ - background = QtGui.QColor(QtCore.QSettings().value(self.settingsSection - + u'/background color', QtCore.QVariant(u'#000000'))) + background = QtGui.QColor(Settings().value(self.settingsSection + + u'/background color', u'#000000')) self.liveController.imageManager.update_images(u'image', background) diff --git a/openlp/plugins/images/lib/imagetab.py b/openlp/plugins/images/lib/imagetab.py index a8188ace6..1fc6e834b 100644 --- a/openlp/plugins/images/lib/imagetab.py +++ b/openlp/plugins/images/lib/imagetab.py @@ -27,7 +27,7 @@ from PyQt4 import QtCore, QtGui -from openlp.core.lib import SettingsTab, translate, Receiver +from openlp.core.lib import Receiver, Settings, SettingsTab, translate class ImageTab(SettingsTab): """ @@ -82,19 +82,18 @@ class ImageTab(SettingsTab): u'background-color: %s' % self.bg_color) def load(self): - settings = QtCore.QSettings() + settings = Settings() settings.beginGroup(self.settingsSection) - self.bg_color = unicode(settings.value( - u'background color', QtCore.QVariant(u'#000000')).toString()) + self.bg_color = unicode(settings.value(u'background color', u'#000000')) self.initial_color = self.bg_color settings.endGroup() self.backgroundColorButton.setStyleSheet( u'background-color: %s' % self.bg_color) def save(self): - settings = QtCore.QSettings() + settings = Settings() settings.beginGroup(self.settingsSection) - settings.setValue(u'background color', QtCore.QVariant(self.bg_color)) + settings.setValue(u'background color', self.bg_color) settings.endGroup() if self.initial_color != self.bg_color: Receiver.send_message(u'image_updated') diff --git a/openlp/plugins/images/lib/mediaitem.py b/openlp/plugins/images/lib/mediaitem.py index ffa67b95e..56f8203e7 100644 --- a/openlp/plugins/images/lib/mediaitem.py +++ b/openlp/plugins/images/lib/mediaitem.py @@ -33,7 +33,7 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import MediaManagerItem, build_icon, ItemCapabilities, \ SettingsManager, translate, check_item_selected, check_directory_exists, \ - Receiver, create_thumb, validate_thumb + Receiver, create_thumb, validate_thumb, Settings from openlp.core.lib.ui import UiStrings, critical_error_message_box from openlp.core.utils import AppLocation, delete_file, get_images_filter @@ -141,7 +141,7 @@ class ImageMediaItem(MediaManagerItem): item_name = QtGui.QListWidgetItem(filename) item_name.setIcon(icon) item_name.setToolTip(imageFile) - item_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(imageFile)) + item_name.setData(QtCore.Qt.UserRole, imageFile) self.listView.addItem(item_name) if not initialLoad: self.plugin.formParent.incrementProgressBar() @@ -151,8 +151,8 @@ class ImageMediaItem(MediaManagerItem): def generateSlideData(self, service_item, item=None, xmlVersion=False, remote=False): - background = QtGui.QColor(QtCore.QSettings().value(self.settingsSection - + u'/background color', QtCore.QVariant(u'#000000'))) + background = QtGui.QColor(Settings().value(self.settingsSection + + u'/background color', u'#000000')) if item: items = [item] else: @@ -220,9 +220,8 @@ class ImageMediaItem(MediaManagerItem): if check_item_selected(self.listView, translate('ImagePlugin.MediaItem', 'You must select an image to replace the background with.')): - background = QtGui.QColor(QtCore.QSettings().value( - self.settingsSection + u'/background color', - QtCore.QVariant(u'#000000'))) + background = QtGui.QColor(Settings().value( + self.settingsSection + u'/background color', u'#000000')) item = self.listView.selectedIndexes()[0] bitem = self.listView.item(item.row()) filename = unicode(bitem.data(QtCore.Qt.UserRole).toString()) diff --git a/openlp/plugins/media/lib/mediaitem.py b/openlp/plugins/media/lib/mediaitem.py index 592cd08c6..efe045a02 100644 --- a/openlp/plugins/media/lib/mediaitem.py +++ b/openlp/plugins/media/lib/mediaitem.py @@ -293,13 +293,13 @@ class MediaMediaItem(MediaManagerItem): filename = os.path.split(unicode(track))[1] item_name = QtGui.QListWidgetItem(filename) item_name.setIcon(build_icon(CLAPPERBOARD)) - item_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(track)) + item_name.setData(QtCore.Qt.UserRole, track) else: filename = os.path.split(unicode(track))[1] item_name = QtGui.QListWidgetItem(filename) #TODO: add the appropriate Icon #item_name.setIcon(build_icon(DVD_ICON)) - item_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(track)) + item_name.setData(QtCore.Qt.UserRole, track) item_name.setToolTip(track) self.listView.addItem(item_name) diff --git a/openlp/plugins/media/lib/mediatab.py b/openlp/plugins/media/lib/mediatab.py index c7ec1a61b..566c2a821 100644 --- a/openlp/plugins/media/lib/mediatab.py +++ b/openlp/plugins/media/lib/mediatab.py @@ -27,7 +27,7 @@ from PyQt4 import QtCore, QtGui -from openlp.core.lib import SettingsTab, translate, Receiver +from openlp.core.lib import Receiver, Settings, SettingsTab, translate from openlp.core.lib.ui import UiStrings, create_button from openlp.core.ui.media import get_media_players, set_media_players class MediaQCheckBox(QtGui.QCheckBox): @@ -186,9 +186,8 @@ class MediaTab(SettingsTab): else: checkbox.setChecked(False) self.updatePlayerList() - self.overridePlayerCheckBox.setChecked(QtCore.QSettings().value( - self.settingsSection + u'/override player', - QtCore.QVariant(QtCore.Qt.Unchecked)).toInt()[0]) + self.overridePlayerCheckBox.setChecked(Settings().value( + self.settingsSection + u'/override player', QtCore.Qt.Unchecked)) def save(self): override_changed = False @@ -200,10 +199,10 @@ class MediaTab(SettingsTab): player_string_changed = True override_changed = True setting_key = self.settingsSection + u'/override player' - if QtCore.QSettings().value(setting_key).toInt()[0] != \ + if Settings().value(setting_key).toInt()[0] != \ self.overridePlayerCheckBox.checkState(): - QtCore.QSettings().setValue(setting_key, - QtCore.QVariant(self.overridePlayerCheckBox.checkState())) + Settings().setValue(setting_key, + self.overridePlayerCheckBox.checkState()) override_changed = True if override_changed: Receiver.send_message(u'mediaitem_media_rebuild') diff --git a/openlp/plugins/media/mediaplugin.py b/openlp/plugins/media/mediaplugin.py index 13c636e83..954ab8d00 100644 --- a/openlp/plugins/media/mediaplugin.py +++ b/openlp/plugins/media/mediaplugin.py @@ -29,7 +29,8 @@ import logging from PyQt4 import QtCore -from openlp.core.lib import Plugin, StringContent, build_icon, translate +from openlp.core.lib import Plugin, StringContent, build_icon, translate, \ + Settings from openlp.plugins.media.lib import MediaMediaItem, MediaTab log = logging.getLogger(__name__) @@ -126,7 +127,7 @@ class MediaPlugin(Plugin): we want to check if we have the old "Use Phonon" setting, and convert it to "enable Phonon" and "make it the first one in the list". """ - settings = QtCore.QSettings() + settings = Settings() settings.beginGroup(self.settingsSection) if settings.contains(u'use phonon'): log.info(u'Found old Phonon setting') @@ -140,8 +141,7 @@ class MediaPlugin(Plugin): if player != u'phonon'] new_players.insert(0, u'phonon') self.mediaController.mediaPlayers[u'phonon'].isActive = True - settings.setValue(u'players', \ - QtCore.QVariant(u','.join(new_players))) + settings.setValue(u'players', u','.join(new_players)) self.settingsTab.load() settings.remove(u'use phonon') settings.endGroup() diff --git a/openlp/plugins/presentations/lib/mediaitem.py b/openlp/plugins/presentations/lib/mediaitem.py index 68eea809b..76897c355 100644 --- a/openlp/plugins/presentations/lib/mediaitem.py +++ b/openlp/plugins/presentations/lib/mediaitem.py @@ -33,7 +33,7 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import MediaManagerItem, build_icon, SettingsManager, \ translate, check_item_selected, Receiver, ItemCapabilities, create_thumb, \ - validate_thumb + validate_thumb, Settings from openlp.core.lib.ui import UiStrings, critical_error_message_box, \ create_horizontal_adjusting_combo_box from openlp.plugins.presentations.lib import MessageListener @@ -149,8 +149,8 @@ class PresentationMediaItem(MediaManagerItem): if self.displayTypeComboBox.count() > 1: self.displayTypeComboBox.insertItem(0, self.Automatic) self.displayTypeComboBox.setCurrentIndex(0) - if QtCore.QSettings().value(self.settingsSection + u'/override app', - QtCore.QVariant(QtCore.Qt.Unchecked)) == QtCore.Qt.Checked: + if Settings().value(self.settingsSection + u'/override app', + QtCore.Qt.Unchecked) == QtCore.Qt.Checked: self.presentationWidget.show() else: self.presentationWidget.hide() @@ -211,7 +211,7 @@ class PresentationMediaItem(MediaManagerItem): 'This type of presentation is not supported.')) continue item_name = QtGui.QListWidgetItem(filename) - item_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(file)) + item_name.setData(QtCore.Qt.UserRole, file) item_name.setIcon(icon) item_name.setToolTip(file) self.listView.addItem(item_name) diff --git a/openlp/plugins/presentations/lib/presentationcontroller.py b/openlp/plugins/presentations/lib/presentationcontroller.py index 7702f19cd..b8e70e3a8 100644 --- a/openlp/plugins/presentations/lib/presentationcontroller.py +++ b/openlp/plugins/presentations/lib/presentationcontroller.py @@ -32,7 +32,7 @@ import shutil from PyQt4 import QtCore from openlp.core.lib import Receiver, check_directory_exists, create_thumb, \ - validate_thumb + validate_thumb, Settings from openlp.core.utils import AppLocation log = logging.getLogger(__name__) @@ -392,10 +392,8 @@ class PresentationController(object): """ Return whether the controller is currently enabled """ - if QtCore.QSettings().value( - self.settings_section + u'/' + self.name, - QtCore.QVariant(QtCore.Qt.Checked)).toInt()[0] == \ - QtCore.Qt.Checked: + if Settings().value(self.settings_section + u'/' + self.name, + QtCore.Qt.Checked) == QtCore.Qt.Checked: return self.is_available() else: return False diff --git a/openlp/plugins/presentations/lib/presentationtab.py b/openlp/plugins/presentations/lib/presentationtab.py index 1b9fa04d9..5338eb132 100644 --- a/openlp/plugins/presentations/lib/presentationtab.py +++ b/openlp/plugins/presentations/lib/presentationtab.py @@ -27,7 +27,7 @@ from PyQt4 import QtCore, QtGui -from openlp.core.lib import Receiver, SettingsTab, translate +from openlp.core.lib import Receiver, Settings, SettingsTab, translate from openlp.core.lib.ui import UiStrings class PresentationTab(SettingsTab): @@ -102,12 +102,11 @@ class PresentationTab(SettingsTab): for key in self.controllers: controller = self.controllers[key] checkbox = self.PresenterCheckboxes[controller.name] - checkbox.setChecked(QtCore.QSettings().value( + checkbox.setChecked(Settings().value( self.settingsSection + u'/' + controller.name, - QtCore.QVariant(QtCore.Qt.Checked)).toInt()[0]) - self.OverrideAppCheckBox.setChecked(QtCore.QSettings().value( - self.settingsSection + u'/override app', - QtCore.QVariant(QtCore.Qt.Unchecked)).toInt()[0]) + QtCore.Qt.Checked)) + self.OverrideAppCheckBox.setChecked(Settings().value( + self.settingsSection + u'/override app', QtCore.Qt.Unchecked)) def save(self): """ @@ -123,20 +122,20 @@ class PresentationTab(SettingsTab): if controller.is_available(): checkbox = self.PresenterCheckboxes[controller.name] setting_key = self.settingsSection + u'/' + controller.name - if QtCore.QSettings().value(setting_key) != \ + if Settings().value(setting_key) != \ checkbox.checkState(): changed = True - QtCore.QSettings().setValue(setting_key, - QtCore.QVariant(checkbox.checkState())) + Settings().setValue(setting_key, + checkbox.checkState()) if checkbox.isChecked(): controller.start_process() else: controller.kill() setting_key = self.settingsSection + u'/override app' - if QtCore.QSettings().value(setting_key) != \ + if Settings().value(setting_key) != \ self.OverrideAppCheckBox.checkState(): - QtCore.QSettings().setValue(setting_key, - QtCore.QVariant(self.OverrideAppCheckBox.checkState())) + Settings().setValue(setting_key, + self.OverrideAppCheckBox.checkState()) changed = True if changed: Receiver.send_message(u'mediaitem_presentation_rebuild') diff --git a/openlp/plugins/remotes/lib/httpserver.py b/openlp/plugins/remotes/lib/httpserver.py index 43afebb41..ecd1b6b0d 100644 --- a/openlp/plugins/remotes/lib/httpserver.py +++ b/openlp/plugins/remotes/lib/httpserver.py @@ -121,7 +121,7 @@ import urlparse from PyQt4 import QtCore, QtNetwork from mako.template import Template -from openlp.core.lib import Receiver, PluginStatus, StringContent +from openlp.core.lib import Receiver, Settings, PluginStatus, StringContent from openlp.core.utils import AppLocation, translate log = logging.getLogger(__name__) @@ -169,12 +169,10 @@ class HttpServer(object): clients. Listen out for socket connections. """ log.debug(u'Start TCP server') - port = QtCore.QSettings().value( - self.plugin.settingsSection + u'/port', - QtCore.QVariant(4316)).toInt()[0] - address = QtCore.QSettings().value( - self.plugin.settingsSection + u'/ip address', - QtCore.QVariant(u'0.0.0.0')).toString() + port = Settings().value( + self.plugin.settingsSection + u'/port', 4316) + address = Settings().value( + self.plugin.settingsSection + u'/ip address', u'0.0.0.0') self.server = QtNetwork.QTcpServer() self.server.listen(QtNetwork.QHostAddress(address), port) QtCore.QObject.connect(Receiver.get_receiver(), @@ -404,14 +402,11 @@ class HttpConnection(object): u'slide': self.parent.current_slide or 0, u'item': self.parent.current_item._uuid \ if self.parent.current_item else u'', - u'twelve':QtCore.QSettings().value( - u'remotes/twelve hour', QtCore.QVariant(True)).toBool(), - u'blank': self.parent.plugin.liveController.blankScreen.\ - isChecked(), - u'theme': self.parent.plugin.liveController.themeScreen.\ - isChecked(), - u'display': self.parent.plugin.liveController.desktopScreen.\ - isChecked() + u'twelve': Settings().value(u'remotes/twelve hour', True), + u'blank': self.parent.plugin.liveController.blankScreen.isChecked(), + u'theme': self.parent.plugin.liveController.themeScreen.isChecked(), + u'display': \ + self.parent.plugin.liveController.desktopScreen.isChecked() } return HttpResponse(json.dumps({u'results': result}), {u'Content-Type': u'application/json'}) diff --git a/openlp/plugins/remotes/lib/remotetab.py b/openlp/plugins/remotes/lib/remotetab.py index bae2a7090..be08bb500 100644 --- a/openlp/plugins/remotes/lib/remotetab.py +++ b/openlp/plugins/remotes/lib/remotetab.py @@ -27,7 +27,7 @@ from PyQt4 import QtCore, QtGui, QtNetwork -from openlp.core.lib import SettingsTab, translate, Receiver +from openlp.core.lib import Settings, SettingsTab, translate, Receiver ZERO_URL = u'0.0.0.0' @@ -149,30 +149,29 @@ class RemoteTab(SettingsTab): def load(self): self.portSpinBox.setValue( - QtCore.QSettings().value(self.settingsSection + u'/port', - QtCore.QVariant(4316)).toInt()[0]) + Settings().value(self.settingsSection + u'/port', + 4316)) self.addressEdit.setText( - QtCore.QSettings().value(self.settingsSection + u'/ip address', - QtCore.QVariant(ZERO_URL)).toString()) - self.twelveHour = QtCore.QSettings().value( - self.settingsSection + u'/twelve hour', - QtCore.QVariant(True)).toBool() + Settings().value(self.settingsSection + u'/ip address', + ZERO_URL)) + self.twelveHour = Settings().value( + self.settingsSection + u'/twelve hour', True) self.twelveHourCheckBox.setChecked(self.twelveHour) self.setUrls() def save(self): changed = False - if QtCore.QSettings().value(self.settingsSection + u'/ip address', - QtCore.QVariant(ZERO_URL).toString() != self.addressEdit.text() or - QtCore.QSettings().value(self.settingsSection + u'/port', - QtCore.QVariant(4316).toInt()[0]) != self.portSpinBox.value()): + if Settings().value(self.settingsSection + u'/ip address', + ZERO_URL != self.addressEdit.text() or + Settings().value(self.settingsSection + u'/port', + 4316) != self.portSpinBox.value()): changed = True - QtCore.QSettings().setValue(self.settingsSection + u'/port', - QtCore.QVariant(self.portSpinBox.value())) - QtCore.QSettings().setValue(self.settingsSection + u'/ip address', - QtCore.QVariant(self.addressEdit.text())) - QtCore.QSettings().setValue(self.settingsSection + u'/twelve hour', - QtCore.QVariant(self.twelveHour)) + Settings().setValue(self.settingsSection + u'/port', + self.portSpinBox.value()) + Settings().setValue(self.settingsSection + u'/ip address', + self.addressEdit.text()) + Settings().setValue(self.settingsSection + u'/twelve hour', + self.twelveHour) if changed: Receiver.send_message(u'remotes_config_updated') diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index 195dda729..0bcf60b07 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -145,8 +145,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): for author in authors: row = self.authorsComboBox.count() self.authorsComboBox.addItem(author.display_name) - self.authorsComboBox.setItemData( - row, QtCore.QVariant(author.id)) + self.authorsComboBox.setItemData(row, author.id) self.authors.append(author.display_name) set_case_insensitive_completer(self.authors, self.authorsComboBox) @@ -166,7 +165,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): row = combo.count() combo.addItem(object.name) cache.append(object.name) - combo.setItemData(row, QtCore.QVariant(object.id)) + combo.setItemData(row, object.id) set_case_insensitive_completer(cache, combo) def loadThemes(self, theme_list): @@ -280,7 +279,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): verse[0][u'label'] = u'1' verse_def = u'%s%s' % (verse[0][u'type'], verse[0][u'label']) item = QtGui.QTableWidgetItem(verse[1]) - item.setData(QtCore.Qt.UserRole, QtCore.QVariant(verse_def)) + item.setData(QtCore.Qt.UserRole, verse_def) self.verseListWidget.setItem(count, 0, item) else: verses = self.song.lyrics.split(u'\n\n') @@ -290,7 +289,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): item = QtGui.QTableWidgetItem(verse) verse_def = u'%s%s' % \ (VerseType.Tags[VerseType.Verse], unicode(count + 1)) - item.setData(QtCore.Qt.UserRole, QtCore.QVariant(verse_def)) + item.setData(QtCore.Qt.UserRole, verse_def) self.verseListWidget.setItem(count, 0, item) if self.song.verse_order: # we translate verse order @@ -312,20 +311,19 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): self.authorsListView.clear() for author in self.song.authors: author_name = QtGui.QListWidgetItem(unicode(author.display_name)) - author_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(author.id)) + author_name.setData(QtCore.Qt.UserRole, author.id) self.authorsListView.addItem(author_name) # clear the results self.topicsListView.clear() for topic in self.song.topics: topic_name = QtGui.QListWidgetItem(unicode(topic.name)) - topic_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(topic.id)) + topic_name.setData(QtCore.Qt.UserRole, topic.id) self.topicsListView.addItem(topic_name) self.audioListWidget.clear() for media in self.song.media_files: media_file = QtGui.QListWidgetItem( os.path.split(media.file_name)[1]) - media_file.setData(QtCore.Qt.UserRole, - QtCore.QVariant(media.file_name)) + media_file.setData(QtCore.Qt.UserRole, media.file_name) self.audioListWidget.addItem(media_file) self.titleEdit.setFocus(QtCore.Qt.OtherFocusReason) # Hide or show the preview button. @@ -396,7 +394,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): Add an author to the author list. """ author_item = QtGui.QListWidgetItem(unicode(author.display_name)) - author_item.setData(QtCore.Qt.UserRole, QtCore.QVariant(author.id)) + author_item.setData(QtCore.Qt.UserRole, author.id) self.authorsListView.addItem(author_item) def onAuthorsListViewClicked(self): @@ -422,8 +420,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): topic = Topic.populate(name=text) self.manager.save_object(topic) topic_item = QtGui.QListWidgetItem(unicode(topic.name)) - topic_item.setData(QtCore.Qt.UserRole, - QtCore.QVariant(topic.id)) + topic_item.setData(QtCore.Qt.UserRole, topic.id) self.topicsListView.addItem(topic_item) self.loadTopics() self.topicsComboBox.setCurrentIndex(0) @@ -439,8 +436,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): 'This topic is already in the list.')) else: topic_item = QtGui.QListWidgetItem(unicode(topic.name)) - topic_item.setData(QtCore.Qt.UserRole, - QtCore.QVariant(topic.id)) + topic_item.setData(QtCore.Qt.UserRole, topic.id) self.topicsListView.addItem(topic_item) self.topicsComboBox.setCurrentIndex(0) else: @@ -469,7 +465,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): after_text, verse_tag, verse_num = self.verseForm.getVerse() verse_def = u'%s%s' % (verse_tag, verse_num) item = QtGui.QTableWidgetItem(after_text) - item.setData(QtCore.Qt.UserRole, QtCore.QVariant(verse_def)) + item.setData(QtCore.Qt.UserRole, verse_def) item.setText(after_text) self.verseListWidget.setRowCount( self.verseListWidget.rowCount() + 1) @@ -488,7 +484,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): if self.verseForm.exec_(): after_text, verse_tag, verse_num = self.verseForm.getVerse() verse_def = u'%s%s' % (verse_tag, verse_num) - item.setData(QtCore.Qt.UserRole, QtCore.QVariant(verse_def)) + item.setData(QtCore.Qt.UserRole, verse_def) item.setText(after_text) # number of lines has changed, repaint the list moving the data if len(tempText.split(u'\n')) != len(after_text.split(u'\n')): @@ -557,8 +553,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): if parts.endswith(u'\n'): parts = parts.rstrip(u'\n') item = QtGui.QTableWidgetItem(parts) - item.setData(QtCore.Qt.UserRole, - QtCore.QVariant(verse_def)) + item.setData(QtCore.Qt.UserRole, verse_def) self.verseListWidget.setRowCount( self.verseListWidget.rowCount() + 1) self.verseListWidget.setItem( @@ -733,8 +728,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): """ filters = u'%s (*)' % UiStrings().AllFiles filenames = QtGui.QFileDialog.getOpenFileNames(self, - translate('SongsPlugin.EditSongForm', 'Open File(s)'), - QtCore.QString(), filters) + translate('SongsPlugin.EditSongForm', 'Open File(s)'), u'', filters) for filename in filenames: item = QtGui.QListWidgetItem(os.path.split(unicode(filename))[1]) item.setData(QtCore.Qt.UserRole, filename) diff --git a/openlp/plugins/songs/forms/songexportform.py b/openlp/plugins/songs/forms/songexportform.py index 397b52cfc..498191f53 100644 --- a/openlp/plugins/songs/forms/songexportform.py +++ b/openlp/plugins/songs/forms/songexportform.py @@ -218,8 +218,9 @@ class SongExportForm(OpenLPWizard): # Add the songs to the list of selected songs. for item in items: song = QtGui.QListWidgetItem(item.text()) + # TODO: check toPyObject() song.setData(QtCore.Qt.UserRole, - QtCore.QVariant(item.data(QtCore.Qt.UserRole).toPyObject())) + item.data(QtCore.Qt.UserRole).toPyObject()) song.setFlags(QtCore.Qt.ItemIsEnabled) self.selectedListWidget.addItem(song) return True @@ -260,7 +261,7 @@ class SongExportForm(OpenLPWizard): for author in song.authors]) title = u'%s (%s)' % (unicode(song.title), authors) item = QtGui.QListWidgetItem(title) - item.setData(QtCore.Qt.UserRole, QtCore.QVariant(song)) + item.setData(QtCore.Qt.UserRole, song) item.setFlags(QtCore.Qt.ItemIsSelectable| QtCore.Qt.ItemIsUserCheckable | QtCore.Qt.ItemIsEnabled) item.setCheckState(QtCore.Qt.Unchecked) @@ -308,8 +309,9 @@ class SongExportForm(OpenLPWizard): ``text`` The text to search for. (unicode string) """ + #TODO: check if unicode() can be removed. return [item for item in listWidget.findItems( - QtCore.QString(unicode(text)), QtCore.Qt.MatchContains) + unicode(text), QtCore.Qt.MatchContains) ] def onItemActivated(self, item): @@ -333,6 +335,8 @@ class SongExportForm(OpenLPWizard): ``text`` The text of the *searchLineEdit*. (QString) """ + #TODO: check if unicode() can be removed. + print type(text) search_result = [ song for song in self._findListWidgetItems( self.availableListWidget, unicode(text)) diff --git a/openlp/plugins/songs/forms/songimportform.py b/openlp/plugins/songs/forms/songimportform.py index d5f7715ea..65d769792 100644 --- a/openlp/plugins/songs/forms/songimportform.py +++ b/openlp/plugins/songs/forms/songimportform.py @@ -33,7 +33,7 @@ import os from PyQt4 import QtCore, QtGui -from openlp.core.lib import Receiver, SettingsManager, translate +from openlp.core.lib import Receiver, Settings, SettingsManager, translate from openlp.core.lib.ui import UiStrings, critical_error_message_box from openlp.core.ui.wizard import OpenLPWizard, WizardStrings from openlp.plugins.songs.lib.importer import SongFormat @@ -387,7 +387,7 @@ class SongImportForm(OpenLPWizard): return True elif self.currentPage() == self.sourcePage: source_format = self.formatComboBox.currentIndex() - QtCore.QSettings().setValue(u'songs/last import type', + Settings().setValue(u'songs/last import type', source_format) if source_format == SongFormat.OpenLP2: if self.openLP2FilenameEdit.text().isEmpty(): @@ -740,7 +740,7 @@ class SongImportForm(OpenLPWizard): self.restart() self.finishButton.setVisible(False) self.cancelButton.setVisible(True) - last_import_type = QtCore.QSettings().value( + last_import_type = Settings().value( u'songs/last import type').toInt()[0] if last_import_type < 0 or \ last_import_type >= self.formatComboBox.count(): diff --git a/openlp/plugins/songs/forms/songmaintenanceform.py b/openlp/plugins/songs/forms/songmaintenanceform.py index 7ba49a102..51bb37e00 100644 --- a/openlp/plugins/songs/forms/songmaintenanceform.py +++ b/openlp/plugins/songs/forms/songmaintenanceform.py @@ -131,7 +131,7 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): else: author_name = QtGui.QListWidgetItem( u' '.join([author.first_name, author.last_name])) - author_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(author.id)) + author_name.setData(QtCore.Qt.UserRole, author.id) self.authorsListWidget.addItem(author_name) def resetTopics(self): @@ -142,7 +142,7 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): topics = self.manager.get_all_objects(Topic, order_by_ref=Topic.name) for topic in topics: topic_name = QtGui.QListWidgetItem(topic.name) - topic_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(topic.id)) + topic_name.setData(QtCore.Qt.UserRole, topic.id) self.topicsListWidget.addItem(topic_name) def resetBooks(self): @@ -154,7 +154,7 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): for book in books: book_name = QtGui.QListWidgetItem(u'%s (%s)' % (book.name, book.publisher)) - book_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(book.id)) + book_name.setData(QtCore.Qt.UserRole, book.id) self.booksListWidget.addItem(book_name) def checkAuthor(self, new_author, edit=False): diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index 51158a954..456062b69 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -34,8 +34,9 @@ import shutil from PyQt4 import QtCore, QtGui from sqlalchemy.sql import or_ -from openlp.core.lib import MediaManagerItem, Receiver, ItemCapabilities, \ - translate, check_item_selected, PluginStatus, create_separated_list +from openlp.core.lib import MediaManagerItem, Receiver, Settings, \ + ItemCapabilities, translate, check_item_selected, PluginStatus, \ + create_separated_list from openlp.core.lib.ui import UiStrings, create_widget_action from openlp.core.utils import AppLocation from openlp.plugins.songs.forms import EditSongForm, SongMaintenanceForm, \ @@ -131,15 +132,13 @@ class SongMediaItem(MediaManagerItem): self.searchTextEdit.setFocus() def configUpdated(self): - self.searchAsYouType = QtCore.QSettings().value( - self.settingsSection + u'/search as type', - QtCore.QVariant(u'False')).toBool() - self.updateServiceOnEdit = QtCore.QSettings().value( - self.settingsSection + u'/update service on edit', - QtCore.QVariant(u'False')).toBool() - self.addSongFromService = QtCore.QSettings().value( - self.settingsSection + u'/add song from service', - QtCore.QVariant(u'True')).toBool() + # TODO: Check .toBool() + self.searchAsYouType = bool(Settings().value( + self.settingsSection + u'/search as type', False)) + self.updateServiceOnEdit = bool(Settings().value( + self.settingsSection + u'/update service on edit', False)) + self.addSongFromService = bool(Settings().value( + self.settingsSection + u'/add song from service', True)) def retranslateUi(self): self.searchTextLabel.setText(u'%s:' % UiStrings().Search) @@ -168,16 +167,14 @@ class SongMediaItem(MediaManagerItem): (SongSearch.Themes, u':/slides/slide_theme.png', UiStrings().Themes, UiStrings().SearchThemes) ]) - self.searchTextEdit.setCurrentSearchType(QtCore.QSettings().value( - u'%s/last search type' % self.settingsSection, - QtCore.QVariant(SongSearch.Entire)).toInt()[0]) + self.searchTextEdit.setCurrentSearchType(Settings().value( + u'%s/last search type' % self.settingsSection, SongSearch.Entire)) self.configUpdated() def onSearchTextButtonClicked(self): # Save the current search type to the configuration. - QtCore.QSettings().setValue(u'%s/last search type' % - self.settingsSection, - QtCore.QVariant(self.searchTextEdit.currentSearchType())) + Settings().setValue(u'%s/last search type' % + self.settingsSection, self.searchTextEdit.currentSearchType()) # Reload the list considering the new search type. search_keywords = unicode(self.searchTextEdit.displayText()) search_results = [] @@ -271,7 +268,7 @@ class SongMediaItem(MediaManagerItem): song_detail = u'%s (%s)' % (song_title, create_separated_list(author_list)) song_name = QtGui.QListWidgetItem(song_detail) - song_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(song.id)) + song_name.setData(QtCore.Qt.UserRole, song.id) self.listView.addItem(song_name) # Auto-select the item if name has been set if song.id == self.autoSelectId: @@ -288,7 +285,7 @@ class SongMediaItem(MediaManagerItem): continue song_detail = u'%s (%s)' % (author.display_name, song.title) song_name = QtGui.QListWidgetItem(song_detail) - song_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(song.id)) + song_name.setData(QtCore.Qt.UserRole, song.id) self.listView.addItem(song_name) def displayResultsBook(self, searchresults, song_number=False): @@ -306,7 +303,7 @@ class SongMediaItem(MediaManagerItem): song_detail = u'%s - %s (%s)' % (book.name, song.song_number, song.title) song_name = QtGui.QListWidgetItem(song_detail) - song_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(song.id)) + song_name.setData(QtCore.Qt.UserRole, song.id) self.listView.addItem(song_name) def onClearTextButtonClick(self): @@ -516,12 +513,10 @@ class SongMediaItem(MediaManagerItem): service_item.raw_footer.append(song.title) service_item.raw_footer.append(create_separated_list(author_list)) service_item.raw_footer.append(song.copyright) - if QtCore.QSettings().value(u'general/ccli number', - QtCore.QVariant(u'')).toString(): + if Settings().value(u'general/ccli number', u''): service_item.raw_footer.append(unicode( translate('SongsPlugin.MediaItem', 'CCLI License: ') + - QtCore.QSettings().value(u'general/ccli number', - QtCore.QVariant(u'')).toString())) + Settings().value(u'general/ccli number', u''))) service_item.audit = [ song.title, author_list, song.copyright, unicode(song.ccli_number) ] diff --git a/openlp/plugins/songs/lib/songstab.py b/openlp/plugins/songs/lib/songstab.py index 9d6de087f..6d58c894e 100644 --- a/openlp/plugins/songs/lib/songstab.py +++ b/openlp/plugins/songs/lib/songstab.py @@ -27,7 +27,7 @@ from PyQt4 import QtCore, QtGui -from openlp.core.lib import SettingsTab, translate +from openlp.core.lib import Settings, SettingsTab, translate class SongsTab(SettingsTab): """ @@ -110,16 +110,12 @@ class SongsTab(SettingsTab): self.update_load = True def load(self): - settings = QtCore.QSettings() + settings = Settings() settings.beginGroup(self.settingsSection) - self.song_search = settings.value( - u'search as type', QtCore.QVariant(False)).toBool() - self.tool_bar = settings.value( - u'display songbar', QtCore.QVariant(True)).toBool() - self.update_edit = settings.value( - u'update service on edit', QtCore.QVariant(False)).toBool() - self.update_load = settings.value( - u'add song from service', QtCore.QVariant(True)).toBool() + self.song_search = settings.value(u'search as type', False) + self.tool_bar = settings.value(u'display songbar', True) + self.update_edit = settings.value(u'update service on edit', False) + self.update_load = settings.value(u'add song from service', True) self.searchAsTypeCheckBox.setChecked(self.song_search) self.toolBarActiveCheckBox.setChecked(self.tool_bar) self.updateOnEditCheckBox.setChecked(self.update_edit) @@ -127,12 +123,10 @@ class SongsTab(SettingsTab): settings.endGroup() def save(self): - settings = QtCore.QSettings() + settings = Settings() settings.beginGroup(self.settingsSection) - settings.setValue(u'search as type', QtCore.QVariant(self.song_search)) - settings.setValue(u'display songbar', QtCore.QVariant(self.tool_bar)) - settings.setValue(u'update service on edit', - QtCore.QVariant(self.update_edit)) - settings.setValue(u'add song from service', - QtCore.QVariant(self.update_load)) + settings.setValue(u'search as type', self.song_search) + settings.setValue(u'display songbar', self.tool_bar) + settings.setValue(u'update service on edit', self.update_edit) + settings.setValue(u'add song from service', self.update_load) settings.endGroup() diff --git a/openlp/plugins/songusage/forms/songusagedetailform.py b/openlp/plugins/songusage/forms/songusagedetailform.py index 363455ea5..f1cdb4cbc 100644 --- a/openlp/plugins/songusage/forms/songusagedetailform.py +++ b/openlp/plugins/songusage/forms/songusagedetailform.py @@ -31,7 +31,7 @@ import os from PyQt4 import QtCore, QtGui from sqlalchemy.sql import and_ -from openlp.core.lib import SettingsManager, translate, Receiver, \ +from openlp.core.lib import Receiver, Settings, SettingsManager, translate, \ check_directory_exists from openlp.plugins.songusage.lib.db import SongUsageItem from songusagedetaildialog import Ui_SongUsageDetailDialog @@ -59,12 +59,11 @@ class SongUsageDetailForm(QtGui.QDialog, Ui_SongUsageDetailDialog): year = QtCore.QDate().currentDate().year() if QtCore.QDate().currentDate().month() < 9: year -= 1 - toDate = QtCore.QSettings().value( - u'songusage/to date', - QtCore.QVariant(QtCore.QDate(year, 8, 31))).toDate() - fromDate = QtCore.QSettings().value( + toDate = Settings().value( + u'songusage/to date', QtCore.QDate(year, 8, 31)).toDate() + fromDate = Settings().value( u'songusage/from date', - QtCore.QVariant(QtCore.QDate(year - 1, 9, 1))).toDate() + QtCore.QDate(year - 1, 9, 1)).toDate() self.fromDate.setSelectedDate(fromDate) self.toDate.setSelectedDate(toDate) self.fileLineEdit.setText( @@ -103,10 +102,10 @@ class SongUsageDetailForm(QtGui.QDialog, Ui_SongUsageDetailDialog): 'usage_detail_%s_%s.txt')) % ( self.fromDate.selectedDate().toString(u'ddMMyyyy'), self.toDate.selectedDate().toString(u'ddMMyyyy')) - QtCore.QSettings().setValue(u'songusage/from date', - QtCore.QVariant(self.fromDate.selectedDate())) - QtCore.QSettings().setValue(u'songusage/to date', - QtCore.QVariant(self.toDate.selectedDate())) + Settings().setValue(u'songusage/from date', + self.fromDate.selectedDate()) + Settings().setValue(u'songusage/to date', + self.toDate.selectedDate()) usage = self.plugin.manager.get_all_objects( SongUsageItem, and_( SongUsageItem.usagedate >= self.fromDate.selectedDate().toPyDate(), diff --git a/openlp/plugins/songusage/songusageplugin.py b/openlp/plugins/songusage/songusageplugin.py index 7746f9b28..48450510f 100644 --- a/openlp/plugins/songusage/songusageplugin.py +++ b/openlp/plugins/songusage/songusageplugin.py @@ -30,8 +30,8 @@ from datetime import datetime from PyQt4 import QtCore, QtGui -from openlp.core.lib import Plugin, StringContent, Receiver, build_icon, \ - translate +from openlp.core.lib import build_icon, Plugin, Receiver, Settings, \ + StringContent, translate from openlp.core.lib.db import Manager from openlp.core.lib.ui import create_action from openlp.core.utils.actions import ActionList @@ -125,9 +125,8 @@ class SongUsagePlugin(Plugin): QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'print_service_started'), self.printSongUsage) - self.songUsageActive = QtCore.QSettings().value( - self.settingsSection + u'/active', - QtCore.QVariant(False)).toBool() + self.songUsageActive = Settings().value( + self.settingsSection + u'/active', False) # Set the button and checkbox state self.setButtonState() action_list = ActionList.get_instance() @@ -168,8 +167,8 @@ class SongUsagePlugin(Plugin): the UI when necessary, """ self.songUsageActive = not self.songUsageActive - QtCore.QSettings().setValue(self.settingsSection + u'/active', - QtCore.QVariant(self.songUsageActive)) + Settings().setValue(self.settingsSection + u'/active', + self.songUsageActive) self.setButtonState() def setButtonState(self): From 4a979b49d9b20a2b0c045faa70a0adfd0ffea5ed Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Thu, 17 May 2012 18:19:06 +0200 Subject: [PATCH 02/53] continued to implement QString v2 api --- openlp/core/lib/__init__.py | 27 ++++++++++++++----- openlp/core/lib/db.py | 12 ++++----- openlp/core/lib/formattingtags.py | 1 - openlp/core/lib/settingsmanager.py | 5 ++-- openlp/core/lib/ui.py | 1 - openlp/core/ui/firsttimeform.py | 3 +-- openlp/core/ui/mainwindow.py | 36 +++++++++++++++----------- openlp/core/ui/media/__init__.py | 2 +- openlp/core/ui/thememanager.py | 4 +-- openlp/core/utils/__init__.py | 3 +-- openlp/core/utils/languagemanager.py | 2 +- openlp/plugins/alerts/lib/alertstab.py | 8 +++--- openlp/plugins/bibles/lib/__init__.py | 8 +++--- openlp/plugins/bibles/lib/biblestab.py | 19 ++++++-------- openlp/plugins/bibles/lib/manager.py | 4 +-- openlp/plugins/bibles/lib/mediaitem.py | 3 +-- openlp/plugins/images/lib/imagetab.py | 2 +- openlp/plugins/songs/lib/mediaitem.py | 16 ++++++------ 18 files changed, 84 insertions(+), 72 deletions(-) diff --git a/openlp/core/lib/__init__.py b/openlp/core/lib/__init__.py index d16adda3c..ad696f954 100644 --- a/openlp/core/lib/__init__.py +++ b/openlp/core/lib/__init__.py @@ -64,20 +64,33 @@ class ServiceItemAction(object): class Settings(QtCore.QSettings): + type_list = [] def __init__(self, *args): QtCore.QSettings.__init__(self, *args) - import copy - self.value_ = copy.deepcopy(self.value) - self.value = copy.deepcopy(self.value2) - def value2(self, key, defaultValue): - setting = self.value_(key, defaultValue) + def value(self, key, defaultValue): + setting = super(Settings, self).value(key, defaultValue) + if isinstance(defaultValue, bool): + return setting.toBool() + if isinstance(defaultValue, QtCore.QByteArray): + return setting.toByteArray() if isinstance(defaultValue, int): return setting.toInt()[0] if isinstance(defaultValue, basestring): return setting.toString() - if isinstance(defaultValue, bool): - return setting.toBool() + if isinstance(defaultValue, list): + return setting.toStringList() + if isinstance(defaultValue, QtCore.QPoint): + return setting.toPoint() + print u'No!' + return setting + + def setValue(self, key, value): + super(Settings, self).setValue(key, value) + if type(value) not in Settings.type_list: + Settings.type_list.append(type(value)) + print Settings.type_list + def translate(context, text, comment=None, encoding=QtCore.QCoreApplication.CodecForTr, n=-1, diff --git a/openlp/core/lib/db.py b/openlp/core/lib/db.py index 0af1fe995..7da71afc9 100644 --- a/openlp/core/lib/db.py +++ b/openlp/core/lib/db.py @@ -184,7 +184,7 @@ class Manager(object): self.db_url = u'' self.is_dirty = False self.session = None - db_type = unicode(settings.value(u'db type', u'sqlite')) + db_type = settings.value(u'db type', u'sqlite') if db_type == u'sqlite': if db_file_name: self.db_url = u'sqlite:///%s/%s' % ( @@ -195,12 +195,12 @@ class Manager(object): AppLocation.get_section_data_path(plugin_name), plugin_name) else: self.db_url = u'%s://%s:%s@%s/%s' % (db_type, - urlquote(unicode(settings.value(u'db username'))), - urlquote(unicode(settings.value(u'db password'))), - urlquote(unicode(settings.value(u'db hostname'))), - urlquote(unicode(settings.value(u'db database')))) + urlquote(settings.value(u'db username', u'')), + urlquote(settings.value(u'db password', u'')), + urlquote(settings.value(u'db hostname', u'')), + urlquote(settings.value(u'db database', u''))) if db_type == u'mysql': - db_encoding = unicode(settings.value(u'db encoding', u'utf8')) + db_encoding = settings.value(u'db encoding', u'utf8') self.db_url += u'?charset=%s' % urlquote(db_encoding) settings.endGroup() if upgrade_mod: diff --git a/openlp/core/lib/formattingtags.py b/openlp/core/lib/formattingtags.py index 2404f3ad7..6661261ba 100644 --- a/openlp/core/lib/formattingtags.py +++ b/openlp/core/lib/formattingtags.py @@ -162,7 +162,6 @@ class FormattingTags(object): u'end html': u'', u'protected': True, u'temporary': False}) FormattingTags.add_html_tags(base_tags) FormattingTags.add_html_tags(temporary_tags) - # Formatting Tags were also known as display tags. user_expands = Settings().value(u'displayTags/html_tags', u'') # cPickle only accepts str not unicode strings diff --git a/openlp/core/lib/settingsmanager.py b/openlp/core/lib/settingsmanager.py index a77df513f..1c1aef4db 100644 --- a/openlp/core/lib/settingsmanager.py +++ b/openlp/core/lib/settingsmanager.py @@ -59,7 +59,7 @@ class SettingsManager(object): name = u'last directory %d' % num else: name = u'last directory' - return unicode(Settings().value(section + u'/' + name, u'')) + return Settings().value(section + u'/' + name, u'') @staticmethod def set_last_dir(section, directory, num=None): @@ -127,7 +127,8 @@ class SettingsManager(object): list = [] if list_count: for counter in range(list_count): - item = unicode(settings.value(u'%s %d' % (name, counter))) + # TODO: Check + item = settings.value(u'%s %d' % (name, counter)) if item: list.append(item) settings.endGroup() diff --git a/openlp/core/lib/ui.py b/openlp/core/lib/ui.py index 3f81af279..2ab67c180 100644 --- a/openlp/core/lib/ui.py +++ b/openlp/core/lib/ui.py @@ -365,7 +365,6 @@ def create_action(parent, name, **kwargs): ``separator`` True in case the action will be considered a separator. - #FIXME: check ``data`` Data which is set as QVariant type. diff --git a/openlp/core/ui/firsttimeform.py b/openlp/core/ui/firsttimeform.py index e14db5ae7..33b4ca610 100644 --- a/openlp/core/ui/firsttimeform.py +++ b/openlp/core/ui/firsttimeform.py @@ -206,8 +206,7 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): index = self.themeComboBox.findText(theme) if index == -1: self.themeComboBox.addItem(theme) - default_theme = unicode(Settings().value( - u'themes/global theme', u'')) + default_theme = Settings().value(u'themes/global theme', u'') # Pre-select the current default theme. index = self.themeComboBox.findText(default_theme) self.themeComboBox.setCurrentIndex(index) diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 64167d194..ecba87ab7 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -566,7 +566,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): self.settingsForm = SettingsForm(self, self) self.formattingTagForm = FormattingTagForm(self) self.shortcutForm = ShortcutListForm(self) - self.recentFiles = QtCore.QStringList() + self.recentFiles = [] # Set up the path with plugins plugin_path = AppLocation.get_directory(AppLocation.PluginsDir) self.pluginManager = PluginManager(plugin_path) @@ -742,7 +742,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): False): self.serviceManagerContents.loadLastFile() view_mode = Settings().value(u'%s/view mode' % \ - self.generalSettingsSection, u'default') + self.generalSettingsSection, u'default') if view_mode == u'default': self.modeDefaultItem.setChecked(True) elif view_mode == u'setup': @@ -1322,20 +1322,20 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): settings.remove(u'custom slide') settings.remove(u'service') settings.beginGroup(self.generalSettingsSection) - self.recentFiles = settings.value(u'recent files').toStringList() + self.recentFiles = settings.value(u'recent files', list()) settings.endGroup() settings.beginGroup(self.uiSettingsSection) - self.move(settings.value(u'main window position', - QtCore.QPoint(0, 0))).toPoint() + self.move(settings.value(u'main window position', QtCore.QPoint(0, 0))) self.restoreGeometry( - settings.value(u'main window geometry').toByteArray()) - self.restoreState(settings.value(u'main window state').toByteArray()) + settings.value(u'main window geometry', QtCore.QByteArray())) + self.restoreState( + settings.value(u'main window state', QtCore.QByteArray())) self.liveController.splitter.restoreState( - settings.value(u'live splitter geometry').toByteArray()) + settings.value(u'live splitter geometry', QtCore.QByteArray())) self.previewController.splitter.restoreState( - settings.value(u'preview splitter geometry').toByteArray()) - self.controlSplitter.restoreState( - settings.value(u'mainwindow splitter geometry').toByteArray()) + settings.value(u'preview splitter geometry', QtCore.QByteArray())) + self.controlSplitter.restoreState(settings.value( + u'mainwindow splitter geometry', QtCore.QByteArray())) settings.endGroup() def saveSettings(self): @@ -1373,7 +1373,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): existingRecentFiles = [recentFile for recentFile in self.recentFiles if os.path.isfile(unicode(recentFile))] recentFilesToDisplay = existingRecentFiles[0:recentFileCount] - self.recentFilesMenu.clear() + self.clearRecentFileMenu() for fileId, filename in enumerate(recentFilesToDisplay): log.debug('Recent file name: %s', filename) action = create_action(self, u'', @@ -1386,10 +1386,10 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): 'Clear List of recent files'), statustip=translate('OpenLP.MainWindow', 'Clear the list of recent files.'), - enabled=not self.recentFiles.isEmpty(), - triggers=self.recentFiles.clear) + enabled=bool(self.recentFiles), + triggers=self.clearRecentFileMenu) add_actions(self.recentFilesMenu, (None, clearRecentFilesAction)) - clearRecentFilesAction.setEnabled(not self.recentFiles.isEmpty()) + clearRecentFilesAction.setEnabled(bool(self.recentFiles)) def addRecentFile(self, filename): """ @@ -1418,6 +1418,12 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): # Don't care what API says takeLast works, removeLast doesn't! self.recentFiles.takeLast() + def clearRecentFileMenu(self): + """ + Clears the recent files. + """ + self.recentFiles = [] + def displayProgressBar(self, size): """ Make Progress bar visible and set size diff --git a/openlp/core/ui/media/__init__.py b/openlp/core/ui/media/__init__.py index 7fb5ccd04..1975c4bb0 100644 --- a/openlp/core/ui/media/__init__.py +++ b/openlp/core/ui/media/__init__.py @@ -80,7 +80,7 @@ def get_media_players(): Here an special media player is chosen for all media actions. """ log.debug(u'get_media_players') - players = Settings().value(u'media/players') + players = Settings().value(u'media/players', u'') if not players: players = u'webkit' reg_ex = QtCore.QRegExp(".*\[(.*)\].*") diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index f4235e2b4..bfbac5fc1 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -764,8 +764,8 @@ class ThemeManager(QtGui.QWidget): Check to see if theme has been selected and the destructive action is allowed. """ - self.global_theme = unicode(Settings().value( - self.settingsSection + u'/global theme', u'')) + self.global_theme = Settings().value( + self.settingsSection + u'/global theme', u'') if check_item_selected(self.themeListWidget, select_text): item = self.themeListWidget.currentItem() theme = unicode(item.text()) diff --git a/openlp/core/utils/__init__.py b/openlp/core/utils/__init__.py index 57d0a33c6..964f82d00 100644 --- a/openlp/core/utils/__init__.py +++ b/openlp/core/utils/__init__.py @@ -285,8 +285,7 @@ def check_latest_version(current_version): # set to prod in the distribution config file. settings = Settings() settings.beginGroup(u'general') - last_test = unicode(settings.value(u'last version test', - datetime.now().date())) + last_test = settings.value(u'last version test', datetime.now().date()) this_test = unicode(datetime.now().date()) settings.setValue(u'last version test', this_test) settings.endGroup() diff --git a/openlp/core/utils/languagemanager.py b/openlp/core/utils/languagemanager.py index 65582885a..21ccffbc1 100644 --- a/openlp/core/utils/languagemanager.py +++ b/openlp/core/utils/languagemanager.py @@ -105,7 +105,7 @@ class LanguageManager(object): Retrieve a saved language to use from settings """ settings = Settings() - language = unicode(settings.value(u'general/language', u'[en]')) + language = settings.value(u'general/language', u'[en]') log.info(u'Language file: \'%s\' Loaded from conf file' % language) reg_ex = QtCore.QRegExp("^\[(.*)\]") if reg_ex.exactMatch(language): diff --git a/openlp/plugins/alerts/lib/alertstab.py b/openlp/plugins/alerts/lib/alertstab.py index cf0c88409..f10826a22 100644 --- a/openlp/plugins/alerts/lib/alertstab.py +++ b/openlp/plugins/alerts/lib/alertstab.py @@ -155,11 +155,11 @@ class AlertsTab(SettingsTab): settings = Settings() settings.beginGroup(self.settingsSection) self.timeout = settings.value(u'timeout', 5) - self.font_color = unicode(settings.value(u'font color', u'#ffffff')) + self.font_color = settings.value(u'font color', u'#ffffff') self.font_size = settings.value(u'font size', 40) - self.bg_color = unicode(settings.value(u'background color', u'#660000')) - self.font_face = unicode(settings.value( - u'font face', QtGui.QFont().family())) + self.bg_color = settings.value(u'background color', u'#660000') + # TODO: isinstance needed? + self.font_face = settings.value(u'font face', QtGui.QFont().family()) self.location = settings.value(u'location', AlertLocation.Bottom) settings.endGroup() self.fontSizeSpinBox.setValue(self.font_size) diff --git a/openlp/plugins/bibles/lib/__init__.py b/openlp/plugins/bibles/lib/__init__.py index b5dc0087a..3543c10a5 100644 --- a/openlp/plugins/bibles/lib/__init__.py +++ b/openlp/plugins/bibles/lib/__init__.py @@ -188,10 +188,10 @@ def update_reference_separators(): settings = Settings() settings.beginGroup(u'bibles') custom_separators = [ - settings.value(u'verse separator'), - settings.value(u'range separator'), - settings.value(u'list separator'), - settings.value(u'end separator')] + settings.value(u'verse separator', u''), + settings.value(u'range separator', u''), + settings.value(u'list separator', u''), + settings.value(u'end separator', u'')] settings.endGroup() for index, role in enumerate([u'v', u'r', u'l', u'e']): if custom_separators[index].strip(u'|') == u'': diff --git a/openlp/plugins/bibles/lib/biblestab.py b/openlp/plugins/bibles/lib/biblestab.py index 148b75cd5..a054d1de0 100644 --- a/openlp/plugins/bibles/lib/biblestab.py +++ b/openlp/plugins/bibles/lib/biblestab.py @@ -420,13 +420,13 @@ class BiblesTab(SettingsTab): self.display_style = settings.value(u'display brackets', 0) self.layout_style = settings.value(u'verse layout style', 0) #TODO: Check - self.bible_theme = unicode(settings.value(u'bible theme', u'')) + self.bible_theme = settings.value(u'bible theme', u'') self.second_bibles = settings.value(u'second bibles', True) self.newChaptersCheckBox.setChecked(self.show_new_chapters) self.displayStyleComboBox.setCurrentIndex(self.display_style) self.layoutStyleComboBox.setCurrentIndex(self.layout_style) self.bibleSecondCheckBox.setChecked(self.second_bibles) - verse_separator = unicode(settings.value(u'verse separator').toString()) + verse_separator = settings.value(u'verse separator', u'') if (verse_separator.strip(u'|') == u'') or \ (verse_separator == get_reference_separator(u'sep_v_default')): self.verseSeparatorLineEdit.setText( @@ -439,7 +439,7 @@ class BiblesTab(SettingsTab): self.verseSeparatorLineEdit.setPalette( self.getGreyTextPalette(False)) self.verseSeparatorCheckBox.setChecked(True) - range_separator = unicode(settings.value(u'range separator').toString()) + range_separator = settings.value(u'range separator', u'') if (range_separator.strip(u'|') == u'') or \ (range_separator == get_reference_separator(u'sep_r_default')): self.rangeSeparatorLineEdit.setText( @@ -452,31 +452,28 @@ class BiblesTab(SettingsTab): self.rangeSeparatorLineEdit.setPalette( self.getGreyTextPalette(False)) self.rangeSeparatorCheckBox.setChecked(True) - list_separator = unicode(settings.value(u'list separator').toString()) + list_separator = settings.value(u'list separator', u'') if (list_separator.strip(u'|') == u'') or \ (list_separator == get_reference_separator(u'sep_l_default')): self.listSeparatorLineEdit.setText( get_reference_separator(u'sep_l_default')) - self.listSeparatorLineEdit.setPalette( - self.getGreyTextPalette(True)) + self.listSeparatorLineEdit.setPalette(self.getGreyTextPalette(True)) self.listSeparatorCheckBox.setChecked(False) else: self.listSeparatorLineEdit.setText(list_separator) self.listSeparatorLineEdit.setPalette( self.getGreyTextPalette(False)) self.listSeparatorCheckBox.setChecked(True) - end_separator = unicode(settings.value(u'end separator').toString()) + end_separator = settings.value(u'end separator', u'') if (end_separator.strip(u'|') == u'') or \ (end_separator == get_reference_separator(u'sep_e_default')): self.endSeparatorLineEdit.setText( get_reference_separator(u'sep_e_default')) - self.endSeparatorLineEdit.setPalette( - self.getGreyTextPalette(True)) + self.endSeparatorLineEdit.setPalette(self.getGreyTextPalette(True)) self.endSeparatorCheckBox.setChecked(False) else: self.endSeparatorLineEdit.setText(end_separator) - self.endSeparatorLineEdit.setPalette( - self.getGreyTextPalette(False)) + self.endSeparatorLineEdit.setPalette(self.getGreyTextPalette(False)) self.endSeparatorCheckBox.setChecked(True) self.language_selection = settings.value(u'book name language', 0) self.languageSelectionComboBox.setCurrentIndex(self.language_selection) diff --git a/openlp/plugins/bibles/lib/manager.py b/openlp/plugins/bibles/lib/manager.py index 03382c572..c2091895a 100644 --- a/openlp/plugins/bibles/lib/manager.py +++ b/openlp/plugins/bibles/lib/manager.py @@ -125,8 +125,8 @@ class BibleManager(object): self.web = u'Web' self.db_cache = None self.path = AppLocation.get_section_data_path(self.settingsSection) - self.proxy_name = unicode(Settings().value( - self.settingsSection + u'/proxy name', u'')) + self.proxy_name = Settings().value( + self.settingsSection + u'/proxy name', u'') self.suffix = u'.sqlite' self.import_wizard = None self.reload_bibles() diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index 09c59fdf9..2778ee42b 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -386,8 +386,7 @@ class BibleMediaItem(MediaManagerItem): self.advancedVersionComboBox.addItems(bibles) self.advancedSecondComboBox.addItems(bibles) # set the default value - bible = Settings().value( - self.settingsSection + u'/advanced bible', u'') + bible = Settings().value(self.settingsSection + u'/advanced bible', u'') if bible in bibles: find_and_set_in_combo_box(self.advancedVersionComboBox, bible) self.initialiseAdvancedBible(unicode(bible)) diff --git a/openlp/plugins/images/lib/imagetab.py b/openlp/plugins/images/lib/imagetab.py index 1fc6e834b..3e32687bd 100644 --- a/openlp/plugins/images/lib/imagetab.py +++ b/openlp/plugins/images/lib/imagetab.py @@ -84,7 +84,7 @@ class ImageTab(SettingsTab): def load(self): settings = Settings() settings.beginGroup(self.settingsSection) - self.bg_color = unicode(settings.value(u'background color', u'#000000')) + self.bg_color = settings.value(u'background color', u'#000000') self.initial_color = self.bg_color settings.endGroup() self.backgroundColorButton.setStyleSheet( diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index 456062b69..b01418cbb 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -133,12 +133,12 @@ class SongMediaItem(MediaManagerItem): def configUpdated(self): # TODO: Check .toBool() - self.searchAsYouType = bool(Settings().value( - self.settingsSection + u'/search as type', False)) - self.updateServiceOnEdit = bool(Settings().value( - self.settingsSection + u'/update service on edit', False)) - self.addSongFromService = bool(Settings().value( - self.settingsSection + u'/add song from service', True)) + self.searchAsYouType = Settings().value( + self.settingsSection + u'/search as type', False) + self.updateServiceOnEdit = Settings().value( + self.settingsSection + u'/update service on edit', False) + self.addSongFromService = Settings().value( + self.settingsSection + u'/add song from service', True) def retranslateUi(self): self.searchTextLabel.setText(u'%s:' % UiStrings().Search) @@ -515,8 +515,8 @@ class SongMediaItem(MediaManagerItem): service_item.raw_footer.append(song.copyright) if Settings().value(u'general/ccli number', u''): service_item.raw_footer.append(unicode( - translate('SongsPlugin.MediaItem', 'CCLI License: ') + - Settings().value(u'general/ccli number', u''))) + translate('SongsPlugin.MediaItem', 'CCLI License: ')) + + Settings().value(u'general/ccli number', u'')) service_item.audit = [ song.title, author_list, song.copyright, unicode(song.ccli_number) ] From 5378399302ecdccd6141c6532213b01719a4d767 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Thu, 17 May 2012 18:32:43 +0200 Subject: [PATCH 03/53] more clean ups --- openlp/core/lib/__init__.py | 2 +- openlp/core/ui/servicemanager.py | 12 ++++++------ openlp/plugins/media/lib/mediatab.py | 18 ++++++++---------- 3 files changed, 15 insertions(+), 17 deletions(-) diff --git a/openlp/core/lib/__init__.py b/openlp/core/lib/__init__.py index ad696f954..695825e56 100644 --- a/openlp/core/lib/__init__.py +++ b/openlp/core/lib/__init__.py @@ -82,7 +82,7 @@ class Settings(QtCore.QSettings): return setting.toStringList() if isinstance(defaultValue, QtCore.QPoint): return setting.toPoint() - print u'No!' + print u'No!', type(defaultValue) return setting def setValue(self, key, value): diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index ae76ccd44..48abc500a 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -274,9 +274,9 @@ class ServiceManager(QtGui.QWidget): QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'service_item_update'), self.serviceItemUpdate) # Last little bits of setting up - self.service_theme = unicode(Settings().value( + self.service_theme = Settings().value( self.mainwindow.serviceManagerSettingsSection + u'/service theme', - u'')) + u'') self.servicePath = AppLocation.get_section_data_path(u'servicemanager') # build the drag and drop context menu self.dndMenu = QtGui.QMenu() @@ -608,18 +608,18 @@ class ServiceManager(QtGui.QWidget): day_delta += 7 time = now + timedelta(days=day_delta) time = time.replace(hour=service_hour, minute=service_minute) - default_pattern = unicode(Settings().value( + default_pattern = Settings().value( u'advanced/default service name', translate('OpenLP.AdvancedTab', 'Service %Y-%m-%d %H-%M', 'This may not contain any of the following characters: ' '/\\?*|<>\[\]":+\nSee http://docs.python.org/library/' 'datetime.html#strftime-strptime-behavior for more ' - 'information.'))) + 'information.')) default_filename = time.strftime(default_pattern) else: default_filename = u'' - directory = unicode(SettingsManager.get_last_dir( - self.mainwindow.serviceManagerSettingsSection)) + directory = SettingsManager.get_last_dir( + self.mainwindow.serviceManagerSettingsSection) path = os.path.join(directory, default_filename) fileName = unicode(QtGui.QFileDialog.getSaveFileName(self.mainwindow, UiStrings().SaveService, path, diff --git a/openlp/plugins/media/lib/mediatab.py b/openlp/plugins/media/lib/mediatab.py index 566c2a821..df17bfca6 100644 --- a/openlp/plugins/media/lib/mediatab.py +++ b/openlp/plugins/media/lib/mediatab.py @@ -67,8 +67,7 @@ class MediaTab(SettingsTab): self.playerOrderGroupBox.setObjectName(u'playerOrderGroupBox') self.playerOrderLayout = QtGui.QHBoxLayout(self.playerOrderGroupBox) self.playerOrderLayout.setObjectName(u'playerOrderLayout') - self.playerOrderlistWidget = QtGui.QListWidget( \ - self.playerOrderGroupBox) + self.playerOrderlistWidget = QtGui.QListWidget(self.playerOrderGroupBox) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) sizePolicy.setHorizontalStretch(0) @@ -76,11 +75,11 @@ class MediaTab(SettingsTab): sizePolicy.setHeightForWidth(self.playerOrderlistWidget. \ sizePolicy().hasHeightForWidth()) self.playerOrderlistWidget.setSizePolicy(sizePolicy) - self.playerOrderlistWidget.setVerticalScrollBarPolicy( \ + self.playerOrderlistWidget.setVerticalScrollBarPolicy( QtCore.Qt.ScrollBarAsNeeded) - self.playerOrderlistWidget.setHorizontalScrollBarPolicy( \ + self.playerOrderlistWidget.setHorizontalScrollBarPolicy( QtCore.Qt.ScrollBarAlwaysOff) - self.playerOrderlistWidget.setEditTriggers( \ + self.playerOrderlistWidget.setEditTriggers( QtGui.QAbstractItemView.NoEditTriggers) self.playerOrderlistWidget.setObjectName(u'playerOrderlistWidget') self.playerOrderLayout.addWidget(self.playerOrderlistWidget) @@ -199,13 +198,12 @@ class MediaTab(SettingsTab): player_string_changed = True override_changed = True setting_key = self.settingsSection + u'/override player' - if Settings().value(setting_key).toInt()[0] != \ + if Settings().value(setting_key, QtCore.Qt.Unchecked) != \ self.overridePlayerCheckBox.checkState(): Settings().setValue(setting_key, self.overridePlayerCheckBox.checkState()) override_changed = True - if override_changed: - Receiver.send_message(u'mediaitem_media_rebuild') - if player_string_changed: - Receiver.send_message(u'mediaitem_media_rebuild') + if player_string_changed or override_changed: + if override_changed: + Receiver.send_message(u'mediaitem_media_rebuild') Receiver.send_message(u'config_screen_changed') From 56c36f355d7c737bc0774fca062335e59e7356c6 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Thu, 17 May 2012 18:35:58 +0200 Subject: [PATCH 04/53] More clean ups and fixes --- openlp/core/lib/__init__.py | 1 + openlp/core/lib/searchedit.py | 2 +- openlp/core/lib/settingsmanager.py | 4 +--- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/openlp/core/lib/__init__.py b/openlp/core/lib/__init__.py index 695825e56..e359b0047 100644 --- a/openlp/core/lib/__init__.py +++ b/openlp/core/lib/__init__.py @@ -82,6 +82,7 @@ class Settings(QtCore.QSettings): return setting.toStringList() if isinstance(defaultValue, QtCore.QPoint): return setting.toPoint() + # TODO: add print u'No!', type(defaultValue) return setting diff --git a/openlp/core/lib/searchedit.py b/openlp/core/lib/searchedit.py index a885e1ecd..22d628dbb 100644 --- a/openlp/core/lib/searchedit.py +++ b/openlp/core/lib/searchedit.py @@ -185,7 +185,7 @@ class SearchEdit(QtGui.QLineEdit): A :class:`~PyQt4.QtCore.QString` instance which represents the text in the line edit. """ - self.clearButton.setVisible(not text.isEmpty()) + self.clearButton.setVisible(bool(text)) def _onClearButtonClicked(self): """ diff --git a/openlp/core/lib/settingsmanager.py b/openlp/core/lib/settingsmanager.py index 1c1aef4db..475458f2c 100644 --- a/openlp/core/lib/settingsmanager.py +++ b/openlp/core/lib/settingsmanager.py @@ -98,7 +98,6 @@ class SettingsManager(object): """ settings = Settings() settings.beginGroup(section) - #TODO: check if [0] is needed. old_count = settings.value(u'%s count' % name, 0) new_count = len(list) settings.setValue(u'%s count' % name, new_count) @@ -127,8 +126,7 @@ class SettingsManager(object): list = [] if list_count: for counter in range(list_count): - # TODO: Check - item = settings.value(u'%s %d' % (name, counter)) + item = settings.value(u'%s %d' % (name, counter), u'') if item: list.append(item) settings.endGroup() From a379d9ec545b9865ca9b2166ce62bbe836f00413 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Thu, 17 May 2012 18:53:54 +0200 Subject: [PATCH 05/53] more clean ups --- openlp/core/__init__.py | 5 ++--- openlp/core/lib/plugin.py | 1 - openlp/core/ui/advancedtab.py | 24 +++++++-------------- openlp/core/ui/firsttimeform.py | 3 +-- openlp/core/ui/generaltab.py | 12 ++++------- openlp/core/ui/maindisplay.py | 18 ++++++---------- openlp/core/ui/mainwindow.py | 38 +++++++++++---------------------- 7 files changed, 34 insertions(+), 67 deletions(-) diff --git a/openlp/core/__init__.py b/openlp/core/__init__.py index 5d0bb1e0e..9f29e55b4 100644 --- a/openlp/core/__init__.py +++ b/openlp/core/__init__.py @@ -78,6 +78,7 @@ QToolBar } """ + class OpenLP(QtGui.QApplication): """ The core application class. This class inherits from Qt's QApplication @@ -97,7 +98,6 @@ class OpenLP(QtGui.QApplication): """ Run the OpenLP application. """ - # On Windows, the args passed into the constructor are # ignored. Not very handy, so set the ones we want to use. self.args.extend(args) @@ -111,8 +111,7 @@ class OpenLP(QtGui.QApplication): # Decide how many screens we have and their size screens = ScreenList(self.desktop()) # First time checks in settings - has_run_wizard = Settings().value( - u'general/has run wizard', False) + has_run_wizard = Settings().value(u'general/has run wizard', False) if not has_run_wizard: if FirstTimeForm(screens).exec_() == QtGui.QDialog.Accepted: Settings().setValue(u'general/has run wizard', True) diff --git a/openlp/core/lib/plugin.py b/openlp/core/lib/plugin.py index e060b4f85..fdbefb92a 100644 --- a/openlp/core/lib/plugin.py +++ b/openlp/core/lib/plugin.py @@ -190,7 +190,6 @@ class Plugin(QtCore.QObject): """ Sets the status of the plugin """ - #TODO: check if [0] is needed. self.status = Settings().value( self.settingsSection + u'/status', PluginStatus.Inactive) diff --git a/openlp/core/ui/advancedtab.py b/openlp/core/ui/advancedtab.py index d44758c22..55547cbbd 100644 --- a/openlp/core/ui/advancedtab.py +++ b/openlp/core/ui/advancedtab.py @@ -348,28 +348,20 @@ class AdvancedTab(SettingsTab): # 20 will always be used. self.recentSpinBox.setMaximum(Settings().value( u'max recent files', 20)) - self.recentSpinBox.setValue(settings.value(u'recent file count', - 4)) + self.recentSpinBox.setValue(settings.value(u'recent file count', 4)) self.mediaPluginCheckBox.setChecked( - settings.value(u'save current plugin', - False)) + settings.value(u'save current plugin', False)) self.doubleClickLiveCheckBox.setChecked( - settings.value(u'double click live', - False)) + settings.value(u'double click live', False)) self.singleClickPreviewCheckBox.setChecked( - settings.value(u'single click preview', - False)) + settings.value(u'single click preview', False)) self.expandServiceItemCheckBox.setChecked( - settings.value(u'expand service item', - False)) + settings.value(u'expand service item', False)) self.enableAutoCloseCheckBox.setChecked( - settings.value(u'enable exit confirmation', - True)) - self.hideMouseCheckBox.setChecked( - settings.value(u'hide mouse', False)) + settings.value(u'enable exit confirmation', True)) + self.hideMouseCheckBox.setChecked(settings.value(u'hide mouse', False)) self.serviceNameDay.setCurrentIndex( - settings.value(u'default service day', - self.defaultServiceDay)) + settings.value(u'default service day', self.defaultServiceDay)) self.serviceNameTime.setTime(QtCore.QTime( settings.value(u'default service hour', self.defaultServiceHour), settings.value(u'default service minute', diff --git a/openlp/core/ui/firsttimeform.py b/openlp/core/ui/firsttimeform.py index 33b4ca610..b0630e5fb 100644 --- a/openlp/core/ui/firsttimeform.py +++ b/openlp/core/ui/firsttimeform.py @@ -113,8 +113,7 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): check_directory_exists(os.path.join(gettempdir(), 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', False) + self.hasRunWizard = Settings().value(u'general/has run wizard', False) # Sort out internet access for downloads if self.webAccess: songs = self.config.get(u'songs', u'languages') diff --git a/openlp/core/ui/generaltab.py b/openlp/core/ui/generaltab.py index 6c6fec519..af2510757 100644 --- a/openlp/core/ui/generaltab.py +++ b/openlp/core/ui/generaltab.py @@ -280,18 +280,14 @@ class GeneralTab(SettingsTab): self.autoUnblankCheckBox.setChecked(settings.value(u'auto unblank', False)) self.displayOnMonitorCheck.setChecked(self.screens.display) - self.warningCheckBox.setChecked(settings.value(u'blank warning', - False)) - self.autoOpenCheckBox.setChecked(settings.value(u'auto open', - False)) - self.showSplashCheckBox.setChecked(settings.value(u'show splash', - True)) + self.warningCheckBox.setChecked(settings.value(u'blank warning', False)) + self.autoOpenCheckBox.setChecked(settings.value(u'auto open', False)) + self.showSplashCheckBox.setChecked(settings.value(u'show splash', True)) self.checkForUpdatesCheckBox.setChecked(settings.value(u'update check', True)) self.autoPreviewCheckBox.setChecked(settings.value(u'auto preview', False)) - self.timeoutSpinBox.setValue(settings.value(u'loop delay', - 5)) + self.timeoutSpinBox.setValue(settings.value(u'loop delay', 5)) self.monitorRadioButton.setChecked( not settings.value(u'override position', False)) diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index dd20230fe..f430ec1c9 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -198,8 +198,7 @@ class MainDisplay(Display): u':/graphics/openlp-splash-screen.png') background_color = QtGui.QColor() background_color.setNamedColor(Settings().value( - u'advanced/default color', - u'#ffffff')) + u'advanced/default color', u'#ffffff')) if not background_color.isValid(): background_color = QtCore.Qt.white splash_image = QtGui.QImage(image_file) @@ -350,8 +349,7 @@ class MainDisplay(Display): # Single screen active if self.screens.display_count == 1: # Only make visible if setting enabled. - if Settings().value( - u'general/display on monitor', True): + if Settings().value(u'general/display on monitor', True): self.setVisible(True) else: self.setVisible(True) @@ -399,8 +397,7 @@ class MainDisplay(Display): self.footer(serviceItem.foot_text) # if was hidden keep it hidden if self.hideMode and self.isLive and not serviceItem.is_media(): - if Settings().value(u'general/auto unblank', - False): + if Settings().value(u'general/auto unblank', False): Receiver.send_message(u'slidecontroller_live_unblank') else: self.hideDisplay(self.hideMode) @@ -423,8 +420,7 @@ class MainDisplay(Display): log.debug(u'hideDisplay mode = %d', mode) if self.screens.display_count == 1: # Only make visible if setting enabled. - if not Settings().value(u'general/display on monitor', - True): + if not Settings().value(u'general/display on monitor', True): return if mode == HideMode.Screen: self.frame.evaluateJavaScript(u'show_blank("desktop");') @@ -448,8 +444,7 @@ class MainDisplay(Display): log.debug(u'showDisplay') if self.screens.display_count == 1: # Only make visible if setting enabled. - if not Settings().value(u'general/display on monitor', - True): + if not Settings().value(u'general/display on monitor', True): return self.frame.evaluateJavaScript('show_blank("show");') if self.isHidden(): @@ -463,8 +458,7 @@ class MainDisplay(Display): """ Hide mouse cursor when moved over display. """ - if Settings().value(u'advanced/hide mouse', - False): + if Settings().value(u'advanced/hide mouse', False): self.setCursor(QtCore.Qt.BlankCursor) self.frame.evaluateJavaScript('document.body.style.cursor = "none"') else: diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index ecba87ab7..3daa11dab 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -99,13 +99,10 @@ class Ui_MainWindow(object): # Create slide controllers self.previewController = SlideController(self) self.liveController = SlideController(self, True) - previewVisible = Settings().value( - u'user interface/preview panel', True) + previewVisible = Settings().value(u'user interface/preview panel', True) self.previewController.panel.setVisible(previewVisible) - liveVisible = Settings().value(u'user interface/live panel', - True) - panelLocked = Settings().value(u'user interface/lock panel', - False) + liveVisible = Settings().value(u'user interface/live panel', True) + panelLocked = Settings().value(u'user interface/lock panel', False) self.liveController.panel.setVisible(liveVisible) # Create menu self.menuBar = QtGui.QMenuBar(mainWindow) @@ -685,8 +682,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): self.liveController.screenSizeChanged() log.info(u'Load data from Settings') if Settings().value(u'advanced/save current plugin', False): - savedPlugin = Settings().value( - u'advanced/current media plugin', ) + savedPlugin = Settings().value(u'advanced/current media plugin', -1) if savedPlugin != -1: self.mediaToolBox.setCurrentIndex(savedPlugin) self.settingsForm.postSetUp() @@ -738,10 +734,9 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): filename = unicode(filename, sys.getfilesystemencoding()) self.serviceManagerContents.loadFile(filename) elif Settings().value( - self.generalSettingsSection + u'/auto open', - False): + self.generalSettingsSection + u'/auto open', False): self.serviceManagerContents.loadLastFile() - view_mode = Settings().value(u'%s/view mode' % \ + view_mode = Settings().value(u'%s/view mode' % self.generalSettingsSection, u'default') if view_mode == u'default': self.modeDefaultItem.setChecked(True) @@ -954,8 +949,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): for plugin in self.pluginManager.plugins: setting_sections.extend([plugin.name]) settings = Settings() - import_settings = Settings(import_file_name, - QtCore.QSettings.IniFormat) + import_settings = Settings(import_file_name, QtCore.QSettings.IniFormat) import_keys = import_settings.allKeys() for section_key in import_keys: # We need to handle the really bad files. @@ -988,8 +982,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): now = datetime.now() settings.beginGroup(self.headerSection) settings.setValue(u'file_imported', import_file_name) - settings.setValue(u'file_date_imported', - now.strftime("%Y-%m-%d %H:%M")) + settings.setValue(u'file_date_imported', now.strftime("%Y-%m-%d %H:%M")) settings.endGroup() settings.sync() # We must do an immediate restart or current configuration will @@ -1043,8 +1036,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): settings.remove(self.headerSection) # Get the settings. keys = settings.allKeys() - export_settings = Settings(temp_file, - QtCore.QSettings.IniFormat) + export_settings = Settings(temp_file, QtCore.QSettings.IniFormat) # Add a header section. # This is to insure it's our conf file for import. now = datetime.now() @@ -1147,8 +1139,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): else: event.ignore() else: - if Settings().value(u'advanced/enable exit confirmation', - True): + if Settings().value(u'advanced/enable exit confirmation', True): ret = QtGui.QMessageBox.question(self, translate('OpenLP.MainWindow', 'Close OpenLP'), translate('OpenLP.MainWindow', @@ -1172,8 +1163,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): """ # Clean temporary files used by services self.serviceManagerContents.cleanUp() - if Settings().value(u'advanced/save current plugin', - False): + if Settings().value(u'advanced/save current plugin', False): Settings().setValue(u'advanced/current media plugin', self.mediaToolBox.currentIndex()) # Call the cleanup method to shutdown plugins. @@ -1368,8 +1358,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): Updates the recent file menu with the latest list of service files accessed. """ - recentFileCount = Settings().value( - u'advanced/recent file count', 4) + recentFileCount = Settings().value(u'advanced/recent file count', 4) existingRecentFiles = [recentFile for recentFile in self.recentFiles if os.path.isfile(unicode(recentFile))] recentFilesToDisplay = existingRecentFiles[0:recentFileCount] @@ -1401,8 +1390,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): # The maxRecentFiles value does not have an interface and so never gets # actually stored in the settings therefore the default value of 20 will # always be used. - maxRecentFiles = Settings().value( - u'advanced/max recent files', 20) + maxRecentFiles = Settings().value(u'advanced/max recent files', 20) if filename: # Add some cleanup to reduce duplication in the recent file list filename = os.path.abspath(filename) From ed3b7660faf3a0f4c21078761ba077cd0b8dfe8b Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Thu, 17 May 2012 20:57:01 +0200 Subject: [PATCH 06/53] removed not neede unicode calls --- openlp/core/__init__.py | 2 +- openlp/core/lib/__init__.py | 18 ++--- openlp/core/lib/db.py | 8 +- openlp/core/lib/listwidgetwithdnd.py | 2 +- openlp/core/lib/mediamanageritem.py | 23 +++--- openlp/core/lib/serviceitem.py | 8 +- openlp/core/lib/spelltextedit.py | 2 +- openlp/core/lib/toolbar.py | 2 +- openlp/core/lib/ui.py | 4 +- openlp/core/ui/aboutdialog.py | 8 +- openlp/core/ui/aboutform.py | 2 +- openlp/core/ui/advancedtab.py | 10 +-- openlp/core/ui/exceptionform.py | 20 ++--- openlp/core/ui/firsttimeform.py | 8 +- openlp/core/ui/formattingtagform.py | 12 +-- openlp/core/ui/maindisplay.py | 2 +- openlp/core/ui/mainwindow.py | 40 +++++----- openlp/core/ui/media/mediacontroller.py | 6 +- openlp/core/ui/pluginform.py | 23 ++---- openlp/core/ui/printserviceform.py | 7 +- openlp/core/ui/servicemanager.py | 38 ++++----- openlp/core/ui/shortcutlistform.py | 6 +- openlp/core/ui/slidecontroller.py | 4 +- openlp/core/ui/themeform.py | 21 +++-- openlp/core/ui/thememanager.py | 79 +++++++++---------- openlp/core/ui/themestab.py | 2 +- openlp/core/ui/wizard.py | 14 ++-- openlp/plugins/alerts/alertsplugin.py | 2 +- openlp/plugins/alerts/forms/alertform.py | 26 +++--- openlp/plugins/bibles/bibleplugin.py | 9 +-- .../plugins/bibles/forms/bibleimportform.py | 31 ++++---- .../plugins/bibles/forms/bibleupgradeform.py | 47 ++++++----- openlp/plugins/bibles/forms/booknameform.py | 2 +- openlp/plugins/bibles/forms/editbibleform.py | 22 +++--- openlp/plugins/bibles/lib/__init__.py | 4 +- openlp/plugins/bibles/lib/csvbible.py | 8 +- openlp/plugins/bibles/lib/http.py | 12 +-- openlp/plugins/bibles/lib/manager.py | 4 +- openlp/plugins/bibles/lib/mediaitem.py | 73 +++++++++-------- openlp/plugins/bibles/lib/opensong.py | 4 +- openlp/plugins/bibles/lib/osis.py | 6 +- openlp/plugins/custom/forms/editcustomform.py | 8 +- openlp/plugins/custom/lib/mediaitem.py | 2 +- openlp/plugins/images/lib/mediaitem.py | 21 +++-- openlp/plugins/media/lib/mediaitem.py | 23 +++--- openlp/plugins/media/lib/mediatab.py | 5 +- openlp/plugins/presentations/lib/mediaitem.py | 19 +++-- .../presentations/lib/presentationtab.py | 4 +- openlp/plugins/songs/forms/editsongform.py | 53 ++++++------- openlp/plugins/songs/forms/editverseform.py | 4 +- openlp/plugins/songs/forms/mediafilesform.py | 2 +- openlp/plugins/songs/forms/songexportform.py | 18 ++--- openlp/plugins/songs/forms/songimportform.py | 10 +-- .../songs/forms/songmaintenanceform.py | 36 ++++----- openlp/plugins/songs/lib/__init__.py | 14 ++-- openlp/plugins/songs/lib/ewimport.py | 4 +- openlp/plugins/songs/lib/openlyricsexport.py | 5 +- openlp/plugins/songs/lib/powersongimport.py | 4 +- openlp/plugins/songs/lib/songimport.py | 3 +- openlp/plugins/songs/lib/xml.py | 8 +- openlp/plugins/songs/songsplugin.py | 16 ++-- .../songusage/forms/songusagedetailform.py | 34 ++++---- openlp/plugins/songusage/songusageplugin.py | 24 +++--- 63 files changed, 445 insertions(+), 493 deletions(-) diff --git a/openlp/core/__init__.py b/openlp/core/__init__.py index 9f29e55b4..1c8d9e2b6 100644 --- a/openlp/core/__init__.py +++ b/openlp/core/__init__.py @@ -194,7 +194,7 @@ class OpenLP(QtGui.QApplication): if event.type() == QtCore.QEvent.FileOpen: file_name = event.file() log.debug(u'Got open file event for %s!', file_name) - self.args.insert(0, unicode(file_name)) + self.args.insert(0, file_name) return True else: return QtGui.QApplication.event(self, event) diff --git a/openlp/core/lib/__init__.py b/openlp/core/lib/__init__.py index e359b0047..4f49e4d58 100644 --- a/openlp/core/lib/__init__.py +++ b/openlp/core/lib/__init__.py @@ -371,22 +371,22 @@ def create_separated_list(stringlist): List of unicode strings """ if Qt.PYQT_VERSION_STR >= u'4.9' and Qt.qVersion() >= u'4.8': - return unicode(QtCore.QLocale().createSeparatedList(stringlist)) + return QtCore.QLocale().createSeparatedList(stringlist) if not stringlist: return u'' elif len(stringlist) == 1: return stringlist[0] elif len(stringlist) == 2: - return unicode(translate('OpenLP.core.lib', '%1 and %2', - 'Locale list separator: 2 items').arg(stringlist[0], stringlist[1])) + return translate('OpenLP.core.lib', '%1 and %2', + 'Locale list separator: 2 items').arg(stringlist[0], stringlist[1]) else: - merged = unicode(translate('OpenLP.core.lib', '%1, and %2', - u'Locale list separator: end').arg(stringlist[-2], stringlist[-1])) + merged = translate('OpenLP.core.lib', '%1, and %2', + u'Locale list separator: end').arg(stringlist[-2], stringlist[-1]) for index in reversed(range(1, len(stringlist) - 2)): - merged = unicode(translate('OpenLP.core.lib', '%1, %2', - u'Locale list separator: middle').arg(stringlist[index], merged)) - return unicode(translate('OpenLP.core.lib', '%1, %2', - u'Locale list separator: start').arg(stringlist[0], merged)) + merged = translate('OpenLP.core.lib', '%1, %2', + u'Locale list separator: middle').arg(stringlist[index], merged) + return translate('OpenLP.core.lib', '%1, %2', + u'Locale list separator: start').arg(stringlist[0], merged) from eventreceiver import Receiver diff --git a/openlp/core/lib/db.py b/openlp/core/lib/db.py index 7da71afc9..e45a4ca1c 100644 --- a/openlp/core/lib/db.py +++ b/openlp/core/lib/db.py @@ -208,11 +208,11 @@ class Manager(object): if db_ver > up_ver: critical_error_message_box( translate('OpenLP.Manager', 'Database Error'), - unicode(translate('OpenLP.Manager', 'The database being ' + translate('OpenLP.Manager', 'The database being ' 'loaded was created in a more recent version of ' 'OpenLP. The database is version %d, while OpenLP ' 'expects version %d. The database will not be loaded.' - '\n\nDatabase: %s')) % \ + '\n\nDatabase: %s') % \ (db_ver, up_ver, self.db_url) ) return @@ -222,8 +222,8 @@ class Manager(object): log.exception(u'Error loading database: %s', self.db_url) critical_error_message_box( translate('OpenLP.Manager', 'Database Error'), - unicode(translate('OpenLP.Manager', 'OpenLP cannot load your ' - 'database.\n\nDatabase: %s')) % self.db_url + translate('OpenLP.Manager', 'OpenLP cannot load your ' + 'database.\n\nDatabase: %s') % self.db_url ) def save_object(self, object_instance, commit=True): diff --git a/openlp/core/lib/listwidgetwithdnd.py b/openlp/core/lib/listwidgetwithdnd.py index 9e9787914..661f95b2e 100644 --- a/openlp/core/lib/listwidgetwithdnd.py +++ b/openlp/core/lib/listwidgetwithdnd.py @@ -98,7 +98,7 @@ class ListWidgetWithDnD(QtGui.QListWidget): event.accept() files = [] for url in event.mimeData().urls(): - localFile = unicode(url.toLocalFile()) + localFile = url.toLocalFile() if os.path.isfile(localFile): files.append(localFile) elif os.path.isdir(localFile): diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index aee0af32d..881efb28b 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -336,7 +336,7 @@ class MediaManagerItem(QtGui.QWidget): self, self.onNewPrompt, SettingsManager.get_last_dir(self.settingsSection), self.onNewFileMasks) - log.info(u'New files(s) %s', unicode(files)) + log.info(u'New files(s) %s', files) if files: Receiver.send_message(u'cursor_busy') self.validateAndLoad(files) @@ -359,9 +359,8 @@ class MediaManagerItem(QtGui.QWidget): critical_error_message_box( translate('OpenLP.MediaManagerItem', 'Invalid File Type'), - unicode(translate('OpenLP.MediaManagerItem', - 'Invalid File %s.\nSuffix not supported')) - % file) + translate('OpenLP.MediaManagerItem', + 'Invalid File %s.\nSuffix not supported') % file) errorShown = True else: newFiles.append(file) @@ -379,9 +378,9 @@ class MediaManagerItem(QtGui.QWidget): names = [] fullList = [] for count in range(self.listView.count()): - names.append(unicode(self.listView.item(count).text())) - fullList.append(unicode(self.listView.item(count). - data(QtCore.Qt.UserRole).toString())) + names.append(self.listView.item(count).text()) + fullList.append(self.listView.item(count). + data(QtCore.Qt.UserRole).toString()) duplicatesFound = False filesAdded = False for file in files: @@ -401,8 +400,8 @@ class MediaManagerItem(QtGui.QWidget): if duplicatesFound: critical_error_message_box( UiStrings().Duplicate, - unicode(translate('OpenLP.MediaManagerItem', - 'Duplicate files were found on import and were ignored.'))) + translate('OpenLP.MediaManagerItem', + 'Duplicate files were found on import and were ignored.')) def contextMenu(self, point): item = self.listView.itemAt(point) @@ -421,7 +420,7 @@ class MediaManagerItem(QtGui.QWidget): filelist = [] while count < self.listView.count(): bitem = self.listView.item(count) - filename = unicode(bitem.data(QtCore.Qt.UserRole).toString()) + filename = bitem.data(QtCore.Qt.UserRole).toString() filelist.append(filename) count += 1 return filelist @@ -573,8 +572,8 @@ class MediaManagerItem(QtGui.QWidget): QtGui.QMessageBox.information(self, translate('OpenLP.MediaManagerItem', 'Invalid Service Item'), - unicode(translate('OpenLP.MediaManagerItem', - 'You must select a %s service item.')) % self.title) + translate('OpenLP.MediaManagerItem', + 'You must select a %s service item.') % self.title) def buildServiceItem(self, item=None, xmlVersion=False, remote=False): """ diff --git a/openlp/core/lib/serviceitem.py b/openlp/core/lib/serviceitem.py index 36314ac7f..d2a3d6575 100644 --- a/openlp/core/lib/serviceitem.py +++ b/openlp/core/lib/serviceitem.py @@ -464,12 +464,12 @@ class ServiceItem(object): start = None end = None if self.start_time != 0: - start = unicode(translate('OpenLP.ServiceItem', - 'Start: %s')) % \ + start = translate('OpenLP.ServiceItem', + 'Start: %s') % \ unicode(datetime.timedelta(seconds=self.start_time)) if self.media_length != 0: - end = unicode(translate('OpenLP.ServiceItem', - 'Length: %s')) % \ + end = translate('OpenLP.ServiceItem', + 'Length: %s') % \ unicode(datetime.timedelta(seconds=self.media_length)) if not start and not end: return u'' diff --git a/openlp/core/lib/spelltextedit.py b/openlp/core/lib/spelltextedit.py index 310c219b5..d855f0ec9 100644 --- a/openlp/core/lib/spelltextedit.py +++ b/openlp/core/lib/spelltextedit.py @@ -100,7 +100,7 @@ class SpellTextEdit(QtGui.QPlainTextEdit): # Check if the selected word is misspelled and offer spelling # suggestions if it is. if ENCHANT_AVAILABLE and self.textCursor().hasSelection(): - text = unicode(self.textCursor().selectedText()) + text = self.textCursor().selectedText() if not self.dictionary.check(text): spell_menu = QtGui.QMenu(translate('OpenLP.SpellTextEdit', 'Spelling Suggestions')) diff --git a/openlp/core/lib/toolbar.py b/openlp/core/lib/toolbar.py index 44df193e1..b797c3389 100644 --- a/openlp/core/lib/toolbar.py +++ b/openlp/core/lib/toolbar.py @@ -66,7 +66,7 @@ class OpenLPToolbar(QtGui.QToolBar): Add a widget and store it's handle under the widgets object name. """ action = self.addWidget(widget) - self.actions[unicode(widget.objectName())] = action + self.actions[widget.objectName()] = action def setWidgetVisible(self, widgets, visible=True): """ diff --git a/openlp/core/lib/ui.py b/openlp/core/lib/ui.py index 2ab67c180..a8f24f8eb 100644 --- a/openlp/core/lib/ui.py +++ b/openlp/core/lib/ui.py @@ -66,7 +66,7 @@ class UiStrings(object): self.CreateService = translate('OpenLP.Ui', 'Create a new service.') self.ConfirmDelete = translate('OpenLP.Ui', 'Confirm Delete') self.Continuous = translate('OpenLP.Ui', 'Continuous') - self.Default = unicode(translate('OpenLP.Ui', 'Default')) + self.Default = translate('OpenLP.Ui', 'Default') self.Delete = translate('OpenLP.Ui', '&Delete') self.DisplayStyle = translate('OpenLP.Ui', 'Display style:') self.Duplicate = translate('OpenLP.Ui', 'Duplicate Error') @@ -127,7 +127,7 @@ class UiStrings(object): self.Split = translate('OpenLP.Ui', 'Optional &Split') self.SplitToolTip = translate('OpenLP.Ui', 'Split a slide into two ' 'only if it does not fit on the screen as one slide.') - self.StartTimeCode = unicode(translate('OpenLP.Ui', 'Start %s')) + self.StartTimeCode = translate('OpenLP.Ui', 'Start %s') self.StopPlaySlidesInLoop = translate('OpenLP.Ui', 'Stop Play Slides in Loop') self.StopPlaySlidesToEnd = translate('OpenLP.Ui', diff --git a/openlp/core/ui/aboutdialog.py b/openlp/core/ui/aboutdialog.py index f0908b729..5e46a622f 100644 --- a/openlp/core/ui/aboutdialog.py +++ b/openlp/core/ui/aboutdialog.py @@ -139,7 +139,7 @@ class Ui_AboutDialog(object): } documentors = [u'Wesley "wrst" Stout', u'John "jseagull1" Cegalis (lead)'] - self.creditsTextEdit.setPlainText(unicode(translate('OpenLP.AboutForm', + self.creditsTextEdit.setPlainText(translate('OpenLP.AboutForm', 'Project Lead\n' ' %s\n' '\n' @@ -200,7 +200,7 @@ class Ui_AboutDialog(object): ' God our Father, for sending His Son to die\n' ' on the cross, setting us free from sin. We\n' ' bring this software to you for free because\n' - ' He has set us free.')) % (lead, u'\n '.join(developers), + ' He has set us free.') % (lead, u'\n '.join(developers), u'\n '.join(contributors), u'\n '.join(testers), u'\n '.join(packagers), u'\n '.join(translators[u'af']), u'\n '.join(translators[u'de']), @@ -218,9 +218,9 @@ class Ui_AboutDialog(object): self.aboutNotebook.setTabText( self.aboutNotebook.indexOf(self.creditsTab), translate('OpenLP.AboutForm', 'Credits')) - copyright = unicode(translate('OpenLP.AboutForm', + copyright = translate('OpenLP.AboutForm', 'Copyright \xa9 2004-2012 %s\n' - 'Portions copyright \xa9 2004-2012 %s')) % (u'Raoul Snyman', + 'Portions copyright \xa9 2004-2012 %s') % (u'Raoul Snyman', u'Tim Bentley, Jonathan Corwin, Michael Gorven, Gerald Britton, ' u'Scott Guerrieri, Matthias Hub, Meinert Jordan, Armin K\xf6hler, ' u'Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias ' diff --git a/openlp/core/ui/aboutform.py b/openlp/core/ui/aboutform.py index e2ccbc3c3..836289b5c 100644 --- a/openlp/core/ui/aboutform.py +++ b/openlp/core/ui/aboutform.py @@ -47,7 +47,7 @@ class AboutForm(QtGui.QDialog, Ui_AboutDialog): about_text = about_text.replace(u'', applicationVersion[u'version']) if applicationVersion[u'build']: - build_text = unicode(translate('OpenLP.AboutForm', ' build %s')) % \ + build_text = translate('OpenLP.AboutForm', ' build %s') % \ applicationVersion[u'build'] else: build_text = u'' diff --git a/openlp/core/ui/advancedtab.py b/openlp/core/ui/advancedtab.py index 55547cbbd..20c71460d 100644 --- a/openlp/core/ui/advancedtab.py +++ b/openlp/core/ui/advancedtab.py @@ -52,12 +52,12 @@ class AdvancedTab(SettingsTab): # 11 o'clock is the most popular time for morning service. self.defaultServiceHour = 11 self.defaultServiceMinute = 0 - self.defaultServiceName = unicode(translate('OpenLP.AdvancedTab', + self.defaultServiceName = translate('OpenLP.AdvancedTab', 'Service %Y-%m-%d %H-%M', 'This may not contain any of the following characters: ' '/\\?*|<>\[\]":+\n' 'See http://docs.python.org/library/datetime.html' - '#strftime-strptime-behavior for more information.')) + '#strftime-strptime-behavior for more information.') self.defaultImage = u':/graphics/openlp-splash-screen.png' self.defaultColor = u'#ffffff' self.iconPath = u':/system/system_settings.png' @@ -299,9 +299,9 @@ class AdvancedTab(SettingsTab): translate('OpenLP.AdvancedTab', 'Name:')) self.serviceNameEdit.setToolTip(translate('OpenLP.AdvancedTab', 'Consult the OpenLP manual for usage.')) - self.serviceNameRevertButton.setToolTip(unicode( + self.serviceNameRevertButton.setToolTip( translate('OpenLP.AdvancedTab', - 'Revert to the default service name "%s".')) % + 'Revert to the default service name "%s".') % self.defaultServiceName) self.serviceNameExampleLabel.setText(translate('OpenLP.AdvancedTab', 'Example:')) @@ -397,7 +397,7 @@ class AdvancedTab(SettingsTab): settings.beginGroup(self.settingsSection) settings.setValue(u'default service enabled', self.serviceNameCheckBox.isChecked()) - service_name = unicode(self.serviceNameEdit.text()) + service_name = self.serviceNameEdit.text() preset_is_valid = self.generateServiceNameExample()[0] if service_name == self.defaultServiceName or not preset_is_valid: settings.remove(u'default service name') diff --git a/openlp/core/ui/exceptionform.py b/openlp/core/ui/exceptionform.py index 7ea3a5bc1..cd2312790 100644 --- a/openlp/core/ui/exceptionform.py +++ b/openlp/core/ui/exceptionform.py @@ -110,10 +110,10 @@ class ExceptionForm(QtGui.QDialog, Ui_ExceptionDialog): def _createReport(self): openlp_version = get_application_version() - description = unicode(self.descriptionTextEdit.toPlainText()) - traceback = unicode(self.exceptionTextEdit.toPlainText()) - system = unicode(translate('OpenLP.ExceptionForm', - 'Platform: %s\n')) % platform.platform() + description = self.descriptionTextEdit.toPlainText() + traceback = self.exceptionTextEdit.toPlainText() + system = translate('OpenLP.ExceptionForm', + 'Platform: %s\n') % platform.platform() libraries = u'Python: %s\n' % platform.python_version() + \ u'Qt4: %s\n' % Qt.qVersion() + \ u'Phonon: %s\n' % PHONON_VERSION + \ @@ -139,13 +139,13 @@ class ExceptionForm(QtGui.QDialog, Ui_ExceptionDialog): """ Saving exception log and system informations to a file. """ - report_text = unicode(translate('OpenLP.ExceptionForm', + report_text = translate('OpenLP.ExceptionForm', '**OpenLP Bug Report**\n' 'Version: %s\n\n' '--- Details of the Exception. ---\n\n%s\n\n ' '--- Exception Traceback ---\n%s\n' '--- System information ---\n%s\n' - '--- Library Versions ---\n%s\n')) + '--- Library Versions ---\n%s\n') filename = QtGui.QFileDialog.getSaveFileName(self, translate('OpenLP.ExceptionForm', 'Save Crash Report'), SettingsManager.get_last_dir(self.settingsSection), @@ -176,7 +176,7 @@ class ExceptionForm(QtGui.QDialog, Ui_ExceptionDialog): Opening systems default email client and inserting exception log and system informations. """ - body = unicode(translate('OpenLP.ExceptionForm', + body = translate('OpenLP.ExceptionForm', '*OpenLP Bug Report*\n' 'Version: %s\n\n' '--- Details of the Exception. ---\n\n%s\n\n ' @@ -184,7 +184,7 @@ class ExceptionForm(QtGui.QDialog, Ui_ExceptionDialog): '--- System information ---\n%s\n' '--- Library Versions ---\n%s\n', 'Please add the information that bug reports are favoured written ' - 'in English.')) + 'in English.') content = self._createReport() source = u'' exception = u'' @@ -209,8 +209,8 @@ class ExceptionForm(QtGui.QDialog, Ui_ExceptionDialog): else: self.__buttonState(False) self.descriptionWordCount.setText( - unicode(translate('OpenLP.ExceptionDialog', - 'Description characters to enter : %s')) % count) + translate('OpenLP.ExceptionDialog', + 'Description characters to enter : %s') % count) def onAttachFileButtonClicked(self): files = QtGui.QFileDialog.getOpenFileName( diff --git a/openlp/core/ui/firsttimeform.py b/openlp/core/ui/firsttimeform.py index b0630e5fb..d17b65927 100644 --- a/openlp/core/ui/firsttimeform.py +++ b/openlp/core/ui/firsttimeform.py @@ -87,8 +87,8 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): self.config.readfp(io.BytesIO(files)) self.updateScreenListCombo() self.downloadCanceled = False - self.downloading = unicode(translate('OpenLP.FirstTimeWizard', - 'Downloading %s...')) + self.downloading = translate('OpenLP.FirstTimeWizard', + 'Downloading %s...') QtCore.QObject.connect(self.cancelButton, QtCore.SIGNAL('clicked()'), self.onCancelButtonClicked) QtCore.QObject.connect(self.noInternetFinishButton, @@ -435,7 +435,7 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): while bibles_iterator.value(): item = bibles_iterator.value() if item.parent() and item.checkState(0) == QtCore.Qt.Checked: - bible = unicode(item.data(0, QtCore.Qt.UserRole).toString()) + bible = item.data(0, QtCore.Qt.UserRole).toString() self._incrementProgressBar(self.downloading % bible, 0) self.previous_size = 0 self.urlGetFile(u'%s%s' % (self.web, bible), @@ -445,7 +445,7 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): for i in xrange(self.themesListWidget.count()): item = self.themesListWidget.item(i) if item.checkState() == QtCore.Qt.Checked: - theme = unicode(item.data(QtCore.Qt.UserRole).toString()) + theme = item.data(QtCore.Qt.UserRole).toString() self._incrementProgressBar(self.downloading % theme, 0) self.previous_size = 0 self.urlGetFile(u'%s%s' % (self.web, theme), diff --git a/openlp/core/ui/formattingtagform.py b/openlp/core/ui/formattingtagform.py index 1084d6a3d..1f6fdf7bd 100644 --- a/openlp/core/ui/formattingtagform.py +++ b/openlp/core/ui/formattingtagform.py @@ -155,18 +155,18 @@ class FormattingTagForm(QtGui.QDialog, Ui_FormattingTagDialog): html_expands = FormattingTags.get_html_tags() if self.selected != -1: html = html_expands[self.selected] - tag = unicode(self.tagLineEdit.text()) + tag = self.tagLineEdit.text() for linenumber, html1 in enumerate(html_expands): if self._strip(html1[u'start tag']) == tag and \ linenumber != self.selected: critical_error_message_box( translate('OpenLP.FormattingTagForm', 'Update Error'), - unicode(translate('OpenLP.FormattingTagForm', - 'Tag %s already defined.')) % tag) + translate('OpenLP.FormattingTagForm', + 'Tag %s already defined.') % tag) return - html[u'desc'] = unicode(self.descriptionLineEdit.text()) - html[u'start html'] = unicode(self.startTagLineEdit.text()) - html[u'end html'] = unicode(self.endTagLineEdit.text()) + html[u'desc'] = self.descriptionLineEdit.text() + html[u'start html'] = self.startTagLineEdit.text() + html[u'end html'] = self.endTagLineEdit.text() html[u'start tag'] = u'{%s}' % tag html[u'end tag'] = u'{/%s}' % tag # Keep temporary tags when the user changes one. diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index f430ec1c9..34d5434ec 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -257,7 +257,7 @@ class MainDisplay(Display): height = self.frame.evaluateJavaScript(js) if shrink: if text: - alert_height = int(height) + alert_height = int(height.toString()) self.resize(self.width(), alert_height) self.setVisible(True) if location == AlertLocation.Middle: diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 3daa11dab..a8ddb9235 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -173,7 +173,7 @@ class Ui_MainWindow(object): self.themeManagerDock) # Create the menu items action_list = ActionList.get_instance() - action_list.add_category(unicode(UiStrings().File), + action_list.add_category(UiStrings().File, CategoryOrder.standardMenu) self.fileNewItem = create_action(mainWindow, u'fileNewItem', icon=u':/general/general_new.png', @@ -202,19 +202,19 @@ class Ui_MainWindow(object): icon=u':/system/system_exit.png', shortcuts=[QtGui.QKeySequence(u'Alt+F4')], category=UiStrings().File, triggers=mainWindow.close) - action_list.add_category(unicode(UiStrings().Import), + action_list.add_category(UiStrings().Import, CategoryOrder.standardMenu) self.importThemeItem = create_action(mainWindow, u'importThemeItem', category=UiStrings().Import) self.importLanguageItem = create_action(mainWindow, u'importLanguageItem')#, category=UiStrings().Import) - action_list.add_category(unicode(UiStrings().Export), + action_list.add_category(UiStrings().Export, CategoryOrder.standardMenu) self.exportThemeItem = create_action(mainWindow, u'exportThemeItem', category=UiStrings().Export) self.exportLanguageItem = create_action(mainWindow, u'exportLanguageItem')#, category=UiStrings().Export) - action_list.add_category(unicode(UiStrings().View), + action_list.add_category(UiStrings().View, CategoryOrder.standardMenu) self.viewMediaManagerItem = create_action(mainWindow, u'viewMediaManagerItem', shortcuts=[QtGui.QKeySequence(u'F8')], @@ -239,7 +239,7 @@ class Ui_MainWindow(object): category=UiStrings().View, triggers=self.setLivePanelVisibility) self.lockPanel = create_action(mainWindow, u'lockPanel', checked=panelLocked, triggers=self.setLockPanel) - action_list.add_category(unicode(UiStrings().ViewMode), + action_list.add_category(UiStrings().ViewMode, CategoryOrder.standardMenu) self.modeDefaultItem = create_action(mainWindow, u'modeDefaultItem', checked=False, category=UiStrings().ViewMode) @@ -252,8 +252,7 @@ class Ui_MainWindow(object): self.modeGroup.addAction(self.modeSetupItem) self.modeGroup.addAction(self.modeLiveItem) self.modeDefaultItem.setChecked(True) - action_list.add_category(unicode(UiStrings().Tools), - CategoryOrder.standardMenu) + action_list.add_category(UiStrings().Tools, CategoryOrder.standardMenu) self.toolsAddToolItem = create_action(mainWindow, u'toolsAddToolItem', icon=u':/tools/tools_add.png', category=UiStrings().Tools) @@ -265,7 +264,7 @@ class Ui_MainWindow(object): category=UiStrings().Tools) self.updateThemeImages = create_action(mainWindow, u'updateThemeImages', category=UiStrings().Tools) - action_list.add_category(unicode(UiStrings().Settings), + action_list.add_category(UiStrings().Settings, CategoryOrder.standardMenu) self.settingsPluginListItem = create_action(mainWindow, u'settingsPluginListItem', @@ -300,8 +299,7 @@ class Ui_MainWindow(object): u'settingsImportItem', category=UiStrings().Settings) self.settingsExportItem = create_action(mainWindow, u'settingsExportItem', category=UiStrings().Settings) - action_list.add_category(unicode(UiStrings().Help), - CategoryOrder.standardMenu) + action_list.add_category(UiStrings().Help, CategoryOrder.standardMenu) self.aboutItem = create_action(mainWindow, u'aboutItem', icon=u':/system/system_about.png', shortcuts=[QtGui.QKeySequence(u'Ctrl+F1')], @@ -497,8 +495,8 @@ class Ui_MainWindow(object): translate('OpenLP.MainWindow', '&Web Site')) for item in self.languageGroup.actions(): item.setText(item.objectName()) - item.setStatusTip(unicode(translate('OpenLP.MainWindow', - 'Set the interface language to %s')) % item.objectName()) + item.setStatusTip(translate('OpenLP.MainWindow', + 'Set the interface language to %s') % item.objectName()) self.autoLanguageItem.setText( translate('OpenLP.MainWindow', '&Autodetect')) self.autoLanguageItem.setStatusTip(translate('OpenLP.MainWindow', @@ -709,10 +707,10 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): Notifies the user that a newer version of OpenLP is available. Triggered by delay thread. """ - version_text = unicode(translate('OpenLP.MainWindow', + version_text = translate('OpenLP.MainWindow', 'Version %s of OpenLP is now available for download (you are ' 'currently running version %s). \n\nYou can download the latest ' - 'version from http://openlp.org/.')) + 'version from http://openlp.org/.') QtGui.QMessageBox.question(self, translate('OpenLP.MainWindow', 'OpenLP Version Updated'), version_text % (version, get_application_version()[u'full'])) @@ -928,11 +926,10 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): QtGui.QMessageBox.No) if answer == QtGui.QMessageBox.No: return - import_file_name = unicode(QtGui.QFileDialog.getOpenFileName(self, - translate('OpenLP.MainWindow', 'Open File'), - '', + import_file_name = QtGui.QFileDialog.getOpenFileName(self, + translate('OpenLP.MainWindow', 'Open File'), '', translate('OpenLP.MainWindow', - 'OpenLP Export Settings Files (*.conf)'))) + 'OpenLP Export Settings Files (*.conf)')) if not import_file_name: return setting_sections = [] @@ -1003,10 +1000,10 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): """ Export settings to a .conf file in INI format """ - export_file_name = unicode(QtGui.QFileDialog.getSaveFileName(self, + export_file_name = QtGui.QFileDialog.getSaveFileName(self, translate('OpenLP.MainWindow', 'Export Settings File'), '', translate('OpenLP.MainWindow', - 'OpenLP Export Settings File (*.conf)'))) + 'OpenLP Export Settings File (*.conf)')) if not export_file_name: return # Make sure it's a .conf file. @@ -1218,8 +1215,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): def defaultThemeChanged(self, theme): self.defaultThemeLabel.setText( - unicode(translate('OpenLP.MainWindow', 'Default Theme: %s')) % - theme) + translate('OpenLP.MainWindow', 'Default Theme: %s') % theme) def toggleMediaManager(self): self.mediaManagerDock.setVisible(not self.mediaManagerDock.isVisible()) diff --git a/openlp/core/ui/media/mediacontroller.py b/openlp/core/ui/media/mediacontroller.py index 2fb0c6fd4..541c61763 100644 --- a/openlp/core/ui/media/mediacontroller.py +++ b/openlp/core/ui/media/mediacontroller.py @@ -324,8 +324,7 @@ class MediaController(object): # Media could not be loaded correctly critical_error_message_box( translate('MediaPlugin.MediaItem', 'Unsupported File'), - unicode(translate('MediaPlugin.MediaItem', - 'Unsupported File'))) + translate('MediaPlugin.MediaItem', 'Unsupported File')) return False # dont care about actual theme, set a black background if controller.isLive and not controller.media_info.is_background: @@ -339,8 +338,7 @@ class MediaController(object): if not self.video_play([controller]): critical_error_message_box( translate('MediaPlugin.MediaItem', 'Unsupported File'), - unicode(translate('MediaPlugin.MediaItem', - 'Unsupported File'))) + translate('MediaPlugin.MediaItem', 'Unsupported File')) return False self.set_controls_visible(controller, True) log.debug(u'use %s controller' % self.curDisplayMediaPlayer[display]) diff --git a/openlp/core/ui/pluginform.py b/openlp/core/ui/pluginform.py index 435181568..8912e604e 100644 --- a/openlp/core/ui/pluginform.py +++ b/openlp/core/ui/pluginform.py @@ -71,22 +71,19 @@ class PluginForm(QtGui.QDialog, Ui_PluginViewDialog): plugin.status = int(plugin.status) # Set the little status text in brackets next to the plugin name. if plugin.status == PluginStatus.Disabled: - status_text = unicode( - translate('OpenLP.PluginForm', '%s (Disabled)')) + status_text = translate('OpenLP.PluginForm', '%s (Disabled)') elif plugin.status == PluginStatus.Active: - status_text = unicode( - translate('OpenLP.PluginForm', '%s (Active)')) + status_text = translate('OpenLP.PluginForm', '%s (Active)') else: # PluginStatus.Inactive - status_text = unicode( - translate('OpenLP.PluginForm', '%s (Inactive)')) + status_text = translate('OpenLP.PluginForm', '%s (Inactive)') item.setText(status_text % plugin.nameStrings[u'singular']) # If the plugin has an icon, set it! if plugin.icon: item.setIcon(plugin.icon) self.pluginListWidget.addItem(item) pluginListWidth = max(pluginListWidth, self.fontMetrics().width( - unicode(translate('OpenLP.PluginForm', '%s (Inactive)')) % + translate('OpenLP.PluginForm', '%s (Inactive)') % plugin.nameStrings[u'singular'])) self.pluginListWidget.setFixedWidth(pluginListWidth + self.pluginListWidget.iconSize().width() + 48) @@ -136,16 +133,12 @@ class PluginForm(QtGui.QDialog, Ui_PluginViewDialog): self.activePlugin.appStartup() else: self.activePlugin.toggleStatus(PluginStatus.Inactive) - status_text = unicode( - translate('OpenLP.PluginForm', '%s (Inactive)')) + status_text = translate('OpenLP.PluginForm', '%s (Inactive)') if self.activePlugin.status == PluginStatus.Active: - status_text = unicode( - translate('OpenLP.PluginForm', '%s (Active)')) + status_text = translate('OpenLP.PluginForm', '%s (Active)') elif self.activePlugin.status == PluginStatus.Inactive: - status_text = unicode( - translate('OpenLP.PluginForm', '%s (Inactive)')) + status_text = translate('OpenLP.PluginForm', '%s (Inactive)') elif self.activePlugin.status == PluginStatus.Disabled: - status_text = unicode( - translate('OpenLP.PluginForm', '%s (Disabled)')) + status_text = translate('OpenLP.PluginForm', '%s (Disabled)') self.pluginListWidget.currentItem().setText( status_text % self.activePlugin.nameStrings[u'singular']) diff --git a/openlp/core/ui/printserviceform.py b/openlp/core/ui/printserviceform.py index 3cf55713b..1650849e0 100644 --- a/openlp/core/ui/printserviceform.py +++ b/openlp/core/ui/printserviceform.py @@ -172,8 +172,7 @@ class PrintServiceForm(QtGui.QDialog, Ui_PrintServiceDialog): """ html_data = self._addElement(u'html') self._addElement(u'head', parent=html_data) - self._addElement(u'title', unicode(self.titleLineEdit.text()), - html_data.head) + self._addElement(u'title', self.titleLineEdit.text(), html_data.head) css_path = os.path.join( AppLocation.get_data_path(), u'service_print.css') custom_css = get_text_file_string(css_path) @@ -182,7 +181,7 @@ class PrintServiceForm(QtGui.QDialog, Ui_PrintServiceDialog): self._addElement(u'style', custom_css, html_data.head, attribute=(u'type', u'text/css')) self._addElement(u'body', parent=html_data) - self._addElement(u'h1', cgi.escape(unicode(self.titleLineEdit.text())), + self._addElement(u'h1', cgi.escape(self.titleLineEdit.text()), html_data.body, classId=u'serviceTitle') for index, item in enumerate(self.serviceManager.serviceItems): self._addPreviewItem(html_data.body, item[u'service_item'], index) @@ -241,7 +240,7 @@ class PrintServiceForm(QtGui.QDialog, Ui_PrintServiceDialog): translate('OpenLP.ServiceManager', 'Notes: '), p, classId=u'itemNotesTitle') self._addElement(u'span', - cgi.escape(unicode(item.notes)).replace(u'\n', u'
'), p, + cgi.escape(item.notes).replace(u'\n', u'
'), p, classId=u'itemNotesText') # Add play length of media files. if item.is_media() and self.metaDataCheckBox.isChecked(): diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 48abc500a..78ca788de 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -174,7 +174,7 @@ class ServiceManager(QtGui.QWidget): self.orderToolbar = OpenLPToolbar(self) action_list = ActionList.get_instance() action_list.add_category( - unicode(UiStrings().Service), CategoryOrder.standardToolbar) + UiStrings().Service, CategoryOrder.standardToolbar) self.serviceManagerList.moveTop = self.orderToolbar.addToolbarAction( u'moveTop', text=translate('OpenLP.ServiceManager', 'Move to &top'), icon=u':/services/service_top.png', tooltip=translate( @@ -405,13 +405,13 @@ class ServiceManager(QtGui.QWidget): elif result == QtGui.QMessageBox.Save: self.saveFile() if not loadFile: - fileName = unicode(QtGui.QFileDialog.getOpenFileName( + fileName = QtGui.QFileDialog.getOpenFileName( self.mainwindow, translate('OpenLP.ServiceManager', 'Open File'), SettingsManager.get_last_dir( self.mainwindow.serviceManagerSettingsSection), translate('OpenLP.ServiceManager', - 'OpenLP Service Files (*.osz)'))) + 'OpenLP Service Files (*.osz)')) if not fileName: return False else: @@ -503,11 +503,11 @@ class ServiceManager(QtGui.QWidget): if not os.path.exists(path_from): if not skipMissing: Receiver.send_message(u'cursor_normal') - title = unicode(translate('OpenLP.ServiceManager', - 'Service File Missing')) - message = unicode(translate('OpenLP.ServiceManager', + title = translate('OpenLP.ServiceManager', + 'Service File Missing') + message = translate('OpenLP.ServiceManager', 'File missing from service\n\n %s \n\n' - 'Continue saving?' % path_from )) + 'Continue saving?' % path_from ) answer = QtGui.QMessageBox.critical(self, title, message, QtGui.QMessageBox.StandardButtons( @@ -621,9 +621,9 @@ class ServiceManager(QtGui.QWidget): directory = SettingsManager.get_last_dir( self.mainwindow.serviceManagerSettingsSection) path = os.path.join(directory, default_filename) - fileName = unicode(QtGui.QFileDialog.getSaveFileName(self.mainwindow, + fileName = QtGui.QFileDialog.getSaveFileName(self.mainwindow, UiStrings().SaveService, path, - translate('OpenLP.ServiceManager', 'OpenLP Service Files (*.osz)'))) + translate('OpenLP.ServiceManager', 'OpenLP Service Files (*.osz)')) if not fileName: return False if os.path.splitext(fileName)[1] == u'': @@ -1043,16 +1043,16 @@ class ServiceManager(QtGui.QWidget): tips = [] if serviceitem.temporary_edit: tips.append(u'%s: %s' % - (unicode(translate('OpenLP.ServiceManager', 'Edit')), - (unicode(translate('OpenLP.ServiceManager', - 'Service copy only'))))) + (translate('OpenLP.ServiceManager', 'Edit'), + (translate('OpenLP.ServiceManager', + 'Service copy only')))) if serviceitem.theme and serviceitem.theme != -1: tips.append(u'%s: %s' % - (unicode(translate('OpenLP.ServiceManager', 'Slide theme')), - serviceitem.theme)) + (translate('OpenLP.ServiceManager', 'Slide theme')), + serviceitem.theme) if serviceitem.notes: tips.append(u'%s: %s' % - (unicode(translate('OpenLP.ServiceManager', 'Notes')), + (translate('OpenLP.ServiceManager', 'Notes'), cgi.escape(unicode(serviceitem.notes)))) if item[u'service_item'] \ .is_capable(ItemCapabilities.HasVariableStartTime): @@ -1099,7 +1099,7 @@ class ServiceManager(QtGui.QWidget): Set the theme for the current service. """ log.debug(u'onThemeComboBoxSelected') - self.service_theme = unicode(self.themeComboBox.currentText()) + self.service_theme = self.themeComboBox.currentText() self.mainwindow.renderer.set_service_theme(self.service_theme) Settings().setValue( self.mainwindow.serviceManagerSettingsSection + @@ -1358,11 +1358,11 @@ class ServiceManager(QtGui.QWidget): event.setDropAction(QtCore.Qt.CopyAction) event.accept() for url in link.urls(): - filename = unicode(url.toLocalFile()) + filename = url.toLocalFile() if filename.endswith(u'.osz'): self.onLoadServiceClicked(filename) elif link.hasText(): - plugin = unicode(link.text()) + plugin = link.text() item = self.serviceManagerList.itemAt(event.pos()) # ServiceManager started the drag and drop if plugin == u'ServiceManager': @@ -1434,7 +1434,7 @@ class ServiceManager(QtGui.QWidget): self.regenerateServiceItems() def onThemeChangeAction(self): - theme = unicode(self.sender().objectName()) + theme = self.sender().objectName() # No object name means that the "Default" theme is supposed to be used. if not theme: theme = None diff --git a/openlp/core/ui/shortcutlistform.py b/openlp/core/ui/shortcutlistform.py index 377da339f..fe62f3d16 100644 --- a/openlp/core/ui/shortcutlistform.py +++ b/openlp/core/ui/shortcutlistform.py @@ -128,7 +128,7 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): continue item = QtGui.QTreeWidgetItem([category.name]) for action in category.actions: - actionText = REMOVE_AMPERSAND.sub('', unicode(action.text())) + actionText = REMOVE_AMPERSAND.sub('', action.text()) actionItem = QtGui.QTreeWidgetItem([actionText]) actionItem.setIcon(0, action.icon()) actionItem.setData(0, QtCore.Qt.UserRole, action) @@ -441,9 +441,9 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): Receiver.send_message(u'openlp_warning_message', { u'title': translate('OpenLP.ShortcutListDialog', 'Duplicate Shortcut'), - u'message': unicode(translate('OpenLP.ShortcutListDialog', + u'message': translate('OpenLP.ShortcutListDialog', 'The shortcut "%s" is already assigned to another action, ' - 'please use a different shortcut.')) % key_sequence.toString() + 'please use a different shortcut.') % key_sequence.toString() }) return is_valid diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index 2dff89bc3..aaff6137c 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -446,7 +446,7 @@ class SlideController(Controller): SONGS_PLUGIN_AVAILABLE = True except ImportError: SONGS_PLUGIN_AVAILABLE = False - sender_name = unicode(self.sender().objectName()) + sender_name = self.sender().objectName() verse_type = sender_name[15:] \ if sender_name[:15] == u'shortcutAction_' else u'' if SONGS_PLUGIN_AVAILABLE: @@ -647,7 +647,7 @@ class SlideController(Controller): framenumber, width / self.ratio) def onSongBarHandler(self): - request = unicode(self.sender().text()) + request = self.sender().text() slide_no = self.slideList[request] self.__updatePreviewSelection(slide_no) self.slideSelected() diff --git a/openlp/core/ui/themeform.py b/openlp/core/ui/themeform.py index 1a9f142f7..25e4c1cf5 100644 --- a/openlp/core/ui/themeform.py +++ b/openlp/core/ui/themeform.py @@ -208,8 +208,8 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard): """ Updates the lines on a page on the wizard """ - self.mainLineCountLabel.setText(unicode(translate('OpenLP.ThemeForm', - '(approximately %d lines per slide)')) % int(lines)) + self.mainLineCountLabel.setText(translate('OpenLP.ThemeForm', + '(approximately %d lines per slide)') % int(lines)) def resizeEvent(self, event=None): """ @@ -319,8 +319,8 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard): self.themeNameEdit.setVisible(not edit) self.edit_mode = edit if edit: - self.setWindowTitle(unicode(translate('OpenLP.ThemeWizard', - 'Edit Theme - %s')) % self.theme.theme_name) + self.setWindowTitle(translate('OpenLP.ThemeWizard', + 'Edit Theme - %s') % self.theme.theme_name) self.next() else: self.setWindowTitle(UiStrings().NewTheme) @@ -550,23 +550,20 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard): return log.debug(u'updateTheme') # main page - self.theme.font_main_name = \ - unicode(self.mainFontComboBox.currentFont().family()) - self.theme.font_main_size = \ - self.field(u'mainSizeSpinBox').toInt()[0] + self.theme.font_main_name = self.mainFontComboBox.currentFont().family() + self.theme.font_main_size = self.field(u'mainSizeSpinBox').toInt()[0] self.theme.font_main_line_adjustment = \ self.field(u'lineSpacingSpinBox').toInt()[0] self.theme.font_main_outline_size = \ self.field(u'outlineSizeSpinBox').toInt()[0] self.theme.font_main_shadow_size = \ self.field(u'shadowSizeSpinBox').toInt()[0] - self.theme.font_main_bold = \ - self.field(u'mainBoldCheckBox').toBool() + self.theme.font_main_bold = self.field(u'mainBoldCheckBox').toBool() self.theme.font_main_italics = \ self.field(u'mainItalicsCheckBox').toBool() # footer page self.theme.font_footer_name = \ - unicode(self.footerFontComboBox.currentFont().family()) + self.footerFontComboBox.currentFont().family() self.theme.font_footer_size = \ self.field(u'footerSizeSpinBox').toInt()[0] # position page @@ -594,7 +591,7 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard): Lets save the theme as Finish has been triggered """ # Save the theme name - self.theme.theme_name = unicode(self.field(u'name').toString()) + self.theme.theme_name = self.field(u'name').toString() if not self.theme.theme_name: critical_error_message_box( translate('OpenLP.ThemeForm', 'Theme Name Missing'), diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index bfbac5fc1..b153310d5 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -173,8 +173,8 @@ class ThemeManager(QtGui.QWidget): """ if item is None: return - real_theme_name = unicode(item.data(QtCore.Qt.UserRole).toString()) - theme_name = unicode(item.text()) + real_theme_name = item.data(QtCore.Qt.UserRole).toString() + theme_name = item.text() # If default theme restrict actions if real_theme_name == theme_name: self.deleteToolbarAction.setVisible(True) @@ -189,8 +189,8 @@ class ThemeManager(QtGui.QWidget): item = self.themeListWidget.itemAt(point) if item is None: return - real_theme_name = unicode(item.data(QtCore.Qt.UserRole).toString()) - theme_name = unicode(item.text()) + real_theme_name = item.data(QtCore.Qt.UserRole).toString() + theme_name = item.text() self.deleteAction.setVisible(False) self.renameAction.setVisible(False) self.globalAction.setVisible(False) @@ -211,13 +211,13 @@ class ThemeManager(QtGui.QWidget): # reset the old name item = self.themeListWidget.item(count) old_name = item.text() - new_name = unicode(item.data(QtCore.Qt.UserRole).toString()) + new_name = item.data(QtCore.Qt.UserRole).toString() if old_name != new_name: self.themeListWidget.item(count).setText(new_name) # Set the new name if theme_name == new_name: - name = unicode(translate('OpenLP.ThemeManager', - '%s (default)')) % new_name + name = translate('OpenLP.ThemeManager', + '%s (default)') % new_name self.themeListWidget.item(count).setText(name) self.deleteToolbarAction.setVisible( item not in self.themeListWidget.selectedItems()) @@ -233,15 +233,14 @@ class ThemeManager(QtGui.QWidget): item = self.themeListWidget.item(count) old_name = item.text() # reset the old name - if old_name != unicode(item.data(QtCore.Qt.UserRole).toString()): + if old_name != item.data(QtCore.Qt.UserRole).toString(): self.themeListWidget.item(count).setText( - unicode(item.data(QtCore.Qt.UserRole).toString())) + item.data(QtCore.Qt.UserRole).toString()) # Set the new name if count == selected_row: - self.global_theme = unicode( - self.themeListWidget.item(count).text()) - name = unicode(translate('OpenLP.ThemeManager', - '%s (default)')) % self.global_theme + self.global_theme = self.themeListWidget.item(count).text() + name = translate('OpenLP.ThemeManager', + '%s (default)') % self.global_theme self.themeListWidget.item(count).setText(name) Settings().setValue( self.settingsSection + u'/global theme', self.global_theme) @@ -262,16 +261,16 @@ class ThemeManager(QtGui.QWidget): """ Renames an existing theme to a new name """ - if self._validate_theme_action(unicode(translate('OpenLP.ThemeManager', - 'You must select a theme to rename.')), - unicode(translate('OpenLP.ThemeManager', 'Rename Confirmation')), - unicode(translate('OpenLP.ThemeManager', 'Rename %s theme?')), + if self._validate_theme_action(translate('OpenLP.ThemeManager', + 'You must select a theme to rename.'), + translate('OpenLP.ThemeManager', 'Rename Confirmation'), + translate('OpenLP.ThemeManager', 'Rename %s theme?'), False, False): item = self.themeListWidget.currentItem() - old_theme_name = unicode(item.data(QtCore.Qt.UserRole).toString()) + old_theme_name = item.data(QtCore.Qt.UserRole).toString() self.fileRenameForm.fileNameEdit.setText(old_theme_name) if self.fileRenameForm.exec_(): - new_theme_name = unicode(self.fileRenameForm.fileNameEdit.text()) + new_theme_name = self.fileRenameForm.fileNameEdit.text() if old_theme_name == new_theme_name: return if self.checkIfThemeExists(new_theme_name): @@ -288,12 +287,12 @@ class ThemeManager(QtGui.QWidget): Copies an existing theme to a new name """ item = self.themeListWidget.currentItem() - old_theme_name = unicode(item.data(QtCore.Qt.UserRole).toString()) + old_theme_name = item.data(QtCore.Qt.UserRole).toString() self.fileRenameForm.fileNameEdit.setText( - unicode(translate('OpenLP.ThemeManager', - 'Copy of %s', 'Copy of ')) % old_theme_name) + translate('OpenLP.ThemeManager', + 'Copy of %s', 'Copy of ') % old_theme_name) if self.fileRenameForm.exec_(True): - new_theme_name = unicode(self.fileRenameForm.fileNameEdit.text()) + new_theme_name = self.fileRenameForm.fileNameEdit.text() if self.checkIfThemeExists(new_theme_name): theme_data = self.getThemeData(old_theme_name) self.cloneThemeData(theme_data, new_theme_name) @@ -322,8 +321,7 @@ class ThemeManager(QtGui.QWidget): translate('OpenLP.ThemeManager', 'You must select a theme to edit.')): item = self.themeListWidget.currentItem() - theme = self.getThemeData( - unicode(item.data(QtCore.Qt.UserRole).toString())) + theme = self.getThemeData(item.data(QtCore.Qt.UserRole).toString()) if theme.background_type == u'image': self.old_background_image = theme.background_filename self.themeForm.theme = theme @@ -334,12 +332,12 @@ class ThemeManager(QtGui.QWidget): """ Delete a theme """ - if self._validate_theme_action(unicode(translate('OpenLP.ThemeManager', - 'You must select a theme to delete.')), - unicode(translate('OpenLP.ThemeManager', 'Delete Confirmation')), - unicode(translate('OpenLP.ThemeManager', 'Delete %s theme?'))): + if self._validate_theme_action(translate('OpenLP.ThemeManager', + 'You must select a theme to delete.'), + translate('OpenLP.ThemeManager', 'Delete Confirmation'), + translate('OpenLP.ThemeManager', 'Delete %s theme?')): item = self.themeListWidget.currentItem() - theme = unicode(item.text()) + theme = item.text() row = self.themeListWidget.row(item) self.themeListWidget.takeItem(row) self.deleteTheme(theme) @@ -373,10 +371,9 @@ class ThemeManager(QtGui.QWidget): critical_error_message_box(message=translate('OpenLP.ThemeManager', 'You have not selected a theme.')) return - theme = unicode(item.data(QtCore.Qt.UserRole).toString()) + theme = item.data(QtCore.Qt.UserRole).toString() path = QtGui.QFileDialog.getExistingDirectory(self, - unicode(translate('OpenLP.ThemeManager', - 'Save Theme - (%s)')) % theme, + translate('OpenLP.ThemeManager', 'Save Theme - (%s)') % theme, SettingsManager.get_last_dir(self.settingsSection, 1)) path = unicode(path) Receiver.send_message(u'cursor_busy') @@ -416,8 +413,8 @@ class ThemeManager(QtGui.QWidget): files = QtGui.QFileDialog.getOpenFileNames(self, translate('OpenLP.ThemeManager', 'Select Theme Import File'), SettingsManager.get_last_dir(self.settingsSection), - unicode(translate('OpenLP.ThemeManager', - 'OpenLP Themes (*.theme *.otz)'))) + translate('OpenLP.ThemeManager', + 'OpenLP Themes (*.theme *.otz)')) log.info(u'New Themes %s', unicode(files)) if not files: return @@ -461,8 +458,8 @@ class ThemeManager(QtGui.QWidget): if os.path.exists(theme): text_name = os.path.splitext(name)[0] if text_name == self.global_theme: - name = unicode(translate('OpenLP.ThemeManager', - '%s (default)')) % text_name + name = translate( + 'OpenLP.ThemeManager', '%s (default)') % text_name else: name = text_name thumb = os.path.join(self.thumb_path, u'%s.png' % text_name) @@ -768,7 +765,7 @@ class ThemeManager(QtGui.QWidget): self.settingsSection + u'/global theme', u'') if check_item_selected(self.themeListWidget, select_text): item = self.themeListWidget.currentItem() - theme = unicode(item.text()) + theme = item.text() # confirm deletion if confirm: answer = QtGui.QMessageBox.question(self, confirm_title, @@ -778,7 +775,7 @@ class ThemeManager(QtGui.QWidget): if answer == QtGui.QMessageBox.No: return False # should be the same unless default - if theme != unicode(item.data(QtCore.Qt.UserRole).toString()): + if theme != item.data(QtCore.Qt.UserRole).toString(): critical_error_message_box( message=translate('OpenLP.ThemeManager', 'You are unable to delete the default theme.')) @@ -790,8 +787,8 @@ class ThemeManager(QtGui.QWidget): critical_error_message_box( translate('OpenLP.ThemeManager', 'Validation Error'), - unicode(translate('OpenLP.ThemeManager', - 'Theme %s is used in the %s plugin.')) % \ + translate('OpenLP.ThemeManager', + 'Theme %s is used in the %s plugin.') % \ (theme, plugin.name)) return False return True diff --git a/openlp/core/ui/themestab.py b/openlp/core/ui/themestab.py index d078cfdac..7eba9ec46 100644 --- a/openlp/core/ui/themestab.py +++ b/openlp/core/ui/themestab.py @@ -168,7 +168,7 @@ class ThemesTab(SettingsTab): self.theme_level = ThemeLevel.Global def onDefaultComboBoxChanged(self, value): - self.global_theme = unicode(self.DefaultComboBox.currentText()) + self.global_theme = self.DefaultComboBox.currentText() self.mainwindow.renderer.set_global_theme( self.global_theme, self.theme_level) self.__previewGlobalTheme() diff --git a/openlp/core/ui/wizard.py b/openlp/core/ui/wizard.py index 500d958fd..d54ed077c 100644 --- a/openlp/core/ui/wizard.py +++ b/openlp/core/ui/wizard.py @@ -63,20 +63,20 @@ class WizardStrings(object): FormatLabel = translate('OpenLP.Ui', 'Format:') HeaderStyle = u'%s' Importing = translate('OpenLP.Ui', 'Importing') - ImportingType = unicode(translate('OpenLP.Ui', 'Importing "%s"...')) + ImportingType = translate('OpenLP.Ui', 'Importing "%s"...') ImportSelect = translate('OpenLP.Ui', 'Select Import Source') - ImportSelectLong = unicode(translate('OpenLP.Ui', - 'Select the import format and the location to import from.')) + ImportSelectLong = translate('OpenLP.Ui', + 'Select the import format and the location to import from.') NoSqlite = translate('OpenLP.Ui', 'The openlp.org 1.x importer has been ' 'disabled due to a missing Python module. If you want to use this ' 'importer, you will need to install the "python-sqlite" ' 'module.') - OpenTypeFile = unicode(translate('OpenLP.Ui', 'Open %s File')) - PercentSymbolFormat = unicode(translate('OpenLP.Ui', '%p%')) + OpenTypeFile = translate('OpenLP.Ui', 'Open %s File') + PercentSymbolFormat = translate('OpenLP.Ui', '%p%') Ready = translate('OpenLP.Ui', 'Ready.') StartingImport = translate('OpenLP.Ui', 'Starting import...') - YouSpecifyFile = unicode(translate('OpenLP.Ui', 'You need to specify at ' - 'least one %s file to import from.', 'A file type e.g. OpenSong')) + YouSpecifyFile = translate('OpenLP.Ui', 'You need to specify at ' + 'least one %s file to import from.', 'A file type e.g. OpenSong') class OpenLPWizard(QtGui.QWizard): diff --git a/openlp/plugins/alerts/alertsplugin.py b/openlp/plugins/alerts/alertsplugin.py index 03078b5cb..787d903de 100644 --- a/openlp/plugins/alerts/alertsplugin.py +++ b/openlp/plugins/alerts/alertsplugin.py @@ -146,7 +146,7 @@ class AlertsPlugin(Plugin): Plugin.initialise(self) self.toolsAlertItem.setVisible(True) action_list = ActionList.get_instance() - action_list.add_action(self.toolsAlertItem, unicode(UiStrings().Tools)) + action_list.add_action(self.toolsAlertItem, UiStrings().Tools) def finalise(self): """ diff --git a/openlp/plugins/alerts/forms/alertform.py b/openlp/plugins/alerts/forms/alertform.py index d494d2a4d..8f86be7b1 100644 --- a/openlp/plugins/alerts/forms/alertform.py +++ b/openlp/plugins/alerts/forms/alertform.py @@ -81,10 +81,10 @@ class AlertForm(QtGui.QDialog, Ui_AlertDialog): self.alertListWidget.addItem(item_name) def onDisplayClicked(self): - self.triggerAlert(unicode(self.alertTextEdit.text())) + self.triggerAlert(self.alertTextEdit.text()) def onDisplayCloseClicked(self): - if self.triggerAlert(unicode(self.alertTextEdit.text())): + if self.triggerAlert(self.alertTextEdit.text()): self.close() def onDeleteButtonClicked(self): @@ -109,7 +109,7 @@ class AlertForm(QtGui.QDialog, Ui_AlertDialog): 'clicking New.')) else: alert = AlertItem() - alert.text = unicode(self.alertTextEdit.text()) + alert.text = self.alertTextEdit.text() self.manager.save_object(alert) self.alertTextEdit.setText(u'') self.loadList() @@ -120,14 +120,14 @@ class AlertForm(QtGui.QDialog, Ui_AlertDialog): """ if self.item_id: alert = self.manager.get_object(AlertItem, self.item_id) - alert.text = unicode(self.alertTextEdit.text()) + alert.text = self.alertTextEdit.text() self.manager.save_object(alert) self.item_id = None self.loadList() def onTextChanged(self): """ - Enable save button when data has been changed by editing the form + Enable save button when data has been changed by editing the form. """ # Only enable the button, if we are editing an item. if self.item_id: @@ -141,26 +141,26 @@ class AlertForm(QtGui.QDialog, Ui_AlertDialog): def onDoubleClick(self): """ - List item has been double clicked to display it + List item has been double clicked to display it. """ item = self.alertListWidget.selectedIndexes()[0] bitem = self.alertListWidget.item(item.row()) - self.triggerAlert(unicode(bitem.text())) - self.alertTextEdit.setText(unicode(bitem.text())) + self.triggerAlert(bitem.text()) + self.alertTextEdit.setText(bitem.text()) self.item_id = (bitem.data(QtCore.Qt.UserRole)).toInt()[0] self.saveButton.setEnabled(False) def onSingleClick(self): """ - List item has been single clicked to add it to - the edit field so it can be changed. + List item has been single clicked to add it to the edit field so it can + be changed. """ item = self.alertListWidget.selectedIndexes()[0] bitem = self.alertListWidget.item(item.row()) - self.alertTextEdit.setText(unicode(bitem.text())) + self.alertTextEdit.setText(bitem.text()) self.item_id = (bitem.data(QtCore.Qt.UserRole)).toInt()[0] # If the alert does not contain '<>' we clear the ParameterEdit field. - if unicode(self.alertTextEdit.text()).find(u'<>') == -1: + if self.alertTextEdit.text().find(u'<>') == -1: self.parameterEdit.setText(u'') self.saveButton.setEnabled(False) @@ -194,7 +194,7 @@ class AlertForm(QtGui.QDialog, Ui_AlertDialog): QtGui.QMessageBox.Yes)) == QtGui.QMessageBox.No: self.parameterEdit.setFocus() return False - text = text.replace(u'<>', unicode(self.parameterEdit.text())) + text = text.replace(u'<>', self.parameterEdit.text()) self.plugin.alertsmanager.displayAlert(text) return True diff --git a/openlp/plugins/bibles/bibleplugin.py b/openlp/plugins/bibles/bibleplugin.py index 193960102..5729efcb3 100644 --- a/openlp/plugins/bibles/bibleplugin.py +++ b/openlp/plugins/bibles/bibleplugin.py @@ -56,11 +56,9 @@ class BiblePlugin(Plugin): Plugin.initialise(self) self.importBibleItem.setVisible(True) action_list = ActionList.get_instance() - action_list.add_action(self.importBibleItem, - unicode(UiStrings().Import)) + action_list.add_action(self.importBibleItem, UiStrings().Import) # Do not add the action to the list yet. - #action_list.add_action(self.exportBibleItem, - # unicode(UiStrings().Export)) + #action_list.add_action(self.exportBibleItem, UiStrings().Export) # Set to invisible until we can export bibles self.exportBibleItem.setVisible(False) if self.manager.old_bible_databases: @@ -74,8 +72,7 @@ class BiblePlugin(Plugin): self.manager.finalise() Plugin.finalise(self) action_list = ActionList.get_instance() - action_list.remove_action(self.importBibleItem, - unicode(UiStrings().Import)) + action_list.remove_action(self.importBibleItem, UiStrings().Import) self.importBibleItem.setVisible(False) #action_list.remove_action(self.exportBibleItem, UiStrings().Export) self.exportBibleItem.setVisible(False) diff --git a/openlp/plugins/bibles/forms/bibleimportform.py b/openlp/plugins/bibles/forms/bibleimportform.py index 299c7430a..736cde23b 100644 --- a/openlp/plugins/bibles/forms/bibleimportform.py +++ b/openlp/plugins/bibles/forms/bibleimportform.py @@ -473,9 +473,8 @@ class BibleImportForm(OpenLPWizard): return False return True elif self.currentPage() == self.licenseDetailsPage: - license_version = unicode(self.field(u'license_version').toString()) - license_copyright = \ - unicode(self.field(u'license_copyright').toString()) + license_version = self.field(u'license_version').toString() + license_copyright = self.field(u'license_copyright').toString() path = AppLocation.get_section_data_path(u'bibles') if not license_version: critical_error_message_box(UiStrings().EmptyField, @@ -658,50 +657,48 @@ class BibleImportForm(OpenLPWizard): Perform the actual import. """ bible_type = self.field(u'source_format').toInt()[0] - license_version = unicode(self.field(u'license_version').toString()) - license_copyright = unicode(self.field(u'license_copyright').toString()) - license_permissions = \ - unicode(self.field(u'license_permissions').toString()) + license_version = self.field(u'license_version').toString() + license_copyright = self.field(u'license_copyright').toString() + license_permissions = self.field(u'license_permissions').toString() importer = None if bible_type == BibleFormat.OSIS: # Import an OSIS bible. importer = self.manager.import_bible(BibleFormat.OSIS, name=license_version, - filename=unicode(self.field(u'osis_location').toString()) + filename=self.field(u'osis_location').toString() ) elif bible_type == BibleFormat.CSV: # Import a CSV bible. importer = self.manager.import_bible(BibleFormat.CSV, name=license_version, - booksfile=unicode(self.field(u'csv_booksfile').toString()), - versefile=unicode(self.field(u'csv_versefile').toString()) + booksfile=self.field(u'csv_booksfile').toString(), + versefile=self.field(u'csv_versefile').toString() ) elif bible_type == BibleFormat.OpenSong: # Import an OpenSong bible. importer = self.manager.import_bible(BibleFormat.OpenSong, name=license_version, - filename=unicode(self.field(u'opensong_file').toString()) + filename=self.field(u'opensong_file').toString() ) elif bible_type == BibleFormat.WebDownload: # Import a bible from the web. self.progressBar.setMaximum(1) download_location = self.field(u'web_location').toInt()[0] - bible_version = unicode(self.webTranslationComboBox.currentText()) + bible_version = self.webTranslationComboBox.currentText() bible = self.web_bible_list[download_location][bible_version] importer = self.manager.import_bible( BibleFormat.WebDownload, name=license_version, download_source=WebDownload.Names[download_location], download_name=bible, - proxy_server=unicode(self.field(u'proxy_server').toString()), - proxy_username=\ - unicode(self.field(u'proxy_username').toString()), - proxy_password=unicode(self.field(u'proxy_password').toString()) + proxy_server=self.field(u'proxy_server').toString(), + proxy_username=self.field(u'proxy_username').toString(), + proxy_password=self.field(u'proxy_password').toString() ) elif bible_type == BibleFormat.OpenLP1: # Import an openlp.org 1.x bible. importer = self.manager.import_bible(BibleFormat.OpenLP1, name=license_version, - filename=unicode(self.field(u'openlp1_location').toString()) + filename=self.field(u'openlp1_location').toString() ) if importer.do_import(license_version): self.manager.save_meta_data(license_version, license_version, diff --git a/openlp/plugins/bibles/forms/bibleupgradeform.py b/openlp/plugins/bibles/forms/bibleupgradeform.py index fddefec36..c87a7ead0 100644 --- a/openlp/plugins/bibles/forms/bibleupgradeform.py +++ b/openlp/plugins/bibles/forms/bibleupgradeform.py @@ -304,7 +304,7 @@ class BibleUpgradeForm(OpenLPWizard): return True elif self.currentPage() == self.backupPage: if not self.noBackupCheckBox.checkState() == QtCore.Qt.Checked: - backup_path = unicode(self.backupDirectoryEdit.text()) + backup_path = self.backupDirectoryEdit.text() if not backup_path: critical_error_message_box(UiStrings().EmptyField, translate('BiblesPlugin.UpgradeWizardForm', @@ -401,9 +401,9 @@ class BibleUpgradeForm(OpenLPWizard): old_bible = OldBibleDB(self.mediaItem, path=self.temp_dir, file=filename[0]) name = filename[1] - self.progressLabel.setText(unicode(translate( + self.progressLabel.setText(translate( 'BiblesPlugin.UpgradeWizardForm', - 'Upgrading Bible %s of %s: "%s"\nUpgrading ...')) % + 'Upgrading Bible %s of %s: "%s"\nUpgrading ...') % (number + 1, max_bibles, name)) self.newbibles[number] = BibleDB(self.mediaItem, path=self.path, name=name, file=filename[0]) @@ -448,9 +448,9 @@ class BibleUpgradeForm(OpenLPWizard): translate('BiblesPlugin.UpgradeWizardForm', 'To upgrade your Web Bibles an Internet connection is ' 'required.')) - self.incrementProgressBar(unicode(translate( + self.incrementProgressBar(translate( 'BiblesPlugin.UpgradeWizardForm', - 'Upgrading Bible %s of %s: "%s"\nFailed')) % + 'Upgrading Bible %s of %s: "%s"\nFailed') % (number + 1, max_bibles, name), self.progressBar.maximum() - self.progressBar.value()) self.success[number] = False @@ -468,9 +468,9 @@ class BibleUpgradeForm(OpenLPWizard): log.warn(u'Upgrading from "%s" failed' % filename[0]) self.newbibles[number].session.close() del self.newbibles[number] - self.incrementProgressBar(unicode(translate( + self.incrementProgressBar(translate( 'BiblesPlugin.UpgradeWizardForm', - 'Upgrading Bible %s of %s: "%s"\nFailed')) % + 'Upgrading Bible %s of %s: "%s"\nFailed') % (number + 1, max_bibles, name), self.progressBar.maximum() - self.progressBar.value()) self.success[number] = False @@ -480,10 +480,10 @@ class BibleUpgradeForm(OpenLPWizard): if self.stop_import_flag: self.success[number] = False break - self.incrementProgressBar(unicode(translate( + self.incrementProgressBar(translate( 'BiblesPlugin.UpgradeWizardForm', 'Upgrading Bible %s of %s: "%s"\n' - 'Upgrading %s ...')) % + 'Upgrading %s ...') % (number + 1, max_bibles, name, book)) book_ref_id = self.newbibles[number].\ get_book_ref_id_by_name(book, len(books), language_id) @@ -525,9 +525,9 @@ class BibleUpgradeForm(OpenLPWizard): log.warn(u'Upgrading books from "%s" failed' % name) self.newbibles[number].session.close() del self.newbibles[number] - self.incrementProgressBar(unicode(translate( + self.incrementProgressBar(translate( 'BiblesPlugin.UpgradeWizardForm', - 'Upgrading Bible %s of %s: "%s"\nFailed')) % + 'Upgrading Bible %s of %s: "%s"\nFailed') % (number + 1, max_bibles, name), self.progressBar.maximum() - self.progressBar.value()) self.success[number] = False @@ -538,10 +538,10 @@ class BibleUpgradeForm(OpenLPWizard): if self.stop_import_flag: self.success[number] = False break - self.incrementProgressBar(unicode(translate( + self.incrementProgressBar(translate( 'BiblesPlugin.UpgradeWizardForm', 'Upgrading Bible %s of %s: "%s"\n' - 'Upgrading %s ...')) % + 'Upgrading %s ...') % (number + 1, max_bibles, name, book[u'name'])) book_ref_id = self.newbibles[number].\ get_book_ref_id_by_name(book[u'name'], len(books), @@ -572,18 +572,18 @@ class BibleUpgradeForm(OpenLPWizard): Receiver.send_message(u'openlp_process_events') self.newbibles[number].session.commit() if not self.success.get(number, True): - self.incrementProgressBar(unicode(translate( + self.incrementProgressBar(translate( 'BiblesPlugin.UpgradeWizardForm', - 'Upgrading Bible %s of %s: "%s"\nFailed')) % + 'Upgrading Bible %s of %s: "%s"\nFailed') % (number + 1, max_bibles, name), self.progressBar.maximum() - self.progressBar.value()) else: self.success[number] = True self.newbibles[number].save_meta(u'name', name) - self.incrementProgressBar(unicode(translate( + self.incrementProgressBar(translate( 'BiblesPlugin.UpgradeWizardForm', 'Upgrading Bible %s of %s: "%s"\n' - 'Complete')) % + 'Complete') % (number + 1, max_bibles, name)) if number in self.newbibles: self.newbibles[number].session.close() @@ -607,23 +607,22 @@ class BibleUpgradeForm(OpenLPWizard): # Copy not upgraded bible back. shutil.move(os.path.join(self.temp_dir, filename[0]), self.path) if failed_import > 0: - failed_import_text = unicode(translate( - 'BiblesPlugin.UpgradeWizardForm', - ', %s failed')) % failed_import + failed_import_text = translate('BiblesPlugin.UpgradeWizardForm', + ', %s failed') % failed_import else: failed_import_text = u'' if successful_import > 0: if self.includeWebBible: - self.progressLabel.setText(unicode( + self.progressLabel.setText( translate('BiblesPlugin.UpgradeWizardForm', 'Upgrading ' 'Bible(s): %s successful%s\nPlease note that verses from ' 'Web Bibles will be downloaded on demand and so an ' - 'Internet connection is required.')) % + 'Internet connection is required.') % (successful_import, failed_import_text)) else: - self.progressLabel.setText(unicode( + self.progressLabel.setText( translate('BiblesPlugin.UpgradeWizardForm', 'Upgrading ' - 'Bible(s): %s successful%s')) % (successful_import, + 'Bible(s): %s successful%s') % (successful_import, failed_import_text)) else: self.progressLabel.setText(translate( diff --git a/openlp/plugins/bibles/forms/booknameform.py b/openlp/plugins/bibles/forms/booknameform.py index 493dc9c1d..690d77d48 100644 --- a/openlp/plugins/bibles/forms/booknameform.py +++ b/openlp/plugins/bibles/forms/booknameform.py @@ -125,7 +125,7 @@ class BookNameForm(QDialog, Ui_BookNameDialog): self.correspondingComboBox.setFocus() return False else: - cor_book = unicode(self.correspondingComboBox.currentText()) + cor_book = self.correspondingComboBox.currentText() for character in u'\\.^$*+?{}[]()': cor_book = cor_book.replace(character, u'\\' + character) books = filter(lambda key: diff --git a/openlp/plugins/bibles/forms/editbibleform.py b/openlp/plugins/bibles/forms/editbibleform.py index 87ad86200..2c828ac23 100644 --- a/openlp/plugins/bibles/forms/editbibleform.py +++ b/openlp/plugins/bibles/forms/editbibleform.py @@ -116,9 +116,9 @@ class EditBibleForm(QtGui.QDialog, Ui_EditBibleDialog): Exit Dialog and save data """ log.debug(u'BibleEditForm.accept') - version = unicode(self.versionNameEdit.text()) - copyright = unicode(self.copyrightEdit.text()) - permissions = unicode(self.permissionsEdit.text()) + version = self.versionNameEdit.text() + copyright = self.copyrightEdit.text() + permissions = self.permissionsEdit.text() book_name_language = self.languageSelectionComboBox.currentIndex() - 1 if book_name_language == -1: book_name_language = None @@ -128,7 +128,7 @@ class EditBibleForm(QtGui.QDialog, Ui_EditBibleDialog): custom_names = {} for abbr, book in self.books.iteritems(): if book: - custom_names[abbr] = unicode(self.bookNameEdit[abbr].text()) + custom_names[abbr] = self.bookNameEdit[abbr].text() if book.name != custom_names[abbr]: if not self.validateBook(custom_names[abbr], abbr): return @@ -183,29 +183,29 @@ class EditBibleForm(QtGui.QDialog, Ui_EditBibleDialog): if not new_book_name: self.bookNameEdit[abbreviation].setFocus() critical_error_message_box(UiStrings().EmptyField, - unicode(translate('BiblesPlugin.BibleEditForm', - 'You need to specify a book name for "%s".')) % + translate('BiblesPlugin.BibleEditForm', + 'You need to specify a book name for "%s".') % self.book_names[abbreviation]) return False elif not book_regex.match(new_book_name): self.bookNameEdit[abbreviation].setFocus() critical_error_message_box(UiStrings().EmptyField, - unicode(translate('BiblesPlugin.BibleEditForm', + translate('BiblesPlugin.BibleEditForm', 'The book name "%s" is not correct.\nNumbers can only be used ' 'at the beginning and must\nbe followed by one or more ' - 'non-numeric characters.')) % new_book_name) + 'non-numeric characters.') % new_book_name) return False for abbr, book in self.books.iteritems(): if book: if abbr == abbreviation: continue - if unicode(self.bookNameEdit[abbr].text()) == new_book_name: + if self.bookNameEdit[abbr].text() == new_book_name: self.bookNameEdit[abbreviation].setFocus() critical_error_message_box( translate('BiblesPlugin.BibleEditForm', 'Duplicate Book Name'), - unicode(translate('BiblesPlugin.BibleEditForm', - 'The Book Name "%s" has been entered more than once.')) + translate('BiblesPlugin.BibleEditForm', + 'The Book Name "%s" has been entered more than once.') % new_book_name) return False return True diff --git a/openlp/plugins/bibles/lib/__init__.py b/openlp/plugins/bibles/lib/__init__.py index 3543c10a5..1148294c6 100644 --- a/openlp/plugins/bibles/lib/__init__.py +++ b/openlp/plugins/bibles/lib/__init__.py @@ -181,10 +181,10 @@ def update_reference_separators(): Updates separators and matches for parsing and formating scripture references. """ - default_separators = unicode(translate('BiblesPlugin', + default_separators = translate('BiblesPlugin', ':|v|V|verse|verses;;-|to;;,|and;;end', 'Double-semicolon delimited separators for parsing references. ' - 'Consult the developers for further information.')).split(u';;') + 'Consult the developers for further information.').split(u';;') settings = Settings() settings.beginGroup(u'bibles') custom_separators = [ diff --git a/openlp/plugins/bibles/lib/csvbible.py b/openlp/plugins/bibles/lib/csvbible.py index cd4b921a1..99bd5d6a5 100644 --- a/openlp/plugins/bibles/lib/csvbible.py +++ b/openlp/plugins/bibles/lib/csvbible.py @@ -107,9 +107,9 @@ class CSVBible(BibleDB): for line in books_reader: if self.stop_import_flag: break - self.wizard.incrementProgressBar(unicode( + self.wizard.incrementProgressBar( translate('BiblesPlugin.CSVBible', - 'Importing books... %s')) % + 'Importing books... %s') % unicode(line[2], details['encoding'])) book_ref_id = self.get_book_ref_id_by_name( unicode(line[2], details['encoding']), 67, language_id) @@ -151,9 +151,9 @@ class CSVBible(BibleDB): if book_ptr != line_book: book = self.get_book(line_book) book_ptr = book.name - self.wizard.incrementProgressBar(unicode(translate( + self.wizard.incrementProgressBar(translate( 'BiblesPlugin.CSVBible', 'Importing verses from %s...', - 'Importing verses from ...')) % book.name) + 'Importing verses from ...') % book.name) self.session.commit() try: verse_text = unicode(line[3], details['encoding']) diff --git a/openlp/plugins/bibles/lib/http.py b/openlp/plugins/bibles/lib/http.py index fb79b26e1..deb531bf8 100644 --- a/openlp/plugins/bibles/lib/http.py +++ b/openlp/plugins/bibles/lib/http.py @@ -398,9 +398,9 @@ class HTTPBible(BibleDB): ``True`` on success, ``False`` on failure. """ self.wizard.progressBar.setMaximum(68) - self.wizard.incrementProgressBar(unicode(translate( + self.wizard.incrementProgressBar(translate( 'BiblesPlugin.HTTPBible', - 'Registering Bible and loading books...'))) + 'Registering Bible and loading books...')) self.save_meta(u'download_source', self.download_source) self.save_meta(u'download_name', self.download_name) if self.proxy_server: @@ -423,8 +423,8 @@ class HTTPBible(BibleDB): 'failed' % (self.download_source, self.download_name)) return False self.wizard.progressBar.setMaximum(len(books)+2) - self.wizard.incrementProgressBar(unicode(translate( - 'BiblesPlugin.HTTPBible', 'Registering Language...'))) + self.wizard.incrementProgressBar(translate( + 'BiblesPlugin.HTTPBible', 'Registering Language...')) bible = BiblesResourcesDB.get_webbible(self.download_name, self.download_source.lower()) if bible[u'language_id']: @@ -439,9 +439,9 @@ class HTTPBible(BibleDB): for book in books: if self.stop_import_flag: break - self.wizard.incrementProgressBar(unicode(translate( + self.wizard.incrementProgressBar(translate( 'BiblesPlugin.HTTPBible', 'Importing %s...', - 'Importing ...')) % book) + 'Importing ...') % book) book_ref_id = self.get_book_ref_id_by_name(book, len(books), language_id) if not book_ref_id: diff --git a/openlp/plugins/bibles/lib/manager.py b/openlp/plugins/bibles/lib/manager.py index c2091895a..1008c5570 100644 --- a/openlp/plugins/bibles/lib/manager.py +++ b/openlp/plugins/bibles/lib/manager.py @@ -348,7 +348,7 @@ class BibleManager(object): Receiver.send_message(u'openlp_information_message', { u'title': translate('BiblesPlugin.BibleManager', 'Scripture Reference Error'), - u'message': unicode(translate('BiblesPlugin.BibleManager', + u'message': translate('BiblesPlugin.BibleManager', 'Your scripture reference is either not supported by ' 'OpenLP or is invalid. Please make sure your reference ' 'conforms to one of the following patterns or consult the ' @@ -363,7 +363,7 @@ class BibleManager(object): 'Book Chapter%(verse)sVerse%(range)sChapter%(verse)sVerse', 'Please pay attention to the appended "s" of the wildcards ' 'and refrain from translating the words inside the ' - 'names in the brackets.')) % reference_seperators + 'names in the brackets.') % reference_seperators }) return None diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index 2778ee42b..4faa1bc37 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -422,7 +422,7 @@ class BibleMediaItem(MediaManagerItem): """ log.debug(u'initialiseAdvancedBible %s, %s', bible, last_book_id) book_data = self.plugin.manager.get_books(bible) - secondbible = unicode(self.advancedSecondComboBox.currentText()) + secondbible = self.advancedSecondComboBox.currentText() if secondbible != u'': secondbook_data = self.plugin.manager.get_books(secondbible) book_data_temp = [] @@ -504,10 +504,10 @@ class BibleMediaItem(MediaManagerItem): # We have to do a 'Reference Search'. if self.quickSearchEdit.currentSearchType() == BibleSearch.Reference: bibles = self.plugin.manager.get_bibles() - bible = unicode(self.quickVersionComboBox.currentText()) + bible = self.quickVersionComboBox.currentText() if bible: book_data = bibles[bible].get_books() - secondbible = unicode(self.quickSecondComboBox.currentText()) + secondbible = self.quickSecondComboBox.currentText() if secondbible != u'': secondbook_data = bibles[secondbible].get_books() book_data_temp = [] @@ -546,9 +546,9 @@ class BibleMediaItem(MediaManagerItem): def onEditClick(self): if self.quickTab.isVisible(): - bible = unicode(self.quickVersionComboBox.currentText()) + bible = self.quickVersionComboBox.currentText() elif self.advancedTab.isVisible(): - bible = unicode(self.advancedVersionComboBox.currentText()) + bible = self.advancedVersionComboBox.currentText() if bible: self.editBibleForm = EditBibleForm(self, self.plugin.formParent, self.plugin.manager) @@ -558,13 +558,13 @@ class BibleMediaItem(MediaManagerItem): def onDeleteClick(self): if self.quickTab.isVisible(): - bible = unicode(self.quickVersionComboBox.currentText()) + bible = self.quickVersionComboBox.currentText() elif self.advancedTab.isVisible(): - bible = unicode(self.advancedVersionComboBox.currentText()) + bible = self.advancedVersionComboBox.currentText() if bible: if QtGui.QMessageBox.question(self, UiStrings().ConfirmDelete, - unicode(translate('BiblesPlugin.MediaItem', - 'Are you sure you want to delete "%s"?')) % bible, + translate('BiblesPlugin.MediaItem', + 'Are you sure you want to delete "%s"?') % bible, QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes | QtGui.QMessageBox.No), QtGui.QMessageBox.Yes) == QtGui.QMessageBox.No: @@ -609,31 +609,30 @@ class BibleMediaItem(MediaManagerItem): def onAdvancedVersionComboBox(self): Settings().setValue(self.settingsSection + u'/advanced bible', self.advancedVersionComboBox.currentText()) - self.initialiseAdvancedBible( - unicode(self.advancedVersionComboBox.currentText()), + self.initialiseAdvancedBible(self.advancedVersionComboBox.currentText(), self.advancedBookComboBox.itemData( int(self.advancedBookComboBox.currentIndex()))) def onAdvancedSecondComboBox(self): self.initialiseAdvancedBible( - unicode(self.advancedVersionComboBox.currentText()), + self.advancedVersionComboBox.currentText(), self.advancedBookComboBox.itemData( int(self.advancedBookComboBox.currentIndex()))) def onAdvancedBookComboBox(self): item = int(self.advancedBookComboBox.currentIndex()) self.initialiseChapterVerse( - unicode(self.advancedVersionComboBox.currentText()), - unicode(self.advancedBookComboBox.currentText()), - unicode(self.advancedBookComboBox.itemData(item).toString())) + self.advancedVersionComboBox.currentText(), + self.advancedBookComboBox.currentText(), + self.advancedBookComboBox.itemData(item).toString()) def onAdvancedFromVerse(self): chapter_from = int(self.advancedFromChapter.currentText()) chapter_to = int(self.advancedToChapter.currentText()) if chapter_from == chapter_to: - bible = unicode(self.advancedVersionComboBox.currentText()) - book_ref_id = unicode(self.advancedBookComboBox.itemData( - int(self.advancedBookComboBox.currentIndex())).toString()) + bible = self.advancedVersionComboBox.currentText() + book_ref_id = self.advancedBookComboBox.itemData( + int(self.advancedBookComboBox.currentIndex())).toString() verse_from = int(self.advancedFromVerse.currentText()) verse_count = self.plugin.manager.get_verse_count_by_book_ref_id( bible, book_ref_id, chapter_to) @@ -641,9 +640,9 @@ class BibleMediaItem(MediaManagerItem): self.advancedToVerse, True) def onAdvancedToChapter(self): - bible = unicode(self.advancedVersionComboBox.currentText()) - book_ref_id = unicode(self.advancedBookComboBox.itemData( - int(self.advancedBookComboBox.currentIndex())).toString()) + bible = self.advancedVersionComboBox.currentText() + book_ref_id = self.advancedBookComboBox.itemData( + int(self.advancedBookComboBox.currentIndex())).toString() chapter_from = int(self.advancedFromChapter.currentText()) chapter_to = int(self.advancedToChapter.currentText()) verse_from = int(self.advancedFromVerse.currentText()) @@ -656,9 +655,9 @@ class BibleMediaItem(MediaManagerItem): self.adjustComboBox(1, verse_count, self.advancedToVerse) def onAdvancedFromChapter(self): - bible = unicode(self.advancedVersionComboBox.currentText()) - book_ref_id = unicode(self.advancedBookComboBox.itemData( - int(self.advancedBookComboBox.currentIndex())).toString()) + bible = self.advancedVersionComboBox.currentText() + book_ref_id = self.advancedBookComboBox.itemData( + int(self.advancedBookComboBox.currentIndex())).toString() chapter_from = int(self.advancedFromChapter.currentText()) chapter_to = int(self.advancedToChapter.currentText()) verse_count = self.plugin.manager.get_verse_count_by_book_ref_id(bible, @@ -695,7 +694,7 @@ class BibleMediaItem(MediaManagerItem): """ log.debug(u'adjustComboBox %s, %s, %s', combo, range_from, range_to) if restore: - old_text = unicode(combo.currentText()) + old_text = combo.currentText() combo.clear() combo.addItems(map(unicode, range(range_from, range_to + 1))) if restore and combo.findText(old_text) != -1: @@ -708,11 +707,11 @@ class BibleMediaItem(MediaManagerItem): log.debug(u'Advanced Search Button clicked') self.advancedSearchButton.setEnabled(False) Receiver.send_message(u'openlp_process_events') - bible = unicode(self.advancedVersionComboBox.currentText()) - second_bible = unicode(self.advancedSecondComboBox.currentText()) - book = unicode(self.advancedBookComboBox.currentText()) - book_ref_id = unicode(self.advancedBookComboBox.itemData( - int(self.advancedBookComboBox.currentIndex())).toString()) + bible = self.advancedVersionComboBox.currentText() + second_bible = self.advancedSecondComboBox.currentText() + book = self.advancedBookComboBox.currentText() + book_ref_id = self.advancedBookComboBox.itemData( + int(self.advancedBookComboBox.currentIndex())).toString() chapter_from = self.advancedFromChapter.currentText() chapter_to = self.advancedToChapter.currentText() verse_from = self.advancedFromVerse.currentText() @@ -747,9 +746,9 @@ class BibleMediaItem(MediaManagerItem): log.debug(u'Quick Search Button clicked') self.quickSearchButton.setEnabled(False) Receiver.send_message(u'openlp_process_events') - bible = unicode(self.quickVersionComboBox.currentText()) - second_bible = unicode(self.quickSecondComboBox.currentText()) - text = unicode(self.quickSearchEdit.text()) + bible = self.quickVersionComboBox.currentText() + second_bible = self.quickSecondComboBox.currentText() + text = self.quickSearchEdit.text() if self.quickSearchEdit.currentSearchType() == BibleSearch.Reference: # We are doing a 'Reference Search'. self.search_results = self.plugin.manager.get_verses(bible, text) @@ -784,11 +783,11 @@ class BibleMediaItem(MediaManagerItem): if passage_not_found: QtGui.QMessageBox.information(self, translate('BiblesPlugin.MediaItem', 'Information'), - unicode(translate('BiblesPlugin.MediaItem', + translate('BiblesPlugin.MediaItem', 'The second Bible does not contain all the verses ' 'that are in the main Bible. Only verses found in both ' 'Bibles will be shown. %d verses have not been ' - 'included in the results.')) % count, + 'included in the results.') % count, QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok)) self.search_results = new_search_results self.second_search_results = \ @@ -1083,7 +1082,7 @@ class BibleMediaItem(MediaManagerItem): """ Search for some Bible verses (by reference). """ - bible = unicode(self.quickVersionComboBox.currentText()) + bible = self.quickVersionComboBox.currentText() search_results = self.plugin.manager.get_verses(bible, string, False, showError) if search_results: @@ -1093,7 +1092,7 @@ class BibleMediaItem(MediaManagerItem): def createItemFromId(self, item_id): item = QtGui.QListWidgetItem() - bible = unicode(self.quickVersionComboBox.currentText()) + bible = self.quickVersionComboBox.currentText() search_results = self.plugin.manager.get_verses(bible, item_id, False) items = self.buildDisplayResults(bible, u'', search_results) return items diff --git a/openlp/plugins/bibles/lib/opensong.py b/openlp/plugins/bibles/lib/opensong.py index 856e9057e..180e6032f 100644 --- a/openlp/plugins/bibles/lib/opensong.py +++ b/openlp/plugins/bibles/lib/opensong.py @@ -90,9 +90,9 @@ class OpenSongBible(BibleDB): int(chapter.attrib[u'n'].split()[-1]), int(verse.attrib[u'n']), unicode(verse.text)) - self.wizard.incrementProgressBar(unicode(translate( + self.wizard.incrementProgressBar(translate( 'BiblesPlugin.Opensong', 'Importing %s %s...', - 'Importing ...')) % + 'Importing ...') % (db_book.name, int(chapter.attrib[u'n'].split()[-1]))) self.session.commit() Receiver.send_message(u'openlp_process_events') diff --git a/openlp/plugins/bibles/lib/osis.py b/openlp/plugins/bibles/lib/osis.py index 7300bd032..5a2fb53cd 100644 --- a/openlp/plugins/bibles/lib/osis.py +++ b/openlp/plugins/bibles/lib/osis.py @@ -101,7 +101,7 @@ class OSISBible(BibleDB): osis = codecs.open(self.filename, u'r', details['encoding']) repl = replacement language_id = False - # Decide if the bible propably contains only NT or AT and NT or + # Decide if the bible propably contains only NT or AT and NT or # AT, NT and Apocrypha if lines_in_file < 11500: book_count = 27 @@ -157,9 +157,9 @@ class OSISBible(BibleDB): if last_chapter != chapter: if last_chapter != 0: self.session.commit() - self.wizard.incrementProgressBar(unicode(translate( + self.wizard.incrementProgressBar(translate( 'BiblesPlugin.OsisImport', 'Importing %s %s...', - 'Importing ...')) % + 'Importing ...') % (book_details[u'name'], chapter)) last_chapter = chapter # All of this rigmarol below is because the mod2osis diff --git a/openlp/plugins/custom/forms/editcustomform.py b/openlp/plugins/custom/forms/editcustomform.py index afa96d237..4ef083c51 100644 --- a/openlp/plugins/custom/forms/editcustomform.py +++ b/openlp/plugins/custom/forms/editcustomform.py @@ -129,12 +129,12 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog): count = 1 for i in range(self.slideListView.count()): sxml.add_verse_to_lyrics(u'custom', unicode(count), - unicode(self.slideListView.item(i).text())) + self.slideListView.item(i).text()) count += 1 - self.customSlide.title = unicode(self.titleEdit.text()) + self.customSlide.title = self.titleEdit.text() self.customSlide.text = unicode(sxml.extract_xml(), u'utf-8') - self.customSlide.credits = unicode(self.creditEdit.text()) - self.customSlide.theme_name = unicode(self.themeComboBox.currentText()) + self.customSlide.credits = self.creditEdit.text() + self.customSlide.theme_name = self.themeComboBox.currentText() success = self.manager.save_object(self.customSlide) self.mediaitem.autoSelectId = self.customSlide.id return success diff --git a/openlp/plugins/custom/lib/mediaitem.py b/openlp/plugins/custom/lib/mediaitem.py index bea2858d8..338dd7201 100644 --- a/openlp/plugins/custom/lib/mediaitem.py +++ b/openlp/plugins/custom/lib/mediaitem.py @@ -229,7 +229,7 @@ class CustomMediaItem(MediaManagerItem): Settings().setValue(u'%s/last search type' % self.settingsSection, self.searchTextEdit.currentSearchType()) # Reload the list considering the new search type. - search_keywords = unicode(self.searchTextEdit.displayText()) + search_keywords = self.searchTextEdit.displayText() search_results = [] search_type = self.searchTextEdit.currentSearchType() if search_type == CustomSearch.Titles: diff --git a/openlp/plugins/images/lib/mediaitem.py b/openlp/plugins/images/lib/mediaitem.py index 56f8203e7..b318ed55d 100644 --- a/openlp/plugins/images/lib/mediaitem.py +++ b/openlp/plugins/images/lib/mediaitem.py @@ -110,8 +110,7 @@ class ImageMediaItem(MediaManagerItem): for row in row_list: text = self.listView.item(row) if text: - delete_file(os.path.join(self.servicePath, - unicode(text.text()))) + delete_file(os.path.join(self.servicePath, text.text())) self.listView.takeItem(row) self.plugin.formParent.incrementProgressBar() SettingsManager.set_list(self.settingsSection, @@ -169,7 +168,7 @@ class ImageMediaItem(MediaManagerItem): missing_items = [] missing_items_filenames = [] for bitem in items: - filename = unicode(bitem.data(QtCore.Qt.UserRole).toString()) + filename = bitem.data(QtCore.Qt.UserRole).toString() if not os.path.exists(filename): missing_items.append(bitem) missing_items_filenames.append(filename) @@ -180,22 +179,22 @@ class ImageMediaItem(MediaManagerItem): if not remote: critical_error_message_box( translate('ImagePlugin.MediaItem', 'Missing Image(s)'), - unicode(translate('ImagePlugin.MediaItem', - 'The following image(s) no longer exist: %s')) % + translate('ImagePlugin.MediaItem', + 'The following image(s) no longer exist: %s') % u'\n'.join(missing_items_filenames)) return False # We have missing as well as existing images. We ask what to do. elif missing_items and QtGui.QMessageBox.question(self, translate('ImagePlugin.MediaItem', 'Missing Image(s)'), - unicode(translate('ImagePlugin.MediaItem', 'The following ' + translate('ImagePlugin.MediaItem', 'The following ' 'image(s) no longer exist: %s\nDo you want to add the other ' - 'images anyway?')) % u'\n'.join(missing_items_filenames), + 'images anyway?') % u'\n'.join(missing_items_filenames), QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.No | QtGui.QMessageBox.Yes)) == QtGui.QMessageBox.No: return False # Continue with the existing images. for bitem in items: - filename = unicode(bitem.data(QtCore.Qt.UserRole).toString()) + filename = bitem.data(QtCore.Qt.UserRole).toString() name = os.path.split(filename)[1] service_item.add_from_image(filename, name, background) return True @@ -224,7 +223,7 @@ class ImageMediaItem(MediaManagerItem): self.settingsSection + u'/background color', u'#000000')) item = self.listView.selectedIndexes()[0] bitem = self.listView.item(item.row()) - filename = unicode(bitem.data(QtCore.Qt.UserRole).toString()) + filename = bitem.data(QtCore.Qt.UserRole).toString() if os.path.exists(filename): name = os.path.split(filename)[1] if self.plugin.liveController.display.directImage(name, @@ -236,9 +235,9 @@ class ImageMediaItem(MediaManagerItem): 'There was no display item to amend.')) else: critical_error_message_box(UiStrings().LiveBGError, - unicode(translate('ImagePlugin.MediaItem', + translate('ImagePlugin.MediaItem', 'There was a problem replacing your background, ' - 'the image file "%s" no longer exists.')) % filename) + 'the image file "%s" no longer exists.') % filename) def search(self, string, showError): files = SettingsManager.load_list(self.settingsSection, u'images') diff --git a/openlp/plugins/media/lib/mediaitem.py b/openlp/plugins/media/lib/mediaitem.py index efe045a02..15cd5e6aa 100644 --- a/openlp/plugins/media/lib/mediaitem.py +++ b/openlp/plugins/media/lib/mediaitem.py @@ -94,16 +94,15 @@ class MediaMediaItem(MediaManagerItem): def retranslateUi(self): self.onNewPrompt = translate('MediaPlugin.MediaItem', 'Select Media') - self.onNewFileMasks = unicode(translate('MediaPlugin.MediaItem', - 'Videos (%s);;Audio (%s);;%s (*)')) % ( + self.onNewFileMasks = translate('MediaPlugin.MediaItem', + 'Videos (%s);;Audio (%s);;%s (*)') % ( u' '.join(self.plugin.video_extensions_list), u' '.join(self.plugin.audio_extensions_list), UiStrings().AllFiles) self.replaceAction.setText(UiStrings().ReplaceBG) self.replaceAction.setToolTip(UiStrings().ReplaceLiveBG) self.resetAction.setText(UiStrings().ResetBG) self.resetAction.setToolTip(UiStrings().ResetLiveBG) - self.automatic = translate('MediaPlugin.MediaItem', - 'Automatic') + self.automatic = translate('MediaPlugin.MediaItem', 'Automatic') self.displayTypeLabel.setText( translate('MediaPlugin.MediaItem', 'Use Player:')) @@ -171,7 +170,7 @@ class MediaMediaItem(MediaManagerItem): translate('MediaPlugin.MediaItem', 'You must select a media file to replace the background with.')): item = self.listView.currentItem() - filename = unicode(item.data(QtCore.Qt.UserRole).toString()) + filename = item.data(QtCore.Qt.UserRole).toString() if os.path.exists(filename): if self.plugin.liveController.mediaController.video( \ self.plugin.liveController, filename, True, True): @@ -182,9 +181,9 @@ class MediaMediaItem(MediaManagerItem): 'There was no display item to amend.')) else: critical_error_message_box(UiStrings().LiveBGError, - unicode(translate('MediaPlugin.MediaItem', + translate('MediaPlugin.MediaItem', 'There was a problem replacing your background, ' - 'the media file "%s" no longer exists.')) % filename) + 'the media file "%s" no longer exists.') % filename) def generateSlideData(self, service_item, item=None, xmlVersion=False, remote=False): @@ -192,14 +191,14 @@ class MediaMediaItem(MediaManagerItem): item = self.listView.currentItem() if item is None: return False - filename = unicode(item.data(QtCore.Qt.UserRole).toString()) + filename = item.data(QtCore.Qt.UserRole).toString() if not os.path.exists(filename): if not remote: # File is no longer present critical_error_message_box( translate('MediaPlugin.MediaItem', 'Missing Media File'), - unicode(translate('MediaPlugin.MediaItem', - 'The file %s no longer exists.')) % filename) + translate('MediaPlugin.MediaItem', + 'The file %s no longer exists.') % filename) return False self.mediaLength = 0 if self.plugin.mediaController.video( \ @@ -234,8 +233,8 @@ class MediaMediaItem(MediaManagerItem): the settings """ self.populateDisplayTypes() - self.onNewFileMasks = unicode(translate('MediaPlugin.MediaItem', - 'Videos (%s);;Audio (%s);;%s (*)')) % ( + self.onNewFileMasks = translate('MediaPlugin.MediaItem', + 'Videos (%s);;Audio (%s);;%s (*)') % ( u' '.join(self.plugin.video_extensions_list), u' '.join(self.plugin.audio_extensions_list), UiStrings().AllFiles) diff --git a/openlp/plugins/media/lib/mediatab.py b/openlp/plugins/media/lib/mediatab.py index df17bfca6..4fefb23c7 100644 --- a/openlp/plugins/media/lib/mediatab.py +++ b/openlp/plugins/media/lib/mediatab.py @@ -122,9 +122,8 @@ class MediaTab(SettingsTab): if player.available: checkbox.setText(player.display_name) else: - checkbox.setText( - unicode(translate('MediaPlugin.MediaTab', - '%s (unavailable)')) % player.display_name) + checkbox.setText(translate('MediaPlugin.MediaTab', + '%s (unavailable)') % player.display_name) self.playerOrderGroupBox.setTitle( translate('MediaPlugin.MediaTab', 'Player Order')) self.advancedGroupBox.setTitle(UiStrings().Advanced) diff --git a/openlp/plugins/presentations/lib/mediaitem.py b/openlp/plugins/presentations/lib/mediaitem.py index 76897c355..1bfb4f123 100644 --- a/openlp/plugins/presentations/lib/mediaitem.py +++ b/openlp/plugins/presentations/lib/mediaitem.py @@ -87,8 +87,8 @@ class PresentationMediaItem(MediaManagerItem): if fileType.find(type) == -1: fileType += u'*.%s ' % type self.plugin.serviceManager.supportedSuffixes(type) - self.onNewFileMasks = unicode(translate('PresentationPlugin.MediaItem', - 'Presentations (%s)')) % fileType + self.onNewFileMasks = translate('PresentationPlugin.MediaItem', + 'Presentations (%s)') % fileType def requiredIcons(self): """ @@ -258,15 +258,15 @@ class PresentationMediaItem(MediaManagerItem): items = self.listView.selectedItems() if len(items) > 1: return False - service_item.title = unicode(self.displayTypeComboBox.currentText()) - service_item.shortname = unicode(self.displayTypeComboBox.currentText()) + service_item.title = self.displayTypeComboBox.currentText() + service_item.shortname = self.displayTypeComboBox.currentText() service_item.add_capability(ItemCapabilities.ProvidesOwnDisplay) service_item.add_capability(ItemCapabilities.HasDetailedTitleDisplay) shortname = service_item.shortname if not shortname: return False for bitem in items: - filename = unicode(bitem.data(QtCore.Qt.UserRole).toString()) + filename = bitem.data(QtCore.Qt.UserRole).toString() if os.path.exists(filename): if shortname == self.Automatic: service_item.shortname = self.findControllerByType(filename) @@ -292,10 +292,9 @@ class PresentationMediaItem(MediaManagerItem): critical_error_message_box( translate('PresentationPlugin.MediaItem', 'Missing Presentation'), - unicode(translate( - 'PresentationPlugin.MediaItem', + translate('PresentationPlugin.MediaItem', 'The presentation %s is incomplete,' - ' please reload.')) % filename) + ' please reload.') % filename) return False else: # File is no longer present @@ -303,8 +302,8 @@ class PresentationMediaItem(MediaManagerItem): critical_error_message_box( translate('PresentationPlugin.MediaItem', 'Missing Presentation'), - unicode(translate('PresentationPlugin.MediaItem', - 'The presentation %s no longer exists.')) % filename) + translate('PresentationPlugin.MediaItem', + 'The presentation %s no longer exists.') % filename) return False def findControllerByType(self, filename): diff --git a/openlp/plugins/presentations/lib/presentationtab.py b/openlp/plugins/presentations/lib/presentationtab.py index 5338eb132..6c972fed1 100644 --- a/openlp/plugins/presentations/lib/presentationtab.py +++ b/openlp/plugins/presentations/lib/presentationtab.py @@ -92,8 +92,8 @@ class PresentationTab(SettingsTab): checkbox.setText(controller.name) else: checkbox.setText( - unicode(translate('PresentationPlugin.PresentationTab', - '%s (unavailable)')) % controller.name) + translate('PresentationPlugin.PresentationTab', + '%s (unavailable)') % controller.name) def load(self): """ diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index 0bcf60b07..cda715d77 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -336,7 +336,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): row_label = [] for row in range(self.verseListWidget.rowCount()): item = self.verseListWidget.item(row, 0) - verse_def = unicode(item.data(QtCore.Qt.UserRole).toString()) + verse_def = item.data(QtCore.Qt.UserRole).toString() verse_tag = VerseType.translated_tag(verse_def[0]) row_def = u'%s%s' % (verse_tag, verse_def[1:]) row_label.append(row_def) @@ -346,7 +346,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): def onAuthorAddButtonClicked(self): item = int(self.authorsComboBox.currentIndex()) - text = unicode(self.authorsComboBox.currentText()).strip(u' \r\n\t') + text = self.authorsComboBox.currentText().strip(u' \r\n\t') # This if statement is for OS X, which doesn't seem to work well with # the QCompleter autocompletion class. See bug #812628. if text in self.authors: @@ -409,7 +409,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): def onTopicAddButtonClicked(self): item = int(self.topicsComboBox.currentIndex()) - text = unicode(self.topicsComboBox.currentText()) + text = self.topicsComboBox.currentText() if item == 0 and text: if QtGui.QMessageBox.question(self, translate('SongsPlugin.EditSongForm', 'Add Topic'), @@ -479,7 +479,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): item = self.verseListWidget.currentItem() if item: tempText = item.text() - verseId = unicode(item.data(QtCore.Qt.UserRole).toString()) + verseId = item.data(QtCore.Qt.UserRole).toString() self.verseForm.setVerse(tempText, True, verseId) if self.verseForm.exec_(): after_text, verse_tag, verse_num = self.verseForm.getVerse() @@ -509,7 +509,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): if self.verseListWidget.rowCount() > 0: for row in range(self.verseListWidget.rowCount()): item = self.verseListWidget.item(row, 0) - field = unicode(item.data(QtCore.Qt.UserRole).toString()) + field = item.data(QtCore.Qt.UserRole).toString() verse_tag = VerseType.translated_name(field[0]) verse_num = field[1:] verse_list += u'---[%s:%s]---\n' % (verse_tag, verse_num) @@ -576,7 +576,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): order = self.__extractVerseOrder(text) for index in range(self.verseListWidget.rowCount()): verse = self.verseListWidget.item(index, 0) - verse = unicode(verse.data(QtCore.Qt.UserRole).toString()) + verse = verse.data(QtCore.Qt.UserRole).toString() if verse not in verse_names: verses.append(verse) verse_names.append(u'%s%s' % ( @@ -617,7 +617,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): order = self.__extractVerseOrder(verse_order) for index in range(verse_count): verse = self.verseListWidget.item(index, 0) - verse = unicode(verse.data(QtCore.Qt.UserRole).toString()) + verse = verse.data(QtCore.Qt.UserRole).toString() if verse not in verse_names: verses.append(verse) verse_names.append(u'%s%s' % ( @@ -628,15 +628,15 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): if invalid_verses: valid = create_separated_list(verse_names) if len(invalid_verses) > 1: - critical_error_message_box(message=unicode(translate( + critical_error_message_box(message=translate( 'SongsPlugin.EditSongForm', 'The verse order is invalid. ' 'There are no verses corresponding to %s. Valid entries ' - 'are %s.')) % (u', '.join(invalid_verses), valid)) + 'are %s.') % (u', '.join(invalid_verses), valid)) else: - critical_error_message_box(message=unicode(translate( + critical_error_message_box(message=translate( 'SongsPlugin.EditSongForm', 'The verse order is invalid. ' 'There is no verse corresponding to %s. Valid entries ' - 'are %s.')) % (invalid_verses[0], valid)) + 'are %s.') % (invalid_verses[0], valid)) return len(invalid_verses) == 0 def __validateSong(self): @@ -673,7 +673,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): self.verseListWidget.rowCount()) if not result: return False - text = unicode(self.songBookComboBox.currentText()) + text = self.songBookComboBox.currentText() if self.songBookComboBox.findText(text, QtCore.Qt.MatchExactly) < 0: if QtGui.QMessageBox.question(self, translate('SongsPlugin.EditSongForm', 'Add Book'), @@ -699,7 +699,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): def onMaintenanceButtonClicked(self): temp_song_book = None item = int(self.songBookComboBox.currentIndex()) - text = unicode(self.songBookComboBox.currentText()) + text = self.songBookComboBox.currentText() if item == 0 and text: temp_song_book = text self.mediaitem.songMaintenanceForm.exec_() @@ -718,7 +718,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): A button (QPushButton). """ log.debug(u'onPreview') - if unicode(button.objectName()) == u'previewButton': + if button.objectName() == u'previewButton': self.saveSong(True) Receiver.send_message(u'songs_preview') @@ -826,30 +826,30 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): # Song() is in a partially complete state. if not self.song: self.song = Song() - self.song.title = unicode(self.titleEdit.text()) - self.song.alternate_title = unicode(self.alternativeEdit.text()) - self.song.copyright = unicode(self.copyrightEdit.text()) + self.song.title = self.titleEdit.text() + self.song.alternate_title = self.alternativeEdit.text() + self.song.copyright = self.copyrightEdit.text() # Values will be set when cleaning the song. self.song.search_title = u'' self.song.search_lyrics = u'' self.song.verse_order = u'' - self.song.comments = unicode(self.commentsEdit.toPlainText()) - ordertext = unicode(self.verseOrderEdit.text()) + self.song.comments = self.commentsEdit.toPlainText() + ordertext = self.verseOrderEdit.text() order = [] for item in ordertext.split(): verse_tag = VerseType.Tags[VerseType.from_translated_tag(item[0])] verse_num = item[1:].lower() order.append(u'%s%s' % (verse_tag, verse_num)) self.song.verse_order = u' '.join(order) - self.song.ccli_number = unicode(self.CCLNumberEdit.text()) - self.song.song_number = unicode(self.songBookNumberEdit.text()) - book_name = unicode(self.songBookComboBox.currentText()) + self.song.ccli_number = self.CCLNumberEdit.text() + self.song.song_number = self.songBookNumberEdit.text() + book_name = self.songBookComboBox.currentText() if book_name: self.song.book = self.manager.get_object_filtered(Book, Book.name == book_name) else: self.song.book = None - theme_name = unicode(self.themeComboBox.currentText()) + theme_name = self.themeComboBox.currentText() if theme_name: self.song.theme_name = theme_name else: @@ -879,7 +879,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): files = [] for row in xrange(self.audioListWidget.count()): item = self.audioListWidget.item(row) - filename = unicode(item.data(QtCore.Qt.UserRole).toString()) + filename = item.data(QtCore.Qt.UserRole).toString() if not filename.startswith(save_path): oldfile, filename = filename, os.path.join(save_path, os.path.split(filename)[1]) @@ -916,11 +916,10 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): multiple = [] for i in range(self.verseListWidget.rowCount()): item = self.verseListWidget.item(i, 0) - verseId = unicode(item.data(QtCore.Qt.UserRole).toString()) + verseId = item.data(QtCore.Qt.UserRole).toString() verse_tag = verseId[0] verse_num = verseId[1:] - sxml.add_verse_to_lyrics(verse_tag, verse_num, - unicode(item.text())) + sxml.add_verse_to_lyrics(verse_tag, verse_num, item.text()) if verse_num > u'1' and verse_tag not in multiple: multiple.append(verse_tag) self.song.lyrics = unicode(sxml.extract_xml(), u'utf-8') diff --git a/openlp/plugins/songs/forms/editverseform.py b/openlp/plugins/songs/forms/editverseform.py index 21285f39d..172f7ad49 100644 --- a/openlp/plugins/songs/forms/editverseform.py +++ b/openlp/plugins/songs/forms/editverseform.py @@ -96,7 +96,7 @@ class EditVerseForm(QtGui.QDialog, Ui_EditVerseDialog): and the cursor's position. """ position = self.verseTextEdit.textCursor().position() - text = unicode(self.verseTextEdit.toPlainText()) + text = self.verseTextEdit.toPlainText() verse_name = VerseType.TranslatedNames[ self.verseTypeComboBox.currentIndex()] if not text: @@ -126,7 +126,7 @@ class EditVerseForm(QtGui.QDialog, Ui_EditVerseDialog): position and adjusts the ComboBox and SpinBox to these values. """ position = self.verseTextEdit.textCursor().position() - text = unicode(self.verseTextEdit.toPlainText()) + text = self.verseTextEdit.toPlainText() if not text: return if text.rfind(u'[', 0, position) > text.rfind(u']', 0, position) and \ diff --git a/openlp/plugins/songs/forms/mediafilesform.py b/openlp/plugins/songs/forms/mediafilesform.py index db40eea63..49fcc0137 100644 --- a/openlp/plugins/songs/forms/mediafilesform.py +++ b/openlp/plugins/songs/forms/mediafilesform.py @@ -52,6 +52,6 @@ class MediaFilesForm(QtGui.QDialog, Ui_MediaFilesDialog): self.fileListWidget.addItem(item) def getSelectedFiles(self): - return map(lambda x: unicode(x.data(QtCore.Qt.UserRole).toString()), + return map(lambda item: item.data(QtCore.Qt.UserRole).toString(), self.fileListWidget.selectedItems()) diff --git a/openlp/plugins/songs/forms/songexportform.py b/openlp/plugins/songs/forms/songexportform.py index 498191f53..f213bc27d 100644 --- a/openlp/plugins/songs/forms/songexportform.py +++ b/openlp/plugins/songs/forms/songexportform.py @@ -286,8 +286,7 @@ class SongExportForm(OpenLPWizard): song.data(QtCore.Qt.UserRole).toPyObject() for song in self._findListWidgetItems(self.selectedListWidget) ] - exporter = OpenLyricsExport( - self, songs, unicode(self.directoryLineEdit.text())) + exporter = OpenLyricsExport(self, songs, self.directoryLineEdit.text()) if exporter.do_export(): self.progressLabel.setText( translate('SongsPlugin.SongExportForm', 'Finished export. To ' @@ -309,9 +308,8 @@ class SongExportForm(OpenLPWizard): ``text`` The text to search for. (unicode string) """ - #TODO: check if unicode() can be removed. - return [item for item in listWidget.findItems( - unicode(text), QtCore.Qt.MatchContains) + return [ + item for item in listWidget.findItems(text, QtCore.Qt.MatchContains) ] def onItemActivated(self, item): @@ -333,13 +331,11 @@ class SongExportForm(OpenLPWizard): will be hidden, but not unchecked! ``text`` - The text of the *searchLineEdit*. (QString) + The text of the *searchLineEdit*. """ - #TODO: check if unicode() can be removed. - print type(text) search_result = [ song for song in self._findListWidgetItems( - self.availableListWidget, unicode(text)) + self.availableListWidget, text) ] for item in self._findListWidgetItems(self.availableListWidget): item.setHidden(item not in search_result) @@ -367,11 +363,11 @@ class SongExportForm(OpenLPWizard): Called when the *directoryButton* was clicked. Opens a dialog and writes the path to *directoryLineEdit*. """ - path = unicode(QtGui.QFileDialog.getExistingDirectory(self, + path = QtGui.QFileDialog.getExistingDirectory(self, translate('SongsPlugin.ExportWizardForm', 'Select Destination Folder'), SettingsManager.get_last_dir(self.plugin.settingsSection, 1), - options=QtGui.QFileDialog.ShowDirsOnly)) + options=QtGui.QFileDialog.ShowDirsOnly) SettingsManager.set_last_dir(self.plugin.settingsSection, path, 1) self.directoryLineEdit.setText(path) diff --git a/openlp/plugins/songs/forms/songimportform.py b/openlp/plugins/songs/forms/songimportform.py index 65d769792..2d8322ff3 100644 --- a/openlp/plugins/songs/forms/songimportform.py +++ b/openlp/plugins/songs/forms/songimportform.py @@ -516,7 +516,7 @@ class SongImportForm(OpenLPWizard): """ Return a list of file from the listbox """ - return [unicode(listbox.item(i).text()) for i in range(listbox.count())] + return [listbox.item(i).text() for i in range(listbox.count())] def removeSelectedItems(self, listbox): """ @@ -786,12 +786,12 @@ class SongImportForm(OpenLPWizard): if source_format == SongFormat.OpenLP2: # Import an OpenLP 2.0 database importer = self.plugin.importSongs(SongFormat.OpenLP2, - filename=unicode(self.openLP2FilenameEdit.text()) + filename=self.openLP2FilenameEdit.text() ) elif source_format == SongFormat.OpenLP1: # Import an openlp.org database importer = self.plugin.importSongs(SongFormat.OpenLP1, - filename=unicode(self.openLP1FilenameEdit.text()), + filename=self.openLP1FilenameEdit.text(), plugin=self.plugin ) elif source_format == SongFormat.OpenLyrics: @@ -841,12 +841,12 @@ class SongImportForm(OpenLPWizard): elif source_format == SongFormat.EasySlides: # Import an EasySlides export file importer = self.plugin.importSongs(SongFormat.EasySlides, - filename=unicode(self.easySlidesFilenameEdit.text()) + filename=self.easySlidesFilenameEdit.text() ) elif source_format == SongFormat.EasyWorship: # Import an EasyWorship database importer = self.plugin.importSongs(SongFormat.EasyWorship, - filename=unicode(self.ewFilenameEdit.text()) + filename=self.ewFilenameEdit.text() ) elif source_format == SongFormat.SongBeamer: # Import SongBeamer songs diff --git a/openlp/plugins/songs/forms/songmaintenanceform.py b/openlp/plugins/songs/forms/songmaintenanceform.py index 51bb37e00..5df73634c 100644 --- a/openlp/plugins/songs/forms/songmaintenanceform.py +++ b/openlp/plugins/songs/forms/songmaintenanceform.py @@ -208,9 +208,9 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): self.authorform.setAutoDisplayName(True) if self.authorform.exec_(): author = Author.populate( - first_name=unicode(self.authorform.firstNameEdit.text()), - last_name=unicode(self.authorform.lastNameEdit.text()), - display_name=unicode(self.authorform.displayEdit.text())) + first_name=self.authorform.firstNameEdit.text(), + last_name=self.authorform.lastNameEdit.text(), + display_name=self.authorform.displayEdit.text()) if self.checkAuthor(author): if self.manager.save_object(author): self.resetAuthors() @@ -225,7 +225,7 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): def onTopicAddButtonClicked(self): if self.topicform.exec_(): - topic = Topic.populate(name=unicode(self.topicform.nameEdit.text())) + topic = Topic.populate(name=self.topicform.nameEdit.text()) if self.checkTopic(topic): if self.manager.save_object(topic): self.resetTopics() @@ -240,8 +240,8 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): def onBookAddButtonClicked(self): if self.bookform.exec_(): - book = Book.populate(name=unicode(self.bookform.nameEdit.text()), - publisher=unicode(self.bookform.publisherEdit.text())) + book = Book.populate(name=self.bookform.nameEdit.text(), + publisher=self.bookform.publisherEdit.text()) if self.checkBook(book): if self.manager.save_object(book): self.resetBooks() @@ -269,9 +269,9 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): temp_last_name = author.last_name temp_display_name = author.display_name if self.authorform.exec_(False): - author.first_name = unicode(self.authorform.firstNameEdit.text()) - author.last_name = unicode(self.authorform.lastNameEdit.text()) - author.display_name = unicode(self.authorform.displayEdit.text()) + author.first_name = self.authorform.firstNameEdit.text() + author.last_name = self.authorform.lastNameEdit.text() + author.display_name = self.authorform.displayEdit.text() if self.checkAuthor(author, True): if self.manager.save_object(author): self.resetAuthors() @@ -280,10 +280,10 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): critical_error_message_box( message=translate('SongsPlugin.SongMaintenanceForm', 'Could not save your changes.')) - elif critical_error_message_box(message=unicode(translate( + elif critical_error_message_box(message=translate( 'SongsPlugin.SongMaintenanceForm', 'The author %s already ' 'exists. Would you like to make songs with author %s use ' - 'the existing author %s?')) % (author.display_name, + 'the existing author %s?') % (author.display_name, temp_display_name, author.display_name), parent=self, question=True) == QtGui.QMessageBox.Yes: self.__mergeObjects(author, self.mergeAuthors, @@ -308,7 +308,7 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): # Save the topic's name for the case that he has to be restored. temp_name = topic.name if self.topicform.exec_(False): - topic.name = unicode(self.topicform.nameEdit.text()) + topic.name = self.topicform.nameEdit.text() if self.checkTopic(topic, True): if self.manager.save_object(topic): self.resetTopics() @@ -317,9 +317,9 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): message=translate('SongsPlugin.SongMaintenanceForm', 'Could not save your changes.')) elif critical_error_message_box( - message=unicode(translate('SongsPlugin.SongMaintenanceForm', + message=translate('SongsPlugin.SongMaintenanceForm', 'The topic %s already exists. Would you like to make songs ' - 'with topic %s use the existing topic %s?')) % (topic.name, + 'with topic %s use the existing topic %s?') % (topic.name, temp_name, topic.name), parent=self, question=True) == QtGui.QMessageBox.Yes: self.__mergeObjects(topic, self.mergeTopics, self.resetTopics) @@ -345,8 +345,8 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): temp_name = book.name temp_publisher = book.publisher if self.bookform.exec_(False): - book.name = unicode(self.bookform.nameEdit.text()) - book.publisher = unicode(self.bookform.publisherEdit.text()) + book.name = self.bookform.nameEdit.text() + book.publisher = self.bookform.publisherEdit.text() if self.checkBook(book, True): if self.manager.save_object(book): self.resetBooks() @@ -355,9 +355,9 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): message=translate('SongsPlugin.SongMaintenanceForm', 'Could not save your changes.')) elif critical_error_message_box( - message=unicode(translate('SongsPlugin.SongMaintenanceForm', + message=translate('SongsPlugin.SongMaintenanceForm', 'The book %s already exists. Would you like to make songs ' - 'with book %s use the existing book %s?')) % (book.name, + 'with book %s use the existing book %s?') % (book.name, temp_name, book.name), parent=self, question=True) == QtGui.QMessageBox.Yes: self.__mergeObjects(book, self.mergeBooks, self.resetBooks) diff --git a/openlp/plugins/songs/lib/__init__.py b/openlp/plugins/songs/lib/__init__.py index 44cf8e113..42df6615e 100644 --- a/openlp/plugins/songs/lib/__init__.py +++ b/openlp/plugins/songs/lib/__init__.py @@ -60,13 +60,13 @@ class VerseType(object): Tags = [name[0].lower() for name in Names] TranslatedNames = [ - unicode(translate('SongsPlugin.VerseType', 'Verse')), - unicode(translate('SongsPlugin.VerseType', 'Chorus')), - unicode(translate('SongsPlugin.VerseType', 'Bridge')), - unicode(translate('SongsPlugin.VerseType', 'Pre-Chorus')), - unicode(translate('SongsPlugin.VerseType', 'Intro')), - unicode(translate('SongsPlugin.VerseType', 'Ending')), - unicode(translate('SongsPlugin.VerseType', 'Other'))] + translate('SongsPlugin.VerseType', 'Verse'), + translate('SongsPlugin.VerseType', 'Chorus'), + translate('SongsPlugin.VerseType', 'Bridge'), + translate('SongsPlugin.VerseType', 'Pre-Chorus'), + translate('SongsPlugin.VerseType', 'Intro'), + translate('SongsPlugin.VerseType', 'Ending'), + translate('SongsPlugin.VerseType', 'Other')] TranslatedTags = [name[0].lower() for name in TranslatedNames] @staticmethod diff --git a/openlp/plugins/songs/lib/ewimport.py b/openlp/plugins/songs/lib/ewimport.py index d58734610..87d89b247 100644 --- a/openlp/plugins/songs/lib/ewimport.py +++ b/openlp/plugins/songs/lib/ewimport.py @@ -258,8 +258,8 @@ class EasyWorshipSongImport(SongImport): if copy: self.copyright += u', ' self.copyright += \ - unicode(translate('SongsPlugin.EasyWorshipSongImport', - 'Administered by %s')) % admin + translate('SongsPlugin.EasyWorshipSongImport', + 'Administered by %s') % admin if ccli: self.ccliNumber = ccli if authors: diff --git a/openlp/plugins/songs/lib/openlyricsexport.py b/openlp/plugins/songs/lib/openlyricsexport.py index d5ffcb1a4..1d17c48b5 100644 --- a/openlp/plugins/songs/lib/openlyricsexport.py +++ b/openlp/plugins/songs/lib/openlyricsexport.py @@ -65,9 +65,8 @@ class OpenLyricsExport(object): Receiver.send_message(u'openlp_process_events') if self.parent.stop_export_flag: return False - self.parent.incrementProgressBar(unicode(translate( - 'SongsPlugin.OpenLyricsExport', 'Exporting "%s"...')) % - song.title) + self.parent.incrementProgressBar(translate( + 'SongsPlugin.OpenLyricsExport', 'Exporting "%s"...') % song.title) xml = openLyrics.song_to_xml(song) tree = etree.ElementTree(etree.fromstring(xml)) filename = u'%s (%s)' % (song.title, diff --git a/openlp/plugins/songs/lib/powersongimport.py b/openlp/plugins/songs/lib/powersongimport.py index 31491398c..2d558b62b 100644 --- a/openlp/plugins/songs/lib/powersongimport.py +++ b/openlp/plugins/songs/lib/powersongimport.py @@ -74,8 +74,8 @@ class PowerSongImport(SongImport): Receive a list of files to import. """ if not isinstance(self.importSource, list): - self.logError(unicode(translate('SongsPlugin.PowerSongImport', - 'No files to import.'))) + self.logError(translate('SongsPlugin.PowerSongImport', + 'No files to import.')) return self.importWizard.progressBar.setMaximum(len(self.importSource)) for file in self.importSource: diff --git a/openlp/plugins/songs/lib/songimport.py b/openlp/plugins/songs/lib/songimport.py index 9bfdce124..9dafacbe4 100644 --- a/openlp/plugins/songs/lib/songimport.py +++ b/openlp/plugins/songs/lib/songimport.py @@ -98,8 +98,7 @@ class SongImport(QtCore.QObject): self.verseOrderList = [] self.verses = [] self.verseCounts = {} - self.copyrightString = unicode(translate( - 'SongsPlugin.SongImport', 'copyright')) + self.copyrightString = translate('SongsPlugin.SongImport', 'copyright') def logError(self, filepath, reason=SongStrings.SongIncomplete): """ diff --git a/openlp/plugins/songs/lib/xml.py b/openlp/plugins/songs/lib/xml.py index 45dac95b9..3d50d3594 100644 --- a/openlp/plugins/songs/lib/xml.py +++ b/openlp/plugins/songs/lib/xml.py @@ -718,15 +718,15 @@ class OpenLyrics(object): except AttributeError: raise OpenLyricsError(OpenLyricsError.LyricsError, ' tag is missing.', - unicode(translate('OpenLP.OpenLyricsImportError', - ' tag is missing.'))) + translate('OpenLP.OpenLyricsImportError', + ' tag is missing.')) try: verse_list = lyrics.verse except AttributeError: raise OpenLyricsError(OpenLyricsError.VerseError, ' tag is missing.', - unicode(translate('OpenLP.OpenLyricsImportError', - ' tag is missing.'))) + translate('OpenLP.OpenLyricsImportError', + ' tag is missing.')) # Loop over the "verse" elements. for verse in verse_list: text = u'' diff --git a/openlp/plugins/songs/songsplugin.py b/openlp/plugins/songs/songsplugin.py index 4d59186e5..8e85cfcff 100644 --- a/openlp/plugins/songs/songsplugin.py +++ b/openlp/plugins/songs/songsplugin.py @@ -74,10 +74,9 @@ class SongsPlugin(Plugin): self.songExportItem.setVisible(True) self.toolsReindexItem.setVisible(True) action_list = ActionList.get_instance() - action_list.add_action(self.songImportItem, unicode(UiStrings().Import)) - action_list.add_action(self.songExportItem, unicode(UiStrings().Export)) - action_list.add_action(self.toolsReindexItem, - unicode(UiStrings().Tools)) + action_list.add_action(self.songImportItem, UiStrings().Import) + action_list.add_action(self.songExportItem, UiStrings().Export) + action_list.add_action(self.toolsReindexItem, UiStrings().Tools) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'servicemanager_new_service'), self.clearTemporarySongs) @@ -268,12 +267,9 @@ class SongsPlugin(Plugin): self.songExportItem.setVisible(False) self.toolsReindexItem.setVisible(False) action_list = ActionList.get_instance() - action_list.remove_action(self.songImportItem, - unicode(UiStrings().Import)) - action_list.remove_action(self.songExportItem, - unicode(UiStrings().Export)) - action_list.remove_action(self.toolsReindexItem, - unicode(UiStrings().Tools)) + action_list.remove_action(self.songImportItem, UiStrings().Import) + action_list.remove_action(self.songExportItem, UiStrings().Export) + action_list.remove_action(self.toolsReindexItem, UiStrings().Tools) Plugin.finalise(self) def clearTemporarySongs(self): diff --git a/openlp/plugins/songusage/forms/songusagedetailform.py b/openlp/plugins/songusage/forms/songusagedetailform.py index f1cdb4cbc..e8f6f352a 100644 --- a/openlp/plugins/songusage/forms/songusagedetailform.py +++ b/openlp/plugins/songusage/forms/songusagedetailform.py @@ -59,11 +59,11 @@ class SongUsageDetailForm(QtGui.QDialog, Ui_SongUsageDetailDialog): year = QtCore.QDate().currentDate().year() if QtCore.QDate().currentDate().month() < 9: year -= 1 - toDate = Settings().value( - u'songusage/to date', QtCore.QDate(year, 8, 31)).toDate() - fromDate = Settings().value( - u'songusage/from date', - QtCore.QDate(year - 1, 9, 1)).toDate() + # TODO: check toDate() + toDate = Settings().value(self.plugin.settingsSection + + u'/to date', QtCore.QDate(year, 8, 31)).toDate() + fromDate = Settings().value(self.plugin.settingsSection + + u'/from date', QtCore.QDate(year - 1, 9, 1)).toDate() self.fromDate.setSelectedDate(fromDate) self.toDate.setSelectedDate(toDate) self.fileLineEdit.setText( @@ -87,25 +87,25 @@ class SongUsageDetailForm(QtGui.QDialog, Ui_SongUsageDetailDialog): Ok was triggered so lets save the data and run the report """ log.debug(u'accept') - path = unicode(self.fileLineEdit.text()) - if path == u'': + path = self.fileLineEdit.text() + if not path: Receiver.send_message(u'openlp_error_message', { u'title': translate('SongUsagePlugin.SongUsageDetailForm', 'Output Path Not Selected'), - u'message': unicode(translate( + u'message': translate( 'SongUsagePlugin.SongUsageDetailForm', 'You have not set a ' 'valid output location for your song usage report. Please ' - 'select an existing path on your computer.'))}) + 'select an existing path on your computer.')}) return check_directory_exists(path) - filename = unicode(translate('SongUsagePlugin.SongUsageDetailForm', - 'usage_detail_%s_%s.txt')) % ( + filename = translate('SongUsagePlugin.SongUsageDetailForm', + 'usage_detail_%s_%s.txt') % ( self.fromDate.selectedDate().toString(u'ddMMyyyy'), self.toDate.selectedDate().toString(u'ddMMyyyy')) - Settings().setValue(u'songusage/from date', - self.fromDate.selectedDate()) - Settings().setValue(u'songusage/to date', - self.toDate.selectedDate()) + Settings().setValue(self.plugin.settingsSection + + u'/from date', self.fromDate.selectedDate()) + Settings().setValue(self.plugin.settingsSection + + u'/to date', self.toDate.selectedDate()) usage = self.plugin.manager.get_all_objects( SongUsageItem, and_( SongUsageItem.usagedate >= self.fromDate.selectedDate().toPyDate(), @@ -125,9 +125,9 @@ class SongUsageDetailForm(QtGui.QDialog, Ui_SongUsageDetailDialog): Receiver.send_message(u'openlp_information_message', { u'title': translate('SongUsagePlugin.SongUsageDetailForm', 'Report Creation'), - u'message': unicode(translate( + u'message': translate( 'SongUsagePlugin.SongUsageDetailForm', 'Report \n%s \n' - 'has been successfully created. ')) % outname}) + 'has been successfully created. ') % outname}) except IOError: log.exception(u'Failed to write out song usage records') finally: diff --git a/openlp/plugins/songusage/songusageplugin.py b/openlp/plugins/songusage/songusageplugin.py index 48450510f..48e8ad3c4 100644 --- a/openlp/plugins/songusage/songusageplugin.py +++ b/openlp/plugins/songusage/songusageplugin.py @@ -112,8 +112,7 @@ class SongUsagePlugin(Plugin): QtCore.SIGNAL(u'visibilityChanged(bool)'), self.songUsageStatus.setChecked) QtCore.QObject.connect(self.songUsageActiveButton, - QtCore.SIGNAL(u'toggled(bool)'), - self.toggleSongUsageState) + QtCore.SIGNAL(u'toggled(bool)'), self.toggleSongUsageState) self.songUsageMenu.menuAction().setVisible(False) def initialise(self): @@ -131,11 +130,11 @@ class SongUsagePlugin(Plugin): self.setButtonState() action_list = ActionList.get_instance() action_list.add_action(self.songUsageStatus, - unicode(translate('SongUsagePlugin', 'Song Usage'))) + translate('SongUsagePlugin', 'Song Usage')) action_list.add_action(self.songUsageDelete, - unicode(translate('SongUsagePlugin', 'Song Usage'))) + translate('SongUsagePlugin', 'Song Usage')) action_list.add_action(self.songUsageReport, - unicode(translate('SongUsagePlugin', 'Song Usage'))) + translate('SongUsagePlugin', 'Song Usage')) self.songUsageDeleteForm = SongUsageDeleteForm(self.manager, self.formParent) self.songUsageDetailForm = SongUsageDetailForm(self, self.formParent) @@ -152,11 +151,11 @@ class SongUsagePlugin(Plugin): self.songUsageMenu.menuAction().setVisible(False) action_list = ActionList.get_instance() action_list.remove_action(self.songUsageStatus, - unicode(translate('SongUsagePlugin', 'Song Usage'))) + translate('SongUsagePlugin', 'Song Usage')) action_list.remove_action(self.songUsageDelete, - unicode(translate('SongUsagePlugin', 'Song Usage'))) + translate('SongUsagePlugin', 'Song Usage')) action_list.remove_action(self.songUsageReport, - unicode(translate('SongUsagePlugin', 'Song Usage'))) + translate('SongUsagePlugin', 'Song Usage')) self.songUsageActiveButton.hide() # stop any events being processed self.songUsageActive = False @@ -167,8 +166,7 @@ class SongUsagePlugin(Plugin): the UI when necessary, """ self.songUsageActive = not self.songUsageActive - Settings().setValue(self.settingsSection + u'/active', - self.songUsageActive) + Settings().setValue(self.settingsSection + u'/active', self.songUsageActive) self.setButtonState() def setButtonState(self): @@ -198,15 +196,13 @@ class SongUsagePlugin(Plugin): """ Song Usage for which has been displayed """ - self._add_song_usage(unicode(translate('SongUsagePlugin', - 'display')), item) + self._add_song_usage(translate('SongUsagePlugin', 'display'), item) def printSongUsage(self, item): """ Song Usage for which has been printed """ - self._add_song_usage(unicode(translate('SongUsagePlugin', - 'printed')), item) + self._add_song_usage(translate('SongUsagePlugin', 'printed'), item) def _add_song_usage(self, source, item): audit = item[0].audit From 06e49d4b97b8fa980864b71f27110a143fb440b6 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Thu, 17 May 2012 21:01:15 +0200 Subject: [PATCH 07/53] clean up --- openlp/core/lib/spelltextedit.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/openlp/core/lib/spelltextedit.py b/openlp/core/lib/spelltextedit.py index d855f0ec9..aecd28384 100644 --- a/openlp/core/lib/spelltextedit.py +++ b/openlp/core/lib/spelltextedit.py @@ -200,5 +200,4 @@ class SpellAction(QtGui.QAction): def __init__(self, *args): QtGui.QAction.__init__(self, *args) - self.triggered.connect(lambda x: self.correct.emit( - unicode(self.text()))) + self.triggered.connect(lambda x: self.correct.emit(self.text())) From 3fa5422d7d0bea607846ccdb0c95a664213ec27b Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Thu, 17 May 2012 21:49:06 +0200 Subject: [PATCH 08/53] fixed recent file menu --- openlp/core/ui/mainwindow.py | 15 +++++++-------- openlp/core/ui/servicemanager.py | 7 +++---- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index a8ddb9235..f9303801a 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -1334,8 +1334,8 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): log.debug(u'Saving QSettings') settings = Settings() settings.beginGroup(self.generalSettingsSection) - recentFiles = self.recentFiles if self.recentFiles else u'' - settings.setValue(u'recent files', recentFiles) + settings.setValue( + u'recent files', self.recentFiles if self.recentFiles else list()) settings.endGroup() settings.beginGroup(self.uiSettingsSection) settings.setValue(u'main window position', self.pos()) @@ -1359,6 +1359,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): if os.path.isfile(unicode(recentFile))] recentFilesToDisplay = existingRecentFiles[0:recentFileCount] self.clearRecentFileMenu() + self.recentFilesMenu.clear() for fileId, filename in enumerate(recentFilesToDisplay): log.debug('Recent file name: %s', filename) action = create_action(self, u'', @@ -1394,13 +1395,11 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): # in the given filename which then causes duplication. if filename[1:3] == ':\\': filename = filename[0].upper() + filename[1:] - position = self.recentFiles.indexOf(filename) - if position != -1: - self.recentFiles.removeAt(position) + if filename in self.recentFiles: + self.recentFiles.remove(filename) self.recentFiles.insert(0, filename) - while self.recentFiles.count() > maxRecentFiles: - # Don't care what API says takeLast works, removeLast doesn't! - self.recentFiles.takeLast() + while len(self.recentFiles) > maxRecentFiles: + self.recentFiles.pop() def clearRecentFileMenu(self): """ diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 78ca788de..6cffc3d6e 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -593,15 +593,14 @@ class ServiceManager(QtGui.QWidget): default_service_enabled = Settings().value( u'advanced/default service enabled', True) if default_service_enabled: - service_day = Settings().value( - u'advanced/default service day', 7).toInt()[0] + service_day = Settings().value(u'advanced/default service day', 7) if service_day == 7: time = datetime.now() else: service_hour = Settings().value( - u'advanced/default service hour', 11).toInt()[0] + u'advanced/default service hour', 11) service_minute = Settings().value( - u'advanced/default service minute', 0).toInt()[0] + u'advanced/default service minute', 0) now = datetime.now() day_delta = service_day - now.weekday() if day_delta < 0: From c36475f27e3eb9b944ed574f824511f93fd77118 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Thu, 17 May 2012 21:57:45 +0200 Subject: [PATCH 09/53] completely fixed recently file menu --- openlp/core/ui/mainwindow.py | 1 - 1 file changed, 1 deletion(-) diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index f9303801a..273041311 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -1358,7 +1358,6 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): existingRecentFiles = [recentFile for recentFile in self.recentFiles if os.path.isfile(unicode(recentFile))] recentFilesToDisplay = existingRecentFiles[0:recentFileCount] - self.clearRecentFileMenu() self.recentFilesMenu.clear() for fileId, filename in enumerate(recentFilesToDisplay): log.debug('Recent file name: %s', filename) From cb13f805e4b2646911e986954d9721ae3bb29445 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Thu, 17 May 2012 22:06:23 +0200 Subject: [PATCH 10/53] clean up + fix --- openlp/core/ui/media/mediacontroller.py | 3 +-- openlp/core/ui/servicemanager.py | 17 ++++++++--------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/openlp/core/ui/media/mediacontroller.py b/openlp/core/ui/media/mediacontroller.py index 541c61763..b7ad43f0f 100644 --- a/openlp/core/ui/media/mediacontroller.py +++ b/openlp/core/ui/media/mediacontroller.py @@ -352,8 +352,7 @@ class MediaController(object): if overriddenPlayer and overriddenPlayer != u'auto': usedPlayers = [overriddenPlayer] if controller.media_info.file_info.isFile(): - suffix = u'*.%s' % \ - controller.media_info.file_info.suffix().toLower() + suffix = u'*.%s' % controller.media_info.file_info.suffix().lower() for title in usedPlayers: player = self.mediaPlayers[title] if suffix in player.video_extensions_list: diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 6cffc3d6e..453ecd00b 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -738,10 +738,10 @@ class ServiceManager(QtGui.QWidget): item = self.serviceManagerList.itemAt(point) if item is None: return - if item.parent() is None: - pos = item.data(0, QtCore.Qt.UserRole).toInt()[0] - else: + if item.parent(): pos = item.parent().data(0, QtCore.Qt.UserRole).toInt()[0] + else: + pos = item.data(0, QtCore.Qt.UserRole).toInt()[0] serviceItem = self.serviceItems[pos - 1] self.editAction.setVisible(False) self.maintainAction.setVisible(False) @@ -750,13 +750,12 @@ class ServiceManager(QtGui.QWidget): if serviceItem[u'service_item'].is_capable(ItemCapabilities.CanEdit)\ and serviceItem[u'service_item'].edit_id: self.editAction.setVisible(True) - if serviceItem[u'service_item']\ - .is_capable(ItemCapabilities.CanMaintain): + if serviceItem[u'service_item'].is_capable( + ItemCapabilities.CanMaintain): self.maintainAction.setVisible(True) - if item.parent() is None: - self.notesAction.setVisible(True) - if serviceItem[u'service_item']\ - .is_capable(ItemCapabilities.HasVariableStartTime): + self.notesAction.setVisible(item.parent() is None) + if serviceItem[u'service_item'].is_capable( + ItemCapabilities.HasVariableStartTime): self.timeAction.setVisible(True) self.themeMenu.menuAction().setVisible(False) # Set up the theme menu. From e80287f5917d08318d7f7abe9bbaa90e0c1ec810 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Thu, 17 May 2012 22:19:07 +0200 Subject: [PATCH 11/53] fixed import --- openlp/core/ui/media/mediacontroller.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/core/ui/media/mediacontroller.py b/openlp/core/ui/media/mediacontroller.py index b7ad43f0f..e8f66ffe3 100644 --- a/openlp/core/ui/media/mediacontroller.py +++ b/openlp/core/ui/media/mediacontroller.py @@ -29,7 +29,7 @@ import logging import os from PyQt4 import QtCore, QtGui -from openlp.core.lib import OpenLPToolbar, Receiver, translate +from openlp.core.lib import OpenLPToolbar, Receiver, translate, Settings from openlp.core.lib.mediaplayer import MediaPlayer from openlp.core.lib.ui import critical_error_message_box from openlp.core.ui.media import MediaState, MediaInfo, MediaType, \ From 374a42634037217c7672c66c60031a39dd561cc7 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sat, 19 May 2012 10:29:31 +0200 Subject: [PATCH 12/53] added another case, clean ups --- openlp/core/lib/__init__.py | 55 +++++++++++++++++++++++++++++------ openlp/core/utils/__init__.py | 2 +- 2 files changed, 47 insertions(+), 10 deletions(-) diff --git a/openlp/core/lib/__init__.py b/openlp/core/lib/__init__.py index 4f49e4d58..ee5f891a4 100644 --- a/openlp/core/lib/__init__.py +++ b/openlp/core/lib/__init__.py @@ -28,6 +28,7 @@ The :mod:`lib` module contains most of the components and libraries that make OpenLP work. """ +import datetime import logging import os @@ -63,17 +64,58 @@ class ServiceItemAction(object): Next = 3 +class MissingTypeConversion(Exception): + """ + A exception class which is used when a setting is not converted. + """ + def __init__(self, msg): + """ + Constructor + """ + self.msg = msg + + def __str__(self): + """ + Returns a string representation. + """ + return repr(self.msg) + + class Settings(QtCore.QSettings): - type_list = [] + """ + This class customises the ``QSettings`` class. You must use this class + instead of the ``QSettings`` class. + """ def __init__(self, *args): + """ + Construct a ``QSettings`` object. + """ QtCore.QSettings.__init__(self, *args) def value(self, key, defaultValue): + """ + Returns the value for the given ``key``. The returned ``value`` is + of the same type as the ``defaultValue``. + + ``key`` + The key to return the value from. + + ``defaultValue`` + The value to be returned if the given ``key`` is not present in the + config. Note, the ``defaultValue``'s type defines the type the + returned is converted to. In other words, if the ``defaultValue`` is + a boolean, then the returned value will be converted to a boolean. + + **Note**, this method only converts a few types and might need to be + extended if a certain type is missing! + """ setting = super(Settings, self).value(key, defaultValue) + # Convert the setting to the correct type. if isinstance(defaultValue, bool): return setting.toBool() if isinstance(defaultValue, QtCore.QByteArray): return setting.toByteArray() + # Enumerations are also taken care of. if isinstance(defaultValue, int): return setting.toInt()[0] if isinstance(defaultValue, basestring): @@ -82,15 +124,10 @@ class Settings(QtCore.QSettings): return setting.toStringList() if isinstance(defaultValue, QtCore.QPoint): return setting.toPoint() - # TODO: add + if isinstance(defaultValue, datetime.date): + return setting.toDate() print u'No!', type(defaultValue) - return setting - - def setValue(self, key, value): - super(Settings, self).setValue(key, value) - if type(value) not in Settings.type_list: - Settings.type_list.append(type(value)) - print Settings.type_list + raise MissingTypeConversion(u'Setting could not be converted') def translate(context, text, comment=None, diff --git a/openlp/core/utils/__init__.py b/openlp/core/utils/__init__.py index 964f82d00..48a8b2ce3 100644 --- a/openlp/core/utils/__init__.py +++ b/openlp/core/utils/__init__.py @@ -286,7 +286,7 @@ def check_latest_version(current_version): settings = Settings() settings.beginGroup(u'general') last_test = settings.value(u'last version test', datetime.now().date()) - this_test = unicode(datetime.now().date()) + this_test = datetime.now().date() settings.setValue(u'last version test', this_test) settings.endGroup() if last_test != this_test: From 175b01621dfba159698bf524c8ef40ce6dcaf074 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sat, 19 May 2012 10:44:45 +0200 Subject: [PATCH 13/53] fixed songusage, clean ups --- openlp/core/lib/__init__.py | 2 +- openlp/core/ui/firsttimeform.py | 1 - openlp/core/ui/themestab.py | 1 - openlp/plugins/alerts/lib/alertstab.py | 1 - openlp/plugins/bibles/lib/biblestab.py | 1 - openlp/plugins/songs/lib/mediaitem.py | 1 - openlp/plugins/songusage/forms/songusagedetailform.py | 5 ++--- 7 files changed, 3 insertions(+), 9 deletions(-) diff --git a/openlp/core/lib/__init__.py b/openlp/core/lib/__init__.py index ee5f891a4..dd84d1a8c 100644 --- a/openlp/core/lib/__init__.py +++ b/openlp/core/lib/__init__.py @@ -124,7 +124,7 @@ class Settings(QtCore.QSettings): return setting.toStringList() if isinstance(defaultValue, QtCore.QPoint): return setting.toPoint() - if isinstance(defaultValue, datetime.date): + if isinstance(defaultValue, (datetime.date, QtCore.QDate)): return setting.toDate() print u'No!', type(defaultValue) raise MissingTypeConversion(u'Setting could not be converted') diff --git a/openlp/core/ui/firsttimeform.py b/openlp/core/ui/firsttimeform.py index d17b65927..5c2e4e821 100644 --- a/openlp/core/ui/firsttimeform.py +++ b/openlp/core/ui/firsttimeform.py @@ -132,7 +132,6 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): for lang in bible_languages: language = unicode(self.config.get( u'bibles_%s' % lang, u'title'), u'utf8') - # FIXME langItem = QtGui.QTreeWidgetItem( self.biblesTreeWidget, language) bibles = self.config.get(u'bibles_%s' % lang, u'translations') diff --git a/openlp/core/ui/themestab.py b/openlp/core/ui/themestab.py index 7eba9ec46..6bfc1b352 100644 --- a/openlp/core/ui/themestab.py +++ b/openlp/core/ui/themestab.py @@ -135,7 +135,6 @@ class ThemesTab(SettingsTab): settings = Settings() settings.beginGroup(self.settingsSection) self.theme_level = settings.value(u'theme level', ThemeLevel.Song) - # TODO: check empty string (logic). self.global_theme = settings.value(u'global theme', u'') settings.endGroup() if self.theme_level == ThemeLevel.Global: diff --git a/openlp/plugins/alerts/lib/alertstab.py b/openlp/plugins/alerts/lib/alertstab.py index f10826a22..28d6a5e1f 100644 --- a/openlp/plugins/alerts/lib/alertstab.py +++ b/openlp/plugins/alerts/lib/alertstab.py @@ -158,7 +158,6 @@ class AlertsTab(SettingsTab): self.font_color = settings.value(u'font color', u'#ffffff') self.font_size = settings.value(u'font size', 40) self.bg_color = settings.value(u'background color', u'#660000') - # TODO: isinstance needed? self.font_face = settings.value(u'font face', QtGui.QFont().family()) self.location = settings.value(u'location', AlertLocation.Bottom) settings.endGroup() diff --git a/openlp/plugins/bibles/lib/biblestab.py b/openlp/plugins/bibles/lib/biblestab.py index a054d1de0..421c78b1f 100644 --- a/openlp/plugins/bibles/lib/biblestab.py +++ b/openlp/plugins/bibles/lib/biblestab.py @@ -419,7 +419,6 @@ class BiblesTab(SettingsTab): self.show_new_chapters = settings.value(u'display new chapter', False) self.display_style = settings.value(u'display brackets', 0) self.layout_style = settings.value(u'verse layout style', 0) - #TODO: Check self.bible_theme = settings.value(u'bible theme', u'') self.second_bibles = settings.value(u'second bibles', True) self.newChaptersCheckBox.setChecked(self.show_new_chapters) diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index b01418cbb..c822c1281 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -132,7 +132,6 @@ class SongMediaItem(MediaManagerItem): self.searchTextEdit.setFocus() def configUpdated(self): - # TODO: Check .toBool() self.searchAsYouType = Settings().value( self.settingsSection + u'/search as type', False) self.updateServiceOnEdit = Settings().value( diff --git a/openlp/plugins/songusage/forms/songusagedetailform.py b/openlp/plugins/songusage/forms/songusagedetailform.py index e8f6f352a..dd28662f6 100644 --- a/openlp/plugins/songusage/forms/songusagedetailform.py +++ b/openlp/plugins/songusage/forms/songusagedetailform.py @@ -59,11 +59,10 @@ class SongUsageDetailForm(QtGui.QDialog, Ui_SongUsageDetailDialog): year = QtCore.QDate().currentDate().year() if QtCore.QDate().currentDate().month() < 9: year -= 1 - # TODO: check toDate() toDate = Settings().value(self.plugin.settingsSection + - u'/to date', QtCore.QDate(year, 8, 31)).toDate() + u'/to date', QtCore.QDate(year, 8, 31)) fromDate = Settings().value(self.plugin.settingsSection + - u'/from date', QtCore.QDate(year - 1, 9, 1)).toDate() + u'/from date', QtCore.QDate(year - 1, 9, 1)) self.fromDate.setSelectedDate(fromDate) self.toDate.setSelectedDate(toDate) self.fileLineEdit.setText( From b07fab7ff0b6c8ae6c3cc84aa8b7ba4477304ba7 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sat, 19 May 2012 10:50:33 +0200 Subject: [PATCH 14/53] clean up --- openlp/core/ui/firsttimeform.py | 1 - openlp/plugins/songs/forms/songexportform.py | 1 - 2 files changed, 2 deletions(-) diff --git a/openlp/core/ui/firsttimeform.py b/openlp/core/ui/firsttimeform.py index 5c2e4e821..1e7aa366e 100644 --- a/openlp/core/ui/firsttimeform.py +++ b/openlp/core/ui/firsttimeform.py @@ -141,7 +141,6 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): u'bible_%s' % bible, u'title'), u'utf8') filename = unicode(self.config.get( u'bible_%s' % bible, u'filename')) - # FIXME item = QtGui.QTreeWidgetItem(langItem, title) item.setData(0, QtCore.Qt.UserRole, filename) item.setCheckState(0, QtCore.Qt.Unchecked) diff --git a/openlp/plugins/songs/forms/songexportform.py b/openlp/plugins/songs/forms/songexportform.py index f213bc27d..f75c34eb5 100644 --- a/openlp/plugins/songs/forms/songexportform.py +++ b/openlp/plugins/songs/forms/songexportform.py @@ -218,7 +218,6 @@ class SongExportForm(OpenLPWizard): # Add the songs to the list of selected songs. for item in items: song = QtGui.QListWidgetItem(item.text()) - # TODO: check toPyObject() song.setData(QtCore.Qt.UserRole, item.data(QtCore.Qt.UserRole).toPyObject()) song.setFlags(QtCore.Qt.ItemIsEnabled) From b124481ea2bfa82b45bba5e0ecb1e69311d18364 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sat, 19 May 2012 11:13:32 +0200 Subject: [PATCH 15/53] continued with QVariant --- openlp.pyw | 1 + openlp/core/lib/__init__.py | 39 ++++------------- openlp/core/lib/mediamanageritem.py | 6 +-- openlp/core/lib/searchedit.py | 4 +- openlp/core/ui/media/webkitplayer.py | 4 +- openlp/core/ui/servicemanager.py | 25 ++++++----- openlp/core/ui/themeform.py | 42 ++++++++----------- openlp/plugins/alerts/forms/alertform.py | 6 +-- .../plugins/bibles/forms/bibleimportform.py | 16 +++---- openlp/plugins/custom/lib/mediaitem.py | 4 +- openlp/plugins/songs/forms/editsongform.py | 8 ++-- openlp/plugins/songs/forms/songimportform.py | 2 +- .../songs/forms/songmaintenanceform.py | 2 +- openlp/plugins/songs/lib/mediaitem.py | 6 +-- 14 files changed, 67 insertions(+), 98 deletions(-) diff --git a/openlp.pyw b/openlp.pyw index ac7b93051..2117a0584 100755 --- a/openlp.pyw +++ b/openlp.pyw @@ -28,6 +28,7 @@ import sip sip.setapi(u'QString', 2) +sip.setapi(u'QVariant', 2) from openlp.core import main diff --git a/openlp/core/lib/__init__.py b/openlp/core/lib/__init__.py index dd84d1a8c..c453472eb 100644 --- a/openlp/core/lib/__init__.py +++ b/openlp/core/lib/__init__.py @@ -64,23 +64,6 @@ class ServiceItemAction(object): Next = 3 -class MissingTypeConversion(Exception): - """ - A exception class which is used when a setting is not converted. - """ - def __init__(self, msg): - """ - Constructor - """ - self.msg = msg - - def __str__(self): - """ - Returns a string representation. - """ - return repr(self.msg) - - class Settings(QtCore.QSettings): """ This class customises the ``QSettings`` class. You must use this class @@ -109,25 +92,17 @@ class Settings(QtCore.QSettings): **Note**, this method only converts a few types and might need to be extended if a certain type is missing! """ - setting = super(Settings, self).value(key, defaultValue) + # FIXME + if key == u'recent files': + return [] + setting = super(Settings, self).value(key, defaultValue) # Convert the setting to the correct type. if isinstance(defaultValue, bool): - return setting.toBool() - if isinstance(defaultValue, QtCore.QByteArray): - return setting.toByteArray() + return bool(setting) # Enumerations are also taken care of. if isinstance(defaultValue, int): - return setting.toInt()[0] - if isinstance(defaultValue, basestring): - return setting.toString() - if isinstance(defaultValue, list): - return setting.toStringList() - if isinstance(defaultValue, QtCore.QPoint): - return setting.toPoint() - if isinstance(defaultValue, (datetime.date, QtCore.QDate)): - return setting.toDate() - print u'No!', type(defaultValue) - raise MissingTypeConversion(u'Setting could not be converted') + return int(setting) + return setting def translate(context, text, comment=None, diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index 881efb28b..6d6a6cf71 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -622,11 +622,11 @@ class MediaManagerItem(QtGui.QWidget): item = self.listView.currentItem() if item is None: return False - item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0] + item_id = item.data(QtCore.Qt.UserRole) else: item_id = remoteItem else: - item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0] + item_id = item.data(QtCore.Qt.UserRole) return item_id def saveAutoSelectId(self): @@ -637,7 +637,7 @@ class MediaManagerItem(QtGui.QWidget): if self.autoSelectId == -1: item = self.listView.currentItem() if item: - self.autoSelectId = item.data(QtCore.Qt.UserRole).toInt()[0] + self.autoSelectId = item.data(QtCore.Qt.UserRole) def search(self, string, showError=True): """ diff --git a/openlp/core/lib/searchedit.py b/openlp/core/lib/searchedit.py index 22d628dbb..598fe7f72 100644 --- a/openlp/core/lib/searchedit.py +++ b/openlp/core/lib/searchedit.py @@ -121,7 +121,7 @@ class SearchEdit(QtGui.QLineEdit): """ menu = self.menuButton.menu() for action in menu.actions(): - if identifier == action.data().toInt()[0]: + if identifier == action.data(): # setPlaceholderText has been implemented in Qt 4.7 and in at # least PyQt 4.9 (I am not sure, if it was implemented in # PyQt 4.8). @@ -209,7 +209,7 @@ class SearchEdit(QtGui.QLineEdit): for action in self.menuButton.menu().actions(): action.setChecked(False) self.menuButton.setDefaultAction(sender) - self._currentSearchType = sender.data().toInt()[0] + self._currentSearchType = sender.data() # setPlaceholderText has been implemented in Qt 4.7 and in at least # PyQt 4.9 (I am not sure, if it was implemented in PyQt 4.8). try: diff --git a/openlp/core/ui/media/webkitplayer.py b/openlp/core/ui/media/webkitplayer.py index e3713d7ae..406d90a59 100644 --- a/openlp/core/ui/media/webkitplayer.py +++ b/openlp/core/ui/media/webkitplayer.py @@ -407,9 +407,9 @@ class WebkitPlayer(MediaPlayer): controller = display.controller if controller.media_info.is_flash: currentTime = display.frame.evaluateJavaScript( \ - u'show_flash("currentTime");').toInt()[0] + u'show_flash("currentTime");') length = display.frame.evaluateJavaScript( \ - u'show_flash("length");').toInt()[0] + u'show_flash("length");') else: if display.frame.evaluateJavaScript( \ u'show_video("isEnded");').toString() == 'true': diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index ef8152565..b30cbcfae 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -737,9 +737,9 @@ class ServiceManager(QtGui.QWidget): if item is None: return if item.parent(): - pos = item.parent().data(0, QtCore.Qt.UserRole).toInt()[0] + pos = item.parent().data(0, QtCore.Qt.UserRole) else: - pos = item.data(0, QtCore.Qt.UserRole).toInt()[0] + pos = item.data(0, QtCore.Qt.UserRole) serviceItem = self.serviceItems[pos - 1] self.editAction.setVisible(False) self.maintainAction.setVisible(False) @@ -841,7 +841,7 @@ class ServiceManager(QtGui.QWidget): while serviceIterator.value(): if serviceIterator.value() == selected: if message == u'last slide' and prevItemLastSlide: - pos = prevItem.data(0, QtCore.Qt.UserRole).toInt()[0] + pos = prevItem.data(0, QtCore.Qt.UserRole) check_expanded = self.serviceItems[pos - 1][u'expanded'] self.serviceManagerList.setCurrentItem(prevItemLastSlide) if not check_expanded: @@ -908,7 +908,7 @@ class ServiceManager(QtGui.QWidget): Record if an item is collapsed. Used when repainting the list to get the correct state. """ - pos = item.data(0, QtCore.Qt.UserRole).toInt()[0] + pos = item.data(0, QtCore.Qt.UserRole) self.serviceItems[pos - 1][u'expanded'] = False def onExpandAll(self): @@ -924,7 +924,7 @@ class ServiceManager(QtGui.QWidget): Record if an item is collapsed. Used when repainting the list to get the correct state. """ - pos = item.data(0, QtCore.Qt.UserRole).toInt()[0] + pos = item.data(0, QtCore.Qt.UserRole) self.serviceItems[pos - 1][u'expanded'] = True def onServiceTop(self): @@ -1133,10 +1133,9 @@ class ServiceManager(QtGui.QWidget): serviceIterator += 1 if selectedItem is not None: if selectedItem.parent() is None: - pos = selectedItem.data(0, QtCore.Qt.UserRole).toInt()[0] + pos = selectedItem.data(0, QtCore.Qt.UserRole) else: - pos = selectedItem.parent().data(0, QtCore.Qt.UserRole). \ - toInt()[0] + pos = selectedItem.parent().data(0, QtCore.Qt.UserRole) self.serviceItems[pos - 1][u'selected'] = True tempServiceItems = self.serviceItems self.serviceManagerList.clear() @@ -1321,10 +1320,10 @@ class ServiceManager(QtGui.QWidget): for item in items: parentitem = item.parent() if parentitem is None: - serviceItem = item.data(0, QtCore.Qt.UserRole).toInt()[0] + serviceItem = item.data(0, QtCore.Qt.UserRole) else: - serviceItem = parentitem.data(0, QtCore.Qt.UserRole).toInt()[0] - serviceItemChild = item.data(0, QtCore.Qt.UserRole).toInt()[0] + serviceItem = parentitem.data(0, QtCore.Qt.UserRole) + serviceItemChild = item.data(0, QtCore.Qt.UserRole) # Adjust for zero based arrays. serviceItem -= 1 # Only process the first item on the list for this method. @@ -1441,9 +1440,9 @@ class ServiceManager(QtGui.QWidget): def _getParentItemData(self, item): parentitem = item.parent() if parentitem is None: - return item.data(0, QtCore.Qt.UserRole).toInt()[0] + return item.data(0, QtCore.Qt.UserRole) else: - return parentitem.data(0, QtCore.Qt.UserRole).toInt()[0] + return parentitem.data(0, QtCore.Qt.UserRole) def printServiceOrder(self): """ diff --git a/openlp/core/ui/themeform.py b/openlp/core/ui/themeform.py index 25e4c1cf5..3eb70a484 100644 --- a/openlp/core/ui/themeform.py +++ b/openlp/core/ui/themeform.py @@ -551,40 +551,34 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard): log.debug(u'updateTheme') # main page self.theme.font_main_name = self.mainFontComboBox.currentFont().family() - self.theme.font_main_size = self.field(u'mainSizeSpinBox').toInt()[0] - self.theme.font_main_line_adjustment = \ - self.field(u'lineSpacingSpinBox').toInt()[0] - self.theme.font_main_outline_size = \ - self.field(u'outlineSizeSpinBox').toInt()[0] - self.theme.font_main_shadow_size = \ - self.field(u'shadowSizeSpinBox').toInt()[0] + self.theme.font_main_size = self.field(u'mainSizeSpinBox') + self.theme.font_main_line_adjustment = self.field(u'lineSpacingSpinBox') + self.theme.font_main_outline_size = self.field(u'outlineSizeSpinBox') + self.theme.font_main_shadow_size = self.field(u'shadowSizeSpinBox') self.theme.font_main_bold = self.field(u'mainBoldCheckBox').toBool() + # FIXME ? self.theme.font_main_italics = \ self.field(u'mainItalicsCheckBox').toBool() # footer page self.theme.font_footer_name = \ self.footerFontComboBox.currentFont().family() - self.theme.font_footer_size = \ - self.field(u'footerSizeSpinBox').toInt()[0] + self.theme.font_footer_size = self.field(u'footerSizeSpinBox') # position page - self.theme.font_main_x = self.field(u'mainPositionX').toInt()[0] - self.theme.font_main_y = self.field(u'mainPositionY').toInt()[0] - self.theme.font_main_height = \ - self.field(u'mainPositionHeight').toInt()[0] - self.theme.font_main_width = self.field(u'mainPositionWidth').toInt()[0] - self.theme.font_footer_x = self.field(u'footerPositionX').toInt()[0] - self.theme.font_footer_y = self.field(u'footerPositionY').toInt()[0] - self.theme.font_footer_height = \ - self.field(u'footerPositionHeight').toInt()[0] - self.theme.font_footer_width = \ - self.field(u'footerPositionWidth').toInt()[0] + self.theme.font_main_x = self.field(u'mainPositionX') + self.theme.font_main_y = self.field(u'mainPositionY') + self.theme.font_main_height = self.field(u'mainPositionHeight') + self.theme.font_main_width = self.field(u'mainPositionWidth') + #print self.field(u'footerPositionX') + self.theme.font_footer_x = self.field(u'footerPositionX') + self.theme.font_footer_y = self.field(u'footerPositionY') + self.theme.font_footer_height = self.field(u'footerPositionHeight') + self.theme.font_footer_width = self.field(u'footerPositionWidth') # position page self.theme.display_horizontal_align = \ self.horizontalComboBox.currentIndex() - self.theme.display_vertical_align = \ - self.verticalComboBox.currentIndex() - self.theme.display_slide_transition = \ - self.field(u'slideTransition').toBool() + self.theme.display_vertical_align = self.verticalComboBox.currentIndex() + # TODO Check + self.theme.display_slide_transition = self.field(u'slideTransition').toBool() def accept(self): """ diff --git a/openlp/plugins/alerts/forms/alertform.py b/openlp/plugins/alerts/forms/alertform.py index 8f86be7b1..fed001682 100644 --- a/openlp/plugins/alerts/forms/alertform.py +++ b/openlp/plugins/alerts/forms/alertform.py @@ -93,7 +93,7 @@ class AlertForm(QtGui.QDialog, Ui_AlertDialog): """ item = self.alertListWidget.currentItem() if item: - item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0] + item_id = item.data(QtCore.Qt.UserRole) self.manager.delete_object(AlertItem, item_id) row = self.alertListWidget.row(item) self.alertListWidget.takeItem(row) @@ -147,7 +147,7 @@ class AlertForm(QtGui.QDialog, Ui_AlertDialog): bitem = self.alertListWidget.item(item.row()) self.triggerAlert(bitem.text()) self.alertTextEdit.setText(bitem.text()) - self.item_id = (bitem.data(QtCore.Qt.UserRole)).toInt()[0] + self.item_id = bitem.data(QtCore.Qt.UserRole) self.saveButton.setEnabled(False) def onSingleClick(self): @@ -158,7 +158,7 @@ class AlertForm(QtGui.QDialog, Ui_AlertDialog): item = self.alertListWidget.selectedIndexes()[0] bitem = self.alertListWidget.item(item.row()) self.alertTextEdit.setText(bitem.text()) - self.item_id = (bitem.data(QtCore.Qt.UserRole)).toInt()[0] + self.item_id = bitem.data(QtCore.Qt.UserRole) # If the alert does not contain '<>' we clear the ParameterEdit field. if self.alertTextEdit.text().find(u'<>') == -1: self.parameterEdit.setText(u'') diff --git a/openlp/plugins/bibles/forms/bibleimportform.py b/openlp/plugins/bibles/forms/bibleimportform.py index 736cde23b..2a028b23b 100644 --- a/openlp/plugins/bibles/forms/bibleimportform.py +++ b/openlp/plugins/bibles/forms/bibleimportform.py @@ -432,13 +432,13 @@ class BibleImportForm(OpenLPWizard): if self.currentPage() == self.welcomePage: return True elif self.currentPage() == self.selectPage: - if self.field(u'source_format').toInt()[0] == BibleFormat.OSIS: + if self.field(u'source_format') == BibleFormat.OSIS: if not self.field(u'osis_location').toString(): critical_error_message_box(UiStrings().NFSs, WizardStrings.YouSpecifyFile % WizardStrings.OSIS) self.osisFileEdit.setFocus() return False - elif self.field(u'source_format').toInt()[0] == BibleFormat.CSV: + elif self.field(u'source_format') == BibleFormat.CSV: if not self.field(u'csv_booksfile').toString(): critical_error_message_box(UiStrings().NFSs, translate('BiblesPlugin.ImportWizardForm', @@ -453,19 +453,19 @@ class BibleImportForm(OpenLPWizard): 'verses to import.')) self.csvVersesEdit.setFocus() return False - elif self.field(u'source_format').toInt()[0] == \ + elif self.field(u'source_format') == \ BibleFormat.OpenSong: if not self.field(u'opensong_file').toString(): critical_error_message_box(UiStrings().NFSs, WizardStrings.YouSpecifyFile % WizardStrings.OS) self.openSongFileEdit.setFocus() return False - elif self.field(u'source_format').toInt()[0] == \ + elif self.field(u'source_format') == \ BibleFormat.WebDownload: self.versionNameEdit.setText( self.webTranslationComboBox.currentText()) return True - elif self.field(u'source_format').toInt()[0] == BibleFormat.OpenLP1: + elif self.field(u'source_format') == BibleFormat.OpenLP1: if not self.field(u'openlp1_location').toString(): critical_error_message_box(UiStrings().NFSs, WizardStrings.YouSpecifyFile % UiStrings().OLPV1) @@ -643,7 +643,7 @@ class BibleImportForm(OpenLPWizard): Prepare the UI for the import. """ OpenLPWizard.preWizard(self) - bible_type = self.field(u'source_format').toInt()[0] + bible_type = self.field(u'source_format') if bible_type == BibleFormat.WebDownload: self.progressLabel.setText(translate( 'BiblesPlugin.ImportWizardForm', @@ -656,7 +656,7 @@ class BibleImportForm(OpenLPWizard): """ Perform the actual import. """ - bible_type = self.field(u'source_format').toInt()[0] + bible_type = self.field(u'source_format') license_version = self.field(u'license_version').toString() license_copyright = self.field(u'license_copyright').toString() license_permissions = self.field(u'license_permissions').toString() @@ -683,7 +683,7 @@ class BibleImportForm(OpenLPWizard): elif bible_type == BibleFormat.WebDownload: # Import a bible from the web. self.progressBar.setMaximum(1) - download_location = self.field(u'web_location').toInt()[0] + download_location = self.field(u'web_location') bible_version = self.webTranslationComboBox.currentText() bible = self.web_bible_list[download_location][bible_version] importer = self.manager.import_bible( diff --git a/openlp/plugins/custom/lib/mediaitem.py b/openlp/plugins/custom/lib/mediaitem.py index 338dd7201..b407a626e 100644 --- a/openlp/plugins/custom/lib/mediaitem.py +++ b/openlp/plugins/custom/lib/mediaitem.py @@ -160,7 +160,7 @@ class CustomMediaItem(MediaManagerItem): """ if check_item_selected(self.listView, UiStrings().SelectEdit): item = self.listView.currentItem() - item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0] + item_id = item.data(QtCore.Qt.UserRole) self.edit_custom_form.loadCustom(item_id, False) self.edit_custom_form.exec_() self.autoSelectId = -1 @@ -184,7 +184,7 @@ class CustomMediaItem(MediaManagerItem): return row_list = [item.row() for item in self.listView.selectedIndexes()] row_list.sort(reverse=True) - id_list = [(item.data(QtCore.Qt.UserRole)).toInt()[0] + id_list = [(item.data(QtCore.Qt.UserRole)) for item in self.listView.selectedIndexes()] for id in id_list: self.plugin.manager.delete_object(CustomSlide, id) diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index cda715d77..fa38ffec7 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -372,7 +372,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): else: return elif item > 0: - item_id = (self.authorsComboBox.itemData(item)).toInt()[0] + item_id = (self.authorsComboBox.itemData(item)) author = self.manager.get_object(Author, item_id) if self.authorsListView.findItems(unicode(author.display_name), QtCore.Qt.MatchExactly): @@ -427,7 +427,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): else: return elif item > 0: - item_id = (self.topicsComboBox.itemData(item)).toInt()[0] + item_id = (self.topicsComboBox.itemData(item)) topic = self.manager.get_object(Topic, item_id) if self.topicsListView.findItems(unicode(topic.name), QtCore.Qt.MatchExactly): @@ -858,12 +858,12 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): self.song.authors = [] for row in xrange(self.authorsListView.count()): item = self.authorsListView.item(row) - authorId = (item.data(QtCore.Qt.UserRole)).toInt()[0] + authorId = (item.data(QtCore.Qt.UserRole)) self.song.authors.append(self.manager.get_object(Author, authorId)) self.song.topics = [] for row in xrange(self.topicsListView.count()): item = self.topicsListView.item(row) - topicId = (item.data(QtCore.Qt.UserRole)).toInt()[0] + topicId = (item.data(QtCore.Qt.UserRole)) self.song.topics.append(self.manager.get_object(Topic, topicId)) # Save the song here because we need a valid id for the audio files. clean_song(self.manager, self.song) diff --git a/openlp/plugins/songs/forms/songimportform.py b/openlp/plugins/songs/forms/songimportform.py index 2d8322ff3..7123506dc 100644 --- a/openlp/plugins/songs/forms/songimportform.py +++ b/openlp/plugins/songs/forms/songimportform.py @@ -741,7 +741,7 @@ class SongImportForm(OpenLPWizard): self.finishButton.setVisible(False) self.cancelButton.setVisible(True) last_import_type = Settings().value( - u'songs/last import type').toInt()[0] + u'songs/last import type') if last_import_type < 0 or \ last_import_type >= self.formatComboBox.count(): last_import_type = 0 diff --git a/openlp/plugins/songs/forms/songmaintenanceform.py b/openlp/plugins/songs/forms/songmaintenanceform.py index 5df73634c..2f47dcce9 100644 --- a/openlp/plugins/songs/forms/songmaintenanceform.py +++ b/openlp/plugins/songs/forms/songmaintenanceform.py @@ -98,7 +98,7 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): def _getCurrentItemId(self, listWidget): item = listWidget.currentItem() if item: - item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0] + item_id = (item.data(QtCore.Qt.UserRole)) return item_id else: return -1 diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index c822c1281..65724e796 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -381,7 +381,7 @@ class SongMediaItem(MediaManagerItem): log.debug(u'onEditClick') if check_item_selected(self.listView, UiStrings().SelectEdit): self.editItem = self.listView.currentItem() - item_id = (self.editItem.data(QtCore.Qt.UserRole)).toInt()[0] + item_id = self.editItem.data(QtCore.Qt.UserRole) self.editSongForm.loadSong(item_id, False) self.editSongForm.exec_() self.autoSelectId = -1 @@ -406,7 +406,7 @@ class SongMediaItem(MediaManagerItem): Receiver.send_message(u'cursor_busy') self.plugin.formParent.displayProgressBar(len(items)) for item in items: - item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0] + item_id = item.data(QtCore.Qt.UserRole) media_files = self.plugin.manager.get_all_objects(MediaFile, MediaFile.song_id == item_id) for media_file in media_files: @@ -435,7 +435,7 @@ class SongMediaItem(MediaManagerItem): log.debug(u'onCloneClick') if check_item_selected(self.listView, UiStrings().SelectEdit): self.editItem = self.listView.currentItem() - item_id = (self.editItem.data(QtCore.Qt.UserRole)).toInt()[0] + item_id = self.editItem.data(QtCore.Qt.UserRole) old_song = self.plugin.manager.get_object(Song, item_id) song_xml = self.openLyrics.song_to_xml(old_song) new_song = self.openLyrics.xml_to_song(song_xml) From a085694be152c2d66eb1ee960898b1ccb4ddf493 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sat, 19 May 2012 17:10:05 +0200 Subject: [PATCH 16/53] removed toString(), toPyObject() --- openlp.pyw | 6 ++++ openlp/core/lib/__init__.py | 11 +++--- openlp/core/lib/mediamanageritem.py | 4 +-- openlp/core/ui/firsttimeform.py | 16 ++++----- openlp/core/ui/maindisplay.py | 4 +-- openlp/core/ui/mainwindow.py | 5 ++- openlp/core/ui/media/webkitplayer.py | 2 +- openlp/core/ui/shortcutlistform.py | 30 ++++++++-------- openlp/core/ui/themeform.py | 8 ++--- openlp/core/ui/thememanager.py | 20 +++++------ openlp/core/utils/languagemanager.py | 10 +++--- .../plugins/bibles/forms/bibleimportform.py | 36 +++++++++---------- openlp/plugins/bibles/lib/mediaitem.py | 14 +++----- openlp/plugins/images/lib/mediaitem.py | 6 ++-- openlp/plugins/media/lib/mediaitem.py | 4 +-- openlp/plugins/media/mediaplugin.py | 2 +- openlp/plugins/presentations/lib/mediaitem.py | 5 ++- openlp/plugins/remotes/lib/httpserver.py | 2 +- openlp/plugins/remotes/lib/remotetab.py | 15 ++++---- openlp/plugins/songs/forms/editsongform.py | 14 ++++---- openlp/plugins/songs/forms/editverseform.py | 10 +++--- openlp/plugins/songs/forms/mediafilesform.py | 2 +- openlp/plugins/songs/forms/songexportform.py | 5 ++- 23 files changed, 113 insertions(+), 118 deletions(-) diff --git a/openlp.pyw b/openlp.pyw index 2117a0584..0b225ded0 100755 --- a/openlp.pyw +++ b/openlp.pyw @@ -27,9 +27,15 @@ ############################################################################### import sip +sip.setapi(u'QDate', 2) +sip.setapi(u'QDateTime', 2) sip.setapi(u'QString', 2) +sip.setapi(u'QTextStream', 2) +sip.setapi(u'QTime', 2) +sip.setapi(u'QUrl', 2) sip.setapi(u'QVariant', 2) + from openlp.core import main diff --git a/openlp/core/lib/__init__.py b/openlp/core/lib/__init__.py index c453472eb..d723a6b2f 100644 --- a/openlp/core/lib/__init__.py +++ b/openlp/core/lib/__init__.py @@ -92,19 +92,18 @@ class Settings(QtCore.QSettings): **Note**, this method only converts a few types and might need to be extended if a certain type is missing! """ - # FIXME - if key == u'recent files': - return [] setting = super(Settings, self).value(key, defaultValue) + # An empty list saved to the settings results ins a None type being + # returned. + if setting is None: + return [] # Convert the setting to the correct type. if isinstance(defaultValue, bool): - return bool(setting) - # Enumerations are also taken care of. + return setting == u'true' if isinstance(defaultValue, int): return int(setting) return setting - def translate(context, text, comment=None, encoding=QtCore.QCoreApplication.CodecForTr, n=-1, translate=QtCore.QCoreApplication.translate): diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index 6d6a6cf71..2f17984be 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -380,7 +380,7 @@ class MediaManagerItem(QtGui.QWidget): for count in range(self.listView.count()): names.append(self.listView.item(count).text()) fullList.append(self.listView.item(count). - data(QtCore.Qt.UserRole).toString()) + data(QtCore.Qt.UserRole)) duplicatesFound = False filesAdded = False for file in files: @@ -420,7 +420,7 @@ class MediaManagerItem(QtGui.QWidget): filelist = [] while count < self.listView.count(): bitem = self.listView.item(count) - filename = bitem.data(QtCore.Qt.UserRole).toString() + filename = bitem.data(QtCore.Qt.UserRole) filelist.append(filename) count += 1 return filelist diff --git a/openlp/core/ui/firsttimeform.py b/openlp/core/ui/firsttimeform.py index 1e7aa366e..1daf0cd40 100644 --- a/openlp/core/ui/firsttimeform.py +++ b/openlp/core/ui/firsttimeform.py @@ -133,7 +133,7 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): language = unicode(self.config.get( u'bibles_%s' % lang, u'title'), u'utf8') langItem = QtGui.QTreeWidgetItem( - self.biblesTreeWidget, language) + self.biblesTreeWidget, [language]) bibles = self.config.get(u'bibles_%s' % lang, u'translations') bibles = bibles.split(u',') for bible in bibles: @@ -141,7 +141,7 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): u'bible_%s' % bible, u'title'), u'utf8') filename = unicode(self.config.get( u'bible_%s' % bible, u'filename')) - item = QtGui.QTreeWidgetItem(langItem, title) + item = QtGui.QTreeWidgetItem(langItem, [title]) item.setData(0, QtCore.Qt.UserRole, filename) item.setCheckState(0, QtCore.Qt.Unchecked) item.setFlags(item.flags() | QtCore.Qt.ItemIsUserCheckable) @@ -332,7 +332,7 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): for i in xrange(self.songsListWidget.count()): item = self.songsListWidget.item(i) if item.checkState() == QtCore.Qt.Checked: - filename = item.data(QtCore.Qt.UserRole).toString() + filename = item.data(QtCore.Qt.UserRole) size = self._getFileSize(u'%s%s' % (self.web, filename)) self.max_progress += size # Loop through the Bibles list and increase for each selected item @@ -340,7 +340,7 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): while iterator.value(): item = iterator.value() if item.parent() and item.checkState(0) == QtCore.Qt.Checked: - filename = item.data(0, QtCore.Qt.UserRole).toString() + filename = item.data(0, QtCore.Qt.UserRole) size = self._getFileSize(u'%s%s' % (self.web, filename)) self.max_progress += size iterator += 1 @@ -348,7 +348,7 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): for i in xrange(self.themesListWidget.count()): item = self.themesListWidget.item(i) if item.checkState() == QtCore.Qt.Checked: - filename = item.data(QtCore.Qt.UserRole).toString() + filename = item.data(QtCore.Qt.UserRole) size = self._getFileSize(u'%s%s' % (self.web, filename)) self.max_progress += size if self.max_progress: @@ -421,7 +421,7 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): for i in xrange(self.songsListWidget.count()): item = self.songsListWidget.item(i) if item.checkState() == QtCore.Qt.Checked: - filename = item.data(QtCore.Qt.UserRole).toString() + filename = item.data(QtCore.Qt.UserRole) self._incrementProgressBar(self.downloading % filename, 0) self.previous_size = 0 destination = os.path.join(songs_destination, @@ -433,7 +433,7 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): while bibles_iterator.value(): item = bibles_iterator.value() if item.parent() and item.checkState(0) == QtCore.Qt.Checked: - bible = item.data(0, QtCore.Qt.UserRole).toString() + bible = item.data(0, QtCore.Qt.UserRole) self._incrementProgressBar(self.downloading % bible, 0) self.previous_size = 0 self.urlGetFile(u'%s%s' % (self.web, bible), @@ -443,7 +443,7 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): for i in xrange(self.themesListWidget.count()): item = self.themesListWidget.item(i) if item.checkState() == QtCore.Qt.Checked: - theme = item.data(QtCore.Qt.UserRole).toString() + theme = item.data(QtCore.Qt.UserRole) self._incrementProgressBar(self.downloading % theme, 0) self.previous_size = 0 self.urlGetFile(u'%s%s' % (self.web, theme), diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index 34d5434ec..1dcffaebe 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -257,7 +257,7 @@ class MainDisplay(Display): height = self.frame.evaluateJavaScript(js) if shrink: if text: - alert_height = int(height.toString()) + alert_height = int(height) self.resize(self.width(), alert_height) self.setVisible(True) if location == AlertLocation.Middle: @@ -335,7 +335,7 @@ class MainDisplay(Display): if self.serviceItem.themedata and \ self.serviceItem.themedata.display_slide_transition: while self.frame.evaluateJavaScript(u'show_text_complete()') \ - .toString() == u'false': + == u'false': Receiver.send_message(u'openlp_process_events') # Wait for the webview to update before getting the preview. # Important otherwise first preview will miss the background ! diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 273041311..0fb410ce1 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -1308,7 +1308,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): settings.remove(u'custom slide') settings.remove(u'service') settings.beginGroup(self.generalSettingsSection) - self.recentFiles = settings.value(u'recent files', list()) + self.recentFiles = settings.value(u'recent files', self.recentFiles) settings.endGroup() settings.beginGroup(self.uiSettingsSection) self.move(settings.value(u'main window position', QtCore.QPoint(0, 0))) @@ -1334,8 +1334,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): log.debug(u'Saving QSettings') settings = Settings() settings.beginGroup(self.generalSettingsSection) - settings.setValue( - u'recent files', self.recentFiles if self.recentFiles else list()) + settings.setValue(u'recent files', self.recentFiles) settings.endGroup() settings.beginGroup(self.uiSettingsSection) settings.setValue(u'main window position', self.pos()) diff --git a/openlp/core/ui/media/webkitplayer.py b/openlp/core/ui/media/webkitplayer.py index 406d90a59..f01f154e8 100644 --- a/openlp/core/ui/media/webkitplayer.py +++ b/openlp/core/ui/media/webkitplayer.py @@ -412,7 +412,7 @@ class WebkitPlayer(MediaPlayer): u'show_flash("length");') else: if display.frame.evaluateJavaScript( \ - u'show_video("isEnded");').toString() == 'true': + u'show_video("isEnded");') == 'true': self.stop(display) (currentTime, ok) = display.frame.evaluateJavaScript( \ u'show_video("currentTime");').toFloat() diff --git a/openlp/core/ui/shortcutlistform.py b/openlp/core/ui/shortcutlistform.py index fe62f3d16..2d998cd9b 100644 --- a/openlp/core/ui/shortcutlistform.py +++ b/openlp/core/ui/shortcutlistform.py @@ -89,7 +89,7 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): if key == QtCore.Qt.Key_Shift or key == QtCore.Qt.Key_Control or \ key == QtCore.Qt.Key_Meta or key == QtCore.Qt.Key_Alt: return - key_string = QtGui.QKeySequence(key).toString() + key_string = QtGui.QKeySequence(key) if event.modifiers() & QtCore.Qt.ControlModifier == \ QtCore.Qt.ControlModifier: key_string = u'Ctrl+' + key_string @@ -105,10 +105,10 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): if self._validiate_shortcut(self._currentItemAction(), key_sequence): if self.primaryPushButton.isChecked(): self._adjustButton(self.primaryPushButton, - False, text=key_sequence.toString()) + False, text=key_sequence) elif self.alternatePushButton.isChecked(): self._adjustButton(self.alternatePushButton, - False, text=key_sequence.toString()) + False, text=key_sequence) def exec_(self): self.changedActions = {} @@ -154,11 +154,11 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): item.setText(1, u'') item.setText(2, u'') elif len(shortcuts) == 1: - item.setText(1, shortcuts[0].toString()) + item.setText(1, shortcuts[0]) item.setText(2, u'') else: - item.setText(1, shortcuts[0].toString()) - item.setText(2, shortcuts[1].toString()) + item.setText(1, shortcuts[0]) + item.setText(2, shortcuts[1]) self.onCurrentItemChanged() def onPrimaryPushButtonClicked(self, toggled): @@ -241,9 +241,9 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): self.alternatePushButton.setChecked(False) else: if action.defaultShortcuts: - primary_label_text = action.defaultShortcuts[0].toString() + primary_label_text = action.defaultShortcuts[0] if len(action.defaultShortcuts) == 2: - alternate_label_text = action.defaultShortcuts[1].toString() + alternate_label_text = action.defaultShortcuts[1] shortcuts = self._actionShortcuts(action) # We do not want to loose pending changes, that is why we have to # keep the text when, this function has not been triggered by a @@ -252,10 +252,10 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): primary_text = self.primaryPushButton.text() alternate_text = self.alternatePushButton.text() elif len(shortcuts) == 1: - primary_text = shortcuts[0].toString() + primary_text = shortcuts[0] elif len(shortcuts) == 2: - primary_text = shortcuts[0].toString() - alternate_text = shortcuts[1].toString() + primary_text = shortcuts[0] + alternate_text = shortcuts[1] # When we are capturing a new shortcut, we do not want, the buttons to # display the current shortcut. if self.primaryPushButton.isChecked(): @@ -313,9 +313,9 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): primary_button_text = u'' alternate_button_text = u'' if temp_shortcuts: - primary_button_text = temp_shortcuts[0].toString() + primary_button_text = temp_shortcuts[0] if len(temp_shortcuts) == 2: - alternate_button_text = temp_shortcuts[1].toString() + alternate_button_text = temp_shortcuts[1] self.primaryPushButton.setText(primary_button_text) self.alternatePushButton.setText(alternate_button_text) @@ -443,7 +443,7 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): 'Duplicate Shortcut'), u'message': translate('OpenLP.ShortcutListDialog', 'The shortcut "%s" is already assigned to another action, ' - 'please use a different shortcut.') % key_sequence.toString() + 'please use a different shortcut.') % key_sequence }) return is_valid @@ -466,7 +466,7 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): item = self.treeWidget.currentItem() if item is None: return - return item.data(0, QtCore.Qt.UserRole).toPyObject() + return item.data(0, QtCore.Qt.UserRole) def _adjustButton(self, button, checked=None, enabled=None, text=None): """ diff --git a/openlp/core/ui/themeform.py b/openlp/core/ui/themeform.py index 3eb70a484..017285888 100644 --- a/openlp/core/ui/themeform.py +++ b/openlp/core/ui/themeform.py @@ -555,10 +555,10 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard): self.theme.font_main_line_adjustment = self.field(u'lineSpacingSpinBox') self.theme.font_main_outline_size = self.field(u'outlineSizeSpinBox') self.theme.font_main_shadow_size = self.field(u'shadowSizeSpinBox') - self.theme.font_main_bold = self.field(u'mainBoldCheckBox').toBool() + self.theme.font_main_bold = self.field(u'mainBoldCheckBox') # FIXME ? self.theme.font_main_italics = \ - self.field(u'mainItalicsCheckBox').toBool() + self.field(u'mainItalicsCheckBox') # footer page self.theme.font_footer_name = \ self.footerFontComboBox.currentFont().family() @@ -578,14 +578,14 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard): self.horizontalComboBox.currentIndex() self.theme.display_vertical_align = self.verticalComboBox.currentIndex() # TODO Check - self.theme.display_slide_transition = self.field(u'slideTransition').toBool() + self.theme.display_slide_transition = self.field(u'slideTransition') def accept(self): """ Lets save the theme as Finish has been triggered """ # Save the theme name - self.theme.theme_name = self.field(u'name').toString() + self.theme.theme_name = self.field(u'name') if not self.theme.theme_name: critical_error_message_box( translate('OpenLP.ThemeForm', 'Theme Name Missing'), diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index b153310d5..8ab15ba2a 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -173,7 +173,7 @@ class ThemeManager(QtGui.QWidget): """ if item is None: return - real_theme_name = item.data(QtCore.Qt.UserRole).toString() + real_theme_name = item.data(QtCore.Qt.UserRole) theme_name = item.text() # If default theme restrict actions if real_theme_name == theme_name: @@ -189,7 +189,7 @@ class ThemeManager(QtGui.QWidget): item = self.themeListWidget.itemAt(point) if item is None: return - real_theme_name = item.data(QtCore.Qt.UserRole).toString() + real_theme_name = item.data(QtCore.Qt.UserRole) theme_name = item.text() self.deleteAction.setVisible(False) self.renameAction.setVisible(False) @@ -211,7 +211,7 @@ class ThemeManager(QtGui.QWidget): # reset the old name item = self.themeListWidget.item(count) old_name = item.text() - new_name = item.data(QtCore.Qt.UserRole).toString() + new_name = item.data(QtCore.Qt.UserRole) if old_name != new_name: self.themeListWidget.item(count).setText(new_name) # Set the new name @@ -233,9 +233,9 @@ class ThemeManager(QtGui.QWidget): item = self.themeListWidget.item(count) old_name = item.text() # reset the old name - if old_name != item.data(QtCore.Qt.UserRole).toString(): + if old_name != item.data(QtCore.Qt.UserRole): self.themeListWidget.item(count).setText( - item.data(QtCore.Qt.UserRole).toString()) + item.data(QtCore.Qt.UserRole)) # Set the new name if count == selected_row: self.global_theme = self.themeListWidget.item(count).text() @@ -267,7 +267,7 @@ class ThemeManager(QtGui.QWidget): translate('OpenLP.ThemeManager', 'Rename %s theme?'), False, False): item = self.themeListWidget.currentItem() - old_theme_name = item.data(QtCore.Qt.UserRole).toString() + old_theme_name = item.data(QtCore.Qt.UserRole) self.fileRenameForm.fileNameEdit.setText(old_theme_name) if self.fileRenameForm.exec_(): new_theme_name = self.fileRenameForm.fileNameEdit.text() @@ -287,7 +287,7 @@ class ThemeManager(QtGui.QWidget): Copies an existing theme to a new name """ item = self.themeListWidget.currentItem() - old_theme_name = item.data(QtCore.Qt.UserRole).toString() + old_theme_name = item.data(QtCore.Qt.UserRole) self.fileRenameForm.fileNameEdit.setText( translate('OpenLP.ThemeManager', 'Copy of %s', 'Copy of ') % old_theme_name) @@ -321,7 +321,7 @@ class ThemeManager(QtGui.QWidget): translate('OpenLP.ThemeManager', 'You must select a theme to edit.')): item = self.themeListWidget.currentItem() - theme = self.getThemeData(item.data(QtCore.Qt.UserRole).toString()) + theme = self.getThemeData(item.data(QtCore.Qt.UserRole)) if theme.background_type == u'image': self.old_background_image = theme.background_filename self.themeForm.theme = theme @@ -371,7 +371,7 @@ class ThemeManager(QtGui.QWidget): critical_error_message_box(message=translate('OpenLP.ThemeManager', 'You have not selected a theme.')) return - theme = item.data(QtCore.Qt.UserRole).toString() + theme = item.data(QtCore.Qt.UserRole) path = QtGui.QFileDialog.getExistingDirectory(self, translate('OpenLP.ThemeManager', 'Save Theme - (%s)') % theme, SettingsManager.get_last_dir(self.settingsSection, 1)) @@ -775,7 +775,7 @@ class ThemeManager(QtGui.QWidget): if answer == QtGui.QMessageBox.No: return False # should be the same unless default - if theme != item.data(QtCore.Qt.UserRole).toString(): + if theme != item.data(QtCore.Qt.UserRole): critical_error_message_box( message=translate('OpenLP.ThemeManager', 'You are unable to delete the default theme.')) diff --git a/openlp/core/utils/languagemanager.py b/openlp/core/utils/languagemanager.py index 21ccffbc1..6de5b2b42 100644 --- a/openlp/core/utils/languagemanager.py +++ b/openlp/core/utils/languagemanager.py @@ -29,6 +29,7 @@ The :mod:`languagemanager` module provides all the translation settings and language file loading for OpenLP. """ import logging +import re import sys from PyQt4 import QtCore, QtGui @@ -104,13 +105,12 @@ class LanguageManager(object): """ Retrieve a saved language to use from settings """ - settings = Settings() - language = settings.value(u'general/language', u'[en]') + language = Settings().value(u'general/language', u'[en]') + language = str(language) log.info(u'Language file: \'%s\' Loaded from conf file' % language) - reg_ex = QtCore.QRegExp("^\[(.*)\]") - if reg_ex.exactMatch(language): + if re.match(r'[[].*[]]', language): LanguageManager.auto_language = True - language = reg_ex.cap(1) + language = re.sub(r'[\[\]]', '', language) return language @staticmethod diff --git a/openlp/plugins/bibles/forms/bibleimportform.py b/openlp/plugins/bibles/forms/bibleimportform.py index 2a028b23b..5b164a1d0 100644 --- a/openlp/plugins/bibles/forms/bibleimportform.py +++ b/openlp/plugins/bibles/forms/bibleimportform.py @@ -433,20 +433,20 @@ class BibleImportForm(OpenLPWizard): return True elif self.currentPage() == self.selectPage: if self.field(u'source_format') == BibleFormat.OSIS: - if not self.field(u'osis_location').toString(): + if not self.field(u'osis_location'): critical_error_message_box(UiStrings().NFSs, WizardStrings.YouSpecifyFile % WizardStrings.OSIS) self.osisFileEdit.setFocus() return False elif self.field(u'source_format') == BibleFormat.CSV: - if not self.field(u'csv_booksfile').toString(): + if not self.field(u'csv_booksfile'): critical_error_message_box(UiStrings().NFSs, translate('BiblesPlugin.ImportWizardForm', 'You need to specify a file with books of ' 'the Bible to use in the import.')) self.csvBooksEdit.setFocus() return False - elif not self.field(u'csv_versefile').toString(): + elif not self.field(u'csv_versefile'): critical_error_message_box(UiStrings().NFSs, translate('BiblesPlugin.ImportWizardForm', 'You need to specify a file of Bible ' @@ -455,7 +455,7 @@ class BibleImportForm(OpenLPWizard): return False elif self.field(u'source_format') == \ BibleFormat.OpenSong: - if not self.field(u'opensong_file').toString(): + if not self.field(u'opensong_file'): critical_error_message_box(UiStrings().NFSs, WizardStrings.YouSpecifyFile % WizardStrings.OS) self.openSongFileEdit.setFocus() @@ -466,15 +466,15 @@ class BibleImportForm(OpenLPWizard): self.webTranslationComboBox.currentText()) return True elif self.field(u'source_format') == BibleFormat.OpenLP1: - if not self.field(u'openlp1_location').toString(): + if not self.field(u'openlp1_location'): critical_error_message_box(UiStrings().NFSs, WizardStrings.YouSpecifyFile % UiStrings().OLPV1) self.openlp1FileEdit.setFocus() return False return True elif self.currentPage() == self.licenseDetailsPage: - license_version = self.field(u'license_version').toString() - license_copyright = self.field(u'license_copyright').toString() + license_version = self.field(u'license_version') + license_copyright = self.field(u'license_copyright') path = AppLocation.get_section_data_path(u'bibles') if not license_version: critical_error_message_box(UiStrings().EmptyField, @@ -657,28 +657,28 @@ class BibleImportForm(OpenLPWizard): Perform the actual import. """ bible_type = self.field(u'source_format') - license_version = self.field(u'license_version').toString() - license_copyright = self.field(u'license_copyright').toString() - license_permissions = self.field(u'license_permissions').toString() + license_version = self.field(u'license_version') + license_copyright = self.field(u'license_copyright') + license_permissions = self.field(u'license_permissions') importer = None if bible_type == BibleFormat.OSIS: # Import an OSIS bible. importer = self.manager.import_bible(BibleFormat.OSIS, name=license_version, - filename=self.field(u'osis_location').toString() + filename=self.field(u'osis_location') ) elif bible_type == BibleFormat.CSV: # Import a CSV bible. importer = self.manager.import_bible(BibleFormat.CSV, name=license_version, - booksfile=self.field(u'csv_booksfile').toString(), - versefile=self.field(u'csv_versefile').toString() + booksfile=self.field(u'csv_booksfile'), + versefile=self.field(u'csv_versefile') ) elif bible_type == BibleFormat.OpenSong: # Import an OpenSong bible. importer = self.manager.import_bible(BibleFormat.OpenSong, name=license_version, - filename=self.field(u'opensong_file').toString() + filename=self.field(u'opensong_file') ) elif bible_type == BibleFormat.WebDownload: # Import a bible from the web. @@ -690,15 +690,15 @@ class BibleImportForm(OpenLPWizard): BibleFormat.WebDownload, name=license_version, download_source=WebDownload.Names[download_location], download_name=bible, - proxy_server=self.field(u'proxy_server').toString(), - proxy_username=self.field(u'proxy_username').toString(), - proxy_password=self.field(u'proxy_password').toString() + proxy_server=self.field(u'proxy_server'), + proxy_username=self.field(u'proxy_username'), + proxy_password=self.field(u'proxy_password') ) elif bible_type == BibleFormat.OpenLP1: # Import an openlp.org 1.x bible. importer = self.manager.import_bible(BibleFormat.OpenLP1, name=license_version, - filename=self.field(u'openlp1_location').toString() + filename=self.field(u'openlp1_location') ) if importer.do_import(license_version): self.manager.save_meta_data(license_version, license_version, diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index 174ec2e22..1dd688759 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -99,11 +99,7 @@ class BibleMediaItem(MediaManagerItem): def _decodeQtObject(self, bitem, key): reference = bitem.data(QtCore.Qt.UserRole) - if isinstance(reference, QtCore.QVariant): - reference = reference.toPyObject() obj = reference[unicode(key)] - if isinstance(obj, QtCore.QVariant): - obj = obj.toPyObject() return unicode(obj).strip() def requiredIcons(self): @@ -624,7 +620,7 @@ class BibleMediaItem(MediaManagerItem): self.initialiseChapterVerse( self.advancedVersionComboBox.currentText(), self.advancedBookComboBox.currentText(), - self.advancedBookComboBox.itemData(item).toString()) + self.advancedBookComboBox.itemData(item)) def onAdvancedFromVerse(self): chapter_from = int(self.advancedFromChapter.currentText()) @@ -632,7 +628,7 @@ class BibleMediaItem(MediaManagerItem): if chapter_from == chapter_to: bible = self.advancedVersionComboBox.currentText() book_ref_id = self.advancedBookComboBox.itemData( - int(self.advancedBookComboBox.currentIndex())).toString() + int(self.advancedBookComboBox.currentIndex())) verse_from = int(self.advancedFromVerse.currentText()) verse_count = self.plugin.manager.get_verse_count_by_book_ref_id( bible, book_ref_id, chapter_to) @@ -642,7 +638,7 @@ class BibleMediaItem(MediaManagerItem): def onAdvancedToChapter(self): bible = self.advancedVersionComboBox.currentText() book_ref_id = self.advancedBookComboBox.itemData( - int(self.advancedBookComboBox.currentIndex())).toString() + int(self.advancedBookComboBox.currentIndex())) chapter_from = int(self.advancedFromChapter.currentText()) chapter_to = int(self.advancedToChapter.currentText()) verse_from = int(self.advancedFromVerse.currentText()) @@ -657,7 +653,7 @@ class BibleMediaItem(MediaManagerItem): def onAdvancedFromChapter(self): bible = self.advancedVersionComboBox.currentText() book_ref_id = self.advancedBookComboBox.itemData( - int(self.advancedBookComboBox.currentIndex())).toString() + int(self.advancedBookComboBox.currentIndex())) chapter_from = int(self.advancedFromChapter.currentText()) chapter_to = int(self.advancedToChapter.currentText()) verse_count = self.plugin.manager.get_verse_count_by_book_ref_id(bible, @@ -711,7 +707,7 @@ class BibleMediaItem(MediaManagerItem): second_bible = self.advancedSecondComboBox.currentText() book = self.advancedBookComboBox.currentText() book_ref_id = self.advancedBookComboBox.itemData( - int(self.advancedBookComboBox.currentIndex())).toString() + int(self.advancedBookComboBox.currentIndex())) chapter_from = self.advancedFromChapter.currentText() chapter_to = self.advancedToChapter.currentText() verse_from = self.advancedFromVerse.currentText() diff --git a/openlp/plugins/images/lib/mediaitem.py b/openlp/plugins/images/lib/mediaitem.py index b318ed55d..d1f5015af 100644 --- a/openlp/plugins/images/lib/mediaitem.py +++ b/openlp/plugins/images/lib/mediaitem.py @@ -168,7 +168,7 @@ class ImageMediaItem(MediaManagerItem): missing_items = [] missing_items_filenames = [] for bitem in items: - filename = bitem.data(QtCore.Qt.UserRole).toString() + filename = bitem.data(QtCore.Qt.UserRole) if not os.path.exists(filename): missing_items.append(bitem) missing_items_filenames.append(filename) @@ -194,7 +194,7 @@ class ImageMediaItem(MediaManagerItem): return False # Continue with the existing images. for bitem in items: - filename = bitem.data(QtCore.Qt.UserRole).toString() + filename = bitem.data(QtCore.Qt.UserRole) name = os.path.split(filename)[1] service_item.add_from_image(filename, name, background) return True @@ -223,7 +223,7 @@ class ImageMediaItem(MediaManagerItem): self.settingsSection + u'/background color', u'#000000')) item = self.listView.selectedIndexes()[0] bitem = self.listView.item(item.row()) - filename = bitem.data(QtCore.Qt.UserRole).toString() + filename = bitem.data(QtCore.Qt.UserRole) if os.path.exists(filename): name = os.path.split(filename)[1] if self.plugin.liveController.display.directImage(name, diff --git a/openlp/plugins/media/lib/mediaitem.py b/openlp/plugins/media/lib/mediaitem.py index 15cd5e6aa..535f9ebf2 100644 --- a/openlp/plugins/media/lib/mediaitem.py +++ b/openlp/plugins/media/lib/mediaitem.py @@ -170,7 +170,7 @@ class MediaMediaItem(MediaManagerItem): translate('MediaPlugin.MediaItem', 'You must select a media file to replace the background with.')): item = self.listView.currentItem() - filename = item.data(QtCore.Qt.UserRole).toString() + filename = item.data(QtCore.Qt.UserRole) if os.path.exists(filename): if self.plugin.liveController.mediaController.video( \ self.plugin.liveController, filename, True, True): @@ -191,7 +191,7 @@ class MediaMediaItem(MediaManagerItem): item = self.listView.currentItem() if item is None: return False - filename = item.data(QtCore.Qt.UserRole).toString() + filename = item.data(QtCore.Qt.UserRole) if not os.path.exists(filename): if not remote: # File is no longer present diff --git a/openlp/plugins/media/mediaplugin.py b/openlp/plugins/media/mediaplugin.py index 954ab8d00..07d72df66 100644 --- a/openlp/plugins/media/mediaplugin.py +++ b/openlp/plugins/media/mediaplugin.py @@ -133,7 +133,7 @@ class MediaPlugin(Plugin): log.info(u'Found old Phonon setting') players = self.mediaController.mediaPlayers.keys() has_phonon = u'phonon' in players - if settings.value(u'use phonon').toBool() and has_phonon: + if settings.value(u'use phonon') and has_phonon: log.debug(u'Converting old setting to new setting') new_players = [] if players: diff --git a/openlp/plugins/presentations/lib/mediaitem.py b/openlp/plugins/presentations/lib/mediaitem.py index 1bfb4f123..966d89fc4 100644 --- a/openlp/plugins/presentations/lib/mediaitem.py +++ b/openlp/plugins/presentations/lib/mediaitem.py @@ -231,8 +231,7 @@ class PresentationMediaItem(MediaManagerItem): Receiver.send_message(u'cursor_busy') self.plugin.formParent.displayProgressBar(len(row_list)) for item in items: - filepath = unicode(item.data( - QtCore.Qt.UserRole).toString()) + filepath = unicode(item.data(QtCore.Qt.UserRole)) for cidx in self.controllers: doc = self.controllers[cidx].add_document(filepath) doc.presentation_deleted() @@ -266,7 +265,7 @@ class PresentationMediaItem(MediaManagerItem): if not shortname: return False for bitem in items: - filename = bitem.data(QtCore.Qt.UserRole).toString() + filename = bitem.data(QtCore.Qt.UserRole) if os.path.exists(filename): if shortname == self.Automatic: service_item.shortname = self.findControllerByType(filename) diff --git a/openlp/plugins/remotes/lib/httpserver.py b/openlp/plugins/remotes/lib/httpserver.py index ecd1b6b0d..56ba1fe9f 100644 --- a/openlp/plugins/remotes/lib/httpserver.py +++ b/openlp/plugins/remotes/lib/httpserver.py @@ -233,7 +233,7 @@ class HttpConnection(object): Initialise the http connection. Listen out for socket signals. """ log.debug(u'Initialise HttpConnection: %s' % - socket.peerAddress().toString()) + socket.peerAddress()) self.socket = socket self.parent = parent self.routes = [ diff --git a/openlp/plugins/remotes/lib/remotetab.py b/openlp/plugins/remotes/lib/remotetab.py index be08bb500..9c1de5cc6 100644 --- a/openlp/plugins/remotes/lib/remotetab.py +++ b/openlp/plugins/remotes/lib/remotetab.py @@ -138,7 +138,7 @@ class RemoteTab(SettingsTab): ip = addr.ip() if ip.protocol() == 0 and \ ip != QtNetwork.QHostAddress.LocalHost: - ipAddress = ip.toString() + ipAddress = ip break else: ipAddress = self.addressEdit.text() @@ -149,11 +149,9 @@ class RemoteTab(SettingsTab): def load(self): self.portSpinBox.setValue( - Settings().value(self.settingsSection + u'/port', - 4316)) + Settings().value(self.settingsSection + u'/port', 4316)) self.addressEdit.setText( - Settings().value(self.settingsSection + u'/ip address', - ZERO_URL)) + Settings().value(self.settingsSection + u'/ip address', ZERO_URL)) self.twelveHour = Settings().value( self.settingsSection + u'/twelve hour', True) self.twelveHourCheckBox.setChecked(self.twelveHour) @@ -161,10 +159,9 @@ class RemoteTab(SettingsTab): def save(self): changed = False - if Settings().value(self.settingsSection + u'/ip address', - ZERO_URL != self.addressEdit.text() or - Settings().value(self.settingsSection + u'/port', - 4316) != self.portSpinBox.value()): + if Settings().value(self.settingsSection + u'/ip address', ZERO_URL != + self.addressEdit.text() or Settings().value(self.settingsSection + + u'/port', 4316) != self.portSpinBox.value()): changed = True Settings().setValue(self.settingsSection + u'/port', self.portSpinBox.value()) diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index fa38ffec7..617cce5f4 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -336,7 +336,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): row_label = [] for row in range(self.verseListWidget.rowCount()): item = self.verseListWidget.item(row, 0) - verse_def = item.data(QtCore.Qt.UserRole).toString() + verse_def = item.data(QtCore.Qt.UserRole) verse_tag = VerseType.translated_tag(verse_def[0]) row_def = u'%s%s' % (verse_tag, verse_def[1:]) row_label.append(row_def) @@ -479,7 +479,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): item = self.verseListWidget.currentItem() if item: tempText = item.text() - verseId = item.data(QtCore.Qt.UserRole).toString() + verseId = item.data(QtCore.Qt.UserRole) self.verseForm.setVerse(tempText, True, verseId) if self.verseForm.exec_(): after_text, verse_tag, verse_num = self.verseForm.getVerse() @@ -509,7 +509,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): if self.verseListWidget.rowCount() > 0: for row in range(self.verseListWidget.rowCount()): item = self.verseListWidget.item(row, 0) - field = item.data(QtCore.Qt.UserRole).toString() + field = item.data(QtCore.Qt.UserRole) verse_tag = VerseType.translated_name(field[0]) verse_num = field[1:] verse_list += u'---[%s:%s]---\n' % (verse_tag, verse_num) @@ -576,7 +576,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): order = self.__extractVerseOrder(text) for index in range(self.verseListWidget.rowCount()): verse = self.verseListWidget.item(index, 0) - verse = verse.data(QtCore.Qt.UserRole).toString() + verse = verse.data(QtCore.Qt.UserRole) if verse not in verse_names: verses.append(verse) verse_names.append(u'%s%s' % ( @@ -617,7 +617,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): order = self.__extractVerseOrder(verse_order) for index in range(verse_count): verse = self.verseListWidget.item(index, 0) - verse = verse.data(QtCore.Qt.UserRole).toString() + verse = verse.data(QtCore.Qt.UserRole) if verse not in verse_names: verses.append(verse) verse_names.append(u'%s%s' % ( @@ -879,7 +879,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): files = [] for row in xrange(self.audioListWidget.count()): item = self.audioListWidget.item(row) - filename = item.data(QtCore.Qt.UserRole).toString() + filename = item.data(QtCore.Qt.UserRole) if not filename.startswith(save_path): oldfile, filename = filename, os.path.join(save_path, os.path.split(filename)[1]) @@ -916,7 +916,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): multiple = [] for i in range(self.verseListWidget.rowCount()): item = self.verseListWidget.item(i, 0) - verseId = item.data(QtCore.Qt.UserRole).toString() + verseId = item.data(QtCore.Qt.UserRole) verse_tag = verseId[0] verse_num = verseId[1:] sxml.add_verse_to_lyrics(verse_tag, verse_num, item.text()) diff --git a/openlp/plugins/songs/forms/editverseform.py b/openlp/plugins/songs/forms/editverseform.py index 172f7ad49..8ec50857b 100644 --- a/openlp/plugins/songs/forms/editverseform.py +++ b/openlp/plugins/songs/forms/editverseform.py @@ -180,19 +180,19 @@ class EditVerseForm(QtGui.QDialog, Ui_EditVerseDialog): def getVerseAll(self): text = self.verseTextEdit.toPlainText() - if not text.startsWith(u'---['): + if not text.startswith(u'---['): text = u'---[%s:1]---\n%s' % \ (VerseType.TranslatedNames[VerseType.Verse], text) return text def accept(self): if self.hasSingleVerse: - value = unicode(self.getVerse()[0]) + value = self.getVerse()[0] else: - log.debug(unicode(self.getVerse()[0]).split(u'\n')) - value = unicode(self.getVerse()[0]).split(u'\n')[1] + log.debug(self.getVerse()[0].split(u'\n')) + value = self.getVerse()[0].split(u'\n')[1] if not value: - lines = unicode(self.getVerse()[0]).split(u'\n') + lines = self.getVerse()[0].split(u'\n') index = 2 while index < len(lines) and not value: value = lines[index] diff --git a/openlp/plugins/songs/forms/mediafilesform.py b/openlp/plugins/songs/forms/mediafilesform.py index 49fcc0137..5eb7f66ef 100644 --- a/openlp/plugins/songs/forms/mediafilesform.py +++ b/openlp/plugins/songs/forms/mediafilesform.py @@ -52,6 +52,6 @@ class MediaFilesForm(QtGui.QDialog, Ui_MediaFilesDialog): self.fileListWidget.addItem(item) def getSelectedFiles(self): - return map(lambda item: item.data(QtCore.Qt.UserRole).toString(), + return map(lambda item: item.data(QtCore.Qt.UserRole), self.fileListWidget.selectedItems()) diff --git a/openlp/plugins/songs/forms/songexportform.py b/openlp/plugins/songs/forms/songexportform.py index f75c34eb5..ff74ba33c 100644 --- a/openlp/plugins/songs/forms/songexportform.py +++ b/openlp/plugins/songs/forms/songexportform.py @@ -218,8 +218,7 @@ class SongExportForm(OpenLPWizard): # Add the songs to the list of selected songs. for item in items: song = QtGui.QListWidgetItem(item.text()) - song.setData(QtCore.Qt.UserRole, - item.data(QtCore.Qt.UserRole).toPyObject()) + song.setData(QtCore.Qt.UserRole, item.data(QtCore.Qt.UserRole)) song.setFlags(QtCore.Qt.ItemIsEnabled) self.selectedListWidget.addItem(song) return True @@ -282,7 +281,7 @@ class SongExportForm(OpenLPWizard): and calls the *do_export* method. """ songs = [ - song.data(QtCore.Qt.UserRole).toPyObject() + song.data(QtCore.Qt.UserRole) for song in self._findListWidgetItems(self.selectedListWidget) ] exporter = OpenLyricsExport(self, songs, self.directoryLineEdit.text()) From 01db1d34d803c59a993ac2396db703ac4cee1e5d Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sat, 19 May 2012 17:12:15 +0200 Subject: [PATCH 17/53] removed/added empty lines --- openlp.pyw | 1 - openlp/core/lib/__init__.py | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp.pyw b/openlp.pyw index 0b225ded0..4a309ea6a 100755 --- a/openlp.pyw +++ b/openlp.pyw @@ -35,7 +35,6 @@ sip.setapi(u'QTime', 2) sip.setapi(u'QUrl', 2) sip.setapi(u'QVariant', 2) - from openlp.core import main diff --git a/openlp/core/lib/__init__.py b/openlp/core/lib/__init__.py index d723a6b2f..3963dddbe 100644 --- a/openlp/core/lib/__init__.py +++ b/openlp/core/lib/__init__.py @@ -104,6 +104,7 @@ class Settings(QtCore.QSettings): return int(setting) return setting + def translate(context, text, comment=None, encoding=QtCore.QCoreApplication.CodecForTr, n=-1, translate=QtCore.QCoreApplication.translate): From 1fe4e0a56aff3e1f4be9e8c4d8c1cfa298e999cb Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sat, 19 May 2012 17:25:39 +0200 Subject: [PATCH 18/53] removed toFloat() --- openlp/core/ui/media/webkitplayer.py | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/openlp/core/ui/media/webkitplayer.py b/openlp/core/ui/media/webkitplayer.py index f01f154e8..52136cb9b 100644 --- a/openlp/core/ui/media/webkitplayer.py +++ b/openlp/core/ui/media/webkitplayer.py @@ -406,24 +406,22 @@ class WebkitPlayer(MediaPlayer): def update_ui(self, display): controller = display.controller if controller.media_info.is_flash: - currentTime = display.frame.evaluateJavaScript( \ + currentTime = display.frame.evaluateJavaScript( u'show_flash("currentTime");') - length = display.frame.evaluateJavaScript( \ - u'show_flash("length");') + length = display.frame.evaluateJavaScript( u'show_flash("length");') else: - if display.frame.evaluateJavaScript( \ + if display.frame.evaluateJavaScript( u'show_video("isEnded");') == 'true': self.stop(display) - (currentTime, ok) = display.frame.evaluateJavaScript( \ - u'show_video("currentTime");').toFloat() + currentTime = display.frame.evaluateJavaScript( + u'show_video("currentTime");') # check if conversion was ok and value is not 'NaN' - if ok and currentTime != float('inf'): - currentTime = int(currentTime*1000) - (length, ok) = display.frame.evaluateJavaScript( \ - u'show_video("length");').toFloat() + if isinstance(currentTime, float) and currentTime != float('inf'): + currentTime = int(currentTime * 1000) + length = display.frame.evaluateJavaScript( u'show_video("length");') # check if conversion was ok and value is not 'NaN' - if ok and length != float('inf'): - length = int(length*1000) + if isinstance(length, float) and length != float('inf'): + length = int(length * 1000) if currentTime > 0: controller.media_info.length = length controller.seekSlider.setMaximum(length) From b0585297fbae3720b447af7febc79c0d45610baf Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sat, 19 May 2012 17:30:09 +0200 Subject: [PATCH 19/53] clean up --- openlp/core/ui/exceptionform.py | 3 +-- openlp/core/ui/media/webkitplayer.py | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/openlp/core/ui/exceptionform.py b/openlp/core/ui/exceptionform.py index cd2312790..c53ed4249 100644 --- a/openlp/core/ui/exceptionform.py +++ b/openlp/core/ui/exceptionform.py @@ -214,8 +214,7 @@ class ExceptionForm(QtGui.QDialog, Ui_ExceptionDialog): def onAttachFileButtonClicked(self): files = QtGui.QFileDialog.getOpenFileName( - self,translate('ImagePlugin.ExceptionDialog', - 'Select Attachment'), + self, translate('ImagePlugin.ExceptionDialog', 'Select Attachment'), SettingsManager.get_last_dir(u'exceptions'), u'%s (*.*) (*)' % UiStrings().AllFiles) log.info(u'New files(s) %s', unicode(files)) diff --git a/openlp/core/ui/media/webkitplayer.py b/openlp/core/ui/media/webkitplayer.py index 52136cb9b..3736ef785 100644 --- a/openlp/core/ui/media/webkitplayer.py +++ b/openlp/core/ui/media/webkitplayer.py @@ -339,7 +339,7 @@ class WebkitPlayer(MediaPlayer): else: display.frame.evaluateJavaScript(u'show_video("play");') if start_time > 0: - self.seek(display, controller.media_info.start_time*1000) + self.seek(display, controller.media_info.start_time * 1000) # TODO add playing check and get the correct media length controller.media_info.length = length self.state = MediaState.Playing From 49cd100f9016c3827e6a845af267006fdf87a242 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sat, 19 May 2012 17:41:05 +0200 Subject: [PATCH 20/53] clean up --- openlp/core/lib/mediamanageritem.py | 3 +-- openlp/core/ui/media/vlcplayer.py | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index 2f17984be..3bebedb0f 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -379,8 +379,7 @@ class MediaManagerItem(QtGui.QWidget): fullList = [] for count in range(self.listView.count()): names.append(self.listView.item(count).text()) - fullList.append(self.listView.item(count). - data(QtCore.Qt.UserRole)) + fullList.append(self.listView.item(count).data(QtCore.Qt.UserRole)) duplicatesFound = False filesAdded = False for file in files: diff --git a/openlp/core/ui/media/vlcplayer.py b/openlp/core/ui/media/vlcplayer.py index 93a06b0b3..3db028af8 100644 --- a/openlp/core/ui/media/vlcplayer.py +++ b/openlp/core/ui/media/vlcplayer.py @@ -145,8 +145,7 @@ class VlcPlayer(MediaPlayer): log.debug(u'load vid in Vlc Controller') controller = display.controller volume = controller.media_info.volume - file_path = str( - controller.media_info.file_info.absoluteFilePath().toUtf8()) + file_path = str(controller.media_info.file_info.absoluteFilePath()) path = os.path.normcase(file_path) # create the media display.vlcMedia = display.vlcInstance.media_new_path(path) From 5157f3a714c294936fe34b8e6364285a02dba0d0 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sat, 19 May 2012 17:49:23 +0200 Subject: [PATCH 21/53] fixed traceback --- openlp/core/ui/servicemanager.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index b30cbcfae..45bfd1dd8 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -1044,8 +1044,8 @@ class ServiceManager(QtGui.QWidget): 'Service copy only')))) if serviceitem.theme and serviceitem.theme != -1: tips.append(u'%s: %s' % - (translate('OpenLP.ServiceManager', 'Slide theme')), - serviceitem.theme) + (translate('OpenLP.ServiceManager', 'Slide theme'), + serviceitem.theme)) if serviceitem.notes: tips.append(u'%s: %s' % (translate('OpenLP.ServiceManager', 'Notes'), From 4a7a7e9050c04cf85bafcd336ff0288936df05f3 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Wed, 3 Oct 2012 19:09:56 +0200 Subject: [PATCH 22/53] fixes --- openlp/core/ui/advancedtab.py | 5 ++--- openlp/core/ui/mainwindow.py | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/openlp/core/ui/advancedtab.py b/openlp/core/ui/advancedtab.py index 66fd0a952..511719d3d 100644 --- a/openlp/core/ui/advancedtab.py +++ b/openlp/core/ui/advancedtab.py @@ -457,7 +457,7 @@ class AdvancedTab(SettingsTab): # The max recent files value does not have an interface and so never # gets actually stored in the settings therefore the default value of # 20 will always be used. - self.recentSpinBox.setMaximum(Settings().value(u'max recent files', 20)) + self.recentSpinBox.setMaximum(settings.value(u'max recent files', 20)) self.recentSpinBox.setValue(settings.value(u'recent file count', 4)) self.mediaPluginCheckBox.setChecked( settings.value(u'save current plugin', False)) @@ -533,8 +533,7 @@ class AdvancedTab(SettingsTab): self.defaultColorButton.setStyleSheet( u'background-color: %s' % self.defaultColor) # Don't allow data directory move if running portable. - if Settings().value(u'advanced/is portable', - QtCore.QVariant(False)).toBool(): + if settings.value(u'advanced/is portable', False): self.dataDirectoryGroupBox.hide() def save(self): diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index b43f2e1bb..274df7eb7 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -208,7 +208,7 @@ class Ui_MainWindow(object): category=UiStrings().File, triggers=mainWindow.close) # Give QT Extra Hint that this is the Exit Menu Item self.fileExitItem.setMenuRole(QtGui.QAction.QuitRole) - aaction_list.add_category(UiStrings().Import, + action_list.add_category(UiStrings().Import, CategoryOrder.standardMenu) self.importThemeItem = create_action(mainWindow, u'importThemeItem', category=UiStrings().Import) From c4bdea7edd785a39dfc893b700106385982496ae Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Wed, 3 Oct 2012 19:55:39 +0200 Subject: [PATCH 23/53] fixes --- openlp/core/lib/__init__.py | 13 ++++++------- openlp/core/ui/mainwindow.py | 1 - openlp/core/ui/themeform.py | 4 +--- openlp/plugins/bibles/lib/biblestab.py | 8 ++++---- 4 files changed, 11 insertions(+), 15 deletions(-) diff --git a/openlp/core/lib/__init__.py b/openlp/core/lib/__init__.py index 990f2141c..d13f32f50 100644 --- a/openlp/core/lib/__init__.py +++ b/openlp/core/lib/__init__.py @@ -92,8 +92,7 @@ class Settings(QtCore.QSettings): then the Settings constructor (without any arguments) will create a Settings object for accessing settings stored in that Ini file. """ - # TODO change - __filePath = u'' + __filePath__ = u'' @staticmethod def setFilename(iniFile): @@ -102,12 +101,12 @@ class Settings(QtCore.QSettings): Does not affect existing Settings objects. """ - Settings.__filePath = iniFile + Settings.__filePath__ = iniFile def __init__(self, *args): - if not args and Settings.__filePath and (Settings.defaultFormat() == - Settings.IniFormat): - QtCore.QSettings.__init__(self, Settings.__filePath, + if not args and Settings.__filePath__ and \ + Settings.defaultFormat() == Settings.IniFormat: + QtCore.QSettings.__init__(self, Settings.__filePath__, Settings.IniFormat) else: QtCore.QSettings.__init__(self, *args) @@ -130,7 +129,7 @@ class Settings(QtCore.QSettings): extended if a certain type is missing! """ setting = super(Settings, self).value(key, defaultValue) - # An empty list saved to the settings results ins a None type being + # An empty list saved to the settings results in a None type being # returned. if setting is None: return [] diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 274df7eb7..8c90db8f1 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -699,7 +699,6 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): self.liveController.screenSizeChanged() log.info(u'Load data from Settings') if Settings().value(u'advanced/save current plugin', False): - # TODO: QtCore.QVariant()).toInt()[0] savedPlugin = Settings().value(u'advanced/current media plugin', -1) if savedPlugin != -1: self.mediaToolBox.setCurrentIndex(savedPlugin) diff --git a/openlp/core/ui/themeform.py b/openlp/core/ui/themeform.py index 7ac17b122..cf2706bdf 100644 --- a/openlp/core/ui/themeform.py +++ b/openlp/core/ui/themeform.py @@ -205,8 +205,6 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard): """ Updates the lines on a page on the wizard """ - #TODO check - print type(lines) self.mainLineCountLabel.setText(translate('OpenLP.ThemeForm', '(approximately %d lines per slide)') % int(lines)) @@ -233,7 +231,7 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard): background_image = BackgroundType.to_string(BackgroundType.Image) if self.page(self.currentId()) == self.backgroundPage and \ self.theme.background_type == background_image and \ - self.imageFileEdit.text().isEmpty(): + not self.imageFileEdit.text(): QtGui.QMessageBox.critical(self, translate('OpenLP.ThemeWizard', 'Background Image Empty'), translate('OpenLP.ThemeWizard', 'You have not selected a ' diff --git a/openlp/plugins/bibles/lib/biblestab.py b/openlp/plugins/bibles/lib/biblestab.py index b6f67170b..cce348733 100644 --- a/openlp/plugins/bibles/lib/biblestab.py +++ b/openlp/plugins/bibles/lib/biblestab.py @@ -332,7 +332,7 @@ class BiblesTab(SettingsTab): if self.verseSeparatorLineEdit.isModified(): text = self.verseSeparatorLineEdit.text() if text == get_reference_separator(u'sep_v_default') or \ - text.remove(u'|').isEmpty(): + not text.replace(u'|', u''): self.verseSeparatorCheckBox.setChecked(False) self.verseSeparatorLineEdit.setText( get_reference_separator(u'sep_v_default')) @@ -357,7 +357,7 @@ class BiblesTab(SettingsTab): if self.rangeSeparatorLineEdit.isModified(): text = self.rangeSeparatorLineEdit.text() if text == get_reference_separator(u'sep_r_default') or \ - text.remove(u'|').isEmpty(): + not text.replace(u'|', u''): self.rangeSeparatorCheckBox.setChecked(False) self.rangeSeparatorLineEdit.setText( get_reference_separator(u'sep_r_default')) @@ -382,7 +382,7 @@ class BiblesTab(SettingsTab): if self.listSeparatorLineEdit.isModified(): text = self.listSeparatorLineEdit.text() if text == get_reference_separator(u'sep_l_default') or \ - text.remove(u'|').isEmpty(): + not text.replace(u'|', u''): self.listSeparatorCheckBox.setChecked(False) self.listSeparatorLineEdit.setText( get_reference_separator(u'sep_l_default')) @@ -407,7 +407,7 @@ class BiblesTab(SettingsTab): if self.endSeparatorLineEdit.isModified(): text = self.endSeparatorLineEdit.text() if text == get_reference_separator(u'sep_e_default') or \ - text.remove(u'|').isEmpty(): + not text.replace(u'|', u''): self.endSeparatorCheckBox.setChecked(False) self.endSeparatorLineEdit.setText( get_reference_separator(u'sep_e_default')) From 99e4786ab6f7c4ae87af7c3150da97756c6d8ab3 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Wed, 3 Oct 2012 20:44:00 +0200 Subject: [PATCH 24/53] fix --- openlp/core/ui/themestab.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/openlp/core/ui/themestab.py b/openlp/core/ui/themestab.py index 08223eb8e..49625ed24 100644 --- a/openlp/core/ui/themestab.py +++ b/openlp/core/ui/themestab.py @@ -169,8 +169,7 @@ class ThemesTab(SettingsTab): def onDefaultComboBoxChanged(self, value): self.global_theme = self.DefaultComboBox.currentText() - self.mainwindow.renderer.set_global_theme( - self.global_theme, self.theme_level) + self.mainwindow.renderer.set_global_theme(self.global_theme) self.__previewGlobalTheme() def updateThemeList(self, theme_list): From 43af89f70fc3477a47846a5ed92f369f626124de Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Wed, 3 Oct 2012 20:52:52 +0200 Subject: [PATCH 25/53] fix --- openlp/core/lib/mediamanageritem.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index 968802a1c..342d4c41e 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -362,7 +362,7 @@ class MediaManagerItem(QtGui.QWidget): 'Invalid File Type'), translate('OpenLP.MediaManagerItem', 'Invalid File %s.\nSuffix not supported') % file) - errorShown = True + error_shown = True else: new_files.append(file) if new_files: From 802de6d241210361a496d7556042f786228ea27f Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Wed, 3 Oct 2012 22:11:54 +0200 Subject: [PATCH 26/53] fix --- openlp/core/ui/generaltab.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/openlp/core/ui/generaltab.py b/openlp/core/ui/generaltab.py index 372fe3b29..3e586aa36 100644 --- a/openlp/core/ui/generaltab.py +++ b/openlp/core/ui/generaltab.py @@ -290,8 +290,7 @@ class GeneralTab(SettingsTab): False)) self.timeoutSpinBox.setValue(settings.value(u'loop delay', 5)) self.monitorRadioButton.setChecked( - not settings.value(u'override position', - False)) + settings.value(u'override position', False)) self.overrideRadioButton.setChecked(settings.value(u'override position', False)) self.customXValueEdit.setValue(settings.value(u'x position', From 6553dda03821ccf2972073aeff8fc98c662c21ac Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Thu, 11 Oct 2012 12:42:37 +0200 Subject: [PATCH 27/53] reverted fix --- openlp/core/ui/generaltab.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/core/ui/generaltab.py b/openlp/core/ui/generaltab.py index 3e586aa36..1ab380f47 100644 --- a/openlp/core/ui/generaltab.py +++ b/openlp/core/ui/generaltab.py @@ -290,7 +290,7 @@ class GeneralTab(SettingsTab): False)) self.timeoutSpinBox.setValue(settings.value(u'loop delay', 5)) self.monitorRadioButton.setChecked( - settings.value(u'override position', False)) + not settings.value(u'override position', False)) self.overrideRadioButton.setChecked(settings.value(u'override position', False)) self.customXValueEdit.setValue(settings.value(u'x position', From 638b95f62ccb5c651f82f0c20b13ab1fc2d5f56e Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Thu, 11 Oct 2012 12:53:39 +0200 Subject: [PATCH 28/53] fixed shortcut dialog --- openlp/core/ui/shortcutlistform.py | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/openlp/core/ui/shortcutlistform.py b/openlp/core/ui/shortcutlistform.py index f07a05750..42d46a1b9 100644 --- a/openlp/core/ui/shortcutlistform.py +++ b/openlp/core/ui/shortcutlistform.py @@ -90,7 +90,7 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): if key == QtCore.Qt.Key_Shift or key == QtCore.Qt.Key_Control or \ key == QtCore.Qt.Key_Meta or key == QtCore.Qt.Key_Alt: return - key_string = QtGui.QKeySequence(key) + key_string = QtGui.QKeySequence(key).toString() if event.modifiers() & QtCore.Qt.ControlModifier == \ QtCore.Qt.ControlModifier: key_string = u'Ctrl+' + key_string @@ -106,10 +106,10 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): if self._validiate_shortcut(self._currentItemAction(), key_sequence): if self.primaryPushButton.isChecked(): self._adjustButton(self.primaryPushButton, - False, text=key_sequence) + False, text=key_sequence.toString()) elif self.alternatePushButton.isChecked(): self._adjustButton(self.alternatePushButton, - False, text=key_sequence) + False, text=key_sequence.toString()) def exec_(self): self.changedActions = {} @@ -155,11 +155,11 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): item.setText(1, u'') item.setText(2, u'') elif len(shortcuts) == 1: - item.setText(1, shortcuts[0]) + item.setText(1, shortcuts[0].toString()) item.setText(2, u'') else: - item.setText(1, shortcuts[0]) - item.setText(2, shortcuts[1]) + item.setText(1, shortcuts[0].toString()) + item.setText(2, shortcuts[1].toString()) self.onCurrentItemChanged() def onPrimaryPushButtonClicked(self, toggled): @@ -242,9 +242,9 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): self.alternatePushButton.setChecked(False) else: if action.defaultShortcuts: - primary_label_text = action.defaultShortcuts[0] + primary_label_text = action.defaultShortcuts[0].toString() if len(action.defaultShortcuts) == 2: - alternate_label_text = action.defaultShortcuts[1] + alternate_label_text = action.defaultShortcuts[1].toString() shortcuts = self._actionShortcuts(action) # We do not want to loose pending changes, that is why we have to # keep the text when, this function has not been triggered by a @@ -253,10 +253,10 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): primary_text = self.primaryPushButton.text() alternate_text = self.alternatePushButton.text() elif len(shortcuts) == 1: - primary_text = shortcuts[0] + primary_text = shortcuts[0].toString() elif len(shortcuts) == 2: - primary_text = shortcuts[0] - alternate_text = shortcuts[1] + primary_text = shortcuts[0].toString() + alternate_text = shortcuts[1].toString() # When we are capturing a new shortcut, we do not want, the buttons to # display the current shortcut. if self.primaryPushButton.isChecked(): @@ -314,9 +314,9 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): primary_button_text = u'' alternate_button_text = u'' if temp_shortcuts: - primary_button_text = temp_shortcuts[0] + primary_button_text = temp_shortcuts[0].toString() if len(temp_shortcuts) == 2: - alternate_button_text = temp_shortcuts[1] + alternate_button_text = temp_shortcuts[1].toString() self.primaryPushButton.setText(primary_button_text) self.alternatePushButton.setText(alternate_button_text) @@ -444,7 +444,7 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): 'Duplicate Shortcut'), u'message': translate('OpenLP.ShortcutListDialog', 'The shortcut "%s" is already assigned to another action, ' - 'please use a different shortcut.') % key_sequence + 'please use a different shortcut.') % key_sequence.toString() }) return is_valid From c5f34a86372fc1a23c5b1164374d83e9214c19eb Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Tue, 4 Dec 2012 22:22:08 +0100 Subject: [PATCH 29/53] 'fixed' code (cough) --- openlp/core/utils/__init__.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/openlp/core/utils/__init__.py b/openlp/core/utils/__init__.py index bcc2bc545..41b1b3d26 100644 --- a/openlp/core/utils/__init__.py +++ b/openlp/core/utils/__init__.py @@ -32,6 +32,7 @@ The :mod:`openlp.core.utils` module provides the utility libraries for OpenLP. from datetime import datetime from distutils.version import LooseVersion import logging +import locale import os import re from subprocess import Popen, PIPE @@ -496,15 +497,17 @@ def locale_compare(string1, string2): or 0, depending on whether string1 collates before or after string2 or is equal to it. Comparison is case insensitive. """ - # Function locale.strcol() from standard Python library does not work + # Function locale.strcoll() from standard Python library does not work # properly on Windows and probably somewhere else. - return QtCore.QString.localeAwareCompare(string1.lower(), string2.lower()) + return locale.strcoll(string1.lower(), string2.lower()) + # TODO: check code + #return QtCore.QString.localeAwareCompare(string1.lower(), string2.lower()) # For performance reasons provide direct reference to compare function # without wrapping it in another function making te string lowercase. # This is needed for sorting songs. -locale_direct_compare = QtCore.QString.localeAwareCompare +locale_direct_compare = locale.strcoll from languagemanager import LanguageManager From 6c1e303dbd031ce032b5e59ec0d99b9c8e390cb6 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Wed, 5 Dec 2012 21:33:39 +0100 Subject: [PATCH 30/53] fixed branch --- openlp/core/lib/ui.py | 2 +- openlp/core/ui/servicemanager.py | 12 +++++------- openlp/plugins/media/lib/mediaitem.py | 2 +- openlp/plugins/presentations/lib/mediaitem.py | 2 +- 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/openlp/core/lib/ui.py b/openlp/core/lib/ui.py index 9e2bde7d6..4e69ec546 100644 --- a/openlp/core/lib/ui.py +++ b/openlp/core/lib/ui.py @@ -373,7 +373,7 @@ def create_action(parent, name, **kwargs): True in case the action will be considered a separator. ``data`` - Data which is set as QVariant type. + The actions data. ``shortcuts`` A QList (or a list of strings) which are set as shortcuts. diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index a3adfa43a..8aff5c174 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -480,7 +480,6 @@ class ServiceManager(QtGui.QWidget): path) service = [] write_list = [] - print 1 missing_list = [] audio_files = [] total_size = 0 @@ -501,12 +500,12 @@ class ServiceManager(QtGui.QWidget): write_list.append(path_from) if missing_list: Receiver.send_message(u'cursor_normal') - title = unicode(translate('OpenLP.ServiceManager', - 'Service File(s) Missing')) - message = unicode(translate('OpenLP.ServiceManager', + title = translate('OpenLP.ServiceManager', + 'Service File(s) Missing') + message = translate('OpenLP.ServiceManager', 'The following file(s) in the service are missing:\n\t%s\n\n' - 'These files will be removed if you continue to save.') - ) % "\n\t".join(missing_list) + 'These files will be removed if you continue to save.') % \ + "\n\t".join(missing_list) answer = QtGui.QMessageBox.critical(self, title, message, QtGui.QMessageBox.StandardButtons( @@ -591,7 +590,6 @@ class ServiceManager(QtGui.QWidget): self.mainwindow.addRecentFile(path_file_name) self.setModified(False) delete_file(temp_file_name) - print 2 return success def saveFileAs(self): diff --git a/openlp/plugins/media/lib/mediaitem.py b/openlp/plugins/media/lib/mediaitem.py index c1a884d9c..a075c6754 100644 --- a/openlp/plugins/media/lib/mediaitem.py +++ b/openlp/plugins/media/lib/mediaitem.py @@ -305,7 +305,7 @@ class MediaMediaItem(MediaManagerItem): filename = os.path.split(unicode(track))[1] item_name = QtGui.QListWidgetItem(filename) item_name.setIcon(build_icon(ERROR)) - item_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(track)) + item_name.setData(QtCore.Qt.UserRole, track) elif track_info.isFile(): filename = os.path.split(unicode(track))[1] item_name = QtGui.QListWidgetItem(filename) diff --git a/openlp/plugins/presentations/lib/mediaitem.py b/openlp/plugins/presentations/lib/mediaitem.py index 4e0f7821a..afaf59253 100644 --- a/openlp/plugins/presentations/lib/mediaitem.py +++ b/openlp/plugins/presentations/lib/mediaitem.py @@ -184,7 +184,7 @@ class PresentationMediaItem(MediaManagerItem): if not os.path.exists(file): item_name = QtGui.QListWidgetItem(filename) item_name.setIcon(build_icon(ERROR)) - item_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(file)) + item_name.setData(QtCore.Qt.UserRole, file) item_name.setToolTip(file) self.listView.addItem(item_name) else: From 1a80a243a879374fbce0c7fdfc9e20e9e00743f1 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Thu, 6 Dec 2012 12:03:27 +0100 Subject: [PATCH 31/53] removed not needed import --- openlp/core/lib/__init__.py | 1 - 1 file changed, 1 deletion(-) diff --git a/openlp/core/lib/__init__.py b/openlp/core/lib/__init__.py index 0f2f1e452..3312df8b1 100644 --- a/openlp/core/lib/__init__.py +++ b/openlp/core/lib/__init__.py @@ -30,7 +30,6 @@ The :mod:`lib` module contains most of the components and libraries that make OpenLP work. """ -import datetime import logging import os From e8178b2569ccbbc8e955c93295f8e3b51bc1f069 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Thu, 6 Dec 2012 12:05:09 +0100 Subject: [PATCH 32/53] swap lines --- openlp/core/lib/formattingtags.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/core/lib/formattingtags.py b/openlp/core/lib/formattingtags.py index f79fb2341..c74b81d4d 100644 --- a/openlp/core/lib/formattingtags.py +++ b/openlp/core/lib/formattingtags.py @@ -163,8 +163,8 @@ class FormattingTags(object): u'end html': u'', u'protected': True, u'temporary': False}) FormattingTags.add_html_tags(base_tags) FormattingTags.add_html_tags(temporary_tags) - # Formatting Tags were also known as display tags. + # Formatting Tags were also known as display tags. user_expands = Settings().value(u'displayTags/html_tags', u'') # cPickle only accepts str not unicode strings user_expands_string = str(user_expands) From 7fa97b2cac13fddc6144b725cace93836742b976 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Thu, 6 Dec 2012 12:09:10 +0100 Subject: [PATCH 33/53] fixed import order --- openlp/core/ui/advancedtab.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/openlp/core/ui/advancedtab.py b/openlp/core/ui/advancedtab.py index d5c338c32..adc93fd19 100644 --- a/openlp/core/ui/advancedtab.py +++ b/openlp/core/ui/advancedtab.py @@ -34,11 +34,10 @@ import logging import os import sys -from openlp.core.lib import SettingsTab, translate, build_icon, Receiver, \ - Settings - from PyQt4 import QtCore, QtGui +from openlp.core.lib import SettingsTab, translate, build_icon, Receiver, \ + Settings from openlp.core.lib.ui import UiStrings from openlp.core.utils import get_images_filter, AppLocation, format_time from openlp.core.lib import SlideLimits From d18564f847aecda31c345d13b5a1e16c1e7ae49e Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Thu, 6 Dec 2012 19:59:07 +0100 Subject: [PATCH 34/53] fixed missing arg method --- openlp/core/lib/__init__.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/openlp/core/lib/__init__.py b/openlp/core/lib/__init__.py index 3312df8b1..8be1c14af 100644 --- a/openlp/core/lib/__init__.py +++ b/openlp/core/lib/__init__.py @@ -430,15 +430,15 @@ def create_separated_list(stringlist): return stringlist[0] elif len(stringlist) == 2: return translate('OpenLP.core.lib', '%1 and %2', - 'Locale list separator: 2 items').arg(stringlist[0], stringlist[1]) + 'Locale list separator: 2 items') % (stringlist[0], stringlist[1]) else: merged = translate('OpenLP.core.lib', '%1, and %2', - u'Locale list separator: end').arg(stringlist[-2], stringlist[-1]) + u'Locale list separator: end') % (stringlist[-2], stringlist[-1]) for index in reversed(range(1, len(stringlist) - 2)): merged = translate('OpenLP.core.lib', '%1, %2', - u'Locale list separator: middle').arg(stringlist[index], merged) + u'Locale list separator: middle') % (stringlist[index], merged) return translate('OpenLP.core.lib', '%1, %2', - u'Locale list separator: start').arg(stringlist[0], merged) + u'Locale list separator: start') % (stringlist[0], merged) from eventreceiver import Receiver From 3a7cc40e4dc75351870b4313419b6cd2baabf3e5 Mon Sep 17 00:00:00 2001 From: M2j Date: Wed, 19 Dec 2012 14:07:24 +0100 Subject: [PATCH 35/53] fix wrong argument names in create_button method call --- openlp/plugins/custom/forms/editcustomdialog.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openlp/plugins/custom/forms/editcustomdialog.py b/openlp/plugins/custom/forms/editcustomdialog.py index a9eba86c0..f91717a06 100644 --- a/openlp/plugins/custom/forms/editcustomdialog.py +++ b/openlp/plugins/custom/forms/editcustomdialog.py @@ -74,9 +74,9 @@ class Ui_CustomEditDialog(object): self.buttonLayout.addWidget(self.deleteButton) self.buttonLayout.addStretch() self.upButton = create_button(customEditDialog, u'upButton', role=u'up', - enable=False, click=customEditDialog.onUpButtonClicked) + enabled=False, click=customEditDialog.onUpButtonClicked) self.downButton = create_button(customEditDialog, u'downButton', - role=u'down', enable=False, + role=u'down', enabled=False, click=customEditDialog.onDownButtonClicked) self.buttonLayout.addWidget(self.upButton) self.buttonLayout.addWidget(self.downButton) From e7787ddd2dc24b6423e3e2ad3beb8096a77b2b28 Mon Sep 17 00:00:00 2001 From: Arjan Schrijver Date: Wed, 19 Dec 2012 17:26:53 +0100 Subject: [PATCH 36/53] fixed bug #1092121 'Interface unusable when run on XFce' Fixes: https://launchpad.net/bugs/1092121 --- openlp/core/ui/advancedtab.py | 3 +++ openlp/core/ui/maindisplay.py | 3 +++ 2 files changed, 6 insertions(+) diff --git a/openlp/core/ui/advancedtab.py b/openlp/core/ui/advancedtab.py index 93c8f4999..361baa5cb 100644 --- a/openlp/core/ui/advancedtab.py +++ b/openlp/core/ui/advancedtab.py @@ -490,6 +490,9 @@ class AdvancedTab(SettingsTab): # Default to False on Gnome. x11_bypass_default = bool(not os.environ.get(u'GNOME_DESKTOP_SESSION_ID')) + # Default to False on XFce + if os.environ.get(u'DESKTOP_SESSION') == 'xfce': + x11_bypass_default = False self.x11BypassCheckBox.setChecked(settings.value( u'x11 bypass wm', QtCore.QVariant(x11_bypass_default)).toBool()) self.defaultColor = settings.value(u'default color', diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index 16ee19161..69b210e84 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -143,6 +143,9 @@ class MainDisplay(Display): # Default to False on Gnome. x11_bypass_default = bool(not os.environ.get(u'GNOME_DESKTOP_SESSION_ID')) + # Default to False on XFce + if os.environ.get(u'DESKTOP_SESSION') == 'xfce': + x11_bypass_default = False if Settings().value(u'advanced/x11 bypass wm', QtCore.QVariant(x11_bypass_default)).toBool(): windowFlags |= QtCore.Qt.X11BypassWindowManagerHint From e574466ebb0298c2117f9f80d2220dc927ec5f87 Mon Sep 17 00:00:00 2001 From: Arjan Schrijver Date: Thu, 20 Dec 2012 09:05:25 +0100 Subject: [PATCH 37/53] use unicode strings --- openlp/core/ui/advancedtab.py | 2 +- openlp/core/ui/maindisplay.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/openlp/core/ui/advancedtab.py b/openlp/core/ui/advancedtab.py index 361baa5cb..54bb69496 100644 --- a/openlp/core/ui/advancedtab.py +++ b/openlp/core/ui/advancedtab.py @@ -491,7 +491,7 @@ class AdvancedTab(SettingsTab): x11_bypass_default = bool(not os.environ.get(u'GNOME_DESKTOP_SESSION_ID')) # Default to False on XFce - if os.environ.get(u'DESKTOP_SESSION') == 'xfce': + if os.environ.get(u'DESKTOP_SESSION') == u'xfce': x11_bypass_default = False self.x11BypassCheckBox.setChecked(settings.value( u'x11 bypass wm', QtCore.QVariant(x11_bypass_default)).toBool()) diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index 69b210e84..eb0c3911b 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -144,7 +144,7 @@ class MainDisplay(Display): x11_bypass_default = bool(not os.environ.get(u'GNOME_DESKTOP_SESSION_ID')) # Default to False on XFce - if os.environ.get(u'DESKTOP_SESSION') == 'xfce': + if os.environ.get(u'DESKTOP_SESSION') == u'xfce': x11_bypass_default = False if Settings().value(u'advanced/x11 bypass wm', QtCore.QVariant(x11_bypass_default)).toBool(): From 18aaf682e8bcc44a8391f4e6f53f28008a7edc2d Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Thu, 20 Dec 2012 21:33:43 +0100 Subject: [PATCH 38/53] started to implment central place for default values --- openlp/core/__init__.py | 8 +- openlp/core/lib/__init__.py | 314 ++++++++++++++---- openlp/core/lib/formattingtags.py | 2 +- openlp/core/lib/mediamanageritem.py | 9 +- openlp/core/lib/plugin.py | 3 +- openlp/core/lib/settingsmanager.py | 2 +- openlp/core/ui/firsttimeform.py | 4 +- openlp/core/ui/maindisplay.py | 16 +- openlp/core/ui/mainwindow.py | 24 +- openlp/core/ui/media/__init__.py | 8 +- openlp/core/ui/media/mediacontroller.py | 2 +- openlp/core/ui/media/phononplayer.py | 2 +- openlp/core/ui/media/vlcplayer.py | 2 +- openlp/core/ui/media/webkitplayer.py | 2 +- openlp/core/ui/servicemanager.py | 23 +- openlp/core/ui/slidecontroller.py | 15 +- openlp/core/ui/thememanager.py | 6 +- openlp/core/ui/themestab.py | 2 +- openlp/core/utils/languagemanager.py | 2 +- openlp/plugins/bibles/lib/manager.py | 4 +- openlp/plugins/bibles/lib/mediaitem.py | 8 +- openlp/plugins/custom/lib/customtab.py | 2 +- openlp/plugins/custom/lib/mediaitem.py | 4 +- openlp/plugins/images/imageplugin.py | 2 +- openlp/plugins/images/lib/mediaitem.py | 4 +- openlp/plugins/media/lib/mediaitem.py | 2 +- openlp/plugins/media/lib/mediatab.py | 10 +- openlp/plugins/presentations/lib/mediaitem.py | 4 +- .../lib/presentationcontroller.py | 1 + .../presentations/lib/presentationtab.py | 1 + openlp/plugins/remotes/lib/httpserver.py | 8 +- openlp/plugins/remotes/lib/remotetab.py | 9 +- openlp/plugins/songs/forms/songimportform.py | 3 +- openlp/plugins/songs/lib/mediaitem.py | 11 +- .../songusage/forms/songusagedetailform.py | 1 + openlp/plugins/songusage/songusageplugin.py | 2 +- 36 files changed, 351 insertions(+), 171 deletions(-) diff --git a/openlp/core/__init__.py b/openlp/core/__init__.py index 04f99bfa7..672f655f5 100644 --- a/openlp/core/__init__.py +++ b/openlp/core/__init__.py @@ -118,7 +118,7 @@ class OpenLP(QtGui.QApplication): # Decide how many screens we have and their size screens = ScreenList.create(self.desktop()) # First time checks in settings - has_run_wizard = Settings().value(u'general/has run wizard', False) + has_run_wizard = Settings().value(u'general/has run wizard') if not has_run_wizard: if FirstTimeForm(screens).exec_() == QtGui.QDialog.Accepted: Settings().setValue(u'general/has run wizard', True) @@ -129,7 +129,7 @@ class OpenLP(QtGui.QApplication): u'QTableWidget, QListWidget, QTreeWidget {alternate-background-color: ' + base_color.name() + ';}\n' application_stylesheet += nt_repair_stylesheet self.setStyleSheet(application_stylesheet) - show_splash = Settings().value(u'general/show splash', True) + show_splash = Settings().value(u'general/show splash') if show_splash: self.splash = SplashScreen() self.splash.show() @@ -148,7 +148,7 @@ class OpenLP(QtGui.QApplication): self.processEvents() if not has_run_wizard: self.mainWindow.firstTime() - update_check = Settings().value(u'general/update check', True) + update_check = Settings().value(u'general/update check') if update_check: VersionThread(self.mainWindow).start() Receiver.send_message(u'live_display_blank_check') @@ -295,7 +295,7 @@ def main(args=None): if app.isAlreadyRunning(): sys.exit() # First time checks in settings - if not Settings().value(u'general/has run wizard', False): + if not Settings().value(u'general/has run wizard'): if not FirstTimeLanguageForm().exec_(): # if cancel then stop processing sys.exit() diff --git a/openlp/core/lib/__init__.py b/openlp/core/lib/__init__.py index 4a3cf7d54..c76557346 100644 --- a/openlp/core/lib/__init__.py +++ b/openlp/core/lib/__init__.py @@ -1,6 +1,5 @@ # -*- coding: utf-8 -*- # vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 - ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # @@ -30,6 +29,7 @@ The :mod:`lib` module contains most of the components and libraries that make OpenLP work. """ +import datetime import logging import os @@ -90,68 +90,6 @@ class ServiceItemAction(object): Next = 3 -class Settings(QtCore.QSettings): - """ - Class to wrap QSettings. - - * Exposes all the methods of QSettings. - * Adds functionality for OpenLP Portable. If the ``defaultFormat`` is set to - ``IniFormat``, and the path to the Ini file is set using ``setFilename``, - then the Settings constructor (without any arguments) will create a Settings - object for accessing settings stored in that Ini file. - """ - __filePath__ = u'' - - @staticmethod - def setFilename(iniFile): - """ - Sets the complete path to an Ini file to be used by Settings objects. - - Does not affect existing Settings objects. - """ - Settings.__filePath__ = iniFile - - def __init__(self, *args): - if not args and Settings.__filePath__ and \ - Settings.defaultFormat() == Settings.IniFormat: - QtCore.QSettings.__init__(self, Settings.__filePath__, - Settings.IniFormat) - else: - QtCore.QSettings.__init__(self, *args) - - def value(self, key, defaultValue): - """ - Returns the value for the given ``key``. The returned ``value`` is - of the same type as the ``defaultValue``. - - ``key`` - The key to return the value from. - - ``defaultValue`` - The value to be returned if the given ``key`` is not present in the - config. Note, the ``defaultValue``'s type defines the type the - returned is converted to. In other words, if the ``defaultValue`` is - a boolean, then the returned value will be converted to a boolean. - - **Note**, this method only converts a few types and might need to be - extended if a certain type is missing! - """ - setting = super(Settings, self).value(key, defaultValue) - # An empty list saved to the settings results in a None type being - # returned. - if setting is None: - return [] - # Convert the setting to the correct type. - if isinstance(defaultValue, bool): - if isinstance(setting, bool): - return setting - # Sometimes setting is string instead of a boolean. - return setting == u'true' - if isinstance(defaultValue, int): - return int(setting) - return setting - - def translate(context, text, comment=None, encoding=QtCore.QCoreApplication.CodecForTr, n=-1, translate=QtCore.QCoreApplication.translate): @@ -174,6 +112,256 @@ def translate(context, text, comment=None, return translate(context, text, comment, encoding, n) +class Settings(QtCore.QSettings): + """ + Class to wrap QSettings. + + * Exposes all the methods of QSettings. + * Adds functionality for OpenLP Portable. If the ``defaultFormat`` is set to + ``IniFormat``, and the path to the Ini file is set using ``setFilename``, + then the Settings constructor (without any arguments) will create a Settings + object for accessing settings stored in that Ini file. + """ + __filePath__ = u'' + __defaultValues__ = { + u'advanced/x11 bypass wm': True, + u'advanced/default service enabled': True, + u'advanced/enable exit confirmation': True, + u'advanced/save current plugin': False, + u'advanced/single click preview': False, + u'advanced/default service day': 7, + u'advanced/max recent files': 20, + u'advanced/is portable': False, + u'advanced/hide mouse': True, + u'advanced/current media plugin': -1, + u'advanced/double click live': False, + u'advanced/default service hour': 11, + u'advanced/default color': u'#ffffff', + u'advanced/default image': u':/graphics/openlp-splash-screen.png', + u'advanced/expand service item': False, + u'advanced/recent file count': 4, + u'advanced/default service name': translate( + 'OpenLP.AdvancedTab', 'Service %Y-%m-%d %H-%M', + 'This may not contain any of the following characters: ' + '/\\?*|<>\[\]":+\nSee http://docs.python.org/library/' + 'datetime.html#strftime-strptime-behavior for more information.'), + u'advanced/default service minute': 0, + u'advanced/slide limits': SlideLimits.End, + u'alerts/font face': u'Sans', + u'alerts/font size': 40, + u'alerts/status': 0,#PluginStatus.Inactive, + u'alerts/db type': u'sqlite', + u'alerts/location': 2, + u'alerts/background color': u'#660000', + u'alerts/font color': u'#ffffff', + u'alerts/timeout': 5, + u'bibles/book name language': 0, + u'bibles/verse separator': u'', + u'bibles/advanced bible': u'', + u'bibles/proxy name': u'', + u'bibles/db type': u'sqlite', + u'bibles/status': 0, # PluginStatus.Inactive, + u'bibles/bible theme': u'', + u'bibles/range separator': u'', + u'bibles/display new chapter': False, + u'bibles/verse layout style': 0, + u'bibles/display brackets': 0, + u'bibles/list separator': u'', + u'bibles/second bibles': True, + u'bibles/quick bible': u'Afrikaans Bybel', + u'bibles/end separator': u'', + u'bibles/last search type': 1, + u'custom/db type': u'sqlite', + u'custom/display footer': True, + u'custom/last search type': 1, + u'custom/status': 0, # PluginStatus.Inactive, + u'displayTags/html_tags': u'', + u'general/ccli number': u'', + u'general/y position': 0, + u'general/has run wizard': False, + u'general/update check': True, + u'general/language': u'[en]', + u'general/songselect password': u'', + u'general/recent files': [], + u'general/save prompt': False, + u'general/auto preview': False, + u'general/override position': False, + u'general/view mode': u'default', + u'general/auto open': False, + u'general/enable slide loop': True, + u'general/show splash': True, + u'general/screen blank': False, + u'general/x position': 0, + u'general/loop delay': 5, + u'general/height': 1024, + u'general/monitor': 0, + u'general/songselect username': u'', + u'general/audio repeat list': False, + u'general/auto unblank': False, + u'general/display on monitor': True, + u'general/width': 1280, + u'general/audio start paused': True, + u'general/last version test': datetime.datetime.now().date(), + u'general/blank warning': False, + u'images/images count': 0, + u'images/background color': u'#000000', + u'images/status': 0, # PluginStatus.Inactive, + u'media/override player': QtCore.Qt.Unchecked, + u'media/media count': 0, + u'media/media auto start': QtCore.Qt.Unchecked, + u'media/status': 0, # PluginStatus.Inactive, + u'media/players': u'webkit', + u'players/background color': u'#000000', + u'presentations/Impress': 2, + u'presentations/override app': QtCore.Qt.Unchecked, + u'presentations/presentations count': 0, + u'presentations/Powerpoint': 2, + u'presentations/status': 0, # PluginStatus.Inactive, + u'presentations/Powerpoint Viewer': 2, + u'remotes/twelve hour': True, + u'remotes/status': 0, # PluginStatus.Inactive, + u'remotes/port': 4316, + u'remotes/ip address': u'0.0.0.0', + u'servicemanager/service theme': u'', + u'shortcuts/viewPreviewPanel': [QtGui.QKeySequence(u'F11')], + u'shortcuts/settingsImportItem': [], + u'shortcuts/settingsPluginListItem': [QtGui.QKeySequence(u'Alt+F7')], + u'shortcuts/modeLiveItem': [], + u'shortcuts/songUsageStatus': [QtCore.Qt.Key_F4], + u'shortcuts/nextTrackItem': [], + u'shortcuts/makeLive': [QtCore.Qt.Key_Enter, QtCore.Qt.Key_Return], + u'shortcuts/webSiteItem': [], + u'shortcuts/shortcutAction_P': [QtGui.QKeySequence(u'P')], + u'shortcuts/previousItem_live': [QtCore.Qt.Key_Up, QtCore.Qt.Key_PageUp], + u'shortcuts/shortcutAction_V': [QtGui.QKeySequence(u'V')], + u'shortcuts/fileOpenItem': [QtGui.QKeySequence(u'Ctrl+O')], + u'shortcuts/viewMediaManagerItem': [QtGui.QKeySequence(u'F8')], + u'shortcuts/desktopScreen': [QtGui.QKeySequence(u'D')], + u'shortcuts/songExportItem': [], + u'shortcuts/modeDefaultItem': [], + u'shortcuts/audioPauseItem': [], + u'shortcuts/themeScreen': [QtGui.QKeySequence(u'T')], + u'shortcuts/expand': [QtCore.Qt.Key_Plus], + u'shortcuts/exportThemeItem': [], + u'shortcuts/viewThemeManagerItem': [QtGui.QKeySequence(u'F10')], + u'shortcuts/playSlidesLoop': [], + u'shortcuts/playSlidesOnce': [], + u'shortcuts/toolsReindexItem': [], + u'shortcuts/toolsAlertItem': [u'F7'], + u'shortcuts/printServiceItem': [QtGui.QKeySequence(u'Ctrl+P')], + u'shortcuts/moveUp': [QtCore.Qt.Key_PageUp], + u'shortcuts/settingsShortcutsItem': [], + u'shortcuts/nextItem_live': [QtCore.Qt.Key_Down, QtCore.Qt.Key_PageDown], + u'shortcuts/moveTop': [QtCore.Qt.Key_Home], + u'shortcuts/blankScreen': [QtCore.Qt.Key_Period], + u'shortcuts/settingsConfigureItem': [], + u'shortcuts/modeSetupItem': [], + u'shortcuts/songUsageDelete': [], + u'shortcuts/shortcutAction_C': [QtGui.QKeySequence(u'C')], + u'shortcuts/shortcutAction_B': [QtGui.QKeySequence(u'B')], + u'shortcuts/shortcutAction_E': [QtGui.QKeySequence(u'E')], + u'shortcuts/shortcutAction_I': [QtGui.QKeySequence(u'I')], + u'shortcuts/shortcutAction_O': [QtGui.QKeySequence(u'O')], + u'shortcuts/importBibleItem': [], + u'shortcuts/fileExitItem': [QtGui.QKeySequence(u'Alt+F4')], + u'shortcuts/fileSaveItem': [QtGui.QKeySequence(u'Ctrl+S')], + u'shortcuts/up': [QtCore.Qt.Key_Up], + u'shortcuts/nextService': [QtCore.Qt.Key_Right], + u'shortcuts/songImportItem': [], + u'shortcuts/toolsOpenDataFolder': [], + u'shortcuts/fileNewItem': [QtGui.QKeySequence(u'Ctrl+N')], + u'shortcuts/aboutItem': [QtGui.QKeySequence(u'Ctrl+F1')], + u'shortcuts/viewLivePanel': [QtGui.QKeySequence(u'F12')], + u'shortcuts/songUsageReport': [], + u'shortcuts/updateThemeImages': [], + u'shortcuts/toolsAddToolItem': [], + u'shortcuts/fileSaveAsItem': [QtGui.QKeySequence(u'Ctrl+Shift+S')], + u'shortcuts/settingsExportItem': [], + u'shortcuts/onlineHelpItem': [QtGui.QKeySequence(u'Alt+F1')], + u'shortcuts/escapeItem': [QtCore.Qt.Key_Escape], + u'shortcuts/displayTagItem': [], + u'shortcuts/moveBottom': [QtCore.Qt.Key_End], + u'shortcuts/toolsFirstTimeWizard': [], + u'shortcuts/moveDown': [QtCore.Qt.Key_PageDown], + u'shortcuts/collapse': [QtCore.Qt.Key_Minus], + u'shortcuts/viewServiceManagerItem': [QtGui.QKeySequence(u'F9')], + u'shortcuts/previousService': [QtCore.Qt.Key_Left], + u'shortcuts/importThemeItem': [], + u'shortcuts/down': [QtCore.Qt.Key_Down], + u'songs/update service on edit': False, + u'songs/search as type': False, + u'songs/add song from service': True, + u'songs/display songbar': True, + u'songs/last search type': 1, # BibleSearch.Reference, + u'songusage/db type': u'sqlite', + u'songusage/status': 0, # PluginStatus.Inactive, + u'songusage/active': False, + u'themes/theme level': 3, + u'themes/global theme': u'', + u'user interface/main window position': QtCore.QPoint(), + u'user interface/preview panel': True, + u'user interface/live panel': True, + u'user interface/main window geometry': QtCore.QByteArray(), + u'user interface/preview splitter geometry': QtCore.QByteArray(), + u'user interface/lock panel': False, + u'user interface/mainwindow splitter geometry': QtCore.QByteArray(), + u'user interface/live splitter geometry': QtCore.QByteArray(), + u'user interface/main window state': QtCore.QByteArray() +} + + @staticmethod + def setFilename(iniFile): + """ + Sets the complete path to an Ini file to be used by Settings objects. + + Does not affect existing Settings objects. + """ + Settings.__filePath__ = iniFile + + def __init__(self, *args): + if not args and Settings.__filePath__ and \ + Settings.defaultFormat() == Settings.IniFormat: + QtCore.QSettings.__init__(self, Settings.__filePath__, + Settings.IniFormat) + else: + QtCore.QSettings.__init__(self, *args) + + def value(self, key): + """ + Returns the value for the given ``key``. The returned ``value`` is + of the same type as the ``defaultValue``. + + ``key`` + The key to return the value from. + + ``defaultValue`` + The value to be returned if the given ``key`` is not present in the + config. Note, the ``defaultValue``'s type defines the type the + returned is converted to. In other words, if the ``defaultValue`` is + a boolean, then the returned value will be converted to a boolean. + + **Note**, this method only converts a few types and might need to be + extended if a certain type is missing! + """ + if u'/' not in key: + key = self.group() + u'/' + key + defaultValue = Settings.__defaultValues__[key] + setting = super(Settings, self).value(key, defaultValue) + # An empty list saved to the settings results in a None type being + # returned. + if setting is None: + return [] + # Convert the setting to the correct type. + if isinstance(defaultValue, bool): + if isinstance(setting, bool): + return setting + # Sometimes setting is string instead of a boolean. + return setting == u'true' + if isinstance(defaultValue, int): + return int(setting) + return setting + + def get_text_file_string(text_file): """ Open a file and return its content as unicode string. If the supplied file diff --git a/openlp/core/lib/formattingtags.py b/openlp/core/lib/formattingtags.py index c74b81d4d..6197845ee 100644 --- a/openlp/core/lib/formattingtags.py +++ b/openlp/core/lib/formattingtags.py @@ -165,7 +165,7 @@ class FormattingTags(object): FormattingTags.add_html_tags(temporary_tags) # Formatting Tags were also known as display tags. - user_expands = Settings().value(u'displayTags/html_tags', u'') + user_expands = Settings().value(u'displayTags/html_tags') # cPickle only accepts str not unicode strings user_expands_string = str(user_expands) if user_expands_string: diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index 8eb79ddfd..05de5e5a9 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -465,7 +465,7 @@ class MediaManagerItem(QtGui.QWidget): """ Allows the list click action to be determined dynamically """ - if Settings().value(u'advanced/double click live', False): + if Settings().value(u'advanced/double click live'): self.onLiveClick() else: self.onPreviewClick() @@ -474,10 +474,9 @@ class MediaManagerItem(QtGui.QWidget): """ Allows the change of current item in the list to be actioned """ - if Settings().value(u'advanced/single click preview', - False) and self.quickPreviewAllowed \ - and self.listView.selectedIndexes() \ - and self.autoSelectId == -1: + if Settings().value(u'advanced/single click preview') and \ + self.quickPreviewAllowed and self.listView.selectedIndexes() and \ + self.autoSelectId == -1: self.onPreviewClick(True) def onPreviewClick(self, keepFocus=False): diff --git a/openlp/core/lib/plugin.py b/openlp/core/lib/plugin.py index 2720c1ab6..68be6420c 100644 --- a/openlp/core/lib/plugin.py +++ b/openlp/core/lib/plugin.py @@ -192,8 +192,7 @@ class Plugin(QtCore.QObject): """ Sets the status of the plugin """ - self.status = Settings().value( - self.settingsSection + u'/status', PluginStatus.Inactive) + self.status = Settings().value(self.settingsSection + u'/status') def toggleStatus(self, new_status): """ diff --git a/openlp/core/lib/settingsmanager.py b/openlp/core/lib/settingsmanager.py index 403c15b09..3bb091f3e 100644 --- a/openlp/core/lib/settingsmanager.py +++ b/openlp/core/lib/settingsmanager.py @@ -61,7 +61,7 @@ class SettingsManager(object): name = u'last directory %d' % num else: name = u'last directory' - return Settings().value(section + u'/' + name, u'') + return Settings().value(section + u'/' + name) @staticmethod def set_last_dir(section, directory, num=None): diff --git a/openlp/core/ui/firsttimeform.py b/openlp/core/ui/firsttimeform.py index 353598909..5d25bc28d 100644 --- a/openlp/core/ui/firsttimeform.py +++ b/openlp/core/ui/firsttimeform.py @@ -120,7 +120,7 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): 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', False) + self.hasRunWizard = Settings().value(u'general/has run wizard') # Sort out internet access for downloads if self.webAccess: songs = self.config.get(u'songs', u'languages') @@ -213,7 +213,7 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): index = self.themeComboBox.findText(theme) if index == -1: self.themeComboBox.addItem(theme) - default_theme = Settings().value(u'themes/global theme', u'') + default_theme = Settings().value(u'themes/global theme') # Pre-select the current default theme. index = self.themeComboBox.findText(default_theme) self.themeComboBox.setCurrentIndex(index) diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index 7193ad024..4f5a70827 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -142,6 +142,7 @@ class MainDisplay(Display): # Default to False on Gnome. x11_bypass_default = bool(not os.environ.get(u'GNOME_DESKTOP_SESSION_ID')) + # TODO: check if Settings().value(u'advanced/x11 bypass wm', x11_bypass_default): windowFlags |= QtCore.Qt.X11BypassWindowManagerHint # TODO: The following combination of windowFlags works correctly @@ -209,11 +210,10 @@ class MainDisplay(Display): # Build the initial frame. background_color = QtGui.QColor() background_color.setNamedColor(Settings().value( - u'advanced/default color', u'#ffffff')) + u'advanced/default color')) if not background_color.isValid(): background_color = QtCore.Qt.white - image_file = Settings().value(u'advanced/default image', - u':/graphics/openlp-splash-screen.png') + image_file = Settings().value(u'advanced/default image') splash_image = QtGui.QImage(image_file) self.initialFrame = QtGui.QImage( self.screen[u'size'].width(), @@ -377,7 +377,7 @@ class MainDisplay(Display): # Single screen active if self.screens.display_count == 1: # Only make visible if setting enabled. - if Settings().value(u'general/display on monitor', True): + if Settings().value(u'general/display on monitor'): self.setVisible(True) else: self.setVisible(True) @@ -428,7 +428,7 @@ class MainDisplay(Display): self.footer(serviceItem.foot_text) # if was hidden keep it hidden if self.hideMode and self.isLive and not serviceItem.is_media(): - if Settings().value(u'general/auto unblank', False): + if Settings().value(u'general/auto unblank'): Receiver.send_message(u'slidecontroller_live_unblank') else: self.hideDisplay(self.hideMode) @@ -451,7 +451,7 @@ class MainDisplay(Display): log.debug(u'hideDisplay mode = %d', mode) if self.screens.display_count == 1: # Only make visible if setting enabled. - if not Settings().value(u'general/display on monitor', True): + if not Settings().value(u'general/display on monitor'): return if mode == HideMode.Screen: self.frame.evaluateJavaScript(u'show_blank("desktop");') @@ -475,7 +475,7 @@ class MainDisplay(Display): log.debug(u'showDisplay') if self.screens.display_count == 1: # Only make visible if setting enabled. - if not Settings().value(u'general/display on monitor', True): + if not Settings().value(u'general/display on monitor'): return self.frame.evaluateJavaScript('show_blank("show");') if self.isHidden(): @@ -489,7 +489,7 @@ class MainDisplay(Display): """ Hide mouse cursor when moved over display. """ - if Settings().value(u'advanced/hide mouse', True): + if Settings().value(u'advanced/hide mouse'): self.setCursor(QtCore.Qt.BlankCursor) self.frame.evaluateJavaScript('document.body.style.cursor = "none"') else: diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 42b4740a2..b0053233d 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -104,10 +104,10 @@ class Ui_MainWindow(object): # Create slide controllers self.previewController = SlideController(self) self.liveController = SlideController(self, True) - previewVisible = Settings().value(u'user interface/preview panel', True) + previewVisible = Settings().value(u'user interface/preview panel') self.previewController.panel.setVisible(previewVisible) - liveVisible = Settings().value(u'user interface/live panel', True) - panelLocked = Settings().value(u'user interface/lock panel', False) + liveVisible = Settings().value(u'user interface/live panel') + panelLocked = Settings().value(u'user interface/lock panel') self.liveController.panel.setVisible(liveVisible) # Create menu self.menuBar = QtGui.QMenuBar(mainWindow) @@ -701,8 +701,8 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): self.previewController.screenSizeChanged() self.liveController.screenSizeChanged() log.info(u'Load data from Settings') - if Settings().value(u'advanced/save current plugin', False): - savedPlugin = Settings().value(u'advanced/current media plugin', -1) + if Settings().value(u'advanced/save current plugin'): + savedPlugin = Settings().value(u'advanced/current media plugin') if savedPlugin != -1: self.mediaToolBox.setCurrentIndex(savedPlugin) self.settingsForm.postSetUp() @@ -754,10 +754,10 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): filename = unicode(filename, sys.getfilesystemencoding()) self.serviceManagerContents.loadFile(filename) elif Settings().value( - self.generalSettingsSection + u'/auto open', False): + self.generalSettingsSection + u'/auto open'): self.serviceManagerContents.loadLastFile() view_mode = Settings().value(u'%s/view mode' % - self.generalSettingsSection, u'default') + self.generalSettingsSection) if view_mode == u'default': self.modeDefaultItem.setChecked(True) elif view_mode == u'setup': @@ -1168,7 +1168,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): else: event.ignore() else: - if Settings().value(u'advanced/enable exit confirmation', True): + if Settings().value(u'advanced/enable exit confirmation'): ret = QtGui.QMessageBox.question(self, translate('OpenLP.MainWindow', 'Close OpenLP'), translate('OpenLP.MainWindow', @@ -1198,7 +1198,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): # Clean temporary files used by services self.serviceManagerContents.cleanUp() if save_settings: - if Settings().value(u'advanced/save current plugin', False): + if Settings().value(u'advanced/save current plugin'): Settings().setValue(u'advanced/current media plugin', self.mediaToolBox.currentIndex()) # Call the cleanup method to shutdown plugins. @@ -1340,7 +1340,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): if Settings().contains(self.generalSettingsSection + u'/enable slide loop'): if Settings().value(self.generalSettingsSection + - u'/enable slide loop', True): + u'/enable slide loop'): Settings().setValue(self.advancedSettingsSection + u'/slide limits', SlideLimits.Wrap) else: @@ -1399,7 +1399,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): Updates the recent file menu with the latest list of service files accessed. """ - recentFileCount = Settings().value(u'advanced/recent file count', 4) + recentFileCount = Settings().value(u'advanced/recent file count') existingRecentFiles = [recentFile for recentFile in self.recentFiles if os.path.isfile(unicode(recentFile))] recentFilesToDisplay = existingRecentFiles[0:recentFileCount] @@ -1431,7 +1431,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): # The maxRecentFiles value does not have an interface and so never gets # actually stored in the settings therefore the default value of 20 will # always be used. - maxRecentFiles = Settings().value(u'advanced/max recent files', 20) + maxRecentFiles = Settings().value(u'advanced/max recent files') if filename: # Add some cleanup to reduce duplication in the recent file list filename = os.path.abspath(filename) diff --git a/openlp/core/ui/media/__init__.py b/openlp/core/ui/media/__init__.py index 9435ae1bf..cfac9d461 100644 --- a/openlp/core/ui/media/__init__.py +++ b/openlp/core/ui/media/__init__.py @@ -76,10 +76,10 @@ def get_media_players(): from the settings. """ log.debug(u'get_media_players') - saved_players = Settings().value(u'media/players', u'webkit') + saved_players = Settings().value(u'media/players') reg_ex = QtCore.QRegExp(".*\[(.*)\].*") - if Settings().value(u'media/override player', - QtCore.Qt.Unchecked)== QtCore.Qt.Checked: + if Settings().value(u'media/override player') == \ + QtCore.Qt.Checked: if reg_ex.exactMatch(saved_players): overridden_player = u'%s' % reg_ex.cap(1) else: @@ -103,7 +103,7 @@ def set_media_players(players_list, overridden_player=u'auto'): """ log.debug(u'set_media_players') players = u','.join(players_list) - if Settings().value(u'media/override player', QtCore.Qt.Unchecked) == QtCore.Qt.Checked and \ + if Settings().value(u'media/override player') == QtCore.Qt.Checked and \ overridden_player != u'auto': players = players.replace(overridden_player, u'[%s]' % overridden_player) Settings().setValue(u'media/players', players) diff --git a/openlp/core/ui/media/mediacontroller.py b/openlp/core/ui/media/mediacontroller.py index 0ab529141..f380cd570 100644 --- a/openlp/core/ui/media/mediacontroller.py +++ b/openlp/core/ui/media/mediacontroller.py @@ -382,7 +382,7 @@ class MediaController(object): elif not hidden or controller.media_info.is_background or serviceItem.will_auto_start: autoplay = True # Unblank on load set - elif Settings().value(u'general/auto unblank', False): + elif Settings().value(u'general/auto unblank'): autoplay = True if autoplay: if not self.media_play(controller): diff --git a/openlp/core/ui/media/phononplayer.py b/openlp/core/ui/media/phononplayer.py index b22219f50..26a73f3fb 100644 --- a/openlp/core/ui/media/phononplayer.py +++ b/openlp/core/ui/media/phononplayer.py @@ -222,7 +222,7 @@ class PhononPlayer(MediaPlayer): """ Add css style sheets to htmlbuilder """ - background = QtGui.QColor(Settings().value(u'players/background color', u'#000000')).name() + background = QtGui.QColor(Settings().value(u'players/background color')).name() return VIDEO_CSS % (background,background,background) def get_info(self): diff --git a/openlp/core/ui/media/vlcplayer.py b/openlp/core/ui/media/vlcplayer.py index 07204aedc..fff97b327 100644 --- a/openlp/core/ui/media/vlcplayer.py +++ b/openlp/core/ui/media/vlcplayer.py @@ -113,7 +113,7 @@ class VlcPlayer(MediaPlayer): command_line_options = u'--no-video-title-show' if not display.hasAudio: command_line_options += u' --no-audio --no-video-title-show' - if Settings().value(u'advanced/hide mouse', True) and display.controller.isLive: + if Settings().value(u'advanced/hide mouse') and display.controller.isLive: command_line_options += u' --mouse-hide-timeout=0' display.vlcInstance = vlc.Instance(command_line_options) display.vlcInstance.set_log_verbosity(2) diff --git a/openlp/core/ui/media/webkitplayer.py b/openlp/core/ui/media/webkitplayer.py index 1c01e79a5..70fbc2afd 100644 --- a/openlp/core/ui/media/webkitplayer.py +++ b/openlp/core/ui/media/webkitplayer.py @@ -282,7 +282,7 @@ class WebkitPlayer(MediaPlayer): """ Add css style sheets to htmlbuilder """ - background = QtGui.QColor(Settings().value(u'players/background color', u'#000000')).name() + background = QtGui.QColor(Settings().value(u'players/background color')).name() css = VIDEO_CSS % (background,background,background) return css + FLASH_CSS diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 129a1addd..715041e2b 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -230,7 +230,7 @@ class ServiceManager(QtGui.QWidget): QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'theme_update_global'), self.themeChange) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'service_item_update'), self.serviceItemUpdate) # Last little bits of setting up - self.service_theme = Settings().value(self.mainwindow.serviceManagerSettingsSection + u'/service theme', u'') + self.service_theme = Settings().value(self.mainwindow.serviceManagerSettingsSection + u'/service theme') self.servicePath = AppLocation.get_section_data_path(u'servicemanager') # build the drag and drop context menu self.dndMenu = QtGui.QMenu() @@ -318,7 +318,7 @@ class ServiceManager(QtGui.QWidget): """ Triggered when Config dialog is updated. """ - self.expandTabs = Settings().value(u'advanced/expand service item', False) + self.expandTabs = Settings().value(u'advanced/expand service item') def resetSupportedSuffixes(self): """ @@ -595,25 +595,21 @@ class ServiceManager(QtGui.QWidget): Get a file name and then call :func:`ServiceManager.saveFile` to save the file. """ - default_service_enabled = Settings().value(u'advanced/default service enabled', True) + default_service_enabled = Settings().value(u'advanced/default service enabled') if default_service_enabled: - service_day = Settings().value(u'advanced/default service day', 7) + service_day = Settings().value(u'advanced/default service day') if service_day == 7: local_time = datetime.now() else: - service_hour = Settings().value(u'advanced/default service hour', 11) - service_minute = Settings().value(u'advanced/default service minute', 0) + service_hour = Settings().value(u'advanced/default service hour') + service_minute = Settings().value(u'advanced/default service minute') now = datetime.now() day_delta = service_day - now.weekday() if day_delta < 0: day_delta += 7 time = now + timedelta(days=day_delta) local_time = time.replace(hour=service_hour, minute=service_minute) - default_pattern = Settings().value(u'advanced/default service name', - translate('OpenLP.AdvancedTab', 'Service %Y-%m-%d %H-%M', - 'This may not contain any of the following characters: ' - '/\\?*|<>\[\]":+\nSee http://docs.python.org/library/' - 'datetime.html#strftime-strptime-behavior for more information.')) + default_pattern = Settings().value(u'advanced/default service name') default_filename = format_time(default_pattern, local_time) else: default_filename = u'' @@ -741,7 +737,7 @@ class ServiceManager(QtGui.QWidget): service was last closed. Can be blank if there was no service present. """ - fileName = Settings().value(u'servicemanager/last file', u'') + fileName = Settings().value(u'servicemanager/last file') if fileName: self.loadFile(fileName) @@ -1290,8 +1286,7 @@ class ServiceManager(QtGui.QWidget): self.mainwindow.liveController.addServiceManagerItem( self.serviceItems[item][u'service_item'], child) if Settings().value( - self.mainwindow.generalSettingsSection + u'/auto preview', - False): + self.mainwindow.generalSettingsSection + u'/auto preview'): item += 1 if self.serviceItems and item < len(self.serviceItems) and \ self.serviceItems[item][u'service_item'].is_capable(ItemCapabilities.CanPreview): diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index a986dd998..5d2fc00d3 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -211,7 +211,7 @@ class SlideController(DisplayController): self.playSlidesOnce = create_action(self, u'playSlidesOnce', text=UiStrings().PlaySlidesToEnd, icon=u':/media/media_time.png', checked=False, shortcuts=[], category=self.category, triggers=self.onPlaySlidesOnce) - if Settings().value(self.parent().generalSettingsSection + u'/enable slide loop', True): + if Settings().value(self.parent().generalSettingsSection + u'/enable slide loop'): self.playSlidesMenu.setDefaultAction(self.playSlidesLoop) else: self.playSlidesMenu.setDefaultAction(self.playSlidesOnce) @@ -585,7 +585,7 @@ class SlideController(DisplayController): """ Updates the Slide Limits variable from the settings. """ - self.slide_limits = Settings().value(self.parent().advancedSettingsSection + u'/slide limits', SlideLimits.End) + self.slide_limits = Settings().value(self.parent().advancedSettingsSection + u'/slide limits') def enableToolBar(self, item): """ @@ -613,7 +613,7 @@ class SlideController(DisplayController): self.playSlidesLoop.setChecked(False) self.playSlidesLoop.setIcon(build_icon(u':/media/media_time.png')) if item.is_text(): - if Settings().value(self.parent().songsSettingsSection + u'/display songbar', True) and self.slideList: + if Settings().value(self.parent().songsSettingsSection + u'/display songbar') and self.slideList: self.songMenu.show() if item.is_capable(ItemCapabilities.CanLoop) and len(item.get_frames()) > 1: self.toolbar.setWidgetVisible(self.loopList) @@ -727,8 +727,8 @@ class SlideController(DisplayController): action.setData(counter) QtCore.QObject.connect(action, QtCore.SIGNAL(u'triggered(bool)'), self.onTrackTriggered) self.display.audioPlayer.repeat = Settings().value( - self.parent().generalSettingsSection + u'/audio repeat list', False) - if Settings().value(self.parent().generalSettingsSection + u'/audio start paused', True): + self.parent().generalSettingsSection + u'/audio repeat list') + if Settings().value(self.parent().generalSettingsSection + u'/audio start paused'): self.audioPauseItem.setChecked(True) self.display.audioPlayer.pause() else: @@ -837,8 +837,7 @@ class SlideController(DisplayController): Allow the main display to blank the main display at startup time """ log.debug(u'mainDisplaySetBackground live = %s' % self.isLive) - display_type = Settings().value(self.parent().generalSettingsSection + u'/screen blank', - u'') + display_type = Settings().value(self.parent().generalSettingsSection + u'/screen blank') if self.screens.which_screen(self.window()) != self.screens.which_screen(self.display): # Order done to handle initial conversion if display_type == u'themed': @@ -1192,7 +1191,7 @@ class SlideController(DisplayController): """ triggered by clicking the Preview slide items """ - if Settings().value(u'advanced/double click live', False): + if Settings().value(u'advanced/double click live'): # Live and Preview have issues if we have video or presentations # playing in both at the same time. if self.serviceItem.is_command(): diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index 6d1222481..76d26d1cb 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -167,7 +167,7 @@ class ThemeManager(QtGui.QWidget): Triggered when Config dialog is updated. """ self.global_theme = Settings().value( - self.settingsSection + u'/global theme', u'') + self.settingsSection + u'/global theme') def checkListState(self, item): """ @@ -451,7 +451,7 @@ class ThemeManager(QtGui.QWidget): self.settingsSection + u'/global theme', theme.theme_name) self.configUpdated() files = SettingsManager.get_files(self.settingsSection, u'.png') - # Sort the themes by its name considering language specific + # Sort the themes by its name considering language specific files.sort(key=lambda file_name: unicode(file_name), cmp=locale_compare) # now process the file list of png files @@ -767,7 +767,7 @@ class ThemeManager(QtGui.QWidget): is allowed. """ self.global_theme = Settings().value( - self.settingsSection + u'/global theme', u'') + self.settingsSection + u'/global theme') if check_item_selected(self.themeListWidget, select_text): item = self.themeListWidget.currentItem() theme = item.text() diff --git a/openlp/core/ui/themestab.py b/openlp/core/ui/themestab.py index 12a474881..71d87d020 100644 --- a/openlp/core/ui/themestab.py +++ b/openlp/core/ui/themestab.py @@ -184,7 +184,7 @@ class ThemesTab(SettingsTab): """ # Reload as may have been triggered by the ThemeManager. self.global_theme = Settings().value( - self.settingsSection + u'/global theme', u'') + self.settingsSection + u'/global theme') self.DefaultComboBox.clear() self.DefaultComboBox.addItems(theme_list) find_and_set_in_combo_box(self.DefaultComboBox, self.global_theme) diff --git a/openlp/core/utils/languagemanager.py b/openlp/core/utils/languagemanager.py index 2c5c51411..e3b761f63 100644 --- a/openlp/core/utils/languagemanager.py +++ b/openlp/core/utils/languagemanager.py @@ -107,7 +107,7 @@ class LanguageManager(object): """ Retrieve a saved language to use from settings """ - language = Settings().value(u'general/language', u'[en]') + language = Settings().value(u'general/language') language = str(language) log.info(u'Language file: \'%s\' Loaded from conf file' % language) if re.match(r'[[].*[]]', language): diff --git a/openlp/plugins/bibles/lib/manager.py b/openlp/plugins/bibles/lib/manager.py index 1ca67e58f..b1c8795ec 100644 --- a/openlp/plugins/bibles/lib/manager.py +++ b/openlp/plugins/bibles/lib/manager.py @@ -128,7 +128,7 @@ class BibleManager(object): self.db_cache = None self.path = AppLocation.get_section_data_path(self.settingsSection) self.proxy_name = Settings().value( - self.settingsSection + u'/proxy name', u'') + self.settingsSection + u'/proxy name') self.suffix = u'.sqlite' self.import_wizard = None self.reload_bibles() @@ -372,7 +372,7 @@ class BibleManager(object): # If None is returned, it's not the singleton object but a # BibleMeta object with the value "None" language_selection = Settings().value( - self.settingsSection + u'/book name language', 0) + self.settingsSection + u'/book name language') else: language_selection = language_selection.value try: diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index 639db6018..4ce8d21d7 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -292,7 +292,7 @@ class BibleMediaItem(MediaManagerItem): def configUpdated(self): log.debug(u'configUpdated') - if Settings().value(self.settingsSection + u'/second bibles', True): + if Settings().value(self.settingsSection + u'/second bibles'): self.advancedSecondLabel.setVisible(True) self.advancedSecondComboBox.setVisible(True) self.quickSecondLabel.setVisible(True) @@ -360,8 +360,7 @@ class BibleMediaItem(MediaManagerItem): translate('BiblesPlugin.MediaItem', 'Search Text...')) ]) self.quickSearchEdit.setCurrentSearchType(Settings().value( - u'%s/last search type' % self.settingsSection, - BibleSearch.Reference)) + u'%s/last search type' % self.settingsSection)) self.configUpdated() log.debug(u'bible manager initialise complete') @@ -383,12 +382,13 @@ class BibleMediaItem(MediaManagerItem): self.advancedVersionComboBox.addItems(bibles) self.advancedSecondComboBox.addItems(bibles) # set the default value - bible = Settings().value(self.settingsSection + u'/advanced bible', u'') + bible = Settings().value(self.settingsSection + u'/advanced bible') if bible in bibles: find_and_set_in_combo_box(self.advancedVersionComboBox, bible) self.initialiseAdvancedBible(unicode(bible)) elif bibles: self.initialiseAdvancedBible(bibles[0]) + # TODO: check bible = Settings().value( self.settingsSection + u'/quick bible', self.quickVersionComboBox.currentText()) diff --git a/openlp/plugins/custom/lib/customtab.py b/openlp/plugins/custom/lib/customtab.py index 537261b64..e441185c2 100644 --- a/openlp/plugins/custom/lib/customtab.py +++ b/openlp/plugins/custom/lib/customtab.py @@ -69,7 +69,7 @@ class CustomTab(SettingsTab): def load(self): self.displayFooter = Settings().value( - self.settingsSection + u'/display footer', True) + self.settingsSection + u'/display footer') self.displayFooterCheckBox.setChecked(self.displayFooter) def save(self): diff --git a/openlp/plugins/custom/lib/mediaitem.py b/openlp/plugins/custom/lib/mediaitem.py index 7662a3338..d6b25218e 100644 --- a/openlp/plugins/custom/lib/mediaitem.py +++ b/openlp/plugins/custom/lib/mediaitem.py @@ -100,6 +100,7 @@ class CustomMediaItem(MediaManagerItem): ]) self.loadList(self.manager.get_all_objects( CustomSlide, order_by_ref=CustomSlide.title)) + # TODO: check self.searchTextEdit.setCurrentSearchType(Settings().value( u'%s/last search type' % self.settingsSection, CustomSearch.Titles)) @@ -211,8 +212,7 @@ class CustomMediaItem(MediaManagerItem): service_item.title = title for slide in raw_slides: service_item.add_from_text(slide) - if Settings().value(self.settingsSection + u'/display footer', - True) or credit: + if Settings().value(self.settingsSection + u'/display footer') or credit: service_item.raw_footer.append(u' '.join([title, credit])) else: service_item.raw_footer.append(u'') diff --git a/openlp/plugins/images/imageplugin.py b/openlp/plugins/images/imageplugin.py index 62652ffaf..d08263c07 100644 --- a/openlp/plugins/images/imageplugin.py +++ b/openlp/plugins/images/imageplugin.py @@ -97,6 +97,6 @@ class ImagePlugin(Plugin): last part of saving the config. """ background = QtGui.QColor(Settings().value(self.settingsSection - + u'/background color', u'#000000')) + + u'/background color')) self.liveController.imageManager.updateImagesBorder( ImageSource.ImagePlugin, background) diff --git a/openlp/plugins/images/lib/mediaitem.py b/openlp/plugins/images/lib/mediaitem.py index fb99e9155..af11da624 100644 --- a/openlp/plugins/images/lib/mediaitem.py +++ b/openlp/plugins/images/lib/mediaitem.py @@ -153,7 +153,7 @@ class ImageMediaItem(MediaManagerItem): def generateSlideData(self, service_item, item=None, xmlVersion=False, remote=False, context=ServiceItemContext.Service): background = QtGui.QColor(Settings().value(self.settingsSection - + u'/background color', u'#000000')) + + u'/background color')) if item: items = [item] else: @@ -222,7 +222,7 @@ class ImageMediaItem(MediaManagerItem): translate('ImagePlugin.MediaItem', 'You must select an image to replace the background with.')): background = QtGui.QColor(Settings().value( - self.settingsSection + u'/background color', u'#000000')) + self.settingsSection + u'/background color')) item = self.listView.selectedIndexes()[0] bitem = self.listView.item(item.row()) filename = bitem.data(QtCore.Qt.UserRole) diff --git a/openlp/plugins/media/lib/mediaitem.py b/openlp/plugins/media/lib/mediaitem.py index efcf3b36e..a9e2e739e 100644 --- a/openlp/plugins/media/lib/mediaitem.py +++ b/openlp/plugins/media/lib/mediaitem.py @@ -192,7 +192,7 @@ class MediaMediaItem(MediaManagerItem): service_item.add_capability(ItemCapabilities.CanAutoStartForLive) service_item.add_capability(ItemCapabilities.RequiresMedia) service_item.add_capability(ItemCapabilities.HasDetailedTitleDisplay) - if Settings().value(self.settingsSection + u'/media auto start', QtCore.Qt.Unchecked) == QtCore.Qt.Checked: + if Settings().value(self.settingsSection + u'/media auto start') == QtCore.Qt.Checked: service_item.will_auto_start = True # force a non-existent theme service_item.theme = -1 diff --git a/openlp/plugins/media/lib/mediatab.py b/openlp/plugins/media/lib/mediatab.py index 345edd7a7..ab71f75d5 100644 --- a/openlp/plugins/media/lib/mediatab.py +++ b/openlp/plugins/media/lib/mediatab.py @@ -72,19 +72,17 @@ class MediaTab(SettingsTab): self.autoStartCheckBox.setText(translate('MediaPlugin.MediaTab', 'Start Live items automatically')) def load(self): - self.overridePlayerCheckBox.setChecked(Settings().value(self.settingsSection + u'/override player', - QtCore.Qt.Unchecked)) - self.autoStartCheckBox.setChecked(Settings().value(self.settingsSection + u'/media auto start', - QtCore.Qt.Unchecked)) + self.overridePlayerCheckBox.setChecked(Settings().value(self.settingsSection + u'/override player')) + self.autoStartCheckBox.setChecked(Settings().value(self.settingsSection + u'/media auto start')) def save(self): override_changed = False setting_key = self.settingsSection + u'/override player' - if Settings().value(setting_key, QtCore.Qt.Unchecked) != self.overridePlayerCheckBox.checkState(): + if Settings().value(setting_key) != self.overridePlayerCheckBox.checkState(): Settings().setValue(setting_key, self.overridePlayerCheckBox.checkState()) override_changed = True setting_key = self.settingsSection + u'/media auto start' - if Settings().value(setting_key, QtCore.Qt.Unchecked) != self.autoStartCheckBox.checkState(): + if Settings().value(setting_key) != self.autoStartCheckBox.checkState(): Settings().setValue(setting_key, self.autoStartCheckBox.checkState()) if override_changed: self.parent.resetSupportedSuffixes() diff --git a/openlp/plugins/presentations/lib/mediaitem.py b/openlp/plugins/presentations/lib/mediaitem.py index 462d12a5d..8f369ca3c 100644 --- a/openlp/plugins/presentations/lib/mediaitem.py +++ b/openlp/plugins/presentations/lib/mediaitem.py @@ -148,8 +148,8 @@ class PresentationMediaItem(MediaManagerItem): if self.displayTypeComboBox.count() > 1: self.displayTypeComboBox.insertItem(0, self.Automatic) self.displayTypeComboBox.setCurrentIndex(0) - if Settings().value(self.settingsSection + u'/override app', - QtCore.Qt.Unchecked) == QtCore.Qt.Checked: + if Settings().value(self.settingsSection + + u'/override app') == QtCore.Qt.Checked: self.presentationWidget.show() else: self.presentationWidget.hide() diff --git a/openlp/plugins/presentations/lib/presentationcontroller.py b/openlp/plugins/presentations/lib/presentationcontroller.py index 746bc7de9..f7caa2fc9 100644 --- a/openlp/plugins/presentations/lib/presentationcontroller.py +++ b/openlp/plugins/presentations/lib/presentationcontroller.py @@ -392,6 +392,7 @@ class PresentationController(object): """ Return whether the controller is currently enabled """ + # TODO: check if Settings().value(self.settings_section + u'/' + self.name, QtCore.Qt.Checked) == QtCore.Qt.Checked: return self.is_available() diff --git a/openlp/plugins/presentations/lib/presentationtab.py b/openlp/plugins/presentations/lib/presentationtab.py index 220da0d74..59f0fb1cb 100644 --- a/openlp/plugins/presentations/lib/presentationtab.py +++ b/openlp/plugins/presentations/lib/presentationtab.py @@ -105,6 +105,7 @@ class PresentationTab(SettingsTab): for key in self.controllers: controller = self.controllers[key] checkbox = self.PresenterCheckboxes[controller.name] + # TODO check checkbox.setChecked(Settings().value( self.settingsSection + u'/' + controller.name, QtCore.Qt.Checked)) diff --git a/openlp/plugins/remotes/lib/httpserver.py b/openlp/plugins/remotes/lib/httpserver.py index 23f2cf83c..cbc67d4b3 100644 --- a/openlp/plugins/remotes/lib/httpserver.py +++ b/openlp/plugins/remotes/lib/httpserver.py @@ -171,10 +171,8 @@ class HttpServer(object): clients. Listen out for socket connections. """ log.debug(u'Start TCP server') - port = Settings().value( - self.plugin.settingsSection + u'/port', 4316) - address = Settings().value( - self.plugin.settingsSection + u'/ip address', u'0.0.0.0') + port = Settings().value(self.plugin.settingsSection + u'/port') + address = Settings().value(self.plugin.settingsSection + u'/ip address') self.server = QtNetwork.QTcpServer() self.server.listen(QtNetwork.QHostAddress(address), port) QtCore.QObject.connect(Receiver.get_receiver(), @@ -406,7 +404,7 @@ class HttpConnection(object): u'slide': self.parent.current_slide or 0, u'item': self.parent.current_item._uuid \ if self.parent.current_item else u'', - u'twelve':Settings().value(u'remotes/twelve hour', True), + u'twelve':Settings().value(u'remotes/twelve hour'), u'blank': self.parent.plugin.liveController.blankScreen.isChecked(), u'theme': self.parent.plugin.liveController.themeScreen.isChecked(), u'display': \ diff --git a/openlp/plugins/remotes/lib/remotetab.py b/openlp/plugins/remotes/lib/remotetab.py index 75ea3f290..bf235e0bd 100644 --- a/openlp/plugins/remotes/lib/remotetab.py +++ b/openlp/plugins/remotes/lib/remotetab.py @@ -151,19 +151,20 @@ class RemoteTab(SettingsTab): def load(self): self.portSpinBox.setValue( - Settings().value(self.settingsSection + u'/port', 4316)) + Settings().value(self.settingsSection + u'/port')) self.addressEdit.setText( - Settings().value(self.settingsSection + u'/ip address', ZERO_URL)) + Settings().value(self.settingsSection + u'/ip address')) self.twelveHour = Settings().value( - self.settingsSection + u'/twelve hour', True) + self.settingsSection + u'/twelve hour') self.twelveHourCheckBox.setChecked(self.twelveHour) self.setUrls() def save(self): changed = False + #TODO: check if Settings().value(self.settingsSection + u'/ip address', ZERO_URL != self.addressEdit.text() or Settings().value(self.settingsSection + - u'/port', 4316) != self.portSpinBox.value()): + u'/port') != self.portSpinBox.value()): changed = True Settings().setValue(self.settingsSection + u'/port', self.portSpinBox.value()) diff --git a/openlp/plugins/songs/forms/songimportform.py b/openlp/plugins/songs/forms/songimportform.py index e95a277a7..6e0f45b8d 100644 --- a/openlp/plugins/songs/forms/songimportform.py +++ b/openlp/plugins/songs/forms/songimportform.py @@ -343,8 +343,7 @@ class SongImportForm(OpenLPWizard): self.restart() self.finishButton.setVisible(False) self.cancelButton.setVisible(True) - last_import_type = Settings().value( - u'songs/last import type') + last_import_type = Settings().value(u'songs/last import type') if last_import_type < 0 or \ last_import_type >= self.formatComboBox.count(): last_import_type = 0 diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index a6419de20..2df0cba5e 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -171,11 +171,11 @@ class SongMediaItem(MediaManagerItem): def configUpdated(self): self.searchAsYouType = Settings().value( - self.settingsSection + u'/search as type', False) + self.settingsSection + u'/search as type') self.updateServiceOnEdit = Settings().value( - self.settingsSection + u'/update service on edit', False) + self.settingsSection + u'/update service on edit') self.addSongFromService = Settings().value( - self.settingsSection + u'/add song from service', True) + self.settingsSection + u'/add song from service') def retranslateUi(self): self.searchTextLabel.setText(u'%s:' % UiStrings().Search) @@ -204,6 +204,7 @@ class SongMediaItem(MediaManagerItem): (SongSearch.Themes, u':/slides/slide_theme.png', UiStrings().Themes, UiStrings().SearchThemes) ]) + # TODO: check self.searchTextEdit.setCurrentSearchType(Settings().value( u'%s/last search type' % self.settingsSection, SongSearch.Entire)) self.configUpdated() @@ -546,10 +547,10 @@ class SongMediaItem(MediaManagerItem): service_item.raw_footer.append(song.title) service_item.raw_footer.append(create_separated_list(author_list)) service_item.raw_footer.append(song.copyright) - if Settings().value(u'general/ccli number', u''): + if Settings().value(u'general/ccli number'): service_item.raw_footer.append( translate('SongsPlugin.MediaItem', 'CCLI License: ') + - Settings().value(u'general/ccli number', u'')) + Settings().value(u'general/ccli number')) service_item.audit = [ song.title, author_list, song.copyright, unicode(song.ccli_number) ] diff --git a/openlp/plugins/songusage/forms/songusagedetailform.py b/openlp/plugins/songusage/forms/songusagedetailform.py index bd46f9173..c15c2f1b2 100644 --- a/openlp/plugins/songusage/forms/songusagedetailform.py +++ b/openlp/plugins/songusage/forms/songusagedetailform.py @@ -61,6 +61,7 @@ class SongUsageDetailForm(QtGui.QDialog, Ui_SongUsageDetailDialog): year = QtCore.QDate().currentDate().year() if QtCore.QDate().currentDate().month() < 9: year -= 1 + # TODO: check toDate = Settings().value(self.plugin.settingsSection + u'/to date', QtCore.QDate(year, 8, 31)) fromDate = Settings().value(self.plugin.settingsSection + diff --git a/openlp/plugins/songusage/songusageplugin.py b/openlp/plugins/songusage/songusageplugin.py index b95d53a6f..e3f22da9f 100644 --- a/openlp/plugins/songusage/songusageplugin.py +++ b/openlp/plugins/songusage/songusageplugin.py @@ -127,7 +127,7 @@ class SongUsagePlugin(Plugin): QtCore.SIGNAL(u'print_service_started'), self.printSongUsage) self.songUsageActive = Settings().value( - self.settingsSection + u'/active', False) + self.settingsSection + u'/active') # Set the button and checkbox state self.setButtonState() action_list = ActionList.get_instance() From b6c9fa16c50478b5819e806827341fc413cac787 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Thu, 27 Dec 2012 17:27:59 +0100 Subject: [PATCH 39/53] reverted last commit --- openlp/core/__init__.py | 8 +- openlp/core/lib/__init__.py | 314 ++++-------------- openlp/core/lib/formattingtags.py | 2 +- openlp/core/lib/mediamanageritem.py | 9 +- openlp/core/lib/plugin.py | 3 +- openlp/core/lib/settingsmanager.py | 2 +- openlp/core/ui/firsttimeform.py | 4 +- openlp/core/ui/maindisplay.py | 16 +- openlp/core/ui/mainwindow.py | 24 +- openlp/core/ui/media/__init__.py | 8 +- openlp/core/ui/media/mediacontroller.py | 2 +- openlp/core/ui/media/phononplayer.py | 2 +- openlp/core/ui/media/vlcplayer.py | 2 +- openlp/core/ui/media/webkitplayer.py | 2 +- openlp/core/ui/servicemanager.py | 23 +- openlp/core/ui/slidecontroller.py | 15 +- openlp/core/ui/thememanager.py | 6 +- openlp/core/ui/themestab.py | 2 +- openlp/core/utils/languagemanager.py | 2 +- openlp/plugins/bibles/lib/manager.py | 4 +- openlp/plugins/bibles/lib/mediaitem.py | 8 +- openlp/plugins/custom/lib/customtab.py | 2 +- openlp/plugins/custom/lib/mediaitem.py | 4 +- openlp/plugins/images/imageplugin.py | 2 +- openlp/plugins/images/lib/mediaitem.py | 4 +- openlp/plugins/media/lib/mediaitem.py | 2 +- openlp/plugins/media/lib/mediatab.py | 10 +- openlp/plugins/presentations/lib/mediaitem.py | 4 +- .../lib/presentationcontroller.py | 1 - .../presentations/lib/presentationtab.py | 1 - openlp/plugins/remotes/lib/httpserver.py | 8 +- openlp/plugins/remotes/lib/remotetab.py | 9 +- openlp/plugins/songs/forms/songimportform.py | 3 +- openlp/plugins/songs/lib/mediaitem.py | 11 +- .../songusage/forms/songusagedetailform.py | 1 - openlp/plugins/songusage/songusageplugin.py | 2 +- 36 files changed, 171 insertions(+), 351 deletions(-) diff --git a/openlp/core/__init__.py b/openlp/core/__init__.py index 672f655f5..04f99bfa7 100644 --- a/openlp/core/__init__.py +++ b/openlp/core/__init__.py @@ -118,7 +118,7 @@ class OpenLP(QtGui.QApplication): # Decide how many screens we have and their size screens = ScreenList.create(self.desktop()) # First time checks in settings - has_run_wizard = Settings().value(u'general/has run wizard') + has_run_wizard = Settings().value(u'general/has run wizard', False) if not has_run_wizard: if FirstTimeForm(screens).exec_() == QtGui.QDialog.Accepted: Settings().setValue(u'general/has run wizard', True) @@ -129,7 +129,7 @@ class OpenLP(QtGui.QApplication): u'QTableWidget, QListWidget, QTreeWidget {alternate-background-color: ' + base_color.name() + ';}\n' application_stylesheet += nt_repair_stylesheet self.setStyleSheet(application_stylesheet) - show_splash = Settings().value(u'general/show splash') + show_splash = Settings().value(u'general/show splash', True) if show_splash: self.splash = SplashScreen() self.splash.show() @@ -148,7 +148,7 @@ class OpenLP(QtGui.QApplication): self.processEvents() if not has_run_wizard: self.mainWindow.firstTime() - update_check = Settings().value(u'general/update check') + update_check = Settings().value(u'general/update check', True) if update_check: VersionThread(self.mainWindow).start() Receiver.send_message(u'live_display_blank_check') @@ -295,7 +295,7 @@ def main(args=None): if app.isAlreadyRunning(): sys.exit() # First time checks in settings - if not Settings().value(u'general/has run wizard'): + if not Settings().value(u'general/has run wizard', False): if not FirstTimeLanguageForm().exec_(): # if cancel then stop processing sys.exit() diff --git a/openlp/core/lib/__init__.py b/openlp/core/lib/__init__.py index c76557346..4a3cf7d54 100644 --- a/openlp/core/lib/__init__.py +++ b/openlp/core/lib/__init__.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- # vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 + ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # @@ -29,7 +30,6 @@ The :mod:`lib` module contains most of the components and libraries that make OpenLP work. """ -import datetime import logging import os @@ -90,6 +90,68 @@ class ServiceItemAction(object): Next = 3 +class Settings(QtCore.QSettings): + """ + Class to wrap QSettings. + + * Exposes all the methods of QSettings. + * Adds functionality for OpenLP Portable. If the ``defaultFormat`` is set to + ``IniFormat``, and the path to the Ini file is set using ``setFilename``, + then the Settings constructor (without any arguments) will create a Settings + object for accessing settings stored in that Ini file. + """ + __filePath__ = u'' + + @staticmethod + def setFilename(iniFile): + """ + Sets the complete path to an Ini file to be used by Settings objects. + + Does not affect existing Settings objects. + """ + Settings.__filePath__ = iniFile + + def __init__(self, *args): + if not args and Settings.__filePath__ and \ + Settings.defaultFormat() == Settings.IniFormat: + QtCore.QSettings.__init__(self, Settings.__filePath__, + Settings.IniFormat) + else: + QtCore.QSettings.__init__(self, *args) + + def value(self, key, defaultValue): + """ + Returns the value for the given ``key``. The returned ``value`` is + of the same type as the ``defaultValue``. + + ``key`` + The key to return the value from. + + ``defaultValue`` + The value to be returned if the given ``key`` is not present in the + config. Note, the ``defaultValue``'s type defines the type the + returned is converted to. In other words, if the ``defaultValue`` is + a boolean, then the returned value will be converted to a boolean. + + **Note**, this method only converts a few types and might need to be + extended if a certain type is missing! + """ + setting = super(Settings, self).value(key, defaultValue) + # An empty list saved to the settings results in a None type being + # returned. + if setting is None: + return [] + # Convert the setting to the correct type. + if isinstance(defaultValue, bool): + if isinstance(setting, bool): + return setting + # Sometimes setting is string instead of a boolean. + return setting == u'true' + if isinstance(defaultValue, int): + return int(setting) + return setting + + def translate(context, text, comment=None, encoding=QtCore.QCoreApplication.CodecForTr, n=-1, translate=QtCore.QCoreApplication.translate): @@ -112,256 +174,6 @@ def translate(context, text, comment=None, return translate(context, text, comment, encoding, n) -class Settings(QtCore.QSettings): - """ - Class to wrap QSettings. - - * Exposes all the methods of QSettings. - * Adds functionality for OpenLP Portable. If the ``defaultFormat`` is set to - ``IniFormat``, and the path to the Ini file is set using ``setFilename``, - then the Settings constructor (without any arguments) will create a Settings - object for accessing settings stored in that Ini file. - """ - __filePath__ = u'' - __defaultValues__ = { - u'advanced/x11 bypass wm': True, - u'advanced/default service enabled': True, - u'advanced/enable exit confirmation': True, - u'advanced/save current plugin': False, - u'advanced/single click preview': False, - u'advanced/default service day': 7, - u'advanced/max recent files': 20, - u'advanced/is portable': False, - u'advanced/hide mouse': True, - u'advanced/current media plugin': -1, - u'advanced/double click live': False, - u'advanced/default service hour': 11, - u'advanced/default color': u'#ffffff', - u'advanced/default image': u':/graphics/openlp-splash-screen.png', - u'advanced/expand service item': False, - u'advanced/recent file count': 4, - u'advanced/default service name': translate( - 'OpenLP.AdvancedTab', 'Service %Y-%m-%d %H-%M', - 'This may not contain any of the following characters: ' - '/\\?*|<>\[\]":+\nSee http://docs.python.org/library/' - 'datetime.html#strftime-strptime-behavior for more information.'), - u'advanced/default service minute': 0, - u'advanced/slide limits': SlideLimits.End, - u'alerts/font face': u'Sans', - u'alerts/font size': 40, - u'alerts/status': 0,#PluginStatus.Inactive, - u'alerts/db type': u'sqlite', - u'alerts/location': 2, - u'alerts/background color': u'#660000', - u'alerts/font color': u'#ffffff', - u'alerts/timeout': 5, - u'bibles/book name language': 0, - u'bibles/verse separator': u'', - u'bibles/advanced bible': u'', - u'bibles/proxy name': u'', - u'bibles/db type': u'sqlite', - u'bibles/status': 0, # PluginStatus.Inactive, - u'bibles/bible theme': u'', - u'bibles/range separator': u'', - u'bibles/display new chapter': False, - u'bibles/verse layout style': 0, - u'bibles/display brackets': 0, - u'bibles/list separator': u'', - u'bibles/second bibles': True, - u'bibles/quick bible': u'Afrikaans Bybel', - u'bibles/end separator': u'', - u'bibles/last search type': 1, - u'custom/db type': u'sqlite', - u'custom/display footer': True, - u'custom/last search type': 1, - u'custom/status': 0, # PluginStatus.Inactive, - u'displayTags/html_tags': u'', - u'general/ccli number': u'', - u'general/y position': 0, - u'general/has run wizard': False, - u'general/update check': True, - u'general/language': u'[en]', - u'general/songselect password': u'', - u'general/recent files': [], - u'general/save prompt': False, - u'general/auto preview': False, - u'general/override position': False, - u'general/view mode': u'default', - u'general/auto open': False, - u'general/enable slide loop': True, - u'general/show splash': True, - u'general/screen blank': False, - u'general/x position': 0, - u'general/loop delay': 5, - u'general/height': 1024, - u'general/monitor': 0, - u'general/songselect username': u'', - u'general/audio repeat list': False, - u'general/auto unblank': False, - u'general/display on monitor': True, - u'general/width': 1280, - u'general/audio start paused': True, - u'general/last version test': datetime.datetime.now().date(), - u'general/blank warning': False, - u'images/images count': 0, - u'images/background color': u'#000000', - u'images/status': 0, # PluginStatus.Inactive, - u'media/override player': QtCore.Qt.Unchecked, - u'media/media count': 0, - u'media/media auto start': QtCore.Qt.Unchecked, - u'media/status': 0, # PluginStatus.Inactive, - u'media/players': u'webkit', - u'players/background color': u'#000000', - u'presentations/Impress': 2, - u'presentations/override app': QtCore.Qt.Unchecked, - u'presentations/presentations count': 0, - u'presentations/Powerpoint': 2, - u'presentations/status': 0, # PluginStatus.Inactive, - u'presentations/Powerpoint Viewer': 2, - u'remotes/twelve hour': True, - u'remotes/status': 0, # PluginStatus.Inactive, - u'remotes/port': 4316, - u'remotes/ip address': u'0.0.0.0', - u'servicemanager/service theme': u'', - u'shortcuts/viewPreviewPanel': [QtGui.QKeySequence(u'F11')], - u'shortcuts/settingsImportItem': [], - u'shortcuts/settingsPluginListItem': [QtGui.QKeySequence(u'Alt+F7')], - u'shortcuts/modeLiveItem': [], - u'shortcuts/songUsageStatus': [QtCore.Qt.Key_F4], - u'shortcuts/nextTrackItem': [], - u'shortcuts/makeLive': [QtCore.Qt.Key_Enter, QtCore.Qt.Key_Return], - u'shortcuts/webSiteItem': [], - u'shortcuts/shortcutAction_P': [QtGui.QKeySequence(u'P')], - u'shortcuts/previousItem_live': [QtCore.Qt.Key_Up, QtCore.Qt.Key_PageUp], - u'shortcuts/shortcutAction_V': [QtGui.QKeySequence(u'V')], - u'shortcuts/fileOpenItem': [QtGui.QKeySequence(u'Ctrl+O')], - u'shortcuts/viewMediaManagerItem': [QtGui.QKeySequence(u'F8')], - u'shortcuts/desktopScreen': [QtGui.QKeySequence(u'D')], - u'shortcuts/songExportItem': [], - u'shortcuts/modeDefaultItem': [], - u'shortcuts/audioPauseItem': [], - u'shortcuts/themeScreen': [QtGui.QKeySequence(u'T')], - u'shortcuts/expand': [QtCore.Qt.Key_Plus], - u'shortcuts/exportThemeItem': [], - u'shortcuts/viewThemeManagerItem': [QtGui.QKeySequence(u'F10')], - u'shortcuts/playSlidesLoop': [], - u'shortcuts/playSlidesOnce': [], - u'shortcuts/toolsReindexItem': [], - u'shortcuts/toolsAlertItem': [u'F7'], - u'shortcuts/printServiceItem': [QtGui.QKeySequence(u'Ctrl+P')], - u'shortcuts/moveUp': [QtCore.Qt.Key_PageUp], - u'shortcuts/settingsShortcutsItem': [], - u'shortcuts/nextItem_live': [QtCore.Qt.Key_Down, QtCore.Qt.Key_PageDown], - u'shortcuts/moveTop': [QtCore.Qt.Key_Home], - u'shortcuts/blankScreen': [QtCore.Qt.Key_Period], - u'shortcuts/settingsConfigureItem': [], - u'shortcuts/modeSetupItem': [], - u'shortcuts/songUsageDelete': [], - u'shortcuts/shortcutAction_C': [QtGui.QKeySequence(u'C')], - u'shortcuts/shortcutAction_B': [QtGui.QKeySequence(u'B')], - u'shortcuts/shortcutAction_E': [QtGui.QKeySequence(u'E')], - u'shortcuts/shortcutAction_I': [QtGui.QKeySequence(u'I')], - u'shortcuts/shortcutAction_O': [QtGui.QKeySequence(u'O')], - u'shortcuts/importBibleItem': [], - u'shortcuts/fileExitItem': [QtGui.QKeySequence(u'Alt+F4')], - u'shortcuts/fileSaveItem': [QtGui.QKeySequence(u'Ctrl+S')], - u'shortcuts/up': [QtCore.Qt.Key_Up], - u'shortcuts/nextService': [QtCore.Qt.Key_Right], - u'shortcuts/songImportItem': [], - u'shortcuts/toolsOpenDataFolder': [], - u'shortcuts/fileNewItem': [QtGui.QKeySequence(u'Ctrl+N')], - u'shortcuts/aboutItem': [QtGui.QKeySequence(u'Ctrl+F1')], - u'shortcuts/viewLivePanel': [QtGui.QKeySequence(u'F12')], - u'shortcuts/songUsageReport': [], - u'shortcuts/updateThemeImages': [], - u'shortcuts/toolsAddToolItem': [], - u'shortcuts/fileSaveAsItem': [QtGui.QKeySequence(u'Ctrl+Shift+S')], - u'shortcuts/settingsExportItem': [], - u'shortcuts/onlineHelpItem': [QtGui.QKeySequence(u'Alt+F1')], - u'shortcuts/escapeItem': [QtCore.Qt.Key_Escape], - u'shortcuts/displayTagItem': [], - u'shortcuts/moveBottom': [QtCore.Qt.Key_End], - u'shortcuts/toolsFirstTimeWizard': [], - u'shortcuts/moveDown': [QtCore.Qt.Key_PageDown], - u'shortcuts/collapse': [QtCore.Qt.Key_Minus], - u'shortcuts/viewServiceManagerItem': [QtGui.QKeySequence(u'F9')], - u'shortcuts/previousService': [QtCore.Qt.Key_Left], - u'shortcuts/importThemeItem': [], - u'shortcuts/down': [QtCore.Qt.Key_Down], - u'songs/update service on edit': False, - u'songs/search as type': False, - u'songs/add song from service': True, - u'songs/display songbar': True, - u'songs/last search type': 1, # BibleSearch.Reference, - u'songusage/db type': u'sqlite', - u'songusage/status': 0, # PluginStatus.Inactive, - u'songusage/active': False, - u'themes/theme level': 3, - u'themes/global theme': u'', - u'user interface/main window position': QtCore.QPoint(), - u'user interface/preview panel': True, - u'user interface/live panel': True, - u'user interface/main window geometry': QtCore.QByteArray(), - u'user interface/preview splitter geometry': QtCore.QByteArray(), - u'user interface/lock panel': False, - u'user interface/mainwindow splitter geometry': QtCore.QByteArray(), - u'user interface/live splitter geometry': QtCore.QByteArray(), - u'user interface/main window state': QtCore.QByteArray() -} - - @staticmethod - def setFilename(iniFile): - """ - Sets the complete path to an Ini file to be used by Settings objects. - - Does not affect existing Settings objects. - """ - Settings.__filePath__ = iniFile - - def __init__(self, *args): - if not args and Settings.__filePath__ and \ - Settings.defaultFormat() == Settings.IniFormat: - QtCore.QSettings.__init__(self, Settings.__filePath__, - Settings.IniFormat) - else: - QtCore.QSettings.__init__(self, *args) - - def value(self, key): - """ - Returns the value for the given ``key``. The returned ``value`` is - of the same type as the ``defaultValue``. - - ``key`` - The key to return the value from. - - ``defaultValue`` - The value to be returned if the given ``key`` is not present in the - config. Note, the ``defaultValue``'s type defines the type the - returned is converted to. In other words, if the ``defaultValue`` is - a boolean, then the returned value will be converted to a boolean. - - **Note**, this method only converts a few types and might need to be - extended if a certain type is missing! - """ - if u'/' not in key: - key = self.group() + u'/' + key - defaultValue = Settings.__defaultValues__[key] - setting = super(Settings, self).value(key, defaultValue) - # An empty list saved to the settings results in a None type being - # returned. - if setting is None: - return [] - # Convert the setting to the correct type. - if isinstance(defaultValue, bool): - if isinstance(setting, bool): - return setting - # Sometimes setting is string instead of a boolean. - return setting == u'true' - if isinstance(defaultValue, int): - return int(setting) - return setting - - def get_text_file_string(text_file): """ Open a file and return its content as unicode string. If the supplied file diff --git a/openlp/core/lib/formattingtags.py b/openlp/core/lib/formattingtags.py index 6197845ee..c74b81d4d 100644 --- a/openlp/core/lib/formattingtags.py +++ b/openlp/core/lib/formattingtags.py @@ -165,7 +165,7 @@ class FormattingTags(object): FormattingTags.add_html_tags(temporary_tags) # Formatting Tags were also known as display tags. - user_expands = Settings().value(u'displayTags/html_tags') + user_expands = Settings().value(u'displayTags/html_tags', u'') # cPickle only accepts str not unicode strings user_expands_string = str(user_expands) if user_expands_string: diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index 05de5e5a9..8eb79ddfd 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -465,7 +465,7 @@ class MediaManagerItem(QtGui.QWidget): """ Allows the list click action to be determined dynamically """ - if Settings().value(u'advanced/double click live'): + if Settings().value(u'advanced/double click live', False): self.onLiveClick() else: self.onPreviewClick() @@ -474,9 +474,10 @@ class MediaManagerItem(QtGui.QWidget): """ Allows the change of current item in the list to be actioned """ - if Settings().value(u'advanced/single click preview') and \ - self.quickPreviewAllowed and self.listView.selectedIndexes() and \ - self.autoSelectId == -1: + if Settings().value(u'advanced/single click preview', + False) and self.quickPreviewAllowed \ + and self.listView.selectedIndexes() \ + and self.autoSelectId == -1: self.onPreviewClick(True) def onPreviewClick(self, keepFocus=False): diff --git a/openlp/core/lib/plugin.py b/openlp/core/lib/plugin.py index 68be6420c..2720c1ab6 100644 --- a/openlp/core/lib/plugin.py +++ b/openlp/core/lib/plugin.py @@ -192,7 +192,8 @@ class Plugin(QtCore.QObject): """ Sets the status of the plugin """ - self.status = Settings().value(self.settingsSection + u'/status') + self.status = Settings().value( + self.settingsSection + u'/status', PluginStatus.Inactive) def toggleStatus(self, new_status): """ diff --git a/openlp/core/lib/settingsmanager.py b/openlp/core/lib/settingsmanager.py index 3bb091f3e..403c15b09 100644 --- a/openlp/core/lib/settingsmanager.py +++ b/openlp/core/lib/settingsmanager.py @@ -61,7 +61,7 @@ class SettingsManager(object): name = u'last directory %d' % num else: name = u'last directory' - return Settings().value(section + u'/' + name) + return Settings().value(section + u'/' + name, u'') @staticmethod def set_last_dir(section, directory, num=None): diff --git a/openlp/core/ui/firsttimeform.py b/openlp/core/ui/firsttimeform.py index 5d25bc28d..353598909 100644 --- a/openlp/core/ui/firsttimeform.py +++ b/openlp/core/ui/firsttimeform.py @@ -120,7 +120,7 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): 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') + self.hasRunWizard = Settings().value(u'general/has run wizard', False) # Sort out internet access for downloads if self.webAccess: songs = self.config.get(u'songs', u'languages') @@ -213,7 +213,7 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): index = self.themeComboBox.findText(theme) if index == -1: self.themeComboBox.addItem(theme) - default_theme = Settings().value(u'themes/global theme') + default_theme = Settings().value(u'themes/global theme', u'') # Pre-select the current default theme. index = self.themeComboBox.findText(default_theme) self.themeComboBox.setCurrentIndex(index) diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index 4f5a70827..7193ad024 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -142,7 +142,6 @@ class MainDisplay(Display): # Default to False on Gnome. x11_bypass_default = bool(not os.environ.get(u'GNOME_DESKTOP_SESSION_ID')) - # TODO: check if Settings().value(u'advanced/x11 bypass wm', x11_bypass_default): windowFlags |= QtCore.Qt.X11BypassWindowManagerHint # TODO: The following combination of windowFlags works correctly @@ -210,10 +209,11 @@ class MainDisplay(Display): # Build the initial frame. background_color = QtGui.QColor() background_color.setNamedColor(Settings().value( - u'advanced/default color')) + u'advanced/default color', u'#ffffff')) if not background_color.isValid(): background_color = QtCore.Qt.white - image_file = Settings().value(u'advanced/default image') + image_file = Settings().value(u'advanced/default image', + u':/graphics/openlp-splash-screen.png') splash_image = QtGui.QImage(image_file) self.initialFrame = QtGui.QImage( self.screen[u'size'].width(), @@ -377,7 +377,7 @@ class MainDisplay(Display): # Single screen active if self.screens.display_count == 1: # Only make visible if setting enabled. - if Settings().value(u'general/display on monitor'): + if Settings().value(u'general/display on monitor', True): self.setVisible(True) else: self.setVisible(True) @@ -428,7 +428,7 @@ class MainDisplay(Display): self.footer(serviceItem.foot_text) # if was hidden keep it hidden if self.hideMode and self.isLive and not serviceItem.is_media(): - if Settings().value(u'general/auto unblank'): + if Settings().value(u'general/auto unblank', False): Receiver.send_message(u'slidecontroller_live_unblank') else: self.hideDisplay(self.hideMode) @@ -451,7 +451,7 @@ class MainDisplay(Display): log.debug(u'hideDisplay mode = %d', mode) if self.screens.display_count == 1: # Only make visible if setting enabled. - if not Settings().value(u'general/display on monitor'): + if not Settings().value(u'general/display on monitor', True): return if mode == HideMode.Screen: self.frame.evaluateJavaScript(u'show_blank("desktop");') @@ -475,7 +475,7 @@ class MainDisplay(Display): log.debug(u'showDisplay') if self.screens.display_count == 1: # Only make visible if setting enabled. - if not Settings().value(u'general/display on monitor'): + if not Settings().value(u'general/display on monitor', True): return self.frame.evaluateJavaScript('show_blank("show");') if self.isHidden(): @@ -489,7 +489,7 @@ class MainDisplay(Display): """ Hide mouse cursor when moved over display. """ - if Settings().value(u'advanced/hide mouse'): + if Settings().value(u'advanced/hide mouse', True): self.setCursor(QtCore.Qt.BlankCursor) self.frame.evaluateJavaScript('document.body.style.cursor = "none"') else: diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index b0053233d..42b4740a2 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -104,10 +104,10 @@ class Ui_MainWindow(object): # Create slide controllers self.previewController = SlideController(self) self.liveController = SlideController(self, True) - previewVisible = Settings().value(u'user interface/preview panel') + previewVisible = Settings().value(u'user interface/preview panel', True) self.previewController.panel.setVisible(previewVisible) - liveVisible = Settings().value(u'user interface/live panel') - panelLocked = Settings().value(u'user interface/lock panel') + liveVisible = Settings().value(u'user interface/live panel', True) + panelLocked = Settings().value(u'user interface/lock panel', False) self.liveController.panel.setVisible(liveVisible) # Create menu self.menuBar = QtGui.QMenuBar(mainWindow) @@ -701,8 +701,8 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): self.previewController.screenSizeChanged() self.liveController.screenSizeChanged() log.info(u'Load data from Settings') - if Settings().value(u'advanced/save current plugin'): - savedPlugin = Settings().value(u'advanced/current media plugin') + if Settings().value(u'advanced/save current plugin', False): + savedPlugin = Settings().value(u'advanced/current media plugin', -1) if savedPlugin != -1: self.mediaToolBox.setCurrentIndex(savedPlugin) self.settingsForm.postSetUp() @@ -754,10 +754,10 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): filename = unicode(filename, sys.getfilesystemencoding()) self.serviceManagerContents.loadFile(filename) elif Settings().value( - self.generalSettingsSection + u'/auto open'): + self.generalSettingsSection + u'/auto open', False): self.serviceManagerContents.loadLastFile() view_mode = Settings().value(u'%s/view mode' % - self.generalSettingsSection) + self.generalSettingsSection, u'default') if view_mode == u'default': self.modeDefaultItem.setChecked(True) elif view_mode == u'setup': @@ -1168,7 +1168,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): else: event.ignore() else: - if Settings().value(u'advanced/enable exit confirmation'): + if Settings().value(u'advanced/enable exit confirmation', True): ret = QtGui.QMessageBox.question(self, translate('OpenLP.MainWindow', 'Close OpenLP'), translate('OpenLP.MainWindow', @@ -1198,7 +1198,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): # Clean temporary files used by services self.serviceManagerContents.cleanUp() if save_settings: - if Settings().value(u'advanced/save current plugin'): + if Settings().value(u'advanced/save current plugin', False): Settings().setValue(u'advanced/current media plugin', self.mediaToolBox.currentIndex()) # Call the cleanup method to shutdown plugins. @@ -1340,7 +1340,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): if Settings().contains(self.generalSettingsSection + u'/enable slide loop'): if Settings().value(self.generalSettingsSection + - u'/enable slide loop'): + u'/enable slide loop', True): Settings().setValue(self.advancedSettingsSection + u'/slide limits', SlideLimits.Wrap) else: @@ -1399,7 +1399,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): Updates the recent file menu with the latest list of service files accessed. """ - recentFileCount = Settings().value(u'advanced/recent file count') + recentFileCount = Settings().value(u'advanced/recent file count', 4) existingRecentFiles = [recentFile for recentFile in self.recentFiles if os.path.isfile(unicode(recentFile))] recentFilesToDisplay = existingRecentFiles[0:recentFileCount] @@ -1431,7 +1431,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): # The maxRecentFiles value does not have an interface and so never gets # actually stored in the settings therefore the default value of 20 will # always be used. - maxRecentFiles = Settings().value(u'advanced/max recent files') + maxRecentFiles = Settings().value(u'advanced/max recent files', 20) if filename: # Add some cleanup to reduce duplication in the recent file list filename = os.path.abspath(filename) diff --git a/openlp/core/ui/media/__init__.py b/openlp/core/ui/media/__init__.py index cfac9d461..9435ae1bf 100644 --- a/openlp/core/ui/media/__init__.py +++ b/openlp/core/ui/media/__init__.py @@ -76,10 +76,10 @@ def get_media_players(): from the settings. """ log.debug(u'get_media_players') - saved_players = Settings().value(u'media/players') + saved_players = Settings().value(u'media/players', u'webkit') reg_ex = QtCore.QRegExp(".*\[(.*)\].*") - if Settings().value(u'media/override player') == \ - QtCore.Qt.Checked: + if Settings().value(u'media/override player', + QtCore.Qt.Unchecked)== QtCore.Qt.Checked: if reg_ex.exactMatch(saved_players): overridden_player = u'%s' % reg_ex.cap(1) else: @@ -103,7 +103,7 @@ def set_media_players(players_list, overridden_player=u'auto'): """ log.debug(u'set_media_players') players = u','.join(players_list) - if Settings().value(u'media/override player') == QtCore.Qt.Checked and \ + if Settings().value(u'media/override player', QtCore.Qt.Unchecked) == QtCore.Qt.Checked and \ overridden_player != u'auto': players = players.replace(overridden_player, u'[%s]' % overridden_player) Settings().setValue(u'media/players', players) diff --git a/openlp/core/ui/media/mediacontroller.py b/openlp/core/ui/media/mediacontroller.py index f380cd570..0ab529141 100644 --- a/openlp/core/ui/media/mediacontroller.py +++ b/openlp/core/ui/media/mediacontroller.py @@ -382,7 +382,7 @@ class MediaController(object): elif not hidden or controller.media_info.is_background or serviceItem.will_auto_start: autoplay = True # Unblank on load set - elif Settings().value(u'general/auto unblank'): + elif Settings().value(u'general/auto unblank', False): autoplay = True if autoplay: if not self.media_play(controller): diff --git a/openlp/core/ui/media/phononplayer.py b/openlp/core/ui/media/phononplayer.py index 26a73f3fb..b22219f50 100644 --- a/openlp/core/ui/media/phononplayer.py +++ b/openlp/core/ui/media/phononplayer.py @@ -222,7 +222,7 @@ class PhononPlayer(MediaPlayer): """ Add css style sheets to htmlbuilder """ - background = QtGui.QColor(Settings().value(u'players/background color')).name() + background = QtGui.QColor(Settings().value(u'players/background color', u'#000000')).name() return VIDEO_CSS % (background,background,background) def get_info(self): diff --git a/openlp/core/ui/media/vlcplayer.py b/openlp/core/ui/media/vlcplayer.py index fff97b327..07204aedc 100644 --- a/openlp/core/ui/media/vlcplayer.py +++ b/openlp/core/ui/media/vlcplayer.py @@ -113,7 +113,7 @@ class VlcPlayer(MediaPlayer): command_line_options = u'--no-video-title-show' if not display.hasAudio: command_line_options += u' --no-audio --no-video-title-show' - if Settings().value(u'advanced/hide mouse') and display.controller.isLive: + if Settings().value(u'advanced/hide mouse', True) and display.controller.isLive: command_line_options += u' --mouse-hide-timeout=0' display.vlcInstance = vlc.Instance(command_line_options) display.vlcInstance.set_log_verbosity(2) diff --git a/openlp/core/ui/media/webkitplayer.py b/openlp/core/ui/media/webkitplayer.py index 70fbc2afd..1c01e79a5 100644 --- a/openlp/core/ui/media/webkitplayer.py +++ b/openlp/core/ui/media/webkitplayer.py @@ -282,7 +282,7 @@ class WebkitPlayer(MediaPlayer): """ Add css style sheets to htmlbuilder """ - background = QtGui.QColor(Settings().value(u'players/background color')).name() + background = QtGui.QColor(Settings().value(u'players/background color', u'#000000')).name() css = VIDEO_CSS % (background,background,background) return css + FLASH_CSS diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 715041e2b..129a1addd 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -230,7 +230,7 @@ class ServiceManager(QtGui.QWidget): QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'theme_update_global'), self.themeChange) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'service_item_update'), self.serviceItemUpdate) # Last little bits of setting up - self.service_theme = Settings().value(self.mainwindow.serviceManagerSettingsSection + u'/service theme') + self.service_theme = Settings().value(self.mainwindow.serviceManagerSettingsSection + u'/service theme', u'') self.servicePath = AppLocation.get_section_data_path(u'servicemanager') # build the drag and drop context menu self.dndMenu = QtGui.QMenu() @@ -318,7 +318,7 @@ class ServiceManager(QtGui.QWidget): """ Triggered when Config dialog is updated. """ - self.expandTabs = Settings().value(u'advanced/expand service item') + self.expandTabs = Settings().value(u'advanced/expand service item', False) def resetSupportedSuffixes(self): """ @@ -595,21 +595,25 @@ class ServiceManager(QtGui.QWidget): Get a file name and then call :func:`ServiceManager.saveFile` to save the file. """ - default_service_enabled = Settings().value(u'advanced/default service enabled') + default_service_enabled = Settings().value(u'advanced/default service enabled', True) if default_service_enabled: - service_day = Settings().value(u'advanced/default service day') + service_day = Settings().value(u'advanced/default service day', 7) if service_day == 7: local_time = datetime.now() else: - service_hour = Settings().value(u'advanced/default service hour') - service_minute = Settings().value(u'advanced/default service minute') + service_hour = Settings().value(u'advanced/default service hour', 11) + service_minute = Settings().value(u'advanced/default service minute', 0) now = datetime.now() day_delta = service_day - now.weekday() if day_delta < 0: day_delta += 7 time = now + timedelta(days=day_delta) local_time = time.replace(hour=service_hour, minute=service_minute) - default_pattern = Settings().value(u'advanced/default service name') + default_pattern = Settings().value(u'advanced/default service name', + translate('OpenLP.AdvancedTab', 'Service %Y-%m-%d %H-%M', + 'This may not contain any of the following characters: ' + '/\\?*|<>\[\]":+\nSee http://docs.python.org/library/' + 'datetime.html#strftime-strptime-behavior for more information.')) default_filename = format_time(default_pattern, local_time) else: default_filename = u'' @@ -737,7 +741,7 @@ class ServiceManager(QtGui.QWidget): service was last closed. Can be blank if there was no service present. """ - fileName = Settings().value(u'servicemanager/last file') + fileName = Settings().value(u'servicemanager/last file', u'') if fileName: self.loadFile(fileName) @@ -1286,7 +1290,8 @@ class ServiceManager(QtGui.QWidget): self.mainwindow.liveController.addServiceManagerItem( self.serviceItems[item][u'service_item'], child) if Settings().value( - self.mainwindow.generalSettingsSection + u'/auto preview'): + self.mainwindow.generalSettingsSection + u'/auto preview', + False): item += 1 if self.serviceItems and item < len(self.serviceItems) and \ self.serviceItems[item][u'service_item'].is_capable(ItemCapabilities.CanPreview): diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index 5d2fc00d3..a986dd998 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -211,7 +211,7 @@ class SlideController(DisplayController): self.playSlidesOnce = create_action(self, u'playSlidesOnce', text=UiStrings().PlaySlidesToEnd, icon=u':/media/media_time.png', checked=False, shortcuts=[], category=self.category, triggers=self.onPlaySlidesOnce) - if Settings().value(self.parent().generalSettingsSection + u'/enable slide loop'): + if Settings().value(self.parent().generalSettingsSection + u'/enable slide loop', True): self.playSlidesMenu.setDefaultAction(self.playSlidesLoop) else: self.playSlidesMenu.setDefaultAction(self.playSlidesOnce) @@ -585,7 +585,7 @@ class SlideController(DisplayController): """ Updates the Slide Limits variable from the settings. """ - self.slide_limits = Settings().value(self.parent().advancedSettingsSection + u'/slide limits') + self.slide_limits = Settings().value(self.parent().advancedSettingsSection + u'/slide limits', SlideLimits.End) def enableToolBar(self, item): """ @@ -613,7 +613,7 @@ class SlideController(DisplayController): self.playSlidesLoop.setChecked(False) self.playSlidesLoop.setIcon(build_icon(u':/media/media_time.png')) if item.is_text(): - if Settings().value(self.parent().songsSettingsSection + u'/display songbar') and self.slideList: + if Settings().value(self.parent().songsSettingsSection + u'/display songbar', True) and self.slideList: self.songMenu.show() if item.is_capable(ItemCapabilities.CanLoop) and len(item.get_frames()) > 1: self.toolbar.setWidgetVisible(self.loopList) @@ -727,8 +727,8 @@ class SlideController(DisplayController): action.setData(counter) QtCore.QObject.connect(action, QtCore.SIGNAL(u'triggered(bool)'), self.onTrackTriggered) self.display.audioPlayer.repeat = Settings().value( - self.parent().generalSettingsSection + u'/audio repeat list') - if Settings().value(self.parent().generalSettingsSection + u'/audio start paused'): + self.parent().generalSettingsSection + u'/audio repeat list', False) + if Settings().value(self.parent().generalSettingsSection + u'/audio start paused', True): self.audioPauseItem.setChecked(True) self.display.audioPlayer.pause() else: @@ -837,7 +837,8 @@ class SlideController(DisplayController): Allow the main display to blank the main display at startup time """ log.debug(u'mainDisplaySetBackground live = %s' % self.isLive) - display_type = Settings().value(self.parent().generalSettingsSection + u'/screen blank') + display_type = Settings().value(self.parent().generalSettingsSection + u'/screen blank', + u'') if self.screens.which_screen(self.window()) != self.screens.which_screen(self.display): # Order done to handle initial conversion if display_type == u'themed': @@ -1191,7 +1192,7 @@ class SlideController(DisplayController): """ triggered by clicking the Preview slide items """ - if Settings().value(u'advanced/double click live'): + if Settings().value(u'advanced/double click live', False): # Live and Preview have issues if we have video or presentations # playing in both at the same time. if self.serviceItem.is_command(): diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index 76d26d1cb..6d1222481 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -167,7 +167,7 @@ class ThemeManager(QtGui.QWidget): Triggered when Config dialog is updated. """ self.global_theme = Settings().value( - self.settingsSection + u'/global theme') + self.settingsSection + u'/global theme', u'') def checkListState(self, item): """ @@ -451,7 +451,7 @@ class ThemeManager(QtGui.QWidget): self.settingsSection + u'/global theme', theme.theme_name) self.configUpdated() files = SettingsManager.get_files(self.settingsSection, u'.png') - # Sort the themes by its name considering language specific + # Sort the themes by its name considering language specific files.sort(key=lambda file_name: unicode(file_name), cmp=locale_compare) # now process the file list of png files @@ -767,7 +767,7 @@ class ThemeManager(QtGui.QWidget): is allowed. """ self.global_theme = Settings().value( - self.settingsSection + u'/global theme') + self.settingsSection + u'/global theme', u'') if check_item_selected(self.themeListWidget, select_text): item = self.themeListWidget.currentItem() theme = item.text() diff --git a/openlp/core/ui/themestab.py b/openlp/core/ui/themestab.py index 71d87d020..12a474881 100644 --- a/openlp/core/ui/themestab.py +++ b/openlp/core/ui/themestab.py @@ -184,7 +184,7 @@ class ThemesTab(SettingsTab): """ # Reload as may have been triggered by the ThemeManager. self.global_theme = Settings().value( - self.settingsSection + u'/global theme') + self.settingsSection + u'/global theme', u'') self.DefaultComboBox.clear() self.DefaultComboBox.addItems(theme_list) find_and_set_in_combo_box(self.DefaultComboBox, self.global_theme) diff --git a/openlp/core/utils/languagemanager.py b/openlp/core/utils/languagemanager.py index e3b761f63..2c5c51411 100644 --- a/openlp/core/utils/languagemanager.py +++ b/openlp/core/utils/languagemanager.py @@ -107,7 +107,7 @@ class LanguageManager(object): """ Retrieve a saved language to use from settings """ - language = Settings().value(u'general/language') + language = Settings().value(u'general/language', u'[en]') language = str(language) log.info(u'Language file: \'%s\' Loaded from conf file' % language) if re.match(r'[[].*[]]', language): diff --git a/openlp/plugins/bibles/lib/manager.py b/openlp/plugins/bibles/lib/manager.py index b1c8795ec..1ca67e58f 100644 --- a/openlp/plugins/bibles/lib/manager.py +++ b/openlp/plugins/bibles/lib/manager.py @@ -128,7 +128,7 @@ class BibleManager(object): self.db_cache = None self.path = AppLocation.get_section_data_path(self.settingsSection) self.proxy_name = Settings().value( - self.settingsSection + u'/proxy name') + self.settingsSection + u'/proxy name', u'') self.suffix = u'.sqlite' self.import_wizard = None self.reload_bibles() @@ -372,7 +372,7 @@ class BibleManager(object): # If None is returned, it's not the singleton object but a # BibleMeta object with the value "None" language_selection = Settings().value( - self.settingsSection + u'/book name language') + self.settingsSection + u'/book name language', 0) else: language_selection = language_selection.value try: diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index 4ce8d21d7..639db6018 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -292,7 +292,7 @@ class BibleMediaItem(MediaManagerItem): def configUpdated(self): log.debug(u'configUpdated') - if Settings().value(self.settingsSection + u'/second bibles'): + if Settings().value(self.settingsSection + u'/second bibles', True): self.advancedSecondLabel.setVisible(True) self.advancedSecondComboBox.setVisible(True) self.quickSecondLabel.setVisible(True) @@ -360,7 +360,8 @@ class BibleMediaItem(MediaManagerItem): translate('BiblesPlugin.MediaItem', 'Search Text...')) ]) self.quickSearchEdit.setCurrentSearchType(Settings().value( - u'%s/last search type' % self.settingsSection)) + u'%s/last search type' % self.settingsSection, + BibleSearch.Reference)) self.configUpdated() log.debug(u'bible manager initialise complete') @@ -382,13 +383,12 @@ class BibleMediaItem(MediaManagerItem): self.advancedVersionComboBox.addItems(bibles) self.advancedSecondComboBox.addItems(bibles) # set the default value - bible = Settings().value(self.settingsSection + u'/advanced bible') + bible = Settings().value(self.settingsSection + u'/advanced bible', u'') if bible in bibles: find_and_set_in_combo_box(self.advancedVersionComboBox, bible) self.initialiseAdvancedBible(unicode(bible)) elif bibles: self.initialiseAdvancedBible(bibles[0]) - # TODO: check bible = Settings().value( self.settingsSection + u'/quick bible', self.quickVersionComboBox.currentText()) diff --git a/openlp/plugins/custom/lib/customtab.py b/openlp/plugins/custom/lib/customtab.py index e441185c2..537261b64 100644 --- a/openlp/plugins/custom/lib/customtab.py +++ b/openlp/plugins/custom/lib/customtab.py @@ -69,7 +69,7 @@ class CustomTab(SettingsTab): def load(self): self.displayFooter = Settings().value( - self.settingsSection + u'/display footer') + self.settingsSection + u'/display footer', True) self.displayFooterCheckBox.setChecked(self.displayFooter) def save(self): diff --git a/openlp/plugins/custom/lib/mediaitem.py b/openlp/plugins/custom/lib/mediaitem.py index d6b25218e..7662a3338 100644 --- a/openlp/plugins/custom/lib/mediaitem.py +++ b/openlp/plugins/custom/lib/mediaitem.py @@ -100,7 +100,6 @@ class CustomMediaItem(MediaManagerItem): ]) self.loadList(self.manager.get_all_objects( CustomSlide, order_by_ref=CustomSlide.title)) - # TODO: check self.searchTextEdit.setCurrentSearchType(Settings().value( u'%s/last search type' % self.settingsSection, CustomSearch.Titles)) @@ -212,7 +211,8 @@ class CustomMediaItem(MediaManagerItem): service_item.title = title for slide in raw_slides: service_item.add_from_text(slide) - if Settings().value(self.settingsSection + u'/display footer') or credit: + if Settings().value(self.settingsSection + u'/display footer', + True) or credit: service_item.raw_footer.append(u' '.join([title, credit])) else: service_item.raw_footer.append(u'') diff --git a/openlp/plugins/images/imageplugin.py b/openlp/plugins/images/imageplugin.py index d08263c07..62652ffaf 100644 --- a/openlp/plugins/images/imageplugin.py +++ b/openlp/plugins/images/imageplugin.py @@ -97,6 +97,6 @@ class ImagePlugin(Plugin): last part of saving the config. """ background = QtGui.QColor(Settings().value(self.settingsSection - + u'/background color')) + + u'/background color', u'#000000')) self.liveController.imageManager.updateImagesBorder( ImageSource.ImagePlugin, background) diff --git a/openlp/plugins/images/lib/mediaitem.py b/openlp/plugins/images/lib/mediaitem.py index af11da624..fb99e9155 100644 --- a/openlp/plugins/images/lib/mediaitem.py +++ b/openlp/plugins/images/lib/mediaitem.py @@ -153,7 +153,7 @@ class ImageMediaItem(MediaManagerItem): def generateSlideData(self, service_item, item=None, xmlVersion=False, remote=False, context=ServiceItemContext.Service): background = QtGui.QColor(Settings().value(self.settingsSection - + u'/background color')) + + u'/background color', u'#000000')) if item: items = [item] else: @@ -222,7 +222,7 @@ class ImageMediaItem(MediaManagerItem): translate('ImagePlugin.MediaItem', 'You must select an image to replace the background with.')): background = QtGui.QColor(Settings().value( - self.settingsSection + u'/background color')) + self.settingsSection + u'/background color', u'#000000')) item = self.listView.selectedIndexes()[0] bitem = self.listView.item(item.row()) filename = bitem.data(QtCore.Qt.UserRole) diff --git a/openlp/plugins/media/lib/mediaitem.py b/openlp/plugins/media/lib/mediaitem.py index a9e2e739e..efcf3b36e 100644 --- a/openlp/plugins/media/lib/mediaitem.py +++ b/openlp/plugins/media/lib/mediaitem.py @@ -192,7 +192,7 @@ class MediaMediaItem(MediaManagerItem): service_item.add_capability(ItemCapabilities.CanAutoStartForLive) service_item.add_capability(ItemCapabilities.RequiresMedia) service_item.add_capability(ItemCapabilities.HasDetailedTitleDisplay) - if Settings().value(self.settingsSection + u'/media auto start') == QtCore.Qt.Checked: + if Settings().value(self.settingsSection + u'/media auto start', QtCore.Qt.Unchecked) == QtCore.Qt.Checked: service_item.will_auto_start = True # force a non-existent theme service_item.theme = -1 diff --git a/openlp/plugins/media/lib/mediatab.py b/openlp/plugins/media/lib/mediatab.py index ab71f75d5..345edd7a7 100644 --- a/openlp/plugins/media/lib/mediatab.py +++ b/openlp/plugins/media/lib/mediatab.py @@ -72,17 +72,19 @@ class MediaTab(SettingsTab): self.autoStartCheckBox.setText(translate('MediaPlugin.MediaTab', 'Start Live items automatically')) def load(self): - self.overridePlayerCheckBox.setChecked(Settings().value(self.settingsSection + u'/override player')) - self.autoStartCheckBox.setChecked(Settings().value(self.settingsSection + u'/media auto start')) + self.overridePlayerCheckBox.setChecked(Settings().value(self.settingsSection + u'/override player', + QtCore.Qt.Unchecked)) + self.autoStartCheckBox.setChecked(Settings().value(self.settingsSection + u'/media auto start', + QtCore.Qt.Unchecked)) def save(self): override_changed = False setting_key = self.settingsSection + u'/override player' - if Settings().value(setting_key) != self.overridePlayerCheckBox.checkState(): + if Settings().value(setting_key, QtCore.Qt.Unchecked) != self.overridePlayerCheckBox.checkState(): Settings().setValue(setting_key, self.overridePlayerCheckBox.checkState()) override_changed = True setting_key = self.settingsSection + u'/media auto start' - if Settings().value(setting_key) != self.autoStartCheckBox.checkState(): + if Settings().value(setting_key, QtCore.Qt.Unchecked) != self.autoStartCheckBox.checkState(): Settings().setValue(setting_key, self.autoStartCheckBox.checkState()) if override_changed: self.parent.resetSupportedSuffixes() diff --git a/openlp/plugins/presentations/lib/mediaitem.py b/openlp/plugins/presentations/lib/mediaitem.py index 8f369ca3c..462d12a5d 100644 --- a/openlp/plugins/presentations/lib/mediaitem.py +++ b/openlp/plugins/presentations/lib/mediaitem.py @@ -148,8 +148,8 @@ class PresentationMediaItem(MediaManagerItem): if self.displayTypeComboBox.count() > 1: self.displayTypeComboBox.insertItem(0, self.Automatic) self.displayTypeComboBox.setCurrentIndex(0) - if Settings().value(self.settingsSection + - u'/override app') == QtCore.Qt.Checked: + if Settings().value(self.settingsSection + u'/override app', + QtCore.Qt.Unchecked) == QtCore.Qt.Checked: self.presentationWidget.show() else: self.presentationWidget.hide() diff --git a/openlp/plugins/presentations/lib/presentationcontroller.py b/openlp/plugins/presentations/lib/presentationcontroller.py index f7caa2fc9..746bc7de9 100644 --- a/openlp/plugins/presentations/lib/presentationcontroller.py +++ b/openlp/plugins/presentations/lib/presentationcontroller.py @@ -392,7 +392,6 @@ class PresentationController(object): """ Return whether the controller is currently enabled """ - # TODO: check if Settings().value(self.settings_section + u'/' + self.name, QtCore.Qt.Checked) == QtCore.Qt.Checked: return self.is_available() diff --git a/openlp/plugins/presentations/lib/presentationtab.py b/openlp/plugins/presentations/lib/presentationtab.py index 59f0fb1cb..220da0d74 100644 --- a/openlp/plugins/presentations/lib/presentationtab.py +++ b/openlp/plugins/presentations/lib/presentationtab.py @@ -105,7 +105,6 @@ class PresentationTab(SettingsTab): for key in self.controllers: controller = self.controllers[key] checkbox = self.PresenterCheckboxes[controller.name] - # TODO check checkbox.setChecked(Settings().value( self.settingsSection + u'/' + controller.name, QtCore.Qt.Checked)) diff --git a/openlp/plugins/remotes/lib/httpserver.py b/openlp/plugins/remotes/lib/httpserver.py index cbc67d4b3..23f2cf83c 100644 --- a/openlp/plugins/remotes/lib/httpserver.py +++ b/openlp/plugins/remotes/lib/httpserver.py @@ -171,8 +171,10 @@ class HttpServer(object): clients. Listen out for socket connections. """ log.debug(u'Start TCP server') - port = Settings().value(self.plugin.settingsSection + u'/port') - address = Settings().value(self.plugin.settingsSection + u'/ip address') + port = Settings().value( + self.plugin.settingsSection + u'/port', 4316) + address = Settings().value( + self.plugin.settingsSection + u'/ip address', u'0.0.0.0') self.server = QtNetwork.QTcpServer() self.server.listen(QtNetwork.QHostAddress(address), port) QtCore.QObject.connect(Receiver.get_receiver(), @@ -404,7 +406,7 @@ class HttpConnection(object): u'slide': self.parent.current_slide or 0, u'item': self.parent.current_item._uuid \ if self.parent.current_item else u'', - u'twelve':Settings().value(u'remotes/twelve hour'), + u'twelve':Settings().value(u'remotes/twelve hour', True), u'blank': self.parent.plugin.liveController.blankScreen.isChecked(), u'theme': self.parent.plugin.liveController.themeScreen.isChecked(), u'display': \ diff --git a/openlp/plugins/remotes/lib/remotetab.py b/openlp/plugins/remotes/lib/remotetab.py index bf235e0bd..75ea3f290 100644 --- a/openlp/plugins/remotes/lib/remotetab.py +++ b/openlp/plugins/remotes/lib/remotetab.py @@ -151,20 +151,19 @@ class RemoteTab(SettingsTab): def load(self): self.portSpinBox.setValue( - Settings().value(self.settingsSection + u'/port')) + Settings().value(self.settingsSection + u'/port', 4316)) self.addressEdit.setText( - Settings().value(self.settingsSection + u'/ip address')) + Settings().value(self.settingsSection + u'/ip address', ZERO_URL)) self.twelveHour = Settings().value( - self.settingsSection + u'/twelve hour') + self.settingsSection + u'/twelve hour', True) self.twelveHourCheckBox.setChecked(self.twelveHour) self.setUrls() def save(self): changed = False - #TODO: check if Settings().value(self.settingsSection + u'/ip address', ZERO_URL != self.addressEdit.text() or Settings().value(self.settingsSection + - u'/port') != self.portSpinBox.value()): + u'/port', 4316) != self.portSpinBox.value()): changed = True Settings().setValue(self.settingsSection + u'/port', self.portSpinBox.value()) diff --git a/openlp/plugins/songs/forms/songimportform.py b/openlp/plugins/songs/forms/songimportform.py index 6e0f45b8d..e95a277a7 100644 --- a/openlp/plugins/songs/forms/songimportform.py +++ b/openlp/plugins/songs/forms/songimportform.py @@ -343,7 +343,8 @@ class SongImportForm(OpenLPWizard): self.restart() self.finishButton.setVisible(False) self.cancelButton.setVisible(True) - last_import_type = Settings().value(u'songs/last import type') + last_import_type = Settings().value( + u'songs/last import type') if last_import_type < 0 or \ last_import_type >= self.formatComboBox.count(): last_import_type = 0 diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index 2df0cba5e..a6419de20 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -171,11 +171,11 @@ class SongMediaItem(MediaManagerItem): def configUpdated(self): self.searchAsYouType = Settings().value( - self.settingsSection + u'/search as type') + self.settingsSection + u'/search as type', False) self.updateServiceOnEdit = Settings().value( - self.settingsSection + u'/update service on edit') + self.settingsSection + u'/update service on edit', False) self.addSongFromService = Settings().value( - self.settingsSection + u'/add song from service') + self.settingsSection + u'/add song from service', True) def retranslateUi(self): self.searchTextLabel.setText(u'%s:' % UiStrings().Search) @@ -204,7 +204,6 @@ class SongMediaItem(MediaManagerItem): (SongSearch.Themes, u':/slides/slide_theme.png', UiStrings().Themes, UiStrings().SearchThemes) ]) - # TODO: check self.searchTextEdit.setCurrentSearchType(Settings().value( u'%s/last search type' % self.settingsSection, SongSearch.Entire)) self.configUpdated() @@ -547,10 +546,10 @@ class SongMediaItem(MediaManagerItem): service_item.raw_footer.append(song.title) service_item.raw_footer.append(create_separated_list(author_list)) service_item.raw_footer.append(song.copyright) - if Settings().value(u'general/ccli number'): + if Settings().value(u'general/ccli number', u''): service_item.raw_footer.append( translate('SongsPlugin.MediaItem', 'CCLI License: ') + - Settings().value(u'general/ccli number')) + Settings().value(u'general/ccli number', u'')) service_item.audit = [ song.title, author_list, song.copyright, unicode(song.ccli_number) ] diff --git a/openlp/plugins/songusage/forms/songusagedetailform.py b/openlp/plugins/songusage/forms/songusagedetailform.py index c15c2f1b2..bd46f9173 100644 --- a/openlp/plugins/songusage/forms/songusagedetailform.py +++ b/openlp/plugins/songusage/forms/songusagedetailform.py @@ -61,7 +61,6 @@ class SongUsageDetailForm(QtGui.QDialog, Ui_SongUsageDetailDialog): year = QtCore.QDate().currentDate().year() if QtCore.QDate().currentDate().month() < 9: year -= 1 - # TODO: check toDate = Settings().value(self.plugin.settingsSection + u'/to date', QtCore.QDate(year, 8, 31)) fromDate = Settings().value(self.plugin.settingsSection + diff --git a/openlp/plugins/songusage/songusageplugin.py b/openlp/plugins/songusage/songusageplugin.py index e3f22da9f..b95d53a6f 100644 --- a/openlp/plugins/songusage/songusageplugin.py +++ b/openlp/plugins/songusage/songusageplugin.py @@ -127,7 +127,7 @@ class SongUsagePlugin(Plugin): QtCore.SIGNAL(u'print_service_started'), self.printSongUsage) self.songUsageActive = Settings().value( - self.settingsSection + u'/active') + self.settingsSection + u'/active', False) # Set the button and checkbox state self.setButtonState() action_list = ActionList.get_instance() From cbd22b71415b5a0d21a3f63e9255c23f40cf65b1 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Thu, 27 Dec 2012 17:46:27 +0100 Subject: [PATCH 40/53] fixed bug caused by merge --- openlp/core/lib/__init__.py | 3 +++ openlp/core/ui/mainwindow.py | 5 +++-- openlp/plugins/songs/lib/__init__.py | 13 +++++++------ 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/openlp/core/lib/__init__.py b/openlp/core/lib/__init__.py index 4a3cf7d54..023c460e1 100644 --- a/openlp/core/lib/__init__.py +++ b/openlp/core/lib/__init__.py @@ -136,6 +136,9 @@ class Settings(QtCore.QSettings): **Note**, this method only converts a few types and might need to be extended if a certain type is missing! """ + # Check for none as u'' is passed as default and is valid! + if defaultValue is None and not super(Settings, self).contains(key): + return None setting = super(Settings, self).value(key, defaultValue) # An empty list saved to the settings results in a None type being # returned. diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 42b4740a2..f02a64229 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -1075,8 +1075,9 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): export_settings.endGroup() # Write all the sections and keys. for section_key in keys: - key_value = settings.value(section_key) - export_settings.setValue(section_key, key_value) + key_value = settings.value(section_key, None) + if key_value is not None: + export_settings.setValue(section_key, key_value) export_settings.sync() # Temp CONF file has been written. Blanks in keys are now '%20'. # Read the temp file and output the user's CONF file with blanks to diff --git a/openlp/plugins/songs/lib/__init__.py b/openlp/plugins/songs/lib/__init__.py index 0d4b523ae..1dc2c528b 100644 --- a/openlp/plugins/songs/lib/__init__.py +++ b/openlp/plugins/songs/lib/__init__.py @@ -41,7 +41,7 @@ PATTERN = re.compile(r"\\([a-z]{1,32})(-?\d{1,10})?[ ]?|\\'" r"([0-9a-f]{2})|\\([^a-z])|([{}])|[\r\n]+|(.)", re.I) # RTF control words which specify a "destination" to be ignored. DESTINATIONS = frozenset(( - u'aftncn', u'aftnsep', u'aftnsepc', u'annotation', u'atnauthor', + u'aftncn', u'aftnsep', u'aftnsepc', u'annotation', u'atnauthor', u'atndate', u'atnicn', u'atnid', u'atnparent', u'atnref', u'atntime', u'atrfend', u'atrfstart', u'author', u'background', u'bkmkend', u'bkmkstart', u'blipuid', u'buptim', u'category', @@ -579,7 +579,7 @@ def strip_rtf(text, default_encoding=None): failed = False while True: try: - encoding, default_encoding = get_encoding(font, + encoding, default_encoding = get_encoding(font, font_table, default_encoding, failed=failed) out.append(chr(charcode).decode(encoding)) except UnicodeDecodeError: @@ -594,6 +594,7 @@ def strip_rtf(text, default_encoding=None): text = u''.join(out) return text, default_encoding + def natcmp(a, b): """ Natural string comparison which mimics the behaviour of Python's internal @@ -604,9 +605,9 @@ def natcmp(a, b): if isinstance(key, int) and isinstance(b[i], int): result = cmp(key, b[i]) elif isinstance(key, int) and not isinstance(b[i], int): - result = locale_direct_compare(QtCore.QString(str(key)), b[i]) + result = locale_direct_compare(str(key), b[i]) elif not isinstance(key, int) and isinstance(b[i], int): - result = locale_direct_compare(key, QtCore.QString(str(b[i]))) + result = locale_direct_compare(key, str(b[i])) else: result = locale_direct_compare(key, b[i]) if result != 0: @@ -620,9 +621,9 @@ def natcmp(a, b): if isinstance(a[i], int) and isinstance(key, int): result = cmp(a[i], key) elif isinstance(a[i], int) and not isinstance(key, int): - result = locale_direct_compare(QtCore.QString(str(a[i])), key) + result = locale_direct_compare(str(a[i]), key) elif not isinstance(a[i], int) and isinstance(key, int): - result = locale_direct_compare(a[i], QtCore.QString(str(key))) + result = locale_direct_compare(a[i], str(key)) else: result = locale_direct_compare(a[i], key) if result != 0: From 0a57bed2f7f5cc7bd70e53909bfc46d29e1ac824 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Thu, 27 Dec 2012 18:00:40 +0100 Subject: [PATCH 41/53] fixed setting import --- openlp/core/lib/__init__.py | 4 +++- openlp/core/ui/mainwindow.py | 5 +++-- openlp/core/utils/__init__.py | 4 +--- openlp/core/utils/actions.py | 10 +++++----- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/openlp/core/lib/__init__.py b/openlp/core/lib/__init__.py index 023c460e1..fc494c5fe 100644 --- a/openlp/core/lib/__init__.py +++ b/openlp/core/lib/__init__.py @@ -136,7 +136,9 @@ class Settings(QtCore.QSettings): **Note**, this method only converts a few types and might need to be extended if a certain type is missing! """ - # Check for none as u'' is passed as default and is valid! + # Check for none as u'' is passed as default and is valid! This is + # needed because the settings export does not know the default values, + # thus just passes None. if defaultValue is None and not super(Settings, self).contains(key): return None setting = super(Settings, self).value(key, defaultValue) diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index f02a64229..811173ae2 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -1000,8 +1000,9 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): return # We have a good file, import it. for section_key in import_keys: - value = import_settings.value(section_key) - settings.setValue(u'%s' % (section_key), value) + value = import_settings.value(section_key, None) + if value is not None: + settings.setValue(u'%s' % (section_key), value) now = datetime.now() settings.beginGroup(self.headerSection) settings.setValue(u'file_imported', import_file_name) diff --git a/openlp/core/utils/__init__.py b/openlp/core/utils/__init__.py index 2b618bddf..86a6e1531 100644 --- a/openlp/core/utils/__init__.py +++ b/openlp/core/utils/__init__.py @@ -497,10 +497,8 @@ def locale_compare(string1, string2): is equal to it. Comparison is case insensitive. """ # Function locale.strcoll() from standard Python library does not work - # properly on Windows and probably somewhere else. + # properly on Windows. return locale.strcoll(string1.lower(), string2.lower()) - # TODO: check code - #return QtCore.QString.localeAwareCompare(string1.lower(), string2.lower()) # For performance reasons provide direct reference to compare function diff --git a/openlp/core/utils/actions.py b/openlp/core/utils/actions.py index b4c4070ae..01ba34a26 100644 --- a/openlp/core/utils/actions.py +++ b/openlp/core/utils/actions.py @@ -213,11 +213,11 @@ class ActionList(object): empty ``objectName``. ``category`` - The category this action belongs to. The category can be a QString - or python unicode string. **Note**, if the category is ``None``, the - category and its actions are being hidden in the shortcut dialog. - However, if they are added, it is possible to avoid assigning - shortcuts twice, which is important. + The category this action belongs to. The category has to be a python + string. . **Note**, if the category is ``None``, the category and + its actions are being hidden in the shortcut dialog. However, if + they are added, it is possible to avoid assigning shortcuts twice, + which is important. ``weight`` The weight specifies how important a category is. However, this only From be2c62baf49916b547f776bb280e5b9cee32b048 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Thu, 27 Dec 2012 18:06:11 +0100 Subject: [PATCH 42/53] fixed song import --- openlp/plugins/songs/forms/songimportform.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/plugins/songs/forms/songimportform.py b/openlp/plugins/songs/forms/songimportform.py index e95a277a7..c77a05afa 100644 --- a/openlp/plugins/songs/forms/songimportform.py +++ b/openlp/plugins/songs/forms/songimportform.py @@ -344,7 +344,7 @@ class SongImportForm(OpenLPWizard): self.finishButton.setVisible(False) self.cancelButton.setVisible(True) last_import_type = Settings().value( - u'songs/last import type') + u'songs/last import type', SongFormat.OpenLyrics) if last_import_type < 0 or \ last_import_type >= self.formatComboBox.count(): last_import_type = 0 From 863aa586564d73b765f856c3afcf8d4b338f908d Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Thu, 27 Dec 2012 18:17:08 +0100 Subject: [PATCH 43/53] final clean ups --- openlp/core/ui/themeform.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/openlp/core/ui/themeform.py b/openlp/core/ui/themeform.py index 2e08073b6..90115fdb0 100644 --- a/openlp/core/ui/themeform.py +++ b/openlp/core/ui/themeform.py @@ -562,9 +562,7 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard): self.theme.font_main_outline_size = self.field(u'outlineSizeSpinBox') self.theme.font_main_shadow_size = self.field(u'shadowSizeSpinBox') self.theme.font_main_bold = self.field(u'mainBoldCheckBox') - # FIXME ? - self.theme.font_main_italics = \ - self.field(u'mainItalicsCheckBox') + self.theme.font_main_italics = self.field(u'mainItalicsCheckBox') # footer page self.theme.font_footer_name = \ self.footerFontComboBox.currentFont().family() @@ -574,7 +572,6 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard): self.theme.font_main_y = self.field(u'mainPositionY') self.theme.font_main_height = self.field(u'mainPositionHeight') self.theme.font_main_width = self.field(u'mainPositionWidth') - #print self.field(u'footerPositionX') self.theme.font_footer_x = self.field(u'footerPositionX') self.theme.font_footer_y = self.field(u'footerPositionY') self.theme.font_footer_height = self.field(u'footerPositionHeight') @@ -583,7 +580,6 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard): self.theme.display_horizontal_align = \ self.horizontalComboBox.currentIndex() self.theme.display_vertical_align = self.verticalComboBox.currentIndex() - # TODO Check self.theme.display_slide_transition = self.field(u'slideTransition') def accept(self): From e325affe1065a36454dfaf704f8155ca68d6177e Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Thu, 27 Dec 2012 22:20:32 +0100 Subject: [PATCH 44/53] fixed data path --- openlp/core/utils/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/core/utils/__init__.py b/openlp/core/utils/__init__.py index 86a6e1531..be9d30e0c 100644 --- a/openlp/core/utils/__init__.py +++ b/openlp/core/utils/__init__.py @@ -133,7 +133,7 @@ class AppLocation(object): """ # Check if we have a different data location. if Settings().contains(u'advanced/data path'): - path = Settings().value(u'advanced/data path') + path = Settings().value(u'advanced/data path', u'') else: path = AppLocation.get_directory(AppLocation.DataDir) check_directory_exists(path) From 8fdbca8d8910bfffd792ced5a927e738ffba1ed2 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Thu, 27 Dec 2012 22:41:11 +0100 Subject: [PATCH 45/53] fixed comment --- openlp/core/lib/ui.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/core/lib/ui.py b/openlp/core/lib/ui.py index f1cda2b96..3e1d662d2 100644 --- a/openlp/core/lib/ui.py +++ b/openlp/core/lib/ui.py @@ -377,7 +377,7 @@ def create_action(parent, name, **kwargs): True in case the action will be considered a separator. ``data`` - The actions data. + The action's data. ``shortcuts`` A QList (or a list of strings) which are set as shortcuts. From df3a1bd100507de5af739ceb9e5bb85a41edcf3e Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Thu, 27 Dec 2012 22:56:53 +0100 Subject: [PATCH 46/53] tweaked language manager code --- openlp/core/utils/languagemanager.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/openlp/core/utils/languagemanager.py b/openlp/core/utils/languagemanager.py index 2c5c51411..25aaa7adf 100644 --- a/openlp/core/utils/languagemanager.py +++ b/openlp/core/utils/languagemanager.py @@ -83,11 +83,7 @@ class LanguageManager(object): # Remove qm files from the list which start with "qt_". file_names = filter( lambda file_: not file_.startswith(u'qt_'), file_names) - names = [] - for name in file_names: - names.append(trans_dir.filePath(name)) - #file_names.replaceInStrings(name, trans_dir.filePath(name)) - return names + return map(trans_dir.filePath, file_names) @staticmethod def language_name(qm_file): From e92deb94d26e538ea5402387e562e3d49d7b7923 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Fri, 28 Dec 2012 21:03:59 +0100 Subject: [PATCH 47/53] fixed presentation bug (bug #1094340) Fixes: https://launchpad.net/bugs/1094340 --- openlp/plugins/presentations/lib/presentationtab.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openlp/plugins/presentations/lib/presentationtab.py b/openlp/plugins/presentations/lib/presentationtab.py index 220da0d74..602c08195 100644 --- a/openlp/plugins/presentations/lib/presentationtab.py +++ b/openlp/plugins/presentations/lib/presentationtab.py @@ -125,7 +125,7 @@ class PresentationTab(SettingsTab): if controller.is_available(): checkbox = self.PresenterCheckboxes[controller.name] setting_key = self.settingsSection + u'/' + controller.name - if Settings().value(setting_key) != \ + if Settings().value(setting_key, QtCore.Qt.Checked) != \ checkbox.checkState(): changed = True Settings().setValue(setting_key, checkbox.checkState()) @@ -134,7 +134,7 @@ class PresentationTab(SettingsTab): else: controller.kill() setting_key = self.settingsSection + u'/override app' - if Settings().value(setting_key) != \ + if Settings().value(setting_key, QtCore.Qt.Checked) != \ self.OverrideAppCheckBox.checkState(): Settings().setValue(setting_key, self.OverrideAppCheckBox.checkState()) From ae576251bd7449068912409856f4932e6ca13489 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Fri, 28 Dec 2012 22:06:43 +0000 Subject: [PATCH 48/53] Core lib --- openlp/core/lib/__init__.py | 20 ++--- openlp/core/lib/db.py | 27 +++---- openlp/core/lib/dockwidget.py | 2 +- openlp/core/lib/eventreceiver.py | 2 +- openlp/core/lib/htmlbuilder.py | 83 ++++++------------- openlp/core/lib/imagemanager.py | 14 ++-- openlp/core/lib/listwidgetwithdnd.py | 5 +- openlp/core/lib/mediamanageritem.py | 112 +++++++++----------------- openlp/core/lib/plugin.py | 49 ++++------- openlp/core/lib/pluginmanager.py | 12 ++- openlp/core/lib/renderer.py | 62 +++++--------- openlp/core/lib/searchedit.py | 44 +++------- openlp/core/lib/serviceitem.py | 6 +- openlp/core/lib/settingsmanager.py | 2 +- openlp/core/lib/settingstab.py | 8 +- openlp/core/lib/spelltextedit.py | 18 ++--- openlp/core/lib/theme.py | 35 +++----- openlp/core/lib/toolbar.py | 2 +- openlp/core/lib/ui.py | 72 ++++++----------- openlp/core/ui/media/playertab.py | 3 +- openlp/core/ui/media/webkitplayer.py | 15 ++-- openlp/core/ui/servicemanager.py | 14 +--- openlp/plugins/media/lib/mediaitem.py | 4 +- 23 files changed, 207 insertions(+), 404 deletions(-) diff --git a/openlp/core/lib/__init__.py b/openlp/core/lib/__init__.py index fc494c5fe..9bfa1a46a 100644 --- a/openlp/core/lib/__init__.py +++ b/openlp/core/lib/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 ############################################################################### # OpenLP - Open Source Lyrics Projection # @@ -114,8 +114,7 @@ class Settings(QtCore.QSettings): def __init__(self, *args): if not args and Settings.__filePath__ and \ Settings.defaultFormat() == Settings.IniFormat: - QtCore.QSettings.__init__(self, Settings.__filePath__, - Settings.IniFormat) + QtCore.QSettings.__init__(self, Settings.__filePath__, Settings.IniFormat) else: QtCore.QSettings.__init__(self, *args) @@ -236,14 +235,11 @@ def build_icon(icon): button_icon = icon elif isinstance(icon, basestring): if icon.startswith(u':/'): - button_icon.addPixmap(QtGui.QPixmap(icon), QtGui.QIcon.Normal, - QtGui.QIcon.Off) + button_icon.addPixmap(QtGui.QPixmap(icon), QtGui.QIcon.Normal, QtGui.QIcon.Off) else: - button_icon.addPixmap(QtGui.QPixmap.fromImage(QtGui.QImage(icon)), - QtGui.QIcon.Normal, QtGui.QIcon.Off) + button_icon.addPixmap(QtGui.QPixmap.fromImage(QtGui.QImage(icon)), QtGui.QIcon.Normal, QtGui.QIcon.Off) elif isinstance(icon, QtGui.QImage): - button_icon.addPixmap(QtGui.QPixmap.fromImage(icon), - QtGui.QIcon.Normal, QtGui.QIcon.Off) + button_icon.addPixmap(QtGui.QPixmap.fromImage(icon), QtGui.QIcon.Normal, QtGui.QIcon.Off) return button_icon @@ -361,12 +357,10 @@ def resize_image(image_path, width, height, background=u'#000000'): real_width = preview.width() real_height = preview.height() # and move it to the centre of the preview space - new_image = QtGui.QImage(width, height, - QtGui.QImage.Format_ARGB32_Premultiplied) + new_image = QtGui.QImage(width, height, QtGui.QImage.Format_ARGB32_Premultiplied) painter = QtGui.QPainter(new_image) painter.fillRect(new_image.rect(), QtGui.QColor(background)) - painter.drawImage( - (width - real_width) / 2, (height - real_height) / 2, preview) + painter.drawImage((width - real_width) / 2, (height - real_height) / 2, preview) return new_image diff --git a/openlp/core/lib/db.py b/openlp/core/lib/db.py index 39047a7c9..c3e36352e 100644 --- a/openlp/core/lib/db.py +++ b/openlp/core/lib/db.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 ############################################################################### # OpenLP - Open Source Lyrics Projection # @@ -36,8 +36,7 @@ from urllib import quote_plus as urlquote from PyQt4 import QtCore from sqlalchemy import Table, MetaData, Column, types, create_engine -from sqlalchemy.exc import SQLAlchemyError, InvalidRequestError, DBAPIError, \ - OperationalError +from sqlalchemy.exc import SQLAlchemyError, InvalidRequestError, DBAPIError, OperationalError from sqlalchemy.orm import scoped_session, sessionmaker, mapper from sqlalchemy.pool import NullPool @@ -111,8 +110,7 @@ def upgrade_db(url, upgrade): while hasattr(upgrade, u'upgrade_%d' % version): log.debug(u'Running upgrade_%d', version) try: - getattr(upgrade, u'upgrade_%d' % version) \ - (session, metadata, tables) + getattr(upgrade, u'upgrade_%d' % version) (session, metadata, tables) except (SQLAlchemyError, DBAPIError): log.exception(u'Could not run database upgrade script ' '"upgrade_%s", upgrade process has been halted.', version) @@ -140,11 +138,9 @@ def delete_database(plugin_name, db_file_name=None): """ db_file_path = None if db_file_name: - db_file_path = os.path.join( - AppLocation.get_section_data_path(plugin_name), db_file_name) + db_file_path = os.path.join(AppLocation.get_section_data_path(plugin_name), db_file_name) else: - db_file_path = os.path.join( - AppLocation.get_section_data_path(plugin_name), plugin_name) + db_file_path = os.path.join(AppLocation.get_section_data_path(plugin_name), plugin_name) return delete_file(db_file_path) @@ -193,12 +189,9 @@ class Manager(object): db_type = settings.value(u'db type', u'sqlite') if db_type == u'sqlite': if db_file_name: - self.db_url = u'sqlite:///%s/%s' % ( - AppLocation.get_section_data_path(plugin_name), - db_file_name) + self.db_url = u'sqlite:///%s/%s' % (AppLocation.get_section_data_path(plugin_name), db_file_name) else: - self.db_url = u'sqlite:///%s/%s.sqlite' % ( - AppLocation.get_section_data_path(plugin_name), plugin_name) + self.db_url = u'sqlite:///%s/%s.sqlite' % (AppLocation.get_section_data_path(plugin_name), plugin_name) else: self.db_url = u'%s://%s:%s@%s/%s' % (db_type, urlquote(settings.value(u'db username', u'')), @@ -226,10 +219,8 @@ class Manager(object): self.session = init_schema(self.db_url) except (SQLAlchemyError, DBAPIError): log.exception(u'Error loading database: %s', self.db_url) - critical_error_message_box( - translate('OpenLP.Manager', 'Database Error'), - translate('OpenLP.Manager', 'OpenLP cannot load your ' - 'database.\n\nDatabase: %s') % self.db_url + critical_error_message_box(translate('OpenLP.Manager', 'Database Error'), + translate('OpenLP.Manager', 'OpenLP cannot load your database.\n\nDatabase: %s') % self.db_url ) def save_object(self, object_instance, commit=True): diff --git a/openlp/core/lib/dockwidget.py b/openlp/core/lib/dockwidget.py index 4105e2b22..0c2c41d90 100644 --- a/openlp/core/lib/dockwidget.py +++ b/openlp/core/lib/dockwidget.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 ############################################################################### # OpenLP - Open Source Lyrics Projection # diff --git a/openlp/core/lib/eventreceiver.py b/openlp/core/lib/eventreceiver.py index b99c6ac33..fd2c5ae42 100644 --- a/openlp/core/lib/eventreceiver.py +++ b/openlp/core/lib/eventreceiver.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 ############################################################################### # OpenLP - Open Source Lyrics Projection # diff --git a/openlp/core/lib/htmlbuilder.py b/openlp/core/lib/htmlbuilder.py index 54a9fc556..bc199573e 100644 --- a/openlp/core/lib/htmlbuilder.py +++ b/openlp/core/lib/htmlbuilder.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 ############################################################################### # OpenLP - Open Source Lyrics Projection # @@ -31,8 +31,7 @@ import logging from PyQt4 import QtWebKit -from openlp.core.lib.theme import BackgroundType, BackgroundGradientType, \ - VerticalType, HorizontalType +from openlp.core.lib.theme import BackgroundType, BackgroundGradientType, VerticalType, HorizontalType log = logging.getLogger(__name__) @@ -258,8 +257,7 @@ def build_html(item, screen, islive, background, image=None, css_additions, build_footer_css(item, height), build_lyrics_css(item, webkitvers), - u'true' if theme and theme.display_slide_transition and islive \ - else u'false', + u'true' if theme and theme.display_slide_transition and islive else u'false', js_additions, bgimage_src, image_src, html_additions, @@ -290,49 +288,26 @@ def build_background_css(item, width, height): theme = item.themedata background = u'background-color: black' if theme: - if theme.background_type == \ - BackgroundType.to_string(BackgroundType.Transparent): + if theme.background_type == BackgroundType.to_string(BackgroundType.Transparent): background = u'' - elif theme.background_type == \ - BackgroundType.to_string(BackgroundType.Solid): + elif theme.background_type == BackgroundType.to_string(BackgroundType.Solid): background = u'background-color: %s' % theme.background_color else: - if theme.background_direction == BackgroundGradientType.to_string \ - (BackgroundGradientType.Horizontal): - background = \ - u'background: ' \ - u'-webkit-gradient(linear, left top, left bottom, ' \ - 'from(%s), to(%s)) fixed' % (theme.background_start_color, - theme.background_end_color) - elif theme.background_direction == \ - BackgroundGradientType.to_string( \ - BackgroundGradientType.LeftTop): - background = \ - u'background: ' \ - u'-webkit-gradient(linear, left top, right bottom, ' \ - 'from(%s), to(%s)) fixed' % (theme.background_start_color, - theme.background_end_color) - elif theme.background_direction == \ - BackgroundGradientType.to_string \ - (BackgroundGradientType.LeftBottom): - background = \ - u'background: ' \ - u'-webkit-gradient(linear, left bottom, right top, ' \ - 'from(%s), to(%s)) fixed' % (theme.background_start_color, - theme.background_end_color) - elif theme.background_direction == \ - BackgroundGradientType.to_string \ - (BackgroundGradientType.Vertical): - background = \ - u'background: -webkit-gradient(linear, left top, ' \ - u'right top, from(%s), to(%s)) fixed' % \ + if theme.background_direction == BackgroundGradientType.to_string(BackgroundGradientType.Horizontal): + background = u'background: -webkit-gradient(linear, left top, left bottom, from(%s), to(%s)) fixed' \ + % (theme.background_start_color, theme.background_end_color) + elif theme.background_direction == BackgroundGradientType.to_string(BackgroundGradientType.LeftTop): + background = u'background: -webkit-gradient(linear, left top, right bottom, from(%s), to(%s)) fixed' \ + % (theme.background_start_color, theme.background_end_color) + elif theme.background_direction == BackgroundGradientType.to_string(BackgroundGradientType.LeftBottom): + background = u'background: -webkit-gradient(linear, left bottom, right top, from(%s), to(%s)) fixed' \ + % (theme.background_start_color, theme.background_end_color) + elif theme.background_direction == BackgroundGradientType.to_string(BackgroundGradientType.Vertical): + background = u'background: -webkit-gradient(linear, left top, right top, from(%s), to(%s)) fixed' % \ (theme.background_start_color, theme.background_end_color) else: - background = \ - u'background: -webkit-gradient(radial, %s 50%%, 100, %s ' \ - u'50%%, %s, from(%s), to(%s)) fixed' % (width, width, - width, theme.background_start_color, - theme.background_end_color) + background = u'background: -webkit-gradient(radial, %s 50%%, 100, %s 50%%, %s, from(%s), to(%s)) fixed'\ + % (width, width, width, theme.background_start_color, theme.background_end_color) return background def build_lyrics_css(item, webkitvers): @@ -376,8 +351,7 @@ def build_lyrics_css(item, webkitvers): shadow = u'' if theme and item.main: lyricstable = u'left: %spx; top: %spx;' % (item.main.x(), item.main.y()) - lyrics = build_lyrics_format_css(theme, item.main.width(), - item.main.height()) + lyrics = build_lyrics_format_css(theme, item.main.width(), item.main.height()) # For performance reasons we want to show as few DIV's as possible, # especially when animating/transitions. # However some bugs in older versions of qtwebkit mean we need to @@ -400,9 +374,8 @@ def build_lyrics_css(item, webkitvers): if theme.font_main_shadow: if theme.font_main_outline and webkitvers <= 534.3: shadow = u'padding-left: %spx; padding-top: %spx;' % \ - (int(theme.font_main_shadow_size) + - (int(theme.font_main_outline_size) * 2), - theme.font_main_shadow_size) + (int(theme.font_main_shadow_size) + (int(theme.font_main_outline_size) * 2), + theme.font_main_shadow_size) shadow += build_lyrics_outline_css(theme, True) else: lyricsmain += u' text-shadow: %s %spx %spx;' % \ @@ -430,8 +403,7 @@ def build_lyrics_outline_css(theme, is_shadow=False): else: fill_color = theme.font_main_color outline_color = theme.font_main_outline_color - return u' -webkit-text-stroke: %sem %s; ' \ - u'-webkit-text-fill-color: %s; ' % (size, outline_color, fill_color) + return u' -webkit-text-stroke: %sem %s; -webkit-text-fill-color: %s; ' % (size, outline_color, fill_color) else: return u'' @@ -467,11 +439,9 @@ def build_lyrics_format_css(theme, width, height): lyrics = u'%s word-wrap: break-word; ' \ 'text-align: %s; vertical-align: %s; font-family: %s; ' \ 'font-size: %spt; color: %s; line-height: %d%%; margin: 0;' \ - 'padding: 0; padding-bottom: %s; padding-left: %spx; width: %spx;' \ - 'height: %spx; ' % \ + 'padding: 0; padding-bottom: %s; padding-left: %spx; width: %spx; height: %spx; ' % \ (justify, align, valign, theme.font_main_name, theme.font_main_size, - theme.font_main_color, 100 + int(theme.font_main_line_adjustment), - padding_bottom, left_margin, width, height) + theme.font_main_color, 100 + int(theme.font_main_line_adjustment), padding_bottom, left_margin, width, height) if theme.font_main_outline: if webkit_version() <= 534.3: lyrics += u' letter-spacing: 1px;' @@ -531,7 +501,6 @@ def build_footer_css(item, height): if not theme or not item.footer: return u'' bottom = height - int(item.footer.y()) - int(item.footer.height()) - lyrics_html = style % (item.footer.x(), bottom, - item.footer.width(), theme.font_footer_name, - theme.font_footer_size, theme.font_footer_color) + lyrics_html = style % (item.footer.x(), bottom, item.footer.width(), + theme.font_footer_name, theme.font_footer_size, theme.font_footer_color) return lyrics_html diff --git a/openlp/core/lib/imagemanager.py b/openlp/core/lib/imagemanager.py index 26d86113b..bc4dbd55a 100644 --- a/openlp/core/lib/imagemanager.py +++ b/openlp/core/lib/imagemanager.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 ############################################################################### # OpenLP - Open Source Lyrics Projection # @@ -190,8 +190,7 @@ class ImageManager(QtCore.QObject): self.imageThread = ImageThread(self) self._conversionQueue = PriorityQueue() self.stopManager = False - QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'config_updated'), self.processUpdates) + QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'config_updated'), self.processUpdates) def updateDisplay(self): """ @@ -293,14 +292,12 @@ class ImageManager(QtCore.QObject): if not (path, source) in self._cache: image = Image(path, source, background) self._cache[(path, source)] = image - self._conversionQueue.put( - (image.priority, image.secondary_priority, image)) + self._conversionQueue.put((image.priority, image.secondary_priority, image)) # Check if the there are any images with the same path and check if the # timestamp has changed. for image in self._cache.values(): if os.path.exists(path): - if image.path == path and \ - image.timestamp != os.stat(path).st_mtime: + if image.path == path and image.timestamp != os.stat(path).st_mtime: image.timestamp = os.stat(path).st_mtime self._resetImage(image) # We want only one thread. @@ -324,8 +321,7 @@ class ImageManager(QtCore.QObject): image = self._conversionQueue.get()[2] # Generate the QImage for the image. if image.image is None: - image.image = resize_image(image.path, self.width, self.height, - image.background) + image.image = resize_image(image.path, self.width, self.height, image.background) # Set the priority to Lowest and stop here as we need to process # more important images first. if image.priority == Priority.Normal: diff --git a/openlp/core/lib/listwidgetwithdnd.py b/openlp/core/lib/listwidgetwithdnd.py index f014f1f53..8caf51ebc 100644 --- a/openlp/core/lib/listwidgetwithdnd.py +++ b/openlp/core/lib/listwidgetwithdnd.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 ############################################################################### # OpenLP - Open Source Lyrics Projection # @@ -53,8 +53,7 @@ class ListWidgetWithDnD(QtGui.QListWidget): """ self.setAcceptDrops(True) self.setDragDropMode(QtGui.QAbstractItemView.DragDrop) - QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'%s_dnd' % self.mimeDataText), + QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'%s_dnd' % self.mimeDataText), self.parent().loadFile) def mouseMoveEvent(self, event): diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index 8eb79ddfd..81d111948 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 ############################################################################### # OpenLP - Open Source Lyrics Projection # @@ -35,12 +35,10 @@ import re from PyQt4 import QtCore, QtGui -from openlp.core.lib import SettingsManager, OpenLPToolbar, ServiceItem, \ - StringContent, build_icon, translate, Receiver, ListWidgetWithDnD, \ - ServiceItemContext, Settings +from openlp.core.lib import SettingsManager, OpenLPToolbar, ServiceItem, StringContent, build_icon, translate, \ + Receiver, ListWidgetWithDnD, ServiceItemContext, Settings from openlp.core.lib.searchedit import SearchEdit -from openlp.core.lib.ui import UiStrings, create_widget_action, \ - critical_error_message_box +from openlp.core.lib.ui import UiStrings, create_widget_action, critical_error_message_box log = logging.getLogger(__name__) @@ -116,8 +114,7 @@ class MediaManagerItem(QtGui.QWidget): self.setupUi() self.retranslateUi() self.autoSelectId = -1 - QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'%s_service_load' % self.plugin.name), + QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'%s_service_load' % self.plugin.name), self.serviceLoad) def requiredIcons(self): @@ -204,8 +201,7 @@ class MediaManagerItem(QtGui.QWidget): for action in toolbar_actions: if action[0] == StringContent.Preview: self.toolbar.addSeparator() - self.toolbar.addToolbarAction( - u'%s%sAction' % (self.plugin.name, action[0]), + self.toolbar.addToolbarAction(u'%s%sAction' % (self.plugin.name, action[0]), text=self.plugin.getString(action[1])[u'title'], icon=action[2], tooltip=self.plugin.getString(action[1])[u'tooltip'], triggers=action[3]) @@ -217,8 +213,7 @@ class MediaManagerItem(QtGui.QWidget): # Add the List widget self.listView = ListWidgetWithDnD(self, self.plugin.name) self.listView.setSpacing(1) - self.listView.setSelectionMode( - QtGui.QAbstractItemView.ExtendedSelection) + self.listView.setSelectionMode(QtGui.QAbstractItemView.ExtendedSelection) self.listView.setAlternatingRowColors(True) self.listView.setObjectName(u'%sListView' % self.plugin.name) # Add to pageLayout @@ -255,22 +250,19 @@ class MediaManagerItem(QtGui.QWidget): triggers=self.onAddClick) if self.addToServiceItem: create_widget_action(self.listView, separator=True) - create_widget_action(self.listView, text=translate( - 'OpenLP.MediaManagerItem', '&Add to selected Service Item'), + create_widget_action(self.listView, + text=translate('OpenLP.MediaManagerItem', '&Add to selected Service Item'), icon=u':/general/general_add.png', triggers=self.onAddEditClick) self.addCustomContextActions() # Create the context menu and add all actions from the listView. self.menu = QtGui.QMenu() self.menu.addActions(self.listView.actions()) - QtCore.QObject.connect(self.listView, - QtCore.SIGNAL(u'doubleClicked(QModelIndex)'), + QtCore.QObject.connect(self.listView, QtCore.SIGNAL(u'doubleClicked(QModelIndex)'), self.onDoubleClicked) - QtCore.QObject.connect(self.listView, - QtCore.SIGNAL(u'itemSelectionChanged()'), + QtCore.QObject.connect(self.listView, QtCore.SIGNAL(u'itemSelectionChanged()'), self.onSelectionChange) - QtCore.QObject.connect(self.listView, - QtCore.SIGNAL('customContextMenuRequested(QPoint)'), + QtCore.QObject.connect(self.listView, QtCore.SIGNAL(u'customContextMenuRequested(QPoint)'), self.contextMenu) def addSearchToToolBar(self): @@ -299,12 +291,9 @@ class MediaManagerItem(QtGui.QWidget): self.searchLayout.addLayout(self.searchButtonLayout) self.pageLayout.addWidget(self.searchWidget) # Signals and slots - QtCore.QObject.connect(self.searchTextEdit, - QtCore.SIGNAL(u'returnPressed()'), self.onSearchTextButtonClicked) - QtCore.QObject.connect(self.searchTextButton, - QtCore.SIGNAL(u'clicked()'), self.onSearchTextButtonClicked) - QtCore.QObject.connect(self.searchTextEdit, - QtCore.SIGNAL(u'textChanged(const QString&)'), + QtCore.QObject.connect(self.searchTextEdit, QtCore.SIGNAL(u'returnPressed()'), self.onSearchTextButtonClicked) + QtCore.QObject.connect(self.searchTextButton, QtCore.SIGNAL(u'clicked()'), self.onSearchTextButtonClicked) + QtCore.QObject.connect(self.searchTextEdit, QtCore.SIGNAL(u'textChanged(const QString&)'), self.onSearchTextEditChanged) def addCustomContextActions(self): @@ -337,10 +326,8 @@ class MediaManagerItem(QtGui.QWidget): """ Add a file to the list widget to make it available for showing """ - files = QtGui.QFileDialog.getOpenFileNames( - self, self.onNewPrompt, - SettingsManager.get_last_dir(self.settingsSection), - self.onNewFileMasks) + files = QtGui.QFileDialog.getOpenFileNames(self, self.onNewPrompt, + SettingsManager.get_last_dir(self.settingsSection), self.onNewFileMasks) log.info(u'New files(s) %s', files) if files: Receiver.send_message(u'cursor_busy') @@ -361,11 +348,8 @@ class MediaManagerItem(QtGui.QWidget): type = file.split(u'.')[-1] if type.lower() not in self.onNewFileMasks: if not error_shown: - critical_error_message_box( - translate('OpenLP.MediaManagerItem', - 'Invalid File Type'), - translate('OpenLP.MediaManagerItem', - 'Invalid File %s.\nSuffix not supported') % file) + critical_error_message_box(translate('OpenLP.MediaManagerItem', 'Invalid File Type'), + translate('OpenLP.MediaManagerItem', 'Invalid File %s.\nSuffix not supported') % file) error_shown = True else: new_files.append(file) @@ -402,10 +386,8 @@ class MediaManagerItem(QtGui.QWidget): SettingsManager.set_list(self.settingsSection, self.settingsSection, self.getFileList()) if duplicates_found: - critical_error_message_box( - UiStrings().Duplicate, - translate('OpenLP.MediaManagerItem', - 'Duplicate files were found on import and were ignored.')) + critical_error_message_box(UiStrings().Duplicate, + translate('OpenLP.MediaManagerItem', 'Duplicate files were found on import and were ignored.')) def contextMenu(self, point): item = self.listView.itemAt(point) @@ -430,8 +412,7 @@ class MediaManagerItem(QtGui.QWidget): return file_list def loadList(self, list): - raise NotImplementedError(u'MediaManagerItem.loadList needs to be ' - u'defined by the plugin') + raise NotImplementedError(u'MediaManagerItem.loadList needs to be defined by the plugin') def onNewClick(self): """ @@ -446,8 +427,7 @@ class MediaManagerItem(QtGui.QWidget): pass def onDeleteClick(self): - raise NotImplementedError(u'MediaManagerItem.onDeleteClick needs to ' - u'be defined by the plugin') + raise NotImplementedError(u'MediaManagerItem.onDeleteClick needs to be defined by the plugin') def onFocus(self): """ @@ -458,8 +438,7 @@ class MediaManagerItem(QtGui.QWidget): def generateSlideData(self, serviceItem, item=None, xmlVersion=False, remote=False, context=ServiceItemContext.Live): - raise NotImplementedError(u'MediaManagerItem.generateSlideData needs ' - u'to be defined by the plugin') + raise NotImplementedError(u'MediaManagerItem.generateSlideData needs to be defined by the plugin') def onDoubleClicked(self): """ @@ -474,10 +453,8 @@ class MediaManagerItem(QtGui.QWidget): """ Allows the change of current item in the list to be actioned """ - if Settings().value(u'advanced/single click preview', - False) and self.quickPreviewAllowed \ - and self.listView.selectedIndexes() \ - and self.autoSelectId == -1: + if Settings().value(u'advanced/single click preview', False) and self.quickPreviewAllowed \ + and self.listView.selectedIndexes() and self.autoSelectId == -1: self.onPreviewClick(True) def onPreviewClick(self, keepFocus=False): @@ -487,8 +464,7 @@ class MediaManagerItem(QtGui.QWidget): """ if not self.listView.selectedIndexes() and not self.remoteTriggered: QtGui.QMessageBox.information(self, UiStrings().NISp, - translate('OpenLP.MediaManagerItem', - 'You must select one or more items to preview.')) + translate('OpenLP.MediaManagerItem', 'You must select one or more items to preview.')) else: log.debug(u'%s Preview requested', self.plugin.name) serviceItem = self.buildServiceItem() @@ -505,8 +481,7 @@ class MediaManagerItem(QtGui.QWidget): """ if not self.listView.selectedIndexes(): QtGui.QMessageBox.information(self, UiStrings().NISp, - translate('OpenLP.MediaManagerItem', - 'You must select one or more items to send live.')) + translate('OpenLP.MediaManagerItem', 'You must select one or more items to send live.')) else: self.goLive() @@ -534,8 +509,7 @@ class MediaManagerItem(QtGui.QWidget): """ if not self.listView.selectedIndexes() and not self.remoteTriggered: QtGui.QMessageBox.information(self, UiStrings().NISp, - translate('OpenLP.MediaManagerItem', - 'You must select one or more items to add.')) + translate('OpenLP.MediaManagerItem', 'You must select one or more items to add.')) else: # Is it posssible to process multiple list items to generate # multiple service items? @@ -548,12 +522,10 @@ class MediaManagerItem(QtGui.QWidget): self.addToService(item) def addToService(self, item=None, replace=None, remote=False): - serviceItem = self.buildServiceItem(item, True, remote=remote, - context=ServiceItemContext.Service) + serviceItem = self.buildServiceItem(item, True, remote=remote, context=ServiceItemContext.Service) if serviceItem: serviceItem.from_plugin = False - self.plugin.serviceManager.addServiceItem(serviceItem, - replace=replace) + self.plugin.serviceManager.addServiceItem(serviceItem, replace=replace) def onAddEditClick(self): """ @@ -561,29 +533,22 @@ class MediaManagerItem(QtGui.QWidget): """ if not self.listView.selectedIndexes() and not self.remoteTriggered: QtGui.QMessageBox.information(self, UiStrings().NISp, - translate('OpenLP.MediaManagerItem', - 'You must select one or more items.')) + translate('OpenLP.MediaManagerItem', 'You must select one or more items.')) else: log.debug(u'%s Add requested', self.plugin.name) serviceItem = self.plugin.serviceManager.getServiceItem() if not serviceItem: QtGui.QMessageBox.information(self, UiStrings().NISs, - translate('OpenLP.MediaManagerItem', - 'You must select an existing service item to add to.')) + translate('OpenLP.MediaManagerItem', 'You must select an existing service item to add to.')) elif self.plugin.name == serviceItem.name: self.generateSlideData(serviceItem) - self.plugin.serviceManager.addServiceItem(serviceItem, - replace=True) + self.plugin.serviceManager.addServiceItem(serviceItem, replace=True) else: # Turn off the remote edit update message indicator - QtGui.QMessageBox.information(self, - translate('OpenLP.MediaManagerItem', - 'Invalid Service Item'), - translate('OpenLP.MediaManagerItem', - 'You must select a %s service item.') % self.title) + QtGui.QMessageBox.information(self, translate('OpenLP.MediaManagerItem', 'Invalid Service Item'), + translate('OpenLP.MediaManagerItem', 'You must select a %s service item.') % self.title) - def buildServiceItem(self, item=None, xmlVersion=False, remote=False, - context=ServiceItemContext.Live): + def buildServiceItem(self, item=None, xmlVersion=False, remote=False, context=ServiceItemContext.Live): """ Common method for generating a service item """ @@ -652,5 +617,4 @@ class MediaManagerItem(QtGui.QWidget): """ Performs a plugin specific search for items containing ``string`` """ - raise NotImplementedError( - u'Plugin.search needs to be defined by the plugin') + raise NotImplementedError(u'Plugin.search needs to be defined by the plugin') diff --git a/openlp/core/lib/plugin.py b/openlp/core/lib/plugin.py index 2720c1ab6..8d13747d9 100644 --- a/openlp/core/lib/plugin.py +++ b/openlp/core/lib/plugin.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 ############################################################################### # OpenLP - Open Source Lyrics Projection # @@ -172,11 +172,9 @@ class Plugin(QtCore.QObject): self.pluginManager = plugin_helpers[u'pluginmanager'] self.formParent = plugin_helpers[u'formparent'] self.mediaController = plugin_helpers[u'mediacontroller'] - QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'%s_add_service_item' % self.name), + QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'%s_add_service_item' % self.name), self.processAddServiceEvent) - QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'%s_config_updated' % self.name), + QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'%s_config_updated' % self.name), self.configUpdated) def checkPreConditions(self): @@ -192,8 +190,7 @@ class Plugin(QtCore.QObject): """ Sets the status of the plugin """ - self.status = Settings().value( - self.settingsSection + u'/status', PluginStatus.Inactive) + self.status = Settings().value(self.settingsSection + u'/status', PluginStatus.Inactive) def toggleStatus(self, new_status): """ @@ -220,8 +217,7 @@ class Plugin(QtCore.QObject): you need, and return it for integration into OpenLP. """ if self.mediaItemClass: - self.mediaItem = self.mediaItemClass(self.mediaDock.media_dock, - self, self.icon) + self.mediaItem = self.mediaItemClass(self.mediaDock.media_dock, self, self.icon) def addImportMenuItem(self, importMenu): """ @@ -257,8 +253,7 @@ class Plugin(QtCore.QObject): """ if self.settingsTabClass: self.settingsTab = self.settingsTabClass(parent, self.name, - self.getString(StringContent.VisibleName)[u'title'], - self.iconPath) + self.getString(StringContent.VisibleName)[u'title'], self.iconPath) def addToMenu(self, menubar): """ @@ -273,8 +268,7 @@ class Plugin(QtCore.QObject): """ Generic Drag and drop handler triggered from service_manager. """ - log.debug(u'processAddServiceEvent event called for plugin %s' % - self.name) + log.debug(u'processAddServiceEvent event called for plugin %s' % self.name) if replace: self.mediaItem.onAddEditClick() else: @@ -285,8 +279,7 @@ class Plugin(QtCore.QObject): Show a dialog when the user clicks on the 'About' button in the plugin manager. """ - raise NotImplementedError( - u'Plugin.about needs to be defined by the plugin') + raise NotImplementedError(u'Plugin.about needs to be defined by the plugin') def initialise(self): """ @@ -305,7 +298,7 @@ class Plugin(QtCore.QObject): def appStartup(self): """ - Perform tasks on application starup + Perform tasks on application startup """ pass @@ -340,29 +333,21 @@ class Plugin(QtCore.QObject): Called to define all translatable texts of the plugin """ ## Load Action ## - self.__setNameTextString(StringContent.Load, - UiStrings().Load, tooltips[u'load']) + self.__setNameTextString(StringContent.Load, UiStrings().Load, tooltips[u'load']) ## Import Action ## - self.__setNameTextString(StringContent.Import, - UiStrings().Import, tooltips[u'import']) + self.__setNameTextString(StringContent.Import, UiStrings().Import, tooltips[u'import']) ## New Action ## - self.__setNameTextString(StringContent.New, - UiStrings().Add, tooltips[u'new']) + self.__setNameTextString(StringContent.New, UiStrings().Add, tooltips[u'new']) ## Edit Action ## - self.__setNameTextString(StringContent.Edit, - UiStrings().Edit, tooltips[u'edit']) + self.__setNameTextString(StringContent.Edit, UiStrings().Edit, tooltips[u'edit']) ## Delete Action ## - self.__setNameTextString(StringContent.Delete, - UiStrings().Delete, tooltips[u'delete']) + self.__setNameTextString(StringContent.Delete, UiStrings().Delete, tooltips[u'delete']) ## Preview Action ## - self.__setNameTextString(StringContent.Preview, - UiStrings().Preview, tooltips[u'preview']) + self.__setNameTextString(StringContent.Preview, UiStrings().Preview, tooltips[u'preview']) ## Send Live Action ## - self.__setNameTextString(StringContent.Live, - UiStrings().Live, tooltips[u'live']) + self.__setNameTextString(StringContent.Live, UiStrings().Live, tooltips[u'live']) ## Add to Service Action ## - self.__setNameTextString(StringContent.Service, - UiStrings().Service, tooltips[u'service']) + self.__setNameTextString(StringContent.Service, UiStrings().Service, tooltips[u'service']) def __setNameTextString(self, name, title, tooltip): """ diff --git a/openlp/core/lib/pluginmanager.py b/openlp/core/lib/pluginmanager.py index 668d1625a..3dc6e7803 100644 --- a/openlp/core/lib/pluginmanager.py +++ b/openlp/core/lib/pluginmanager.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 ############################################################################### # OpenLP - Open Source Lyrics Projection # @@ -107,13 +107,12 @@ class PluginManager(object): modulename = modulename[len(prefix) + 1:] modulename = modulename.replace(os.path.sep, '.') # import the modules - log.debug(u'Importing %s from %s. Depth %d', - modulename, path, thisdepth) + log.debug(u'Importing %s from %s. Depth %d', modulename, path, thisdepth) try: __import__(modulename, globals(), locals(), []) except ImportError, e: - log.exception(u'Failed to import module %s on path %s ' - 'for reason %s', modulename, path, e.args[0]) + log.exception(u'Failed to import module %s on path %s for reason %s', + modulename, path, e.args[0]) plugin_classes = Plugin.__subclasses__() plugin_objects = [] for p in plugin_classes: @@ -197,8 +196,7 @@ class PluginManager(object): """ log.info(u'Initialise Plugins - Started') for plugin in self.plugins: - log.info(u'initialising plugins %s in a %s state' - % (plugin.name, plugin.isActive())) + log.info(u'initialising plugins %s in a %s state' % (plugin.name, plugin.isActive())) if plugin.isActive(): plugin.initialise() log.info(u'Initialisation Complete for %s ' % plugin.name) diff --git a/openlp/core/lib/renderer.py b/openlp/core/lib/renderer.py index 3ec4acca8..b373a0da6 100644 --- a/openlp/core/lib/renderer.py +++ b/openlp/core/lib/renderer.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 ############################################################################### # OpenLP - Open Source Lyrics Projection # @@ -31,8 +31,7 @@ import logging from PyQt4 import QtGui, QtCore, QtWebKit -from openlp.core.lib import ServiceItem, expand_tags, \ - build_lyrics_format_css, build_lyrics_outline_css, Receiver, \ +from openlp.core.lib import ServiceItem, expand_tags, build_lyrics_format_css, build_lyrics_outline_css, Receiver, \ ItemCapabilities, FormattingTags, ImageSource from openlp.core.lib.theme import ThemeLevel from openlp.core.ui import MainDisplay, ScreenList @@ -81,8 +80,7 @@ class Renderer(object): self.display.setup() self._theme_dimensions = {} self._calculate_default() - QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'theme_update_global'), self.set_global_theme) + QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'theme_update_global'), self.set_global_theme) self.web = QtWebKit.QWebView() self.web.setVisible(False) self.web_frame = self.web.page().mainFrame() @@ -115,8 +113,7 @@ class Renderer(object): Only remove the given ``theme_name`` from the ``_theme_dimensions`` list. This can be used when a theme is permanently deleted. """ - if old_theme_name is not None and \ - old_theme_name in self._theme_dimensions: + if old_theme_name is not None and old_theme_name in self._theme_dimensions: del self._theme_dimensions[old_theme_name] if theme_name in self._theme_dimensions: del self._theme_dimensions[theme_name] @@ -134,16 +131,13 @@ class Renderer(object): theme_data = self.theme_manager.getThemeData(theme_name) main_rect = self.get_main_rectangle(theme_data) footer_rect = self.get_footer_rectangle(theme_data) - self._theme_dimensions[theme_name] = \ - [theme_data, main_rect, footer_rect] + self._theme_dimensions[theme_name] = [theme_data, main_rect, footer_rect] else: - theme_data, main_rect, footer_rect = \ - self._theme_dimensions[theme_name] + theme_data, main_rect, footer_rect = self._theme_dimensions[theme_name] # if No file do not update cache if theme_data.background_filename: self.image_manager.addImage(theme_data.background_filename, - ImageSource.Theme, - QtGui.QColor(theme_data.background_border_color)) + ImageSource.Theme, QtGui.QColor(theme_data.background_border_color)) def pre_render(self, override_theme_data=None): """ @@ -172,8 +166,7 @@ class Renderer(object): if override_theme_data is None: if theme_to_use not in self._theme_dimensions: self._set_theme(theme_to_use) - theme_data, main_rect, footer_rect = \ - self._theme_dimensions[theme_to_use] + theme_data, main_rect, footer_rect = self._theme_dimensions[theme_to_use] else: # Ignore everything and use own theme data. theme_data = override_theme_data @@ -305,13 +298,11 @@ class Renderer(object): text_contains_split = u'[---]' in text if text_contains_split: try: - text_to_render, text = \ - text.split(u'\n[---]\n', 1) + text_to_render, text = text.split(u'\n[---]\n', 1) except ValueError: text_to_render = text.split(u'\n[---]\n')[0] text = u'' - text_to_render, raw_tags, html_tags = \ - self._get_start_tags(text_to_render) + text_to_render, raw_tags, html_tags = self._get_start_tags(text_to_render) if text: text = raw_tags + text else: @@ -504,9 +495,8 @@ class Renderer(object): # the line will not fit as a whole. raw_words = self._words_split(line) html_words = map(expand_tags, raw_words) - previous_html, previous_raw = self._binary_chop( - formatted, previous_html, previous_raw, html_words, - raw_words, u' ', line_end) + previous_html, previous_raw = \ + self._binary_chop(formatted, previous_html, previous_raw, html_words, raw_words, u' ', line_end) else: previous_html += html_line + line_end previous_raw += line + line_end @@ -537,13 +527,9 @@ class Renderer(object): for tag in FormattingTags.get_html_tags(): if tag[u'start tag'] == u'{br}': continue - if raw_text.count(tag[u'start tag']) != \ - raw_text.count(tag[u'end tag']): - raw_tags.append( - (raw_text.find(tag[u'start tag']), tag[u'start tag'], - tag[u'end tag'])) - html_tags.append( - (raw_text.find(tag[u'start tag']), tag[u'start html'])) + if raw_text.count(tag[u'start tag']) != raw_text.count(tag[u'end tag']): + raw_tags.append((raw_text.find(tag[u'start tag']), tag[u'start tag'], tag[u'end tag'])) + html_tags.append((raw_text.find(tag[u'start tag']), tag[u'start html'])) # Sort the lists, so that the tags which were opened first on the first # slide (the text we are checking) will be opened first on the next # slide as well. @@ -558,11 +544,9 @@ class Renderer(object): end_tags.reverse() # Remove the indexes. html_tags = [tag[1] for tag in html_tags] - return raw_text + u''.join(end_tags), u''.join(start_tags), \ - u''.join(html_tags) + return raw_text + u''.join(end_tags), u''.join(start_tags), u''.join(html_tags) - def _binary_chop(self, formatted, previous_html, previous_raw, html_list, - raw_list, separator, line_end): + def _binary_chop(self, formatted, previous_html, previous_raw, html_list, raw_list, separator, line_end): """ This implements the binary chop algorithm for faster rendering. This algorithm works line based (line by line) and word based (word by word). @@ -612,8 +596,7 @@ class Renderer(object): # We found the number of words which will fit. if smallest_index == index or highest_index == index: index = smallest_index - text = previous_raw.rstrip(u'
') + \ - separator.join(raw_list[:index + 1]) + text = previous_raw.rstrip(u'
') + separator.join(raw_list[:index + 1]) text, raw_tags, html_tags = self._get_start_tags(text) formatted.append(text) previous_html = u'' @@ -627,10 +610,8 @@ class Renderer(object): # Check if the remaining elements fit on the slide. if self._text_fits_on_slide( html_tags + separator.join(html_list[index + 1:]).strip()): - previous_html = html_tags + separator.join( - html_list[index + 1:]).strip() + line_end - previous_raw = raw_tags + separator.join( - raw_list[index + 1:]).strip() + line_end + previous_html = html_tags + separator.join(html_list[index + 1:]).strip() + line_end + previous_raw = raw_tags + separator.join(raw_list[index + 1:]).strip() + line_end break else: # The remaining elements do not fit, thus reset the indexes, @@ -652,8 +633,7 @@ class Renderer(object): ``text`` The text to check. It may contain HTML tags. """ - self.web_frame.evaluateJavaScript(u'show_text("%s")' % - text.replace(u'\\', u'\\\\').replace(u'\"', u'\\\"')) + self.web_frame.evaluateJavaScript(u'show_text("%s")' % text.replace(u'\\', u'\\\\').replace(u'\"', u'\\\"')) return self.web_frame.contentsSize().height() <= self.empty_height def _words_split(self, line): diff --git a/openlp/core/lib/searchedit.py b/openlp/core/lib/searchedit.py index b4fc68804..b9ca51a22 100644 --- a/openlp/core/lib/searchedit.py +++ b/openlp/core/lib/searchedit.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 ############################################################################### # OpenLP - Open Source Lyrics Projection # @@ -54,16 +54,8 @@ class SearchEdit(QtGui.QLineEdit): u'QToolButton { border: none; padding: 0px; }') self.clearButton.resize(18, 18) self.clearButton.hide() - QtCore.QObject.connect( - self.clearButton, - QtCore.SIGNAL(u'clicked()'), - self._onClearButtonClicked - ) - QtCore.QObject.connect( - self, - QtCore.SIGNAL(u'textChanged(const QString&)'), - self._onSearchEditTextChanged - ) + QtCore.QObject.connect(self.clearButton, QtCore.SIGNAL(u'clicked()'), self._onClearButtonClicked) + QtCore.QObject.connect(self, QtCore.SIGNAL(u'textChanged(const QString&)'), self._onSearchEditTextChanged) self._updateStyleSheet() self.setAcceptDrops(False) @@ -72,24 +64,16 @@ class SearchEdit(QtGui.QLineEdit): Internal method to update the stylesheet depending on which widgets are available and visible. """ - frameWidth = self.style().pixelMetric( - QtGui.QStyle.PM_DefaultFrameWidth) + frameWidth = self.style().pixelMetric(QtGui.QStyle.PM_DefaultFrameWidth) rightPadding = self.clearButton.width() + frameWidth if hasattr(self, u'menuButton'): leftPadding = self.menuButton.width() - self.setStyleSheet( - u'QLineEdit { padding-left: %spx; padding-right: %spx; } ' % - (leftPadding, rightPadding)) + self.setStyleSheet(u'QLineEdit { padding-left: %spx; padding-right: %spx; } ' % (leftPadding, rightPadding)) else: - self.setStyleSheet(u'QLineEdit { padding-right: %spx; } ' % - rightPadding) + self.setStyleSheet(u'QLineEdit { padding-right: %spx; } ' % rightPadding) msz = self.minimumSizeHint() - self.setMinimumSize( - max(msz.width(), - self.clearButton.width() + (frameWidth * 2) + 2), - max(msz.height(), - self.clearButton.height() + (frameWidth * 2) + 2) - ) + self.setMinimumSize(max(msz.width(), self.clearButton.width() + (frameWidth * 2) + 2), + max(msz.height(), self.clearButton.height() + (frameWidth * 2) + 2)) def resizeEvent(self, event): """ @@ -99,14 +83,12 @@ class SearchEdit(QtGui.QLineEdit): The event that happened. """ size = self.clearButton.size() - frameWidth = self.style().pixelMetric( - QtGui.QStyle.PM_DefaultFrameWidth) + frameWidth = self.style().pixelMetric(QtGui.QStyle.PM_DefaultFrameWidth) self.clearButton.move(self.rect().right() - frameWidth - size.width(), (self.rect().bottom() + 1 - size.height()) / 2) if hasattr(self, u'menuButton'): size = self.menuButton.size() - self.menuButton.move(self.rect().left() + frameWidth + 2, - (self.rect().bottom() + 1 - size.height()) / 2) + self.menuButton.move(self.rect().left() + frameWidth + 2, (self.rect().bottom() + 1 - size.height()) / 2) def currentSearchType(self): """ @@ -215,9 +197,7 @@ class SearchEdit(QtGui.QLineEdit): # setPlaceholderText has been implemented in Qt 4.7 and in at least # PyQt 4.9 (I am not sure, if it was implemented in PyQt 4.8). try: - self.setPlaceholderText( - self.menuButton.defaultAction().placeholderText) + self.setPlaceholderText(self.menuButton.defaultAction().placeholderText) except AttributeError: pass - self.emit(QtCore.SIGNAL(u'searchTypeChanged(int)'), - self._currentSearchType) + self.emit(QtCore.SIGNAL(u'searchTypeChanged(int)'), self._currentSearchType) diff --git a/openlp/core/lib/serviceitem.py b/openlp/core/lib/serviceitem.py index cc319e27c..a72c06a53 100644 --- a/openlp/core/lib/serviceitem.py +++ b/openlp/core/lib/serviceitem.py @@ -570,12 +570,10 @@ class ServiceItem(object): start = None end = None if self.start_time != 0: - start = translate('OpenLP.ServiceItem', - 'Start: %s') % \ + start = translate('OpenLP.ServiceItem', 'Start: %s') % \ unicode(datetime.timedelta(seconds=self.start_time)) if self.media_length != 0: - end = translate('OpenLP.ServiceItem', - 'Length: %s') % \ + end = translate('OpenLP.ServiceItem', 'Length: %s') % \ unicode(datetime.timedelta(seconds=self.media_length)) if not start and not end: return u'' diff --git a/openlp/core/lib/settingsmanager.py b/openlp/core/lib/settingsmanager.py index 403c15b09..abf7bb578 100644 --- a/openlp/core/lib/settingsmanager.py +++ b/openlp/core/lib/settingsmanager.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 ############################################################################### # OpenLP - Open Source Lyrics Projection # diff --git a/openlp/core/lib/settingstab.py b/openlp/core/lib/settingstab.py index c7b4b8ce3..904c26fde 100644 --- a/openlp/core/lib/settingstab.py +++ b/openlp/core/lib/settingstab.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 ############################################################################### # OpenLP - Open Source Lyrics Projection # @@ -81,10 +81,8 @@ class SettingsTab(QtGui.QWidget): if event: QtGui.QWidget.resizeEvent(self, event) width = self.width() - self.tabLayout.spacing() - \ - self.tabLayout.contentsMargins().left() - \ - self.tabLayout.contentsMargins().right() - left_width = min(width - self.rightColumn.minimumSizeHint().width(), - width / 2) + self.tabLayout.contentsMargins().left() - self.tabLayout.contentsMargins().right() + left_width = min(width - self.rightColumn.minimumSizeHint().width(), width / 2) left_width = max(left_width, self.leftColumn.minimumSizeHint().width()) self.leftColumn.setFixedWidth(left_width) diff --git a/openlp/core/lib/spelltextedit.py b/openlp/core/lib/spelltextedit.py index 42894348b..42b0a2f0e 100644 --- a/openlp/core/lib/spelltextedit.py +++ b/openlp/core/lib/spelltextedit.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 ############################################################################### # OpenLP - Open Source Lyrics Projection # @@ -28,6 +28,7 @@ ############################################################################### import logging import re + try: import enchant from enchant import DictNotFoundError @@ -72,8 +73,7 @@ class SpellTextEdit(QtGui.QPlainTextEdit): # Rewrite the mouse event to a left button event so the cursor is # moved to the location of the pointer. event = QtGui.QMouseEvent(QtCore.QEvent.MouseButtonPress, - event.pos(), QtCore.Qt.LeftButton, QtCore.Qt.LeftButton, - QtCore.Qt.NoModifier) + event.pos(), QtCore.Qt.LeftButton, QtCore.Qt.LeftButton, QtCore.Qt.NoModifier) QtGui.QPlainTextEdit.mousePressEvent(self, event) def contextMenuEvent(self, event): @@ -92,20 +92,17 @@ class SpellTextEdit(QtGui.QPlainTextEdit): lang_menu = QtGui.QMenu( translate('OpenLP.SpellTextEdit', 'Language:')) for lang in enchant.list_languages(): - action = create_action(lang_menu, lang, text=lang, - checked=lang == self.dictionary.tag) + action = create_action(lang_menu, lang, text=lang, checked=lang == self.dictionary.tag) lang_menu.addAction(action) popupMenu.insertSeparator(popupMenu.actions()[0]) popupMenu.insertMenu(popupMenu.actions()[0], lang_menu) - QtCore.QObject.connect(lang_menu, - QtCore.SIGNAL(u'triggered(QAction*)'), self.setLanguage) + QtCore.QObject.connect(lang_menu, QtCore.SIGNAL(u'triggered(QAction*)'), self.setLanguage) # Check if the selected word is misspelled and offer spelling # suggestions if it is. if ENCHANT_AVAILABLE and self.textCursor().hasSelection(): text = self.textCursor().selectedText() if not self.dictionary.check(text): - spell_menu = QtGui.QMenu(translate('OpenLP.SpellTextEdit', - 'Spelling Suggestions')) + spell_menu = QtGui.QMenu(translate('OpenLP.SpellTextEdit', 'Spelling Suggestions')) for word in self.dictionary.suggest(text): action = SpellAction(word, spell_menu) action.correct.connect(self.correctWord) @@ -114,8 +111,7 @@ class SpellTextEdit(QtGui.QPlainTextEdit): # suggestions. if spell_menu.actions(): popupMenu.insertMenu(popupMenu.actions()[0], spell_menu) - tagMenu = QtGui.QMenu(translate('OpenLP.SpellTextEdit', - 'Formatting Tags')) + tagMenu = QtGui.QMenu(translate('OpenLP.SpellTextEdit', 'Formatting Tags')) if self.formattingTagsAllowed: for html in FormattingTags.get_html_tags(): action = SpellAction(html[u'desc'], tagMenu) diff --git a/openlp/core/lib/theme.py b/openlp/core/lib/theme.py index f2c8ec534..3f77fbb8b 100644 --- a/openlp/core/lib/theme.py +++ b/openlp/core/lib/theme.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 ############################################################################### # OpenLP - Open Source Lyrics Projection # @@ -478,8 +478,7 @@ class ThemeXML(object): Pull out the XML string formatted for human consumption """ self._build_xml_from_attrs() - return self.theme_xml.toprettyxml(indent=u' ', newl=u'\n', - encoding=u'utf-8') + return self.theme_xml.toprettyxml(indent=u' ', newl=u'\n', encoding=u'utf-8') def parse(self, xml): """ @@ -512,18 +511,15 @@ class ThemeXML(object): if element.tag == u'background': if element.attrib: for attr in element.attrib: - self._create_attr(element.tag, attr, \ - element.attrib[attr]) + self._create_attr(element.tag, attr, element.attrib[attr]) parent = element.getparent() if parent is not None: if parent.tag == u'font': master = parent.tag + u'_' + parent.attrib[u'type'] # set up Outline and Shadow Tags and move to font_main if parent.tag == u'display': - if element.tag.startswith(u'shadow') or \ - element.tag.startswith(u'outline'): - self._create_attr(u'font_main', element.tag, - element.text) + if element.tag.startswith(u'shadow') or element.tag.startswith(u'outline'): + self._create_attr(u'font_main', element.tag, element.text) master = parent.tag if parent.tag == u'background': master = parent.tag @@ -533,12 +529,10 @@ class ThemeXML(object): for attr in element.attrib: base_element = attr # correction for the shadow and outline tags - if element.tag == u'shadow' or \ - element.tag == u'outline': + if element.tag == u'shadow' or element.tag == u'outline': if not attr.startswith(element.tag): base_element = element.tag + u'_' + attr - self._create_attr(master, base_element, - element.attrib[attr]) + self._create_attr(master, base_element, element.attrib[attr]) else: if element.tag == u'name': self._create_attr(u'theme', element.tag, element.text) @@ -570,8 +564,7 @@ class ThemeXML(object): """ Create the attributes with the correct data types and name format """ - reject, master, element, value = \ - self._translate_tags(master, element, value) + reject, master, element, value = self._translate_tags(master, element, value) if reject: return field = self._de_hump(element) @@ -611,21 +604,17 @@ class ThemeXML(object): Build the XML from the varables in the object """ self._new_document(self.theme_name) - if self.background_type == \ - BackgroundType.to_string(BackgroundType.Solid): + if self.background_type == BackgroundType.to_string(BackgroundType.Solid): self.add_background_solid(self.background_color) - elif self.background_type == \ - BackgroundType.to_string(BackgroundType.Gradient): + elif self.background_type == BackgroundType.to_string(BackgroundType.Gradient): self.add_background_gradient( self.background_start_color, self.background_end_color, self.background_direction) - elif self.background_type == \ - BackgroundType.to_string(BackgroundType.Image): + elif self.background_type == BackgroundType.to_string(BackgroundType.Image): filename = os.path.split(self.background_filename)[1] self.add_background_image(filename, self.background_border_color) - elif self.background_type == \ - BackgroundType.to_string(BackgroundType.Transparent): + elif self.background_type == BackgroundType.to_string(BackgroundType.Transparent): self.add_background_transparent() self.add_font(self.font_main_name, self.font_main_color, diff --git a/openlp/core/lib/toolbar.py b/openlp/core/lib/toolbar.py index a9c1e3f8a..c39cf0776 100644 --- a/openlp/core/lib/toolbar.py +++ b/openlp/core/lib/toolbar.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 ############################################################################### # OpenLP - Open Source Lyrics Projection # diff --git a/openlp/core/lib/ui.py b/openlp/core/lib/ui.py index 3e1d662d2..f418d6c8d 100644 --- a/openlp/core/lib/ui.py +++ b/openlp/core/lib/ui.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 ############################################################################### # OpenLP - Open Source Lyrics Projection # @@ -80,13 +80,10 @@ class UiStrings(object): self.Error = translate('OpenLP.Ui', 'Error') self.Export = translate('OpenLP.Ui', 'Export') self.File = translate('OpenLP.Ui', 'File') - self.FontSizePtUnit = translate('OpenLP.Ui', 'pt', - 'Abbreviated font pointsize unit') + self.FontSizePtUnit = translate('OpenLP.Ui', 'pt', 'Abbreviated font pointsize unit') self.Help = translate('OpenLP.Ui', 'Help') - self.Hours = translate('OpenLP.Ui', 'h', - 'The abbreviated unit for hours') - self.IFdSs = translate('OpenLP.Ui', 'Invalid Folder Selected', - 'Singular') + self.Hours = translate('OpenLP.Ui', 'h', 'The abbreviated unit for hours') + self.IFdSs = translate('OpenLP.Ui', 'Invalid Folder Selected', 'Singular') self.IFSs = translate('OpenLP.Ui', 'Invalid File Selected', 'Singular') self.IFSp = translate('OpenLP.Ui', 'Invalid Files Selected', 'Plural') self.Image = translate('OpenLP.Ui', 'Image') @@ -96,8 +93,7 @@ class UiStrings(object): self.LiveBGError = translate('OpenLP.Ui', 'Live Background Error') self.LiveToolbar = translate('OpenLP.Ui', 'Live Toolbar') self.Load = translate('OpenLP.Ui', 'Load') - self.Minutes = translate('OpenLP.Ui', 'm', - 'The abbreviated unit for minutes') + self.Minutes = translate('OpenLP.Ui', 'm', 'The abbreviated unit for minutes') self.Middle = translate('OpenLP.Ui', 'Middle') self.New = translate('OpenLP.Ui', 'New') self.NewService = translate('OpenLP.Ui', 'New Service') @@ -111,8 +107,7 @@ class UiStrings(object): self.OLPV1 = translate('OpenLP.Ui', 'openlp.org 1.x') self.OLPV2 = translate('OpenLP.Ui', 'OpenLP 2') self.OLPV2x = translate('OpenLP.Ui', 'OpenLP 2.1') - self.OpenLPStart = translate('OpenLP.Ui', 'OpenLP is already running. ' - 'Do you wish to continue?') + self.OpenLPStart = translate('OpenLP.Ui', 'OpenLP is already running. Do you wish to continue?') self.OpenService = translate('OpenLP.Ui', 'Open service.') self.PlaySlidesInLoop = translate('OpenLP.Ui','Play Slides in Loop') self.PlaySlidesToEnd = translate('OpenLP.Ui','Play Slides to End') @@ -122,27 +117,21 @@ class UiStrings(object): self.ReplaceLiveBG = translate('OpenLP.Ui', 'Replace live background.') self.ResetBG = translate('OpenLP.Ui', 'Reset Background') self.ResetLiveBG = translate('OpenLP.Ui', 'Reset live background.') - self.Seconds = translate('OpenLP.Ui', 's', - 'The abbreviated unit for seconds') + self.Seconds = translate('OpenLP.Ui', 's', 'The abbreviated unit for seconds') self.SaveAndPreview = translate('OpenLP.Ui', 'Save && Preview') self.Search = translate('OpenLP.Ui', 'Search') - self.SearchThemes = translate( - 'OpenLP.Ui', 'Search Themes...', 'Search bar place holder text ') - self.SelectDelete = translate('OpenLP.Ui', 'You must select an item ' - 'to delete.') - self.SelectEdit = translate('OpenLP.Ui', 'You must select an item to ' - 'edit.') + self.SearchThemes = translate('OpenLP.Ui', 'Search Themes...', 'Search bar place holder text ') + self.SelectDelete = translate('OpenLP.Ui', 'You must select an item to delete.') + self.SelectEdit = translate('OpenLP.Ui', 'You must select an item to edit.') self.Settings = translate('OpenLP.Ui', 'Settings') self.SaveService = translate('OpenLP.Ui', 'Save Service') self.Service = translate('OpenLP.Ui', 'Service') self.Split = translate('OpenLP.Ui', 'Optional &Split') - self.SplitToolTip = translate('OpenLP.Ui', 'Split a slide into two ' - 'only if it does not fit on the screen as one slide.') + self.SplitToolTip = translate('OpenLP.Ui', + 'Split a slide into two only if it does not fit on the screen as one slide.') self.StartTimeCode = translate('OpenLP.Ui', 'Start %s') - self.StopPlaySlidesInLoop = translate('OpenLP.Ui', - 'Stop Play Slides in Loop') - self.StopPlaySlidesToEnd = translate('OpenLP.Ui', - 'Stop Play Slides to End') + self.StopPlaySlidesInLoop = translate('OpenLP.Ui', 'Stop Play Slides in Loop') + self.StopPlaySlidesToEnd = translate('OpenLP.Ui', 'Stop Play Slides to End') self.Theme = translate('OpenLP.Ui', 'Theme', 'Singular') self.Themes = translate('OpenLP.Ui', 'Themes', 'Plural') self.Tools = translate('OpenLP.Ui', 'Tools') @@ -166,8 +155,7 @@ def add_welcome_page(parent, image): A splash image for the wizard. """ parent.welcomePage = QtGui.QWizardPage() - parent.welcomePage.setPixmap(QtGui.QWizard.WatermarkPixmap, - QtGui.QPixmap(image)) + parent.welcomePage.setPixmap(QtGui.QWizard.WatermarkPixmap, QtGui.QPixmap(image)) parent.welcomePage.setObjectName(u'WelcomePage') parent.welcomeLayout = QtGui.QVBoxLayout(parent.welcomePage) parent.welcomeLayout.setObjectName(u'WelcomeLayout') @@ -223,15 +211,12 @@ def create_button_box(dialog, name, standard_buttons, custom_buttons=[]): button_box.addButton(button, QtGui.QDialogButtonBox.ActionRole) else: button_box.addButton(*button) - QtCore.QObject.connect(button_box, QtCore.SIGNAL(u'accepted()'), - dialog.accept) - QtCore.QObject.connect(button_box, QtCore.SIGNAL(u'rejected()'), - dialog.reject) + QtCore.QObject.connect(button_box, QtCore.SIGNAL(u'accepted()'), dialog.accept) + QtCore.QObject.connect(button_box, QtCore.SIGNAL(u'rejected()'), dialog.reject) return button_box -def critical_error_message_box(title=None, message=None, parent=None, - question=False): +def critical_error_message_box(title=None, message=None, parent=None, question=False): """ Provides a standard critical message box for errors that OpenLP displays to users. @@ -250,8 +235,7 @@ def critical_error_message_box(title=None, message=None, parent=None, """ if question: return QtGui.QMessageBox.critical(parent, UiStrings().Error, message, - QtGui.QMessageBox.StandardButtons( - QtGui.QMessageBox.Yes | QtGui.QMessageBox.No)) + QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes | QtGui.QMessageBox.No)) data = {u'message': message} data[u'title'] = title if title else UiStrings().Error return Receiver.send_message(u'openlp_error_message', data) @@ -306,16 +290,13 @@ def create_button(parent, name, **kwargs): role = kwargs.pop(u'role') if role == u'delete': kwargs.setdefault(u'text', UiStrings().Delete) - kwargs.setdefault(u'tooltip', - translate('OpenLP.Ui', 'Delete the selected item.')) + kwargs.setdefault(u'tooltip', translate('OpenLP.Ui', 'Delete the selected item.')) elif role == u'up': kwargs.setdefault(u'icon', u':/services/service_up.png') - kwargs.setdefault(u'tooltip', - translate('OpenLP.Ui', 'Move selection up one position.')) + kwargs.setdefault(u'tooltip', translate('OpenLP.Ui', 'Move selection up one position.')) elif role == u'down': kwargs.setdefault(u'icon', u':/services/service_down.png') - kwargs.setdefault(u'tooltip', - translate('OpenLP.Ui', 'Move selection down one position.')) + kwargs.setdefault(u'tooltip', translate('OpenLP.Ui', 'Move selection down one position.')) else: log.warn(u'The role "%s" is not defined in create_push_button().', role) @@ -333,8 +314,7 @@ def create_button(parent, name, **kwargs): if not kwargs.pop(u'enabled', True): button.setEnabled(False) if kwargs.get(u'click'): - QtCore.QObject.connect(button, QtCore.SIGNAL(u'clicked()'), - kwargs.pop(u'click')) + QtCore.QObject.connect(button, QtCore.SIGNAL(u'clicked()'), kwargs.pop(u'click')) for key in kwargs.keys(): if key not in [u'text', u'icon', u'tooltip', u'click']: log.warn(u'Parameter %s was not consumed in create_button().', key) @@ -423,8 +403,7 @@ def create_action(parent, name, **kwargs): QtCore.QObject.connect(action, QtCore.SIGNAL(u'triggered(bool)'), kwargs.pop(u'triggers')) for key in kwargs.keys(): - if key not in [u'text', u'icon', u'tooltip', u'statustip', u'checked', - u'shortcuts', u'category', u'triggers']: + if key not in [u'text', u'icon', u'tooltip', u'statustip', u'checked', u'shortcuts', u'category', u'triggers']: log.warn(u'Parameter %s was not consumed in create_action().', key) return action @@ -469,8 +448,7 @@ def create_valign_selection_widgets(parent): label = QtGui.QLabel(parent) label.setText(translate('OpenLP.Ui', '&Vertical Align:')) combo_box = QtGui.QComboBox(parent) - combo_box.addItems( - [UiStrings().Top, UiStrings().Middle, UiStrings().Bottom]) + combo_box.addItems([UiStrings().Top, UiStrings().Middle, UiStrings().Bottom]) label.setBuddy(combo_box) return label, combo_box diff --git a/openlp/core/ui/media/playertab.py b/openlp/core/ui/media/playertab.py index 2b2137adf..ebc951b5e 100644 --- a/openlp/core/ui/media/playertab.py +++ b/openlp/core/ui/media/playertab.py @@ -87,8 +87,7 @@ class PlayerTab(SettingsTab): self.playerOrderGroupBox.setObjectName(u'playerOrderGroupBox') self.playerOrderLayout = QtGui.QHBoxLayout(self.playerOrderGroupBox) self.playerOrderLayout.setObjectName(u'playerOrderLayout') - self.playerOrderlistWidget = QtGui.QListWidget( - self.playerOrderGroupBox) + self.playerOrderlistWidget = QtGui.QListWidget(self.playerOrderGroupBox) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) diff --git a/openlp/core/ui/media/webkitplayer.py b/openlp/core/ui/media/webkitplayer.py index 1c01e79a5..61761d17f 100644 --- a/openlp/core/ui/media/webkitplayer.py +++ b/openlp/core/ui/media/webkitplayer.py @@ -373,19 +373,16 @@ class WebkitPlayer(MediaPlayer): if display.hasAudio: vol = float(vol) / float(100) if not controller.media_info.is_flash: - display.frame.evaluateJavaScript( - u'show_video(null, null, %s);' % str(vol)) + display.frame.evaluateJavaScript(u'show_video(null, null, %s);' % str(vol)) def seek(self, display, seekVal): controller = display.controller if controller.media_info.is_flash: seek = seekVal - display.frame.evaluateJavaScript( - u'show_flash("seek", null, null, "%s");' % (seek)) + display.frame.evaluateJavaScript(u'show_flash("seek", null, null, "%s");' % (seek)) else: seek = float(seekVal) / 1000 - display.frame.evaluateJavaScript( - u'show_video("seek", null, null, null, "%f");' % (seek)) + display.frame.evaluateJavaScript(u'show_video("seek", null, null, null, "%f");' % (seek)) def reset(self, display): controller = display.controller @@ -412,11 +409,9 @@ class WebkitPlayer(MediaPlayer): currentTime = display.frame.evaluateJavaScript(u'show_flash("currentTime");') length = display.frame.evaluateJavaScript(u'show_flash("length");') else: - if display.frame.evaluateJavaScript( - u'show_video("isEnded");') == 'true': + if display.frame.evaluateJavaScript(u'show_video("isEnded");') == 'true': self.stop(display) - (currentTime, ok) = display.frame.evaluateJavaScript( - u'show_video("currentTime");') + (currentTime, ok) = display.frame.evaluateJavaScript(u'show_video("currentTime");') # check if conversion was ok and value is not 'NaN' if ok and currentTime != float('inf'): currentTime = int(currentTime * 1000) diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 129a1addd..2787702a6 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -234,11 +234,9 @@ class ServiceManager(QtGui.QWidget): self.servicePath = AppLocation.get_section_data_path(u'servicemanager') # build the drag and drop context menu self.dndMenu = QtGui.QMenu() - self.newAction = self.dndMenu.addAction( - translate('OpenLP.ServiceManager', '&Add New Item')) + self.newAction = self.dndMenu.addAction(translate('OpenLP.ServiceManager', '&Add New Item')) self.newAction.setIcon(build_icon(u':/general/general_edit.png')) - self.addToAction = self.dndMenu.addAction( - translate('OpenLP.ServiceManager', '&Add to Selected Item')) + self.addToAction = self.dndMenu.addAction(translate('OpenLP.ServiceManager', '&Add to Selected Item')) self.addToAction.setIcon(build_icon(u':/general/general_edit.png')) # build the context menu self.menu = QtGui.QMenu() @@ -420,9 +418,7 @@ class ServiceManager(QtGui.QWidget): basename = os.path.splitext(file_name)[0] service_file_name = '%s.osd' % basename log.debug(u'ServiceManager.saveFile - %s', path_file_name) - SettingsManager.set_last_dir( - self.mainwindow.serviceManagerSettingsSection, - path) + SettingsManager.set_last_dir(self.mainwindow.serviceManagerSettingsSection, path) service = [] write_list = [] missing_list = [] @@ -1289,9 +1285,7 @@ class ServiceManager(QtGui.QWidget): if self.serviceItems[item][u'service_item'].is_valid: self.mainwindow.liveController.addServiceManagerItem( self.serviceItems[item][u'service_item'], child) - if Settings().value( - self.mainwindow.generalSettingsSection + u'/auto preview', - False): + if Settings().value(self.mainwindow.generalSettingsSection + u'/auto preview', False): item += 1 if self.serviceItems and item < len(self.serviceItems) and \ self.serviceItems[item][u'service_item'].is_capable(ItemCapabilities.CanPreview): diff --git a/openlp/plugins/media/lib/mediaitem.py b/openlp/plugins/media/lib/mediaitem.py index efcf3b36e..197939e40 100644 --- a/openlp/plugins/media/lib/mediaitem.py +++ b/openlp/plugins/media/lib/mediaitem.py @@ -71,8 +71,8 @@ class MediaMediaItem(MediaManagerItem): self.displayController.previewDisplay.screen = {u'size':self.displayController.previewDisplay.geometry()} self.displayController.previewDisplay.setup() self.plugin.mediaController.setup_display(self.displayController.previewDisplay, False) - QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'video_background_replaced'), self.videobackgroundReplaced) + QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'video_background_replaced'), + self.videobackgroundReplaced) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'mediaitem_media_rebuild'), self.rebuild_players) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'config_screen_changed'), self.displaySetup) # Allow DnD from the desktop From 2b6b6d5756b934d4d6a87f8fcecab982c29cc347 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sat, 29 Dec 2012 09:35:24 +0000 Subject: [PATCH 49/53] Start of ui --- openlp/core/theme/__init__.py | 2 +- openlp/core/theme/theme.py | 14 +- openlp/core/ui/__init__.py | 2 +- openlp/core/ui/aboutdialog.py | 26 +- openlp/core/ui/aboutform.py | 11 +- openlp/core/ui/advancedtab.py | 402 +++++++++------------------ openlp/core/ui/exceptiondialog.py | 26 +- openlp/core/ui/exceptionform.py | 22 +- openlp/core/utils/__init__.py | 50 ++-- openlp/core/utils/actions.py | 14 +- openlp/core/utils/languagemanager.py | 23 +- 11 files changed, 199 insertions(+), 393 deletions(-) diff --git a/openlp/core/theme/__init__.py b/openlp/core/theme/__init__.py index 8b4415566..e6b70c28c 100644 --- a/openlp/core/theme/__init__.py +++ b/openlp/core/theme/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 ############################################################################### # OpenLP - Open Source Lyrics Projection # diff --git a/openlp/core/theme/theme.py b/openlp/core/theme/theme.py index 63461b53b..4c9adebcb 100644 --- a/openlp/core/theme/theme.py +++ b/openlp/core/theme/theme.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 ############################################################################### # OpenLP - Open Source Lyrics Projection # @@ -194,8 +194,7 @@ class Theme(object): ``xml`` The data to apply to the theme """ - root = ElementTree(element=XML(xml.encode(u'ascii', - u'xmlcharrefreplace'))) + root = ElementTree(element=XML(xml.encode(u'ascii', u'xmlcharrefreplace'))) xml_iter = root.getiterator() for element in xml_iter: delphi_color_change = False @@ -219,16 +218,13 @@ class Theme(object): val = int(element_text) except ValueError: val = element_text - if (element.tag.find(u'Color') > 0 or - (element.tag.find(u'BackgroundParameter') == 0 and + if (element.tag.find(u'Color') > 0 or (element.tag.find(u'BackgroundParameter') == 0 and isinstance(val, int))): # convert to a wx.Colour if not delphi_color_change: - val = QtGui.QColor( - val&0xFF, (val>>8)&0xFF, (val>>16)&0xFF) + val = QtGui.QColor(val&0xFF, (val>>8)&0xFF, (val>>16)&0xFF) else: - val = QtGui.QColor( - (val>>16)&0xFF, (val>>8)&0xFF, val&0xFF) + val = QtGui.QColor((val>>16)&0xFF, (val>>8)&0xFF, val&0xFF) setattr(self, element.tag, val) def __str__(self): diff --git a/openlp/core/ui/__init__.py b/openlp/core/ui/__init__.py index 325b1d450..cce8b16bb 100644 --- a/openlp/core/ui/__init__.py +++ b/openlp/core/ui/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 ############################################################################### # OpenLP - Open Source Lyrics Projection # diff --git a/openlp/core/ui/aboutdialog.py b/openlp/core/ui/aboutdialog.py index 1dd447bcf..fd42edf3b 100644 --- a/openlp/core/ui/aboutdialog.py +++ b/openlp/core/ui/aboutdialog.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 ############################################################################### # OpenLP - Open Source Lyrics Projection # @@ -39,8 +39,7 @@ class Ui_AboutDialog(object): self.aboutDialogLayout = QtGui.QVBoxLayout(aboutDialog) self.aboutDialogLayout.setObjectName(u'aboutDialogLayout') self.logoLabel = QtGui.QLabel(aboutDialog) - self.logoLabel.setPixmap( - QtGui.QPixmap(u':/graphics/openlp-about-logo.png')) + self.logoLabel.setPixmap(QtGui.QPixmap(u':/graphics/openlp-about-logo.png')) self.logoLabel.setObjectName(u'logoLabel') self.aboutDialogLayout.addWidget(self.logoLabel) self.aboutNotebook = QtGui.QTabWidget(aboutDialog) @@ -73,10 +72,8 @@ class Ui_AboutDialog(object): self.licenseTabLayout.addWidget(self.licenseTextEdit) self.aboutNotebook.addTab(self.licenseTab, u'') self.aboutDialogLayout.addWidget(self.aboutNotebook) - self.volunteerButton = create_button(None, u'volunteerButton', - icon=u':/system/system_volunteer.png') - self.buttonBox = create_button_box(aboutDialog, u'buttonBox', - [u'close'], [self.volunteerButton]) + self.volunteerButton = create_button(None, u'volunteerButton', icon=u':/system/system_volunteer.png') + self.buttonBox = create_button_box(aboutDialog, u'buttonBox', [u'close'], [self.volunteerButton]) self.aboutDialogLayout.addWidget(self.buttonBox) self.retranslateUi(aboutDialog) self.aboutNotebook.setCurrentIndex(0) @@ -99,8 +96,7 @@ class Ui_AboutDialog(object): 'like to see more free Christian software being written, please ' 'consider volunteering by using the button below.' )) - self.aboutNotebook.setTabText( - self.aboutNotebook.indexOf(self.aboutTab), UiStrings().About) + self.aboutNotebook.setTabText(self.aboutNotebook.indexOf(self.aboutTab), UiStrings().About) lead = u'Raoul "superfly" Snyman' developers = [u'Tim "TRB143" Bentley', u'Jonathan "gushie" Corwin', u'Michael "cocooncrash" Gorven', @@ -261,8 +257,7 @@ class Ui_AboutDialog(object): u'\n '.join(translators[u'ta_LK']), u'\n '.join(translators[u'zh_CN']), u'\n '.join(documentors))) - self.aboutNotebook.setTabText( - self.aboutNotebook.indexOf(self.creditsTab), + self.aboutNotebook.setTabText(self.aboutNotebook.indexOf(self.creditsTab), translate('OpenLP.AboutForm', 'Credits')) copyright = translate('OpenLP.AboutForm', 'Copyright \xa9 2004-2012 %s\n' @@ -656,10 +651,7 @@ class Ui_AboutDialog(object): 'linking proprietary applications with the library. If this is ' 'what you want to do, use the GNU Lesser General Public License ' 'instead of this License.') - self.licenseTextEdit.setPlainText(u'%s\n\n%s\n\n%s\n\n\n%s' % - (copyright, licence, disclaimer, gpltext)) - self.aboutNotebook.setTabText( - self.aboutNotebook.indexOf(self.licenseTab), + self.licenseTextEdit.setPlainText(u'%s\n\n%s\n\n%s\n\n\n%s' % (copyright, licence, disclaimer, gpltext)) + self.aboutNotebook.setTabText(self.aboutNotebook.indexOf(self.licenseTab), translate('OpenLP.AboutForm', 'License')) - self.volunteerButton.setText(translate('OpenLP.AboutForm', - 'Volunteer')) + self.volunteerButton.setText(translate('OpenLP.AboutForm', 'Volunteer')) diff --git a/openlp/core/ui/aboutform.py b/openlp/core/ui/aboutform.py index 19929e7f3..67537b7ea 100644 --- a/openlp/core/ui/aboutform.py +++ b/openlp/core/ui/aboutform.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 ############################################################################### # OpenLP - Open Source Lyrics Projection # @@ -46,17 +46,14 @@ class AboutForm(QtGui.QDialog, Ui_AboutDialog): applicationVersion = get_application_version() self.setupUi(self) about_text = self.aboutTextEdit.toPlainText() - about_text = about_text.replace(u'', - applicationVersion[u'version']) + about_text = about_text.replace(u'', applicationVersion[u'version']) if applicationVersion[u'build']: - build_text = translate('OpenLP.AboutForm', ' build %s') % \ - applicationVersion[u'build'] + build_text = translate('OpenLP.AboutForm', ' build %s') % applicationVersion[u'build'] else: build_text = u'' about_text = about_text.replace(u'', build_text) self.aboutTextEdit.setPlainText(about_text) - QtCore.QObject.connect(self.volunteerButton, - QtCore.SIGNAL(u'clicked()'), self.onVolunteerButtonClicked) + QtCore.QObject.connect(self.volunteerButton, QtCore.SIGNAL(u'clicked()'), self.onVolunteerButtonClicked) def onVolunteerButtonClicked(self): """ diff --git a/openlp/core/ui/advancedtab.py b/openlp/core/ui/advancedtab.py index 32179281b..bdb24c04b 100644 --- a/openlp/core/ui/advancedtab.py +++ b/openlp/core/ui/advancedtab.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 ############################################################################### # OpenLP - Open Source Lyrics Projection # @@ -36,8 +36,7 @@ import sys from PyQt4 import QtCore, QtGui -from openlp.core.lib import SettingsTab, translate, build_icon, Receiver, \ - Settings +from openlp.core.lib import SettingsTab, translate, build_icon, Receiver, Settings from openlp.core.lib.ui import UiStrings from openlp.core.utils import get_images_filter, AppLocation, format_time from openlp.core.lib import SlideLimits @@ -95,12 +94,10 @@ class AdvancedTab(SettingsTab): self.doubleClickLiveCheckBox.setObjectName(u'doubleClickLiveCheckBox') self.uiLayout.addRow(self.doubleClickLiveCheckBox) self.singleClickPreviewCheckBox = QtGui.QCheckBox(self.uiGroupBox) - self.singleClickPreviewCheckBox.setObjectName( - u'singleClickPreviewCheckBox') + self.singleClickPreviewCheckBox.setObjectName(u'singleClickPreviewCheckBox') self.uiLayout.addRow(self.singleClickPreviewCheckBox) self.expandServiceItemCheckBox = QtGui.QCheckBox(self.uiGroupBox) - self.expandServiceItemCheckBox.setObjectName( - u'expandServiceItemCheckBox') + self.expandServiceItemCheckBox.setObjectName(u'expandServiceItemCheckBox') self.uiLayout.addRow(self.expandServiceItemCheckBox) self.enableAutoCloseCheckBox = QtGui.QCheckBox(self.uiGroupBox) self.enableAutoCloseCheckBox.setObjectName(u'enableAutoCloseCheckBox') @@ -125,33 +122,25 @@ class AdvancedTab(SettingsTab): self.serviceNameTimeHBox.setObjectName(u'serviceNameTimeHBox') self.serviceNameTimeHBox.addWidget(self.serviceNameDay) self.serviceNameTimeHBox.addWidget(self.serviceNameTime) - self.serviceNameLayout.addRow(self.serviceNameTimeLabel, - self.serviceNameTimeHBox) + self.serviceNameLayout.addRow(self.serviceNameTimeLabel, self.serviceNameTimeHBox) self.serviceNameLabel = QtGui.QLabel(self.serviceNameGroupBox) self.serviceNameLabel.setObjectName(u'serviceNameLabel') self.serviceNameEdit = QtGui.QLineEdit(self.serviceNameGroupBox) self.serviceNameEdit.setObjectName(u'serviceNameEdit') - self.serviceNameEdit.setValidator(QtGui.QRegExpValidator( - QtCore.QRegExp(r'[^/\\?*|<>\[\]":+]+'), self)) - self.serviceNameRevertButton = QtGui.QToolButton( - self.serviceNameGroupBox) - self.serviceNameRevertButton.setObjectName( - u'serviceNameRevertButton') - self.serviceNameRevertButton.setIcon( - build_icon(u':/general/general_revert.png')) + self.serviceNameEdit.setValidator(QtGui.QRegExpValidator(QtCore.QRegExp(r'[^/\\?*|<>\[\]":+]+'), self)) + self.serviceNameRevertButton = QtGui.QToolButton(self.serviceNameGroupBox) + self.serviceNameRevertButton.setObjectName(u'serviceNameRevertButton') + self.serviceNameRevertButton.setIcon(build_icon(u':/general/general_revert.png')) self.serviceNameHBox = QtGui.QHBoxLayout() self.serviceNameHBox.setObjectName(u'serviceNameHBox') self.serviceNameHBox.addWidget(self.serviceNameEdit) self.serviceNameHBox.addWidget(self.serviceNameRevertButton) - self.serviceNameLayout.addRow(self.serviceNameLabel, - self.serviceNameHBox) + self.serviceNameLayout.addRow(self.serviceNameLabel, self.serviceNameHBox) self.serviceNameExampleLabel = QtGui.QLabel(self.serviceNameGroupBox) - self.serviceNameExampleLabel.setObjectName( - u'serviceNameExampleLabel') + self.serviceNameExampleLabel.setObjectName(u'serviceNameExampleLabel') self.serviceNameExample = QtGui.QLabel(self.serviceNameGroupBox) self.serviceNameExample.setObjectName(u'serviceNameExample') - self.serviceNameLayout.addRow(self.serviceNameExampleLabel, - self.serviceNameExample) + self.serviceNameLayout.addRow(self.serviceNameExampleLabel, self.serviceNameExample) self.leftLayout.addWidget(self.serviceNameGroupBox) # Data Directory self.dataDirectoryGroupBox = QtGui.QGroupBox(self.leftColumn) @@ -159,8 +148,7 @@ class AdvancedTab(SettingsTab): self.dataDirectoryLayout = QtGui.QFormLayout(self.dataDirectoryGroupBox) self.dataDirectoryLayout.setObjectName(u'dataDirectoryLayout') self.dataDirectoryCurrentLabel = QtGui.QLabel(self.dataDirectoryGroupBox) - self.dataDirectoryCurrentLabel.setObjectName( - u'dataDirectoryCurrentLabel') + self.dataDirectoryCurrentLabel.setObjectName( u'dataDirectoryCurrentLabel') self.dataDirectoryLabel = QtGui.QLabel(self.dataDirectoryGroupBox) self.dataDirectoryLabel.setObjectName(u'dataDirectoryLabel') self.dataDirectoryNewLabel = QtGui.QLabel(self.dataDirectoryGroupBox) @@ -168,52 +156,32 @@ class AdvancedTab(SettingsTab): self.newDataDirectoryEdit = QtGui.QLineEdit(self.dataDirectoryGroupBox) self.newDataDirectoryEdit.setObjectName(u'newDataDirectoryEdit') self.newDataDirectoryEdit.setReadOnly(True) - self.newDataDirectoryHasFilesLabel = QtGui.QLabel( - self.dataDirectoryGroupBox) - self.newDataDirectoryHasFilesLabel.setObjectName( - u'newDataDirectoryHasFilesLabel') + self.newDataDirectoryHasFilesLabel = QtGui.QLabel(self.dataDirectoryGroupBox) + self.newDataDirectoryHasFilesLabel.setObjectName(u'newDataDirectoryHasFilesLabel') self.newDataDirectoryHasFilesLabel.setWordWrap(True) - self.dataDirectoryBrowseButton = QtGui.QToolButton( - self.dataDirectoryGroupBox) - self.dataDirectoryBrowseButton.setObjectName( - u'dataDirectoryBrowseButton') - self.dataDirectoryBrowseButton.setIcon( - build_icon(u':/general/general_open.png')) - self.dataDirectoryDefaultButton = QtGui.QToolButton( - self.dataDirectoryGroupBox) - self.dataDirectoryDefaultButton.setObjectName( - u'dataDirectoryDefaultButton') - self.dataDirectoryDefaultButton.setIcon( - build_icon(u':/general/general_revert.png')) - self.dataDirectoryCancelButton = QtGui.QToolButton( - self.dataDirectoryGroupBox) - self.dataDirectoryCancelButton.setObjectName( - u'dataDirectoryCancelButton') - self.dataDirectoryCancelButton.setIcon( - build_icon(u':/general/general_delete.png')) + self.dataDirectoryBrowseButton = QtGui.QToolButton(self.dataDirectoryGroupBox) + self.dataDirectoryBrowseButton.setObjectName(u'dataDirectoryBrowseButton') + self.dataDirectoryBrowseButton.setIcon(build_icon(u':/general/general_open.png')) + self.dataDirectoryDefaultButton = QtGui.QToolButton(self.dataDirectoryGroupBox) + self.dataDirectoryDefaultButton.setObjectName(u'dataDirectoryDefaultButton') + self.dataDirectoryDefaultButton.setIcon(build_icon(u':/general/general_revert.png')) + self.dataDirectoryCancelButton = QtGui.QToolButton(self.dataDirectoryGroupBox) + self.dataDirectoryCancelButton.setObjectName(u'dataDirectoryCancelButton') + self.dataDirectoryCancelButton.setIcon(build_icon(u':/general/general_delete.png')) self.newDataDirectoryLabelHBox = QtGui.QHBoxLayout() - self.newDataDirectoryLabelHBox.setObjectName( - u'newDataDirectoryLabelHBox') + self.newDataDirectoryLabelHBox.setObjectName(u'newDataDirectoryLabelHBox') self.newDataDirectoryLabelHBox.addWidget(self.newDataDirectoryEdit) self.newDataDirectoryLabelHBox.addWidget(self.dataDirectoryBrowseButton) - self.newDataDirectoryLabelHBox.addWidget( - self.dataDirectoryDefaultButton) + self.newDataDirectoryLabelHBox.addWidget(self.dataDirectoryDefaultButton) self.dataDirectoryCopyCheckHBox = QtGui.QHBoxLayout() - self.dataDirectoryCopyCheckHBox.setObjectName( - u'dataDirectoryCopyCheckHBox') - self.dataDirectoryCopyCheckBox = QtGui.QCheckBox( - self.dataDirectoryGroupBox) - self.dataDirectoryCopyCheckBox.setObjectName( - u'dataDirectoryCopyCheckBox') - self.dataDirectoryCopyCheckHBox.addWidget( - self.dataDirectoryCopyCheckBox) + self.dataDirectoryCopyCheckHBox.setObjectName(u'dataDirectoryCopyCheckHBox') + self.dataDirectoryCopyCheckBox = QtGui.QCheckBox(self.dataDirectoryGroupBox) + self.dataDirectoryCopyCheckBox.setObjectName(u'dataDirectoryCopyCheckBox') + self.dataDirectoryCopyCheckHBox.addWidget(self.dataDirectoryCopyCheckBox) self.dataDirectoryCopyCheckHBox.addStretch() - self.dataDirectoryCopyCheckHBox.addWidget( - self.dataDirectoryCancelButton) - self.dataDirectoryLayout.addRow(self.dataDirectoryCurrentLabel, - self.dataDirectoryLabel) - self.dataDirectoryLayout.addRow(self.dataDirectoryNewLabel, - self.newDataDirectoryLabelHBox) + self.dataDirectoryCopyCheckHBox.addWidget(self.dataDirectoryCancelButton) + self.dataDirectoryLayout.addRow(self.dataDirectoryCurrentLabel, self.dataDirectoryLabel) + self.dataDirectoryLayout.addRow(self.dataDirectoryNewLabel, self.newDataDirectoryLabelHBox) self.dataDirectoryLayout.addRow(self.dataDirectoryCopyCheckHBox) self.dataDirectoryLayout.addRow(self.newDataDirectoryHasFilesLabel) self.leftLayout.addWidget(self.dataDirectoryGroupBox) @@ -227,27 +195,23 @@ class AdvancedTab(SettingsTab): self.defaultColorLabel.setObjectName(u'defaultColorLabel') self.defaultColorButton = QtGui.QPushButton(self.defaultImageGroupBox) self.defaultColorButton.setObjectName(u'defaultColorButton') - self.defaultImageLayout.addRow(self.defaultColorLabel, - self.defaultColorButton) + self.defaultImageLayout.addRow(self.defaultColorLabel, self.defaultColorButton) self.defaultFileLabel = QtGui.QLabel(self.defaultImageGroupBox) self.defaultFileLabel.setObjectName(u'defaultFileLabel') self.defaultFileEdit = QtGui.QLineEdit(self.defaultImageGroupBox) self.defaultFileEdit.setObjectName(u'defaultFileEdit') self.defaultBrowseButton = QtGui.QToolButton(self.defaultImageGroupBox) self.defaultBrowseButton.setObjectName(u'defaultBrowseButton') - self.defaultBrowseButton.setIcon( - build_icon(u':/general/general_open.png')) + self.defaultBrowseButton.setIcon(build_icon(u':/general/general_open.png')) self.defaultRevertButton = QtGui.QToolButton(self.defaultImageGroupBox) self.defaultRevertButton.setObjectName(u'defaultRevertButton') - self.defaultRevertButton.setIcon( - build_icon(u':/general/general_revert.png')) + self.defaultRevertButton.setIcon(build_icon(u':/general/general_revert.png')) self.defaultFileLayout = QtGui.QHBoxLayout() self.defaultFileLayout.setObjectName(u'defaultFileLayout') self.defaultFileLayout.addWidget(self.defaultFileEdit) self.defaultFileLayout.addWidget(self.defaultBrowseButton) self.defaultFileLayout.addWidget(self.defaultRevertButton) - self.defaultImageLayout.addRow(self.defaultFileLabel, - self.defaultFileLayout) + self.defaultImageLayout.addRow(self.defaultFileLabel, self.defaultFileLayout) self.rightLayout.addWidget(self.defaultImageGroupBox) # Hide mouse self.hideMouseGroupBox = QtGui.QGroupBox(self.rightColumn) @@ -286,46 +250,31 @@ class AdvancedTab(SettingsTab): self.rightLayout.addWidget(self.x11GroupBox) self.rightLayout.addStretch() self.shouldUpdateServiceNameExample = False - QtCore.QObject.connect(self.serviceNameCheckBox, - QtCore.SIGNAL(u'toggled(bool)'), self.serviceNameCheckBoxToggled) - QtCore.QObject.connect(self.serviceNameDay, - QtCore.SIGNAL(u'currentIndexChanged(int)'), + QtCore.QObject.connect(self.serviceNameCheckBox, QtCore.SIGNAL(u'toggled(bool)'), + self.serviceNameCheckBoxToggled) + QtCore.QObject.connect(self.serviceNameDay, QtCore.SIGNAL(u'currentIndexChanged(int)'), self.onServiceNameDayChanged) - QtCore.QObject.connect(self.serviceNameTime, - QtCore.SIGNAL(u'timeChanged(QTime)'), + QtCore.QObject.connect(self.serviceNameTime, QtCore.SIGNAL(u'timeChanged(QTime)'), self.updateServiceNameExample) - QtCore.QObject.connect(self.serviceNameEdit, - QtCore.SIGNAL(u'textChanged(QString)'), + QtCore.QObject.connect(self.serviceNameEdit, QtCore.SIGNAL(u'textChanged(QString)'), self.updateServiceNameExample) - QtCore.QObject.connect(self.serviceNameRevertButton, - QtCore.SIGNAL(u'clicked()'), + QtCore.QObject.connect(self.serviceNameRevertButton, QtCore.SIGNAL(u'clicked()'), self.onServiceNameRevertButtonClicked) - QtCore.QObject.connect(self.defaultColorButton, - QtCore.SIGNAL(u'clicked()'), self.onDefaultColorButtonClicked) - QtCore.QObject.connect(self.defaultBrowseButton, - QtCore.SIGNAL(u'clicked()'), self.onDefaultBrowseButtonClicked) - QtCore.QObject.connect(self.defaultRevertButton, - QtCore.SIGNAL(u'clicked()'), self.onDefaultRevertButtonClicked) - QtCore.QObject.connect(self.x11BypassCheckBox, - QtCore.SIGNAL(u'toggled(bool)'), self.onX11BypassCheckBoxToggled) - QtCore.QObject.connect(self.dataDirectoryBrowseButton, - QtCore.SIGNAL(u'clicked()'), + QtCore.QObject.connect(self.defaultColorButton, QtCore.SIGNAL(u'clicked()'), self.onDefaultColorButtonClicked) + QtCore.QObject.connect(self.defaultBrowseButton, QtCore.SIGNAL(u'clicked()'), self.onDefaultBrowseButtonClicked) + QtCore.QObject.connect(self.defaultRevertButton, QtCore.SIGNAL(u'clicked()'), self.onDefaultRevertButtonClicked) + QtCore.QObject.connect(self.x11BypassCheckBox, QtCore.SIGNAL(u'toggled(bool)'), self.onX11BypassCheckBoxToggled) + QtCore.QObject.connect(self.dataDirectoryBrowseButton, QtCore.SIGNAL(u'clicked()'), self.onDataDirectoryBrowseButtonClicked) - QtCore.QObject.connect(self.dataDirectoryDefaultButton, - QtCore.SIGNAL(u'clicked()'), + QtCore.QObject.connect(self.dataDirectoryDefaultButton, QtCore.SIGNAL(u'clicked()'), self.onDataDirectoryDefaultButtonClicked) - QtCore.QObject.connect(self.dataDirectoryCancelButton, - QtCore.SIGNAL(u'clicked()'), + QtCore.QObject.connect(self.dataDirectoryCancelButton, QtCore.SIGNAL(u'clicked()'), self.onDataDirectoryCancelButtonClicked) - QtCore.QObject.connect(self.dataDirectoryCopyCheckBox, - QtCore.SIGNAL(u'toggled(bool)'), + QtCore.QObject.connect(self.dataDirectoryCopyCheckBox, QtCore.SIGNAL(u'toggled(bool)'), self.onDataDirectoryCopyCheckBoxToggled) - QtCore.QObject.connect(self.endSlideRadioButton, - QtCore.SIGNAL(u'clicked()'), self.onEndSlideButtonClicked) - QtCore.QObject.connect(self.wrapSlideRadioButton, - QtCore.SIGNAL(u'clicked()'), self.onWrapSlideButtonClicked) - QtCore.QObject.connect(self.nextItemRadioButton, - QtCore.SIGNAL(u'clicked()'), self.onnextItemButtonClicked) + QtCore.QObject.connect(self.endSlideRadioButton, QtCore.SIGNAL(u'clicked()'), self.onEndSlideButtonClicked) + QtCore.QObject.connect(self.wrapSlideRadioButton, QtCore.SIGNAL(u'clicked()'), self.onWrapSlideButtonClicked) + QtCore.QObject.connect(self.nextItemRadioButton, QtCore.SIGNAL(u'clicked()'), self.onnextItemButtonClicked) def retranslateUi(self): """ @@ -333,11 +282,8 @@ class AdvancedTab(SettingsTab): """ self.tabTitleVisible = UiStrings().Advanced self.uiGroupBox.setTitle(translate('OpenLP.AdvancedTab', 'UI Settings')) - self.dataDirectoryGroupBox.setTitle( - translate('OpenLP.AdvancedTab', 'Data Location')) - self.recentLabel.setText( - translate('OpenLP.AdvancedTab', - 'Number of recent files to display:')) + self.dataDirectoryGroupBox.setTitle(translate('OpenLP.AdvancedTab', 'Data Location')) + self.recentLabel.setText(translate('OpenLP.AdvancedTab', 'Number of recent files to display:')) self.mediaPluginCheckBox.setText(translate('OpenLP.AdvancedTab', 'Remember active media manager tab on startup')) self.doubleClickLiveCheckBox.setText(translate('OpenLP.AdvancedTab', @@ -348,96 +294,54 @@ class AdvancedTab(SettingsTab): 'Expand new service items on creation')) self.enableAutoCloseCheckBox.setText(translate('OpenLP.AdvancedTab', 'Enable application exit confirmation')) - self.serviceNameGroupBox.setTitle( - translate('OpenLP.AdvancedTab', 'Default Service Name')) - self.serviceNameCheckBox.setText( - translate('OpenLP.AdvancedTab', 'Enable default service name')) - self.serviceNameTimeLabel.setText( - translate('OpenLP.AdvancedTab', 'Date and Time:')) - self.serviceNameDay.setItemText(0, - translate('OpenLP.AdvancedTab', 'Monday')) - self.serviceNameDay.setItemText(1, - translate('OpenLP.AdvancedTab', 'Tuesday')) - self.serviceNameDay.setItemText(2, - translate('OpenLP.AdvancedTab', 'Wednesday')) - self.serviceNameDay.setItemText(3, - translate('OpenLP.AdvancedTab', 'Thurdsday')) - self.serviceNameDay.setItemText(4, - translate('OpenLP.AdvancedTab', 'Friday')) - self.serviceNameDay.setItemText(5, - translate('OpenLP.AdvancedTab', 'Saturday')) - self.serviceNameDay.setItemText(6, - translate('OpenLP.AdvancedTab', 'Sunday')) - self.serviceNameDay.setItemText(7, - translate('OpenLP.AdvancedTab', 'Now')) + self.serviceNameGroupBox.setTitle(translate('OpenLP.AdvancedTab', 'Default Service Name')) + self.serviceNameCheckBox.setText(translate('OpenLP.AdvancedTab', 'Enable default service name')) + self.serviceNameTimeLabel.setText(translate('OpenLP.AdvancedTab', 'Date and Time:')) + self.serviceNameDay.setItemText(0, translate('OpenLP.AdvancedTab', 'Monday')) + self.serviceNameDay.setItemText(1, translate('OpenLP.AdvancedTab', 'Tuesday')) + self.serviceNameDay.setItemText(2, translate('OpenLP.AdvancedTab', 'Wednesday')) + self.serviceNameDay.setItemText(3, translate('OpenLP.AdvancedTab', 'Thurdsday')) + self.serviceNameDay.setItemText(4, translate('OpenLP.AdvancedTab', 'Friday')) + self.serviceNameDay.setItemText(5, translate('OpenLP.AdvancedTab', 'Saturday')) + self.serviceNameDay.setItemText(6, translate('OpenLP.AdvancedTab', 'Sunday')) + self.serviceNameDay.setItemText(7, translate('OpenLP.AdvancedTab', 'Now')) self.serviceNameTime.setToolTip(translate('OpenLP.AdvancedTab', 'Time when usual service starts.')) - self.serviceNameLabel.setText( - translate('OpenLP.AdvancedTab', 'Name:')) - self.serviceNameEdit.setToolTip(translate('OpenLP.AdvancedTab', - 'Consult the OpenLP manual for usage.')) + self.serviceNameLabel.setText(translate('OpenLP.AdvancedTab', 'Name:')) + self.serviceNameEdit.setToolTip(translate('OpenLP.AdvancedTab', 'Consult the OpenLP manual for usage.')) self.serviceNameRevertButton.setToolTip( - translate('OpenLP.AdvancedTab', - 'Revert to the default service name "%s".') % - self.defaultServiceName) - self.serviceNameExampleLabel.setText(translate('OpenLP.AdvancedTab', - 'Example:')) - self.hideMouseGroupBox.setTitle(translate('OpenLP.AdvancedTab', - 'Mouse Cursor')) - self.hideMouseCheckBox.setText(translate('OpenLP.AdvancedTab', - 'Hide mouse cursor when over display window')) - self.defaultImageGroupBox.setTitle(translate('OpenLP.AdvancedTab', - 'Default Image')) - self.defaultColorLabel.setText(translate('OpenLP.AdvancedTab', - 'Background color:')) - self.defaultColorButton.setToolTip(translate('OpenLP.AdvancedTab', - 'Click to select a color.')) - self.defaultFileLabel.setText(translate('OpenLP.AdvancedTab', - 'Image file:')) - self.defaultBrowseButton.setToolTip(translate('OpenLP.AdvancedTab', - 'Browse for an image file to display.')) - self.defaultRevertButton.setToolTip(translate('OpenLP.AdvancedTab', - 'Revert to the default OpenLP logo.')) - self.dataDirectoryCurrentLabel.setText(translate('OpenLP.AdvancedTab', - 'Current path:')) - self.dataDirectoryNewLabel.setText(translate('OpenLP.AdvancedTab', - 'Custom path:')) - self.dataDirectoryBrowseButton.setToolTip( - translate('OpenLP.AdvancedTab', - 'Browse for new data file location.')) + translate('OpenLP.AdvancedTab', 'Revert to the default service name "%s".') % self.defaultServiceName) + self.serviceNameExampleLabel.setText(translate('OpenLP.AdvancedTab', 'Example:')) + self.hideMouseGroupBox.setTitle(translate('OpenLP.AdvancedTab', 'Mouse Cursor')) + self.hideMouseCheckBox.setText(translate('OpenLP.AdvancedTab', 'Hide mouse cursor when over display window')) + self.defaultImageGroupBox.setTitle(translate('OpenLP.AdvancedTab', 'Default Image')) + self.defaultColorLabel.setText(translate('OpenLP.AdvancedTab', 'Background color:')) + self.defaultColorButton.setToolTip(translate('OpenLP.AdvancedTab', 'Click to select a color.')) + self.defaultFileLabel.setText(translate('OpenLP.AdvancedTab', 'Image file:')) + self.defaultBrowseButton.setToolTip(translate('OpenLP.AdvancedTab', 'Browse for an image file to display.')) + self.defaultRevertButton.setToolTip(translate('OpenLP.AdvancedTab', 'Revert to the default OpenLP logo.')) + self.dataDirectoryCurrentLabel.setText(translate('OpenLP.AdvancedTab', 'Current path:')) + self.dataDirectoryNewLabel.setText(translate('OpenLP.AdvancedTab', 'Custom path:')) + self.dataDirectoryBrowseButton.setToolTip(translate('OpenLP.AdvancedTab', 'Browse for new data file location.')) self.dataDirectoryDefaultButton.setToolTip( - translate('OpenLP.AdvancedTab', - 'Set the data location to the default.')) - self.dataDirectoryCancelButton.setText( - translate('OpenLP.AdvancedTab', - 'Cancel')) + translate('OpenLP.AdvancedTab', 'Set the data location to the default.')) + self.dataDirectoryCancelButton.setText(translate('OpenLP.AdvancedTab', 'Cancel')) self.dataDirectoryCancelButton.setToolTip( - translate('OpenLP.AdvancedTab', - 'Cancel OpenLP data directory location change.')) - self.dataDirectoryCopyCheckBox.setText( - translate('OpenLP.AdvancedTab', - 'Copy data to new location.')) - self.dataDirectoryCopyCheckBox.setToolTip( - translate('OpenLP.AdvancedTab', - 'Copy the OpenLP data files to the new location.')) + translate('OpenLP.AdvancedTab', 'Cancel OpenLP data directory location change.')) + self.dataDirectoryCopyCheckBox.setText(translate('OpenLP.AdvancedTab', 'Copy data to new location.')) + self.dataDirectoryCopyCheckBox.setToolTip(translate( + 'OpenLP.AdvancedTab', 'Copy the OpenLP data files to the new location.')) self.newDataDirectoryHasFilesLabel.setText( - translate('OpenLP.AdvancedTab', - 'WARNING: New data directory location contains ' - 'OpenLP data files. These files WILL be replaced during a copy.')) + translate('OpenLP.AdvancedTab', 'WARNING: New data directory location contains ' + 'OpenLP data files. These files WILL be replaced during a copy.')) self.x11GroupBox.setTitle(translate('OpenLP.AdvancedTab', 'X11')) - self.x11BypassCheckBox.setText(translate('OpenLP.AdvancedTab', - 'Bypass X11 Window Manager')) + self.x11BypassCheckBox.setText(translate('OpenLP.AdvancedTab','Bypass X11 Window Manager')) # Slide Limits - self.slideGroupBox.setTitle( - translate('OpenLP.GeneralTab', 'Service Item Slide Limits')) - self.slideLabel.setText(translate('OpenLP.GeneralTab', - 'Behavior of next/previous on the last/first slide:')) - self.endSlideRadioButton.setText( - translate('OpenLP.GeneralTab', '&Remain on Slide')) - self.wrapSlideRadioButton.setText( - translate('OpenLP.GeneralTab', '&Wrap around')) - self.nextItemRadioButton.setText(translate('OpenLP.GeneralTab', - '&Move to next/previous service item')) + self.slideGroupBox.setTitle(translate('OpenLP.GeneralTab', 'Service Item Slide Limits')) + self.slideLabel.setText(translate('OpenLP.GeneralTab', 'Behavior of next/previous on the last/first slide:')) + self.endSlideRadioButton.setText(translate('OpenLP.GeneralTab', '&Remain on Slide')) + self.wrapSlideRadioButton.setText(translate('OpenLP.GeneralTab', '&Wrap around')) + self.nextItemRadioButton.setText(translate('OpenLP.GeneralTab', '&Move to next/previous service item')) def load(self): """ @@ -450,28 +354,19 @@ class AdvancedTab(SettingsTab): # 20 will always be used. self.recentSpinBox.setMaximum(settings.value(u'max recent files', 20)) self.recentSpinBox.setValue(settings.value(u'recent file count', 4)) - self.mediaPluginCheckBox.setChecked( - settings.value(u'save current plugin', False)) - self.doubleClickLiveCheckBox.setChecked( - settings.value(u'double click live', False)) - self.singleClickPreviewCheckBox.setChecked( - settings.value(u'single click preview', False)) - self.expandServiceItemCheckBox.setChecked( - settings.value(u'expand service item', False)) - self.enableAutoCloseCheckBox.setChecked( - settings.value(u'enable exit confirmation', True)) + self.mediaPluginCheckBox.setChecked(settings.value(u'save current plugin', False)) + self.doubleClickLiveCheckBox.setChecked(settings.value(u'double click live', False)) + self.singleClickPreviewCheckBox.setChecked(settings.value(u'single click preview', False)) + self.expandServiceItemCheckBox.setChecked(settings.value(u'expand service item', False)) + self.enableAutoCloseCheckBox.setChecked(settings.value(u'enable exit confirmation', True)) self.hideMouseCheckBox.setChecked(settings.value(u'hide mouse', True)) - self.serviceNameDay.setCurrentIndex( - settings.value(u'default service day', self.defaultServiceDay)) - self.serviceNameTime.setTime(QtCore.QTime( - settings.value(u'default service hour', self.defaultServiceHour), - settings.value(u'default service minute', - self.defaultServiceMinute))) + self.serviceNameDay.setCurrentIndex(settings.value(u'default service day', self.defaultServiceDay)) + self.serviceNameTime.setTime(QtCore.QTime(settings.value(u'default service hour', self.defaultServiceHour), + settings.value(u'default service minute',self.defaultServiceMinute))) self.shouldUpdateServiceNameExample = True self.serviceNameEdit.setText(settings.value(u'default service name', self.defaultServiceName)) - default_service_enabled = settings.value( - u'default service enabled', True) + default_service_enabled = settings.value(u'default service enabled', True) self.serviceNameCheckBox.setChecked(default_service_enabled) self.serviceNameCheckBoxToggled(default_service_enabled) # Fix for bug #1014422. @@ -483,11 +378,9 @@ class AdvancedTab(SettingsTab): # Default to False on XFce if os.environ.get(u'DESKTOP_SESSION') == u'xfce': x11_bypass_default = False - self.x11BypassCheckBox.setChecked( - settings.value(u'x11 bypass wm', x11_bypass_default)) + self.x11BypassCheckBox.setChecked(settings.value(u'x11 bypass wm', x11_bypass_default)) self.defaultColor = settings.value(u'default color', u'#ffffff') - self.defaultFileEdit.setText(settings.value(u'default image', - u':/graphics/openlp-splash-screen.png')) + self.defaultFileEdit.setText(settings.value(u'default image', u':/graphics/openlp-splash-screen.png')) self.slide_limits = settings.value(u'slide limits', SlideLimits.End) if self.slide_limits == SlideLimits.End: self.endSlideRadioButton.setChecked(True) @@ -526,11 +419,9 @@ class AdvancedTab(SettingsTab): # Set data location to default. settings.remove(u'advanced/data path') self.currentDataPath = AppLocation.get_data_path() - log.warning(u'User requested data path set to default %s' - % self.currentDataPath) + log.warning(u'User requested data path set to default %s' % self.currentDataPath) self.dataDirectoryLabel.setText(os.path.abspath(self.currentDataPath)) - self.defaultColorButton.setStyleSheet( - u'background-color: %s' % self.defaultColor) + self.defaultColorButton.setStyleSheet(u'background-color: %s' % self.defaultColor) # Don't allow data directory move if running portable. if settings.value(u'advanced/is portable', False): self.dataDirectoryGroupBox.hide() @@ -550,23 +441,15 @@ class AdvancedTab(SettingsTab): self.serviceNameEdit.setText(service_name) else: settings.setValue(u'default service name', service_name) - settings.setValue(u'default service day', - self.serviceNameDay.currentIndex()) - settings.setValue(u'default service hour', - self.serviceNameTime.time().hour()) - settings.setValue(u'default service minute', - self.serviceNameTime.time().minute()) + settings.setValue(u'default service day', self.serviceNameDay.currentIndex()) + settings.setValue(u'default service hour', self.serviceNameTime.time().hour()) + settings.setValue(u'default service minute', self.serviceNameTime.time().minute()) settings.setValue(u'recent file count', self.recentSpinBox.value()) - settings.setValue(u'save current plugin', - self.mediaPluginCheckBox.isChecked()) - settings.setValue(u'double click live', - self.doubleClickLiveCheckBox.isChecked()) - settings.setValue(u'single click preview', - self.singleClickPreviewCheckBox.isChecked()) - settings.setValue(u'expand service item', - self.expandServiceItemCheckBox.isChecked()) - settings.setValue(u'enable exit confirmation', - self.enableAutoCloseCheckBox.isChecked()) + settings.setValue(u'save current plugin', self.mediaPluginCheckBox.isChecked()) + settings.setValue(u'double click live', self.doubleClickLiveCheckBox.isChecked()) + settings.setValue(u'single click preview', self.singleClickPreviewCheckBox.isChecked()) + settings.setValue(u'expand service item', self.expandServiceItemCheckBox.isChecked()) + settings.setValue(u'enable exit confirmation', self.enableAutoCloseCheckBox.isChecked()) settings.setValue(u'hide mouse', self.hideMouseCheckBox.isChecked()) settings.setValue(u'x11 bypass wm', self.x11BypassCheckBox.isChecked()) settings.setValue(u'default color', self.defaultColor) @@ -585,8 +468,7 @@ class AdvancedTab(SettingsTab): def serviceNameCheckBoxToggled(self, default_service_enabled): self.serviceNameDay.setEnabled(default_service_enabled) - time_enabled = default_service_enabled and \ - self.serviceNameDay.currentIndex() is not 7 + time_enabled = default_service_enabled and self.serviceNameDay.currentIndex() is not 7 self.serviceNameTime.setEnabled(time_enabled) self.serviceNameEdit.setEnabled(default_service_enabled) self.serviceNameRevertButton.setEnabled(default_service_enabled) @@ -604,12 +486,10 @@ class AdvancedTab(SettingsTab): local_time = time.replace(hour = self.serviceNameTime.time().hour(), minute = self.serviceNameTime.time().minute()) try: - service_name_example = format_time(unicode( - self.serviceNameEdit.text()), local_time) + service_name_example = format_time(unicode(self.serviceNameEdit.text()), local_time) except ValueError: preset_is_valid = False - service_name_example = translate('OpenLP.AdvancedTab', - 'Syntax error.') + service_name_example = translate('OpenLP.AdvancedTab', 'Syntax error.') return preset_is_valid, service_name_example def updateServiceNameExample(self, returned_value): @@ -631,8 +511,7 @@ class AdvancedTab(SettingsTab): QtGui.QColor(self.defaultColor), self) if new_color.isValid(): self.defaultColor = new_color.name() - self.defaultColorButton.setStyleSheet( - u'background-color: %s' % self.defaultColor) + self.defaultColorButton.setStyleSheet(u'background-color: %s' % self.defaultColor) def onDefaultBrowseButtonClicked(self): file_filters = u'%s;;%s (*.*) (*)' % (get_images_filter(), @@ -650,8 +529,7 @@ class AdvancedTab(SettingsTab): old_root_path = unicode(self.dataDirectoryLabel.text()) # Get the new directory location. new_data_path = unicode(QtGui.QFileDialog.getExistingDirectory(self, - translate('OpenLP.AdvancedTab', - 'Select Data Directory Location'), old_root_path, + translate('OpenLP.AdvancedTab', 'Select Data Directory Location'), old_root_path, options = QtGui.QFileDialog.ShowDirsOnly)) # Set the new data path. if new_data_path: @@ -664,15 +542,10 @@ class AdvancedTab(SettingsTab): # Make sure they want to change the data. answer = QtGui.QMessageBox.question(self, translate('OpenLP.AdvancedTab', 'Confirm Data Directory Change'), - translate('OpenLP.AdvancedTab', - 'Are you sure you want to change the location of the OpenLP ' - 'data directory to:\n\n%s\n\n' - 'The data directory will be changed when OpenLP is closed.' - ).replace('%s', new_data_path), - QtGui.QMessageBox.StandardButtons( - QtGui.QMessageBox.Yes | - QtGui.QMessageBox.No), - QtGui.QMessageBox.No) + translate('OpenLP.AdvancedTab', 'Are you sure you want to change the location of the OpenLP ' + 'data directory to:\n\n%s\n\n ' + 'The data directory will be changed when OpenLP is closed.').replace('%s', new_data_path), + QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes | QtGui.QMessageBox.No), QtGui.QMessageBox.No) if answer != QtGui.QMessageBox.Yes: return # Check if data already exists here. @@ -692,14 +565,9 @@ class AdvancedTab(SettingsTab): # default. answer = QtGui.QMessageBox.question(self, translate('OpenLP.AdvancedTab', 'Reset Data Directory'), - translate('OpenLP.AdvancedTab', - 'Are you sure you want to change the location of the OpenLP ' - 'data directory to the default location?\n\n' - 'This location will be used after OpenLP is closed.'), - QtGui.QMessageBox.StandardButtons( - QtGui.QMessageBox.Yes | - QtGui.QMessageBox.No), - QtGui.QMessageBox.No) + translate('OpenLP.AdvancedTab', 'Are you sure you want to change the location of the OpenLP ' + 'data directory to the default location?\n\nThis location will be used after OpenLP is closed.'), + QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes | QtGui.QMessageBox.No), QtGui.QMessageBox.No) if answer != QtGui.QMessageBox.Yes: return self.checkDataOverwrite(new_data_path) @@ -728,16 +596,10 @@ class AdvancedTab(SettingsTab): # Check is they want to replace existing data. answer = QtGui.QMessageBox.warning(self, translate('OpenLP.AdvancedTab', 'Overwrite Existing Data'), - translate('OpenLP.AdvancedTab', - 'WARNING: \n\n' - 'The location you have selected \n\n%s\n\n' - 'appears to contain OpenLP data files. Do you wish to replace ' - 'these files with the current data files?' + translate('OpenLP.AdvancedTab', 'WARNING: \n\n The location you have selected \n\n%s\n\n' + 'appears to contain OpenLP data files. Do you wish to replace these files with the current data files?' ).replace('%s', os.path.abspath(data_path,)), - QtGui.QMessageBox.StandardButtons( - QtGui.QMessageBox.Yes | - QtGui.QMessageBox.No), - QtGui.QMessageBox.No) + QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes | QtGui.QMessageBox.No), QtGui.QMessageBox.No) if answer == QtGui.QMessageBox.Yes: self.dataDirectoryCopyCheckBox.setChecked(True) self.newDataDirectoryHasFilesLabel.show() diff --git a/openlp/core/ui/exceptiondialog.py b/openlp/core/ui/exceptiondialog.py index 7a30eff64..4e89af583 100644 --- a/openlp/core/ui/exceptiondialog.py +++ b/openlp/core/ui/exceptiondialog.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 ############################################################################### # OpenLP - Open Source Lyrics Projection # @@ -42,8 +42,7 @@ class Ui_ExceptionDialog(object): self.messageLayout.addSpacing(12) self.bugLabel = QtGui.QLabel(exceptionDialog) self.bugLabel.setPixmap(QtGui.QPixmap(u':/graphics/exception.png')) - self.bugLabel.setSizePolicy(QtGui.QSizePolicy.Fixed, - QtGui.QSizePolicy.Fixed) + self.bugLabel.setSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) self.bugLabel.setObjectName(u'bugLabel') self.messageLayout.addWidget(self.bugLabel) self.messageLayout.addSpacing(12) @@ -65,18 +64,14 @@ class Ui_ExceptionDialog(object): self.exceptionTextEdit.setReadOnly(True) self.exceptionTextEdit.setObjectName(u'exceptionTextEdit') self.exceptionLayout.addWidget(self.exceptionTextEdit) - self.sendReportButton = create_button(exceptionDialog, - u'sendReportButton', icon=u':/general/general_email.png', - click=self.onSendReportButtonClicked) - self.saveReportButton = create_button(exceptionDialog, - u'saveReportButton', icon=u':/general/general_save.png', - click=self.onSaveReportButtonClicked) - self.attachFileButton = create_button(exceptionDialog, - u'attachFileButton', icon=u':/general/general_open.png', - click=self.onAttachFileButtonClicked) + self.sendReportButton = create_button(exceptionDialog, u'sendReportButton', + icon=u':/general/general_email.png', click=self.onSendReportButtonClicked) + self.saveReportButton = create_button(exceptionDialog,u'saveReportButton', + icon=u':/general/general_save.png', click=self.onSaveReportButtonClicked) + self.attachFileButton = create_button(exceptionDialog, u'attachFileButton', + icon=u':/general/general_open.png', click=self.onAttachFileButtonClicked) self.buttonBox = create_button_box(exceptionDialog, u'buttonBox', - [u'close'], [self.sendReportButton, self.saveReportButton, - self.attachFileButton]) + [u'close'], [self.sendReportButton, self.saveReportButton, self.attachFileButton]) self.exceptionLayout.addWidget(self.buttonBox) self.retranslateUi(exceptionDialog) @@ -84,8 +79,7 @@ class Ui_ExceptionDialog(object): QtCore.SIGNAL(u'textChanged()'), self.onDescriptionUpdated) def retranslateUi(self, exceptionDialog): - exceptionDialog.setWindowTitle( - translate('OpenLP.ExceptionDialog', 'Error Occurred')) + exceptionDialog.setWindowTitle(translate('OpenLP.ExceptionDialog', 'Error Occurred')) self.descriptionExplanation.setText(translate('OpenLP.ExceptionDialog', 'Please enter a description of what you were doing to cause this ' 'error \n(Minimum 20 characters)')) diff --git a/openlp/core/ui/exceptionform.py b/openlp/core/ui/exceptionform.py index 19956ad87..fca548485 100644 --- a/openlp/core/ui/exceptionform.py +++ b/openlp/core/ui/exceptionform.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 ############################################################################### # OpenLP - Open Source Lyrics Projection # @@ -72,10 +72,8 @@ try: arg.Name = u'nodepath' arg.Value = u'/org.openoffice.Setup/Product' context = uno.getComponentContext() - provider = context.ServiceManager.createInstance( - u'com.sun.star.configuration.ConfigurationProvider') - node = provider.createInstanceWithArguments( - u'com.sun.star.configuration.ConfigurationAccess', (arg,)) + provider = context.ServiceManager.createInstance(u'com.sun.star.configuration.ConfigurationProvider') + node = provider.createInstanceWithArguments(u'com.sun.star.configuration.ConfigurationAccess', (arg,)) UNO_VERSION = node.getByName(u'ooSetupVersion') except ImportError: UNO_VERSION = u'-' @@ -114,8 +112,7 @@ class ExceptionForm(QtGui.QDialog, Ui_ExceptionDialog): openlp_version = get_application_version() description = self.descriptionTextEdit.toPlainText() traceback = self.exceptionTextEdit.toPlainText() - system = translate('OpenLP.ExceptionForm', - 'Platform: %s\n') % platform.platform() + system = translate('OpenLP.ExceptionForm', 'Platform: %s\n') % platform.platform() libraries = u'Python: %s\n' % platform.python_version() + \ u'Qt4: %s\n' % Qt.qVersion() + \ u'Phonon: %s\n' % PHONON_VERSION + \ @@ -139,7 +136,7 @@ class ExceptionForm(QtGui.QDialog, Ui_ExceptionDialog): def onSaveReportButtonClicked(self): """ - Saving exception log and system informations to a file. + Saving exception log and system information to a file. """ report_text = translate('OpenLP.ExceptionForm', '**OpenLP Bug Report**\n' @@ -155,8 +152,7 @@ class ExceptionForm(QtGui.QDialog, Ui_ExceptionDialog): 'Text files (*.txt *.log *.text)')) if filename: filename = unicode(filename).replace(u'/', os.path.sep) - SettingsManager.set_last_dir(self.settingsSection, os.path.dirname( - filename)) + SettingsManager.set_last_dir(self.settingsSection, os.path.dirname(filename)) report_text = report_text % self._createReport() try: report_file = open(filename, u'w') @@ -211,14 +207,12 @@ class ExceptionForm(QtGui.QDialog, Ui_ExceptionDialog): else: self.__buttonState(False) self.descriptionWordCount.setText( - translate('OpenLP.ExceptionDialog', - 'Description characters to enter : %s') % count) + translate('OpenLP.ExceptionDialog', 'Description characters to enter : %s') % count) def onAttachFileButtonClicked(self): files = QtGui.QFileDialog.getOpenFileName( self, translate('ImagePlugin.ExceptionDialog', 'Select Attachment'), - SettingsManager.get_last_dir(u'exceptions'), - u'%s (*.*) (*)' % UiStrings().AllFiles) + SettingsManager.get_last_dir(u'exceptions'), u'%s (*.*) (*)' % UiStrings().AllFiles) log.info(u'New files(s) %s', unicode(files)) if files: self.fileAttachment = unicode(files) diff --git a/openlp/core/utils/__init__.py b/openlp/core/utils/__init__.py index be9d30e0c..dd0b496b7 100644 --- a/openlp/core/utils/__init__.py +++ b/openlp/core/utils/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 ############################################################################### # OpenLP - Open Source Lyrics Projection # @@ -105,21 +105,15 @@ class AppLocation(object): The directory type you want, for instance the data directory. """ if dir_type == AppLocation.AppDir: - return _get_frozen_path( - os.path.abspath(os.path.split(sys.argv[0])[0]), - os.path.split(openlp.__file__)[0]) + return _get_frozen_path(os.path.abspath(os.path.split(sys.argv[0])[0]), os.path.split(openlp.__file__)[0]) elif dir_type == AppLocation.PluginsDir: app_path = os.path.abspath(os.path.split(sys.argv[0])[0]) return _get_frozen_path(os.path.join(app_path, u'plugins'), os.path.join(os.path.split(openlp.__file__)[0], u'plugins')) elif dir_type == AppLocation.VersionDir: - return _get_frozen_path( - os.path.abspath(os.path.split(sys.argv[0])[0]), - os.path.split(openlp.__file__)[0]) + return _get_frozen_path(os.path.abspath(os.path.split(sys.argv[0])[0]), os.path.split(openlp.__file__)[0]) elif dir_type == AppLocation.LanguageDir: - app_path = _get_frozen_path( - os.path.abspath(os.path.split(sys.argv[0])[0]), - _get_os_dir_path(dir_type)) + app_path = _get_frozen_path(os.path.abspath(os.path.split(sys.argv[0])[0]), _get_os_dir_path(dir_type)) return os.path.join(app_path, u'i18n') elif dir_type == AppLocation.DataDir and AppLocation.BaseDir: return os.path.join(AppLocation.BaseDir, 'data') @@ -157,8 +151,7 @@ def _get_os_dir_path(dir_type): encoding = sys.getfilesystemencoding() if sys.platform == u'win32': if dir_type == AppLocation.DataDir: - return os.path.join(unicode(os.getenv(u'APPDATA'), encoding), - u'openlp', u'data') + return os.path.join(unicode(os.getenv(u'APPDATA'), encoding), u'openlp', u'data') elif dir_type == AppLocation.LanguageDir: return os.path.split(openlp.__file__)[0] return os.path.join(unicode(os.getenv(u'APPDATA'), encoding), @@ -181,17 +174,13 @@ def _get_os_dir_path(dir_type): return os.path.join(u'/usr', u'share', u'openlp') if XDG_BASE_AVAILABLE: if dir_type == AppLocation.ConfigDir: - return os.path.join(unicode(BaseDirectory.xdg_config_home, - encoding), u'openlp') + return os.path.join(unicode(BaseDirectory.xdg_config_home, encoding), u'openlp') elif dir_type == AppLocation.DataDir: - return os.path.join( - unicode(BaseDirectory.xdg_data_home, encoding), u'openlp') + return os.path.join(unicode(BaseDirectory.xdg_data_home, encoding), u'openlp') elif dir_type == AppLocation.CacheDir: - return os.path.join(unicode(BaseDirectory.xdg_cache_home, - encoding), u'openlp') + return os.path.join(unicode(BaseDirectory.xdg_cache_home, encoding), u'openlp') if dir_type == AppLocation.DataDir: - return os.path.join(unicode(os.getenv(u'HOME'), encoding), - u'.openlp', u'data') + return os.path.join(unicode(os.getenv(u'HOME'), encoding), u'.openlp', u'data') return os.path.join(unicode(os.getenv(u'HOME'), encoding), u'.openlp') @@ -231,8 +220,7 @@ def get_application_version(): if revision_id in tags: full_version = u'%s' % tags[revision_id][0] else: - full_version = '%s-bzr%s' % \ - (sorted(b.tags.get_tag_dict().keys())[-1], revno) + full_version = '%s-bzr%s' % (sorted(b.tags.get_tag_dict().keys())[-1], revno) finally: b.unlock() except: @@ -254,8 +242,7 @@ def get_application_version(): if code != 0: raise Exception(u'Error running bzr log') latest = output.split(u':')[0] - full_version = latest == revision and tag or \ - u'%s-bzr%s' % (tag, latest) + full_version = latest == revision and tag or u'%s-bzr%s' % (tag, latest) else: # We're not running the development version, let's use the file. filepath = AppLocation.get_directory(AppLocation.VersionDir) @@ -277,8 +264,7 @@ def get_application_version(): u'build': bits[1] if len(bits) > 1 else None } if APPLICATION_VERSION[u'build']: - log.info(u'Openlp version %s build %s', - APPLICATION_VERSION[u'version'], APPLICATION_VERSION[u'build']) + log.info(u'Openlp version %s build %s', APPLICATION_VERSION[u'version'], APPLICATION_VERSION[u'build']) else: log.info(u'Openlp version %s' % APPLICATION_VERSION[u'version']) return APPLICATION_VERSION @@ -302,8 +288,7 @@ def check_latest_version(current_version): settings.endGroup() if last_test != this_test: if current_version[u'build']: - req = urllib2.Request( - u'http://www.openlp.org/files/dev_version.txt') + req = urllib2.Request(u'http://www.openlp.org/files/dev_version.txt') else: req = urllib2.Request(u'http://www.openlp.org/files/version.txt') req.add_header(u'User-Agent', u'OpenLP/%s' % current_version[u'full']) @@ -358,8 +343,7 @@ def get_images_filter(): for fmt in QtGui.QImageReader.supportedImageFormats()] visible_formats = u'(*.%s)' % u'; *.'.join(formats) actual_formats = u'(*.%s)' % u' *.'.join(formats) - IMAGES_FILTER = u'%s %s %s' % (translate('OpenLP', 'Image Files'), - visible_formats, actual_formats) + IMAGES_FILTER = u'%s %s %s' % (translate('OpenLP', 'Image Files'), visible_formats, actual_formats) return IMAGES_FILTER @@ -463,11 +447,9 @@ def get_uno_instance(resolver): """ log.debug(u'get UNO Desktop Openoffice - resolve') if UNO_CONNECTION_TYPE == u'pipe': - return resolver.resolve(u'uno:pipe,name=openlp_pipe;' \ - + u'urp;StarOffice.ComponentContext') + return resolver.resolve(u'uno:pipe,name=openlp_pipe; urp;StarOffice.ComponentContext') else: - return resolver.resolve(u'uno:socket,host=localhost,port=2002;' \ - + u'urp;StarOffice.ComponentContext') + return resolver.resolve(u'uno:socket,host=localhost,port=2002; urp;StarOffice.ComponentContext') def format_time(text, local_time): diff --git a/openlp/core/utils/actions.py b/openlp/core/utils/actions.py index 01ba34a26..27f58b19e 100644 --- a/openlp/core/utils/actions.py +++ b/openlp/core/utils/actions.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 ############################################################################### # OpenLP - Open Source Lyrics Projection # @@ -287,8 +287,7 @@ class ActionList(object): # Remove empty categories. if not self.categories[category].actions: self.categories.remove(category) - shortcuts = map(unicode, - map(QtGui.QKeySequence.toString, action.shortcuts())) + shortcuts = map(unicode, map(QtGui.QKeySequence.toString, action.shortcuts())) for shortcut in shortcuts: # Remove action from the list of actions which are using this # shortcut. @@ -339,8 +338,7 @@ class ActionList(object): # Remove empty entries. if not ActionList.shortcut_map[old_shortcut]: del ActionList.shortcut_map[old_shortcut] - new_shortcuts = map(unicode, - map(QtGui.QKeySequence.toString, action.shortcuts())) + new_shortcuts = map(unicode, map(QtGui.QKeySequence.toString, action.shortcuts())) # Add the new shortcuts to the map. for new_shortcut in new_shortcuts: existing_actions = ActionList.shortcut_map.get(new_shortcut, []) @@ -358,8 +356,7 @@ class ActionList(object): ``action`` The action which wants to use a particular shortcut. """ - local = action.shortcutContext() in \ - [QtCore.Qt.WindowShortcut, QtCore.Qt.ApplicationShortcut] + local = action.shortcutContext() in [QtCore.Qt.WindowShortcut, QtCore.Qt.ApplicationShortcut] affected_actions = filter(lambda a: isinstance(a, QtGui.QAction), self.getAllChildObjects(action.parent())) if local else [] for existing_action in existing_actions: @@ -367,8 +364,7 @@ class ActionList(object): continue if not local or existing_action in affected_actions: return False - if existing_action.shortcutContext() \ - in [QtCore.Qt.WindowShortcut, QtCore.Qt.ApplicationShortcut]: + if existing_action.shortcutContext() in [QtCore.Qt.WindowShortcut, QtCore.Qt.ApplicationShortcut]: return False elif action in self.getAllChildObjects(existing_action.parent()): return False diff --git a/openlp/core/utils/languagemanager.py b/openlp/core/utils/languagemanager.py index 25aaa7adf..3e7f56ffb 100644 --- a/openlp/core/utils/languagemanager.py +++ b/openlp/core/utils/languagemanager.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 ############################################################################### # OpenLP - Open Source Lyrics Projection # @@ -63,8 +63,7 @@ class LanguageManager(object): app_translator.load(language, lang_path) # A translator for buttons and other default strings provided by Qt. if sys.platform != u'win32' and sys.platform != u'darwin': - lang_path = QtCore.QLibraryInfo.location( - QtCore.QLibraryInfo.TranslationsPath) + lang_path = QtCore.QLibraryInfo.location(QtCore.QLibraryInfo.TranslationsPath) default_translator = QtCore.QTranslator() default_translator.load(u'qt_%s' % language, lang_path) return app_translator, default_translator @@ -76,13 +75,10 @@ class LanguageManager(object): """ log.debug(u'Translation files: %s', AppLocation.get_directory( AppLocation.LanguageDir)) - trans_dir = QtCore.QDir(AppLocation.get_directory( - AppLocation.LanguageDir)) - file_names = trans_dir.entryList( - u'*.qm', QtCore.QDir.Files, QtCore.QDir.Name) + trans_dir = QtCore.QDir(AppLocation.get_directory(AppLocation.LanguageDir)) + file_names = trans_dir.entryList(u'*.qm', QtCore.QDir.Files, QtCore.QDir.Name) # Remove qm files from the list which start with "qt_". - file_names = filter( - lambda file_: not file_.startswith(u'qt_'), file_names) + file_names = filter(lambda file_: not file_.startswith(u'qt_'), file_names) return map(trans_dir.filePath, file_names) @staticmethod @@ -95,8 +91,7 @@ class LanguageManager(object): """ translator = QtCore.QTranslator() translator.load(qm_file) - return translator.translate('OpenLP.MainWindow', 'English', - 'Please add the name of your language here') + return translator.translate('OpenLP.MainWindow', 'English', 'Please add the name of your language here') @staticmethod def get_language(): @@ -138,8 +133,7 @@ class LanguageManager(object): if message: QtGui.QMessageBox.information(None, translate('OpenLP.LanguageManager', 'Language'), - translate('OpenLP.LanguageManager', - 'Please restart OpenLP to use your new language setting.')) + translate('OpenLP.LanguageManager', 'Please restart OpenLP to use your new language setting.')) @staticmethod def init_qm_list(): @@ -152,8 +146,7 @@ class LanguageManager(object): reg_ex = QtCore.QRegExp("^.*i18n/(.*).qm") if reg_ex.exactMatch(qmf): name = u'%s' % reg_ex.cap(1) - LanguageManager.__qm_list__[u'%#2i %s' % (counter + 1, - LanguageManager.language_name(qmf))] = name + LanguageManager.__qm_list__[u'%#2i %s' % (counter + 1, LanguageManager.language_name(qmf))] = name @staticmethod def get_qm_list(): From 4b6292220a4dd14ce6f6eb793be22cc7209fe540 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sat, 29 Dec 2012 13:15:42 +0000 Subject: [PATCH 50/53] Main window done --- openlp/core/ui/filerenamedialog.py | 11 +- openlp/core/ui/filerenameform.py | 8 +- openlp/core/ui/firsttimeform.py | 90 ++-- openlp/core/ui/firsttimelanguagedialog.py | 19 +- openlp/core/ui/firsttimelanguageform.py | 2 +- openlp/core/ui/firsttimewizard.py | 84 +-- openlp/core/ui/generaltab.py | 150 ++---- openlp/core/ui/maindisplay.py | 79 +-- openlp/core/ui/mainwindow.py | 603 ++++++++-------------- 9 files changed, 365 insertions(+), 681 deletions(-) diff --git a/openlp/core/ui/filerenamedialog.py b/openlp/core/ui/filerenamedialog.py index ad7ebb767..55ad3950f 100644 --- a/openlp/core/ui/filerenamedialog.py +++ b/openlp/core/ui/filerenamedialog.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 ############################################################################### # OpenLP - Open Source Lyrics Projection # @@ -42,16 +42,13 @@ class Ui_FileRenameDialog(object): self.fileNameLabel.setObjectName(u'fileNameLabel') self.dialogLayout.addWidget(self.fileNameLabel, 0, 0) self.fileNameEdit = QtGui.QLineEdit(fileRenameDialog) - self.fileNameEdit.setValidator(QtGui.QRegExpValidator( - QtCore.QRegExp(r'[^/\\?*|<>\[\]":+%]+'), self)) + self.fileNameEdit.setValidator(QtGui.QRegExpValidator(QtCore.QRegExp(r'[^/\\?*|<>\[\]":+%]+'), self)) self.fileNameEdit.setObjectName(u'fileNameEdit') self.dialogLayout.addWidget(self.fileNameEdit, 0, 1) - self.buttonBox = create_button_box(fileRenameDialog, u'buttonBox', - [u'cancel', u'ok']) + self.buttonBox = create_button_box(fileRenameDialog, u'buttonBox', [u'cancel', u'ok']) self.dialogLayout.addWidget(self.buttonBox, 1, 0, 1, 2) self.retranslateUi(fileRenameDialog) self.setMaximumHeight(self.sizeHint().height()) def retranslateUi(self, fileRenameDialog): - self.fileNameLabel.setText(translate('OpenLP.FileRenameForm', - 'New File Name:')) + self.fileNameLabel.setText(translate('OpenLP.FileRenameForm', 'New File Name:')) diff --git a/openlp/core/ui/filerenameform.py b/openlp/core/ui/filerenameform.py index fc8242003..6c0531597 100644 --- a/openlp/core/ui/filerenameform.py +++ b/openlp/core/ui/filerenameform.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 ############################################################################### # OpenLP - Open Source Lyrics Projection # @@ -46,9 +46,7 @@ class FileRenameForm(QtGui.QDialog, Ui_FileRenameDialog): Run the Dialog with correct heading. """ if copy: - self.setWindowTitle(translate('OpenLP.FileRenameForm', - 'File Copy')) + self.setWindowTitle(translate('OpenLP.FileRenameForm', 'File Copy')) else: - self.setWindowTitle(translate('OpenLP.FileRenameForm', - 'File Rename')) + self.setWindowTitle(translate('OpenLP.FileRenameForm', 'File Rename')) return QtGui.QDialog.exec_(self) diff --git a/openlp/core/ui/firsttimeform.py b/openlp/core/ui/firsttimeform.py index 353598909..04320f6c1 100644 --- a/openlp/core/ui/firsttimeform.py +++ b/openlp/core/ui/firsttimeform.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 ############################################################################### # OpenLP - Open Source Lyrics Projection # @@ -39,8 +39,7 @@ from ConfigParser import SafeConfigParser from PyQt4 import QtCore, QtGui -from openlp.core.lib import translate, PluginStatus, Receiver, build_icon, \ - check_directory_exists, Settings +from openlp.core.lib import translate, PluginStatus, Receiver, build_icon, check_directory_exists, Settings from openlp.core.utils import get_web_page, AppLocation, get_filesystem_encoding from firsttimewizard import Ui_FirstTimeWizard, FirstTimePage @@ -65,8 +64,7 @@ class ThemeScreenshotThread(QtCore.QThread): 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), - os.path.join(unicode(gettempdir(), get_filesystem_encoding()), - u'openlp', screenshot)) + os.path.join(unicode(gettempdir(), get_filesystem_encoding()), u'openlp', screenshot)) item = QtGui.QListWidgetItem(title, self.parent().themesListWidget) item.setData(QtCore.Qt.UserRole, filename) item.setCheckState(QtCore.Qt.Unchecked) @@ -97,12 +95,11 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): 'Downloading %s...') QtCore.QObject.connect(self.cancelButton, QtCore.SIGNAL('clicked()'), self.onCancelButtonClicked) - QtCore.QObject.connect(self.noInternetFinishButton, - QtCore.SIGNAL('clicked()'), self.onNoInternetFinishButtonClicked) - QtCore.QObject.connect(self, - QtCore.SIGNAL(u'currentIdChanged(int)'), self.onCurrentIdChanged) - QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'config_screen_changed'), self.updateScreenListCombo) + QtCore.QObject.connect(self.noInternetFinishButton, QtCore.SIGNAL('clicked()'), + self.onNoInternetFinishButtonClicked) + QtCore.QObject.connect(self, QtCore.SIGNAL(u'currentIdChanged(int)'), self.onCurrentIdChanged) + QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'config_screen_changed'), + self.updateScreenListCombo) def exec_(self): """ @@ -126,10 +123,8 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): songs = self.config.get(u'songs', u'languages') songs = songs.split(u',') for song in songs: - 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') + 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') item = QtGui.QListWidgetItem(title, self.songsListWidget) item.setData(QtCore.Qt.UserRole, filename) item.setCheckState(QtCore.Qt.Unchecked) @@ -137,17 +132,13 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): bible_languages = self.config.get(u'bibles', u'languages') bible_languages = bible_languages.split(u',') for lang in bible_languages: - language = unicode(self.config.get( - u'bibles_%s' % lang, u'title'), u'utf8') - langItem = QtGui.QTreeWidgetItem( - self.biblesTreeWidget, [language]) + language = unicode(self.config.get(u'bibles_%s' % lang, u'title'), u'utf8') + langItem = QtGui.QTreeWidgetItem(self.biblesTreeWidget, [language]) bibles = self.config.get(u'bibles_%s' % lang, u'translations') bibles = bibles.split(u',') for bible in bibles: - title = unicode(self.config.get( - u'bible_%s' % bible, u'title'), u'utf8') - filename = unicode(self.config.get( - u'bible_%s' % bible, u'filename')) + title = unicode(self.config.get(u'bible_%s' % bible, u'title'), u'utf8') + filename = unicode(self.config.get(u'bible_%s' % bible, u'filename')) item = QtGui.QTreeWidgetItem(langItem, [title]) item.setData(0, QtCore.Qt.UserRole, filename) item.setCheckState(0, QtCore.Qt.Unchecked) @@ -199,8 +190,7 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): if self.hasRunWizard: self.noInternetLabel.setText(self.noInternetText) else: - self.noInternetLabel.setText(self.noInternetText + - self.cancelWizardText) + self.noInternetLabel.setText(self.noInternetText + self.cancelWizardText) elif pageId == FirstTimePage.Defaults: self.themeComboBox.clear() for iter in xrange(self.themesListWidget.count()): @@ -249,7 +239,7 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): Process the triggering of the cancel button. """ if self.lastId == FirstTimePage.NoInternet or \ - (self.lastId <= FirstTimePage.Plugins and not self.hasRunWizard): + (self.lastId <= FirstTimePage.Plugins and not self.hasRunWizard): QtCore.QCoreApplication.exit() sys.exit() self.downloadCancelled = True @@ -304,8 +294,8 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): item = self.themesListWidget.item(index) if item.data(QtCore.Qt.UserRole) == filename: break - item.setIcon(build_icon(os.path.join(unicode(gettempdir(), - get_filesystem_encoding()), u'openlp', screenshot))) + item.setIcon(build_icon(os.path.join(unicode(gettempdir(), get_filesystem_encoding()), u'openlp', + screenshot))) def _getFileSize(self, url): site = urllib.urlopen(url) @@ -372,15 +362,12 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): self.progressBar.setValue(0) self.progressBar.setMinimum(0) self.progressBar.setMaximum(self.max_progress) - 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.')) + 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.')) else: self.progressBar.setVisible(False) - self.progressPage.setTitle(translate('OpenLP.FirstTimeWizard', - 'Setting Up')) + self.progressPage.setTitle(translate('OpenLP.FirstTimeWizard', 'Setting Up')) self.progressPage.setSubTitle(u'Setup complete.') self.repaint() Receiver.send_message(u'openlp_process_events') @@ -395,12 +382,10 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): self.progressBar.setValue(self.progressBar.maximum()) if self.hasRunWizard: self.progressLabel.setText(translate('OpenLP.FirstTimeWizard', - 'Download complete.' - ' Click the finish button to return to OpenLP.')) + 'Download complete. Click the finish button to return to OpenLP.')) else: self.progressLabel.setText(translate('OpenLP.FirstTimeWizard', - 'Download complete.' - ' Click the finish button to start OpenLP.')) + 'Download complete. Click the finish button to start OpenLP.')) else: if self.hasRunWizard: self.progressLabel.setText(translate('OpenLP.FirstTimeWizard', @@ -419,15 +404,13 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): Run the tasks in the wizard. """ # Set plugin states - self._incrementProgressBar(translate('OpenLP.FirstTimeWizard', - 'Enabling selected plugins...')) + self._incrementProgressBar(translate('OpenLP.FirstTimeWizard', 'Enabling selected plugins...')) self._setPluginStatus(self.songsCheckBox, u'songs/status') self._setPluginStatus(self.bibleCheckBox, u'bibles/status') # TODO Presentation plugin is not yet working on Mac OS X. # For now just ignore it. if sys.platform != 'darwin': - self._setPluginStatus(self.presentationCheckBox, - u'presentations/status') + self._setPluginStatus(self.presentationCheckBox, u'presentations/status') self._setPluginStatus(self.imageCheckBox, u'images/status') self._setPluginStatus(self.mediaCheckBox, u'media/status') self._setPluginStatus(self.remoteCheckBox, u'remotes/status') @@ -447,8 +430,7 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): filename = item.data(QtCore.Qt.UserRole) self._incrementProgressBar(self.downloading % filename, 0) self.previous_size = 0 - destination = os.path.join(songs_destination, - unicode(filename)) + destination = os.path.join(songs_destination, unicode(filename)) self.urlGetFile(u'%s%s' % (self.web, filename), destination) # Download Bibles bibles_iterator = QtGui.QTreeWidgetItemIterator( @@ -459,8 +441,7 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): bible = item.data(0, QtCore.Qt.UserRole) self._incrementProgressBar(self.downloading % bible, 0) self.previous_size = 0 - self.urlGetFile(u'%s%s' % (self.web, bible), - os.path.join(bibles_destination, bible)) + 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()): @@ -469,20 +450,15 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): theme = item.data(QtCore.Qt.UserRole) self._incrementProgressBar(self.downloading % theme, 0) self.previous_size = 0 - self.urlGetFile(u'%s%s' % (self.web, theme), - os.path.join(themes_destination, theme)) + self.urlGetFile(u'%s%s' % (self.web, theme), os.path.join(themes_destination, theme)) # Set Default Display if self.displayComboBox.currentIndex() != -1: - Settings().setValue(u'General/monitor', - self.displayComboBox.currentIndex()) - self.screens.set_current_display( - self.displayComboBox.currentIndex()) + Settings().setValue(u'General/monitor', self.displayComboBox.currentIndex()) + self.screens.set_current_display(self.displayComboBox.currentIndex()) # Set Global Theme if self.themeComboBox.currentIndex() != -1: - Settings().setValue(u'themes/global theme', - self.themeComboBox.currentText()) + Settings().setValue(u'themes/global theme', self.themeComboBox.currentText()) def _setPluginStatus(self, field, tag): - status = PluginStatus.Active if field.checkState() \ - == QtCore.Qt.Checked else PluginStatus.Inactive + status = PluginStatus.Active if field.checkState() == QtCore.Qt.Checked else PluginStatus.Inactive Settings().setValue(tag, status) diff --git a/openlp/core/ui/firsttimelanguagedialog.py b/openlp/core/ui/firsttimelanguagedialog.py index 208f1f068..24f179cba 100644 --- a/openlp/core/ui/firsttimelanguagedialog.py +++ b/openlp/core/ui/firsttimelanguagedialog.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 ############################################################################### # OpenLP - Open Source Lyrics Projection # @@ -49,22 +49,17 @@ class Ui_FirstTimeLanguageDialog(object): self.languageLabel.setObjectName(u'languageLabel') self.languageLayout.addWidget(self.languageLabel) self.languageComboBox = QtGui.QComboBox(languageDialog) - self.languageComboBox.setSizeAdjustPolicy( - QtGui.QComboBox.AdjustToContents) + self.languageComboBox.setSizeAdjustPolicy(QtGui.QComboBox.AdjustToContents) self.languageComboBox.setObjectName("languageComboBox") self.languageLayout.addWidget(self.languageComboBox) self.dialogLayout.addLayout(self.languageLayout) - self.buttonBox = create_button_box(languageDialog, u'buttonBox', - [u'cancel', u'ok']) + self.buttonBox = create_button_box(languageDialog, u'buttonBox', [u'cancel', u'ok']) self.dialogLayout.addWidget(self.buttonBox) - self.retranslateUi(languageDialog) self.setMaximumHeight(self.sizeHint().height()) def retranslateUi(self, languageDialog): - self.setWindowTitle(translate('OpenLP.FirstTimeLanguageForm', - 'Select Translation')) - self.infoLabel.setText(translate('OpenLP.FirstTimeLanguageForm', - 'Choose the translation you\'d like to use in OpenLP.')) - self.languageLabel.setText(translate('OpenLP.FirstTimeLanguageForm', - 'Translation:')) + self.setWindowTitle(translate('OpenLP.FirstTimeLanguageForm', 'Select Translation')) + self.infoLabel.setText( + translate('OpenLP.FirstTimeLanguageForm', 'Choose the translation you\'d like to use in OpenLP.')) + self.languageLabel.setText(translate('OpenLP.FirstTimeLanguageForm', 'Translation:')) diff --git a/openlp/core/ui/firsttimelanguageform.py b/openlp/core/ui/firsttimelanguageform.py index 0d72406b0..c120600fc 100644 --- a/openlp/core/ui/firsttimelanguageform.py +++ b/openlp/core/ui/firsttimelanguageform.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 ############################################################################### # OpenLP - Open Source Lyrics Projection # diff --git a/openlp/core/ui/firsttimewizard.py b/openlp/core/ui/firsttimewizard.py index 54a01fd43..fc706030c 100644 --- a/openlp/core/ui/firsttimewizard.py +++ b/openlp/core/ui/firsttimewizard.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 ############################################################################### # OpenLP - Open Source Lyrics Projection # @@ -51,10 +51,8 @@ class Ui_FirstTimeWizard(object): FirstTimeWizard.resize(550, 386) FirstTimeWizard.setModal(True) FirstTimeWizard.setWizardStyle(QtGui.QWizard.ModernStyle) - FirstTimeWizard.setOptions(QtGui.QWizard.IndependentPages | - QtGui.QWizard.NoBackButtonOnStartPage | - QtGui.QWizard.NoBackButtonOnLastPage | - QtGui.QWizard.HaveCustomButton1) + FirstTimeWizard.setOptions(QtGui.QWizard.IndependentPages | QtGui.QWizard.NoBackButtonOnStartPage | + QtGui.QWizard.NoBackButtonOnLastPage |QtGui.QWizard.HaveCustomButton1) self.finishButton = self.button(QtGui.QWizard.FinishButton) self.noInternetFinishButton = self.button(QtGui.QWizard.CustomButton1) self.cancelButton = self.button(QtGui.QWizard.CancelButton) @@ -175,8 +173,7 @@ class Ui_FirstTimeWizard(object): self.themeComboBox = QtGui.QComboBox(self.defaultsPage) self.themeComboBox.setEditable(False) self.themeComboBox.setInsertPolicy(QtGui.QComboBox.NoInsert) - self.themeComboBox.setSizeAdjustPolicy( - QtGui.QComboBox.AdjustToContents) + self.themeComboBox.setSizeAdjustPolicy(QtGui.QComboBox.AdjustToContents) self.themeComboBox.setObjectName(u'themeComboBox') self.defaultsLayout.addRow(self.themeLabel, self.themeComboBox) FirstTimeWizard.setPage(FirstTimePage.Defaults, self.defaultsPage) @@ -198,41 +195,27 @@ class Ui_FirstTimeWizard(object): def retranslateUi(self, FirstTimeWizard): FirstTimeWizard.setWindowTitle(translate( 'OpenLP.FirstTimeWizard', 'First Time Wizard')) - self.titleLabel.setText( - u'%s' % \ - translate('OpenLP.FirstTimeWizard', - 'Welcome to the First Time Wizard')) + self.titleLabel.setText(u'%s' % \ + translate('OpenLP.FirstTimeWizard', 'Welcome to the First Time Wizard')) self.informationLabel.setText(translate('OpenLP.FirstTimeWizard', 'This wizard will help you to configure OpenLP for initial use.' ' Click the next button below to start.')) - self.pluginPage.setTitle(translate('OpenLP.FirstTimeWizard', - 'Activate required Plugins')) - self.pluginPage.setSubTitle(translate('OpenLP.FirstTimeWizard', - 'Select the Plugins you wish to use. ')) + self.pluginPage.setTitle(translate('OpenLP.FirstTimeWizard', 'Activate required Plugins')) + self.pluginPage.setSubTitle(translate('OpenLP.FirstTimeWizard','Select the Plugins you wish to use. ')) self.songsCheckBox.setText(translate('OpenLP.FirstTimeWizard', 'Songs')) - self.customCheckBox.setText(translate('OpenLP.FirstTimeWizard', - 'Custom Slides')) + self.customCheckBox.setText(translate('OpenLP.FirstTimeWizard','Custom Slides')) self.bibleCheckBox.setText(translate('OpenLP.FirstTimeWizard', 'Bible')) - self.imageCheckBox.setText(translate('OpenLP.FirstTimeWizard', - 'Images')) + self.imageCheckBox.setText(translate('OpenLP.FirstTimeWizard', 'Images')) # TODO Presentation plugin is not yet working on Mac OS X. # For now just ignore it. if sys.platform != 'darwin': - self.presentationCheckBox.setText(translate('OpenLP.FirstTimeWizard', - 'Presentations')) - self.mediaCheckBox.setText(translate('OpenLP.FirstTimeWizard', - 'Media (Audio and Video)')) - self.remoteCheckBox.setText(translate('OpenLP.FirstTimeWizard', - 'Allow remote access')) - self.songUsageCheckBox.setText(translate('OpenLP.FirstTimeWizard', - 'Monitor Song Usage')) - self.alertCheckBox.setText(translate('OpenLP.FirstTimeWizard', - 'Allow Alerts')) - self.noInternetPage.setTitle(translate('OpenLP.FirstTimeWizard', - 'No Internet Connection')) - self.noInternetPage.setSubTitle(translate( - 'OpenLP.FirstTimeWizard', - 'Unable to detect an Internet connection.')) + self.presentationCheckBox.setText(translate('OpenLP.FirstTimeWizard', 'Presentations')) + self.mediaCheckBox.setText(translate('OpenLP.FirstTimeWizard', 'Media (Audio and Video)')) + self.remoteCheckBox.setText(translate('OpenLP.FirstTimeWizard', 'Allow remote access')) + self.songUsageCheckBox.setText(translate('OpenLP.FirstTimeWizard', 'Monitor Song Usage')) + self.alertCheckBox.setText(translate('OpenLP.FirstTimeWizard', 'Allow Alerts')) + self.noInternetPage.setTitle(translate('OpenLP.FirstTimeWizard', 'No Internet Connection')) + self.noInternetPage.setSubTitle(translate('OpenLP.FirstTimeWizard', 'Unable to detect an Internet connection.')) self.noInternetText = translate('OpenLP.FirstTimeWizard', 'No Internet connection was found. The First Time Wizard needs an ' 'Internet connection in order to be able to download sample ' @@ -244,27 +227,16 @@ class Ui_FirstTimeWizard(object): self.cancelWizardText = translate('OpenLP.FirstTimeWizard', '\n\nTo cancel the First Time Wizard completely (and not start ' 'OpenLP), click the Cancel button now.') - self.songsPage.setTitle(translate('OpenLP.FirstTimeWizard', - 'Sample Songs')) - self.songsPage.setSubTitle(translate('OpenLP.FirstTimeWizard', - 'Select and download public domain songs.')) - self.biblesPage.setTitle(translate('OpenLP.FirstTimeWizard', - 'Sample Bibles')) - self.biblesPage.setSubTitle(translate('OpenLP.FirstTimeWizard', - 'Select and download free Bibles.')) - self.themesPage.setTitle(translate('OpenLP.FirstTimeWizard', - 'Sample Themes')) - self.themesPage.setSubTitle(translate('OpenLP.FirstTimeWizard', - 'Select and download sample themes.')) - self.defaultsPage.setTitle(translate('OpenLP.FirstTimeWizard', - 'Default Settings')) + self.songsPage.setTitle(translate('OpenLP.FirstTimeWizard', 'Sample Songs')) + self.songsPage.setSubTitle(translate('OpenLP.FirstTimeWizard', 'Select and download public domain songs.')) + self.biblesPage.setTitle(translate('OpenLP.FirstTimeWizard', 'Sample Bibles')) + self.biblesPage.setSubTitle(translate('OpenLP.FirstTimeWizard', 'Select and download free Bibles.')) + self.themesPage.setTitle(translate('OpenLP.FirstTimeWizard', 'Sample Themes')) + self.themesPage.setSubTitle(translate('OpenLP.FirstTimeWizard', 'Select and download sample themes.')) + self.defaultsPage.setTitle(translate('OpenLP.FirstTimeWizard', 'Default Settings')) self.defaultsPage.setSubTitle(translate('OpenLP.FirstTimeWizard', 'Set up default settings to be used by OpenLP.')) - self.displayLabel.setText(translate('OpenLP.FirstTimeWizard', - 'Default output display:')) - self.themeLabel.setText(translate('OpenLP.FirstTimeWizard', - 'Select default theme:')) - self.progressLabel.setText(translate('OpenLP.FirstTimeWizard', - 'Starting configuration process...')) - FirstTimeWizard.setButtonText(QtGui.QWizard.CustomButton1, - translate('OpenLP.FirstTimeWizard', 'Finish')) + self.displayLabel.setText(translate('OpenLP.FirstTimeWizard', 'Default output display:')) + self.themeLabel.setText(translate('OpenLP.FirstTimeWizard', 'Select default theme:')) + self.progressLabel.setText(translate('OpenLP.FirstTimeWizard', 'Starting configuration process...')) + FirstTimeWizard.setButtonText(QtGui.QWizard.CustomButton1, translate('OpenLP.FirstTimeWizard', 'Finish')) diff --git a/openlp/core/ui/generaltab.py b/openlp/core/ui/generaltab.py index ff4da8176..d4016cd7a 100644 --- a/openlp/core/ui/generaltab.py +++ b/openlp/core/ui/generaltab.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 ############################################################################### # OpenLP - Open Source Lyrics Projection # @@ -189,21 +189,15 @@ class GeneralTab(SettingsTab): self.rightLayout.addWidget(self.settingsGroupBox) self.rightLayout.addStretch() # Signals and slots - QtCore.QObject.connect(self.overrideRadioButton, - QtCore.SIGNAL(u'toggled(bool)'), self.onOverrideRadioButtonPressed) - QtCore.QObject.connect(self.customHeightValueEdit, - QtCore.SIGNAL(u'valueChanged(int)'), self.onDisplayChanged) - QtCore.QObject.connect(self.customWidthValueEdit, - QtCore.SIGNAL(u'valueChanged(int)'), self.onDisplayChanged) - QtCore.QObject.connect(self.customYValueEdit, - QtCore.SIGNAL(u'valueChanged(int)'), self.onDisplayChanged) - QtCore.QObject.connect(self.customXValueEdit, - QtCore.SIGNAL(u'valueChanged(int)'), self.onDisplayChanged) - QtCore.QObject.connect(self.monitorComboBox, - QtCore.SIGNAL(u'currentIndexChanged(int)'), self.onDisplayChanged) + QtCore.QObject.connect(self.overrideRadioButton, QtCore.SIGNAL(u'toggled(bool)'), + self.onOverrideRadioButtonPressed) + QtCore.QObject.connect(self.customHeightValueEdit, QtCore.SIGNAL(u'valueChanged(int)'), self.onDisplayChanged) + QtCore.QObject.connect(self.customWidthValueEdit, QtCore.SIGNAL(u'valueChanged(int)'), self.onDisplayChanged) + QtCore.QObject.connect(self.customYValueEdit, QtCore.SIGNAL(u'valueChanged(int)'), self.onDisplayChanged) + QtCore.QObject.connect(self.customXValueEdit, QtCore.SIGNAL(u'valueChanged(int)'), self.onDisplayChanged) + QtCore.QObject.connect(self.monitorComboBox, QtCore.SIGNAL(u'currentIndexChanged(int)'), self.onDisplayChanged) # Reload the tab, as the screen resolution/count may have changed. - QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'config_screen_changed'), self.load) + QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'config_screen_changed'), self.load) # Remove for now self.usernameLabel.setVisible(False) self.usernameEdit.setVisible(False) @@ -215,40 +209,25 @@ class GeneralTab(SettingsTab): Translate the general settings tab to the currently selected language """ self.tabTitleVisible = translate('OpenLP.GeneralTab', 'General') - self.monitorGroupBox.setTitle(translate('OpenLP.GeneralTab', - 'Monitors')) - self.monitorRadioButton.setText(translate('OpenLP.GeneralTab', - 'Select monitor for output display:')) - self.displayOnMonitorCheck.setText( - translate('OpenLP.GeneralTab', 'Display if a single screen')) - self.startupGroupBox.setTitle( - translate('OpenLP.GeneralTab', 'Application Startup')) - self.warningCheckBox.setText( - translate('OpenLP.GeneralTab', 'Show blank screen warning')) - self.autoOpenCheckBox.setText(translate('OpenLP.GeneralTab', - 'Automatically open the last service')) - self.showSplashCheckBox.setText( - translate('OpenLP.GeneralTab', 'Show the splash screen')) - self.checkForUpdatesCheckBox.setText( - translate('OpenLP.GeneralTab', 'Check for updates to OpenLP')) - self.settingsGroupBox.setTitle( - translate('OpenLP.GeneralTab', 'Application Settings')) + self.monitorGroupBox.setTitle(translate('OpenLP.GeneralTab', 'Monitors')) + self.monitorRadioButton.setText(translate('OpenLP.GeneralTab', 'Select monitor for output display:')) + self.displayOnMonitorCheck.setText(translate('OpenLP.GeneralTab', 'Display if a single screen')) + self.startupGroupBox.setTitle(translate('OpenLP.GeneralTab', 'Application Startup')) + self.warningCheckBox.setText(translate('OpenLP.GeneralTab', 'Show blank screen warning')) + self.autoOpenCheckBox.setText(translate('OpenLP.GeneralTab', 'Automatically open the last service')) + self.showSplashCheckBox.setText(translate('OpenLP.GeneralTab', 'Show the splash screen')) + self.checkForUpdatesCheckBox.setText(translate('OpenLP.GeneralTab', 'Check for updates to OpenLP')) + self.settingsGroupBox.setTitle(translate('OpenLP.GeneralTab', 'Application Settings')) self.saveCheckServiceCheckBox.setText(translate('OpenLP.GeneralTab', 'Prompt to save before starting a new service')) - self.autoUnblankCheckBox.setText(translate('OpenLP.GeneralTab', - 'Unblank display when adding new live item')) - self.autoPreviewCheckBox.setText(translate('OpenLP.GeneralTab', - 'Automatically preview next item in service')) - self.timeoutLabel.setText(translate('OpenLP.GeneralTab', - 'Timed slide interval:')) + self.autoUnblankCheckBox.setText(translate('OpenLP.GeneralTab', 'Unblank display when adding new live item')) + self.autoPreviewCheckBox.setText(translate('OpenLP.GeneralTab', 'Automatically preview next item in service')) + self.timeoutLabel.setText(translate('OpenLP.GeneralTab', 'Timed slide interval:')) self.timeoutSpinBox.setSuffix(translate('OpenLP.GeneralTab', ' sec')) - self.ccliGroupBox.setTitle( - translate('OpenLP.GeneralTab', 'CCLI Details')) + self.ccliGroupBox.setTitle(translate('OpenLP.GeneralTab', 'CCLI Details')) self.numberLabel.setText(UiStrings().CCLINumberLabel) - self.usernameLabel.setText( - translate('OpenLP.GeneralTab', 'SongSelect username:')) - self.passwordLabel.setText( - translate('OpenLP.GeneralTab', 'SongSelect password:')) + self.usernameLabel.setText(translate('OpenLP.GeneralTab', 'SongSelect username:')) + self.passwordLabel.setText(translate('OpenLP.GeneralTab', 'SongSelect password:')) # Moved from display tab self.overrideRadioButton.setText(translate('OpenLP.GeneralTab', 'Override display position:')) @@ -256,12 +235,9 @@ class GeneralTab(SettingsTab): self.customYLabel.setText(translate('OpenLP.GeneralTab', 'Y')) self.customHeightLabel.setText(translate('OpenLP.GeneralTab', 'Height')) self.customWidthLabel.setText(translate('OpenLP.GeneralTab', 'Width')) - self.audioGroupBox.setTitle( - translate('OpenLP.GeneralTab', 'Background Audio')) - self.startPausedCheckBox.setText( - translate('OpenLP.GeneralTab', 'Start background audio paused')) - self.repeatListCheckBox.setText( - translate('OpenLP.GeneralTab', 'Repeat track list')) + self.audioGroupBox.setTitle(translate('OpenLP.GeneralTab', 'Background Audio')) + self.startPausedCheckBox.setText(translate('OpenLP.GeneralTab', 'Start background audio paused')) + self.repeatListCheckBox.setText(translate('OpenLP.GeneralTab', 'Repeat track list')) def load(self): """ @@ -271,49 +247,34 @@ class GeneralTab(SettingsTab): settings.beginGroup(self.settingsSection) self.monitorComboBox.clear() self.monitorComboBox.addItems(self.screens.get_screen_list()) - monitorNumber = settings.value( - u'monitor', self.screens.display_count - 1) + monitorNumber = settings.value(u'monitor', self.screens.display_count - 1) self.monitorComboBox.setCurrentIndex(monitorNumber) self.numberEdit.setText(settings.value(u'ccli number', u'')) self.usernameEdit.setText(settings.value(u'songselect username', u'')) self.passwordEdit.setText(settings.value(u'songselect password', u'')) - self.saveCheckServiceCheckBox.setChecked(settings.value(u'save prompt', - False)) - self.autoUnblankCheckBox.setChecked(settings.value(u'auto unblank', - False)) + self.saveCheckServiceCheckBox.setChecked(settings.value(u'save prompt', False)) + self.autoUnblankCheckBox.setChecked(settings.value(u'auto unblank', False)) self.displayOnMonitorCheck.setChecked(self.screens.display) self.warningCheckBox.setChecked(settings.value(u'blank warning', False)) self.autoOpenCheckBox.setChecked(settings.value(u'auto open', False)) self.showSplashCheckBox.setChecked(settings.value(u'show splash', True)) - self.checkForUpdatesCheckBox.setChecked(settings.value(u'update check', - True)) - self.autoPreviewCheckBox.setChecked(settings.value(u'auto preview', - False)) + self.checkForUpdatesCheckBox.setChecked(settings.value(u'update check', True)) + self.autoPreviewCheckBox.setChecked(settings.value(u'auto preview', False)) self.timeoutSpinBox.setValue(settings.value(u'loop delay', 5)) - self.monitorRadioButton.setChecked( - not settings.value(u'override position', False)) - self.overrideRadioButton.setChecked(settings.value(u'override position', - False)) - self.customXValueEdit.setValue(settings.value(u'x position', - self.screens.current[u'size'].x())) - self.customYValueEdit.setValue(settings.value(u'y position', - self.screens.current[u'size'].y())) - self.customHeightValueEdit.setValue(settings.value(u'height', - self.screens.current[u'size'].height())) - self.customWidthValueEdit.setValue(settings.value(u'width', - self.screens.current[u'size'].width())) - self.startPausedCheckBox.setChecked(settings.value( - u'audio start paused', True)) - self.repeatListCheckBox.setChecked(settings.value( - u'audio repeat list', False)) + self.monitorRadioButton.setChecked(not settings.value(u'override position', False)) + self.overrideRadioButton.setChecked(settings.value(u'override position', False)) + self.customXValueEdit.setValue(settings.value(u'x position', self.screens.current[u'size'].x())) + self.customYValueEdit.setValue(settings.value(u'y position', self.screens.current[u'size'].y())) + self.customHeightValueEdit.setValue(settings.value(u'height', self.screens.current[u'size'].height())) + self.customWidthValueEdit.setValue(settings.value(u'width', self.screens.current[u'size'].width())) + self.startPausedCheckBox.setChecked(settings.value(u'audio start paused', True)) + self.repeatListCheckBox.setChecked(settings.value(u'audio repeat list', False)) settings.endGroup() self.monitorComboBox.setDisabled(self.overrideRadioButton.isChecked()) self.customXValueEdit.setEnabled(self.overrideRadioButton.isChecked()) self.customYValueEdit.setEnabled(self.overrideRadioButton.isChecked()) - self.customHeightValueEdit.setEnabled( - self.overrideRadioButton.isChecked()) - self.customWidthValueEdit.setEnabled( - self.overrideRadioButton.isChecked()) + self.customHeightValueEdit.setEnabled(self.overrideRadioButton.isChecked()) + self.customWidthValueEdit.setEnabled(self.overrideRadioButton.isChecked()) self.display_changed = False settings.beginGroup(self.settingsSection) @@ -324,33 +285,25 @@ class GeneralTab(SettingsTab): settings = Settings() settings.beginGroup(self.settingsSection) settings.setValue(u'monitor', self.monitorComboBox.currentIndex()) - settings.setValue(u'display on monitor', - self.displayOnMonitorCheck.isChecked()) + settings.setValue(u'display on monitor', self.displayOnMonitorCheck.isChecked()) settings.setValue(u'blank warning', self.warningCheckBox.isChecked()) settings.setValue(u'auto open', self.autoOpenCheckBox.isChecked()) settings.setValue(u'show splash', self.showSplashCheckBox.isChecked()) - settings.setValue(u'update check', - self.checkForUpdatesCheckBox.isChecked()) - settings.setValue(u'save prompt', - self.saveCheckServiceCheckBox.isChecked()) + settings.setValue(u'update check', self.checkForUpdatesCheckBox.isChecked()) + settings.setValue(u'save prompt', self.saveCheckServiceCheckBox.isChecked()) settings.setValue(u'auto unblank', self.autoUnblankCheckBox.isChecked()) settings.setValue(u'auto preview', self.autoPreviewCheckBox.isChecked()) settings.setValue(u'loop delay', self.timeoutSpinBox.value()) settings.setValue(u'ccli number', self.numberEdit.displayText()) - settings.setValue(u'songselect username', - self.usernameEdit.displayText()) - settings.setValue(u'songselect password', - self.passwordEdit.displayText()) + settings.setValue(u'songselect username', self.usernameEdit.displayText()) + settings.setValue(u'songselect password', self.passwordEdit.displayText()) settings.setValue(u'x position', self.customXValueEdit.value()) settings.setValue(u'y position', self.customYValueEdit.value()) settings.setValue(u'height', self.customHeightValueEdit.value()) settings.setValue(u'width', self.customWidthValueEdit.value()) - settings.setValue(u'override position', - self.overrideRadioButton.isChecked()) - settings.setValue(u'audio start paused', - self.startPausedCheckBox.isChecked()) - settings.setValue(u'audio repeat list', - self.repeatListCheckBox.isChecked()) + settings.setValue(u'override position', self.overrideRadioButton.isChecked()) + settings.setValue(u'audio start paused', self.startPausedCheckBox.isChecked()) + settings.setValue(u'audio repeat list', self.repeatListCheckBox.isChecked()) settings.endGroup() # On save update the screens as well self.postSetUp(True) @@ -360,8 +313,7 @@ class GeneralTab(SettingsTab): Apply settings after settings tab has loaded and most of the system so must be delayed """ - Receiver.send_message(u'slidecontroller_live_spin_delay', - self.timeoutSpinBox.value()) + Receiver.send_message(u'slidecontroller_live_spin_delay', self.timeoutSpinBox.value()) # Do not continue on start up. if not postUpdate: return diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index 2f5b98edc..cff70b4b6 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 ############################################################################### # OpenLP - Open Source Lyrics Projection # @@ -38,8 +38,8 @@ import sys from PyQt4 import QtCore, QtGui, QtWebKit, QtOpenGL from PyQt4.phonon import Phonon -from openlp.core.lib import Receiver, build_html, ServiceItem, image_to_byte, \ - translate, PluginManager, expand_tags, Settings, ImageSource +from openlp.core.lib import Receiver, build_html, ServiceItem, image_to_byte, translate, PluginManager, expand_tags,\ + Settings, ImageSource from openlp.core.lib.theme import BackgroundType from openlp.core.ui import HideMode, ScreenList, AlertLocation @@ -81,10 +81,8 @@ class Display(QtGui.QGraphicsView): self.setGeometry(self.screen[u'size']) log.debug(u'Setup webView') self.webView = QtWebKit.QWebView(self) - self.webView.setGeometry(0, 0, - self.screen[u'size'].width(), self.screen[u'size'].height()) - self.webView.settings().setAttribute( - QtWebKit.QWebSettings.PluginsEnabled, True) + self.webView.setGeometry(0, 0, self.screen[u'size'].width(), self.screen[u'size'].height()) + self.webView.settings().setAttribute(QtWebKit.QWebSettings.PluginsEnabled, True) palette = self.webView.palette() palette.setBrush(QtGui.QPalette.Base, QtCore.Qt.transparent) self.webView.page().setPalette(palette) @@ -92,8 +90,7 @@ class Display(QtGui.QGraphicsView): self.page = self.webView.page() self.frame = self.page.mainFrame() if self.isLive and log.getEffectiveLevel() == logging.DEBUG: - self.webView.settings().setAttribute( - QtWebKit.QWebSettings.DeveloperExtrasEnabled, True) + self.webView.settings().setAttribute(QtWebKit.QWebSettings.DeveloperExtrasEnabled, True) QtCore.QObject.connect(self.webView, QtCore.SIGNAL(u'loadFinished(bool)'), self.isWebLoaded) self.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) @@ -161,14 +158,10 @@ class MainDisplay(Display): self.setAttribute(QtCore.Qt.WA_DeleteOnClose) self.setTransparency(False) if self.isLive: - QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'live_display_hide'), self.hideDisplay) - QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'live_display_show'), self.showDisplay) - QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'update_display_css'), self.cssChanged) - QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'config_updated'), self.configChanged) + QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'live_display_hide'), self.hideDisplay) + QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'live_display_show'), self.showDisplay) + QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'update_display_css'), self.cssChanged) + QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'config_updated'), self.configChanged) def setTransparency(self, enabled): if enabled: @@ -211,12 +204,10 @@ class MainDisplay(Display): if self.isLive: # Build the initial frame. background_color = QtGui.QColor() - background_color.setNamedColor(Settings().value( - u'advanced/default color', u'#ffffff')) + background_color.setNamedColor(Settings().value(u'advanced/default color', u'#ffffff')) if not background_color.isValid(): background_color = QtCore.Qt.white - image_file = Settings().value(u'advanced/default image', - u':/graphics/openlp-splash-screen.png') + image_file = Settings().value(u'advanced/default image', u':/graphics/openlp-splash-screen.png') splash_image = QtGui.QImage(image_file) self.initialFrame = QtGui.QImage( self.screen[u'size'].width(), @@ -252,8 +243,7 @@ class MainDisplay(Display): Receiver.send_message(u'openlp_process_events') self.setGeometry(self.screen[u'size']) if animate: - self.frame.evaluateJavaScript(u'show_text("%s")' % - slide.replace(u'\\', u'\\\\').replace(u'\"', u'\\\"')) + self.frame.evaluateJavaScript(u'show_text("%s")' % slide.replace(u'\\', u'\\\\').replace(u'\"', u'\\\"')) else: # This exists for https://bugs.launchpad.net/openlp/+bug/1016843 # For unknown reasons if evaluateJavaScript is called @@ -274,10 +264,8 @@ class MainDisplay(Display): log.debug(u'alert to display') # First we convert <>& marks to html variants, then apply # formattingtags, finally we double all backslashes for JavaScript. - text_prepared = expand_tags( - cgi.escape(text)).replace(u'\\', u'\\\\').replace(u'\"', u'\\\"') - if self.height() != self.screen[u'size'].height() or not \ - self.isVisible(): + text_prepared = expand_tags(cgi.escape(text)).replace(u'\\', u'\\\\').replace(u'\"', u'\\\"') + if self.height() != self.screen[u'size'].height() or not self.isVisible(): shrink = True js = u'show_alert("%s", "%s")' % (text_prepared, u'top') else: @@ -290,11 +278,9 @@ class MainDisplay(Display): self.resize(self.width(), alert_height) self.setVisible(True) if location == AlertLocation.Middle: - self.move(self.screen[u'size'].left(), - (self.screen[u'size'].height() - alert_height) / 2) + self.move(self.screen[u'size'].left(), (self.screen[u'size'].height() - alert_height) / 2) elif location == AlertLocation.Bottom: - self.move(self.screen[u'size'].left(), - self.screen[u'size'].height() - alert_height) + self.move(self.screen[u'size'].left(), self.screen[u'size'].height() - alert_height) else: self.setVisible(False) self.setGeometry(self.screen[u'size']) @@ -363,10 +349,8 @@ class MainDisplay(Display): if self.isLive and hasattr(self, u'serviceItem'): # Wait for the fade to finish before geting the preview. # Important otherwise preview will have incorrect text if at all! - if self.serviceItem.themedata and \ - self.serviceItem.themedata.display_slide_transition: - while self.frame.evaluateJavaScript(u'show_text_complete()') \ - == u'false': + if self.serviceItem.themedata and self.serviceItem.themedata.display_slide_transition: + while self.frame.evaluateJavaScript(u'show_text_complete()') == u'false': Receiver.send_message(u'openlp_process_events') # Wait for the webview to update before getting the preview. # Important otherwise first preview will miss the background ! @@ -403,27 +387,22 @@ class MainDisplay(Display): Receiver.send_message(u'video_background_replaced') self.override = {} # We have a different theme. - elif self.override[u'theme'] != \ - serviceItem.themedata.background_filename: + elif self.override[u'theme'] != serviceItem.themedata.background_filename: Receiver.send_message(u'live_theme_changed') self.override = {} else: # replace the background - background = self.imageManager.getImageBytes( - self.override[u'image'], ImageSource.ImagePlugin) + background = self.imageManager.getImageBytes(self.override[u'image'], ImageSource.ImagePlugin) self.setTransparency(self.serviceItem.themedata.background_type == BackgroundType.to_string(BackgroundType.Transparent)) if self.serviceItem.themedata.background_filename: self.serviceItem.bg_image_bytes = self.imageManager.getImageBytes( - self.serviceItem.themedata.background_filename, - ImageSource.Theme) + self.serviceItem.themedata.background_filename,ImageSource.Theme) if image_path: - image_bytes = self.imageManager.getImageBytes( - image_path, ImageSource.ImagePlugin) + image_bytes = self.imageManager.getImageBytes(image_path, ImageSource.ImagePlugin) else: image_bytes = None - html = build_html(self.serviceItem, self.screen, self.isLive, - background, image_bytes, self.plugins) + html = build_html(self.serviceItem, self.screen, self.isLive, background, image_bytes, self.plugins) log.debug(u'buildHtml - pre setHtml') self.webView.setHtml(html) log.debug(u'buildHtml - post setHtml') @@ -442,8 +421,7 @@ class MainDisplay(Display): Display the Footer """ log.debug(u'footer') - js = u'show_footer(\'' + \ - text.replace(u'\\', u'\\\\').replace(u'\'', u'\\\'') + u'\')' + js = u'show_footer(\'' + text.replace(u'\\', u'\\\\').replace(u'\'', u'\\\'') + u'\')' self.frame.evaluateJavaScript(js) def hideDisplay(self, mode=HideMode.Screen): @@ -523,10 +501,8 @@ class AudioPlayer(QtCore.QObject): self.mediaObject.setTickInterval(100) self.audioObject = Phonon.AudioOutput(Phonon.VideoCategory) Phonon.createPath(self.mediaObject, self.audioObject) - QtCore.QObject.connect(self.mediaObject, - QtCore.SIGNAL(u'aboutToFinish()'), self.onAboutToFinish) - QtCore.QObject.connect(self.mediaObject, - QtCore.SIGNAL(u'finished()'), self.onFinished) + QtCore.QObject.connect(self.mediaObject, QtCore.SIGNAL(u'aboutToFinish()'), self.onAboutToFinish) + QtCore.QObject.connect(self.mediaObject, QtCore.SIGNAL(u'finished()'), self.onFinished) def __del__(self): """ @@ -621,5 +597,6 @@ class AudioPlayer(QtCore.QObject): if isPlaying: self.mediaObject.play() + #@todo is this used? def connectSlot(self, signal, slot): QtCore.QObject.connect(self.mediaObject, signal, slot) diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 811173ae2..dd7677ae1 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 ############################################################################### # OpenLP - Open Source Lyrics Projection # @@ -39,16 +39,15 @@ from datetime import datetime from PyQt4 import QtCore, QtGui -from openlp.core.lib import Renderer, build_icon, OpenLPDockWidget, \ - PluginManager, Receiver, translate, ImageManager, PluginStatus +from openlp.core.lib import Renderer, build_icon, OpenLPDockWidget, PluginManager, Receiver, translate, ImageManager, \ + PluginStatus from openlp.core.lib.ui import UiStrings, create_action from openlp.core.lib import SlideLimits, Settings -from openlp.core.ui import AboutForm, SettingsForm, ServiceManager, \ - ThemeManager, SlideController, PluginForm, MediaDockManager, \ - ShortcutListForm, FormattingTagForm +from openlp.core.ui import AboutForm, SettingsForm, ServiceManager, ThemeManager, SlideController, PluginForm, \ + MediaDockManager, ShortcutListForm, FormattingTagForm from openlp.core.ui.media import MediaController -from openlp.core.utils import AppLocation, add_actions, LanguageManager, \ - get_application_version, get_filesystem_encoding +from openlp.core.utils import AppLocation, add_actions, LanguageManager, get_application_version, \ + get_filesystem_encoding from openlp.core.utils.actions import ActionList, CategoryOrder from openlp.core.ui.firsttimeform import FirstTimeForm from openlp.core.ui import ScreenList @@ -150,36 +149,28 @@ class Ui_MainWindow(object): self.defaultThemeLabel.setObjectName(u'defaultThemeLabel') self.statusBar.addPermanentWidget(self.defaultThemeLabel) # Create the MediaManager - self.mediaManagerDock = OpenLPDockWidget(mainWindow, - u'mediaManagerDock', u':/system/system_mediamanager.png') + self.mediaManagerDock = OpenLPDockWidget(mainWindow,u'mediaManagerDock', u':/system/system_mediamanager.png') self.mediaManagerDock.setStyleSheet(MEDIA_MANAGER_STYLE) # Create the media toolbox self.mediaToolBox = QtGui.QToolBox(self.mediaManagerDock) self.mediaToolBox.setObjectName(u'mediaToolBox') self.mediaManagerDock.setWidget(self.mediaToolBox) - mainWindow.addDockWidget(QtCore.Qt.LeftDockWidgetArea, - self.mediaManagerDock) + mainWindow.addDockWidget(QtCore.Qt.LeftDockWidgetArea, self.mediaManagerDock) # Create the service manager - self.serviceManagerDock = OpenLPDockWidget(mainWindow, - u'serviceManagerDock', u':/system/system_servicemanager.png') - self.serviceManagerContents = ServiceManager(mainWindow, - self.serviceManagerDock) + self.serviceManagerDock = OpenLPDockWidget(mainWindow, u'serviceManagerDock', + u':/system/system_servicemanager.png') + self.serviceManagerContents = ServiceManager(mainWindow, self.serviceManagerDock) self.serviceManagerDock.setWidget(self.serviceManagerContents) - mainWindow.addDockWidget(QtCore.Qt.RightDockWidgetArea, - self.serviceManagerDock) + mainWindow.addDockWidget(QtCore.Qt.RightDockWidgetArea, self.serviceManagerDock) # Create the theme manager - self.themeManagerDock = OpenLPDockWidget(mainWindow, - u'themeManagerDock', u':/system/system_thememanager.png') - self.themeManagerContents = ThemeManager(mainWindow, - self.themeManagerDock) + self.themeManagerDock = OpenLPDockWidget(mainWindow, u'themeManagerDock', u':/system/system_thememanager.png') + self.themeManagerContents = ThemeManager(mainWindow, self.themeManagerDock) self.themeManagerContents.setObjectName(u'themeManagerContents') self.themeManagerDock.setWidget(self.themeManagerContents) - mainWindow.addDockWidget(QtCore.Qt.RightDockWidgetArea, - self.themeManagerDock) + mainWindow.addDockWidget(QtCore.Qt.RightDockWidgetArea, self.themeManagerDock) # Create the menu items action_list = ActionList.get_instance() - action_list.add_category(UiStrings().File, - CategoryOrder.standardMenu) + action_list.add_category(UiStrings().File, CategoryOrder.standardMenu) self.fileNewItem = create_action(mainWindow, u'fileNewItem', icon=u':/general/general_new.png', shortcuts=[QtGui.QKeySequence(u'Ctrl+N')], @@ -209,20 +200,13 @@ class Ui_MainWindow(object): category=UiStrings().File, triggers=mainWindow.close) # Give QT Extra Hint that this is the Exit Menu Item self.fileExitItem.setMenuRole(QtGui.QAction.QuitRole) - action_list.add_category(UiStrings().Import, - CategoryOrder.standardMenu) - self.importThemeItem = create_action(mainWindow, - u'importThemeItem', category=UiStrings().Import) - self.importLanguageItem = create_action(mainWindow, - u'importLanguageItem')#, category=UiStrings().Import) - action_list.add_category(UiStrings().Export, - CategoryOrder.standardMenu) - self.exportThemeItem = create_action(mainWindow, - u'exportThemeItem', category=UiStrings().Export) - self.exportLanguageItem = create_action(mainWindow, - u'exportLanguageItem')#, category=UiStrings().Export) - action_list.add_category(UiStrings().View, - CategoryOrder.standardMenu) + action_list.add_category(UiStrings().Import, CategoryOrder.standardMenu) + self.importThemeItem = create_action(mainWindow, u'importThemeItem', category=UiStrings().Import) + self.importLanguageItem = create_action(mainWindow, u'importLanguageItem') + action_list.add_category(UiStrings().Export, CategoryOrder.standardMenu) + self.exportThemeItem = create_action(mainWindow, u'exportThemeItem', category=UiStrings().Export) + self.exportLanguageItem = create_action(mainWindow, u'exportLanguageItem') + action_list.add_category(UiStrings().View, CategoryOrder.standardMenu) self.viewMediaManagerItem = create_action(mainWindow, u'viewMediaManagerItem', shortcuts=[QtGui.QKeySequence(u'F8')], icon=u':/system/system_mediamanager.png', @@ -248,12 +232,10 @@ class Ui_MainWindow(object): checked=panelLocked, triggers=self.setLockPanel) action_list.add_category(UiStrings().ViewMode, CategoryOrder.standardMenu) - self.modeDefaultItem = create_action(mainWindow, u'modeDefaultItem', - checked=False, category=UiStrings().ViewMode) - self.modeSetupItem = create_action(mainWindow, u'modeSetupItem', - checked=False, category=UiStrings().ViewMode) - self.modeLiveItem = create_action(mainWindow, u'modeLiveItem', - checked=True, category=UiStrings().ViewMode) + self.modeDefaultItem = create_action(mainWindow, u'modeDefaultItem', checked=False, + category=UiStrings().ViewMode) + self.modeSetupItem = create_action(mainWindow, u'modeSetupItem', checked=False, category=UiStrings().ViewMode) + self.modeLiveItem = create_action(mainWindow, u'modeLiveItem', checked=True, category=UiStrings().ViewMode) self.modeGroup = QtGui.QActionGroup(mainWindow) self.modeGroup.addAction(self.modeDefaultItem) self.modeGroup.addAction(self.modeSetupItem) @@ -288,29 +270,21 @@ class Ui_MainWindow(object): qmList = LanguageManager.get_qm_list() savedLanguage = LanguageManager.get_language() for key in sorted(qmList.keys()): - languageItem = create_action(mainWindow, key, - checked=qmList[key] == savedLanguage) + languageItem = create_action(mainWindow, key, checked=qmList[key] == savedLanguage) add_actions(self.languageGroup, [languageItem]) - self.settingsShortcutsItem = create_action(mainWindow, - u'settingsShortcutsItem', - icon=u':/system/system_configure_shortcuts.png', - category=UiStrings().Settings) + self.settingsShortcutsItem = create_action(mainWindow, u'settingsShortcutsItem', + icon=u':/system/system_configure_shortcuts.png', category=UiStrings().Settings) # Formatting Tags were also known as display tags. - self.formattingTagItem = create_action(mainWindow, - u'displayTagItem', icon=u':/system/tag_editor.png', - category=UiStrings().Settings) - self.settingsConfigureItem = create_action(mainWindow, - u'settingsConfigureItem', icon=u':/system/system_settings.png', - category=UiStrings().Settings) + self.formattingTagItem = create_action(mainWindow, u'displayTagItem', + icon=u':/system/tag_editor.png', category=UiStrings().Settings) + self.settingsConfigureItem = create_action(mainWindow, u'settingsConfigureItem', + icon=u':/system/system_settings.png', category=UiStrings().Settings) # Give QT Extra Hint that this is the Preferences Menu Item self.settingsConfigureItem.setMenuRole(QtGui.QAction.PreferencesRole) - self.settingsImportItem = create_action(mainWindow, - u'settingsImportItem', category=UiStrings().Settings) - self.settingsExportItem = create_action(mainWindow, - u'settingsExportItem', category=UiStrings().Settings) + self.settingsImportItem = create_action(mainWindow, u'settingsImportItem', category=UiStrings().Settings) + self.settingsExportItem = create_action(mainWindow, u'settingsExportItem', category=UiStrings().Settings) action_list.add_category(UiStrings().Help, CategoryOrder.standardMenu) - self.aboutItem = create_action(mainWindow, u'aboutItem', - icon=u':/system/system_about.png', + self.aboutItem = create_action(mainWindow, u'aboutItem', icon=u':/system/system_about.png', shortcuts=[QtGui.QKeySequence(u'Ctrl+F1')], category=UiStrings().Help, triggers=self.onAboutItemClicked) # Give QT Extra Hint that this is an About Menu Item @@ -326,22 +300,16 @@ class Ui_MainWindow(object): icon=u':/system/system_online_help.png', shortcuts=[QtGui.QKeySequence(u'Alt+F1')], category=UiStrings().Help, triggers=self.onOnlineHelpClicked) - self.webSiteItem = create_action(mainWindow, - u'webSiteItem', category=UiStrings().Help) - add_actions(self.fileImportMenu, (self.settingsImportItem, None, - self.importThemeItem, self.importLanguageItem)) - add_actions(self.fileExportMenu, (self.settingsExportItem, None, - self.exportThemeItem, self.exportLanguageItem)) + self.webSiteItem = create_action(mainWindow, u'webSiteItem', category=UiStrings().Help) + add_actions(self.fileImportMenu, (self.settingsImportItem, None, self.importThemeItem, self.importLanguageItem)) + add_actions(self.fileExportMenu, (self.settingsExportItem, None, self.exportThemeItem, self.exportLanguageItem)) add_actions(self.fileMenu, (self.fileNewItem, self.fileOpenItem, - self.fileSaveItem, self.fileSaveAsItem, - self.recentFilesMenu.menuAction(), None, - self.fileImportMenu.menuAction(), self.fileExportMenu.menuAction(), - None, self.printServiceOrderItem, self.fileExitItem)) - add_actions(self.viewModeMenu, (self.modeDefaultItem, - self.modeSetupItem, self.modeLiveItem)) - add_actions(self.viewMenu, (self.viewModeMenu.menuAction(), - None, self.viewMediaManagerItem, self.viewServiceManagerItem, - self.viewThemeManagerItem, None, self.viewPreviewPanel, + self.fileSaveItem, self.fileSaveAsItem, self.recentFilesMenu.menuAction(), None, + self.fileImportMenu.menuAction(), self.fileExportMenu.menuAction(), None, self.printServiceOrderItem, + self.fileExitItem)) + add_actions(self.viewModeMenu, (self.modeDefaultItem, self.modeSetupItem, self.modeLiveItem)) + add_actions(self.viewMenu, (self.viewModeMenu.menuAction(), None, self.viewMediaManagerItem, + self.viewServiceManagerItem, self.viewThemeManagerItem, None, self.viewPreviewPanel, self.viewLivePanel, None, self.lockPanel)) # i18n add Language Actions add_actions(self.settingsLanguageMenu, (self.autoLanguageItem, None)) @@ -349,35 +317,27 @@ class Ui_MainWindow(object): # Order things differently in OS X so that Preferences menu item in the # app menu is correct (this gets picked up automatically by Qt). if sys.platform == u'darwin': - add_actions(self.settingsMenu, (self.settingsPluginListItem, - self.settingsLanguageMenu.menuAction(), None, - self.settingsConfigureItem, self.settingsShortcutsItem, - self.formattingTagItem)) + add_actions(self.settingsMenu, (self.settingsPluginListItem, self.settingsLanguageMenu.menuAction(), None, + self.settingsConfigureItem, self.settingsShortcutsItem, self.formattingTagItem)) else: - add_actions(self.settingsMenu, (self.settingsPluginListItem, - self.settingsLanguageMenu.menuAction(), None, - self.formattingTagItem, self.settingsShortcutsItem, - self.settingsConfigureItem)) + add_actions(self.settingsMenu, (self.settingsPluginListItem, self.settingsLanguageMenu.menuAction(), None, + self.formattingTagItem, self.settingsShortcutsItem, self.settingsConfigureItem)) add_actions(self.toolsMenu, (self.toolsAddToolItem, None)) add_actions(self.toolsMenu, (self.toolsOpenDataFolder, None)) add_actions(self.toolsMenu, (self.toolsFirstTimeWizard, None)) add_actions(self.toolsMenu, [self.updateThemeImages]) if os.name == u'nt': - add_actions(self.helpMenu, (self.offlineHelpItem, - self.onlineHelpItem, None, self.webSiteItem, - self.aboutItem)) + add_actions(self.helpMenu, (self.offlineHelpItem, self.onlineHelpItem, None, self.webSiteItem, + self.aboutItem)) else: - add_actions(self.helpMenu, (self.onlineHelpItem, None, - self.webSiteItem, self.aboutItem)) - add_actions(self.menuBar, (self.fileMenu.menuAction(), - self.viewMenu.menuAction(), self.toolsMenu.menuAction(), + add_actions(self.helpMenu, (self.onlineHelpItem, None, self.webSiteItem, self.aboutItem)) + add_actions(self.menuBar, (self.fileMenu.menuAction(), self.viewMenu.menuAction(), self.toolsMenu.menuAction(), self.settingsMenu.menuAction(), self.helpMenu.menuAction())) # Initialise the translation self.retranslateUi(mainWindow) self.mediaToolBox.setCurrentIndex(0) # Connect up some signals and slots - QtCore.QObject.connect(self.fileMenu, - QtCore.SIGNAL(u'aboutToShow()'), self.updateRecentFilesMenu) + QtCore.QObject.connect(self.fileMenu, QtCore.SIGNAL(u'aboutToShow()'), self.updateRecentFilesMenu) # Hide the entry, as it does not have any functionality yet. self.toolsAddToolItem.setVisible(False) self.importLanguageItem.setVisible(False) @@ -394,152 +354,94 @@ class Ui_MainWindow(object): self.fileMenu.setTitle(translate('OpenLP.MainWindow', '&File')) self.fileImportMenu.setTitle(translate('OpenLP.MainWindow', '&Import')) self.fileExportMenu.setTitle(translate('OpenLP.MainWindow', '&Export')) - self.recentFilesMenu.setTitle( - translate('OpenLP.MainWindow', '&Recent Files')) + self.recentFilesMenu.setTitle(translate('OpenLP.MainWindow', '&Recent Files')) self.viewMenu.setTitle(translate('OpenLP.MainWindow', '&View')) self.viewModeMenu.setTitle(translate('OpenLP.MainWindow', 'M&ode')) self.toolsMenu.setTitle(translate('OpenLP.MainWindow', '&Tools')) self.settingsMenu.setTitle(translate('OpenLP.MainWindow', '&Settings')) - self.settingsLanguageMenu.setTitle(translate('OpenLP.MainWindow', - '&Language')) + self.settingsLanguageMenu.setTitle(translate('OpenLP.MainWindow', '&Language')) self.helpMenu.setTitle(translate('OpenLP.MainWindow', '&Help')) - self.mediaManagerDock.setWindowTitle( - translate('OpenLP.MainWindow', 'Media Manager')) - self.serviceManagerDock.setWindowTitle( - translate('OpenLP.MainWindow', 'Service Manager')) - self.themeManagerDock.setWindowTitle( - translate('OpenLP.MainWindow', 'Theme Manager')) + self.mediaManagerDock.setWindowTitle(translate('OpenLP.MainWindow', 'Media Manager')) + self.serviceManagerDock.setWindowTitle(translate('OpenLP.MainWindow', 'Service Manager')) + self.themeManagerDock.setWindowTitle(translate('OpenLP.MainWindow', 'Theme Manager')) self.fileNewItem.setText(translate('OpenLP.MainWindow', '&New')) self.fileNewItem.setToolTip(UiStrings().NewService) self.fileNewItem.setStatusTip(UiStrings().CreateService) self.fileOpenItem.setText(translate('OpenLP.MainWindow', '&Open')) self.fileOpenItem.setToolTip(UiStrings().OpenService) - self.fileOpenItem.setStatusTip( - translate('OpenLP.MainWindow', 'Open an existing service.')) + self.fileOpenItem.setStatusTip(translate('OpenLP.MainWindow', 'Open an existing service.')) self.fileSaveItem.setText(translate('OpenLP.MainWindow', '&Save')) self.fileSaveItem.setToolTip(UiStrings().SaveService) - self.fileSaveItem.setStatusTip( - translate('OpenLP.MainWindow', 'Save the current service to disk.')) - self.fileSaveAsItem.setText( - translate('OpenLP.MainWindow', 'Save &As...')) - self.fileSaveAsItem.setToolTip( - translate('OpenLP.MainWindow', 'Save Service As')) - self.fileSaveAsItem.setStatusTip(translate('OpenLP.MainWindow', - 'Save the current service under a new name.')) + self.fileSaveItem.setStatusTip(translate('OpenLP.MainWindow', 'Save the current service to disk.')) + self.fileSaveAsItem.setText(translate('OpenLP.MainWindow', 'Save &As...')) + self.fileSaveAsItem.setToolTip(translate('OpenLP.MainWindow', 'Save Service As')) + self.fileSaveAsItem.setStatusTip(translate('OpenLP.MainWindow', 'Save the current service under a new name.')) self.printServiceOrderItem.setText(UiStrings().PrintService) - self.printServiceOrderItem.setStatusTip(translate('OpenLP.MainWindow', - 'Print the current service.')) - self.fileExitItem.setText( - translate('OpenLP.MainWindow', 'E&xit')) - self.fileExitItem.setStatusTip( - translate('OpenLP.MainWindow', 'Quit OpenLP')) - self.importThemeItem.setText( - translate('OpenLP.MainWindow', '&Theme')) - self.importLanguageItem.setText( - translate('OpenLP.MainWindow', '&Language')) - self.exportThemeItem.setText( - translate('OpenLP.MainWindow', '&Theme')) - self.exportLanguageItem.setText( - translate('OpenLP.MainWindow', '&Language')) - self.settingsShortcutsItem.setText( - translate('OpenLP.MainWindow', 'Configure &Shortcuts...')) - self.formattingTagItem.setText( - translate('OpenLP.MainWindow', 'Configure &Formatting Tags...')) - self.settingsConfigureItem.setText( - translate('OpenLP.MainWindow', '&Configure OpenLP...')) + self.printServiceOrderItem.setStatusTip(translate('OpenLP.MainWindow', 'Print the current service.')) + self.fileExitItem.setText(translate('OpenLP.MainWindow', 'E&xit')) + self.fileExitItem.setStatusTip(translate('OpenLP.MainWindow', 'Quit OpenLP')) + self.importThemeItem.setText(translate('OpenLP.MainWindow', '&Theme')) + self.importLanguageItem.setText(translate('OpenLP.MainWindow', '&Language')) + self.exportThemeItem.setText(translate('OpenLP.MainWindow', '&Theme')) + self.exportLanguageItem.setText(translate('OpenLP.MainWindow', '&Language')) + self.settingsShortcutsItem.setText(translate('OpenLP.MainWindow', 'Configure &Shortcuts...')) + self.formattingTagItem.setText(translate('OpenLP.MainWindow', 'Configure &Formatting Tags...')) + self.settingsConfigureItem.setText(translate('OpenLP.MainWindow', '&Configure OpenLP...')) self.settingsExportItem.setStatusTip(translate('OpenLP.MainWindow', 'Export OpenLP settings to a specified *.config file')) - self.settingsExportItem.setText( - translate('OpenLP.MainWindow', 'Settings')) + self.settingsExportItem.setText(translate('OpenLP.MainWindow', 'Settings')) self.settingsImportItem.setStatusTip(translate('OpenLP.MainWindow', - 'Import OpenLP settings from a specified *.config file previously ' - 'exported on this or another machine')) - self.settingsImportItem.setText( - translate('OpenLP.MainWindow', 'Settings')) - self.viewMediaManagerItem.setText( - translate('OpenLP.MainWindow', '&Media Manager')) - self.viewMediaManagerItem.setToolTip( - translate('OpenLP.MainWindow', 'Toggle Media Manager')) + 'Import OpenLP settings from a specified *.config file previously exported on this or another machine')) + self.settingsImportItem.setText(translate('OpenLP.MainWindow', 'Settings')) + self.viewMediaManagerItem.setText(translate('OpenLP.MainWindow', '&Media Manager')) + self.viewMediaManagerItem.setToolTip(translate('OpenLP.MainWindow', 'Toggle Media Manager')) self.viewMediaManagerItem.setStatusTip(translate('OpenLP.MainWindow', 'Toggle the visibility of the media manager.')) - self.viewThemeManagerItem.setText( - translate('OpenLP.MainWindow', '&Theme Manager')) - self.viewThemeManagerItem.setToolTip( - translate('OpenLP.MainWindow', 'Toggle Theme Manager')) + self.viewThemeManagerItem.setText(translate('OpenLP.MainWindow', '&Theme Manager')) + self.viewThemeManagerItem.setToolTip(translate('OpenLP.MainWindow', 'Toggle Theme Manager')) self.viewThemeManagerItem.setStatusTip(translate('OpenLP.MainWindow', 'Toggle the visibility of the theme manager.')) - self.viewServiceManagerItem.setText( - translate('OpenLP.MainWindow', '&Service Manager')) - self.viewServiceManagerItem.setToolTip( - translate('OpenLP.MainWindow', 'Toggle Service Manager')) + self.viewServiceManagerItem.setText(translate('OpenLP.MainWindow', '&Service Manager')) + self.viewServiceManagerItem.setToolTip(translate('OpenLP.MainWindow', 'Toggle Service Manager')) self.viewServiceManagerItem.setStatusTip(translate('OpenLP.MainWindow', 'Toggle the visibility of the service manager.')) - self.viewPreviewPanel.setText( - translate('OpenLP.MainWindow', '&Preview Panel')) - self.viewPreviewPanel.setToolTip( - translate('OpenLP.MainWindow', 'Toggle Preview Panel')) - self.viewPreviewPanel.setStatusTip(translate('OpenLP.MainWindow', - 'Toggle the visibility of the preview panel.')) - self.viewLivePanel.setText( - translate('OpenLP.MainWindow', '&Live Panel')) - self.viewLivePanel.setToolTip( - translate('OpenLP.MainWindow', 'Toggle Live Panel')) - self.lockPanel.setText( - translate('OpenLP.MainWindow', 'L&ock Panels')) - self.lockPanel.setStatusTip( - translate('OpenLP.MainWindow', 'Prevent the panels being moved.')) - self.viewLivePanel.setStatusTip(translate('OpenLP.MainWindow', - 'Toggle the visibility of the live panel.')) - self.settingsPluginListItem.setText(translate('OpenLP.MainWindow', - '&Plugin List')) - self.settingsPluginListItem.setStatusTip( - translate('OpenLP.MainWindow', 'List the Plugins')) + self.viewPreviewPanel.setText(translate('OpenLP.MainWindow', '&Preview Panel')) + self.viewPreviewPanel.setToolTip(translate('OpenLP.MainWindow', 'Toggle Preview Panel')) + self.viewPreviewPanel.setStatusTip(translate('OpenLP.MainWindow', 'Toggle the visibility of the preview panel.')) + self.viewLivePanel.setText(translate('OpenLP.MainWindow', '&Live Panel')) + self.viewLivePanel.setToolTip(translate('OpenLP.MainWindow', 'Toggle Live Panel')) + self.lockPanel.setText(translate('OpenLP.MainWindow', 'L&ock Panels')) + self.lockPanel.setStatusTip(translate('OpenLP.MainWindow', 'Prevent the panels being moved.')) + self.viewLivePanel.setStatusTip(translate('OpenLP.MainWindow', 'Toggle the visibility of the live panel.')) + self.settingsPluginListItem.setText(translate('OpenLP.MainWindow', '&Plugin List')) + self.settingsPluginListItem.setStatusTip(translate('OpenLP.MainWindow', 'List the Plugins')) self.aboutItem.setText(translate('OpenLP.MainWindow', '&About')) - self.aboutItem.setStatusTip( - translate('OpenLP.MainWindow', 'More information about OpenLP')) + self.aboutItem.setStatusTip(translate('OpenLP.MainWindow', 'More information about OpenLP')) if os.name == u'nt': - self.offlineHelpItem.setText( - translate('OpenLP.MainWindow', '&User Guide')) - self.onlineHelpItem.setText( - translate('OpenLP.MainWindow', '&Online Help')) - self.webSiteItem.setText( - translate('OpenLP.MainWindow', '&Web Site')) + self.offlineHelpItem.setText(translate('OpenLP.MainWindow', '&User Guide')) + self.onlineHelpItem.setText(translate('OpenLP.MainWindow', '&Online Help')) + self.webSiteItem.setText(translate('OpenLP.MainWindow', '&Web Site')) for item in self.languageGroup.actions(): item.setText(item.objectName()) - item.setStatusTip(translate('OpenLP.MainWindow', - 'Set the interface language to %s') % item.objectName()) - self.autoLanguageItem.setText( - translate('OpenLP.MainWindow', '&Autodetect')) - self.autoLanguageItem.setStatusTip(translate('OpenLP.MainWindow', - 'Use the system language, if available.')) - self.toolsAddToolItem.setText( - translate('OpenLP.MainWindow', 'Add &Tool...')) - self.toolsAddToolItem.setStatusTip(translate('OpenLP.MainWindow', - 'Add an application to the list of tools.')) - self.toolsOpenDataFolder.setText( - translate('OpenLP.MainWindow', 'Open &Data Folder...')) + item.setStatusTip(translate('OpenLP.MainWindow', 'Set the interface language to %s') % item.objectName()) + self.autoLanguageItem.setText(translate('OpenLP.MainWindow', '&Autodetect')) + self.autoLanguageItem.setStatusTip(translate('OpenLP.MainWindow', 'Use the system language, if available.')) + self.toolsAddToolItem.setText(translate('OpenLP.MainWindow', 'Add &Tool...')) + self.toolsAddToolItem.setStatusTip(translate('OpenLP.MainWindow', 'Add an application to the list of tools.')) + self.toolsOpenDataFolder.setText(translate('OpenLP.MainWindow', 'Open &Data Folder...')) self.toolsOpenDataFolder.setStatusTip(translate('OpenLP.MainWindow', 'Open the folder where songs, bibles and other data resides.')) - self.toolsFirstTimeWizard.setText( - translate('OpenLP.MainWindow', 'Re-run First Time Wizard')) + self.toolsFirstTimeWizard.setText(translate('OpenLP.MainWindow', 'Re-run First Time Wizard')) self.toolsFirstTimeWizard.setStatusTip(translate('OpenLP.MainWindow', - 'Re-run the First Time Wizard, importing songs, Bibles and ' - 'themes.')) - self.updateThemeImages.setText( - translate('OpenLP.MainWindow', 'Update Theme Images')) - self.updateThemeImages.setStatusTip( - translate('OpenLP.MainWindow', 'Update the preview images for all ' - 'themes.')) - self.modeDefaultItem.setText( - translate('OpenLP.MainWindow', '&Default')) - self.modeDefaultItem.setStatusTip(translate('OpenLP.MainWindow', - 'Set the view mode back to the default.')) + 'Re-run the First Time Wizard, importing songs, Bibles and themes.')) + self.updateThemeImages.setText(translate('OpenLP.MainWindow', 'Update Theme Images')) + self.updateThemeImages.setStatusTip(translate('OpenLP.MainWindow', 'Update the preview images for all themes.')) + self.modeDefaultItem.setText(translate('OpenLP.MainWindow', '&Default')) + self.modeDefaultItem.setStatusTip(translate('OpenLP.MainWindow', 'Set the view mode back to the default.')) self.modeSetupItem.setText(translate('OpenLP.MainWindow', '&Setup')) - self.modeSetupItem.setStatusTip( - translate('OpenLP.MainWindow', 'Set the view mode to Setup.')) + self.modeSetupItem.setStatusTip(translate('OpenLP.MainWindow', 'Set the view mode to Setup.')) self.modeLiveItem.setText(translate('OpenLP.MainWindow', '&Live')) - self.modeLiveItem.setStatusTip( - translate('OpenLP.MainWindow', 'Set the view mode to Live.')) + self.modeLiveItem.setStatusTip(translate('OpenLP.MainWindow', 'Set the view mode to Live.')) class MainWindow(QtGui.QMainWindow, Ui_MainWindow): @@ -592,75 +494,50 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): self.newDataPath = u'' self.copyData = False # Set up signals and slots - QtCore.QObject.connect(self.importThemeItem, - QtCore.SIGNAL(u'triggered()'), + QtCore.QObject.connect(self.importThemeItem, QtCore.SIGNAL(u'triggered()'), self.themeManagerContents.onImportTheme) - QtCore.QObject.connect(self.exportThemeItem, - QtCore.SIGNAL(u'triggered()'), + QtCore.QObject.connect(self.exportThemeItem, QtCore.SIGNAL(u'triggered()'), self.themeManagerContents.onExportTheme) - QtCore.QObject.connect(self.mediaManagerDock, - QtCore.SIGNAL(u'visibilityChanged(bool)'), + QtCore.QObject.connect(self.mediaManagerDock, QtCore.SIGNAL(u'visibilityChanged(bool)'), self.viewMediaManagerItem.setChecked) - QtCore.QObject.connect(self.serviceManagerDock, - QtCore.SIGNAL(u'visibilityChanged(bool)'), + QtCore.QObject.connect(self.serviceManagerDock, QtCore.SIGNAL(u'visibilityChanged(bool)'), self.viewServiceManagerItem.setChecked) - QtCore.QObject.connect(self.themeManagerDock, - QtCore.SIGNAL(u'visibilityChanged(bool)'), + QtCore.QObject.connect(self.themeManagerDock, QtCore.SIGNAL(u'visibilityChanged(bool)'), self.viewThemeManagerItem.setChecked) - QtCore.QObject.connect(self.webSiteItem, - QtCore.SIGNAL(u'triggered()'), self.onHelpWebSiteClicked) - QtCore.QObject.connect(self.toolsOpenDataFolder, - QtCore.SIGNAL(u'triggered()'), self.onToolsOpenDataFolderClicked) - QtCore.QObject.connect(self.toolsFirstTimeWizard, - QtCore.SIGNAL(u'triggered()'), self.onFirstTimeWizardClicked) - QtCore.QObject.connect(self.updateThemeImages, - QtCore.SIGNAL(u'triggered()'), self.onUpdateThemeImages) - QtCore.QObject.connect(self.formattingTagItem, - QtCore.SIGNAL(u'triggered()'), self.onFormattingTagItemClicked) - QtCore.QObject.connect(self.settingsConfigureItem, - QtCore.SIGNAL(u'triggered()'), self.onSettingsConfigureItemClicked) - QtCore.QObject.connect(self.settingsShortcutsItem, - QtCore.SIGNAL(u'triggered()'), self.onSettingsShortcutsItemClicked) - QtCore.QObject.connect(self.settingsImportItem, - QtCore.SIGNAL(u'triggered()'), self.onSettingsImportItemClicked) - QtCore.QObject.connect(self.settingsExportItem, - QtCore.SIGNAL(u'triggered()'), self.onSettingsExportItemClicked) + QtCore.QObject.connect(self.webSiteItem, QtCore.SIGNAL(u'triggered()'), self.onHelpWebSiteClicked) + QtCore.QObject.connect(self.toolsOpenDataFolder, QtCore.SIGNAL(u'triggered()'), + self.onToolsOpenDataFolderClicked) + QtCore.QObject.connect(self.toolsFirstTimeWizard, QtCore.SIGNAL(u'triggered()'), self.onFirstTimeWizardClicked) + QtCore.QObject.connect(self.updateThemeImages, QtCore.SIGNAL(u'triggered()'), self.onUpdateThemeImages) + QtCore.QObject.connect(self.formattingTagItem, QtCore.SIGNAL(u'triggered()'), self.onFormattingTagItemClicked) + QtCore.QObject.connect(self.settingsConfigureItem, QtCore.SIGNAL(u'triggered()'), + self.onSettingsConfigureItemClicked) + QtCore.QObject.connect(self.settingsShortcutsItem, QtCore.SIGNAL(u'triggered()'), + self.onSettingsShortcutsItemClicked) + QtCore.QObject.connect(self.settingsImportItem, QtCore.SIGNAL(u'triggered()'), + self.onSettingsImportItemClicked) + QtCore.QObject.connect(self.settingsExportItem,QtCore.SIGNAL(u'triggered()'), self.onSettingsExportItemClicked) # i18n set signals for languages self.languageGroup.triggered.connect(LanguageManager.set_language) - QtCore.QObject.connect(self.modeDefaultItem, - QtCore.SIGNAL(u'triggered()'), self.onModeDefaultItemClicked) - QtCore.QObject.connect(self.modeSetupItem, - QtCore.SIGNAL(u'triggered()'), self.onModeSetupItemClicked) - QtCore.QObject.connect(self.modeLiveItem, - QtCore.SIGNAL(u'triggered()'), self.onModeLiveItemClicked) - QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'theme_update_global'), self.defaultThemeChanged) - QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'openlp_version_check'), self.versionNotice) - QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'live_display_blank_check'), self.blankCheck) - QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'config_screen_changed'), self.screenChanged) - QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'mainwindow_status_text'), self.showStatusMessage) - QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'cleanup'), self.cleanUp) + QtCore.QObject.connect(self.modeDefaultItem, QtCore.SIGNAL(u'triggered()'), self.onModeDefaultItemClicked) + QtCore.QObject.connect(self.modeSetupItem, QtCore.SIGNAL(u'triggered()'), self.onModeSetupItemClicked) + QtCore.QObject.connect(self.modeLiveItem, QtCore.SIGNAL(u'triggered()'), self.onModeLiveItemClicked) + QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'theme_update_global'), self.defaultThemeChanged) + QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'openlp_version_check'), self.versionNotice) + QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'live_display_blank_check'), self.blankCheck) + QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'config_screen_changed'), self.screenChanged) + QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'mainwindow_status_text'), self.showStatusMessage) + QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'cleanup'), self.cleanUp) # Media Manager - QtCore.QObject.connect(self.mediaToolBox, - QtCore.SIGNAL(u'currentChanged(int)'), self.onMediaToolBoxChanged) + QtCore.QObject.connect(self.mediaToolBox, QtCore.SIGNAL(u'currentChanged(int)'), self.onMediaToolBoxChanged) Receiver.send_message(u'cursor_busy') # Simple message boxes - QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'openlp_error_message'), self.onErrorMessage) - QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'openlp_warning_message'), self.onWarningMessage) - QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'openlp_information_message'), + QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'openlp_error_message'), self.onErrorMessage) + QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'openlp_warning_message'), self.onWarningMessage) + QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'openlp_information_message'), self.onInformationMessage) - QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'set_new_data_path'), self.setNewDataPath) - QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'set_copy_data'), self.setCopyData) + QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'set_new_data_path'), self.setNewDataPath) + QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'set_copy_data'), self.setCopyData) # warning cyclic dependency # renderer needs to call ThemeManager and # ThemeManager needs to call Renderer @@ -729,13 +606,11 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): Notifies the user that a newer version of OpenLP is available. Triggered by delay thread. """ - version_text = translate('OpenLP.MainWindow', - 'Version %s of OpenLP is now available for download (you are ' - 'currently running version %s). \n\nYou can download the latest ' - 'version from http://openlp.org/.') + version_text = translate('OpenLP.MainWindow', 'Version %s of OpenLP is now available for download (you are ' + 'currently running version %s). \n\nYou can download the latest version from http://openlp.org/.') QtGui.QMessageBox.question(self, translate('OpenLP.MainWindow', 'OpenLP Version Updated'), - version_text % (version, get_application_version()[u'full'])) + version_text % (version, get_application_version()[u'full'])) def show(self): """ @@ -756,8 +631,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): elif Settings().value( self.generalSettingsSection + u'/auto open', False): self.serviceManagerContents.loadLastFile() - view_mode = Settings().value(u'%s/view mode' % - self.generalSettingsSection, u'default') + view_mode = Settings().value(u'%s/view mode' % self.generalSettingsSection, u'default') if view_mode == u'default': self.modeDefaultItem.setChecked(True) elif view_mode == u'setup': @@ -797,15 +671,12 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): """ answer = QtGui.QMessageBox.warning(self, translate('OpenLP.MainWindow', 'Re-run First Time Wizard?'), - translate('OpenLP.MainWindow', - 'Are you sure you want to re-run the First Time Wizard?\n\n' - 'Re-running this wizard may make changes to your current ' - 'OpenLP configuration and possibly add songs to your ' - 'existing songs list and change your default theme.'), - QtGui.QMessageBox.StandardButtons( - QtGui.QMessageBox.Yes | - QtGui.QMessageBox.No), - QtGui.QMessageBox.No) + translate('OpenLP.MainWindow', 'Are you sure you want to re-run the First Time Wizard?\n\n' + 'Re-running this wizard may make changes to your current ' + 'OpenLP configuration and possibly add songs to your ' + 'existing songs list and change your default theme.'), + QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes | QtGui.QMessageBox.No), + QtGui.QMessageBox.No) if answer == QtGui.QMessageBox.No: return Receiver.send_message(u'cursor_busy') @@ -827,8 +698,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): self.activePlugin.toggleStatus(PluginStatus.Inactive) self.themeManagerContents.configUpdated() self.themeManagerContents.loadThemes(True) - Receiver.send_message(u'theme_update_global', - self.themeManagerContents.global_theme) + Receiver.send_message(u'theme_update_global', self.themeManagerContents.global_theme) # Check if any Bibles downloaded. If there are, they will be # processed. Receiver.send_message(u'bibles_load_list', True) @@ -843,11 +713,8 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): False): if settings.value(u'%s/blank warning' % self.generalSettingsSection, False): - QtGui.QMessageBox.question(self, - translate('OpenLP.MainWindow', - 'OpenLP Main Display Blanked'), - translate('OpenLP.MainWindow', - 'The Main Display has been blanked out')) + QtGui.QMessageBox.question(self, translate('OpenLP.MainWindow', 'OpenLP Main Display Blanked'), + translate('OpenLP.MainWindow', 'The Main Display has been blanked out')) def onErrorMessage(self, data): Receiver.send_message(u'close_splash') @@ -937,24 +804,16 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): """ Import settings from an export INI file """ - answer = QtGui.QMessageBox.critical(self, - translate('OpenLP.MainWindow', 'Import settings?'), - translate('OpenLP.MainWindow', - 'Are you sure you want to import settings?\n\n' - 'Importing settings will make permanent changes to your current ' - 'OpenLP configuration.\n\n' - 'Importing incorrect settings may cause erratic behaviour or ' - 'OpenLP to terminate abnormally.'), - QtGui.QMessageBox.StandardButtons( - QtGui.QMessageBox.Yes | - QtGui.QMessageBox.No), - QtGui.QMessageBox.No) + answer = QtGui.QMessageBox.critical(self, translate('OpenLP.MainWindow', 'Import settings?'), + translate('OpenLP.MainWindow', 'Are you sure you want to import settings?\n\n' + 'Importing settings will make permanent changes to your current OpenLP configuration.\n\n' + 'Importing incorrect settings may cause erratic behaviour or OpenLP to terminate abnormally.'), + QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes | QtGui.QMessageBox.No), + QtGui.QMessageBox.No) if answer == QtGui.QMessageBox.No: return - import_file_name = QtGui.QFileDialog.getOpenFileName(self, - translate('OpenLP.MainWindow', 'Open File'), '', - translate('OpenLP.MainWindow', - 'OpenLP Export Settings Files (*.conf)')) + import_file_name = QtGui.QFileDialog.getOpenFileName(self,translate('OpenLP.MainWindow', 'Open File'), '', + translate('OpenLP.MainWindow', 'OpenLP Export Settings Files (*.conf)')) if not import_file_name: return setting_sections = [] @@ -987,16 +846,11 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): section_key = section + "/" + key # Make sure it's a valid section for us. if not section in setting_sections: - QtGui.QMessageBox.critical(self, - translate('OpenLP.MainWindow', 'Import settings'), - translate('OpenLP.MainWindow', - 'The file you selected does appear to be a valid OpenLP ' - 'settings file.\n\n' - 'Section [%s] is not valid \n\n' - 'Processing has terminated and no changed have been made.' - ).replace('%s', section), - QtGui.QMessageBox.StandardButtons( - QtGui.QMessageBox.Ok)) + QtGui.QMessageBox.critical(self, translate('OpenLP.MainWindow', 'Import settings'), + translate('OpenLP.MainWindow', 'The file you selected does appear to be a valid OpenLP ' + 'settings file.\n\n Section [%s] is not valid \n\n' + 'Processing has terminated and no changed have been made.').replace('%s', section), + QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok)) return # We have a good file, import it. for section_key in import_keys: @@ -1012,13 +866,10 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): # We must do an immediate restart or current configuration will # overwrite what was just imported when application terminates # normally. We need to exit without saving configuration. - QtGui.QMessageBox.information(self, - translate('OpenLP.MainWindow', 'Import settings'), - translate('OpenLP.MainWindow', - 'OpenLP will now close. Imported settings will ' - 'be applied the next time you start OpenLP.'), - QtGui.QMessageBox.StandardButtons( - QtGui.QMessageBox.Ok)) + QtGui.QMessageBox.information(self, translate('OpenLP.MainWindow', 'Import settings'), + translate('OpenLP.MainWindow', 'OpenLP will now close. Imported settings will ' + 'be applied the next time you start OpenLP.'), + QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok)) self.settingsImported = True self.cleanUp() QtCore.QCoreApplication.exit() @@ -1029,8 +880,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): """ export_file_name = QtGui.QFileDialog.getSaveFileName(self, translate('OpenLP.MainWindow', 'Export Settings File'), '', - translate('OpenLP.MainWindow', - 'OpenLP Export Settings File (*.conf)')) + translate('OpenLP.MainWindow', 'OpenLP Export Settings File (*.conf)')) if not export_file_name: return # Make sure it's a .conf file. @@ -1120,8 +970,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): """ if mode: settings = Settings() - settings.setValue(u'%s/view mode' % self.generalSettingsSection, - mode) + settings.setValue(u'%s/view mode' % self.generalSettingsSection, mode) self.mediaManagerDock.setVisible(media) self.serviceManagerDock.setVisible(service) self.themeManagerDock.setVisible(theme) @@ -1171,12 +1020,9 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): event.ignore() else: if Settings().value(u'advanced/enable exit confirmation', True): - ret = QtGui.QMessageBox.question(self, - translate('OpenLP.MainWindow', 'Close OpenLP'), - translate('OpenLP.MainWindow', - 'Are you sure you want to close OpenLP?'), - QtGui.QMessageBox.StandardButtons( - QtGui.QMessageBox.Yes | QtGui.QMessageBox.No), + ret = QtGui.QMessageBox.question(self, translate('OpenLP.MainWindow', 'Close OpenLP'), + translate('OpenLP.MainWindow', 'Are you sure you want to close OpenLP?'), + QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes | QtGui.QMessageBox.No), QtGui.QMessageBox.Yes) if ret == QtGui.QMessageBox.Yes: self.cleanUp() @@ -1201,8 +1047,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): self.serviceManagerContents.cleanUp() if save_settings: if Settings().value(u'advanced/save current plugin', False): - Settings().setValue(u'advanced/current media plugin', - self.mediaToolBox.currentIndex()) + Settings().setValue(u'advanced/current media plugin', self.mediaToolBox.currentIndex()) # Call the cleanup method to shutdown plugins. log.info(u'cleanup plugins') self.pluginManager.finalise_plugins() @@ -1262,15 +1107,13 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): self.statusBar.showMessage(message) def defaultThemeChanged(self, theme): - self.defaultThemeLabel.setText( - translate('OpenLP.MainWindow', 'Default Theme: %s') % theme) + self.defaultThemeLabel.setText(translate('OpenLP.MainWindow', 'Default Theme: %s') % theme) def toggleMediaManager(self): self.mediaManagerDock.setVisible(not self.mediaManagerDock.isVisible()) def toggleServiceManager(self): - self.serviceManagerDock.setVisible( - not self.serviceManagerDock.isVisible()) + self.serviceManagerDock.setVisible(not self.serviceManagerDock.isVisible()) def toggleThemeManager(self): self.themeManagerDock.setVisible(not self.themeManagerDock.isVisible()) @@ -1294,24 +1137,18 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): Sets the ability to stop the toolbars being changed. """ if lock: - self.themeManagerDock.setFeatures( - QtGui.QDockWidget.NoDockWidgetFeatures) - self.serviceManagerDock.setFeatures( - QtGui.QDockWidget.NoDockWidgetFeatures) - self.mediaManagerDock.setFeatures( - QtGui.QDockWidget.NoDockWidgetFeatures) + self.themeManagerDock.setFeatures(QtGui.QDockWidget.NoDockWidgetFeatures) + self.serviceManagerDock.setFeatures(QtGui.QDockWidget.NoDockWidgetFeatures) + self.mediaManagerDock.setFeatures(QtGui.QDockWidget.NoDockWidgetFeatures) self.viewMediaManagerItem.setEnabled(False) self.viewServiceManagerItem.setEnabled(False) self.viewThemeManagerItem.setEnabled(False) self.viewPreviewPanel.setEnabled(False) self.viewLivePanel.setEnabled(False) else: - self.themeManagerDock.setFeatures( - QtGui.QDockWidget.AllDockWidgetFeatures) - self.serviceManagerDock.setFeatures( - QtGui.QDockWidget.AllDockWidgetFeatures) - self.mediaManagerDock.setFeatures( - QtGui.QDockWidget.AllDockWidgetFeatures) + self.themeManagerDock.setFeatures(QtGui.QDockWidget.AllDockWidgetFeatures) + self.serviceManagerDock.setFeatures(QtGui.QDockWidget.AllDockWidgetFeatures) + self.mediaManagerDock.setFeatures(QtGui.QDockWidget.AllDockWidgetFeatures) self.viewMediaManagerItem.setEnabled(True) self.viewServiceManagerItem.setEnabled(True) self.viewThemeManagerItem.setEnabled(True) @@ -1339,17 +1176,12 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): """ log.debug(u'Loading QSettings') # Migrate Wrap Settings to Slide Limits Settings - if Settings().contains(self.generalSettingsSection + - u'/enable slide loop'): - if Settings().value(self.generalSettingsSection + - u'/enable slide loop', True): - Settings().setValue(self.advancedSettingsSection + - u'/slide limits', SlideLimits.Wrap) + if Settings().contains(self.generalSettingsSection + u'/enable slide loop'): + if Settings().value(self.generalSettingsSection + u'/enable slide loop', True): + Settings().setValue(self.advancedSettingsSection + u'/slide limits', SlideLimits.Wrap) else: - Settings().setValue(self.advancedSettingsSection + - u'/slide limits', SlideLimits.End) - Settings().remove(self.generalSettingsSection + - u'/enable slide loop') + Settings().setValue(self.advancedSettingsSection + u'/slide limits', SlideLimits.End) + Settings().remove(self.generalSettingsSection + u'/enable slide loop') Receiver.send_message(u'slidecontroller_update_slide_limits') settings = Settings() # Remove obsolete entries. @@ -1360,16 +1192,11 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): settings.endGroup() settings.beginGroup(self.uiSettingsSection) self.move(settings.value(u'main window position', QtCore.QPoint(0, 0))) - self.restoreGeometry( - settings.value(u'main window geometry', QtCore.QByteArray())) - self.restoreState( - settings.value(u'main window state', QtCore.QByteArray())) - self.liveController.splitter.restoreState( - settings.value(u'live splitter geometry', QtCore.QByteArray())) - self.previewController.splitter.restoreState( - settings.value(u'preview splitter geometry', QtCore.QByteArray())) - self.controlSplitter.restoreState(settings.value( - u'mainwindow splitter geometry', QtCore.QByteArray())) + self.restoreGeometry(settings.value(u'main window geometry', QtCore.QByteArray())) + self.restoreState(settings.value(u'main window state', QtCore.QByteArray())) + self.liveController.splitter.restoreState(settings.value(u'live splitter geometry', QtCore.QByteArray())) + self.previewController.splitter.restoreState(settings.value(u'preview splitter geometry', QtCore.QByteArray())) + self.controlSplitter.restoreState(settings.value(u'mainwindow splitter geometry', QtCore.QByteArray())) settings.endGroup() def saveSettings(self): @@ -1388,12 +1215,9 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): settings.setValue(u'main window position', self.pos()) settings.setValue(u'main window state', self.saveState()) settings.setValue(u'main window geometry', self.saveGeometry()) - settings.setValue(u'live splitter geometry', - self.liveController.splitter.saveState()) - settings.setValue(u'preview splitter geometry', - self.previewController.splitter.saveState()) - settings.setValue(u'mainwindow splitter geometry', - self.controlSplitter.saveState()) + settings.setValue(u'live splitter geometry', self.liveController.splitter.saveState()) + settings.setValue(u'preview splitter geometry', self.previewController.splitter.saveState()) + settings.setValue(u'mainwindow splitter geometry', self.controlSplitter.saveState()) settings.endGroup() def updateRecentFilesMenu(self): @@ -1414,10 +1238,8 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): triggers=self.serviceManagerContents.onRecentServiceClicked) self.recentFilesMenu.addAction(action) clearRecentFilesAction = create_action(self, u'', - text=translate('OpenLP.MainWindow', 'Clear List', - 'Clear List of recent files'), - statustip=translate('OpenLP.MainWindow', - 'Clear the list of recent files.'), + text=translate('OpenLP.MainWindow', 'Clear List', 'Clear List of recent files'), + statustip=translate('OpenLP.MainWindow', 'Clear the list of recent files.'), enabled=bool(self.recentFiles), triggers=self.clearRecentFileMenu) add_actions(self.recentFilesMenu, (None, clearRecentFilesAction)) @@ -1500,22 +1322,17 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): Receiver.send_message(u'openlp_process_events') Receiver.send_message(u'cursor_busy') self.showStatusMessage( - translate('OpenLP.MainWindow', - 'Copying OpenLP data to new data directory location - %s ' - '- Please wait for copy to finish' - ).replace('%s', self.newDataPath)) + translate('OpenLP.MainWindow', 'Copying OpenLP data to new data directory location - %s ' + '- Please wait for copy to finish').replace('%s', self.newDataPath)) dir_util.copy_tree(old_data_path, self.newDataPath) log.info(u'Copy sucessful') except (IOError, os.error, DistutilsFileError), why: Receiver.send_message(u'cursor_normal') log.exception(u'Data copy failed %s' % unicode(why)) - QtGui.QMessageBox.critical(self, - translate('OpenLP.MainWindow', 'New Data Directory Error'), + QtGui.QMessageBox.critical(self, translate('OpenLP.MainWindow', 'New Data Directory Error'), translate('OpenLP.MainWindow', - 'OpenLP Data directory copy failed\n\n%s' - ).replace('%s', unicode(why)), - QtGui.QMessageBox.StandardButtons( - QtGui.QMessageBox.Ok)) + 'OpenLP Data directory copy failed\n\n%s').replace('%s', unicode(why)), + QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok)) return False else: log.info(u'No data copy requested') From 345b5638c88bc53ee11895f6a11d3af02ccda55b Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sat, 29 Dec 2012 13:35:16 +0000 Subject: [PATCH 51/53] Splash screen done --- openlp/core/ui/mediadockmanager.py | 8 +-- openlp/core/ui/plugindialog.py | 23 +++---- openlp/core/ui/pluginform.py | 16 ++--- openlp/core/ui/printservicedialog.py | 56 ++++++---------- openlp/core/ui/printserviceform.py | 88 +++++++++---------------- openlp/core/ui/screen.py | 19 ++---- openlp/core/ui/serviceitemeditdialog.py | 19 +++--- openlp/core/ui/serviceitemeditform.py | 5 +- openlp/core/ui/servicenoteform.py | 8 +-- openlp/core/ui/settingsdialog.py | 18 ++--- openlp/core/ui/settingsform.py | 2 +- openlp/core/ui/shortcutlistdialog.py | 47 +++++-------- openlp/core/ui/shortcutlistform.py | 83 ++++++++++------------- openlp/core/ui/splashscreen.py | 5 +- 14 files changed, 143 insertions(+), 254 deletions(-) diff --git a/openlp/core/ui/mediadockmanager.py b/openlp/core/ui/mediadockmanager.py index 1a6f86fde..1d86bc7d9 100644 --- a/openlp/core/ui/mediadockmanager.py +++ b/openlp/core/ui/mediadockmanager.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 ############################################################################### # OpenLP - Open Source Lyrics Projection # @@ -67,8 +67,7 @@ class MediaDockManager(object): log.debug(u'Inserting %s dock' % visible_title[u'title']) match = False for dock_index in range(self.media_dock.count()): - if self.media_dock.widget(dock_index).settingsSection == \ - media_item.plugin.name: + if self.media_dock.widget(dock_index).settingsSection == media_item.plugin.name: match = True break if not match: @@ -85,7 +84,6 @@ class MediaDockManager(object): log.debug(u'remove %s dock' % visible_title[u'title']) for dock_index in range(self.media_dock.count()): if self.media_dock.widget(dock_index): - if self.media_dock.widget(dock_index).settingsSection == \ - media_item.plugin.name: + if self.media_dock.widget(dock_index).settingsSection == media_item.plugin.name: self.media_dock.widget(dock_index).setVisible(False) self.media_dock.removeItem(dock_index) diff --git a/openlp/core/ui/plugindialog.py b/openlp/core/ui/plugindialog.py index d32aafb0a..41d567681 100644 --- a/openlp/core/ui/plugindialog.py +++ b/openlp/core/ui/plugindialog.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 ############################################################################### # OpenLP - Open Source Lyrics Projection # @@ -61,27 +61,20 @@ class Ui_PluginViewDialog(object): self.aboutLabel = QtGui.QLabel(self.pluginInfoGroupBox) self.aboutLabel.setObjectName(u'aboutLabel') self.aboutTextBrowser = QtGui.QTextBrowser(self.pluginInfoGroupBox) - self.aboutTextBrowser.setTextInteractionFlags( - QtCore.Qt.LinksAccessibleByMouse) + self.aboutTextBrowser.setTextInteractionFlags(QtCore.Qt.LinksAccessibleByMouse) self.aboutTextBrowser.setObjectName(u'aboutTextBrowser') self.pluginInfoLayout.addRow(self.aboutLabel, self.aboutTextBrowser) self.listLayout.addWidget(self.pluginInfoGroupBox) self.pluginLayout.addLayout(self.listLayout) - self.buttonBox = create_button_box(pluginViewDialog, u'buttonBox', - [u'ok']) + self.buttonBox = create_button_box(pluginViewDialog, u'buttonBox', [u'ok']) self.pluginLayout.addWidget(self.buttonBox) self.retranslateUi(pluginViewDialog) def retranslateUi(self, pluginViewDialog): - pluginViewDialog.setWindowTitle( - translate('OpenLP.PluginForm', 'Plugin List')) - self.pluginInfoGroupBox.setTitle( - translate('OpenLP.PluginForm', 'Plugin Details')) + pluginViewDialog.setWindowTitle(translate('OpenLP.PluginForm', 'Plugin List')) + self.pluginInfoGroupBox.setTitle(translate('OpenLP.PluginForm', 'Plugin Details')) self.versionLabel.setText(u'%s:' % UiStrings().Version) self.aboutLabel.setText(u'%s:' % UiStrings().About) - self.statusLabel.setText( - translate('OpenLP.PluginForm', 'Status:')) - self.statusComboBox.setItemText(0, - translate('OpenLP.PluginForm', 'Active')) - self.statusComboBox.setItemText(1, - translate('OpenLP.PluginForm', 'Inactive')) + self.statusLabel.setText(translate('OpenLP.PluginForm', 'Status:')) + self.statusComboBox.setItemText(0, translate('OpenLP.PluginForm', 'Active')) + self.statusComboBox.setItemText(1, translate('OpenLP.PluginForm', 'Inactive')) diff --git a/openlp/core/ui/pluginform.py b/openlp/core/ui/pluginform.py index 9d72becce..2955f469b 100644 --- a/openlp/core/ui/pluginform.py +++ b/openlp/core/ui/pluginform.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 ############################################################################### # OpenLP - Open Source Lyrics Projection # @@ -48,13 +48,9 @@ class PluginForm(QtGui.QDialog, Ui_PluginViewDialog): self.load() self._clearDetails() # Right, now let's put some signals and slots together! - QtCore.QObject.connect( - self.pluginListWidget, - QtCore.SIGNAL(u'itemSelectionChanged()'), + QtCore.QObject.connect(self.pluginListWidget, QtCore.SIGNAL(u'itemSelectionChanged()'), self.onPluginListWidgetSelectionChanged) - QtCore.QObject.connect( - self.statusComboBox, - QtCore.SIGNAL(u'currentIndexChanged(int)'), + QtCore.QObject.connect(self.statusComboBox, QtCore.SIGNAL(u'currentIndexChanged(int)'), self.onStatusComboBoxChanged) def load(self): @@ -85,10 +81,8 @@ class PluginForm(QtGui.QDialog, Ui_PluginViewDialog): item.setIcon(plugin.icon) self.pluginListWidget.addItem(item) pluginListWidth = max(pluginListWidth, self.fontMetrics().width( - translate('OpenLP.PluginForm', '%s (Inactive)') % - plugin.nameStrings[u'singular'])) - self.pluginListWidget.setFixedWidth(pluginListWidth + - self.pluginListWidget.iconSize().width() + 48) + translate('OpenLP.PluginForm', '%s (Inactive)') % plugin.nameStrings[u'singular'])) + self.pluginListWidget.setFixedWidth(pluginListWidth + self.pluginListWidget.iconSize().width() + 48) def _clearDetails(self): self.statusComboBox.setCurrentIndex(-1) diff --git a/openlp/core/ui/printservicedialog.py b/openlp/core/ui/printservicedialog.py index 3904d4870..df36de45c 100644 --- a/openlp/core/ui/printservicedialog.py +++ b/openlp/core/ui/printservicedialog.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 ############################################################################### # OpenLP - Open Source Lyrics Projection # @@ -55,21 +55,17 @@ class Ui_PrintServiceDialog(object): self.toolbar = QtGui.QToolBar(printServiceDialog) self.toolbar.setIconSize(QtCore.QSize(22, 22)) self.toolbar.setToolButtonStyle(QtCore.Qt.ToolButtonTextBesideIcon) - self.printButton = self.toolbar.addAction( - build_icon(u':/general/general_print.png'), + self.printButton = self.toolbar.addAction(build_icon(u':/general/general_print.png'), translate('OpenLP.PrintServiceForm', 'Print')) self.optionsButton = QtGui.QToolButton(self.toolbar) - self.optionsButton.setToolButtonStyle( - QtCore.Qt.ToolButtonTextBesideIcon) + self.optionsButton.setToolButtonStyle(QtCore.Qt.ToolButtonTextBesideIcon) self.optionsButton.setIcon(build_icon(u':/system/system_configure.png')) self.optionsButton.setCheckable(True) self.toolbar.addWidget(self.optionsButton) self.toolbar.addSeparator() - self.plainCopy = self.toolbar.addAction( - build_icon(u':/system/system_edit_copy.png'), + self.plainCopy = self.toolbar.addAction(build_icon(u':/system/system_edit_copy.png'), translate('OpenLP.PrintServiceForm', 'Copy')) - self.htmlCopy = self.toolbar.addAction( - build_icon(u':/system/system_edit_copy.png'), + self.htmlCopy = self.toolbar.addAction(build_icon(u':/system/system_edit_copy.png'), translate('OpenLP.PrintServiceForm', 'Copy as HTML')) self.toolbar.addSeparator() self.zoomInButton = QtGui.QToolButton(self.toolbar) @@ -78,14 +74,12 @@ class Ui_PrintServiceDialog(object): self.zoomInButton.setIconSize(QtCore.QSize(22, 22)) self.toolbar.addWidget(self.zoomInButton) self.zoomOutButton = QtGui.QToolButton(self.toolbar) - self.zoomOutButton.setIcon( - build_icon(u':/general/general_zoom_out.png')) + self.zoomOutButton.setIcon(build_icon(u':/general/general_zoom_out.png')) self.zoomOutButton.setObjectName(u'zoomOutButton') self.zoomOutButton.setIconSize(QtCore.QSize(22, 22)) self.toolbar.addWidget(self.zoomOutButton) self.zoomOriginalButton = QtGui.QToolButton(self.toolbar) - self.zoomOriginalButton.setIcon( - build_icon(u':/general/general_zoom_original.png')) + self.zoomOriginalButton.setIcon(build_icon(u':/general/general_zoom_original.png')) self.zoomOriginalButton.setObjectName(u'zoomOriginalButton') self.zoomOriginalButton.setIconSize(QtCore.QSize(22, 22)) self.toolbar.addWidget(self.zoomOriginalButton) @@ -128,34 +122,22 @@ class Ui_PrintServiceDialog(object): self.optionsLayout.addWidget(self.optionsGroupBox) self.retranslateUi(printServiceDialog) - QtCore.QObject.connect(self.optionsButton, - QtCore.SIGNAL(u'toggled(bool)'), self.toggleOptions) + QtCore.QObject.connect(self.optionsButton,QtCore.SIGNAL(u'toggled(bool)'), self.toggleOptions) def retranslateUi(self, printServiceDialog): printServiceDialog.setWindowTitle(UiStrings().PrintService) - self.zoomOutButton.setToolTip(translate('OpenLP.PrintServiceForm', - 'Zoom Out')) - self.zoomOriginalButton.setToolTip(translate('OpenLP.PrintServiceForm', - 'Zoom Original')) - self.zoomInButton.setToolTip(translate('OpenLP.PrintServiceForm', - 'Zoom In')) - self.optionsButton.setText(translate('OpenLP.PrintServiceForm', - 'Options')) + self.zoomOutButton.setToolTip(translate('OpenLP.PrintServiceForm', 'Zoom Out')) + self.zoomOriginalButton.setToolTip(translate('OpenLP.PrintServiceForm', 'Zoom Original')) + self.zoomInButton.setToolTip(translate('OpenLP.PrintServiceForm', 'Zoom In')) + self.optionsButton.setText(translate('OpenLP.PrintServiceForm', 'Options')) self.titleLabel.setText(translate('OpenLP.PrintServiceForm', 'Title:')) - self.footerLabel.setText(translate('OpenLP.PrintServiceForm', - 'Custom Footer Text:')) - self.optionsGroupBox.setTitle( - translate('OpenLP.PrintServiceForm','Other Options')) - self.slideTextCheckBox.setText(translate('OpenLP.PrintServiceForm', - 'Include slide text if available')) - self.pageBreakAfterText.setText(translate('OpenLP.PrintServiceForm', - 'Add page break before each text item')) - self.notesCheckBox.setText(translate('OpenLP.PrintServiceForm', - 'Include service item notes')) - self.metaDataCheckBox.setText(translate('OpenLP.PrintServiceForm', - 'Include play length of media items')) - self.titleLineEdit.setText(translate('OpenLP.PrintServiceForm', - 'Service Sheet')) + self.footerLabel.setText(translate('OpenLP.PrintServiceForm', 'Custom Footer Text:')) + self.optionsGroupBox.setTitle(translate('OpenLP.PrintServiceForm','Other Options')) + self.slideTextCheckBox.setText(translate('OpenLP.PrintServiceForm', 'Include slide text if available')) + self.pageBreakAfterText.setText(translate('OpenLP.PrintServiceForm', 'Add page break before each text item')) + self.notesCheckBox.setText(translate('OpenLP.PrintServiceForm', 'Include service item notes')) + self.metaDataCheckBox.setText(translate('OpenLP.PrintServiceForm', 'Include play length of media items')) + self.titleLineEdit.setText(translate('OpenLP.PrintServiceForm', 'Service Sheet')) # Do not change the order. self.zoomComboBox.addItems([ translate('OpenLP.PrintServiceDialog', 'Fit Page'), diff --git a/openlp/core/ui/printserviceform.py b/openlp/core/ui/printserviceform.py index 8e48874f9..2ed12d72e 100644 --- a/openlp/core/ui/printserviceform.py +++ b/openlp/core/ui/printserviceform.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 ############################################################################### # OpenLP - Open Source Lyrics Projection # @@ -124,37 +124,24 @@ class PrintServiceForm(QtGui.QDialog, Ui_PrintServiceDialog): # Load the settings for the dialog. settings = Settings() settings.beginGroup(u'advanced') - self.slideTextCheckBox.setChecked(settings.value( - u'print slide text', False)) - self.pageBreakAfterText.setChecked(settings.value( - u'add page break', False)) + self.slideTextCheckBox.setChecked(settings.value(u'print slide text', False)) + self.pageBreakAfterText.setChecked(settings.value(u'add page break', False)) if not self.slideTextCheckBox.isChecked(): self.pageBreakAfterText.setDisabled(True) - self.metaDataCheckBox.setChecked(settings.value( - u'print file meta data', False)) + self.metaDataCheckBox.setChecked(settings.value(u'print file meta data', False)) self.notesCheckBox.setChecked(settings.value(u'print notes', False)) self.zoomComboBox.setCurrentIndex(settings.value(u'display size', 0)) settings.endGroup() # Signals - QtCore.QObject.connect(self.printButton, - QtCore.SIGNAL(u'triggered()'), self.printServiceOrder) - QtCore.QObject.connect(self.zoomOutButton, - QtCore.SIGNAL(u'clicked()'), self.zoomOut) - QtCore.QObject.connect(self.zoomInButton, - QtCore.SIGNAL(u'clicked()'), self.zoomIn) - QtCore.QObject.connect(self.zoomOriginalButton, - QtCore.SIGNAL(u'clicked()'), self.zoomOriginal) - QtCore.QObject.connect(self.previewWidget, - QtCore.SIGNAL(u'paintRequested(QPrinter *)'), self.paintRequested) - QtCore.QObject.connect(self.zoomComboBox, - QtCore.SIGNAL(u'currentIndexChanged(int)'), self.displaySizeChanged) - QtCore.QObject.connect(self.plainCopy, - QtCore.SIGNAL(u'triggered()'), self.copyText) - QtCore.QObject.connect(self.htmlCopy, - QtCore.SIGNAL(u'triggered()'), self.copyHtmlText) - QtCore.QObject.connect(self.slideTextCheckBox, - QtCore.SIGNAL(u'stateChanged(int)'), - self.onSlideTextCheckBoxChanged) + QtCore.QObject.connect(self.printButton, QtCore.SIGNAL(u'triggered()'), self.printServiceOrder) + QtCore.QObject.connect(self.zoomOutButton, QtCore.SIGNAL(u'clicked()'), self.zoomOut) + QtCore.QObject.connect(self.zoomInButton, QtCore.SIGNAL(u'clicked()'), self.zoomIn) + QtCore.QObject.connect(self.zoomOriginalButton, QtCore.SIGNAL(u'clicked()'), self.zoomOriginal) + QtCore.QObject.connect(self.previewWidget, QtCore.SIGNAL(u'paintRequested(QPrinter *)'), self.paintRequested) + QtCore.QObject.connect(self.zoomComboBox, QtCore.SIGNAL(u'currentIndexChanged(int)'), self.displaySizeChanged) + QtCore.QObject.connect(self.plainCopy, QtCore.SIGNAL(u'triggered()'), self.copyText) + QtCore.QObject.connect(self.htmlCopy, QtCore.SIGNAL(u'triggered()'), self.copyHtmlText) + QtCore.QObject.connect(self.slideTextCheckBox, QtCore.SIGNAL(u'stateChanged(int)'), self.onSlideTextCheckBoxChanged) self.updatePreviewText() def toggleOptions(self, checked): @@ -175,8 +162,7 @@ class PrintServiceForm(QtGui.QDialog, Ui_PrintServiceDialog): html_data = self._addElement(u'html') self._addElement(u'head', parent=html_data) self._addElement(u'title', self.titleLineEdit.text(), html_data.head) - css_path = os.path.join( - AppLocation.get_data_path(), u'service_print.css') + css_path = os.path.join(AppLocation.get_data_path(), u'service_print.css') custom_css = get_text_file_string(css_path) if not custom_css: custom_css = DEFAULT_CSS @@ -189,13 +175,10 @@ class PrintServiceForm(QtGui.QDialog, Ui_PrintServiceDialog): self._addPreviewItem(html_data.body, item[u'service_item'], index) # Add the custom service notes: if self.footerTextEdit.toPlainText(): - div = self._addElement(u'div', parent=html_data.body, - classId=u'customNotes') - self._addElement(u'span', translate('OpenLP.ServiceManager', - 'Custom Service Notes: '), div, classId=u'customNotesTitle') - self._addElement(u'span', - cgi.escape(self.footerTextEdit.toPlainText()), - div, classId=u'customNotesText') + div = self._addElement(u'div', parent=html_data.body, classId=u'customNotes') + self._addElement(u'span', translate('OpenLP.ServiceManager', 'Custom Service Notes: '), div, + classId=u'customNotesTitle') + self._addElement(u'span', cgi.escape(self.footerTextEdit.toPlainText()), div, classId=u'customNotesText') self.document.setHtml(html.tostring(html_data)) self.previewWidget.updatePreview() @@ -203,18 +186,15 @@ class PrintServiceForm(QtGui.QDialog, Ui_PrintServiceDialog): div = self._addElement(u'div', classId=u'item', parent=body) # Add the title of the service item. item_title = self._addElement(u'h2', parent=div, classId=u'itemTitle') - self._addElement(u'img', parent=item_title, - attribute=(u'src', item.icon)) - self._addElement(u'span', - u' ' + cgi.escape(item.get_display_title()), item_title) + self._addElement(u'img', parent=item_title, attribute=(u'src', item.icon)) + self._addElement(u'span', u' ' + cgi.escape(item.get_display_title()), item_title) if self.slideTextCheckBox.isChecked(): # Add the text of the service item. if item.is_text(): verse_def = None for slide in item.get_frames(): if not verse_def or verse_def != slide[u'verseTag']: - text_div = self._addElement(u'div', parent=div, - classId=u'itemText') + text_div = self._addElement(u'div', parent=div, classId=u'itemText') else: self._addElement(u'br', parent=text_div) self._addElement(u'span', slide[u'html'], text_div) @@ -232,26 +212,22 @@ class PrintServiceForm(QtGui.QDialog, Ui_PrintServiceDialog): foot_text = foot_text.partition(u'
')[2] if foot_text: foot_text = cgi.escape(foot_text.replace(u'
', u'\n')) - self._addElement(u'div', foot_text.replace(u'\n', u'
'), - parent=div, classId=u'itemFooter') + self._addElement(u'div', foot_text.replace(u'\n', u'
'), parent=div, classId=u'itemFooter') # Add service items' notes. if self.notesCheckBox.isChecked(): if item.notes: p = self._addElement(u'div', classId=u'itemNotes', parent=div) - self._addElement(u'span', - translate('OpenLP.ServiceManager', 'Notes: '), p, + self._addElement(u'span', translate('OpenLP.ServiceManager', 'Notes: '), p, classId=u'itemNotesTitle') - self._addElement(u'span', - cgi.escape(item.notes).replace(u'\n', u'
'), p, - classId=u'itemNotesText') + self._addElement(u'span', cgi.escape(item.notes).replace(u'\n', u'
'), p, classId=u'itemNotesText') # Add play length of media files. if item.is_media() and self.metaDataCheckBox.isChecked(): tme = item.media_length if item.end_time > 0: tme = item.end_time - item.start_time title = self._addElement(u'div', classId=u'media', parent=div) - self._addElement(u'span', translate('OpenLP.ServiceManager', - 'Playing time: '), title, classId=u'mediaTitle') + self._addElement(u'span', translate('OpenLP.ServiceManager', 'Playing time: '), title, + classId=u'mediaTitle') self._addElement(u'span', unicode(datetime.timedelta(seconds=tme)), title, classId=u'mediaText') @@ -407,12 +383,9 @@ class PrintServiceForm(QtGui.QDialog, Ui_PrintServiceDialog): # Save the settings for this dialog. settings = Settings() settings.beginGroup(u'advanced') - settings.setValue(u'print slide text', - self.slideTextCheckBox.isChecked()) - settings.setValue(u'add page break', - self.pageBreakAfterText.isChecked()) - settings.setValue(u'print file meta data', - self.metaDataCheckBox.isChecked()) + settings.setValue(u'print slide text', self.slideTextCheckBox.isChecked()) + settings.setValue(u'add page break', self.pageBreakAfterText.isChecked()) + settings.setValue(u'print file meta data', self.metaDataCheckBox.isChecked()) settings.setValue(u'print notes', self.notesCheckBox.isChecked()) settings.endGroup() @@ -422,5 +395,4 @@ class PrintServiceForm(QtGui.QDialog, Ui_PrintServiceDialog): return for item in self.serviceManager.serviceItems: # Trigger Audit requests - Receiver.send_message(u'print_service_started', - [item[u'service_item']]) + Receiver.send_message(u'print_service_started', [item[u'service_item']]) diff --git a/openlp/core/ui/screen.py b/openlp/core/ui/screen.py index 87c603dbb..6ac7d8c9a 100644 --- a/openlp/core/ui/screen.py +++ b/openlp/core/ui/screen.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 ############################################################################### # OpenLP - Open Source Lyrics Projection # @@ -70,12 +70,8 @@ class ScreenList(object): screen_list.display_count = 0 screen_list.screen_count_changed() screen_list._load_screen_settings() - QtCore.QObject.connect(desktop, - QtCore.SIGNAL(u'resized(int)'), - screen_list.screen_resolution_changed) - QtCore.QObject.connect(desktop, - QtCore.SIGNAL(u'screenCountChanged(int)'), - screen_list.screen_count_changed) + QtCore.QObject.connect(desktop, QtCore.SIGNAL(u'resized(int)'), screen_list.screen_resolution_changed) + QtCore.QObject.connect(desktop, QtCore.SIGNAL(u'screenCountChanged(int)'), screen_list.screen_count_changed) return screen_list def screen_resolution_changed(self, number): @@ -142,8 +138,7 @@ class ScreenList(object): screen_name = u'%s %d' % (translate('OpenLP.ScreenList', 'Screen'), screen[u'number'] + 1) if screen[u'primary']: - screen_name = u'%s (%s)' % (screen_name, - translate('OpenLP.ScreenList', 'primary')) + screen_name = u'%s (%s)' % (screen_name, translate('OpenLP.ScreenList', 'primary')) screen_list.append(screen_name) return screen_list @@ -160,8 +155,7 @@ class ScreenList(object): u'size': PyQt4.QtCore.QRect(0, 0, 1024, 768) } """ - log.info(u'Screen %d found with resolution %s', - screen[u'number'], screen[u'size']) + log.info(u'Screen %d found with resolution %s', screen[u'number'], screen[u'size']) if screen[u'primary']: self.current = screen self.override = copy.deepcopy(self.current) @@ -249,8 +243,7 @@ class ScreenList(object): """ settings = Settings() settings.beginGroup(u'general') - self.set_current_display(settings.value(u'monitor', - self.display_count - 1)) + self.set_current_display(settings.value(u'monitor', self.display_count - 1)) self.display = settings.value(u'display on monitor', True) override_display = settings.value(u'override position', False) x = settings.value(u'x position', self.current[u'size'].x()) diff --git a/openlp/core/ui/serviceitemeditdialog.py b/openlp/core/ui/serviceitemeditdialog.py index afe1e6cdb..725a5efea 100644 --- a/openlp/core/ui/serviceitemeditdialog.py +++ b/openlp/core/ui/serviceitemeditdialog.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 ############################################################################### # OpenLP - Open Source Lyrics Projection # @@ -45,23 +45,20 @@ class Ui_ServiceItemEditDialog(object): self.dialogLayout.addWidget(self.listWidget, 0, 0) self.buttonLayout = QtGui.QVBoxLayout() self.buttonLayout.setObjectName(u'buttonLayout') - self.deleteButton = create_button(serviceItemEditDialog, - u'deleteButton', role=u'delete', + self.deleteButton = create_button(serviceItemEditDialog, u'deleteButton', role=u'delete', click=serviceItemEditDialog.onDeleteButtonClicked) self.buttonLayout.addWidget(self.deleteButton) self.buttonLayout.addStretch() - self.upButton = create_button(serviceItemEditDialog, u'upButton', - role=u'up', click=serviceItemEditDialog.onUpButtonClicked) - self.downButton = create_button(serviceItemEditDialog, u'downButton', - role=u'down', click=serviceItemEditDialog.onDownButtonClicked) + self.upButton = create_button(serviceItemEditDialog, u'upButton', role=u'up', + click=serviceItemEditDialog.onUpButtonClicked) + self.downButton = create_button(serviceItemEditDialog, u'downButton', role=u'down', + click=serviceItemEditDialog.onDownButtonClicked) self.buttonLayout.addWidget(self.upButton) self.buttonLayout.addWidget(self.downButton) self.dialogLayout.addLayout(self.buttonLayout, 0, 1) - self.buttonBox = create_button_box(serviceItemEditDialog, u'buttonBox', - [u'cancel', u'save']) + self.buttonBox = create_button_box(serviceItemEditDialog, u'buttonBox', [u'cancel', u'save']) self.dialogLayout.addWidget(self.buttonBox, 1, 0, 1, 2) self.retranslateUi(serviceItemEditDialog) def retranslateUi(self, serviceItemEditDialog): - serviceItemEditDialog.setWindowTitle( - translate('OpenLP.ServiceItemEditForm', 'Reorder Service Item')) + serviceItemEditDialog.setWindowTitle(translate('OpenLP.ServiceItemEditForm', 'Reorder Service Item')) diff --git a/openlp/core/ui/serviceitemeditform.py b/openlp/core/ui/serviceitemeditform.py index 292054782..071cd88a9 100644 --- a/openlp/core/ui/serviceitemeditform.py +++ b/openlp/core/ui/serviceitemeditform.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 ############################################################################### # OpenLP - Open Source Lyrics Projection # @@ -42,8 +42,7 @@ class ServiceItemEditForm(QtGui.QDialog, Ui_ServiceItemEditDialog): QtGui.QDialog.__init__(self, parent) self.setupUi(self) self.itemList = [] - QtCore.QObject.connect(self.listWidget, - QtCore.SIGNAL(u'currentRowChanged(int)'), self.onCurrentRowChanged) + QtCore.QObject.connect(self.listWidget, QtCore.SIGNAL(u'currentRowChanged(int)'), self.onCurrentRowChanged) def setServiceItem(self, item): self.item = item diff --git a/openlp/core/ui/servicenoteform.py b/openlp/core/ui/servicenoteform.py index e2bc3ed57..f5343f156 100644 --- a/openlp/core/ui/servicenoteform.py +++ b/openlp/core/ui/servicenoteform.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 ############################################################################### # OpenLP - Open Source Lyrics Projection # @@ -57,10 +57,8 @@ class ServiceNoteForm(QtGui.QDialog): self.textEdit = SpellTextEdit(self, False) self.textEdit.setObjectName(u'textEdit') self.dialogLayout.addWidget(self.textEdit) - self.buttonBox = create_button_box(self, u'buttonBox', - [u'cancel', u'save']) + self.buttonBox = create_button_box(self, u'buttonBox', [u'cancel', u'save']) self.dialogLayout.addWidget(self.buttonBox) def retranslateUi(self): - self.setWindowTitle( - translate('OpenLP.ServiceNoteForm', 'Service Item Notes')) + self.setWindowTitle(translate('OpenLP.ServiceNoteForm', 'Service Item Notes')) diff --git a/openlp/core/ui/settingsdialog.py b/openlp/core/ui/settingsdialog.py index baee8bc38..0c50b066e 100644 --- a/openlp/core/ui/settingsdialog.py +++ b/openlp/core/ui/settingsdialog.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 ############################################################################### # OpenLP - Open Source Lyrics Projection # @@ -36,29 +36,23 @@ class Ui_SettingsDialog(object): def setupUi(self, settingsDialog): settingsDialog.setObjectName(u'settingsDialog') settingsDialog.resize(800, 500) - settingsDialog.setWindowIcon( - build_icon(u':/system/system_settings.png')) + settingsDialog.setWindowIcon(build_icon(u':/system/system_settings.png')) self.dialogLayout = QtGui.QGridLayout(settingsDialog) self.dialogLayout.setObjectName(u'dialogLayout') self.dialogLayout.setMargin(8) self.settingListWidget = QtGui.QListWidget(settingsDialog) self.settingListWidget.setUniformItemSizes(True) self.settingListWidget.setMinimumSize(QtCore.QSize(150, 0)) - self.settingListWidget.setHorizontalScrollBarPolicy( - QtCore.Qt.ScrollBarAlwaysOff) + self.settingListWidget.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) self.settingListWidget.setObjectName(u'settingListWidget') self.dialogLayout.addWidget(self.settingListWidget, 0, 0, 1, 1) self.stackedLayout = QtGui.QStackedLayout() self.stackedLayout.setObjectName(u'stackedLayout') self.dialogLayout.addLayout(self.stackedLayout, 0, 1, 1, 1) - self.buttonBox = create_button_box(settingsDialog, u'buttonBox', - [u'cancel', u'ok']) + self.buttonBox = create_button_box(settingsDialog, u'buttonBox', [u'cancel', u'ok']) self.dialogLayout.addWidget(self.buttonBox, 1, 1, 1, 1) self.retranslateUi(settingsDialog) - QtCore.QObject.connect(self.settingListWidget, - QtCore.SIGNAL(u'currentRowChanged(int)'), - self.tabChanged) + QtCore.QObject.connect(self.settingListWidget, QtCore.SIGNAL(u'currentRowChanged(int)'), self.tabChanged) def retranslateUi(self, settingsDialog): - settingsDialog.setWindowTitle(translate('OpenLP.SettingsForm', - 'Configure OpenLP')) + settingsDialog.setWindowTitle(translate('OpenLP.SettingsForm', 'Configure OpenLP')) diff --git a/openlp/core/ui/settingsform.py b/openlp/core/ui/settingsform.py index 570adce42..2be59318e 100644 --- a/openlp/core/ui/settingsform.py +++ b/openlp/core/ui/settingsform.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 ############################################################################### # OpenLP - Open Source Lyrics Projection # diff --git a/openlp/core/ui/shortcutlistdialog.py b/openlp/core/ui/shortcutlistdialog.py index 9522ac227..84ed2ce92 100644 --- a/openlp/core/ui/shortcutlistdialog.py +++ b/openlp/core/ui/shortcutlistdialog.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 ############################################################################### # OpenLP - Open Source Lyrics Projection # @@ -81,27 +81,23 @@ class Ui_ShortcutListDialog(object): self.primaryPushButton = CaptureShortcutButton(shortcutListDialog) self.primaryPushButton.setObjectName(u'primaryPushButton') self.primaryPushButton.setMinimumSize(QtCore.QSize(84, 0)) - self.primaryPushButton.setIcon( - build_icon(u':/system/system_configure_shortcuts.png')) + self.primaryPushButton.setIcon(build_icon(u':/system/system_configure_shortcuts.png')) self.primaryLayout.addWidget(self.primaryPushButton) self.clearPrimaryButton = QtGui.QToolButton(shortcutListDialog) self.clearPrimaryButton.setObjectName(u'clearPrimaryButton') self.clearPrimaryButton.setMinimumSize(QtCore.QSize(0, 16)) - self.clearPrimaryButton.setIcon( - build_icon(u':/system/clear_shortcut.png')) + self.clearPrimaryButton.setIcon(build_icon(u':/system/clear_shortcut.png')) self.primaryLayout.addWidget(self.clearPrimaryButton) self.detailsLayout.addLayout(self.primaryLayout, 1, 1, 1, 1) self.alternateLayout = QtGui.QHBoxLayout() self.alternateLayout.setObjectName(u'alternateLayout') self.alternatePushButton = CaptureShortcutButton(shortcutListDialog) self.alternatePushButton.setObjectName(u'alternatePushButton') - self.alternatePushButton.setIcon( - build_icon(u':/system/system_configure_shortcuts.png')) + self.alternatePushButton.setIcon(build_icon(u':/system/system_configure_shortcuts.png')) self.alternateLayout.addWidget(self.alternatePushButton) self.clearAlternateButton = QtGui.QToolButton(shortcutListDialog) self.clearAlternateButton.setObjectName(u'clearAlternateButton') - self.clearAlternateButton.setIcon( - build_icon(u':/system/clear_shortcut.png')) + self.clearAlternateButton.setIcon(build_icon(u':/system/clear_shortcut.png')) self.alternateLayout.addWidget(self.clearAlternateButton) self.detailsLayout.addLayout(self.alternateLayout, 1, 2, 1, 1) self.primaryLabel = QtGui.QLabel(shortcutListDialog) @@ -111,33 +107,24 @@ class Ui_ShortcutListDialog(object): self.alternateLabel.setObjectName(u'alternateLabel') self.detailsLayout.addWidget(self.alternateLabel, 0, 2, 1, 1) self.shortcutListLayout.addLayout(self.detailsLayout) - self.buttonBox = create_button_box(shortcutListDialog, u'buttonBox', - [u'cancel', u'ok', u'defaults']) + self.buttonBox = create_button_box(shortcutListDialog, u'buttonBox', [u'cancel', u'ok', u'defaults']) self.buttonBox.setOrientation(QtCore.Qt.Horizontal) self.shortcutListLayout.addWidget(self.buttonBox) self.retranslateUi(shortcutListDialog) def retranslateUi(self, shortcutListDialog): - shortcutListDialog.setWindowTitle( - translate('OpenLP.ShortcutListDialog', 'Configure Shortcuts')) - self.descriptionLabel.setText(translate('OpenLP.ShortcutListDialog', - 'Select an action and click one of the buttons below to start ' - 'capturing a new primary or alternate shortcut, respectively.')) - self.treeWidget.setHeaderLabels([ - translate('OpenLP.ShortcutListDialog', 'Action'), + shortcutListDialog.setWindowTitle(translate('OpenLP.ShortcutListDialog', 'Configure Shortcuts')) + self.descriptionLabel.setText( + translate('OpenLP.ShortcutListDialog', 'Select an action and click one of the buttons below to start ' + 'capturing a new primary or alternate shortcut, respectively.')) + self.treeWidget.setHeaderLabels([translate('OpenLP.ShortcutListDialog', 'Action'), translate('OpenLP.ShortcutListDialog', 'Shortcut'), translate('OpenLP.ShortcutListDialog', 'Alternate')]) - self.defaultRadioButton.setText( - translate('OpenLP.ShortcutListDialog', 'Default')) - self.customRadioButton.setText( - translate('OpenLP.ShortcutListDialog', 'Custom')) - self.primaryPushButton.setToolTip( - translate('OpenLP.ShortcutListDialog', 'Capture shortcut.')) - self.alternatePushButton.setToolTip( - translate('OpenLP.ShortcutListDialog', 'Capture shortcut.')) - self.clearPrimaryButton.setToolTip( - translate('OpenLP.ShortcutListDialog', + self.defaultRadioButton.setText(translate('OpenLP.ShortcutListDialog', 'Default')) + self.customRadioButton.setText(translate('OpenLP.ShortcutListDialog', 'Custom')) + self.primaryPushButton.setToolTip(translate('OpenLP.ShortcutListDialog', 'Capture shortcut.')) + self.alternatePushButton.setToolTip(translate('OpenLP.ShortcutListDialog', 'Capture shortcut.')) + self.clearPrimaryButton.setToolTip(translate('OpenLP.ShortcutListDialog', 'Restore the default shortcut of this action.')) - self.clearAlternateButton.setToolTip( - translate('OpenLP.ShortcutListDialog', + self.clearAlternateButton.setToolTip(translate('OpenLP.ShortcutListDialog', 'Restore the default shortcut of this action.')) diff --git a/openlp/core/ui/shortcutlistform.py b/openlp/core/ui/shortcutlistform.py index d43c69b67..6f4358b4f 100644 --- a/openlp/core/ui/shortcutlistform.py +++ b/openlp/core/ui/shortcutlistform.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 ############################################################################### # OpenLP - Open Source Lyrics Projection # @@ -51,57 +51,49 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): self.setupUi(self) self.changedActions = {} self.action_list = ActionList.get_instance() - QtCore.QObject.connect(self.primaryPushButton, - QtCore.SIGNAL(u'toggled(bool)'), self.onPrimaryPushButtonClicked) - QtCore.QObject.connect(self.alternatePushButton, - QtCore.SIGNAL(u'toggled(bool)'), self.onAlternatePushButtonClicked) - QtCore.QObject.connect(self.treeWidget, QtCore.SIGNAL( - u'currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)'), - self.onCurrentItemChanged) + QtCore.QObject.connect(self.primaryPushButton, QtCore.SIGNAL(u'toggled(bool)'), + self.onPrimaryPushButtonClicked) + QtCore.QObject.connect(self.alternatePushButton, QtCore.SIGNAL(u'toggled(bool)'), + self.onAlternatePushButtonClicked) QtCore.QObject.connect(self.treeWidget, - QtCore.SIGNAL(u'itemDoubleClicked(QTreeWidgetItem*, int)'), + QtCore.SIGNAL(u'currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)'), self.onCurrentItemChanged) + QtCore.QObject.connect(self.treeWidget, QtCore.SIGNAL(u'itemDoubleClicked(QTreeWidgetItem*, int)'), self.onItemDoubleClicked) - QtCore.QObject.connect(self.clearPrimaryButton, - QtCore.SIGNAL(u'clicked(bool)'), self.onClearPrimaryButtonClicked) - QtCore.QObject.connect(self.clearAlternateButton, - QtCore.SIGNAL(u'clicked(bool)'), self.onClearAlternateButtonClicked) - QtCore.QObject.connect(self.buttonBox, - QtCore.SIGNAL(u'clicked(QAbstractButton*)'), + QtCore.QObject.connect(self.clearPrimaryButton, QtCore.SIGNAL(u'clicked(bool)'), + self.onClearPrimaryButtonClicked) + QtCore.QObject.connect(self.clearAlternateButton, QtCore.SIGNAL(u'clicked(bool)'), + self.onClearAlternateButtonClicked) + QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(u'clicked(QAbstractButton*)'), self.onRestoreDefaultsClicked) - QtCore.QObject.connect(self.defaultRadioButton, - QtCore.SIGNAL(u'clicked(bool)'), self.onDefaultRadioButtonClicked) - QtCore.QObject.connect(self.customRadioButton, - QtCore.SIGNAL(u'clicked(bool)'), self.onCustomRadioButtonClicked) + QtCore.QObject.connect(self.defaultRadioButton, QtCore.SIGNAL(u'clicked(bool)'), + self.onDefaultRadioButtonClicked) + QtCore.QObject.connect(self.customRadioButton, QtCore.SIGNAL(u'clicked(bool)'), + self.onCustomRadioButtonClicked) def keyPressEvent(self, event): if event.key() == QtCore.Qt.Key_Space: self.keyReleaseEvent(event) - elif self.primaryPushButton.isChecked() or \ - self.alternatePushButton.isChecked(): + elif self.primaryPushButton.isChecked() or self.alternatePushButton.isChecked(): event.ignore() elif event.key() == QtCore.Qt.Key_Escape: event.accept() self.close() def keyReleaseEvent(self, event): - if not self.primaryPushButton.isChecked() and \ - not self.alternatePushButton.isChecked(): + if not self.primaryPushButton.isChecked() and not self.alternatePushButton.isChecked(): return key = event.key() if key == QtCore.Qt.Key_Shift or key == QtCore.Qt.Key_Control or \ key == QtCore.Qt.Key_Meta or key == QtCore.Qt.Key_Alt: return key_string = QtGui.QKeySequence(key).toString() - if event.modifiers() & QtCore.Qt.ControlModifier == \ - QtCore.Qt.ControlModifier: + if event.modifiers() & QtCore.Qt.ControlModifier == QtCore.Qt.ControlModifier: key_string = u'Ctrl+' + key_string if event.modifiers() & QtCore.Qt.AltModifier == QtCore.Qt.AltModifier: key_string = u'Alt+' + key_string - if event.modifiers() & QtCore.Qt.ShiftModifier == \ - QtCore.Qt.ShiftModifier: + if event.modifiers() & QtCore.Qt.ShiftModifier == QtCore.Qt.ShiftModifier: key_string = u'Shift+' + key_string - if event.modifiers() & QtCore.Qt.MetaModifier == \ - QtCore.Qt.MetaModifier: + if event.modifiers() & QtCore.Qt.MetaModifier == QtCore.Qt.MetaModifier: key_string = u'Meta+' + key_string key_sequence = QtGui.QKeySequence(key_string) if self._validiate_shortcut(self._currentItemAction(), key_sequence): @@ -272,8 +264,7 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): # been triggered by a signal. if item is None: return - if primary_label_text == primary_text and \ - alternate_label_text == alternate_text: + if primary_label_text == primary_text and alternate_label_text == alternate_text: self.defaultRadioButton.toggle() else: self.customRadioButton.toggle() @@ -282,15 +273,12 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): """ Restores all default shortcuts. """ - if self.buttonBox.buttonRole(button) != \ - QtGui.QDialogButtonBox.ResetRole: + if self.buttonBox.buttonRole(button) != QtGui.QDialogButtonBox.ResetRole: return - if QtGui.QMessageBox.question(self, - translate('OpenLP.ShortcutListDialog', 'Restore Default Shortcuts'), + if QtGui.QMessageBox.question(self, translate('OpenLP.ShortcutListDialog', 'Restore Default Shortcuts'), translate('OpenLP.ShortcutListDialog', 'Do you want to restore all ' - 'shortcuts to their defaults?'), QtGui.QMessageBox.StandardButtons( - QtGui.QMessageBox.Yes | - QtGui.QMessageBox.No)) == QtGui.QMessageBox.No: + 'shortcuts to their defaults?'), + QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes | QtGui.QMessageBox.No)) == QtGui.QMessageBox.No: return self._adjustButton(self.primaryPushButton, False, text=u'') self._adjustButton(self.alternatePushButton, False, text=u'') @@ -372,8 +360,7 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): # shortcut (not the default one) will become primary shortcut, thus # the check will assume that an action were going to have the same # shortcut twice. - if not self._validiate_shortcut(action, new_shortcuts[0]) and \ - new_shortcuts[0] != shortcuts[0]: + if not self._validiate_shortcut(action, new_shortcuts[0]) and new_shortcuts[0] != shortcuts[0]: return if len(shortcuts) == 2: new_shortcuts.append(shortcuts[1]) @@ -421,11 +408,9 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): if key_sequence not in shortcuts: continue if action is changing_action: - if self.primaryPushButton.isChecked() and \ - shortcuts.index(key_sequence) == 0: + if self.primaryPushButton.isChecked() and shortcuts.index(key_sequence) == 0: continue - if self.alternatePushButton.isChecked() and \ - shortcuts.index(key_sequence) == 1: + if self.alternatePushButton.isChecked() and shortcuts.index(key_sequence) == 1: continue # Have the same parent, thus they cannot have the same shortcut. if action.parent() is changing_action.parent(): @@ -436,16 +421,14 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): if action.shortcutContext() in [QtCore.Qt.WindowShortcut, QtCore.Qt.ApplicationShortcut]: is_valid = False - if changing_action.shortcutContext() in \ - [QtCore.Qt.WindowShortcut, QtCore.Qt.ApplicationShortcut]: + if changing_action.shortcutContext() in [QtCore.Qt.WindowShortcut, QtCore.Qt.ApplicationShortcut]: is_valid = False if not is_valid: Receiver.send_message(u'openlp_warning_message', { - u'title': translate('OpenLP.ShortcutListDialog', - 'Duplicate Shortcut'), + u'title': translate('OpenLP.ShortcutListDialog', 'Duplicate Shortcut'), u'message': translate('OpenLP.ShortcutListDialog', - 'The shortcut "%s" is already assigned to another action, ' - 'please use a different shortcut.') % key_sequence.toString() + 'The shortcut "%s" is already assigned to another action, ' + 'please use a different shortcut.') % key_sequence.toString() }) return is_valid diff --git a/openlp/core/ui/splashscreen.py b/openlp/core/ui/splashscreen.py index 2af80e6fe..89c8cae76 100644 --- a/openlp/core/ui/splashscreen.py +++ b/openlp/core/ui/splashscreen.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 ############################################################################### # OpenLP - Open Source Lyrics Projection # @@ -34,8 +34,7 @@ class SplashScreen(QtGui.QSplashScreen): def __init__(self): QtGui.QSplashScreen.__init__(self) self.setupUi() - QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'close_splash'), self.close) + QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'close_splash'), self.close) def setupUi(self): self.setObjectName(u'splashScreen') From 4f2f6f73aa073ef957ae3b6fe9b8e701760e2d74 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sat, 29 Dec 2012 15:25:29 +0000 Subject: [PATCH 52/53] Completed core conversion --- openlp/core/lib/formattingtags.py | 5 +- openlp/core/ui/formattingtagdialog.py | 50 ++--- openlp/core/ui/formattingtagform.py | 50 ++--- openlp/core/ui/starttimedialog.py | 8 +- openlp/core/ui/starttimeform.py | 31 +-- openlp/core/ui/themeform.py | 296 +++++++++----------------- openlp/core/ui/themelayoutdialog.py | 14 +- openlp/core/ui/themelayoutform.py | 2 +- openlp/core/ui/thememanager.py | 178 ++++++---------- openlp/core/ui/themestab.py | 73 +++---- openlp/core/ui/themewizard.py | 250 ++++++++-------------- openlp/core/ui/wizard.py | 30 +-- 12 files changed, 338 insertions(+), 649 deletions(-) diff --git a/openlp/core/lib/formattingtags.py b/openlp/core/lib/formattingtags.py index c74b81d4d..73fe272dc 100644 --- a/openlp/core/lib/formattingtags.py +++ b/openlp/core/lib/formattingtags.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 ############################################################################### # OpenLP - Open Source Lyrics Projection # @@ -69,8 +69,7 @@ class FormattingTags(object): if isinstance(tag[element], unicode): tag[element] = tag[element].encode('utf8') # Formatting Tags were also known as display tags. - Settings().setValue(u'displayTags/html_tags', - cPickle.dumps(tags) if tags else u'') + Settings().setValue(u'displayTags/html_tags', cPickle.dumps(tags) if tags else u'') @staticmethod def load_tags(): diff --git a/openlp/core/ui/formattingtagdialog.py b/openlp/core/ui/formattingtagdialog.py index 0f08c95a2..8d1f73860 100644 --- a/openlp/core/ui/formattingtagdialog.py +++ b/openlp/core/ui/formattingtagdialog.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 ############################################################################### # OpenLP - Open Source Lyrics Projection # @@ -41,15 +41,11 @@ class Ui_FormattingTagDialog(object): self.listdataGridLayout.setMargin(8) self.listdataGridLayout.setObjectName(u'listdataGridLayout') self.tagTableWidget = QtGui.QTableWidget(formattingTagDialog) - self.tagTableWidget.setHorizontalScrollBarPolicy( - QtCore.Qt.ScrollBarAlwaysOff) - self.tagTableWidget.setEditTriggers( - QtGui.QAbstractItemView.NoEditTriggers) + self.tagTableWidget.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) + self.tagTableWidget.setEditTriggers(QtGui.QAbstractItemView.NoEditTriggers) self.tagTableWidget.setAlternatingRowColors(True) - self.tagTableWidget.setSelectionMode( - QtGui.QAbstractItemView.SingleSelection) - self.tagTableWidget.setSelectionBehavior( - QtGui.QAbstractItemView.SelectRows) + self.tagTableWidget.setSelectionMode(QtGui.QAbstractItemView.SingleSelection) + self.tagTableWidget.setSelectionBehavior(QtGui.QAbstractItemView.SelectRows) self.tagTableWidget.setCornerButtonEnabled(False) self.tagTableWidget.setObjectName(u'tagTableWidget') self.tagTableWidget.setColumnCount(4) @@ -66,8 +62,7 @@ class Ui_FormattingTagDialog(object): self.listdataGridLayout.addWidget(self.tagTableWidget, 0, 0, 1, 1) self.horizontalLayout = QtGui.QHBoxLayout() self.horizontalLayout.setObjectName(u'horizontalLayout') - spacerItem = QtGui.QSpacerItem(40, 20, - QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) + spacerItem = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) self.horizontalLayout.addItem(spacerItem) self.deletePushButton = QtGui.QPushButton(formattingTagDialog) self.deletePushButton.setObjectName(u'deletePushButton') @@ -114,36 +109,25 @@ class Ui_FormattingTagDialog(object): self.savePushButton.setObjectName(u'savePushButton') self.dataGridLayout.addWidget(self.savePushButton, 4, 2, 1, 1) self.listdataGridLayout.addWidget(self.editGroupBox, 2, 0, 1, 1) - self.buttonBox = create_button_box(formattingTagDialog, 'buttonBox', - [u'close']) + self.buttonBox = create_button_box(formattingTagDialog, u'buttonBox', [u'close']) self.listdataGridLayout.addWidget(self.buttonBox, 3, 0, 1, 1) self.retranslateUi(formattingTagDialog) def retranslateUi(self, formattingTagDialog): - formattingTagDialog.setWindowTitle(translate( - 'OpenLP.FormattingTagDialog', 'Configure Formatting Tags')) - self.editGroupBox.setTitle( - translate('OpenLP.FormattingTagDialog', 'Edit Selection')) - self.savePushButton.setText( - translate('OpenLP.FormattingTagDialog', 'Save')) - self.descriptionLabel.setText( - translate('OpenLP.FormattingTagDialog', 'Description')) + formattingTagDialog.setWindowTitle(translate('OpenLP.FormattingTagDialog', 'Configure Formatting Tags')) + self.editGroupBox.setTitle(translate('OpenLP.FormattingTagDialog', 'Edit Selection')) + self.savePushButton.setText(translate('OpenLP.FormattingTagDialog', 'Save')) + self.descriptionLabel.setText(translate('OpenLP.FormattingTagDialog', 'Description')) self.tagLabel.setText(translate('OpenLP.FormattingTagDialog', 'Tag')) - self.startTagLabel.setText( - translate('OpenLP.FormattingTagDialog', 'Start HTML')) - self.endTagLabel.setText( - translate('OpenLP.FormattingTagDialog', 'End HTML')) + self.startTagLabel.setText(translate('OpenLP.FormattingTagDialog', 'Start HTML')) + self.endTagLabel.setText(translate('OpenLP.FormattingTagDialog', 'End HTML')) self.deletePushButton.setText(UiStrings().Delete) self.newPushButton.setText(UiStrings().New) - self.tagTableWidget.horizontalHeaderItem(0).setText( - translate('OpenLP.FormattingTagDialog', 'Description')) - self.tagTableWidget.horizontalHeaderItem(1).setText( - translate('OpenLP.FormattingTagDialog', 'Tag')) - self.tagTableWidget.horizontalHeaderItem(2).setText( - translate('OpenLP.FormattingTagDialog', 'Start HTML')) - self.tagTableWidget.horizontalHeaderItem(3).setText( - translate('OpenLP.FormattingTagDialog', 'End HTML')) + self.tagTableWidget.horizontalHeaderItem(0).setText(translate('OpenLP.FormattingTagDialog', 'Description')) + self.tagTableWidget.horizontalHeaderItem(1).setText(translate('OpenLP.FormattingTagDialog', 'Tag')) + self.tagTableWidget.horizontalHeaderItem(2).setText(translate('OpenLP.FormattingTagDialog', 'Start HTML')) + self.tagTableWidget.horizontalHeaderItem(3).setText(translate('OpenLP.FormattingTagDialog', 'End HTML')) self.tagTableWidget.setColumnWidth(0, 120) self.tagTableWidget.setColumnWidth(1, 80) self.tagTableWidget.setColumnWidth(2, 330) diff --git a/openlp/core/ui/formattingtagform.py b/openlp/core/ui/formattingtagform.py index 50521675f..fc81f22da 100644 --- a/openlp/core/ui/formattingtagform.py +++ b/openlp/core/ui/formattingtagform.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 ############################################################################### # OpenLP - Open Source Lyrics Projection # @@ -49,24 +49,15 @@ class FormattingTagForm(QtGui.QDialog, Ui_FormattingTagDialog): """ QtGui.QDialog.__init__(self, parent) self.setupUi(self) - QtCore.QObject.connect(self.tagTableWidget, - QtCore.SIGNAL(u'itemSelectionChanged()'),self.onRowSelected) - QtCore.QObject.connect(self.newPushButton, - QtCore.SIGNAL(u'clicked()'), self.onNewClicked) - QtCore.QObject.connect(self.savePushButton, - QtCore.SIGNAL(u'clicked()'), self.onSavedClicked) - QtCore.QObject.connect(self.deletePushButton, - QtCore.SIGNAL(u'clicked()'), self.onDeleteClicked) - QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(u'rejected()'), - self.close) - QtCore.QObject.connect(self.descriptionLineEdit, - QtCore.SIGNAL(u'textEdited(QString)'), self.onTextEdited) - QtCore.QObject.connect(self.tagLineEdit, - QtCore.SIGNAL(u'textEdited(QString)'), self.onTextEdited) - QtCore.QObject.connect(self.startTagLineEdit, - QtCore.SIGNAL(u'textEdited(QString)'), self.onTextEdited) - QtCore.QObject.connect(self.endTagLineEdit, - QtCore.SIGNAL(u'textEdited(QString)'), self.onTextEdited) + QtCore.QObject.connect(self.tagTableWidget, QtCore.SIGNAL(u'itemSelectionChanged()'),self.onRowSelected) + QtCore.QObject.connect(self.newPushButton, QtCore.SIGNAL(u'clicked()'), self.onNewClicked) + QtCore.QObject.connect(self.savePushButton, QtCore.SIGNAL(u'clicked()'), self.onSavedClicked) + QtCore.QObject.connect(self.deletePushButton, QtCore.SIGNAL(u'clicked()'), self.onDeleteClicked) + QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(u'rejected()'), self.close) + QtCore.QObject.connect(self.descriptionLineEdit, QtCore.SIGNAL(u'textEdited(QString)'), self.onTextEdited) + QtCore.QObject.connect(self.tagLineEdit, QtCore.SIGNAL(u'textEdited(QString)'), self.onTextEdited) + QtCore.QObject.connect(self.startTagLineEdit, QtCore.SIGNAL(u'textEdited(QString)'), self.onTextEdited) + QtCore.QObject.connect(self.endTagLineEdit, QtCore.SIGNAL(u'textEdited(QString)'), self.onTextEdited) # Forces reloading of tags from openlp configuration. FormattingTags.load_tags() @@ -118,8 +109,7 @@ class FormattingTagForm(QtGui.QDialog, Ui_FormattingTagDialog): if self._strip(html[u'start tag']) == u'n': critical_error_message_box( translate('OpenLP.FormattingTagForm', 'Update Error'), - translate('OpenLP.FormattingTagForm', - 'Tag "n" already defined.')) + translate('OpenLP.FormattingTagForm', 'Tag "n" already defined.')) return # Add new tag to list tag = { @@ -162,12 +152,10 @@ class FormattingTagForm(QtGui.QDialog, Ui_FormattingTagDialog): html = html_expands[self.selected] tag = self.tagLineEdit.text() for linenumber, html1 in enumerate(html_expands): - if self._strip(html1[u'start tag']) == tag and \ - linenumber != self.selected: + if self._strip(html1[u'start tag']) == tag and linenumber != self.selected: critical_error_message_box( translate('OpenLP.FormattingTagForm', 'Update Error'), - translate('OpenLP.FormattingTagForm', - 'Tag %s already defined.') % tag) + translate('OpenLP.FormattingTagForm', 'Tag %s already defined.') % tag) return html[u'desc'] = self.descriptionLineEdit.text() html[u'start html'] = self.startTagLineEdit.text() @@ -191,14 +179,10 @@ class FormattingTagForm(QtGui.QDialog, Ui_FormattingTagDialog): self.deletePushButton.setEnabled(False) for linenumber, html in enumerate(FormattingTags.get_html_tags()): self.tagTableWidget.setRowCount(self.tagTableWidget.rowCount() + 1) - self.tagTableWidget.setItem(linenumber, 0, - QtGui.QTableWidgetItem(html[u'desc'])) - self.tagTableWidget.setItem(linenumber, 1, - QtGui.QTableWidgetItem(self._strip(html[u'start tag']))) - self.tagTableWidget.setItem(linenumber, 2, - QtGui.QTableWidgetItem(html[u'start html'])) - self.tagTableWidget.setItem(linenumber, 3, - QtGui.QTableWidgetItem(html[u'end html'])) + self.tagTableWidget.setItem(linenumber, 0, QtGui.QTableWidgetItem(html[u'desc'])) + self.tagTableWidget.setItem(linenumber, 1, QtGui.QTableWidgetItem(self._strip(html[u'start tag']))) + self.tagTableWidget.setItem(linenumber, 2, QtGui.QTableWidgetItem(html[u'start html'])) + self.tagTableWidget.setItem(linenumber, 3, QtGui.QTableWidgetItem(html[u'end html'])) # Permanent (persistent) tags do not have this key. if u'temporary' not in html: html[u'temporary'] = False diff --git a/openlp/core/ui/starttimedialog.py b/openlp/core/ui/starttimedialog.py index 8ae448b59..e7738576b 100644 --- a/openlp/core/ui/starttimedialog.py +++ b/openlp/core/ui/starttimedialog.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 ############################################################################### # OpenLP - Open Source Lyrics Projection # @@ -101,15 +101,13 @@ class Ui_StartTimeDialog(object): self.secondFinishLabel.setAlignment(QtCore.Qt.AlignRight) self.dialogLayout.addWidget(self.secondFinishLabel, 3, 3, 1, 1) self.dialogLayout.addWidget(self.secondSpinBox, 3, 1, 1, 1) - self.buttonBox = create_button_box(StartTimeDialog, u'buttonBox', - [u'cancel', u'ok']) + self.buttonBox = create_button_box(StartTimeDialog, u'buttonBox', [u'cancel', u'ok']) self.dialogLayout.addWidget(self.buttonBox, 5, 2, 1, 2) self.retranslateUi(StartTimeDialog) self.setMaximumHeight(self.sizeHint().height()) def retranslateUi(self, StartTimeDialog): - self.setWindowTitle(translate('OpenLP.StartTimeForm', - 'Item Start and Finish Time')) + self.setWindowTitle(translate('OpenLP.StartTimeForm', 'Item Start and Finish Time')) self.hourSpinBox.setSuffix(UiStrings().Hours) self.minuteSpinBox.setSuffix(UiStrings().Minutes) self.secondSpinBox.setSuffix(UiStrings().Seconds) diff --git a/openlp/core/ui/starttimeform.py b/openlp/core/ui/starttimeform.py index cd4bc2651..b12601261 100644 --- a/openlp/core/ui/starttimeform.py +++ b/openlp/core/ui/starttimeform.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 ############################################################################### # OpenLP - Open Source Lyrics Projection # @@ -46,22 +46,17 @@ class StartTimeForm(QtGui.QDialog, Ui_StartTimeDialog): """ Run the Dialog with correct heading. """ - hour, minutes, seconds = self._time_split( - self.item[u'service_item'].start_time) + hour, minutes, seconds = self._time_split(self.item[u'service_item'].start_time) self.hourSpinBox.setValue(hour) self.minuteSpinBox.setValue(minutes) self.secondSpinBox.setValue(seconds) - hours, minutes, seconds = self._time_split( - self.item[u'service_item'].media_length) + hours, minutes, seconds = self._time_split(self.item[u'service_item'].media_length) self.hourFinishSpinBox.setValue(hours) self.minuteFinishSpinBox.setValue(minutes) self.secondFinishSpinBox.setValue(seconds) - self.hourFinishLabel.setText(u'%s%s' % (unicode(hour), - UiStrings().Hours)) - self.minuteFinishLabel.setText(u'%s%s' % - (unicode(minutes), UiStrings().Minutes)) - self.secondFinishLabel.setText(u'%s%s' % - (unicode(seconds), UiStrings().Seconds)) + self.hourFinishLabel.setText(u'%s%s' % (unicode(hour), UiStrings().Hours)) + self.minuteFinishLabel.setText(u'%s%s' % (unicode(minutes), UiStrings().Minutes)) + self.secondFinishLabel.setText(u'%s%s' % (unicode(seconds), UiStrings().Seconds)) return QtGui.QDialog.exec_(self) def accept(self): @@ -72,18 +67,12 @@ class StartTimeForm(QtGui.QDialog, Ui_StartTimeDialog): self.minuteFinishSpinBox.value() * 60 + \ self.secondFinishSpinBox.value() if end > self.item[u'service_item'].media_length: - critical_error_message_box( - title=translate('OpenLP.StartTimeForm', - 'Time Validation Error'), - message=translate('OpenLP.StartTimeForm', - 'Finish time is set after the end of the media item')) + critical_error_message_box(title=translate('OpenLP.StartTimeForm', 'Time Validation Error'), + message=translate('OpenLP.StartTimeForm', 'Finish time is set after the end of the media item')) return elif start > end: - critical_error_message_box( - title=translate('OpenLP.StartTimeForm', - 'Time Validation Error'), - message=translate('OpenLP.StartTimeForm', - 'Start time is after the finish time of the media item')) + critical_error_message_box(title=translate('OpenLP.StartTimeForm', 'Time Validation Error'), + message=translate('OpenLP.StartTimeForm', 'Start time is after the finish time of the media item')) return self.item[u'service_item'].start_time = start self.item[u'service_item'].end_time = end diff --git a/openlp/core/ui/themeform.py b/openlp/core/ui/themeform.py index 90115fdb0..16a123dec 100644 --- a/openlp/core/ui/themeform.py +++ b/openlp/core/ui/themeform.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 ############################################################################### # OpenLP - Open Source Lyrics Projection # @@ -62,63 +62,37 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard): self.updateThemeAllowed = True self.temp_background_filename = u'' self.themeLayoutForm = ThemeLayoutForm(self) - QtCore.QObject.connect(self.backgroundComboBox, - QtCore.SIGNAL(u'currentIndexChanged(int)'), + QtCore.QObject.connect(self.backgroundComboBox, QtCore.SIGNAL(u'currentIndexChanged(int)'), self.onBackgroundComboBoxCurrentIndexChanged) - QtCore.QObject.connect(self.gradientComboBox, - QtCore.SIGNAL(u'currentIndexChanged(int)'), + QtCore.QObject.connect(self.gradientComboBox, QtCore.SIGNAL(u'currentIndexChanged(int)'), self.onGradientComboBoxCurrentIndexChanged) - QtCore.QObject.connect(self.colorButton, - QtCore.SIGNAL(u'clicked()'), self.onColorButtonClicked) - QtCore.QObject.connect(self.imageColorButton, - QtCore.SIGNAL(u'clicked()'), self.onImageColorButtonClicked) - QtCore.QObject.connect(self.gradientStartButton, - QtCore.SIGNAL(u'clicked()'), self.onGradientStartButtonClicked) - QtCore.QObject.connect(self.gradientEndButton, - QtCore.SIGNAL(u'clicked()'), self.onGradientEndButtonClicked) - QtCore.QObject.connect(self.imageBrowseButton, - QtCore.SIGNAL(u'clicked()'), self.onImageBrowseButtonClicked) - QtCore.QObject.connect(self.mainColorButton, - QtCore.SIGNAL(u'clicked()'), self.onMainColorButtonClicked) - QtCore.QObject.connect(self.outlineColorButton, - QtCore.SIGNAL(u'clicked()'), self.onOutlineColorButtonClicked) - QtCore.QObject.connect(self.shadowColorButton, - QtCore.SIGNAL(u'clicked()'), self.onShadowColorButtonClicked) - QtCore.QObject.connect(self.outlineCheckBox, - QtCore.SIGNAL(u'stateChanged(int)'), + QtCore.QObject.connect(self.colorButton, QtCore.SIGNAL(u'clicked()'), self.onColorButtonClicked) + QtCore.QObject.connect(self.imageColorButton, QtCore.SIGNAL(u'clicked()'), self.onImageColorButtonClicked) + QtCore.QObject.connect(self.gradientStartButton, QtCore.SIGNAL(u'clicked()'), + self.onGradientStartButtonClicked) + QtCore.QObject.connect(self.gradientEndButton, QtCore.SIGNAL(u'clicked()'), self.onGradientEndButtonClicked) + QtCore.QObject.connect(self.imageBrowseButton, QtCore.SIGNAL(u'clicked()'), self.onImageBrowseButtonClicked) + QtCore.QObject.connect(self.mainColorButton, QtCore.SIGNAL(u'clicked()'), self.onMainColorButtonClicked) + QtCore.QObject.connect(self.outlineColorButton, QtCore.SIGNAL(u'clicked()'), self.onOutlineColorButtonClicked) + QtCore.QObject.connect(self.shadowColorButton, QtCore.SIGNAL(u'clicked()'), self.onShadowColorButtonClicked) + QtCore.QObject.connect(self.outlineCheckBox, QtCore.SIGNAL(u'stateChanged(int)'), self.onOutlineCheckCheckBoxStateChanged) - QtCore.QObject.connect(self.shadowCheckBox, - QtCore.SIGNAL(u'stateChanged(int)'), + QtCore.QObject.connect(self.shadowCheckBox, QtCore.SIGNAL(u'stateChanged(int)'), self.onShadowCheckCheckBoxStateChanged) - QtCore.QObject.connect(self.footerColorButton, - QtCore.SIGNAL(u'clicked()'), self.onFooterColorButtonClicked) - QtCore.QObject.connect(self, - QtCore.SIGNAL(u'customButtonClicked(int)'), - self.onCustom1ButtonClicked) - QtCore.QObject.connect(self.mainPositionCheckBox, - QtCore.SIGNAL(u'stateChanged(int)'), + QtCore.QObject.connect(self.footerColorButton,QtCore.SIGNAL(u'clicked()'), self.onFooterColorButtonClicked) + QtCore.QObject.connect(self, QtCore.SIGNAL(u'customButtonClicked(int)'), self.onCustom1ButtonClicked) + QtCore.QObject.connect(self.mainPositionCheckBox, QtCore.SIGNAL(u'stateChanged(int)'), self.onMainPositionCheckBoxStateChanged) - QtCore.QObject.connect(self.footerPositionCheckBox, - QtCore.SIGNAL(u'stateChanged(int)'), + QtCore.QObject.connect(self.footerPositionCheckBox, QtCore.SIGNAL(u'stateChanged(int)'), self.onFooterPositionCheckBoxStateChanged) - QtCore.QObject.connect(self, - QtCore.SIGNAL(u'currentIdChanged(int)'), self.onCurrentIdChanged) - QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'theme_line_count'), self.updateLinesText) - QtCore.QObject.connect(self.mainSizeSpinBox, - QtCore.SIGNAL(u'valueChanged(int)'), self.calculateLines) - QtCore.QObject.connect(self.lineSpacingSpinBox, - QtCore.SIGNAL(u'valueChanged(int)'), self.calculateLines) - QtCore.QObject.connect(self.outlineSizeSpinBox, - QtCore.SIGNAL(u'valueChanged(int)'), self.calculateLines) - QtCore.QObject.connect(self.shadowSizeSpinBox, - QtCore.SIGNAL(u'valueChanged(int)'), self.calculateLines) - QtCore.QObject.connect(self.mainFontComboBox, - QtCore.SIGNAL(u'activated(int)'), self.calculateLines) - QtCore.QObject.connect(self.footerFontComboBox, - QtCore.SIGNAL(u'activated(int)'), self.updateTheme) - QtCore.QObject.connect(self.footerSizeSpinBox, - QtCore.SIGNAL(u'valueChanged(int)'), self.updateTheme) + QtCore.QObject.connect(self, QtCore.SIGNAL(u'currentIdChanged(int)'), self.onCurrentIdChanged) + QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'theme_line_count'), self.updateLinesText) + QtCore.QObject.connect(self.mainSizeSpinBox, QtCore.SIGNAL(u'valueChanged(int)'), self.calculateLines) + QtCore.QObject.connect(self.lineSpacingSpinBox, QtCore.SIGNAL(u'valueChanged(int)'), self.calculateLines) + QtCore.QObject.connect(self.outlineSizeSpinBox, QtCore.SIGNAL(u'valueChanged(int)'), self.calculateLines) + QtCore.QObject.connect(self.mainFontComboBox, QtCore.SIGNAL(u'activated(int)'), self.calculateLines) + QtCore.QObject.connect(self.footerFontComboBox, QtCore.SIGNAL(u'activated(int)'), self.updateTheme) + QtCore.QObject.connect(self.footerSizeSpinBox, QtCore.SIGNAL(u'valueChanged(int)'), self.updateTheme) def setDefaults(self): """ @@ -136,61 +110,35 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard): """ Map field names to screen names, """ - self.backgroundPage.registerField( - u'background_type', self.backgroundComboBox) + self.backgroundPage.registerField(u'background_type', self.backgroundComboBox) self.backgroundPage.registerField(u'color', self.colorButton) - self.backgroundPage.registerField( - u'grandient_start', self.gradientStartButton) - self.backgroundPage.registerField( - u'grandient_end', self.gradientEndButton) - self.backgroundPage.registerField( - u'background_image', self.imageFileEdit) + self.backgroundPage.registerField(u'grandient_start', self.gradientStartButton) + self.backgroundPage.registerField(u'grandient_end', self.gradientEndButton) + self.backgroundPage.registerField(u'background_image', self.imageFileEdit) self.backgroundPage.registerField(u'gradient', self.gradientComboBox) - self.mainAreaPage.registerField( - u'mainColorButton', self.mainColorButton) - self.mainAreaPage.registerField( - u'mainSizeSpinBox', self.mainSizeSpinBox) - self.mainAreaPage.registerField( - u'lineSpacingSpinBox', self.lineSpacingSpinBox) - self.mainAreaPage.registerField( - u'outlineCheckBox', self.outlineCheckBox) - self.mainAreaPage.registerField( - u'outlineColorButton', self.outlineColorButton) - self.mainAreaPage.registerField( - u'outlineSizeSpinBox', self.outlineSizeSpinBox) - self.mainAreaPage.registerField( - u'shadowCheckBox', self.shadowCheckBox) - self.mainAreaPage.registerField( - u'mainBoldCheckBox', self.mainBoldCheckBox) - self.mainAreaPage.registerField( - u'mainItalicsCheckBox', self.mainItalicsCheckBox) - self.mainAreaPage.registerField( - u'shadowColorButton', self.shadowColorButton) - self.mainAreaPage.registerField( - u'shadowSizeSpinBox', self.shadowSizeSpinBox) - self.mainAreaPage.registerField( - u'footerSizeSpinBox', self.footerSizeSpinBox) - self.areaPositionPage.registerField( - u'mainPositionX', self.mainXSpinBox) - self.areaPositionPage.registerField( - u'mainPositionY', self.mainYSpinBox) - self.areaPositionPage.registerField( - u'mainPositionWidth', self.mainWidthSpinBox) - self.areaPositionPage.registerField( - u'mainPositionHeight', self.mainHeightSpinBox) - self.areaPositionPage.registerField( - u'footerPositionX', self.footerXSpinBox) - self.areaPositionPage.registerField( - u'footerPositionY', self.footerYSpinBox) - self.areaPositionPage.registerField( - u'footerPositionWidth', self.footerWidthSpinBox) - self.areaPositionPage.registerField( - u'footerPositionHeight', self.footerHeightSpinBox) - self.backgroundPage.registerField( - u'horizontal', self.horizontalComboBox) + self.mainAreaPage.registerField(u'mainColorButton', self.mainColorButton) + self.mainAreaPage.registerField(u'mainSizeSpinBox', self.mainSizeSpinBox) + self.mainAreaPage.registerField(u'lineSpacingSpinBox', self.lineSpacingSpinBox) + self.mainAreaPage.registerField(u'outlineCheckBox', self.outlineCheckBox) + self.mainAreaPage.registerField(u'outlineColorButton', self.outlineColorButton) + self.mainAreaPage.registerField(u'outlineSizeSpinBox', self.outlineSizeSpinBox) + self.mainAreaPage.registerField(u'shadowCheckBox', self.shadowCheckBox) + self.mainAreaPage.registerField(u'mainBoldCheckBox', self.mainBoldCheckBox) + self.mainAreaPage.registerField(u'mainItalicsCheckBox', self.mainItalicsCheckBox) + self.mainAreaPage.registerField(u'shadowColorButton', self.shadowColorButton) + self.mainAreaPage.registerField(u'shadowSizeSpinBox', self.shadowSizeSpinBox) + self.mainAreaPage.registerField(u'footerSizeSpinBox', self.footerSizeSpinBox) + self.areaPositionPage.registerField(u'mainPositionX', self.mainXSpinBox) + self.areaPositionPage.registerField(u'mainPositionY', self.mainYSpinBox) + self.areaPositionPage.registerField(u'mainPositionWidth', self.mainWidthSpinBox) + self.areaPositionPage.registerField(u'mainPositionHeight', self.mainHeightSpinBox) + self.areaPositionPage.registerField(u'footerPositionX', self.footerXSpinBox) + self.areaPositionPage.registerField(u'footerPositionY', self.footerYSpinBox) + self.areaPositionPage.registerField(u'footerPositionWidth', self.footerWidthSpinBox) + self.areaPositionPage.registerField(u'footerPositionHeight', self.footerHeightSpinBox) + self.backgroundPage.registerField(u'horizontal', self.horizontalComboBox) self.backgroundPage.registerField(u'vertical', self.verticalComboBox) - self.backgroundPage.registerField( - u'slideTransition', self.transitionsCheckBox) + self.backgroundPage.registerField(u'slideTransition', self.transitionsCheckBox) self.backgroundPage.registerField(u'name', self.themeNameEdit) def calculateLines(self): @@ -206,8 +154,8 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard): """ Updates the lines on a page on the wizard """ - self.mainLineCountLabel.setText(translate('OpenLP.ThemeForm', - '(approximately %d lines per slide)') % int(lines)) + self.mainLineCountLabel.setText( + translate('OpenLP.ThemeForm', '(approximately %d lines per slide)') % int(lines)) def resizeEvent(self, event=None): """ @@ -231,10 +179,8 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard): def validateCurrentPage(self): background_image = BackgroundType.to_string(BackgroundType.Image) if self.page(self.currentId()) == self.backgroundPage and \ - self.theme.background_type == background_image and \ - not self.imageFileEdit.text(): - QtGui.QMessageBox.critical(self, - translate('OpenLP.ThemeWizard', 'Background Image Empty'), + self.theme.background_type == background_image and not self.imageFileEdit.text(): + QtGui.QMessageBox.critical(self, translate('OpenLP.ThemeWizard', 'Background Image Empty'), translate('OpenLP.ThemeWizard', 'You have not selected a ' 'background image. Please select one before continuing.')) return False @@ -265,11 +211,9 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard): pixmap.fill(QtCore.Qt.white) paint = QtGui.QPainter(pixmap) paint.setPen(QtGui.QPen(QtCore.Qt.blue, 2)) - paint.drawRect(self.thememanager.mainwindow.renderer. - get_main_rectangle(self.theme)) + paint.drawRect(self.thememanager.mainwindow.renderer.get_main_rectangle(self.theme)) paint.setPen(QtGui.QPen(QtCore.Qt.red, 2)) - paint.drawRect(self.thememanager.mainwindow.renderer. - get_footer_rectangle(self.theme)) + paint.drawRect(self.thememanager.mainwindow.renderer.get_footer_rectangle(self.theme)) paint.end() self.themeLayoutForm.exec_(pixmap) @@ -325,8 +269,7 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard): self.themeNameEdit.setVisible(not edit) self.edit_mode = edit if edit: - self.setWindowTitle(translate('OpenLP.ThemeWizard', - 'Edit Theme - %s') % self.theme.theme_name) + self.setWindowTitle(translate('OpenLP.ThemeWizard', 'Edit Theme - %s') % self.theme.theme_name) self.next() else: self.setWindowTitle(UiStrings().NewTheme) @@ -355,36 +298,25 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard): """ if self.theme.background_type == \ BackgroundType.to_string(BackgroundType.Solid): - self.colorButton.setStyleSheet(u'background-color: %s' % - self.theme.background_color) + self.colorButton.setStyleSheet(u'background-color: %s' % self.theme.background_color) self.setField(u'background_type', 0) - elif self.theme.background_type == \ - BackgroundType.to_string(BackgroundType.Gradient): - self.gradientStartButton.setStyleSheet(u'background-color: %s' % - self.theme.background_start_color) - self.gradientEndButton.setStyleSheet(u'background-color: %s' % - self.theme.background_end_color) + elif self.theme.background_type == BackgroundType.to_string(BackgroundType.Gradient): + self.gradientStartButton.setStyleSheet(u'background-color: %s' % self.theme.background_start_color) + self.gradientEndButton.setStyleSheet(u'background-color: %s' % self.theme.background_end_color) self.setField(u'background_type', 1) - elif self.theme.background_type == \ - BackgroundType.to_string(BackgroundType.Image): - self.imageColorButton.setStyleSheet(u'background-color: %s' % - self.theme.background_border_color) + elif self.theme.background_type == BackgroundType.to_string(BackgroundType.Image): + self.imageColorButton.setStyleSheet(u'background-color: %s' % self.theme.background_border_color) self.imageFileEdit.setText(self.theme.background_filename) self.setField(u'background_type', 2) - elif self.theme.background_type == \ - BackgroundType.to_string(BackgroundType.Transparent): + elif self.theme.background_type == BackgroundType.to_string(BackgroundType.Transparent): self.setField(u'background_type', 3) - if self.theme.background_direction == \ - BackgroundGradientType.to_string(BackgroundGradientType.Horizontal): + if self.theme.background_direction == BackgroundGradientType.to_string(BackgroundGradientType.Horizontal): self.setField(u'gradient', 0) - elif self.theme.background_direction == \ - BackgroundGradientType.to_string(BackgroundGradientType.Vertical): + elif self.theme.background_direction == BackgroundGradientType.to_string(BackgroundGradientType.Vertical): self.setField(u'gradient', 1) - elif self.theme.background_direction == \ - BackgroundGradientType.to_string(BackgroundGradientType.Circular): + elif self.theme.background_direction == BackgroundGradientType.to_string(BackgroundGradientType.Circular): self.setField(u'gradient', 2) - elif self.theme.background_direction == \ - BackgroundGradientType.to_string(BackgroundGradientType.LeftTop): + elif self.theme.background_direction == BackgroundGradientType.to_string(BackgroundGradientType.LeftTop): self.setField(u'gradient', 3) else: self.setField(u'gradient', 4) @@ -393,20 +325,15 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard): """ Handle the display and state of the Main Area page. """ - self.mainFontComboBox.setCurrentFont( - QtGui.QFont(self.theme.font_main_name)) - self.mainColorButton.setStyleSheet(u'background-color: %s' % - self.theme.font_main_color) + self.mainFontComboBox.setCurrentFont(QtGui.QFont(self.theme.font_main_name)) + self.mainColorButton.setStyleSheet(u'background-color: %s' % self.theme.font_main_color) self.setField(u'mainSizeSpinBox', self.theme.font_main_size) - self.setField(u'lineSpacingSpinBox', - self.theme.font_main_line_adjustment) + self.setField(u'lineSpacingSpinBox', self.theme.font_main_line_adjustment) self.setField(u'outlineCheckBox', self.theme.font_main_outline) - self.outlineColorButton.setStyleSheet(u'background-color: %s' % - self.theme.font_main_outline_color) + self.outlineColorButton.setStyleSheet(u'background-color: %s' % self.theme.font_main_outline_color) self.setField(u'outlineSizeSpinBox', self.theme.font_main_outline_size) self.setField(u'shadowCheckBox', self.theme.font_main_shadow) - self.shadowColorButton.setStyleSheet(u'background-color: %s' % - self.theme.font_main_shadow_color) + self.shadowColorButton.setStyleSheet(u'background-color: %s' % self.theme.font_main_shadow_color) self.setField(u'shadowSizeSpinBox', self.theme.font_main_shadow_size) self.setField(u'mainBoldCheckBox', self.theme.font_main_bold) self.setField(u'mainItalicsCheckBox', self.theme.font_main_italics) @@ -415,10 +342,8 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard): """ Handle the display and state of the Footer Area page. """ - self.footerFontComboBox.setCurrentFont( - QtGui.QFont(self.theme.font_footer_name)) - self.footerColorButton.setStyleSheet(u'background-color: %s' % - self.theme.font_footer_color) + self.footerFontComboBox.setCurrentFont(QtGui.QFont(self.theme.font_footer_name)) + self.footerColorButton.setStyleSheet(u'background-color: %s' % self.theme.font_footer_color) self.setField(u'footerSizeSpinBox', self.theme.font_footer_size) def setPositionPageValues(self): @@ -432,8 +357,7 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard): self.setField(u'mainPositionHeight', self.theme.font_main_height) self.setField(u'mainPositionWidth', self.theme.font_main_width) # Footer - self.footerPositionCheckBox.setChecked( - not self.theme.font_footer_override) + self.footerPositionCheckBox.setChecked(not self.theme.font_footer_override) self.setField(u'footerPositionX', self.theme.font_footer_x) self.setField(u'footerPositionY', self.theme.font_footer_y) self.setField(u'footerPositionHeight', self.theme.font_footer_height) @@ -460,14 +384,12 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard): # do not allow updates when screen is building for the first time. if self.updateThemeAllowed: self.theme.background_type = BackgroundType.to_string(index) - if self.theme.background_type != \ - BackgroundType.to_string(BackgroundType.Image) and \ - self.temp_background_filename == u'': + if self.theme.background_type != BackgroundType.to_string(BackgroundType.Image) and \ + self.temp_background_filename == u'': self.temp_background_filename = self.theme.background_filename self.theme.background_filename = u'' - if self.theme.background_type == \ - BackgroundType.to_string(BackgroundType.Image) and \ - self.temp_background_filename != u'': + if self.theme.background_type == BackgroundType.to_string(BackgroundType.Image) and \ + self.temp_background_filename != u'': self.theme.background_filename = self.temp_background_filename self.temp_background_filename = u'' self.setBackgroundPageValues() @@ -477,40 +399,35 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard): Background gradient Combo box has changed. """ if self.updateThemeAllowed: - self.theme.background_direction = \ - BackgroundGradientType.to_string(index) + self.theme.background_direction = BackgroundGradientType.to_string(index) self.setBackgroundPageValues() def onColorButtonClicked(self): """ Background / Gradient 1 Color button pushed. """ - self.theme.background_color = \ - self._colorButton(self.theme.background_color) + self.theme.background_color = self._colorButton(self.theme.background_color) self.setBackgroundPageValues() def onImageColorButtonClicked(self): """ Background / Gradient 1 Color button pushed. """ - self.theme.background_border_color = \ - self._colorButton(self.theme.background_border_color) + self.theme.background_border_color = self._colorButton(self.theme.background_border_color) self.setBackgroundPageValues() def onGradientStartButtonClicked(self): """ Gradient 2 Color button pushed. """ - self.theme.background_start_color = \ - self._colorButton(self.theme.background_start_color) + self.theme.background_start_color = self._colorButton(self.theme.background_start_color) self.setBackgroundPageValues() def onGradientEndButtonClicked(self): """ Gradient 2 Color button pushed. """ - self.theme.background_end_color = \ - self._colorButton(self.theme.background_end_color) + self.theme.background_end_color = self._colorButton(self.theme.background_end_color) self.setBackgroundPageValues() def onImageBrowseButtonClicked(self): @@ -518,33 +435,27 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard): Background Image button pushed. """ images_filter = get_images_filter() - images_filter = u'%s;;%s (*.*) (*)' % ( - images_filter, UiStrings().AllFiles) + images_filter = u'%s;;%s (*.*) (*)' % (images_filter, UiStrings().AllFiles) filename = QtGui.QFileDialog.getOpenFileName(self, - translate('OpenLP.ThemeWizard', 'Select Image'), u'', - images_filter) + translate('OpenLP.ThemeWizard', 'Select Image'), u'', images_filter) if filename: self.theme.background_filename = unicode(filename) self.setBackgroundPageValues() def onMainColorButtonClicked(self): - self.theme.font_main_color = \ - self._colorButton(self.theme.font_main_color) + self.theme.font_main_color = self._colorButton(self.theme.font_main_color) self.setMainAreaPageValues() def onOutlineColorButtonClicked(self): - self.theme.font_main_outline_color = \ - self._colorButton(self.theme.font_main_outline_color) + self.theme.font_main_outline_color = self._colorButton(self.theme.font_main_outline_color) self.setMainAreaPageValues() def onShadowColorButtonClicked(self): - self.theme.font_main_shadow_color = \ - self._colorButton(self.theme.font_main_shadow_color) + self.theme.font_main_shadow_color = self._colorButton(self.theme.font_main_shadow_color) self.setMainAreaPageValues() def onFooterColorButtonClicked(self): - self.theme.font_footer_color = \ - self._colorButton(self.theme.font_footer_color) + self.theme.font_footer_color = self._colorButton(self.theme.font_footer_color) self.setFooterAreaPageValues() def updateTheme(self): @@ -564,8 +475,7 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard): self.theme.font_main_bold = self.field(u'mainBoldCheckBox') self.theme.font_main_italics = self.field(u'mainItalicsCheckBox') # footer page - self.theme.font_footer_name = \ - self.footerFontComboBox.currentFont().family() + self.theme.font_footer_name = self.footerFontComboBox.currentFont().family() self.theme.font_footer_size = self.field(u'footerSizeSpinBox') # position page self.theme.font_main_x = self.field(u'mainPositionX') @@ -577,8 +487,7 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard): self.theme.font_footer_height = self.field(u'footerPositionHeight') self.theme.font_footer_width = self.field(u'footerPositionWidth') # position page - self.theme.display_horizontal_align = \ - self.horizontalComboBox.currentIndex() + self.theme.display_horizontal_align = self.horizontalComboBox.currentIndex() self.theme.display_vertical_align = self.verticalComboBox.currentIndex() self.theme.display_slide_transition = self.field(u'slideTransition') @@ -591,25 +500,20 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard): if not self.theme.theme_name: critical_error_message_box( translate('OpenLP.ThemeWizard', 'Theme Name Missing'), - translate('OpenLP.ThemeWizard', - 'There is no name for this theme. Please enter one.')) + translate('OpenLP.ThemeWizard', 'There is no name for this theme. Please enter one.')) return if self.theme.theme_name == u'-1' or self.theme.theme_name == u'None': critical_error_message_box( translate('OpenLP.ThemeWizard', 'Theme Name Invalid'), - translate('OpenLP.ThemeWizard', - 'Invalid theme name. Please enter one.')) + translate('OpenLP.ThemeWizard', 'Invalid theme name. Please enter one.')) return saveFrom = None saveTo = None - if self.theme.background_type == \ - BackgroundType.to_string(BackgroundType.Image): - filename = \ - os.path.split(unicode(self.theme.background_filename))[1] + if self.theme.background_type == BackgroundType.to_string(BackgroundType.Image): + filename = os.path.split(unicode(self.theme.background_filename))[1] saveTo = os.path.join(self.path, self.theme.theme_name, filename) saveFrom = self.theme.background_filename - if not self.edit_mode and \ - not self.thememanager.checkIfThemeExists(self.theme.theme_name): + if not self.edit_mode and not self.thememanager.checkIfThemeExists(self.theme.theme_name): return self.thememanager.saveTheme(self.theme, saveFrom, saveTo) return QtGui.QDialog.accept(self) diff --git a/openlp/core/ui/themelayoutdialog.py b/openlp/core/ui/themelayoutdialog.py index afad8983c..0b969c3bb 100644 --- a/openlp/core/ui/themelayoutdialog.py +++ b/openlp/core/ui/themelayoutdialog.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 ############################################################################### # OpenLP - Open Source Lyrics Projection # @@ -58,16 +58,12 @@ class Ui_ThemeLayoutDialog(object): self.footerColourLabel = QtGui.QLabel(self.previewArea) self.footerColourLabel.setObjectName(u'footerColourLabel') self.previewLayout.addWidget(self.footerColourLabel) - self.buttonBox = create_button_box(themeLayoutDialog, u'buttonBox', - [u'ok']) + self.buttonBox = create_button_box(themeLayoutDialog, u'buttonBox', [u'ok']) self.previewLayout.addWidget(self.buttonBox) self.retranslateUi(themeLayoutDialog) def retranslateUi(self, themeLayoutDialog): - themeLayoutDialog.setWindowTitle( - translate('OpenLP.StartTimeForm', 'Theme Layout')) - self.mainColourLabel.setText(translate('OpenLP.StartTimeForm', - 'The blue box shows the main area.')) - self.footerColourLabel.setText(translate('OpenLP.StartTimeForm', - 'The red box shows the footer.')) + themeLayoutDialog.setWindowTitle(translate('OpenLP.StartTimeForm', 'Theme Layout')) + self.mainColourLabel.setText(translate('OpenLP.StartTimeForm', 'The blue box shows the main area.')) + self.footerColourLabel.setText(translate('OpenLP.StartTimeForm', 'The red box shows the footer.')) diff --git a/openlp/core/ui/themelayoutform.py b/openlp/core/ui/themelayoutform.py index 28c6dd601..c6bda81e3 100644 --- a/openlp/core/ui/themelayoutform.py +++ b/openlp/core/ui/themelayoutform.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 ############################################################################### # OpenLP - Open Source Lyrics Projection # diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index 6d1222481..8048b65fc 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 ############################################################################### # OpenLP - Open Source Lyrics Projection # @@ -36,17 +36,13 @@ import re from xml.etree.ElementTree import ElementTree, XML from PyQt4 import QtCore, QtGui -from openlp.core.lib import OpenLPToolbar, get_text_file_string, build_icon, \ - Receiver, SettingsManager, translate, check_item_selected, \ - check_directory_exists, create_thumb, validate_thumb, ImageSource, Settings -from openlp.core.lib.theme import ThemeXML, BackgroundType, VerticalType, \ - BackgroundGradientType -from openlp.core.lib.ui import UiStrings, critical_error_message_box, \ - create_widget_action +from openlp.core.lib import OpenLPToolbar, get_text_file_string, build_icon, Receiver, SettingsManager, translate, \ + check_item_selected, check_directory_exists, create_thumb, validate_thumb, ImageSource, Settings +from openlp.core.lib.theme import ThemeXML, BackgroundType, VerticalType, BackgroundGradientType +from openlp.core.lib.ui import UiStrings, critical_error_message_box, create_widget_action from openlp.core.theme import Theme from openlp.core.ui import FileRenameForm, ThemeForm -from openlp.core.utils import AppLocation, delete_file, locale_compare, \ - get_filesystem_encoding +from openlp.core.utils import AppLocation, delete_file, locale_compare, get_filesystem_encoding log = logging.getLogger(__name__) @@ -102,8 +98,7 @@ class ThemeManager(QtGui.QWidget): self.themeListWidget.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) self.themeListWidget.setObjectName(u'themeListWidget') self.layout.addWidget(self.themeListWidget) - QtCore.QObject.connect(self.themeListWidget, - QtCore.SIGNAL('customContextMenuRequested(QPoint)'), + QtCore.QObject.connect(self.themeListWidget, QtCore.SIGNAL('customContextMenuRequested(QPoint)'), self.contextMenu) # build the context menu self.menu = QtGui.QMenu() @@ -129,15 +124,12 @@ class ThemeManager(QtGui.QWidget): icon=u':/general/general_export.png', triggers=self.onExportTheme) # Signals QtCore.QObject.connect(self.themeListWidget, - QtCore.SIGNAL(u'doubleClicked(QModelIndex)'), - self.changeGlobalFromScreen) - QtCore.QObject.connect(self.themeListWidget, QtCore.SIGNAL( - u'currentItemChanged(QListWidgetItem *, QListWidgetItem *)'), - self.checkListState) + QtCore.SIGNAL(u'doubleClicked(QModelIndex)'), self.changeGlobalFromScreen) + QtCore.QObject.connect(self.themeListWidget, + QtCore.SIGNAL(u'currentItemChanged(QListWidgetItem *, QListWidgetItem *)'), self.checkListState) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'theme_update_global'), self.changeGlobalFromTab) - QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'config_updated'), self.configUpdated) + QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'config_updated'), self.configUpdated) # Variables self.themeList = [] self.path = AppLocation.get_section_data_path(self.settingsSection) @@ -166,8 +158,7 @@ class ThemeManager(QtGui.QWidget): """ Triggered when Config dialog is updated. """ - self.global_theme = Settings().value( - self.settingsSection + u'/global theme', u'') + self.global_theme = Settings().value(self.settingsSection + u'/global theme', u'') def checkListState(self, item): """ @@ -214,8 +205,7 @@ class ThemeManager(QtGui.QWidget): self.themeListWidget.item(count).setText(new_name) # Set the new name if theme_name == new_name: - name = translate('OpenLP.ThemeManager', - '%s (default)') % new_name + name = translate('OpenLP.ThemeManager', '%s (default)') % new_name self.themeListWidget.item(count).setText(name) self.deleteToolbarAction.setVisible( item not in self.themeListWidget.selectedItems()) @@ -232,16 +222,13 @@ class ThemeManager(QtGui.QWidget): old_name = item.text() # reset the old name if old_name != item.data(QtCore.Qt.UserRole): - self.themeListWidget.item(count).setText( - item.data(QtCore.Qt.UserRole)) + self.themeListWidget.item(count).setText(item.data(QtCore.Qt.UserRole)) # Set the new name if count == selected_row: self.global_theme = self.themeListWidget.item(count).text() - name = translate('OpenLP.ThemeManager', - '%s (default)') % self.global_theme + name = translate('OpenLP.ThemeManager', '%s (default)') % self.global_theme self.themeListWidget.item(count).setText(name) - Settings().setValue( - self.settingsSection + u'/global theme', self.global_theme) + Settings().setValue(self.settingsSection + u'/global theme', self.global_theme) Receiver.send_message(u'theme_update_global', self.global_theme) self._pushThemes() @@ -260,11 +247,9 @@ class ThemeManager(QtGui.QWidget): """ Renames an existing theme to a new name """ - if self._validate_theme_action(translate('OpenLP.ThemeManager', - 'You must select a theme to rename.'), - translate('OpenLP.ThemeManager', 'Rename Confirmation'), - translate('OpenLP.ThemeManager', 'Rename %s theme?'), - False, False): + if self._validate_theme_action(translate('OpenLP.ThemeManager', 'You must select a theme to rename.'), + translate('OpenLP.ThemeManager', 'Rename Confirmation'), + translate('OpenLP.ThemeManager', 'Rename %s theme?'), False, False): item = self.themeListWidget.currentItem() old_theme_name = item.data(QtCore.Qt.UserRole) self.fileRenameForm.fileNameEdit.setText(old_theme_name) @@ -289,8 +274,7 @@ class ThemeManager(QtGui.QWidget): """ item = self.themeListWidget.currentItem() old_theme_name = item.data(QtCore.Qt.UserRole) - self.fileRenameForm.fileNameEdit.setText( - translate('OpenLP.ThemeManager', + self.fileRenameForm.fileNameEdit.setText(translate('OpenLP.ThemeManager', 'Copy of %s', 'Copy of ') % old_theme_name) if self.fileRenameForm.exec_(True): new_theme_name = self.fileRenameForm.fileNameEdit.text() @@ -319,8 +303,8 @@ class ThemeManager(QtGui.QWidget): Loads the settings for the theme that is to be edited and launches the theme editing form so the user can make their changes. """ - if check_item_selected(self.themeListWidget, translate( - 'OpenLP.ThemeManager', 'You must select a theme to edit.')): + if check_item_selected(self.themeListWidget, + translate('OpenLP.ThemeManager', 'You must select a theme to edit.')): item = self.themeListWidget.currentItem() theme = self.getThemeData(item.data(QtCore.Qt.UserRole)) if theme.background_type == u'image': @@ -335,10 +319,9 @@ class ThemeManager(QtGui.QWidget): """ Delete a theme """ - if self._validate_theme_action(translate('OpenLP.ThemeManager', - 'You must select a theme to delete.'), - translate('OpenLP.ThemeManager', 'Delete Confirmation'), - translate('OpenLP.ThemeManager', 'Delete %s theme?')): + if self._validate_theme_action(translate('OpenLP.ThemeManager', 'You must select a theme to delete.'), + translate('OpenLP.ThemeManager', 'Delete Confirmation'), + translate('OpenLP.ThemeManager', 'Delete %s theme?')): item = self.themeListWidget.currentItem() theme = item.text() row = self.themeListWidget.row(item) @@ -372,8 +355,7 @@ class ThemeManager(QtGui.QWidget): """ item = self.themeListWidget.currentItem() if item is None: - critical_error_message_box(message=translate('OpenLP.ThemeManager', - 'You have not selected a theme.')) + critical_error_message_box(message=translate('OpenLP.ThemeManager', 'You have not selected a theme.')) return theme = item.data(QtCore.Qt.UserRole) path = QtGui.QFileDialog.getExistingDirectory(self, @@ -395,14 +377,12 @@ class ThemeManager(QtGui.QWidget): os.path.join(theme, name).encode(u'utf-8')) QtGui.QMessageBox.information(self, translate('OpenLP.ThemeManager', 'Theme Exported'), - translate('OpenLP.ThemeManager', - 'Your theme has been successfully exported.')) + translate('OpenLP.ThemeManager', 'Your theme has been successfully exported.')) except (IOError, OSError): log.exception(u'Export Theme Failed') critical_error_message_box( translate('OpenLP.ThemeManager', 'Theme Export Failed'), - translate('OpenLP.ThemeManager', - 'Your theme could not be exported due to an error.')) + translate('OpenLP.ThemeManager', 'Your theme could not be exported due to an error.')) finally: if zip: zip.close() @@ -417,8 +397,7 @@ class ThemeManager(QtGui.QWidget): files = QtGui.QFileDialog.getOpenFileNames(self, translate('OpenLP.ThemeManager', 'Select Theme Import File'), SettingsManager.get_last_dir(self.settingsSection), - translate('OpenLP.ThemeManager', - 'OpenLP Themes (*.theme *.otz)')) + translate('OpenLP.ThemeManager', 'OpenLP Themes (*.theme *.otz)')) log.info(u'New Themes %s', unicode(files)) if not files: return @@ -447,8 +426,7 @@ class ThemeManager(QtGui.QWidget): theme = ThemeXML() theme.theme_name = UiStrings().Default self._writeTheme(theme, None, None) - Settings().setValue( - self.settingsSection + u'/global theme', theme.theme_name) + Settings().setValue(self.settingsSection + u'/global theme', theme.theme_name) self.configUpdated() files = SettingsManager.get_files(self.settingsSection, u'.png') # Sort the themes by its name considering language specific @@ -461,8 +439,7 @@ class ThemeManager(QtGui.QWidget): if os.path.exists(theme): text_name = os.path.splitext(name)[0] if text_name == self.global_theme: - name = translate( - 'OpenLP.ThemeManager', '%s (default)') % text_name + name = translate('OpenLP.ThemeManager', '%s (default)') % text_name else: name = text_name thumb = os.path.join(self.thumbPath, u'%s.png' % text_name) @@ -510,10 +487,8 @@ class ThemeManager(QtGui.QWidget): ret = QtGui.QMessageBox.question(self, translate('OpenLP.ThemeManager', 'Theme Already Exists'), translate('OpenLP.ThemeManager', - 'Theme %s already exists. Do you want to replace it?' - ).replace('%s', theme_name), - QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes | - QtGui.QMessageBox.No), + 'Theme %s already exists. Do you want to replace it?').replace('%s', theme_name), + QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes | QtGui.QMessageBox.No), QtGui.QMessageBox.No) return ret == QtGui.QMessageBox.Yes @@ -539,8 +514,7 @@ class ThemeManager(QtGui.QWidget): xml_tree = ElementTree(element=XML(zip.read(xml_file[0]))).getroot() v1_background = xml_tree.find(u'BackgroundType') if v1_background is not None: - theme_name, file_xml, out_file, abort_import = \ - self.unzipVersion122( + theme_name, file_xml, out_file, abort_import = self.unzipVersion122( dir, zip, xml_file[0], xml_tree, v1_background, out_file) else: theme_name = xml_tree.find(u'name').text.strip() @@ -555,8 +529,8 @@ class ThemeManager(QtGui.QWidget): try: uname = unicode(name, u'utf-8') except UnicodeDecodeError: - log.exception(u'Theme file contains non utf-8 filename' - u' "%s"' % name.decode(u'utf-8', u'replace')) + log.exception(u'Theme file contains non utf-8 filename "%s"' % + name.decode(u'utf-8', u'replace')) raise Exception(u'validation') uname = uname.replace(u'/', os.path.sep) split_name = uname.split(os.path.sep) @@ -579,8 +553,7 @@ class ThemeManager(QtGui.QWidget): except Exception as info: if unicode(info) == u'validation': critical_error_message_box(translate('OpenLP.ThemeManager', - 'Validation Error'), translate('OpenLP.ThemeManager', - 'File is not a valid theme.')) + 'Validation Error'), translate('OpenLP.ThemeManager', 'File is not a valid theme.')) else: raise finally: @@ -599,10 +572,8 @@ class ThemeManager(QtGui.QWidget): elif zip is not None: critical_error_message_box( translate('OpenLP.ThemeManager', 'Validation Error'), - translate('OpenLP.ThemeManager', - 'File is not a valid theme.')) - log.exception(u'Theme file does not contain XML data %s' % - file_name) + translate('OpenLP.ThemeManager', 'File is not a valid theme.')) + log.exception(u'Theme file does not contain XML data %s' % file_name) def unzipVersion122(self, dir, zip, xml_file, xml_tree, background, out_file): @@ -634,8 +605,7 @@ class ThemeManager(QtGui.QWidget): out_file.write(zip.read(image_file[0])) out_file.close() else: - log.exception(u'Theme file does not contain image file "%s"' % - image_name.decode(u'utf-8', u'replace')) + log.exception(u'Theme file does not contain image file "%s"' % image_name.decode(u'utf-8', u'replace')) raise Exception(u'validation') return theme_name, file_xml, out_file, False @@ -650,8 +620,7 @@ class ThemeManager(QtGui.QWidget): if os.path.exists(theme_dir): critical_error_message_box( translate('OpenLP.ThemeManager', 'Validation Error'), - translate('OpenLP.ThemeManager', - 'A theme with this name already exists.')) + translate('OpenLP.ThemeManager', 'A theme with this name already exists.')) return False return True @@ -661,10 +630,8 @@ class ThemeManager(QtGui.QWidget): and to trigger the reload of the theme list """ self._writeTheme(theme, image_from, image_to) - if theme.background_type == \ - BackgroundType.to_string(BackgroundType.Image): - self.mainwindow.imageManager.updateImageBorder( - theme.background_filename, + if theme.background_type == BackgroundType.to_string(BackgroundType.Image): + self.mainwindow.imageManager.updateImageBorder(theme.background_filename, ImageSource.Theme, QtGui.QColor(theme.background_border_color)) self.mainwindow.imageManager.processUpdates() @@ -693,9 +660,7 @@ class ThemeManager(QtGui.QWidget): if image_from and image_from != image_to: try: encoding = get_filesystem_encoding() - shutil.copyfile( - unicode(image_from).encode(encoding), - unicode(image_to).encode(encoding)) + shutil.copyfile(unicode(image_from).encode(encoding), unicode(image_to).encode(encoding)) except IOError: log.exception(u'Failed to save theme image') self.generateAndSaveImage(self.path, name, theme) @@ -718,8 +683,7 @@ class ThemeManager(QtGui.QWidget): self.mainwindow.displayProgressBar(len(self.themeList)) for theme in self.themeList: self.mainwindow.incrementProgressBar() - self.generateAndSaveImage( - self.path, theme, self.getThemeData(theme)) + self.generateAndSaveImage(self.path, theme, self.getThemeData(theme)) self.mainwindow.finishedProgressBar() self.loadThemes() @@ -734,8 +698,7 @@ class ThemeManager(QtGui.QWidget): Flag to tell message lines per page need to be generated. """ log.debug(u'generateImage \n%s ', theme_data) - return self.mainwindow.renderer.generate_preview( - theme_data, forcePage) + return self.mainwindow.renderer.generate_preview(theme_data, forcePage) def getPreviewImage(self, theme): """ @@ -773,28 +736,23 @@ class ThemeManager(QtGui.QWidget): theme = item.text() # confirm deletion if confirm: - answer = QtGui.QMessageBox.question(self, confirm_title, - confirm_text % theme, QtGui.QMessageBox.StandardButtons( - QtGui.QMessageBox.Yes | QtGui.QMessageBox.No), + answer = QtGui.QMessageBox.question(self, confirm_title, confirm_text % theme, + QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes | QtGui.QMessageBox.No), QtGui.QMessageBox.No) if answer == QtGui.QMessageBox.No: return False # should be the same unless default if theme != item.data(QtCore.Qt.UserRole): critical_error_message_box( - message=translate('OpenLP.ThemeManager', - 'You are unable to delete the default theme.')) + message=translate('OpenLP.ThemeManager', 'You are unable to delete the default theme.')) return False # check for use in the system else where. if testPlugin: for plugin in self.mainwindow.pluginManager.plugins: if plugin.usesTheme(theme): - critical_error_message_box( - translate('OpenLP.ThemeManager', - 'Validation Error'), - translate('OpenLP.ThemeManager', - 'Theme %s is used in the %s plugin.') % \ - (theme, plugin.name)) + critical_error_message_box(translate('OpenLP.ThemeManager', 'Validation Error'), + translate('OpenLP.ThemeManager', 'Theme %s is used in the %s plugin.') % + (theme, plugin.name)) return False return True return False @@ -813,31 +771,20 @@ class ThemeManager(QtGui.QWidget): new_theme = ThemeXML() new_theme.theme_name = self.badV1NameChars.sub(u'', theme.Name) if theme.BackgroundType == 0: - new_theme.background_type = \ - BackgroundType.to_string(BackgroundType.Solid) - new_theme.background_color = \ - unicode(theme.BackgroundParameter1.name()) + new_theme.background_type = BackgroundType.to_string(BackgroundType.Solid) + new_theme.background_color = unicode(theme.BackgroundParameter1.name()) elif theme.BackgroundType == 1: - new_theme.background_type = \ - BackgroundType.to_string(BackgroundType.Gradient) - new_theme.background_direction = \ - BackgroundGradientType. \ - to_string(BackgroundGradientType.Horizontal) + new_theme.background_type = BackgroundType.to_string(BackgroundType.Gradient) + new_theme.background_direction = BackgroundGradientType.to_string(BackgroundGradientType.Horizontal) if theme.BackgroundParameter3.name() == 1: - new_theme.background_direction = \ - BackgroundGradientType. \ - to_string(BackgroundGradientType.Horizontal) - new_theme.background_start_color = \ - unicode(theme.BackgroundParameter1.name()) - new_theme.background_end_color = \ - unicode(theme.BackgroundParameter2.name()) + new_theme.background_direction = BackgroundGradientType.to_string(BackgroundGradientType.Horizontal) + new_theme.background_start_color = unicode(theme.BackgroundParameter1.name()) + new_theme.background_end_color = unicode(theme.BackgroundParameter2.name()) elif theme.BackgroundType == 2: - new_theme.background_type = \ - BackgroundType.to_string(BackgroundType.Image) + new_theme.background_type = BackgroundType.to_string(BackgroundType.Image) new_theme.background_filename = unicode(theme.BackgroundParameter1) elif theme.BackgroundType == 3: - new_theme.background_type = \ - BackgroundType.to_string(BackgroundType.Transparent) + new_theme.background_type = BackgroundType.to_string(BackgroundType.Transparent) new_theme.font_main_name = theme.FontName new_theme.font_main_color = unicode(theme.FontColor.name()) new_theme.font_main_size = theme.FontProportion * 3 @@ -849,8 +796,7 @@ class ThemeManager(QtGui.QWidget): new_theme.font_main_shadow_color = unicode(theme.ShadowColor.name()) if theme.Outline == 1: new_theme.font_main_outline = True - new_theme.font_main_outline_color = \ - unicode(theme.OutlineColor.name()) + new_theme.font_main_outline_color = unicode(theme.OutlineColor.name()) vAlignCorrection = VerticalType.Top if theme.VerticalAlign == 2: vAlignCorrection = VerticalType.Middle diff --git a/openlp/core/ui/themestab.py b/openlp/core/ui/themestab.py index 12a474881..d2dd3590c 100644 --- a/openlp/core/ui/themestab.py +++ b/openlp/core/ui/themestab.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 ############################################################################### # OpenLP - Open Source Lyrics Projection # @@ -51,10 +51,8 @@ class ThemesTab(SettingsTab): self.GlobalGroupBoxLayout = QtGui.QVBoxLayout(self.GlobalGroupBox) self.GlobalGroupBoxLayout.setObjectName(u'GlobalGroupBoxLayout') self.DefaultComboBox = QtGui.QComboBox(self.GlobalGroupBox) - self.DefaultComboBox.setSizeAdjustPolicy( - QtGui.QComboBox.AdjustToMinimumContentsLength) - self.DefaultComboBox.setSizePolicy( - QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed) + self.DefaultComboBox.setSizeAdjustPolicy(QtGui.QComboBox.AdjustToMinimumContentsLength) + self.DefaultComboBox.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed) self.DefaultComboBox.setObjectName(u'DefaultComboBox') self.GlobalGroupBoxLayout.addWidget(self.DefaultComboBox) self.DefaultListView = QtGui.QLabel(self.GlobalGroupBox) @@ -65,10 +63,8 @@ class ThemesTab(SettingsTab): self.LevelGroupBox = QtGui.QGroupBox(self.rightColumn) self.LevelGroupBox.setObjectName(u'LevelGroupBox') self.LevelLayout = QtGui.QFormLayout(self.LevelGroupBox) - self.LevelLayout.setLabelAlignment( - QtCore.Qt.AlignLeft | QtCore.Qt.AlignTop) - self.LevelLayout.setFormAlignment( - QtCore.Qt.AlignLeft | QtCore.Qt.AlignTop) + self.LevelLayout.setLabelAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignTop) + self.LevelLayout.setFormAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignTop) self.LevelLayout.setObjectName(u'LevelLayout') self.SongLevelRadioButton = QtGui.QRadioButton(self.LevelGroupBox) self.SongLevelRadioButton.setObjectName(u'SongLevelRadioButton') @@ -79,58 +75,44 @@ class ThemesTab(SettingsTab): self.ServiceLevelRadioButton.setObjectName(u'ServiceLevelRadioButton') self.ServiceLevelLabel = QtGui.QLabel(self.LevelGroupBox) self.ServiceLevelLabel.setObjectName(u'ServiceLevelLabel') - self.LevelLayout.addRow(self.ServiceLevelRadioButton, - self.ServiceLevelLabel) + self.LevelLayout.addRow(self.ServiceLevelRadioButton, self.ServiceLevelLabel) self.GlobalLevelRadioButton = QtGui.QRadioButton(self.LevelGroupBox) self.GlobalLevelRadioButton.setObjectName(u'GlobalLevelRadioButton') self.GlobalLevelLabel = QtGui.QLabel(self.LevelGroupBox) self.GlobalLevelLabel.setObjectName(u'GlobalLevelLabel') - self.LevelLayout.addRow(self.GlobalLevelRadioButton, - self.GlobalLevelLabel) + self.LevelLayout.addRow(self.GlobalLevelRadioButton, self.GlobalLevelLabel) label_top_margin = (self.SongLevelRadioButton.sizeHint().height() - self.SongLevelLabel.sizeHint().height()) / 2 - for label in [self.SongLevelLabel, self.ServiceLevelLabel, - self.GlobalLevelLabel]: + for label in [self.SongLevelLabel, self.ServiceLevelLabel, self.GlobalLevelLabel]: rect = label.rect() rect.setTop(rect.top() + label_top_margin) label.setFrameRect(rect) label.setWordWrap(True) self.rightLayout.addWidget(self.LevelGroupBox) self.rightLayout.addStretch() - QtCore.QObject.connect(self.SongLevelRadioButton, - QtCore.SIGNAL(u'clicked()'), self.onSongLevelButtonClicked) - QtCore.QObject.connect(self.ServiceLevelRadioButton, - QtCore.SIGNAL(u'clicked()'), self.onServiceLevelButtonClicked) - QtCore.QObject.connect(self.GlobalLevelRadioButton, - QtCore.SIGNAL(u'clicked()'), self.onGlobalLevelButtonClicked) - QtCore.QObject.connect(self.DefaultComboBox, - QtCore.SIGNAL(u'activated(int)'), self.onDefaultComboBoxChanged) - QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'theme_update_list'), self.updateThemeList) + QtCore.QObject.connect(self.SongLevelRadioButton, QtCore.SIGNAL(u'clicked()'), self.onSongLevelButtonClicked) + QtCore.QObject.connect(self.ServiceLevelRadioButton, QtCore.SIGNAL(u'clicked()'), + self.onServiceLevelButtonClicked) + QtCore.QObject.connect(self.GlobalLevelRadioButton, QtCore.SIGNAL(u'clicked()'), + self.onGlobalLevelButtonClicked) + QtCore.QObject.connect(self.DefaultComboBox, QtCore.SIGNAL(u'activated(int)'), self.onDefaultComboBoxChanged) + QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'theme_update_list'), self.updateThemeList) def retranslateUi(self): self.tabTitleVisible = UiStrings().Themes - self.GlobalGroupBox.setTitle( - translate('OpenLP.ThemesTab', 'Global Theme')) - self.LevelGroupBox.setTitle( - translate('OpenLP.ThemesTab', 'Theme Level')) - self.SongLevelRadioButton.setText( - translate('OpenLP.ThemesTab', 'S&ong Level')) - self.SongLevelLabel.setText( - translate('OpenLP.ThemesTab', 'Use the theme from each song ' + self.GlobalGroupBox.setTitle(translate('OpenLP.ThemesTab', 'Global Theme')) + self.LevelGroupBox.setTitle(translate('OpenLP.ThemesTab', 'Theme Level')) + self.SongLevelRadioButton.setText(translate('OpenLP.ThemesTab', 'S&ong Level')) + self.SongLevelLabel.setText(translate('OpenLP.ThemesTab', 'Use the theme from each song ' 'in the database. If a song doesn\'t have a theme associated with ' 'it, then use the service\'s theme. If the service doesn\'t have ' 'a theme, then use the global theme.')) - self.ServiceLevelRadioButton.setText( - translate('OpenLP.ThemesTab', '&Service Level')) - self.ServiceLevelLabel.setText( - translate('OpenLP.ThemesTab', 'Use the theme from the service, ' + self.ServiceLevelRadioButton.setText(translate('OpenLP.ThemesTab', '&Service Level')) + self.ServiceLevelLabel.setText(translate('OpenLP.ThemesTab', 'Use the theme from the service, ' 'overriding any of the individual songs\' themes. If the ' 'service doesn\'t have a theme, then use the global theme.')) - self.GlobalLevelRadioButton.setText( - translate('OpenLP.ThemesTab', '&Global Level')) - self.GlobalLevelLabel.setText( - translate('OpenLP.ThemesTab', 'Use the global theme, overriding ' + self.GlobalLevelRadioButton.setText(translate('OpenLP.ThemesTab', '&Global Level')) + self.GlobalLevelLabel.setText(translate('OpenLP.ThemesTab', 'Use the global theme, overriding ' 'any themes associated with either the service or the songs.')) def load(self): @@ -183,8 +165,7 @@ class ThemesTab(SettingsTab): [u'Bible Theme', u'Song Theme'] """ # Reload as may have been triggered by the ThemeManager. - self.global_theme = Settings().value( - self.settingsSection + u'/global theme', u'') + self.global_theme = Settings().value(self.settingsSection + u'/global theme', u'') self.DefaultComboBox.clear() self.DefaultComboBox.addItems(theme_list) find_and_set_in_combo_box(self.DefaultComboBox, self.global_theme) @@ -197,10 +178,8 @@ class ThemesTab(SettingsTab): """ Utility method to update the global theme preview image. """ - image = self.mainwindow.themeManagerContents.getPreviewImage( - self.global_theme) + image = self.mainwindow.themeManagerContents.getPreviewImage(self.global_theme) preview = QtGui.QPixmap(unicode(image)) if not preview.isNull(): - preview = preview.scaled(300, 255, QtCore.Qt.KeepAspectRatio, - QtCore.Qt.SmoothTransformation) + preview = preview.scaled(300, 255, QtCore.Qt.KeepAspectRatio, QtCore.Qt.SmoothTransformation) self.DefaultListView.setPixmap(preview) diff --git a/openlp/core/ui/themewizard.py b/openlp/core/ui/themewizard.py index c3211fc27..5663b3575 100644 --- a/openlp/core/ui/themewizard.py +++ b/openlp/core/ui/themewizard.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 ############################################################################### # OpenLP - Open Source Lyrics Projection # @@ -30,10 +30,8 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import translate, build_icon -from openlp.core.lib.theme import HorizontalType, BackgroundType, \ - BackgroundGradientType -from openlp.core.lib.ui import UiStrings, add_welcome_page, \ - create_valign_selection_widgets +from openlp.core.lib.theme import HorizontalType, BackgroundType, BackgroundGradientType +from openlp.core.lib.ui import UiStrings, add_welcome_page, create_valign_selection_widgets class Ui_ThemeWizard(object): def setupUi(self, themeWizard): @@ -43,8 +41,7 @@ class Ui_ThemeWizard(object): themeWizard.setOptions(QtGui.QWizard.IndependentPages | QtGui.QWizard.NoBackButtonOnStartPage | QtGui.QWizard.HaveCustomButton1) - self.spacer = QtGui.QSpacerItem(10, 0, - QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Minimum) + self.spacer = QtGui.QSpacerItem(10, 0, QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Minimum) # Welcome Page add_welcome_page(themeWizard, u':/wizards/wizard_createtheme.bmp') # Background Page @@ -59,10 +56,8 @@ class Ui_ThemeWizard(object): self.backgroundComboBox = QtGui.QComboBox(self.backgroundPage) self.backgroundComboBox.addItems([u'', u'', u'', u'']) self.backgroundComboBox.setObjectName(u'BackgroundComboBox') - self.backgroundTypeLayout.addRow(self.backgroundLabel, - self.backgroundComboBox) - self.backgroundTypeLayout.setItem(1, QtGui.QFormLayout.LabelRole, - self.spacer) + self.backgroundTypeLayout.addRow(self.backgroundLabel, self.backgroundComboBox) + self.backgroundTypeLayout.setItem(1, QtGui.QFormLayout.LabelRole, self.spacer) self.backgroundLayout.addLayout(self.backgroundTypeLayout) self.backgroundStack = QtGui.QStackedLayout() self.backgroundStack.setObjectName(u'BackgroundStack') @@ -87,21 +82,18 @@ class Ui_ThemeWizard(object): self.gradientStartLabel.setObjectName(u'GradientStartLabel') self.gradientStartButton = QtGui.QPushButton(self.gradientWidget) self.gradientStartButton.setObjectName(u'GradientStartButton') - self.gradientLayout.addRow(self.gradientStartLabel, - self.gradientStartButton) + self.gradientLayout.addRow(self.gradientStartLabel, self.gradientStartButton) self.gradientEndLabel = QtGui.QLabel(self.gradientWidget) self.gradientEndLabel.setObjectName(u'GradientEndLabel') self.gradientEndButton = QtGui.QPushButton(self.gradientWidget) self.gradientEndButton.setObjectName(u'GradientEndButton') - self.gradientLayout.addRow(self.gradientEndLabel, - self.gradientEndButton) + self.gradientLayout.addRow(self.gradientEndLabel, self.gradientEndButton) self.gradientTypeLabel = QtGui.QLabel(self.gradientWidget) self.gradientTypeLabel.setObjectName(u'GradientTypeLabel') self.gradientComboBox = QtGui.QComboBox(self.gradientWidget) self.gradientComboBox.setObjectName(u'GradientComboBox') self.gradientComboBox.addItems([u'', u'', u'', u'', u'']) - self.gradientLayout.addRow(self.gradientTypeLabel, - self.gradientComboBox) + self.gradientLayout.addRow(self.gradientTypeLabel, self.gradientComboBox) self.gradientLayout.setItem(3, QtGui.QFormLayout.LabelRole, self.spacer) self.backgroundStack.addWidget(self.gradientWidget) self.imageWidget = QtGui.QWidget(self.backgroundPage) @@ -123,8 +115,7 @@ class Ui_ThemeWizard(object): self.imageFileLayout.addWidget(self.imageFileEdit) self.imageBrowseButton = QtGui.QToolButton(self.imageWidget) self.imageBrowseButton.setObjectName(u'ImageBrowseButton') - self.imageBrowseButton.setIcon( - build_icon(u':/general/general_open.png')) + self.imageBrowseButton.setIcon(build_icon(u':/general/general_open.png')) self.imageFileLayout.addWidget(self.imageBrowseButton) self.imageLayout.addRow(self.imageLabel, self.imageFileLayout) self.imageLayout.setItem(2, QtGui.QFormLayout.LabelRole, self.spacer) @@ -162,8 +153,7 @@ class Ui_ThemeWizard(object): self.mainItalicsCheckBox = QtGui.QCheckBox(self.mainAreaPage) self.mainItalicsCheckBox.setObjectName(u'MainItalicsCheckBox') self.mainPropertiesLayout.addWidget(self.mainItalicsCheckBox) - self.mainAreaLayout.addRow(self.mainColorLabel, - self.mainPropertiesLayout) + self.mainAreaLayout.addRow(self.mainColorLabel, self.mainPropertiesLayout) self.mainSizeLabel = QtGui.QLabel(self.mainAreaPage) self.mainSizeLabel.setObjectName(u'MainSizeLabel') self.mainSizeLayout = QtGui.QHBoxLayout() @@ -183,8 +173,7 @@ class Ui_ThemeWizard(object): self.lineSpacingSpinBox.setMinimum(-50) self.lineSpacingSpinBox.setMaximum(50) self.lineSpacingSpinBox.setObjectName(u'LineSpacingSpinBox') - self.mainAreaLayout.addRow(self.lineSpacingLabel, - self.lineSpacingSpinBox) + self.mainAreaLayout.addRow(self.lineSpacingLabel, self.lineSpacingSpinBox) self.outlineCheckBox = QtGui.QCheckBox(self.mainAreaPage) self.outlineCheckBox.setObjectName(u'OutlineCheckBox') self.outlineLayout = QtGui.QHBoxLayout() @@ -229,24 +218,20 @@ class Ui_ThemeWizard(object): self.footerFontLabel.setObjectName(u'FooterFontLabel') self.footerFontComboBox = QtGui.QFontComboBox(self.footerAreaPage) self.footerFontComboBox.setObjectName(u'footerFontComboBox') - self.footerAreaLayout.addRow(self.footerFontLabel, - self.footerFontComboBox) + self.footerAreaLayout.addRow(self.footerFontLabel, self.footerFontComboBox) self.footerColorLabel = QtGui.QLabel(self.footerAreaPage) self.footerColorLabel.setObjectName(u'FooterColorLabel') self.footerColorButton = QtGui.QPushButton(self.footerAreaPage) self.footerColorButton.setObjectName(u'footerColorButton') - self.footerAreaLayout.addRow(self.footerColorLabel, - self.footerColorButton) + self.footerAreaLayout.addRow(self.footerColorLabel, self.footerColorButton) self.footerSizeLabel = QtGui.QLabel(self.footerAreaPage) self.footerSizeLabel.setObjectName(u'FooterSizeLabel') self.footerSizeSpinBox = QtGui.QSpinBox(self.footerAreaPage) self.footerSizeSpinBox.setMaximum(999) self.footerSizeSpinBox.setValue(10) self.footerSizeSpinBox.setObjectName(u'FooterSizeSpinBox') - self.footerAreaLayout.addRow(self.footerSizeLabel, - self.footerSizeSpinBox) - self.footerAreaLayout.setItem(3, QtGui.QFormLayout.LabelRole, - self.spacer) + self.footerAreaLayout.addRow(self.footerSizeLabel, self.footerSizeSpinBox) + self.footerAreaLayout.setItem(3, QtGui.QFormLayout.LabelRole, self.spacer) themeWizard.addPage(self.footerAreaPage) # Alignment Page self.alignmentPage = QtGui.QWizardPage() @@ -258,10 +243,8 @@ class Ui_ThemeWizard(object): self.horizontalComboBox = QtGui.QComboBox(self.alignmentPage) self.horizontalComboBox.addItems([u'', u'', u'', u'']) self.horizontalComboBox.setObjectName(u'HorizontalComboBox') - self.alignmentLayout.addRow(self.horizontalLabel, - self.horizontalComboBox) - self.verticalLabel, self.verticalComboBox = \ - create_valign_selection_widgets(self.alignmentPage) + self.alignmentLayout.addRow(self.horizontalLabel, self.horizontalComboBox) + self.verticalLabel, self.verticalComboBox = create_valign_selection_widgets(self.alignmentPage) self.verticalLabel.setObjectName(u'verticalLabel') self.verticalComboBox.setObjectName(u'verticalComboBox') self.alignmentLayout.addRow(self.verticalLabel, self.verticalComboBox) @@ -269,10 +252,8 @@ class Ui_ThemeWizard(object): self.transitionsLabel.setObjectName(u'TransitionsLabel') self.transitionsCheckBox = QtGui.QCheckBox(self.alignmentPage) self.transitionsCheckBox.setObjectName(u'TransitionsCheckBox') - self.alignmentLayout.addRow(self.transitionsLabel, - self.transitionsCheckBox) - self.alignmentLayout.setItem(3, QtGui.QFormLayout.LabelRole, - self.spacer) + self.alignmentLayout.addRow(self.transitionsLabel, self.transitionsCheckBox) + self.alignmentLayout.setItem(3, QtGui.QFormLayout.LabelRole, self.spacer) themeWizard.addPage(self.alignmentPage) # Area Position Page self.areaPositionPage = QtGui.QWizardPage() @@ -303,23 +284,19 @@ class Ui_ThemeWizard(object): self.mainWidthSpinBox = QtGui.QSpinBox(self.mainPositionGroupBox) self.mainWidthSpinBox.setMaximum(9999) self.mainWidthSpinBox.setObjectName(u'MainWidthSpinBox') - self.mainPositionLayout.addRow(self.mainWidthLabel, - self.mainWidthSpinBox) + self.mainPositionLayout.addRow(self.mainWidthLabel, self.mainWidthSpinBox) self.mainHeightLabel = QtGui.QLabel(self.mainPositionGroupBox) self.mainHeightLabel.setObjectName(u'MainHeightLabel') self.mainHeightSpinBox = QtGui.QSpinBox(self.mainPositionGroupBox) self.mainHeightSpinBox.setMaximum(9999) self.mainHeightSpinBox.setObjectName(u'MainHeightSpinBox') - self.mainPositionLayout.addRow(self.mainHeightLabel, - self.mainHeightSpinBox) + self.mainPositionLayout.addRow(self.mainHeightLabel, self.mainHeightSpinBox) self.areaPositionLayout.addWidget(self.mainPositionGroupBox) self.footerPositionGroupBox = QtGui.QGroupBox(self.areaPositionPage) self.footerPositionGroupBox.setObjectName(u'FooterPositionGroupBox') - self.footerPositionLayout = QtGui.QFormLayout( - self.footerPositionGroupBox) + self.footerPositionLayout = QtGui.QFormLayout(self.footerPositionGroupBox) self.footerPositionLayout.setObjectName(u'FooterPositionLayout') - self.footerPositionCheckBox = QtGui.QCheckBox( - self.footerPositionGroupBox) + self.footerPositionCheckBox = QtGui.QCheckBox(self.footerPositionGroupBox) self.footerPositionCheckBox.setObjectName(u'FooterPositionCheckBox') self.footerPositionLayout.addRow(self.footerPositionCheckBox) self.footerXLabel = QtGui.QLabel(self.footerPositionGroupBox) @@ -339,15 +316,13 @@ class Ui_ThemeWizard(object): self.footerWidthSpinBox = QtGui.QSpinBox(self.footerPositionGroupBox) self.footerWidthSpinBox.setMaximum(9999) self.footerWidthSpinBox.setObjectName(u'FooterWidthSpinBox') - self.footerPositionLayout.addRow(self.footerWidthLabel, - self.footerWidthSpinBox) + self.footerPositionLayout.addRow(self.footerWidthLabel, self.footerWidthSpinBox) self.footerHeightLabel = QtGui.QLabel(self.footerPositionGroupBox) self.footerHeightLabel.setObjectName(u'FooterHeightLabel') self.footerHeightSpinBox = QtGui.QSpinBox(self.footerPositionGroupBox) self.footerHeightSpinBox.setMaximum(9999) self.footerHeightSpinBox.setObjectName(u'FooterHeightSpinBox') - self.footerPositionLayout.addRow(self.footerHeightLabel, - self.footerHeightSpinBox) + self.footerPositionLayout.addRow(self.footerHeightLabel, self.footerHeightSpinBox) self.areaPositionLayout.addWidget(self.footerPositionGroupBox) themeWizard.addPage(self.areaPositionPage) # Preview Page @@ -360,8 +335,7 @@ class Ui_ThemeWizard(object): self.themeNameLabel = QtGui.QLabel(self.previewPage) self.themeNameLabel.setObjectName(u'ThemeNameLabel') self.themeNameEdit = QtGui.QLineEdit(self.previewPage) - self.themeNameEdit.setValidator(QtGui.QRegExpValidator( - QtCore.QRegExp(r'[^/\\?*|<>\[\]":<>+%]+'), self)) + self.themeNameEdit.setValidator(QtGui.QRegExpValidator(QtCore.QRegExp(r'[^/\\?*|<>\[\]":<>+%]+'), self)) self.themeNameEdit.setObjectName(u'ThemeNameEdit') self.themeNameLayout.addRow(self.themeNameLabel, self.themeNameEdit) self.previewLayout.addLayout(self.themeNameLayout) @@ -380,78 +354,55 @@ class Ui_ThemeWizard(object): self.previewLayout.addWidget(self.previewArea) themeWizard.addPage(self.previewPage) self.retranslateUi(themeWizard) - QtCore.QObject.connect(self.backgroundComboBox, - QtCore.SIGNAL(u'currentIndexChanged(int)'), self.backgroundStack, - QtCore.SLOT(u'setCurrentIndex(int)')) - QtCore.QObject.connect(self.outlineCheckBox, - QtCore.SIGNAL(u'toggled(bool)'), self.outlineColorButton, + QtCore.QObject.connect(self.backgroundComboBox, QtCore.SIGNAL(u'currentIndexChanged(int)'), + self.backgroundStack, QtCore.SLOT(u'setCurrentIndex(int)')) + QtCore.QObject.connect(self.outlineCheckBox, QtCore.SIGNAL(u'toggled(bool)'), self.outlineColorButton, QtCore.SLOT(u'setEnabled(bool)')) - QtCore.QObject.connect(self.outlineCheckBox, - QtCore.SIGNAL(u'toggled(bool)'), self.outlineSizeSpinBox, + QtCore.QObject.connect(self.outlineCheckBox, QtCore.SIGNAL(u'toggled(bool)'), self.outlineSizeSpinBox, QtCore.SLOT(u'setEnabled(bool)')) - QtCore.QObject.connect(self.shadowCheckBox, - QtCore.SIGNAL(u'toggled(bool)'), self.shadowColorButton, + QtCore.QObject.connect(self.shadowCheckBox, QtCore.SIGNAL(u'toggled(bool)'), self.shadowColorButton, QtCore.SLOT(u'setEnabled(bool)')) - QtCore.QObject.connect(self.shadowCheckBox, - QtCore.SIGNAL(u'toggled(bool)'), self.shadowSizeSpinBox, + QtCore.QObject.connect(self.shadowCheckBox, QtCore.SIGNAL(u'toggled(bool)'), self.shadowSizeSpinBox, QtCore.SLOT(u'setEnabled(bool)')) - QtCore.QObject.connect(self.mainPositionCheckBox, - QtCore.SIGNAL(u'toggled(bool)'), self.mainXSpinBox, + QtCore.QObject.connect(self.mainPositionCheckBox, QtCore.SIGNAL(u'toggled(bool)'), self.mainXSpinBox, QtCore.SLOT(u'setDisabled(bool)')) - QtCore.QObject.connect(self.mainPositionCheckBox, - QtCore.SIGNAL(u'toggled(bool)'), self.mainYSpinBox, + QtCore.QObject.connect(self.mainPositionCheckBox, QtCore.SIGNAL(u'toggled(bool)'), self.mainYSpinBox, QtCore.SLOT(u'setDisabled(bool)')) - QtCore.QObject.connect(self.mainPositionCheckBox, - QtCore.SIGNAL(u'toggled(bool)'), self.mainWidthSpinBox, + QtCore.QObject.connect(self.mainPositionCheckBox, QtCore.SIGNAL(u'toggled(bool)'), self.mainWidthSpinBox, QtCore.SLOT(u'setDisabled(bool)')) - QtCore.QObject.connect(self.mainPositionCheckBox, - QtCore.SIGNAL(u'toggled(bool)'), self.mainHeightSpinBox, + QtCore.QObject.connect(self.mainPositionCheckBox, QtCore.SIGNAL(u'toggled(bool)'), self.mainHeightSpinBox, QtCore.SLOT(u'setDisabled(bool)')) - QtCore.QObject.connect(self.footerPositionCheckBox, - QtCore.SIGNAL(u'toggled(bool)'), self.footerXSpinBox, + QtCore.QObject.connect(self.footerPositionCheckBox,QtCore.SIGNAL(u'toggled(bool)'), self.footerXSpinBox, QtCore.SLOT(u'setDisabled(bool)')) - QtCore.QObject.connect(self.footerPositionCheckBox, - QtCore.SIGNAL(u'toggled(bool)'), self.footerYSpinBox, + QtCore.QObject.connect(self.footerPositionCheckBox, QtCore.SIGNAL(u'toggled(bool)'), self.footerYSpinBox, QtCore.SLOT(u'setDisabled(bool)')) - QtCore.QObject.connect(self.footerPositionCheckBox, - QtCore.SIGNAL(u'toggled(bool)'), self.footerWidthSpinBox, + QtCore.QObject.connect(self.footerPositionCheckBox, QtCore.SIGNAL(u'toggled(bool)'), self.footerWidthSpinBox, QtCore.SLOT(u'setDisabled(bool)')) - QtCore.QObject.connect(self.footerPositionCheckBox, - QtCore.SIGNAL(u'toggled(bool)'), self.footerHeightSpinBox, + QtCore.QObject.connect(self.footerPositionCheckBox, QtCore.SIGNAL(u'toggled(bool)'), self.footerHeightSpinBox, QtCore.SLOT(u'setDisabled(bool)')) def retranslateUi(self, themeWizard): - themeWizard.setWindowTitle( - translate('OpenLP.ThemeWizard', 'Theme Wizard')) - self.titleLabel.setText( - u'%s' % \ + themeWizard.setWindowTitle(translate('OpenLP.ThemeWizard', 'Theme Wizard')) + self.titleLabel.setText(u'%s' % \ translate('OpenLP.ThemeWizard', 'Welcome to the Theme Wizard')) self.informationLabel.setText( translate('OpenLP.ThemeWizard', 'This wizard will help you to ' 'create and edit your themes. Click the next button below to ' 'start the process by setting up your background.')) - self.backgroundPage.setTitle( - translate('OpenLP.ThemeWizard', 'Set Up Background')) - self.backgroundPage.setSubTitle( - translate('OpenLP.ThemeWizard', 'Set up your theme\'s background ' + self.backgroundPage.setTitle(translate('OpenLP.ThemeWizard', 'Set Up Background')) + self.backgroundPage.setSubTitle(translate('OpenLP.ThemeWizard', 'Set up your theme\'s background ' 'according to the parameters below.')) - self.backgroundLabel.setText( - translate('OpenLP.ThemeWizard', 'Background type:')) + self.backgroundLabel.setText(translate('OpenLP.ThemeWizard', 'Background type:')) self.backgroundComboBox.setItemText(BackgroundType.Solid, translate('OpenLP.ThemeWizard', 'Solid Color')) self.backgroundComboBox.setItemText(BackgroundType.Gradient, translate('OpenLP.ThemeWizard', 'Gradient')) - self.backgroundComboBox.setItemText( - BackgroundType.Image, UiStrings().Image) - self.backgroundComboBox.setItemText(BackgroundType.Transparent, - translate('OpenLP.ThemeWizard', 'Transparent')) + self.backgroundComboBox.setItemText(BackgroundType.Image, UiStrings().Image) + self.backgroundComboBox.setItemText(BackgroundType.Transparent, translate('OpenLP.ThemeWizard', 'Transparent')) self.colorLabel.setText(translate('OpenLP.ThemeWizard', 'Color:')) - self.gradientStartLabel.setText( - translate(u'OpenLP.ThemeWizard', 'Starting color:')) - self.gradientEndLabel.setText( - translate(u'OpenLP.ThemeWizard', 'Ending color:')) - self.gradientTypeLabel.setText( - translate('OpenLP.ThemeWizard', 'Gradient:')) + self.gradientStartLabel.setText(translate(u'OpenLP.ThemeWizard', 'Starting color:')) + self.gradientEndLabel.setText(translate(u'OpenLP.ThemeWizard', 'Ending color:')) + self.gradientTypeLabel.setText(translate('OpenLP.ThemeWizard', 'Gradient:')) self.gradientComboBox.setItemText(BackgroundGradientType.Horizontal, translate('OpenLP.ThemeWizard', 'Horizontal')) self.gradientComboBox.setItemText(BackgroundGradientType.Vertical, @@ -462,66 +413,46 @@ class Ui_ThemeWizard(object): translate('OpenLP.ThemeWizard', 'Top Left - Bottom Right')) self.gradientComboBox.setItemText(BackgroundGradientType.LeftBottom, translate('OpenLP.ThemeWizard', 'Bottom Left - Top Right')) - self.imageColorLabel.setText( - translate(u'OpenLP.ThemeWizard', 'Background color:')) + self.imageColorLabel.setText(translate(u'OpenLP.ThemeWizard', 'Background color:')) self.imageLabel.setText(u'%s:' % UiStrings().Image) - self.mainAreaPage.setTitle( - translate('OpenLP.ThemeWizard', 'Main Area Font Details')) - self.mainAreaPage.setSubTitle( - translate('OpenLP.ThemeWizard', 'Define the font and display ' + self.mainAreaPage.setTitle(translate('OpenLP.ThemeWizard', 'Main Area Font Details')) + self.mainAreaPage.setSubTitle(translate('OpenLP.ThemeWizard', 'Define the font and display ' 'characteristics for the Display text')) self.mainFontLabel.setText(translate('OpenLP.ThemeWizard', 'Font:')) self.mainColorLabel.setText(translate('OpenLP.ThemeWizard', 'Color:')) self.mainSizeLabel.setText(translate('OpenLP.ThemeWizard', 'Size:')) self.mainSizeSpinBox.setSuffix(UiStrings().FontSizePtUnit) - self.lineSpacingLabel.setText( - translate('OpenLP.ThemeWizard', 'Line Spacing:')) + self.lineSpacingLabel.setText(translate('OpenLP.ThemeWizard', 'Line Spacing:')) self.lineSpacingSpinBox.setSuffix(UiStrings().FontSizePtUnit) - self.outlineCheckBox.setText( - translate('OpenLP.ThemeWizard', '&Outline:')) + self.outlineCheckBox.setText(translate('OpenLP.ThemeWizard', '&Outline:')) self.outlineSizeLabel.setText(translate('OpenLP.ThemeWizard', 'Size:')) self.outlineSizeSpinBox.setSuffix(UiStrings().FontSizePtUnit) self.shadowCheckBox.setText(translate('OpenLP.ThemeWizard', '&Shadow:')) self.shadowSizeLabel.setText(translate('OpenLP.ThemeWizard', 'Size:')) self.shadowSizeSpinBox.setSuffix(UiStrings().FontSizePtUnit) self.mainBoldCheckBox.setText(translate('OpenLP.ThemeWizard', 'Bold')) - self.mainItalicsCheckBox.setText( - translate('OpenLP.ThemeWizard', 'Italic')) - self.footerAreaPage.setTitle( - translate('OpenLP.ThemeWizard', 'Footer Area Font Details')) - self.footerAreaPage.setSubTitle( - translate('OpenLP.ThemeWizard', 'Define the font and display ' + self.mainItalicsCheckBox.setText(translate('OpenLP.ThemeWizard', 'Italic')) + self.footerAreaPage.setTitle(translate('OpenLP.ThemeWizard', 'Footer Area Font Details')) + self.footerAreaPage.setSubTitle(translate('OpenLP.ThemeWizard', 'Define the font and display ' 'characteristics for the Footer text')) self.footerFontLabel.setText(translate('OpenLP.ThemeWizard', 'Font:')) self.footerColorLabel.setText(translate('OpenLP.ThemeWizard', 'Color:')) self.footerSizeLabel.setText(translate('OpenLP.ThemeWizard', 'Size:')) self.footerSizeSpinBox.setSuffix(UiStrings().FontSizePtUnit) - self.alignmentPage.setTitle( - translate('OpenLP.ThemeWizard', 'Text Formatting Details')) - self.alignmentPage.setSubTitle( - translate('OpenLP.ThemeWizard', 'Allows additional display ' + self.alignmentPage.setTitle(translate('OpenLP.ThemeWizard', 'Text Formatting Details')) + self.alignmentPage.setSubTitle(translate('OpenLP.ThemeWizard', 'Allows additional display ' 'formatting information to be defined')) - self.horizontalLabel.setText( - translate('OpenLP.ThemeWizard', 'Horizontal Align:')) - self.horizontalComboBox.setItemText(HorizontalType.Left, - translate('OpenLP.ThemeWizard', 'Left')) - self.horizontalComboBox.setItemText(HorizontalType.Right, - translate('OpenLP.ThemeWizard', 'Right')) - self.horizontalComboBox.setItemText(HorizontalType.Center, - translate('OpenLP.ThemeWizard', 'Center')) - self.horizontalComboBox.setItemText(HorizontalType.Justify, - translate('OpenLP.ThemeWizard', 'Justify')) - self.transitionsLabel.setText( - translate('OpenLP.ThemeWizard', 'Transitions:')) - self.areaPositionPage.setTitle( - translate('OpenLP.ThemeWizard', 'Output Area Locations')) - self.areaPositionPage.setSubTitle( - translate('OpenLP.ThemeWizard', 'Allows you to change and move the' + self.horizontalLabel.setText(translate('OpenLP.ThemeWizard', 'Horizontal Align:')) + self.horizontalComboBox.setItemText(HorizontalType.Left, translate('OpenLP.ThemeWizard', 'Left')) + self.horizontalComboBox.setItemText(HorizontalType.Right, translate('OpenLP.ThemeWizard', 'Right')) + self.horizontalComboBox.setItemText(HorizontalType.Center, translate('OpenLP.ThemeWizard', 'Center')) + self.horizontalComboBox.setItemText(HorizontalType.Justify, translate('OpenLP.ThemeWizard', 'Justify')) + self.transitionsLabel.setText(translate('OpenLP.ThemeWizard', 'Transitions:')) + self.areaPositionPage.setTitle(translate('OpenLP.ThemeWizard', 'Output Area Locations')) + self.areaPositionPage.setSubTitle(translate('OpenLP.ThemeWizard', 'Allows you to change and move the' ' main and footer areas.')) - self.mainPositionGroupBox.setTitle( - translate('OpenLP.ThemeWizard', '&Main Area')) - self.mainPositionCheckBox.setText( - translate('OpenLP.ThemeWizard', '&Use default location')) + self.mainPositionGroupBox.setTitle(translate('OpenLP.ThemeWizard', '&Main Area')) + self.mainPositionCheckBox.setText(translate('OpenLP.ThemeWizard', '&Use default location')) self.mainXLabel.setText(translate('OpenLP.ThemeWizard', 'X position:')) self.mainXSpinBox.setSuffix(translate('OpenLP.ThemeWizard', 'px')) self.mainYSpinBox.setSuffix(translate('OpenLP.ThemeWizard', 'px')) @@ -529,37 +460,24 @@ class Ui_ThemeWizard(object): self.mainWidthSpinBox.setSuffix(translate('OpenLP.ThemeWizard', 'px')) self.mainWidthLabel.setText(translate('OpenLP.ThemeWizard', 'Width:')) self.mainHeightSpinBox.setSuffix(translate('OpenLP.ThemeWizard', 'px')) - self.mainHeightLabel.setText( - translate('OpenLP.ThemeWizard', 'Height:')) - self.footerPositionGroupBox.setTitle( - translate('OpenLP.ThemeWizard', '&Footer Area')) - self.footerXLabel.setText( - translate('OpenLP.ThemeWizard', 'X position:')) + self.mainHeightLabel.setText(translate('OpenLP.ThemeWizard', 'Height:')) + self.footerPositionGroupBox.setTitle(translate('OpenLP.ThemeWizard', '&Footer Area')) + self.footerXLabel.setText(translate('OpenLP.ThemeWizard', 'X position:')) self.footerXSpinBox.setSuffix(translate('OpenLP.ThemeWizard', 'px')) - self.footerYLabel.setText( - translate('OpenLP.ThemeWizard', 'Y position:')) + self.footerYLabel.setText(translate('OpenLP.ThemeWizard', 'Y position:')) self.footerYSpinBox.setSuffix(translate('OpenLP.ThemeWizard', 'px')) - self.footerWidthLabel.setText( - translate('OpenLP.ThemeWizard', 'Width:')) - self.footerWidthSpinBox.setSuffix( - translate('OpenLP.ThemeWizard', 'px')) - self.footerHeightLabel.setText( - translate('OpenLP.ThemeWizard', 'Height:')) - self.footerHeightSpinBox.setSuffix( - translate('OpenLP.ThemeWizard', 'px')) - self.footerPositionCheckBox.setText( - translate('OpenLP.ThemeWizard', 'Use default location')) + self.footerWidthLabel.setText(translate('OpenLP.ThemeWizard', 'Width:')) + self.footerWidthSpinBox.setSuffix(translate('OpenLP.ThemeWizard', 'px')) + self.footerHeightLabel.setText(translate('OpenLP.ThemeWizard', 'Height:')) + self.footerHeightSpinBox.setSuffix(translate('OpenLP.ThemeWizard', 'px')) + self.footerPositionCheckBox.setText(translate('OpenLP.ThemeWizard', 'Use default location')) themeWizard.setOption(QtGui.QWizard.HaveCustomButton1, False) themeWizard.setButtonText(QtGui.QWizard.CustomButton1, translate('OpenLP.ThemeWizard', 'Layout Preview')) - self.previewPage.setTitle( - translate('OpenLP.ThemeWizard', 'Preview and Save')) - self.previewPage.setSubTitle( - translate('OpenLP.ThemeWizard', 'Preview the theme and save it.')) - self.themeNameLabel.setText( - translate('OpenLP.ThemeWizard', 'Theme name:')) + self.previewPage.setTitle(translate('OpenLP.ThemeWizard', 'Preview and Save')) + self.previewPage.setSubTitle(translate('OpenLP.ThemeWizard', 'Preview the theme and save it.')) + self.themeNameLabel.setText(translate('OpenLP.ThemeWizard', 'Theme name:')) # Align all QFormLayouts towards each other. labelWidth = max(self.backgroundLabel.minimumSizeHint().width(), self.horizontalLabel.minimumSizeHint().width()) - self.spacer.changeSize(labelWidth, 0, - QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) + self.spacer.changeSize(labelWidth, 0, QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) diff --git a/openlp/core/ui/wizard.py b/openlp/core/ui/wizard.py index 24f353084..4b973167e 100644 --- a/openlp/core/ui/wizard.py +++ b/openlp/core/ui/wizard.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 ############################################################################### # OpenLP - Open Source Lyrics Projection # @@ -60,8 +60,7 @@ class WizardStrings(object): 'Select the import format and the location to import from.') NoSqlite = translate('OpenLP.Ui', 'The openlp.org 1.x importer has been ' 'disabled due to a missing Python module. If you want to use this ' - 'importer, you will need to install the "python-sqlite" ' - 'module.') + 'importer, you will need to install the "python-sqlite" module.') OpenTypeFile = translate('OpenLP.Ui', 'Open %s File') OpenTypeFolder = translate('OpenLP.Ui', 'Open %s Folder') PercentSymbolFormat = translate('OpenLP.Ui', '%p%') @@ -92,12 +91,9 @@ class OpenLPWizard(QtGui.QWizard): self.registerFields() self.customInit() self.customSignals() - QtCore.QObject.connect(self, QtCore.SIGNAL(u'currentIdChanged(int)'), - self.onCurrentIdChanged) - QtCore.QObject.connect(self.errorCopyToButton, - QtCore.SIGNAL(u'clicked()'), self.onErrorCopyToButtonClicked) - QtCore.QObject.connect(self.errorSaveToButton, - QtCore.SIGNAL(u'clicked()'), self.onErrorSaveToButtonClicked) + QtCore.QObject.connect(self, QtCore.SIGNAL(u'currentIdChanged(int)'), self.onCurrentIdChanged) + QtCore.QObject.connect(self.errorCopyToButton, QtCore.SIGNAL(u'clicked()'), self.onErrorCopyToButtonClicked) + QtCore.QObject.connect(self.errorSaveToButton, QtCore.SIGNAL(u'clicked()'), self.onErrorSaveToButtonClicked) def setupUi(self, image): """ @@ -145,20 +141,17 @@ class OpenLPWizard(QtGui.QWizard): self.progressLayout.addWidget(self.errorReportTextEdit) self.errorButtonLayout = QtGui.QHBoxLayout() self.errorButtonLayout.setObjectName(u'errorButtonLayout') - spacer = QtGui.QSpacerItem(40, 20, - QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) + spacer = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) self.errorButtonLayout.addItem(spacer) self.errorCopyToButton = QtGui.QPushButton(self.progressPage) self.errorCopyToButton.setObjectName(u'errorCopyToButton') self.errorCopyToButton.setHidden(True) - self.errorCopyToButton.setIcon( - build_icon(u':/system/system_edit_copy.png')) + self.errorCopyToButton.setIcon(build_icon(u':/system/system_edit_copy.png')) self.errorButtonLayout.addWidget(self.errorCopyToButton) self.errorSaveToButton = QtGui.QPushButton(self.progressPage) self.errorSaveToButton.setObjectName(u'errorSaveToButton') self.errorSaveToButton.setHidden(True) - self.errorSaveToButton.setIcon( - build_icon(u':/general/general_save.png')) + self.errorSaveToButton.setIcon(build_icon(u':/general/general_save.png')) self.errorButtonLayout.addWidget(self.errorSaveToButton) self.progressLayout.addLayout(self.errorButtonLayout) self.addPage(self.progressPage) @@ -280,9 +273,8 @@ class OpenLPWizard(QtGui.QWizard): An editbox (QLineEdit). """ folder = unicode(QtGui.QFileDialog.getExistingDirectory(self, title, - os.path.dirname(SettingsManager.get_last_dir( - self.plugin.settingsSection, 1)), QtGui.QFileDialog.ShowDirsOnly)) + os.path.dirname(SettingsManager.get_last_dir(self.plugin.settingsSection, 1)), + QtGui.QFileDialog.ShowDirsOnly)) if folder: editbox.setText(folder) - SettingsManager.set_last_dir(self.plugin.settingsSection, - folder, 1) + SettingsManager.set_last_dir(self.plugin.settingsSection, folder, 1) From 9f28874eb5984cc7ee835d925f4334783fe53136 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sat, 29 Dec 2012 18:13:08 +0000 Subject: [PATCH 53/53] Code fixes --- openlp/core/ui/advancedtab.py | 2 +- openlp/core/ui/firsttimeform.py | 5 ++--- openlp/core/ui/mainwindow.py | 2 +- openlp/core/ui/themeform.py | 1 + 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/openlp/core/ui/advancedtab.py b/openlp/core/ui/advancedtab.py index bdb24c04b..29efddb76 100644 --- a/openlp/core/ui/advancedtab.py +++ b/openlp/core/ui/advancedtab.py @@ -596,7 +596,7 @@ class AdvancedTab(SettingsTab): # Check is they want to replace existing data. answer = QtGui.QMessageBox.warning(self, translate('OpenLP.AdvancedTab', 'Overwrite Existing Data'), - translate('OpenLP.AdvancedTab', 'WARNING: \n\n The location you have selected \n\n%s\n\n' + translate('OpenLP.AdvancedTab', 'WARNING: \n\nThe location you have selected \n\n%s\n\n' 'appears to contain OpenLP data files. Do you wish to replace these files with the current data files?' ).replace('%s', os.path.abspath(data_path,)), QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes | QtGui.QMessageBox.No), QtGui.QMessageBox.No) diff --git a/openlp/core/ui/firsttimeform.py b/openlp/core/ui/firsttimeform.py index 04320f6c1..a8fb342e4 100644 --- a/openlp/core/ui/firsttimeform.py +++ b/openlp/core/ui/firsttimeform.py @@ -91,8 +91,7 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): self.config.readfp(io.BytesIO(files)) self.updateScreenListCombo() self.downloadCancelled = False - self.downloading = translate('OpenLP.FirstTimeWizard', - 'Downloading %s...') + self.downloading = translate('OpenLP.FirstTimeWizard', 'Downloading %s...') QtCore.QObject.connect(self.cancelButton, QtCore.SIGNAL('clicked()'), self.onCancelButtonClicked) QtCore.QObject.connect(self.noInternetFinishButton, QtCore.SIGNAL('clicked()'), @@ -382,7 +381,7 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): self.progressBar.setValue(self.progressBar.maximum()) if self.hasRunWizard: self.progressLabel.setText(translate('OpenLP.FirstTimeWizard', - 'Download complete. Click the finish button to return to OpenLP.')) + 'Download complete. Click the finish button to return to OpenLP.')) else: self.progressLabel.setText(translate('OpenLP.FirstTimeWizard', 'Download complete. Click the finish button to start OpenLP.')) diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index dd7677ae1..1258c552f 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -848,7 +848,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): if not section in setting_sections: QtGui.QMessageBox.critical(self, translate('OpenLP.MainWindow', 'Import settings'), translate('OpenLP.MainWindow', 'The file you selected does appear to be a valid OpenLP ' - 'settings file.\n\n Section [%s] is not valid \n\n' + 'settings file.\n\nSection [%s] is not valid \n\n' 'Processing has terminated and no changed have been made.').replace('%s', section), QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok)) return diff --git a/openlp/core/ui/themeform.py b/openlp/core/ui/themeform.py index 16a123dec..0ffec4877 100644 --- a/openlp/core/ui/themeform.py +++ b/openlp/core/ui/themeform.py @@ -90,6 +90,7 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard): QtCore.QObject.connect(self.mainSizeSpinBox, QtCore.SIGNAL(u'valueChanged(int)'), self.calculateLines) QtCore.QObject.connect(self.lineSpacingSpinBox, QtCore.SIGNAL(u'valueChanged(int)'), self.calculateLines) QtCore.QObject.connect(self.outlineSizeSpinBox, QtCore.SIGNAL(u'valueChanged(int)'), self.calculateLines) + QtCore.QObject.connect(self.shadowSizeSpinBox, QtCore.SIGNAL(u'valueChanged(int)'), self.calculateLines) QtCore.QObject.connect(self.mainFontComboBox, QtCore.SIGNAL(u'activated(int)'), self.calculateLines) QtCore.QObject.connect(self.footerFontComboBox, QtCore.SIGNAL(u'activated(int)'), self.updateTheme) QtCore.QObject.connect(self.footerSizeSpinBox, QtCore.SIGNAL(u'valueChanged(int)'), self.updateTheme)