diff --git a/openlp.pyw b/openlp.pyw index 69e36618c..0c1227b6a 100755 --- a/openlp.pyw +++ b/openlp.pyw @@ -120,7 +120,7 @@ class OpenLP(QtGui.QApplication): if os.name == u'nt': self.setStyleSheet(application_stylesheet) show_splash = QtCore.QSettings().value( - u'general/show splash', True).toBool() + u'general/show splash', QtCore.QVariant(True)).toBool() if show_splash: self.splash = SplashScreen(self.applicationVersion()) self.splash.show() @@ -130,8 +130,8 @@ class OpenLP(QtGui.QApplication): # Decide how many screens we have and their size for screen in xrange(0, self.desktop().numScreens()): screens.add_screen({u'number': screen, - u'size': self.desktop().availableGeometry(screen), - u'primary': (self.desktop().primaryScreen() == screen)}) + u'size': self.desktop().availableGeometry(screen), + u'primary': (self.desktop().primaryScreen() == screen)}) log.info(u'Screen %d found with resolution %s', screen, self.desktop().availableGeometry(screen)) # start the main app window @@ -196,4 +196,4 @@ if __name__ == u'__main__': """ Instantiate and run the application. """ - main() \ No newline at end of file + main() diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index bf27ed38a..2d16687f4 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -70,7 +70,7 @@ class MediaManagerItem(QtGui.QWidget): The user visible name for a plugin which should use a suitable translation function. - ``self.ConfigSection`` + ``self.SettingsSection`` The section in the configuration where the items in the media manager are stored. This could potentially be ``self.PluginNameShort.lower()``. @@ -335,15 +335,15 @@ class MediaManagerItem(QtGui.QWidget): def onFileClick(self): files = QtGui.QFileDialog.getOpenFileNames( self, self.OnNewPrompt, - SettingsManager.get_last_dir(self.ConfigSection), + SettingsManager.get_last_dir(self.SettingsSection), self.OnNewFileMasks) log.info(u'New files(s) %s', unicode(files)) if files: self.loadList(files) dir, filename = os.path.split(unicode(files[0])) - SettingsManager.set_last_dir(self.ConfigSection, dir) + SettingsManager.set_last_dir(self.SettingsSection, dir) SettingsManager.set_list( - self.ConfigSection, self.ConfigSection, self.getFileList()) + self.SettingsSection, self.SettingsSection, self.getFileList()) def getFileList(self): count = 0 @@ -454,7 +454,8 @@ class MediaManagerItem(QtGui.QWidget): if not service_item: QtGui.QMessageBox.information(self, self.trUtf8('No Service Item Selected'), - self.trUtf8('You must select a existing service item to add to.')) + self.trUtf8( + 'You must select an existing service item to add to.')) elif self.title.lower() == service_item.name.lower(): self.generateSlideData(service_item) self.parent.service_manager.addServiceItem(service_item, @@ -463,7 +464,8 @@ class MediaManagerItem(QtGui.QWidget): #Turn off the remote edit update message indicator QtGui.QMessageBox.information(self, self.trUtf8('Invalid Service Item'), - self.trUtf8(unicode('You must select a %s service item.' % self.title))) + self.trUtf8(unicode( + 'You must select a %s service item.' % self.title))) def buildServiceItem(self, item=None): """ diff --git a/openlp/core/lib/plugin.py b/openlp/core/lib/plugin.py index f01fa0807..c7a257700 100644 --- a/openlp/core/lib/plugin.py +++ b/openlp/core/lib/plugin.py @@ -51,6 +51,9 @@ class Plugin(QtCore.QObject): ``version`` The version number of this iteration of the plugin. + ``settings_section`` + The namespace to store settings for the plugin. + ``icon`` An instance of QIcon, which holds an icon for this plugin. @@ -113,6 +116,7 @@ class Plugin(QtCore.QObject): self.name = name if version: self.version = version + self.settings_section = self.name.lower() self.icon = None self.weight = 0 self.status = PluginStatus.Inactive @@ -143,7 +147,8 @@ class Plugin(QtCore.QObject): Sets the status of the plugin """ self.status = QtCore.QSettings().value( - self.name.lower() + u'/status', PluginStatus.Inactive).toInt()[0] + self.settings_section + u'/status', + QtCore.QVariant(PluginStatus.Inactive)).toInt()[0] def toggle_status(self, new_status): """ @@ -151,7 +156,7 @@ class Plugin(QtCore.QObject): """ self.status = new_status QtCore.QSettings().setValue( - self.name.lower() + u'/status', QtCore.QVariant(self.status)) + self.settings_section + u'/status', QtCore.QVariant(self.status)) def is_active(self): """ diff --git a/openlp/core/lib/settingsmanager.py b/openlp/core/lib/settingsmanager.py index 36caa38f5..de1401d56 100644 --- a/openlp/core/lib/settingsmanager.py +++ b/openlp/core/lib/settingsmanager.py @@ -76,7 +76,7 @@ class SettingsManager(object): else: name = u'last directory' last_dir = unicode(QtCore.QSettings().value( - section + u'/' + name, u'').toString()) + section + u'/' + name, QtCore.QVariant(u'')).toString()) return last_dir @staticmethod @@ -116,18 +116,19 @@ class SettingsManager(object): The list of values to save. """ settings = QtCore.QSettings() + settings.beginGroup(section) old_count = settings.value( - u'%s/%s count' % (section, name), 0).toInt()[0] + u'%s count' % name, QtCore.QVariant(0)).toInt()[0] new_count = len(list) - settings.setValue( - u'%s/%s count' % (section, name), QtCore.QVariant(new_count)) + settings.setValue(u'%s count' % name, QtCore.QVariant(new_count)) for counter in range (0, new_count): settings.setValue( - u'%s/%s %d' % (section, name, counter), list[counter-1]) + u'%s %d' % (name, counter), QtCore.QVariant(list[counter-1])) if old_count > new_count: # Tidy up any old list items for counter in range(new_count, old_count): - settings.remove(u'%s/%s %d' % (section, name, counter)) + settings.remove(u'%s %d' % (name, counter)) + settings.endGroup() @staticmethod def load_list(section, name): @@ -141,15 +142,17 @@ class SettingsManager(object): The name of the list. """ settings = QtCore.QSettings() + settings.beginGroup(section) list_count = settings.value( - u'%s/%s count' % (section, name), 0).toInt()[0] + u'%s count' % name, QtCore.QVariant(0)).toInt()[0] list = [] if list_count: for counter in range(0, list_count): - item = unicode(settings.value( - u'%s/%s %d' % (section, name, counter)).toString()) + item = unicode( + settings.value(u'%s %d' % (name, counter)).toString()) if item: list.append(item) + settings.endGroup() return list @staticmethod diff --git a/openlp/core/lib/settingstab.py b/openlp/core/lib/settingstab.py index 6f1aef854..0b862d9f8 100644 --- a/openlp/core/lib/settingstab.py +++ b/openlp/core/lib/settingstab.py @@ -40,6 +40,7 @@ class SettingsTab(QtGui.QWidget): QtGui.QWidget.__init__(self) self.tabTitle = title self.tabTitleVisible = None + self.settingsSection = self.tabTitle.lower() self.setupUi() self.retranslateUi() self.initialise() diff --git a/openlp/core/ui/generaltab.py b/openlp/core/ui/generaltab.py index 357756a08..005e588ac 100644 --- a/openlp/core/ui/generaltab.py +++ b/openlp/core/ui/generaltab.py @@ -42,13 +42,15 @@ class GeneralTab(SettingsTab): If not set before default to last screen. """ settings = QtCore.QSettings() - self.MonitorNumber = settings.value( - u'general/monitor', self.screens.monitor_number).toInt()[0] + settings.beginGroup(self.settingsSection) + self.MonitorNumber = settings.value(u'monitor', + QtCore.QVariant(self.screens.monitor_number)).toInt()[0] self.screens.set_current_display(self.MonitorNumber) self.screens.monitor_number = self.MonitorNumber self.DisplayOnMonitor = settings.value( - u'general/display on monitor', True).toBool() + u'display on monitor', QtCore.QVariant(True)).toBool() self.screens.display = self.DisplayOnMonitor + settings.endGroup() def setupUi(self): self.setObjectName(u'GeneralTab') @@ -227,6 +229,7 @@ class GeneralTab(SettingsTab): def load(self): settings = QtCore.QSettings() + settings.beginGroup(self.settingsSection) for screen in self.screens.screen_list: screen_name = u'%s %d' % (self.trUtf8('Screen'), screen[u'number'] + 1) @@ -235,21 +238,22 @@ class GeneralTab(SettingsTab): self.MonitorComboBox.addItem(screen_name) # Get the configs self.Warning = settings.value( - u'general/blank warning', QtCore.QVariant(False)).toBool() + u'blank warning', QtCore.QVariant(False)).toBool() self.AutoOpen = settings.value( - u'general/auto open', QtCore.QVariant(False)).toBool() + u'auto open', QtCore.QVariant(False)).toBool() self.ShowSplash = settings.value( - u'general/show splash', QtCore.QVariant(True)).toBool() + u'show splash', QtCore.QVariant(True)).toBool() self.PromptSaveService = settings.value( - u'general/save prompt', QtCore.QVariant(False)).toBool() + u'save prompt', QtCore.QVariant(False)).toBool() self.AutoPreview = settings.value( - u'general/auto preview', QtCore.QVariant(False)).toBool() + u'auto preview', QtCore.QVariant(False)).toBool() self.CCLINumber = unicode(settings.value( - u'general/ccli number', QtCore.QVariant(u'')).toString()) + u'ccli number', QtCore.QVariant(u'')).toString()) self.Username = unicode(settings.value( - u'general/songselect username', QtCore.QVariant(u'')).toString()) + u'songselect username', QtCore.QVariant(u'')).toString()) self.Password = unicode(settings.value( - u'general/songselect password', QtCore.QVariant(u'')).toString()) + u'songselect password', QtCore.QVariant(u'')).toString()) + settings.endGroup() self.SaveCheckServiceCheckBox.setChecked(self.PromptSaveService) # Set a few things up self.MonitorComboBox.setCurrentIndex(self.MonitorNumber) @@ -264,26 +268,22 @@ class GeneralTab(SettingsTab): def save(self): settings = QtCore.QSettings() - settings.setValue(u'general/monitor', - QtCore.QVariant(self.MonitorNumber)) - settings.setValue(u'general/display on monitor', + settings.beginGroup(self.settingsSection) + settings.setValue(u'monitor', QtCore.QVariant(self.MonitorNumber)) + settings.setValue(u'display on monitor', QtCore.QVariant(self.DisplayOnMonitor)) - settings.setValue(u'general/blank warning', - QtCore.QVariant(self.Warning)) - settings.setValue(u'general/auto open', - QtCore.QVariant(self.AutoOpen)) - settings.setValue(u'general/show splash', - QtCore.QVariant(self.ShowSplash)) - settings.setValue(u'general/save prompt', + settings.setValue(u'blank warning', QtCore.QVariant(self.Warning)) + settings.setValue(u'auto open', QtCore.QVariant(self.AutoOpen)) + settings.setValue(u'show splash', QtCore.QVariant(self.ShowSplash)) + settings.setValue(u'save prompt', QtCore.QVariant(self.PromptSaveService)) - settings.setValue(u'general/auto preview', - QtCore.QVariant(self.AutoPreview)) - settings.setValue(u'general/ccli number', - QtCore.QVariant(self.CCLINumber)) - settings.setValue(u'general/songselect username', + settings.setValue(u'auto preview', QtCore.QVariant(self.AutoPreview)) + settings.setValue(u'ccli number', QtCore.QVariant(self.CCLINumber)) + settings.setValue(u'songselect username', QtCore.QVariant(self.Username)) - settings.setValue(u'general/songselect password', + settings.setValue(u'songselect password', QtCore.QVariant(self.Password)) + settings.endGroup() self.screens.display = self.DisplayOnMonitor #Monitor Number has changed. if self.screens.monitor_number != self.MonitorNumber: diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index d1efc79c5..44341244d 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -362,12 +362,14 @@ class Ui_MainWindow(object): self.actionLook_Feel.setText(self.trUtf8('Look && &Feel')) self.OptionsSettingsItem.setText(self.trUtf8('&Settings')) self.ViewMediaManagerItem.setText(self.trUtf8('&Media Manager')) - self.ViewMediaManagerItem.setToolTip(self.trUtf8('Toggle Media Manager')) + self.ViewMediaManagerItem.setToolTip( + self.trUtf8('Toggle Media Manager')) self.ViewMediaManagerItem.setStatusTip( self.trUtf8('Toggle the visibility of the Media Manager')) self.ViewMediaManagerItem.setShortcut(self.trUtf8('F8')) self.ViewThemeManagerItem.setText(self.trUtf8('&Theme Manager')) - self.ViewThemeManagerItem.setToolTip(self.trUtf8('Toggle Theme Manager')) + self.ViewThemeManagerItem.setToolTip( + self.trUtf8('Toggle Theme Manager')) self.ViewThemeManagerItem.setStatusTip( self.trUtf8('Toggle the visibility of the Theme Manager')) self.ViewThemeManagerItem.setShortcut(self.trUtf8('F10')) @@ -378,7 +380,8 @@ class Ui_MainWindow(object): self.trUtf8('Toggle the visibility of the Service Manager')) self.ViewServiceManagerItem.setShortcut(self.trUtf8('F9')) self.action_Preview_Panel.setText(self.trUtf8('&Preview Panel')) - self.action_Preview_Panel.setToolTip(self.trUtf8('Toggle Preview Panel')) + self.action_Preview_Panel.setToolTip( + self.trUtf8('Toggle Preview Panel')) self.action_Preview_Panel.setStatusTip( self.trUtf8('Toggle the visibility of the Preview Panel')) self.action_Preview_Panel.setShortcut(self.trUtf8('F11')) @@ -419,6 +422,8 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): QtGui.QMainWindow.__init__(self) self.screens = screens self.applicationVersion = applicationVersion + self.generalSettingsSection = u'general' + self.uiSettingsSection = u'user interface' self.serviceNotSaved = False self.settingsmanager = SettingsManager(screens) self.displayManager = DisplayManager(screens) @@ -498,8 +503,8 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): #warning cyclic dependency #RenderManager needs to call ThemeManager and #ThemeManager needs to call RenderManager - self.RenderManager = RenderManager(self.ThemeManagerContents, - self.screens) + self.RenderManager = RenderManager( + self.ThemeManagerContents, self.screens) #Define the media Dock Manager self.mediaDockManager = MediaDockManager(self.MediaToolBox) log.info(u'Load Plugins') @@ -561,7 +566,8 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): if self.displayManager.mainDisplay.isVisible(): self.displayManager.mainDisplay.setFocus() self.activateWindow() - if QtCore.QSettings().value(u'general/auto open', False).toBool(): + if QtCore.QSettings().value(self.generalSettingsSection + u'/auto open', + QtCore.QVariant(False)).toBool(): self.ServiceManagerContents.onLoadService(True) def blankCheck(self): @@ -569,14 +575,17 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): Check and display message if screen blank on setup. Triggered by delay thread. """ - if QtCore.QSettings().value(u'general/screen blank', False).toBool() \ - and QtCore.QSettings().value(u'general/blank warning', False).toBool(): + settings = QtCore.QSettings() + settings.beginGroup(self.generalSettingsSection) + if settings.value(u'screen blank', QtCore.QVariant(False)).toBool() \ + and settings.value(u'blank warning', QtCore.QVariant(False)).toBool(): self.LiveController.onBlankDisplay(True) QtGui.QMessageBox.question(self, self.trUtf8('OpenLP Main Display Blanked'), self.trUtf8('The Main Display has been blanked out'), QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok), QtGui.QMessageBox.Ok) + settings.endGroup() def versionThread(self): """ @@ -622,7 +631,8 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): if self.serviceNotSaved: ret = QtGui.QMessageBox.question(self, self.trUtf8('Save Changes to Service?'), - self.trUtf8('Your service has changed, do you want to save those changes?'), + self.trUtf8('Your service has changed. ' + 'Do you want to save those changes?'), QtGui.QMessageBox.StandardButtons( QtGui.QMessageBox.Cancel | QtGui.QMessageBox.Discard | @@ -705,26 +715,30 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): log.debug(u'Loading QSettings') settings = QtCore.QSettings() self.recentFiles = settings.value( - u'general/recent files').toStringList() - self.move(settings.value(u'user interface/main window position', + self.generalSettingsSection + u'/recent files').toStringList() + settings.beginGroup(self.uiSettingsSection) + self.move(settings.value(u'main window position', QtCore.QVariant(QtCore.QPoint(0, 0))).toPoint()) - self.restoreGeometry(settings.value( - u'user interface/main window geometry').toByteArray()) - self.restoreState( - settings.value(u'user interface/main window state').toByteArray()) + self.restoreGeometry( + settings.value(u'main window geometry').toByteArray()) + self.restoreState(settings.value(u'main window state').toByteArray()) + settings.endGroup() def saveSettings(self): log.debug(u'Saving QSettings') settings = QtCore.QSettings() recentFiles = QtCore.QVariant(self.recentFiles) \ if self.recentFiles else QtCore.QVariant() - settings.setValue(u'general/recent files', recentFiles) - settings.setValue(u'user interface/main window position', + settings.setValue( + self.generalSettingsSection + u'/recent files', recentFiles) + settings.beginGroup(self.uiSettingsSection) + settings.setValue(u'main window position', QtCore.QVariant(self.pos())) - settings.setValue(u'user interface/main window state', + settings.setValue(u'main window state', QtCore.QVariant(self.saveState())) - settings.setValue(u'user interface/main window geometry', + settings.setValue(u'main window geometry', QtCore.QVariant(self.saveGeometry())) + settings.endGroup() def updateFileMenu(self): self.FileMenu.clear() @@ -747,7 +761,8 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): def addRecentFile(self, filename): recentFileCount = QtCore.QSettings().value( - u'general/max recent files', 4).toInt()[0] + self.generalSettingsSection + u'/max recent files', + QtCore.QVariant(4)).toInt()[0] if filename and not self.recentFiles.contains(filename): self.recentFiles.prepend(QtCore.QString(filename)) while self.recentFiles.count() > recentFileCount: diff --git a/openlp/core/ui/mediadockmanager.py b/openlp/core/ui/mediadockmanager.py index 574b181da..ae77cc43a 100644 --- a/openlp/core/ui/mediadockmanager.py +++ b/openlp/core/ui/mediadockmanager.py @@ -45,7 +45,8 @@ class MediaDockManager(object): log.debug(u'Inserting %s dock' % media_item.title) match = False for dock_index in range(0, self.media_dock.count()): - if self.media_dock.widget(dock_index).ConfigSection == media_item.title.lower(): + if self.media_dock.widget(dock_index).SettingsSection == \ + media_item.title.lower(): match = True break if not match: @@ -56,6 +57,6 @@ class MediaDockManager(object): log.debug(u'remove %s dock' % name) for dock_index in range(0, self.media_dock.count()): if self.media_dock.widget(dock_index): - if self.media_dock.widget(dock_index).ConfigSection == name: + if self.media_dock.widget(dock_index).SettingsSection == name: self.media_dock.widget(dock_index).hide() self.media_dock.removeItem(dock_index) diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 28793de71..45d007c17 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -40,7 +40,7 @@ from openlp.core.utils import AppLocation class ServiceManagerList(QtGui.QTreeWidget): def __init__(self, parent=None, name=None): - QtGui.QTreeWidget.__init__(self,parent) + QtGui.QTreeWidget.__init__(self, parent) self.parent = parent def keyPressEvent(self, event): @@ -99,6 +99,8 @@ class ServiceManager(QtGui.QWidget): """ QtGui.QWidget.__init__(self) self.parent = parent + self.settingsSection = u'servicemanager' + self.generalSettingsSection = self.parent.generalSettingsSection self.serviceItems = [] self.serviceName = u'' self.droppos = 0 @@ -191,7 +193,8 @@ class ServiceManager(QtGui.QWidget): QtCore.SIGNAL(u'config_updated'), self.regenerateServiceItems) # Last little bits of setting up self.service_theme = unicode(QtCore.QSettings().value( - u'service manager/service theme', u'').toString()) + self.settingsSection + u'/service theme', + QtCore.QVariant(u'')).toString()) self.servicePath = AppLocation.get_section_data_path(u'servicemanager') #build the context menu self.menu = QtGui.QMenu() @@ -402,8 +405,9 @@ class ServiceManager(QtGui.QWidget): """ Clear the list to create a new service """ - if self.parent.serviceNotSaved and \ - QtCore.QSettings().value(u'general/save prompt', False).toBool(): + if self.parent.serviceNotSaved and QtCore.QSettings().value( + self.generalSettingsSection + u'/save prompt', + QtCore.QVariant(False)).toBool(): ret = QtGui.QMessageBox.question(self, self.trUtf8('Save Changes to Service?'), self.trUtf8('Your service is unsaved, do you want to save ' @@ -487,17 +491,17 @@ class ServiceManager(QtGui.QWidget): if not quick or self.isNew: filename = QtGui.QFileDialog.getSaveFileName(self, self.trUtf8(u'Save Service'), - SettingsManager.get_last_dir(u'servicemanager'), + SettingsManager.get_last_dir(self.settingsSection), self.trUtf8(u'OpenLP Service Files (*.osz)')) else: - filename = SettingsManager.get_last_dir(u'servicemanager') + filename = SettingsManager.get_last_dir(self.settingsSection) if filename: splittedFile = filename.split(u'.') if splittedFile[-1] != u'osz': filename = filename + u'.osz' filename = unicode(filename) self.isNew = False - SettingsManager.set_last_dir(u'servicemanager', filename) + SettingsManager.set_last_dir(self.settingsSection, filename) service = [] servicefile = filename + u'.osd' zip = None @@ -538,11 +542,11 @@ class ServiceManager(QtGui.QWidget): def onLoadService(self, lastService=False): if lastService: - filename = SettingsManager.get_last_dir(u'servicemanager') + filename = SettingsManager.get_last_dir(self.settingsSection) else: filename = QtGui.QFileDialog.getOpenFileName( self, self.trUtf8('Open Service'), - SettingsManager.get_last_dir(u'servicemanager'), + SettingsManager.get_last_dir(self.settingsSection), u'Services (*.osz)') self.loadService(filename) @@ -572,7 +576,7 @@ class ServiceManager(QtGui.QWidget): filename = unicode(filename) name = filename.split(os.path.sep) if filename: - SettingsManager.set_last_dir(u'servicemanager', filename) + SettingsManager.set_last_dir(self.settingsSection, filename) zip = None f = None try: @@ -641,7 +645,7 @@ class ServiceManager(QtGui.QWidget): """ self.service_theme = unicode(self.ThemeComboBox.currentText()) self.parent.RenderManager.set_service_theme(self.service_theme) - QtCore.QSettings().setValue(u'servicemanager/service theme', + QtCore.QSettings().setValue(self.settingsSection + u'/service theme', QtCore.QVariant(self.service_theme)) self.regenerateServiceItems() @@ -724,7 +728,9 @@ class ServiceManager(QtGui.QWidget): item, count = self.findServiceItem() self.parent.LiveController.addServiceManagerItem( self.serviceItems[item][u'service_item'], count) - if QtCore.QSettings().value(u'general/auto preview', False).toBool(): + if QtCore.QSettings().value( + self.generalSettingsSection + u'/auto preview', + QtCore.QVariant(False)).toBool(): 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/slidecontroller.py b/openlp/core/ui/slidecontroller.py index 6ff739fc3..811fd51e3 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -93,6 +93,8 @@ class SlideController(QtGui.QWidget): """ QtGui.QWidget.__init__(self, parent) self.settingsmanager = settingsmanager + self.generalSettingsSection = u'general' + self.songsSettingsSection = u'songs' self.isLive = isLive self.parent = parent self.mainDisplay = self.parent.displayManager.mainDisplay @@ -396,8 +398,9 @@ class SlideController(QtGui.QWidget): self.Toolbar.makeWidgetsInvisible(self.loop_list) if item.is_text(): self.Toolbar.makeWidgetsInvisible(self.loop_list) - if QtCore.QSettings().value(u'songs/show songbar', True).toBool() \ - and len(self.slideList) > 0: + if QtCore.QSettings().value( + self.songsSettingsSection + u'/show songbar', + QtCore.QVariant(True)).toBool() and len(self.slideList) > 0: self.Toolbar.makeWidgetsVisible([u'Song Menu']) if item.is_capable(ItemCapabilities.AllowsLoop) and \ len(item.get_frames()) > 1: @@ -585,7 +588,8 @@ class SlideController(QtGui.QWidget): if force: self.blankButton.setChecked(True) self.blankScreen(HideMode.Blank, self.blankButton.isChecked()) - QtCore.QSettings().setValue(u'general/screen blank', + QtCore.QSettings().setValue( + self.generalSettingsSection + u'/screen blank', QtCore.QVariant(self.blankButton.isChecked())) def onThemeDisplay(self, force=False): diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index a71e65210..797a6a27a 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -47,6 +47,7 @@ class ThemeManager(QtGui.QWidget): def __init__(self, parent): QtGui.QWidget.__init__(self, parent) self.parent = parent + self.settingsSection = u'themes' self.Layout = QtGui.QVBoxLayout(self) self.Layout.setSpacing(0) self.Layout.setMargin(0) @@ -105,14 +106,15 @@ class ThemeManager(QtGui.QWidget): QtCore.SIGNAL(u'theme_update_global'), self.changeGlobalFromTab) #Variables self.themelist = [] - self.path = AppLocation.get_section_data_path(u'themes') + self.path = AppLocation.get_section_data_path(self.settingsSection) self.checkThemesExists(self.path) self.thumbPath = os.path.join(self.path, u'.thumbnails') self.checkThemesExists(self.thumbPath) self.amendThemeForm.path = self.path # Last little bits of setting up self.global_theme = unicode(QtCore.QSettings().value( - u'themes/global theme', u'').toString()) + self.settingsSection + u'/global theme', + QtCore.QVariant(u'')).toString()) def changeGlobalFromTab(self, themeName): log.debug(u'changeGlobalFromTab %s', themeName) @@ -144,7 +146,8 @@ class ThemeManager(QtGui.QWidget): self.ThemeListWidget.item(count).text()) name = u'%s (%s)' % (self.global_theme, self.trUtf8('default')) self.ThemeListWidget.item(count).setText(name) - QtCore.QSettings().setValue(u'themes/global theme', + QtCore.QSettings().setValue( + self.settingsSection + u'/global theme', QtCore.QVariant(self.global_theme)) Receiver.send_message(u'theme_update_global', self.global_theme) self.pushThemes() @@ -167,7 +170,8 @@ class ThemeManager(QtGui.QWidget): def onDeleteTheme(self): self.global_theme = unicode(QtCore.QSettings().value( - u'themes/global theme', u'').toString()) + self.settingsSection + u'/global theme', + QtCore.QVariant(u'')).toString()) item = self.ThemeListWidget.currentItem() if item: theme = unicode(item.text()) @@ -220,10 +224,10 @@ class ThemeManager(QtGui.QWidget): theme = unicode(item.data(QtCore.Qt.UserRole).toString()) path = QtGui.QFileDialog.getExistingDirectory(self, unicode(self.trUtf8('Save Theme - (%s)')) % theme, - SettingsManager.get_last_dir(u'themes', 1)) + SettingsManager.get_last_dir(self.settingsSection, 1)) path = unicode(path) if path: - SettingsManager.set_last_dir(u'themes', path, 1) + SettingsManager.set_last_dir(self.settingsSection, path, 1) themePath = os.path.join(path, theme + u'.theme') zip = None try: @@ -232,7 +236,8 @@ class ThemeManager(QtGui.QWidget): for root, dirs, files in os.walk(source): for name in files: zip.write( - os.path.join(source, name), os.path.join(theme, name)) + os.path.join(source, name), + os.path.join(theme, name)) except: log.exception(u'Export Theme Failed') finally: @@ -242,11 +247,12 @@ class ThemeManager(QtGui.QWidget): def onImportTheme(self): files = QtGui.QFileDialog.getOpenFileNames( self, self.trUtf8('Select Theme Import File'), - SettingsManager.get_last_dir(u'themes'), u'Theme (*.*)') + SettingsManager.get_last_dir(self.settingsSection), u'Theme (*.*)') log.info(u'New Themes %s', unicode(files)) if files: for file in files: - SettingsManager.set_last_dir(u'themes', unicode(file)) + SettingsManager.set_last_dir( + self.settingsSection, unicode(file)) self.unzipTheme(file, self.path) self.loadThemes() diff --git a/openlp/core/ui/themestab.py b/openlp/core/ui/themestab.py index f3b5ec917..dba07eb6d 100644 --- a/openlp/core/ui/themestab.py +++ b/openlp/core/ui/themestab.py @@ -124,10 +124,12 @@ class ThemesTab(SettingsTab): def load(self): settings = QtCore.QSettings() + settings.beginGroup(self.settingsSection) self.theme_level = settings.value( - u'themes/theme level', ThemeLevel.Global).toInt()[0] + u'theme level', QtCore.QVariant(ThemeLevel.Global)).toInt()[0] self.global_theme = unicode(settings.value( - u'themes/global theme', u'').toString()) + u'global theme', QtCore.QVariant(u'')).toString()) + settings.endGroup() if self.theme_level == ThemeLevel.Global: self.GlobalLevelRadioButton.setChecked(True) elif self.theme_level == ThemeLevel.Service: @@ -137,10 +139,12 @@ class ThemesTab(SettingsTab): def save(self): settings = QtCore.QSettings() - settings.setValue(u'themes/theme level', + settings.beginGroup(self.settingsSection) + settings.setValue(u'theme level', QtCore.QVariant(self.theme_level)) - settings.setValue(u'themes/global theme', + settings.setValue(u'global theme', QtCore.QVariant(self.global_theme)) + settings.endGroup() Receiver.send_message(u'theme_update_global', self.global_theme) self.parent.RenderManager.set_global_theme( self.global_theme, self.theme_level) @@ -175,7 +179,8 @@ class ThemesTab(SettingsTab): """ #reload as may have been triggered by the ThemeManager self.global_theme = unicode(QtCore.QSettings().value( - u'themes/global theme', u'').toString()) + self.settingsSection + u'/global theme', + QtCore.QVariant(u'')).toString()) self.DefaultComboBox.clear() for theme in theme_list: self.DefaultComboBox.addItem(theme) @@ -194,4 +199,4 @@ class ThemesTab(SettingsTab): if not preview.isNull(): preview = preview.scaled(300, 255, QtCore.Qt.KeepAspectRatio, QtCore.Qt.SmoothTransformation) - self.DefaultListView.setPixmap(preview) \ No newline at end of file + self.DefaultListView.setPixmap(preview) diff --git a/openlp/core/utils/__init__.py b/openlp/core/utils/__init__.py index 659cb1ceb..0aaa31de3 100644 --- a/openlp/core/utils/__init__.py +++ b/openlp/core/utils/__init__.py @@ -124,11 +124,13 @@ def check_latest_version(current_version): """ version_string = current_version[u'full'] #set to prod in the distribution config file. - last_test = unicode(QtCore.QSettings().value(u'general/last version test', - datetime.now().date()).toString()) + settings = QtCore.QSettings() + settings.beginGroup(u'general') + last_test = unicode(settings.value(u'last version test', + QtCore.QVariant(datetime.now().date())).toString()) this_test = unicode(datetime.now().date()) - QtCore.QSettings().setValue( - u'general/last version test', QtCore.QVariant(this_test)) + settings.setValue(u'last version test', QtCore.QVariant(this_test)) + settings.endGroup() if last_test != this_test: version_string = u'' if current_version[u'build']: diff --git a/openlp/plugins/alerts/alertsplugin.py b/openlp/plugins/alerts/alertsplugin.py index a55523e4b..2ec2db506 100644 --- a/openlp/plugins/alerts/alertsplugin.py +++ b/openlp/plugins/alerts/alertsplugin.py @@ -84,7 +84,8 @@ class alertsPlugin(Plugin): def togglealertsState(self): self.alertsActive = not self.alertsActive QtCore.QSettings().setValue( - u'alerts/active', QtCore.QVariant(self.alertsActive)) + self.settings_section + u'/active', + QtCore.QVariant(self.alertsActive)) def onAlertsTrigger(self): self.alertForm.loadList() diff --git a/openlp/plugins/alerts/forms/alertstab.py b/openlp/plugins/alerts/forms/alertstab.py index 14066f7aa..7cda09488 100644 --- a/openlp/plugins/alerts/forms/alertstab.py +++ b/openlp/plugins/alerts/forms/alertstab.py @@ -229,15 +229,19 @@ class AlertsTab(SettingsTab): def load(self): settings = QtCore.QSettings() - self.timeout = settings.value(u'alerts/timeout', 5).toInt()[0] + settings.beginGroup(self.settingsSection) + self.timeout = settings.value(u'timeout', QtCore.QVariant(5)).toInt()[0] self.font_color = unicode(settings.value( - u'alerts/font color', u'#ffffff').toString()) - self.font_size = settings.value(u'alerts/font size', 40).toInt()[0] + 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'alerts/background color', u'#660000').toString()) + u'background color', QtCore.QVariant(u'#660000')).toString()) self.font_face = unicode(settings.value( - u'alerts/font face', QtGui.QFont().family()).toString()) - self.location = settings.value(u'alerts/location', 0).toInt()[0] + u'font face', QtCore.QVariant(QtGui.QFont().family())).toString()) + self.location = settings.value( + u'location', QtCore.QVariant(0)).toInt()[0] + settings.endGroup() self.FontSizeSpinBox.setValue(self.font_size) self.TimeoutSpinBox.setValue(self.timeout) self.FontColorButton.setStyleSheet( @@ -256,16 +260,16 @@ class AlertsTab(SettingsTab): def save(self): settings = QtCore.QSettings() + settings.beginGroup(self.settingsSection) self.font_face = self.FontComboBox.currentFont().family() - settings.setValue( - u'alerts/background color', QtCore.QVariant(self.bg_color)) - settings.setValue( - u'alerts/font color', QtCore.QVariant(self.font_color)) - settings.setValue(u'alerts/font size', QtCore.QVariant(self.font_size)) - settings.setValue(u'alerts/font face', QtCore.QVariant(self.font_face)) - settings.setValue(u'alerts/timeout', QtCore.QVariant(self.timeout)) - settings.setValue(u'alerts/location', + 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'font face', QtCore.QVariant(self.font_face)) + settings.setValue(u'timeout', QtCore.QVariant(self.timeout)) + settings.setValue(u'location', QtCore.QVariant(self.LocationComboBox.currentIndex())) + settings.endGroup() def updateDisplay(self): font = QtGui.QFont() diff --git a/openlp/plugins/alerts/lib/manager.py b/openlp/plugins/alerts/lib/manager.py index 98a3d8a43..f82266f49 100644 --- a/openlp/plugins/alerts/lib/manager.py +++ b/openlp/plugins/alerts/lib/manager.py @@ -44,23 +44,24 @@ class DBManager(): Creates the connection to the database, and creates the tables if they don't exist. """ - settings = QtCore.QSettings() log.debug(u'Alerts Initialising') + settings = QtCore.QSettings() + settings.beginGroup(u'alerts') self.db_url = u'' db_type = unicode( - settings.value(u'alerts/db type', u'sqlite').toString()) + settings.value(u'db type', QtCore.QVariant(u'sqlite')).toString()) if db_type == u'sqlite': self.db_url = u'sqlite:///%s/alerts.sqlite' % \ AppLocation.get_section_data_path(u'alerts') else: - self.db_url = u'%s://%s:%s@%s/%s' % \ - (db_type, settings.value(u'alerts/db username'), - settings.value(u'alerts/db password'), - settings.value(u'alerts/db hostname'), - settings.value(u'alerts/db database')) + self.db_url = u'%s://%s:%s@%s/%s' % (db_type, + unicode(settings.value(u'db username').toString()), + unicode(settings.value(u'db password').toString()), + unicode(settings.value(u'db hostname').toString()), + unicode(settings.value(u'db database').toString())) + settings.endGroup() self.session = init_models(self.db_url) metadata.create_all(checkfirst=True) - log.debug(u'Alerts Initialised') def get_all_alerts(self): diff --git a/openlp/plugins/bibles/forms/importwizardform.py b/openlp/plugins/bibles/forms/importwizardform.py index 41df18cdc..d3e8acd73 100644 --- a/openlp/plugins/bibles/forms/importwizardform.py +++ b/openlp/plugins/bibles/forms/importwizardform.py @@ -274,6 +274,7 @@ class ImportWizardForm(QtGui.QWizard, Ui_BibleImportWizard): def setDefaults(self): settings = QtCore.QSettings() + settings.beginGroup(self.bibleplugin.settings_section) self.setField(u'source_format', QtCore.QVariant(0)) self.setField(u'osis_location', QtCore.QVariant('')) self.setField(u'csv_booksfile', QtCore.QVariant('')) @@ -282,16 +283,17 @@ class ImportWizardForm(QtGui.QWizard, Ui_BibleImportWizard): self.setField(u'web_location', QtCore.QVariant(WebDownload.Crosswalk)) self.setField(u'web_biblename', QtCore.QVariant(self.BibleComboBox)) self.setField(u'proxy_server', - settings.value(u'bibles/proxy address', u'')) + settings.value(u'proxy address', QtCore.QVariant(u''))) self.setField(u'proxy_username', - settings.value(u'bibles/proxy username', u'')) + settings.value(u'proxy username', QtCore.QVariant(u''))) self.setField(u'proxy_password', - settings.value(u'proxy password', u'')) + settings.value(u'proxy password', QtCore.QVariant(u''))) self.setField(u'license_version', QtCore.QVariant(self.VersionNameEdit)) self.setField(u'license_copyright', QtCore.QVariant(self.CopyrightEdit)) self.setField(u'license_permission', QtCore.QVariant(self.PermissionEdit)) self.onLocationComboBoxChanged(WebDownload.Crosswalk) + settings.endGroup() def loadWebBibles(self): """ @@ -343,10 +345,11 @@ class ImportWizardForm(QtGui.QWizard, Ui_BibleImportWizard): def getFileName(self, title, editbox): filename = QtGui.QFileDialog.getOpenFileName(self, title, - SettingsManager.get_last_dir(bibles, 1)) + SettingsManager.get_last_dir(self.bibleplugin.settings_section, 1)) if filename: editbox.setText(filename) - SettingsManager.set_last_dir(bibles, filename, 1) + SettingsManager.set_last_dir( + self.bibleplugin.settings_section, filename, 1) def incrementProgressBar(self, status_text): log.debug(u'IncrementBar %s', status_text) diff --git a/openlp/plugins/bibles/lib/biblestab.py b/openlp/plugins/bibles/lib/biblestab.py index 3965a0933..80e0cef5e 100644 --- a/openlp/plugins/bibles/lib/biblestab.py +++ b/openlp/plugins/bibles/lib/biblestab.py @@ -150,7 +150,8 @@ class BiblesTab(SettingsTab): def retranslateUi(self): self.VerseDisplayGroupBox.setTitle(self.trUtf8('Verse Display')) - self.NewChaptersCheckBox.setText(self.trUtf8('Only show new chapter numbers')) + self.NewChaptersCheckBox.setText( + self.trUtf8('Only show new chapter numbers')) self.LayoutStyleLabel.setText(self.trUtf8('Layout Style:')) self.DisplayStyleLabel.setText(self.trUtf8('Display Style:')) self.BibleThemeLabel.setText(self.trUtf8('Bible Theme:')) @@ -188,32 +189,35 @@ class BiblesTab(SettingsTab): def load(self): settings = QtCore.QSettings() + settings.beginGroup(self.settingsSection) self.show_new_chapters = settings.value( - u'bibles/display new chapter', False).toBool() + u'display new chapter', QtCore.QVariant(False)).toBool() self.display_style = settings.value( - u'bibles/display brackets', 0).toInt()[0] + u'display brackets', QtCore.QVariant(0)).toInt()[0] self.layout_style = settings.value( - u'bibles/verse layout style', 0).toInt()[0] + u'verse layout style', QtCore.QVariant(0)).toInt()[0] self.bible_theme = unicode( - settings.value(u'bibles/bible theme', u'').toString()) - self.duel_bibles = settings.value(u'bibles/dual bibles', True).toBool() + settings.value(u'bible theme', QtCore.QVariant(u'')).toString()) + self.duel_bibles = settings.value( + u'dual bibles', QtCore.QVariant(True)).toBool() self.NewChaptersCheckBox.setChecked(self.show_new_chapters) self.DisplayStyleComboBox.setCurrentIndex(self.display_style) self.LayoutStyleComboBox.setCurrentIndex(self.layout_style) self.BibleDualCheckBox.setChecked(self.duel_bibles) + settings.endGroup() def save(self): settings = QtCore.QSettings() - settings.setValue(u'bibles/display new chapter', + settings.beginGroup(self.settingsSection) + settings.setValue(u'display new chapter', QtCore.QVariant(self.show_new_chapters)) - settings.setValue(u'bibles/display brackets', + settings.setValue(u'display brackets', QtCore.QVariant(self.display_style)) - settings.setValue(u'bibles/verse layout style', + settings.setValue(u'verse layout style', QtCore.QVariant(self.layout_style)) - settings.setValue(u'bibles/dual bibles', - QtCore.QVariant(self.duel_bibles)) - settings.setValue(u'bibles/bible theme', - QtCore.QVariant(self.bible_theme)) + settings.setValue(u'dual bibles', QtCore.QVariant(self.duel_bibles)) + settings.setValue(u'bible theme', QtCore.QVariant(self.bible_theme)) + settings.endGroup() def updateThemeList(self, theme_list): """ @@ -229,4 +233,4 @@ class BiblesTab(SettingsTab): # Not Found id = 0 self.bible_theme = u'' - self.BibleThemeComboBox.setCurrentIndex(id) \ No newline at end of file + self.BibleThemeComboBox.setCurrentIndex(id) diff --git a/openlp/plugins/bibles/lib/db.py b/openlp/plugins/bibles/lib/db.py index 0d2422a8d..c95884693 100644 --- a/openlp/plugins/bibles/lib/db.py +++ b/openlp/plugins/bibles/lib/db.py @@ -74,17 +74,19 @@ class BibleDB(QtCore.QObject): self.db_file = os.path.join(kwargs[u'path'], self.file) log.debug(u'Load bible %s on path %s', self.file, self.db_file) settings = QtCore.QSettings() + settings.beginGroup(u'bibles') db_type = unicode( - settings.value(u'bibles/db type', u'sqlite').toString()) + settings.value(u'db type', QtCore.QVariant(u'sqlite')).toString()) db_url = u'' if db_type == u'sqlite': db_url = u'sqlite:///' + self.db_file else: db_url = u'%s://%s:%s@%s/%s' % (db_type, - unicode(settings.value(u'bibles/db username').toString()), - unicode(settings.value(u'bibles/db password').toString()), - unicode(settings.value(u'bibles/db hostname').toString()), - unicode(settings.value(u'bibles/db database').toString())) + unicode(settings.value(u'db username').toString()), + unicode(settings.value(u'db password').toString()), + unicode(settings.value(u'db hostname').toString()), + unicode(settings.value(u'db database').toString())) + settings.endGroup() self.metadata, self.session = init_models(db_url) self.metadata.create_all(checkfirst=True) if u'file' in kwargs: diff --git a/openlp/plugins/bibles/lib/manager.py b/openlp/plugins/bibles/lib/manager.py index 1f962be90..d8fe3e156 100644 --- a/openlp/plugins/bibles/lib/manager.py +++ b/openlp/plugins/bibles/lib/manager.py @@ -109,11 +109,13 @@ class BibleManager(object): """ log.debug(u'Bible Initialising') self.parent = parent + self.settings_section = u'bibles' self.web = u'Web' self.db_cache = None - self.path = AppLocation.get_section_data_path(u'bibles') + self.path = AppLocation.get_section_data_path(self.settings_section) self.proxy_name = unicode( - QtCore.QSettings().value(u'bibles/proxy name', u'').toString()) + QtCore.QSettings().value(self.settings_section + u'/proxy name', + QtCore.QVariant(u'')).toString()) self.suffix = u'.sqlite' self.import_wizard = None self.reload_bibles() @@ -126,7 +128,7 @@ class BibleManager(object): BibleDB class. """ log.debug(u'Reload bibles') - files = SettingsManager.get_files(u'bibles', self.suffix) + files = SettingsManager.get_files(self.settings_section, self.suffix) log.debug(u'Bible Files %s', files) self.db_cache = {} for filename in files: @@ -137,7 +139,8 @@ class BibleManager(object): # look to see if lazy load bible exists and get create getter. source = self.db_cache[name].get_meta(u'download source') if source: - download_name = self.db_cache[name].get_meta(u'download name').value + download_name = \ + self.db_cache[name].get_meta(u'download name').value meta_proxy = self.db_cache[name].get_meta(u'proxy url') web_bible = HTTPBible(self.parent, path=self.path, file=filename, download_source=source.value, @@ -208,7 +211,8 @@ class BibleManager(object): Returns all the number of verses for a given book and chapterMaxBibleBookVerses """ - log.debug(u'BibleManager.get_verse_count("%s", "%s", %s)', bible, book, chapter) + log.debug(u'BibleManager.get_verse_count("%s", "%s", %s)', + bible, book, chapter) return self.db_cache[bible].get_verse_count(book, chapter) def get_verses(self, bible, versetext): diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index afdd89e3e..c448e5066 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -54,7 +54,7 @@ class BibleMediaItem(MediaManagerItem): def __init__(self, parent, icon, title): self.PluginNameShort = u'Bible' - self.ConfigSection = title + self.SettingsSection = title.lower() self.IconPath = u'songs/song' self.ListViewWithDnD_class = BibleListView self.lastReference = [] @@ -276,7 +276,8 @@ class BibleMediaItem(MediaManagerItem): self.SearchProgress.setObjectName(u'SearchProgress') def configUpdated(self): - if QtCore.QSettings().value(u'bibles/dual bibles', False).toBool(): + if QtCore.QSettings().value(self.SettingsSection + u'/dual bibles', + QtCore.QVariant(False)).toBool(): self.AdvancedSecondBibleLabel.setVisible(True) self.AdvancedSecondBibleComboBox.setVisible(True) self.QuickSecondVersionLabel.setVisible(True) diff --git a/openlp/plugins/custom/lib/customtab.py b/openlp/plugins/custom/lib/customtab.py index 5470c64d0..2b6cedfbf 100644 --- a/openlp/plugins/custom/lib/customtab.py +++ b/openlp/plugins/custom/lib/customtab.py @@ -67,9 +67,10 @@ class CustomTab(SettingsTab): def load(self): self.displayFooter = QtCore.QSettings().value( - u'custom/display footer', True).toBool() + self.settingsSection + u'/display footer', + QtCore.QVariant(True)).toBool() self.DisplayFooterCheckBox.setChecked(self.displayFooter) def save(self): - QtCore.QSettings().setValue( - u'custom/display footer', QtCore.QVariant(self.displayFooter)) + QtCore.QSettings().setValue(self.settingsSection + u'/display footer', + QtCore.QVariant(self.displayFooter)) diff --git a/openlp/plugins/custom/lib/manager.py b/openlp/plugins/custom/lib/manager.py index c9555e63a..9e781f560 100644 --- a/openlp/plugins/custom/lib/manager.py +++ b/openlp/plugins/custom/lib/manager.py @@ -46,21 +46,22 @@ class CustomManager(): """ log.debug(u'Custom Initialising') settings = QtCore.QSettings() + settings.beginGroup(u'custom') self.db_url = u'' db_type = unicode( - settings.value(u'custom/db type', u'sqlite').toString()) + settings.value(u'db type', QtCore.QVariant(u'sqlite')).toString()) if db_type == u'sqlite': self.db_url = u'sqlite:///%s/custom.sqlite' % \ AppLocation.get_section_data_path(u'custom') else: self.db_url = u'%s://%s:%s@%s/%s' % (db_type, - unicode(settings.value(u'custom/db username').toString()), - unicode(settings.value(u'custom/db password').toString()), - unicode(settings.value(u'custom/db hostname').toString()), - unicode(settings.value(u'custom/db database').toString())) + unicode(settings.value(u'db username').toString()), + unicode(settings.value(u'db password').toString()), + unicode(settings.value(u'db hostname').toString()), + unicode(settings.value(u'db database').toString())) self.session = init_models(self.db_url) metadata.create_all(checkfirst=True) - + settings.endGroup() log.debug(u'Custom Initialised') def get_all_slides(self): diff --git a/openlp/plugins/custom/lib/mediaitem.py b/openlp/plugins/custom/lib/mediaitem.py index aa82eb452..c1f4ff1e6 100644 --- a/openlp/plugins/custom/lib/mediaitem.py +++ b/openlp/plugins/custom/lib/mediaitem.py @@ -45,7 +45,7 @@ class CustomMediaItem(MediaManagerItem): def __init__(self, parent, icon, title): self.PluginNameShort = u'Custom' - self.ConfigSection = title + self.SettingsSection = title.lower() self.IconPath = u'custom/custom' # this next is a class, not an instance of a class - it will # be instanced by the base MediaManagerItem @@ -133,7 +133,7 @@ class CustomMediaItem(MediaManagerItem): self.ListView.takeItem(row) def generateSlideData(self, service_item, item=None): - raw_slides =[] + raw_slides = [] raw_footer = [] slide = None theme = None @@ -164,8 +164,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(u'custom/display footer', True).toBool() \ - or credit: + if QtCore.QSettings().value(self.SettingsSection + u'/display footer', + QtCore.QVariant(True)).toBool() or credit: raw_footer.append(title + u' ' + credit) else: raw_footer.append(u'') diff --git a/openlp/plugins/images/lib/imagetab.py b/openlp/plugins/images/lib/imagetab.py index f7bdb3106..346d28b16 100644 --- a/openlp/plugins/images/lib/imagetab.py +++ b/openlp/plugins/images/lib/imagetab.py @@ -72,12 +72,13 @@ class ImageTab(SettingsTab): def load(self): self.loop_delay = QtCore.QSettings().value( - u'images/loop delay', 5).toInt()[0] + self.settingsSection + u'/loop delay', + QtCore.QVariant(5)).toInt()[0] self.TimeoutSpinBox.setValue(self.loop_delay) def save(self): - QtCore.QSettings().setValue( - u'images/loop delay', QtCore.QVariant(self.loop_delay)) + QtCore.QSettings().setValue(self.settingsSection + u'/loop delay', + QtCore.QVariant(self.loop_delay)) Receiver.send_message(u'slidecontroller_live_spin_delay', self.loop_delay) diff --git a/openlp/plugins/images/lib/mediaitem.py b/openlp/plugins/images/lib/mediaitem.py index 7b104136c..32ed5edb6 100644 --- a/openlp/plugins/images/lib/mediaitem.py +++ b/openlp/plugins/images/lib/mediaitem.py @@ -49,7 +49,7 @@ class ImageMediaItem(MediaManagerItem): def __init__(self, parent, icon, title): self.PluginNameShort = u'Image' - self.ConfigSection = title + self.SettingsSection = title.lower() self.IconPath = u'images/image' # this next is a class, not an instance of a class - it will # be instanced by the base MediaManagerItem @@ -61,8 +61,8 @@ class ImageMediaItem(MediaManagerItem): def retranslateUi(self): self.OnNewPrompt = self.trUtf8('Select Image(s)') - self.OnNewFileMasks = \ - self.trUtf8('Images (*.jpg *.jpeg *.gif *.png *.bmp);; All files (*)') + self.OnNewFileMasks = self.trUtf8( + 'Images (*.jpg *.jpeg *.gif *.png *.bmp);; All files (*)') def requiredIcons(self): MediaManagerItem.requiredIcons(self) @@ -78,12 +78,12 @@ class ImageMediaItem(MediaManagerItem): QtGui.QAbstractItemView.ExtendedSelection) self.ListView.setIconSize(QtCore.QSize(88,50)) self.servicePath = os.path.join( - AppLocation.get_section_data_path(self.ConfigSection), + AppLocation.get_section_data_path(self.SettingsSection), u'.thumbnails') if not os.path.exists(self.servicePath): os.mkdir(self.servicePath) self.loadList(SettingsManager.load_list( - self.ConfigSection, self.ConfigSection)) + self.SettingsSection, self.SettingsSection)) def addListViewToToolBar(self): MediaManagerItem.addListViewToToolBar(self) @@ -122,7 +122,8 @@ class ImageMediaItem(MediaManagerItem): #if not present do not worry pass self.ListView.takeItem(item.row()) - SettingsManager.set_list(self.ConfigSection, self.getFileList()) + SettingsManager.set_list( + self.SettingsSection, self.getFileList()) def loadList(self, list): for file in list: diff --git a/openlp/plugins/media/lib/mediaitem.py b/openlp/plugins/media/lib/mediaitem.py index 9342708f4..f594fe54c 100644 --- a/openlp/plugins/media/lib/mediaitem.py +++ b/openlp/plugins/media/lib/mediaitem.py @@ -47,7 +47,7 @@ class MediaMediaItem(MediaManagerItem): def __init__(self, parent, icon, title): self.PluginNameShort = u'Media' self.IconPath = u'images/image' - self.ConfigSection = title + self.SettingsSection = title.lower() # this next is a class, not an instance of a class - it will # be instanced by the base MediaManagerItem self.ListViewWithDnD_class = MediaListView @@ -90,14 +90,14 @@ class MediaMediaItem(MediaManagerItem): QtGui.QAbstractItemView.ExtendedSelection) self.ListView.setIconSize(QtCore.QSize(88,50)) self.loadList(SettingsManager.load_list( - self.ConfigSection, self.ConfigSection)) + self.SettingsSection, self.SettingsSection)) def onDeleteClick(self): item = self.ListView.currentItem() if item: row = self.ListView.row(item) self.ListView.takeItem(row) - SettingsManager.set_list(self.ConfigSection, self.getFileList()) + SettingsManager.set_list(self.SettingsSection, self.getFileList()) def loadList(self, list): for file in list: @@ -106,4 +106,4 @@ class MediaMediaItem(MediaManagerItem): img = QtGui.QPixmap(u':/media/media_video.png').toImage() item_name.setIcon(build_icon(img)) item_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(file)) - self.ListView.addItem(item_name) \ No newline at end of file + self.ListView.addItem(item_name) diff --git a/openlp/plugins/presentations/lib/mediaitem.py b/openlp/plugins/presentations/lib/mediaitem.py index 900af71b6..f547f0633 100644 --- a/openlp/plugins/presentations/lib/mediaitem.py +++ b/openlp/plugins/presentations/lib/mediaitem.py @@ -52,7 +52,7 @@ class PresentationMediaItem(MediaManagerItem): def __init__(self, parent, icon, title, controllers): self.controllers = controllers self.PluginNameShort = u'Presentation' - self.ConfigSection = title + self.SettingsSection = title.lower() self.IconPath = u'presentations/presentation' self.Automatic = u'' # this next is a class, not an instance of a class - it will @@ -107,11 +107,11 @@ class PresentationMediaItem(MediaManagerItem): def initialise(self): self.servicePath = os.path.join( - AppLocation.get_section_data_path(self.ConfigSection), + AppLocation.get_section_data_path(self.SettingsSection), u'thumbnails') if not os.path.exists(self.servicePath): os.mkdir(self.servicePath) - list = SettingsManager.load_list(self.ConfigSection, u'presentations') + list = SettingsManager.load_list(self.SettingsSection, u'presentations') self.loadList(list) for item in self.controllers: #load the drop down selection @@ -139,11 +139,11 @@ class PresentationMediaItem(MediaManagerItem): icon = None for controller in self.controllers: thumbPath = os.path.join( - AppLocation.get_section_data_path(self.ConfigSection), + AppLocation.get_section_data_path(self.SettingsSection), u'thumbnails', controller, filename) thumb = os.path.join(thumbPath, u'slide1.png') preview = os.path.join( - AppLocation.get_section_data_path(self.ConfigSection), + AppLocation.get_section_data_path(self.SettingsSection), controller, u'thumbnails', filename, u'slide1.png') if os.path.exists(preview): if os.path.exists(thumb): @@ -167,7 +167,7 @@ class PresentationMediaItem(MediaManagerItem): if item: row = self.ListView.row(item) self.ListView.takeItem(row) - SettingsManager.set_list(self.ConfigSection, self.getFileList()) + SettingsManager.set_list(self.SettingsSection, self.getFileList()) filepath = unicode((item.data(QtCore.Qt.UserRole)).toString()) #not sure of this has errors #John please can you look at . diff --git a/openlp/plugins/presentations/lib/presentationcontroller.py b/openlp/plugins/presentations/lib/presentationcontroller.py index 8e5d797da..fa6e9474d 100644 --- a/openlp/plugins/presentations/lib/presentationcontroller.py +++ b/openlp/plugins/presentations/lib/presentationcontroller.py @@ -100,14 +100,16 @@ class PresentationController(object): self.docs = [] self.plugin = plugin self.name = name + self.settings_section = self.plugin.settings_section self.available = self.check_available() if self.available: - self.enabled = QtCore.QSettings().value(u'presentations/' + name, + self.enabled = QtCore.QSettings().value( + self.settings_section + u'/' + name, QtCore.Qt.Unchecked).toInt()[0] == QtCore.Qt.Checked else: self.enabled = False self.thumbnailroot = os.path.join( - AppLocation.get_section_data_path(u'presentations'), + AppLocation.get_section_data_path(self.settings_section), name, u'thumbnails') self.thumbnailprefix = u'slide' if not os.path.isdir(self.thumbnailroot): diff --git a/openlp/plugins/presentations/lib/presentationtab.py b/openlp/plugins/presentations/lib/presentationtab.py index 4c1b41813..ebcbb3d7b 100644 --- a/openlp/plugins/presentations/lib/presentationtab.py +++ b/openlp/plugins/presentations/lib/presentationtab.py @@ -101,11 +101,13 @@ class PresentationTab(SettingsTab): if controller.available: checkbox = self.PresenterCheckboxes[controller.name] checkbox.setChecked(QtCore.QSettings().value( - u'presentations/' + controller.name, 0).toInt()[0]) + self.settingsSection + u'/' + controller.name, + QtCore.QVariant(0)).toInt()[0]) def save(self): for key in self.controllers: controller = self.controllers[key] checkbox = self.PresenterCheckboxes[controller.name] - QtCore.QSettings().setValue(u'presentations/' + controller.name, + QtCore.QSettings().setValue( + self.settingsSection + u'/' + controller.name, QtCore.QVariant(checkbox.checkState())) diff --git a/openlp/plugins/remotes/lib/remotetab.py b/openlp/plugins/remotes/lib/remotetab.py index 7096ee302..abdda065f 100644 --- a/openlp/plugins/remotes/lib/remotetab.py +++ b/openlp/plugins/remotes/lib/remotetab.py @@ -57,8 +57,9 @@ class RemoteTab(SettingsTab): def load(self): self.RemotePortSpinBox.setValue( - QtCore.QSettings().value(u'remotes/remote port', 4316).toInt()[0]) + QtCore.QSettings().value(self.settingsSection + u'/remote port', + QtCore.QVariant(4316)).toInt()[0]) def save(self): - QtCore.QSettings().setValue(u'remotes/remote port', + QtCore.QSettings().setValue(self.settingsSection + u'/remote port', QtCore.QVariant(self.RemotePortSpinBox.value())) diff --git a/openlp/plugins/remotes/remoteplugin.py b/openlp/plugins/remotes/remoteplugin.py index 3ceb6d1f8..8bc91c824 100644 --- a/openlp/plugins/remotes/remoteplugin.py +++ b/openlp/plugins/remotes/remoteplugin.py @@ -46,7 +46,8 @@ class RemotesPlugin(Plugin): self.insert_toolbox_item() self.server = QtNetwork.QUdpSocket() self.server.bind( - QtCore.QSettings().value(u'remotes/remote port', 4316).toInt()[0]) + QtCore.QSettings().value(self.settings_section + u'/remote port', + QtCore.QVariant(4316)).toInt()[0]) QtCore.QObject.connect(self.server, QtCore.SIGNAL(u'readyRead()'), self.readData) diff --git a/openlp/plugins/songs/lib/manager.py b/openlp/plugins/songs/lib/manager.py index 5264a58ed..ff9231fe2 100644 --- a/openlp/plugins/songs/lib/manager.py +++ b/openlp/plugins/songs/lib/manager.py @@ -47,6 +47,7 @@ class SongManager(): """ log.debug(u'Song Initialising') settings = QtCore.QSettings() + settings.beginGroup(u'songs') self.db_url = u'' db_type = unicode( settings.value(u'songs/db type', u'sqlite').toString()) @@ -54,17 +55,18 @@ class SongManager(): self.db_url = u'sqlite:///%s/songs.sqlite' % \ AppLocation.get_section_data_path(u'songs') else: - self.db_url = db_type + 'u://' + \ + self.db_url = u'%s://%s:%s@%s/%s' % (db_type, unicode(settings.value( - u'songs/db username', u'').toString()) + u':' + \ + u'db username', QtCore.QVariant(u'')).toString()), unicode(settings.value( - u'songs/db password', u'').toString()) + u'@' + \ + u'db password', QtCore.QVariant(u'')).toString()), unicode(settings.value( - u'songs/db hostname', u'').toString()) + u'/' + \ + u'db hostname', QtCore.QVariant(u'')).toString()), unicode(settings.value( - u'songs/db database', u'').toString()) + u'db database', QtCore.QVariant(u'')).toString())) self.session = init_models(self.db_url) metadata.create_all(checkfirst=True) + settings.endGroup() log.debug(u'Song Initialised') def get_songs(self): diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index 24ef71e81..84af7e6d0 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -46,7 +46,7 @@ class SongMediaItem(MediaManagerItem): def __init__(self, parent, icon, title): self.PluginNameShort = u'Song' - self.ConfigSection = title + self.SettingsSection = title.lower() self.IconPath = u'songs/song' self.ListViewWithDnD_class = SongListView MediaManagerItem.__init__(self, parent, icon, title) @@ -134,7 +134,8 @@ class SongMediaItem(MediaManagerItem): def configUpdated(self): self.searchAsYouType = QtCore.QSettings().value( - u'songs/search as type', u'False').toBool() + self.SettingsSection + u'/search as type', + QtCore.QVariant(u'False')).toBool() def retranslateUi(self): self.SearchTextLabel.setText(self.trUtf8('Search:')) diff --git a/openlp/plugins/songs/lib/songstab.py b/openlp/plugins/songs/lib/songstab.py index 8b9f6804d..38bdd791d 100644 --- a/openlp/plugins/songs/lib/songstab.py +++ b/openlp/plugins/songs/lib/songstab.py @@ -81,15 +81,18 @@ class SongsTab(SettingsTab): def load(self): settings = QtCore.QSettings() + settings.beginGroup(self.settingsSection) self.song_search = settings.value( - u'songs/search as type', False).toBool() - self.song_bar = settings.value(u'songs/display songbar', True).toBool() + u'search as type', QtCore.QVariant(False)).toBool() + self.song_bar = settings.value( + u'display songbar', QtCore.QVariant(True)).toBool() self.SearchAsTypeCheckBox.setChecked(self.song_search) self.SongBarActiveCheckBox.setChecked(self.song_bar) + settings.endGroup() def save(self): settings = QtCore.QSettings() - settings.setValue( - u'songs/search as type', QtCore.QVariant(self.song_search)) - settings.setValue( - u'songs/display songbar', QtCore.QVariant(self.song_bar)) + settings.beginGroup(self.settingsSection) + settings.setValue(u'search as type', QtCore.QVariant(self.song_search)) + settings.setValue(u'display songbar', QtCore.QVariant(self.song_bar)) + settings.endGroup() diff --git a/openlp/plugins/songusage/forms/songusagedetailform.py b/openlp/plugins/songusage/forms/songusagedetailform.py index e4ec80d58..97359807f 100644 --- a/openlp/plugins/songusage/forms/songusagedetailform.py +++ b/openlp/plugins/songusage/forms/songusagedetailform.py @@ -45,6 +45,7 @@ class SongUsageDetailForm(QtGui.QDialog, Ui_SongUsageDetailDialog): """ QtGui.QDialog.__init__(self, None) self.parent = parent + self.settingsSection = u'songusage' self.setupUi(self) def initialise(self): @@ -55,15 +56,16 @@ class SongUsageDetailForm(QtGui.QDialog, Ui_SongUsageDetailDialog): fromDate = QtCore.QDate(year - 1, 9, 1) self.FromDate.setSelectedDate(fromDate) self.ToDate.setSelectedDate(toDate) - self.FileLineEdit.setText(SettingsManager.get_last_dir(u'songusage', 1)) + self.FileLineEdit.setText( + SettingsManager.get_last_dir(self.settingsSection, 1)) def defineOutputLocation(self): path = QtGui.QFileDialog.getExistingDirectory(self, self.trUtf8('Output File Location'), - SettingsManager.get_last_dir(u'songusage', 1)) + SettingsManager.get_last_dir(self.settingsSection, 1)) path = unicode(path) if path != u'': - SettingsManager.set_last_dir(u'songusage', path, 1) + SettingsManager.set_last_dir(self.settingsSection, path, 1) self.FileLineEdit.setText(path) def accept(self): @@ -88,4 +90,3 @@ class SongUsageDetailForm(QtGui.QDialog, Ui_SongUsageDetailDialog): finally: if file: file.close() - diff --git a/openlp/plugins/songusage/lib/manager.py b/openlp/plugins/songusage/lib/manager.py index d307f9dd5..e8816b552 100644 --- a/openlp/plugins/songusage/lib/manager.py +++ b/openlp/plugins/songusage/lib/manager.py @@ -45,27 +45,28 @@ class SongUsageManager(): Creates the connection to the database, and creates the tables if they don't exist. """ - settings = QtCore.QSettings() log.debug(u'SongUsage Initialising') + settings = QtCore.QSettings() + settings.beginGroup(u'songusage') self.db_url = u'' db_type = unicode( - settings.value(u'songusage/db type', u'sqlite').toString()) + settings.value(u'db type', QtCore.QVariant(u'sqlite')).toString()) if db_type == u'sqlite': self.db_url = u'sqlite:///%s/songusage.sqlite' % \ AppLocation.get_section_data_path(u'songusage') else: self.db_url = u'%s://%s:%s@%s/%s' % (db_type, - unicode( - settings.value(u'songusage/db username', u'').toString()), - unicode( - settings.value(u'songusage/db password', u'').toString()), - unicode( - settings.value(u'songusage/db hostname', u'').toString()), - unicode( - settings.value(u'songusage/db database', u'').toString())) + unicode(settings.value(u'db username', + QtCore.QVariant(u'')).toString()), + unicode(settings.value(u'db password', + QtCore.QVariant(u'')).toString()), + unicode(settings.value(u'db hostname', + QtCore.QVariant(u'')).toString()), + unicode(settings.value(u'db database', + QtCore.QVariant(u'')).toString())) self.session = init_models(self.db_url) metadata.create_all(checkfirst=True) - + settings.endGroup() log.debug(u'SongUsage Initialised') def get_all_songusage(self, start_date, end_date): diff --git a/openlp/plugins/songusage/songusageplugin.py b/openlp/plugins/songusage/songusageplugin.py index c654477e0..da557e81e 100644 --- a/openlp/plugins/songusage/songusageplugin.py +++ b/openlp/plugins/songusage/songusageplugin.py @@ -111,7 +111,8 @@ class SongUsagePlugin(Plugin): QtCore.SIGNAL(u'slidecontroller_live_started'), self.onReceiveSongUsage) self.SongUsageActive = QtCore.QSettings().value( - u'songusage/active', False).toBool() + self.settings_section + u'/active', + QtCore.QVariant(False)).toBool() self.SongUsageStatus.setChecked(self.SongUsageActive) if self.songusagemanager is None: self.songusagemanager = SongUsageManager() @@ -127,8 +128,8 @@ class SongUsagePlugin(Plugin): def toggleSongUsageState(self): self.SongUsageActive = not self.SongUsageActive - QtCore.QSettings().setValue( - u'songusage/active', QtCore.QVariant(self.SongUsageActive)) + QtCore.QSettings().setValue(self.settings_section + u'/active', + QtCore.QVariant(self.SongUsageActive)) def onReceiveSongUsage(self, items): """