forked from openlp/openlp
Config file to QSettings conversion
This commit is contained in:
parent
ba17d94e77
commit
9605183812
@ -34,10 +34,10 @@ from PyQt4 import QtCore, QtGui
|
|||||||
|
|
||||||
log = logging.getLogger()
|
log = logging.getLogger()
|
||||||
|
|
||||||
from openlp.core.lib import Receiver, str_to_bool
|
from openlp.core.lib import Receiver
|
||||||
from openlp.core.resources import qInitResources
|
from openlp.core.resources import qInitResources
|
||||||
from openlp.core.ui import MainWindow, SplashScreen, ScreenList
|
from openlp.core.ui import MainWindow, SplashScreen, ScreenList
|
||||||
from openlp.core.utils import AppLocation, ConfigHelper
|
from openlp.core.utils import AppLocation
|
||||||
|
|
||||||
application_stylesheet = u"""
|
application_stylesheet = u"""
|
||||||
QMainWindow::separator
|
QMainWindow::separator
|
||||||
@ -119,8 +119,8 @@ class OpenLP(QtGui.QApplication):
|
|||||||
self.setApplicationVersion(app_version[u'version'])
|
self.setApplicationVersion(app_version[u'version'])
|
||||||
if os.name == u'nt':
|
if os.name == u'nt':
|
||||||
self.setStyleSheet(application_stylesheet)
|
self.setStyleSheet(application_stylesheet)
|
||||||
show_splash = str_to_bool(ConfigHelper.get_registry().get_value(
|
show_splash = QtCore.QSettings().value(
|
||||||
u'general', u'show splash', True))
|
u'general/show splash', True).toBool()
|
||||||
if show_splash:
|
if show_splash:
|
||||||
self.splash = SplashScreen(self.applicationVersion())
|
self.splash = SplashScreen(self.applicationVersion())
|
||||||
self.splash.show()
|
self.splash.show()
|
||||||
|
@ -164,7 +164,6 @@ class ThemeLevel(object):
|
|||||||
|
|
||||||
from eventreceiver import Receiver
|
from eventreceiver import Receiver
|
||||||
from settingsmanager import SettingsManager
|
from settingsmanager import SettingsManager
|
||||||
from pluginconfig import PluginConfig
|
|
||||||
from plugin import PluginStatus, Plugin
|
from plugin import PluginStatus, Plugin
|
||||||
from pluginmanager import PluginManager
|
from pluginmanager import PluginManager
|
||||||
from settingstab import SettingsTab
|
from settingstab import SettingsTab
|
||||||
|
@ -29,7 +29,8 @@ import os
|
|||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
|
|
||||||
from openlp.core.lib.toolbar import *
|
from openlp.core.lib.toolbar import *
|
||||||
from openlp.core.lib import contextMenuAction, contextMenuSeparator
|
from openlp.core.lib import contextMenuAction, contextMenuSeparator, \
|
||||||
|
SettingsManager
|
||||||
from serviceitem import ServiceItem
|
from serviceitem import ServiceItem
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
@ -334,13 +335,15 @@ class MediaManagerItem(QtGui.QWidget):
|
|||||||
def onFileClick(self):
|
def onFileClick(self):
|
||||||
files = QtGui.QFileDialog.getOpenFileNames(
|
files = QtGui.QFileDialog.getOpenFileNames(
|
||||||
self, self.OnNewPrompt,
|
self, self.OnNewPrompt,
|
||||||
self.parent.config.get_last_dir(), self.OnNewFileMasks)
|
SettingsManager.get_last_dir(self.ConfigSection),
|
||||||
|
self.OnNewFileMasks)
|
||||||
log.info(u'New files(s) %s', unicode(files))
|
log.info(u'New files(s) %s', unicode(files))
|
||||||
if files:
|
if files:
|
||||||
self.loadList(files)
|
self.loadList(files)
|
||||||
dir, filename = os.path.split(unicode(files[0]))
|
dir, filename = os.path.split(unicode(files[0]))
|
||||||
self.parent.config.set_last_dir(dir)
|
SettingsManager.set_last_dir(self.ConfigSection, dir)
|
||||||
self.parent.config.set_list(self.ConfigSection, self.getFileList())
|
SettingsManager.set_list(
|
||||||
|
self.ConfigSection, self.ConfigSection, self.getFileList())
|
||||||
|
|
||||||
def getFileList(self):
|
def getFileList(self):
|
||||||
count = 0
|
count = 0
|
||||||
|
@ -24,9 +24,10 @@
|
|||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from PyQt4 import QtCore
|
from PyQt4 import QtCore
|
||||||
|
|
||||||
from openlp.core.lib import PluginConfig, Receiver
|
from openlp.core.lib import Receiver
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -53,10 +54,6 @@ class Plugin(QtCore.QObject):
|
|||||||
``icon``
|
``icon``
|
||||||
An instance of QIcon, which holds an icon for this plugin.
|
An instance of QIcon, which holds an icon for this plugin.
|
||||||
|
|
||||||
``config``
|
|
||||||
An instance of PluginConfig, which allows plugins to read and write to
|
|
||||||
openlp.org's configuration. This is pre-instantiated.
|
|
||||||
|
|
||||||
``log``
|
``log``
|
||||||
A log object used to log debugging messages. This is pre-instantiated.
|
A log object used to log debugging messages. This is pre-instantiated.
|
||||||
|
|
||||||
@ -78,7 +75,8 @@ class Plugin(QtCore.QObject):
|
|||||||
Add an item to the Export menu.
|
Add an item to the Export menu.
|
||||||
|
|
||||||
``get_settings_tab()``
|
``get_settings_tab()``
|
||||||
Returns an instance of SettingsTabItem to be used in the Settings dialog.
|
Returns an instance of SettingsTabItem to be used in the Settings
|
||||||
|
dialog.
|
||||||
|
|
||||||
``add_to_menu(menubar)``
|
``add_to_menu(menubar)``
|
||||||
A method to add a menu item to anywhere in the menu, given the menu bar.
|
A method to add a menu item to anywhere in the menu, given the menu bar.
|
||||||
@ -116,7 +114,6 @@ class Plugin(QtCore.QObject):
|
|||||||
if version:
|
if version:
|
||||||
self.version = version
|
self.version = version
|
||||||
self.icon = None
|
self.icon = None
|
||||||
self.config = PluginConfig(self.name)
|
|
||||||
self.weight = 0
|
self.weight = 0
|
||||||
self.status = PluginStatus.Inactive
|
self.status = PluginStatus.Inactive
|
||||||
# Set up logging
|
# Set up logging
|
||||||
@ -125,7 +122,7 @@ class Plugin(QtCore.QObject):
|
|||||||
self.live_controller = plugin_helpers[u'live']
|
self.live_controller = plugin_helpers[u'live']
|
||||||
self.render_manager = plugin_helpers[u'render']
|
self.render_manager = plugin_helpers[u'render']
|
||||||
self.service_manager = plugin_helpers[u'service']
|
self.service_manager = plugin_helpers[u'service']
|
||||||
self.settings = plugin_helpers[u'settings']
|
self.settings_form = plugin_helpers[u'settings form']
|
||||||
self.mediadock = plugin_helpers[u'toolbox']
|
self.mediadock = plugin_helpers[u'toolbox']
|
||||||
self.maindisplay = plugin_helpers[u'maindisplay']
|
self.maindisplay = plugin_helpers[u'maindisplay']
|
||||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||||
@ -145,15 +142,16 @@ class Plugin(QtCore.QObject):
|
|||||||
"""
|
"""
|
||||||
Sets the status of the plugin
|
Sets the status of the plugin
|
||||||
"""
|
"""
|
||||||
self.status = int(self.config.get_config(u'status',
|
self.status = QtCore.QSettings().value(
|
||||||
PluginStatus.Inactive))
|
self.name.lower() + u'/status', PluginStatus.Inactive).toInt()[0]
|
||||||
|
|
||||||
def toggle_status(self, new_status):
|
def toggle_status(self, new_status):
|
||||||
"""
|
"""
|
||||||
Changes the status of the plugin and remembers it
|
Changes the status of the plugin and remembers it
|
||||||
"""
|
"""
|
||||||
self.status = new_status
|
self.status = new_status
|
||||||
self.config.set_config(u'status', self.status)
|
QtCore.QSettings().setValue(
|
||||||
|
self.name.lower() + u'/status', QtCore.QVariant(self.status))
|
||||||
|
|
||||||
def is_active(self):
|
def is_active(self):
|
||||||
"""
|
"""
|
||||||
@ -216,7 +214,8 @@ class Plugin(QtCore.QObject):
|
|||||||
"""
|
"""
|
||||||
Generic Drag and drop handler triggered from service_manager.
|
Generic Drag and drop handler triggered from service_manager.
|
||||||
"""
|
"""
|
||||||
log.debug(u'process_add_service_event event called for plugin %s' % self.name)
|
log.debug(u'process_add_service_event event called for plugin %s' %
|
||||||
|
self.name)
|
||||||
self.media_item.onAddClick()
|
self.media_item.onAddClick()
|
||||||
|
|
||||||
def about(self):
|
def about(self):
|
||||||
@ -244,7 +243,7 @@ class Plugin(QtCore.QObject):
|
|||||||
Called by the plugin to remove toolbar
|
Called by the plugin to remove toolbar
|
||||||
"""
|
"""
|
||||||
self.mediadock.remove_dock(self.name)
|
self.mediadock.remove_dock(self.name)
|
||||||
self.settings.removeTab(self.name)
|
self.settings_form.removeTab(self.name)
|
||||||
|
|
||||||
def insert_toolbox_item(self):
|
def insert_toolbox_item(self):
|
||||||
"""
|
"""
|
||||||
@ -253,7 +252,7 @@ class Plugin(QtCore.QObject):
|
|||||||
if self.media_item:
|
if self.media_item:
|
||||||
self.mediadock.insert_dock(self.media_item, self.icon, self.weight)
|
self.mediadock.insert_dock(self.media_item, self.icon, self.weight)
|
||||||
if self.settings_tab:
|
if self.settings_tab:
|
||||||
self.settings.insertTab(self.settings_tab, self.weight)
|
self.settings_form.insertTab(self.settings_tab, self.weight)
|
||||||
|
|
||||||
def can_delete_theme(self, theme):
|
def can_delete_theme(self, theme):
|
||||||
"""
|
"""
|
||||||
|
@ -1,194 +0,0 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
|
|
||||||
|
|
||||||
###############################################################################
|
|
||||||
# OpenLP - Open Source Lyrics Projection #
|
|
||||||
# --------------------------------------------------------------------------- #
|
|
||||||
# Copyright (c) 2008-2010 Raoul Snyman #
|
|
||||||
# Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael #
|
|
||||||
# Gorven, Scott Guerrieri, Christian Richter, Maikel Stuivenberg, Martin #
|
|
||||||
# Thompson, Jon Tibble, Carsten Tinggaard #
|
|
||||||
# --------------------------------------------------------------------------- #
|
|
||||||
# This program is free software; you can redistribute it and/or modify it #
|
|
||||||
# under the terms of the GNU General Public License as published by the Free #
|
|
||||||
# Software Foundation; version 2 of the License. #
|
|
||||||
# #
|
|
||||||
# This program is distributed in the hope that it will be useful, but WITHOUT #
|
|
||||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
|
|
||||||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for #
|
|
||||||
# more details. #
|
|
||||||
# #
|
|
||||||
# You should have received a copy of the GNU General Public License along #
|
|
||||||
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
|
|
||||||
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
|
||||||
###############################################################################
|
|
||||||
|
|
||||||
import os
|
|
||||||
|
|
||||||
from openlp.core.utils import ConfigHelper
|
|
||||||
|
|
||||||
class PluginConfig(object):
|
|
||||||
"""
|
|
||||||
This is a generic config helper for plugins.
|
|
||||||
"""
|
|
||||||
def __init__(self, plugin_name):
|
|
||||||
"""
|
|
||||||
Initialise the plugin config object, setting the section name to the
|
|
||||||
plugin name.
|
|
||||||
|
|
||||||
``plugin_name``
|
|
||||||
The name of the plugin to use as a section name.
|
|
||||||
"""
|
|
||||||
self.section = plugin_name.lower()
|
|
||||||
|
|
||||||
def get_config(self, key, default=None):
|
|
||||||
"""
|
|
||||||
Get a configuration value from the configuration registry.
|
|
||||||
|
|
||||||
``key``
|
|
||||||
The name of configuration to load.
|
|
||||||
|
|
||||||
``default``
|
|
||||||
Defaults to *None*. The default value to return if there is no
|
|
||||||
other value.
|
|
||||||
"""
|
|
||||||
return ConfigHelper.get_config(self.section, key, default)
|
|
||||||
|
|
||||||
def delete_config(self, key):
|
|
||||||
"""
|
|
||||||
Delete a configuration value from the configuration registry.
|
|
||||||
|
|
||||||
``key``
|
|
||||||
The name of the configuration to remove.
|
|
||||||
"""
|
|
||||||
return ConfigHelper.delete_config(self.section, key)
|
|
||||||
|
|
||||||
def set_config(self, key, value):
|
|
||||||
"""
|
|
||||||
Set a configuration value in the configuration registry.
|
|
||||||
|
|
||||||
``key``
|
|
||||||
The name of the configuration to save.
|
|
||||||
|
|
||||||
``value``
|
|
||||||
The value of the configuration to save.
|
|
||||||
"""
|
|
||||||
return ConfigHelper.set_config(self.section, key, value)
|
|
||||||
|
|
||||||
def get_data_path(self):
|
|
||||||
"""
|
|
||||||
Dynamically build the data file path for a plugin.
|
|
||||||
"""
|
|
||||||
#app_data = ConfigHelper.get_data_path()
|
|
||||||
app_data = ConfigHelper.get_data_path()
|
|
||||||
safe_name = self.section.replace(u' ',u'-')
|
|
||||||
plugin_data = self.get_config(u'data path', safe_name)
|
|
||||||
path = os.path.join(app_data, plugin_data)
|
|
||||||
if not os.path.exists(path):
|
|
||||||
os.makedirs(path)
|
|
||||||
return path
|
|
||||||
|
|
||||||
def set_data_path(self, path):
|
|
||||||
"""
|
|
||||||
Set the data file path.
|
|
||||||
|
|
||||||
``path``
|
|
||||||
The path to save.
|
|
||||||
"""
|
|
||||||
return self.set_config(u'data path', os.path.basename(path))
|
|
||||||
|
|
||||||
def get_files(self, suffix=None):
|
|
||||||
"""
|
|
||||||
Get a list of files from the data files path.
|
|
||||||
|
|
||||||
``suffix``
|
|
||||||
Defaults to *None*. The extension to search for.
|
|
||||||
"""
|
|
||||||
try:
|
|
||||||
files = os.listdir(self.get_data_path())
|
|
||||||
except:
|
|
||||||
return []
|
|
||||||
if suffix:
|
|
||||||
return_files = []
|
|
||||||
for file in files:
|
|
||||||
if file.find(u'.') != -1:
|
|
||||||
filename = file.split(u'.')
|
|
||||||
#bname = nme[0]
|
|
||||||
filesuffix = filename[1].lower()
|
|
||||||
filesuffix = filesuffix.lower()
|
|
||||||
# only load files with the correct suffix
|
|
||||||
if suffix.find(filesuffix) > -1 :
|
|
||||||
return_files.append(file)
|
|
||||||
return return_files
|
|
||||||
else:
|
|
||||||
# no filtering required
|
|
||||||
return files
|
|
||||||
|
|
||||||
def load_list(self, name):
|
|
||||||
"""
|
|
||||||
Load a list from the config file.
|
|
||||||
|
|
||||||
``name``
|
|
||||||
The name of the list.
|
|
||||||
"""
|
|
||||||
list_count = self.get_config(u'%s count' % name)
|
|
||||||
if list_count:
|
|
||||||
list_count = int(list_count)
|
|
||||||
else:
|
|
||||||
list_count = 0
|
|
||||||
list = []
|
|
||||||
if list_count > 0:
|
|
||||||
for counter in range(0, list_count):
|
|
||||||
item = self.get_config(u'%s %d' % (name, counter))
|
|
||||||
if item:
|
|
||||||
list.append(item)
|
|
||||||
return list
|
|
||||||
|
|
||||||
def set_list(self, name, list):
|
|
||||||
"""
|
|
||||||
Save a list to the config file.
|
|
||||||
|
|
||||||
``name``
|
|
||||||
The name of the list to save.
|
|
||||||
|
|
||||||
``list``
|
|
||||||
The list of values to save.
|
|
||||||
"""
|
|
||||||
old_count = int(self.get_config(u'%s count' % name, int(0)))
|
|
||||||
new_count = len(list)
|
|
||||||
self.set_config(u'%s count' % name, new_count)
|
|
||||||
for counter in range (0, new_count):
|
|
||||||
self.set_config(u'%s %d' % (name, counter), list[counter-1])
|
|
||||||
if old_count > new_count:
|
|
||||||
# Tidy up any old list itrms if list is smaller now
|
|
||||||
for counter in range(new_count, old_count):
|
|
||||||
self.delete_config(u'%s %d' % (name, counter))
|
|
||||||
|
|
||||||
def get_last_dir(self, num=None):
|
|
||||||
"""
|
|
||||||
Read the last directory used for plugin.
|
|
||||||
|
|
||||||
``num``
|
|
||||||
Defaults to *None*. A further qualifier.
|
|
||||||
"""
|
|
||||||
if num:
|
|
||||||
name = u'last directory %d' % num
|
|
||||||
else:
|
|
||||||
name = u'last directory'
|
|
||||||
last_dir = self.get_config(name)
|
|
||||||
if not last_dir:
|
|
||||||
last_dir = u''
|
|
||||||
return last_dir
|
|
||||||
|
|
||||||
def set_last_dir(self, directory, num=None):
|
|
||||||
"""
|
|
||||||
Save the last directory used for plugin.
|
|
||||||
|
|
||||||
``num``
|
|
||||||
Defaults to *None*. A further qualifier.
|
|
||||||
"""
|
|
||||||
if num:
|
|
||||||
name = u'last directory %d' % num
|
|
||||||
else:
|
|
||||||
name = u'last directory'
|
|
||||||
self.set_config(name, directory)
|
|
@ -25,14 +25,14 @@
|
|||||||
|
|
||||||
from PyQt4 import QtCore
|
from PyQt4 import QtCore
|
||||||
|
|
||||||
|
from openlp.core.utils import AppLocation
|
||||||
|
|
||||||
class SettingsManager(object):
|
class SettingsManager(object):
|
||||||
"""
|
"""
|
||||||
Class to control the size of the UI components so they size correctly.
|
Class to control the initial settings for the UI and provide helper
|
||||||
This class is created by the main window and then calculates the size of
|
functions for the loading and saving of application settings.
|
||||||
individual components.
|
|
||||||
"""
|
"""
|
||||||
def __init__(self, screen):
|
def __init__(self, screen):
|
||||||
self.settings = QtCore.QSettings()
|
|
||||||
self.screen = screen.current
|
self.screen = screen.current
|
||||||
self.width = self.screen[u'size'].width()
|
self.width = self.screen[u'size'].width()
|
||||||
self.height = self.screen[u'size'].height()
|
self.height = self.screen[u'size'].height()
|
||||||
@ -50,9 +50,129 @@ class SettingsManager(object):
|
|||||||
self.mainwindow_left + self.mainwindow_right) - 100 ) / 2
|
self.mainwindow_left + self.mainwindow_right) - 100 ) / 2
|
||||||
self.slidecontroller_image = self.slidecontroller - 50
|
self.slidecontroller_image = self.slidecontroller - 50
|
||||||
|
|
||||||
self.showPreviewPanel = self.settings.value(
|
self.showPreviewPanel = QtCore.QSettings().value(
|
||||||
u'user interface/preview panel', True).toBool()
|
u'user interface/preview panel', True).toBool()
|
||||||
|
|
||||||
def togglePreviewPanel(self, isVisible):
|
def togglePreviewPanel(self, isVisible):
|
||||||
self.settings.setValue(u'user interface/preview panel',
|
QtCore.QSettings().setValue(u'user interface/preview panel',
|
||||||
QtCore.QVariant(isVisible))
|
QtCore.QVariant(isVisible))
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def get_last_dir(section, num=None):
|
||||||
|
"""
|
||||||
|
Read the last directory used for plugin.
|
||||||
|
|
||||||
|
``section``
|
||||||
|
The section of code calling the method. This is used in the
|
||||||
|
settings key.
|
||||||
|
|
||||||
|
``num``
|
||||||
|
Defaults to *None*. A further qualifier.
|
||||||
|
"""
|
||||||
|
if num:
|
||||||
|
name = u'last directory %d' % num
|
||||||
|
else:
|
||||||
|
name = u'last directory'
|
||||||
|
last_dir = unicode(QtCore.QSettings().value(
|
||||||
|
section + u'/' + name, u'').toString())
|
||||||
|
return last_dir
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def set_last_dir(section, directory, num=None):
|
||||||
|
"""
|
||||||
|
Save the last directory used for plugin.
|
||||||
|
|
||||||
|
``section``
|
||||||
|
The section of code calling the method. This is used in the
|
||||||
|
settings key.
|
||||||
|
|
||||||
|
``directory``
|
||||||
|
The directory being stored in the settings.
|
||||||
|
|
||||||
|
``num``
|
||||||
|
Defaults to *None*. A further qualifier.
|
||||||
|
"""
|
||||||
|
if num:
|
||||||
|
name = u'last directory %d' % num
|
||||||
|
else:
|
||||||
|
name = u'last directory'
|
||||||
|
QtCore.QSettings().setValue(
|
||||||
|
section + u'/' + name, QtCore.QVariant(directory))
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def set_list(section, name, list):
|
||||||
|
"""
|
||||||
|
Save a list to application settings.
|
||||||
|
|
||||||
|
``section``
|
||||||
|
The section of the settings to store this list.
|
||||||
|
|
||||||
|
``name``
|
||||||
|
The name of the list to save.
|
||||||
|
|
||||||
|
``list``
|
||||||
|
The list of values to save.
|
||||||
|
"""
|
||||||
|
settings = QtCore.QSettings()
|
||||||
|
old_count = settings.value(
|
||||||
|
u'%s/%s count' % (section, name), 0).toInt()[0]
|
||||||
|
new_count = len(list)
|
||||||
|
settings.setValue(
|
||||||
|
u'%s/%s count' % (section, name), QtCore.QVariant(new_count))
|
||||||
|
for counter in range (0, new_count):
|
||||||
|
settings.setValue(
|
||||||
|
u'%s/%s %d' % (section, name, counter), list[counter-1])
|
||||||
|
if old_count > new_count:
|
||||||
|
# Tidy up any old list itrms if list is smaller now
|
||||||
|
for counter in range(new_count, old_count):
|
||||||
|
settings.remove(u'%s/%s %d' % (section, name, counter))
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def load_list(section, name):
|
||||||
|
"""
|
||||||
|
Load a list from the config file.
|
||||||
|
|
||||||
|
``section``
|
||||||
|
The section of the settings to load the list from.
|
||||||
|
|
||||||
|
``name``
|
||||||
|
The name of the list.
|
||||||
|
"""
|
||||||
|
settings = QtCore.QSettings()
|
||||||
|
list_count = settings.value(
|
||||||
|
u'%s/%s count' % (section, name), 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())
|
||||||
|
if item:
|
||||||
|
list.append(item)
|
||||||
|
return list
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def get_files(suffix=None):
|
||||||
|
"""
|
||||||
|
Get a list of files from the data files path.
|
||||||
|
|
||||||
|
``suffix``
|
||||||
|
Defaults to *None*. The extension to search for.
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
files = os.listdir(AppLocation.get_data_path())
|
||||||
|
except:
|
||||||
|
return []
|
||||||
|
if suffix:
|
||||||
|
return_files = []
|
||||||
|
for file in files:
|
||||||
|
if file.find(u'.') != -1:
|
||||||
|
filename = file.split(u'.')
|
||||||
|
filesuffix = filename[1].lower()
|
||||||
|
filesuffix = filesuffix.lower()
|
||||||
|
# only load files with the correct suffix
|
||||||
|
if suffix.find(filesuffix) > -1 :
|
||||||
|
return_files.append(file)
|
||||||
|
return return_files
|
||||||
|
else:
|
||||||
|
# no filtering required
|
||||||
|
return files
|
||||||
|
@ -25,24 +25,17 @@
|
|||||||
|
|
||||||
from PyQt4 import QtGui
|
from PyQt4 import QtGui
|
||||||
|
|
||||||
from openlp.core.lib import PluginConfig
|
|
||||||
|
|
||||||
class SettingsTab(QtGui.QWidget):
|
class SettingsTab(QtGui.QWidget):
|
||||||
"""
|
"""
|
||||||
SettingsTab is a helper widget for plugins to define Tabs for the settings
|
SettingsTab is a helper widget for plugins to define Tabs for the settings
|
||||||
dialog.
|
dialog.
|
||||||
"""
|
"""
|
||||||
def __init__(self, title, section=None):
|
def __init__(self, title):
|
||||||
"""
|
"""
|
||||||
Constructor to create the Settings tab item.
|
Constructor to create the Settings tab item.
|
||||||
|
|
||||||
``title``
|
``title``
|
||||||
Defaults to *None*. The title of the tab, which is usually
|
The title of the tab, which is usually displayed on the tab.
|
||||||
displayed on the tab.
|
|
||||||
|
|
||||||
``section``
|
|
||||||
Defaults to *None*. This is the section in the configuration file
|
|
||||||
to write to when the ``save`` method is called.
|
|
||||||
"""
|
"""
|
||||||
QtGui.QWidget.__init__(self)
|
QtGui.QWidget.__init__(self)
|
||||||
self.tabTitle = title
|
self.tabTitle = title
|
||||||
@ -50,10 +43,6 @@ class SettingsTab(QtGui.QWidget):
|
|||||||
self.setupUi()
|
self.setupUi()
|
||||||
self.retranslateUi()
|
self.retranslateUi()
|
||||||
self.initialise()
|
self.initialise()
|
||||||
if section is None:
|
|
||||||
self.config = PluginConfig(title)
|
|
||||||
else:
|
|
||||||
self.config = PluginConfig(section)
|
|
||||||
self.preLoad()
|
self.preLoad()
|
||||||
self.load()
|
self.load()
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
|
|
||||||
from openlp.core.lib import SettingsTab, str_to_bool, Receiver
|
from openlp.core.lib import SettingsTab, Receiver
|
||||||
|
|
||||||
class GeneralTab(SettingsTab):
|
class GeneralTab(SettingsTab):
|
||||||
"""
|
"""
|
||||||
@ -41,11 +41,13 @@ class GeneralTab(SettingsTab):
|
|||||||
values.
|
values.
|
||||||
If not set before default to last screen.
|
If not set before default to last screen.
|
||||||
"""
|
"""
|
||||||
self.MonitorNumber = int(self.config.get_config(u'monitor',
|
settings = QtCore.QSettings()
|
||||||
self.screens.monitor_number))
|
self.MonitorNumber = settings.value(
|
||||||
|
u'general/monitor', self.screens.monitor_number).toInt()[0]
|
||||||
self.screens.set_current_display(self.MonitorNumber)
|
self.screens.set_current_display(self.MonitorNumber)
|
||||||
self.screens.monitor_number = self.MonitorNumber
|
self.screens.monitor_number = self.MonitorNumber
|
||||||
self.DisplayOnMonitor = str_to_bool(self.config.get_config(u'display on monitor', u'True'))
|
self.DisplayOnMonitor = settings.value(
|
||||||
|
u'general/display on monitor', True).toBool()
|
||||||
self.screens.display = self.DisplayOnMonitor
|
self.screens.display = self.DisplayOnMonitor
|
||||||
|
|
||||||
def setupUi(self):
|
def setupUi(self):
|
||||||
@ -151,15 +153,18 @@ class GeneralTab(SettingsTab):
|
|||||||
QtCore.QObject.connect(self.MonitorComboBox,
|
QtCore.QObject.connect(self.MonitorComboBox,
|
||||||
QtCore.SIGNAL(u'activated(int)'), self.onMonitorComboBoxChanged)
|
QtCore.SIGNAL(u'activated(int)'), self.onMonitorComboBoxChanged)
|
||||||
QtCore.QObject.connect(self.DisplayOnMonitorCheck,
|
QtCore.QObject.connect(self.DisplayOnMonitorCheck,
|
||||||
QtCore.SIGNAL(u'stateChanged(int)'), self.onDisplayOnMonitorCheckChanged)
|
QtCore.SIGNAL(u'stateChanged(int)'),
|
||||||
|
self.onDisplayOnMonitorCheckChanged)
|
||||||
QtCore.QObject.connect(self.WarningCheckBox,
|
QtCore.QObject.connect(self.WarningCheckBox,
|
||||||
QtCore.SIGNAL(u'stateChanged(int)'), self.onWarningCheckBoxChanged)
|
QtCore.SIGNAL(u'stateChanged(int)'), self.onWarningCheckBoxChanged)
|
||||||
QtCore.QObject.connect(self.AutoOpenCheckBox,
|
QtCore.QObject.connect(self.AutoOpenCheckBox,
|
||||||
QtCore.SIGNAL(u'stateChanged(int)'), self.onAutoOpenCheckBoxChanged)
|
QtCore.SIGNAL(u'stateChanged(int)'), self.onAutoOpenCheckBoxChanged)
|
||||||
QtCore.QObject.connect(self.ShowSplashCheckBox,
|
QtCore.QObject.connect(self.ShowSplashCheckBox,
|
||||||
QtCore.SIGNAL(u'stateChanged(int)'), self.onShowSplashCheckBoxChanged)
|
QtCore.SIGNAL(u'stateChanged(int)'),
|
||||||
|
self.onShowSplashCheckBoxChanged)
|
||||||
QtCore.QObject.connect(self.SaveCheckServiceCheckBox,
|
QtCore.QObject.connect(self.SaveCheckServiceCheckBox,
|
||||||
QtCore.SIGNAL(u'stateChanged(int)'), self.onSaveCheckServiceCheckBox)
|
QtCore.SIGNAL(u'stateChanged(int)'),
|
||||||
|
self.onSaveCheckServiceCheckBox)
|
||||||
QtCore.QObject.connect(self.AutoPreviewCheckBox,
|
QtCore.QObject.connect(self.AutoPreviewCheckBox,
|
||||||
QtCore.SIGNAL(u'stateChanged(int)'), self.onAutoPreviewCheckBox)
|
QtCore.SIGNAL(u'stateChanged(int)'), self.onAutoPreviewCheckBox)
|
||||||
QtCore.QObject.connect(self.NumberEdit,
|
QtCore.QObject.connect(self.NumberEdit,
|
||||||
@ -171,15 +176,20 @@ class GeneralTab(SettingsTab):
|
|||||||
|
|
||||||
def retranslateUi(self):
|
def retranslateUi(self):
|
||||||
self.MonitorGroupBox.setTitle(self.trUtf8('Monitors'))
|
self.MonitorGroupBox.setTitle(self.trUtf8('Monitors'))
|
||||||
self.MonitorLabel.setText(self.trUtf8('Select monitor for output display:'))
|
self.MonitorLabel.setText(
|
||||||
self.DisplayOnMonitorCheck.setText(self.trUtf8('Display if in single screen'))
|
self.trUtf8('Select monitor for output display:'))
|
||||||
|
self.DisplayOnMonitorCheck.setText(
|
||||||
|
self.trUtf8('Display if in single screen'))
|
||||||
self.StartupGroupBox.setTitle(self.trUtf8('Application Startup'))
|
self.StartupGroupBox.setTitle(self.trUtf8('Application Startup'))
|
||||||
self.WarningCheckBox.setText(self.trUtf8('Show blank screen warning'))
|
self.WarningCheckBox.setText(self.trUtf8('Show blank screen warning'))
|
||||||
self.AutoOpenCheckBox.setText(self.trUtf8('Automatically open the last service'))
|
self.AutoOpenCheckBox.setText(
|
||||||
|
self.trUtf8('Automatically open the last service'))
|
||||||
self.ShowSplashCheckBox.setText(self.trUtf8('Show the splash screen'))
|
self.ShowSplashCheckBox.setText(self.trUtf8('Show the splash screen'))
|
||||||
self.SettingsGroupBox.setTitle(self.trUtf8('Application Settings'))
|
self.SettingsGroupBox.setTitle(self.trUtf8('Application Settings'))
|
||||||
self.SaveCheckServiceCheckBox.setText(self.trUtf8('Prompt to save Service before starting New'))
|
self.SaveCheckServiceCheckBox.setText(
|
||||||
self.AutoPreviewCheckBox.setText(self.trUtf8('Preview Next Song from Service Manager'))
|
self.trUtf8('Prompt to save Service before starting New'))
|
||||||
|
self.AutoPreviewCheckBox.setText(
|
||||||
|
self.trUtf8('Preview Next Song from Service Manager'))
|
||||||
self.CCLIGroupBox.setTitle(self.trUtf8('CCLI Details'))
|
self.CCLIGroupBox.setTitle(self.trUtf8('CCLI Details'))
|
||||||
self.NumberLabel.setText(self.trUtf8('CCLI Number:'))
|
self.NumberLabel.setText(self.trUtf8('CCLI Number:'))
|
||||||
self.UsernameLabel.setText(self.trUtf8('SongSelect Username:'))
|
self.UsernameLabel.setText(self.trUtf8('SongSelect Username:'))
|
||||||
@ -216,20 +226,30 @@ class GeneralTab(SettingsTab):
|
|||||||
self.Password = self.PasswordEdit.displayText()
|
self.Password = self.PasswordEdit.displayText()
|
||||||
|
|
||||||
def load(self):
|
def load(self):
|
||||||
|
settings = QtCore.QSettings()
|
||||||
for screen in self.screens.screen_list:
|
for screen in self.screens.screen_list:
|
||||||
screen_name = u'%s %d' % (self.trUtf8('Screen'), screen[u'number'] + 1)
|
screen_name = u'%s %d' % (self.trUtf8('Screen'),
|
||||||
|
screen[u'number'] + 1)
|
||||||
if screen[u'primary']:
|
if screen[u'primary']:
|
||||||
screen_name = u'%s (%s)' % (screen_name, self.trUtf8('primary'))
|
screen_name = u'%s (%s)' % (screen_name, self.trUtf8('primary'))
|
||||||
self.MonitorComboBox.addItem(screen_name)
|
self.MonitorComboBox.addItem(screen_name)
|
||||||
# Get the configs
|
# Get the configs
|
||||||
self.Warning = str_to_bool(self.config.get_config(u'blank warning', u'False'))
|
self.Warning = settings.value(
|
||||||
self.AutoOpen = str_to_bool(self.config.get_config(u'auto open', u'False'))
|
u'general/blank warning', QtCore.QVariant(False)).toBool()
|
||||||
self.ShowSplash = str_to_bool(self.config.get_config(u'show splash', u'True'))
|
self.AutoOpen = settings.value(
|
||||||
self.PromptSaveService = str_to_bool(self.config.get_config(u'save prompt', u'False'))
|
u'general/auto open', QtCore.QVariant(False)).toBool()
|
||||||
self.AutoPreview = str_to_bool(self.config.get_config(u'auto preview', u'False'))
|
self.ShowSplash = settings.value(
|
||||||
self.CCLINumber = unicode(self.config.get_config(u'ccli number', u''))
|
u'general/show splash', QtCore.QVariant(True)).toBool()
|
||||||
self.Username = unicode(self.config.get_config(u'songselect username', u''))
|
self.PromptSaveService = settings.value(
|
||||||
self.Password = unicode(self.config.get_config(u'songselect password', u''))
|
u'general/save prompt', QtCore.QVariant(False)).toBool()
|
||||||
|
self.AutoPreview = settings.value(
|
||||||
|
u'general/auto preview', QtCore.QVariant(False)).toBool()
|
||||||
|
self.CCLINumber = unicode(settings.value(
|
||||||
|
u'general/ccli number', QtCore.QVariant(u'')).toString())
|
||||||
|
self.Username = unicode(settings.value(
|
||||||
|
u'general/songselect username', QtCore.QVariant(u'')).toString())
|
||||||
|
self.Password = unicode(settings.value(
|
||||||
|
u'general/songselect password', QtCore.QVariant(u'')).toString())
|
||||||
self.SaveCheckServiceCheckBox.setChecked(self.PromptSaveService)
|
self.SaveCheckServiceCheckBox.setChecked(self.PromptSaveService)
|
||||||
# Set a few things up
|
# Set a few things up
|
||||||
self.MonitorComboBox.setCurrentIndex(self.MonitorNumber)
|
self.MonitorComboBox.setCurrentIndex(self.MonitorNumber)
|
||||||
@ -243,16 +263,18 @@ class GeneralTab(SettingsTab):
|
|||||||
self.PasswordEdit.setText(self.Password)
|
self.PasswordEdit.setText(self.Password)
|
||||||
|
|
||||||
def save(self):
|
def save(self):
|
||||||
self.config.set_config(u'monitor', self.MonitorNumber)
|
settings = QtCore.QSettings()
|
||||||
self.config.set_config(u'display on monitor', self.DisplayOnMonitor)
|
settings.setValue(u'general/monitor', self.MonitorNumber)
|
||||||
self.config.set_config(u'blank warning', self.Warning)
|
settings.setValue(
|
||||||
self.config.set_config(u'auto open', self.AutoOpen)
|
u'general/display on monitor', self.DisplayOnMonitor)
|
||||||
self.config.set_config(u'show splash', self.ShowSplash)
|
settings.setValue(u'general/blank warning', self.Warning)
|
||||||
self.config.set_config(u'save prompt', self.PromptSaveService)
|
settings.setValue(u'general/auto open', self.AutoOpen)
|
||||||
self.config.set_config(u'auto preview', self.AutoPreview)
|
settings.setValue(u'general/show splash', self.ShowSplash)
|
||||||
self.config.set_config(u'ccli number', self.CCLINumber)
|
settings.setValue(u'general/save prompt', self.PromptSaveService)
|
||||||
self.config.set_config(u'songselect username', self.Username)
|
settings.setValue(u'general/auto preview', self.AutoPreview)
|
||||||
self.config.set_config(u'songselect password', self.Password)
|
settings.setValue(u'general/ccli number', self.CCLINumber)
|
||||||
|
settings.setValue(u'general/songselect username', self.Username)
|
||||||
|
settings.setValue(u'general/songselect password', self.Password)
|
||||||
self.screens.display = self.DisplayOnMonitor
|
self.screens.display = self.DisplayOnMonitor
|
||||||
#Monitor Number has changed.
|
#Monitor Number has changed.
|
||||||
if self.screens.monitor_number != self.MonitorNumber:
|
if self.screens.monitor_number != self.MonitorNumber:
|
||||||
|
@ -30,8 +30,8 @@ from PyQt4 import QtCore, QtGui
|
|||||||
|
|
||||||
from openlp.core.ui import AboutForm, SettingsForm, ServiceManager, \
|
from openlp.core.ui import AboutForm, SettingsForm, ServiceManager, \
|
||||||
ThemeManager, SlideController, PluginForm, MediaDockManager, DisplayManager
|
ThemeManager, SlideController, PluginForm, MediaDockManager, DisplayManager
|
||||||
from openlp.core.lib import RenderManager, PluginConfig, build_icon, \
|
from openlp.core.lib import RenderManager, build_icon, OpenLPDockWidget, \
|
||||||
OpenLPDockWidget, SettingsManager, PluginManager, Receiver, str_to_bool
|
SettingsManager, PluginManager, Receiver
|
||||||
from openlp.core.utils import check_latest_version, AppLocation, add_actions
|
from openlp.core.utils import check_latest_version, AppLocation, add_actions
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
@ -56,11 +56,10 @@ class VersionThread(QtCore.QThread):
|
|||||||
A special Qt thread class to fetch the version of OpenLP from the website.
|
A special Qt thread class to fetch the version of OpenLP from the website.
|
||||||
This is threaded so that it doesn't affect the loading time of OpenLP.
|
This is threaded so that it doesn't affect the loading time of OpenLP.
|
||||||
"""
|
"""
|
||||||
def __init__(self, parent, app_version, generalConfig):
|
def __init__(self, parent, app_version):
|
||||||
QtCore.QThread.__init__(self, parent)
|
QtCore.QThread.__init__(self, parent)
|
||||||
self.parent = parent
|
self.parent = parent
|
||||||
self.app_version = app_version
|
self.app_version = app_version
|
||||||
self.generalConfig = generalConfig
|
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
"""
|
"""
|
||||||
@ -68,7 +67,7 @@ class VersionThread(QtCore.QThread):
|
|||||||
"""
|
"""
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
Receiver.send_message(u'maindisplay_blank_check')
|
Receiver.send_message(u'maindisplay_blank_check')
|
||||||
version = check_latest_version(self.generalConfig, self.app_version)
|
version = check_latest_version(self.app_version)
|
||||||
#new version has arrived
|
#new version has arrived
|
||||||
if version != self.app_version[u'full']:
|
if version != self.app_version[u'full']:
|
||||||
Receiver.send_message(u'openlp_version_check', u'%s' % version)
|
Receiver.send_message(u'openlp_version_check', u'%s' % version)
|
||||||
@ -422,7 +421,6 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
|||||||
self.applicationVersion = applicationVersion
|
self.applicationVersion = applicationVersion
|
||||||
self.serviceNotSaved = False
|
self.serviceNotSaved = False
|
||||||
self.settingsmanager = SettingsManager(screens)
|
self.settingsmanager = SettingsManager(screens)
|
||||||
self.generalConfig = PluginConfig(u'General')
|
|
||||||
self.displayManager = DisplayManager(screens)
|
self.displayManager = DisplayManager(screens)
|
||||||
self.aboutForm = AboutForm(self, applicationVersion)
|
self.aboutForm = AboutForm(self, applicationVersion)
|
||||||
self.settingsForm = SettingsForm(self.screens, self, self)
|
self.settingsForm = SettingsForm(self.screens, self, self)
|
||||||
@ -510,7 +508,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
|||||||
self.plugin_helpers[u'live'] = self.LiveController
|
self.plugin_helpers[u'live'] = self.LiveController
|
||||||
self.plugin_helpers[u'render'] = self.RenderManager
|
self.plugin_helpers[u'render'] = self.RenderManager
|
||||||
self.plugin_helpers[u'service'] = self.ServiceManagerContents
|
self.plugin_helpers[u'service'] = self.ServiceManagerContents
|
||||||
self.plugin_helpers[u'settings'] = self.settingsForm
|
self.plugin_helpers[u'settings form'] = self.settingsForm
|
||||||
self.plugin_helpers[u'toolbox'] = self.mediaDockManager
|
self.plugin_helpers[u'toolbox'] = self.mediaDockManager
|
||||||
self.plugin_helpers[u'maindisplay'] = self.displayManager.mainDisplay
|
self.plugin_helpers[u'maindisplay'] = self.displayManager.mainDisplay
|
||||||
self.plugin_manager.find_plugins(pluginpath, self.plugin_helpers)
|
self.plugin_manager.find_plugins(pluginpath, self.plugin_helpers)
|
||||||
@ -563,7 +561,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
|||||||
if self.displayManager.mainDisplay.isVisible():
|
if self.displayManager.mainDisplay.isVisible():
|
||||||
self.displayManager.mainDisplay.setFocus()
|
self.displayManager.mainDisplay.setFocus()
|
||||||
self.activateWindow()
|
self.activateWindow()
|
||||||
if str_to_bool(self.generalConfig.get_config(u'auto open', False)):
|
if QtCore.QSettings().value(u'general/auto open', False).toBool():
|
||||||
self.ServiceManagerContents.onLoadService(True)
|
self.ServiceManagerContents.onLoadService(True)
|
||||||
|
|
||||||
def blankCheck(self):
|
def blankCheck(self):
|
||||||
@ -571,8 +569,8 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
|||||||
Check and display message if screen blank on setup.
|
Check and display message if screen blank on setup.
|
||||||
Triggered by delay thread.
|
Triggered by delay thread.
|
||||||
"""
|
"""
|
||||||
if str_to_bool(self.generalConfig.get_config(u'screen blank', False)) \
|
if QtCore.QSettings().value(u'general/screen blank', False).toBool() \
|
||||||
and str_to_bool(self.generalConfig.get_config(u'blank warning', False)):
|
and QtCore.QSettings().value(u'general/blank warning', False).toBool():
|
||||||
self.LiveController.onBlankDisplay(True)
|
self.LiveController.onBlankDisplay(True)
|
||||||
QtGui.QMessageBox.question(self,
|
QtGui.QMessageBox.question(self,
|
||||||
self.trUtf8('OpenLP Main Display Blanked'),
|
self.trUtf8('OpenLP Main Display Blanked'),
|
||||||
@ -584,7 +582,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
|||||||
"""
|
"""
|
||||||
Start an initial setup thread to delay notifications
|
Start an initial setup thread to delay notifications
|
||||||
"""
|
"""
|
||||||
vT = VersionThread(self, self.applicationVersion, self.generalConfig)
|
vT = VersionThread(self, self.applicationVersion)
|
||||||
vT.start()
|
vT.start()
|
||||||
|
|
||||||
def onHelpAboutItemClicked(self):
|
def onHelpAboutItemClicked(self):
|
||||||
@ -748,8 +746,8 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
|||||||
self.FileMenu.addAction(self.FileMenuActions[-1])
|
self.FileMenu.addAction(self.FileMenuActions[-1])
|
||||||
|
|
||||||
def addRecentFile(self, filename):
|
def addRecentFile(self, filename):
|
||||||
recentFileCount = int(PluginConfig(u'General').
|
recentFileCount = QtCore.QSettings().value(
|
||||||
get_config(u'max recent files', 4))
|
u'general/max recent files', 4).toInt()[0]
|
||||||
if filename and not self.recentFiles.contains(filename):
|
if filename and not self.recentFiles.contains(filename):
|
||||||
self.recentFiles.prepend(QtCore.QString(filename))
|
self.recentFiles.prepend(QtCore.QString(filename))
|
||||||
while self.recentFiles.count() > recentFileCount:
|
while self.recentFiles.count() > recentFileCount:
|
||||||
|
@ -32,9 +32,10 @@ log = logging.getLogger(__name__)
|
|||||||
|
|
||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
|
|
||||||
from openlp.core.lib import PluginConfig, OpenLPToolbar, ServiceItem, \
|
from openlp.core.lib import OpenLPToolbar, ServiceItem, contextMenuAction, \
|
||||||
contextMenuAction, Receiver, str_to_bool, build_icon, ItemCapabilities
|
Receiver, build_icon, ItemCapabilities, SettingsManager
|
||||||
from openlp.core.ui import ServiceNoteForm, ServiceItemEditForm
|
from openlp.core.ui import ServiceNoteForm, ServiceItemEditForm
|
||||||
|
from openlp.core.utils import AppLocation
|
||||||
|
|
||||||
class ServiceManagerList(QtGui.QTreeWidget):
|
class ServiceManagerList(QtGui.QTreeWidget):
|
||||||
|
|
||||||
@ -189,10 +190,9 @@ class ServiceManager(QtGui.QWidget):
|
|||||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||||
QtCore.SIGNAL(u'config_updated'), self.regenerateServiceItems)
|
QtCore.SIGNAL(u'config_updated'), self.regenerateServiceItems)
|
||||||
# Last little bits of setting up
|
# Last little bits of setting up
|
||||||
self.config = PluginConfig(u'ServiceManager')
|
self.service_theme = unicode(QtCore.QSettings().value(
|
||||||
self.servicePath = self.config.get_data_path()
|
u'service manager/service theme', u'').toString())
|
||||||
self.service_theme = unicode(
|
self.servicePath = AppLocation.get_section_data_path(u'servicemanager')
|
||||||
self.config.get_config(u'service theme', u''))
|
|
||||||
#build the context menu
|
#build the context menu
|
||||||
self.menu = QtGui.QMenu()
|
self.menu = QtGui.QMenu()
|
||||||
self.editAction = self.menu.addAction(self.trUtf8('&Edit Item'))
|
self.editAction = self.menu.addAction(self.trUtf8('&Edit Item'))
|
||||||
@ -201,7 +201,8 @@ class ServiceManager(QtGui.QWidget):
|
|||||||
self.editAction.setIcon(build_icon(u':/general/general_edit.png'))
|
self.editAction.setIcon(build_icon(u':/general/general_edit.png'))
|
||||||
self.notesAction = self.menu.addAction(self.trUtf8('&Notes'))
|
self.notesAction = self.menu.addAction(self.trUtf8('&Notes'))
|
||||||
self.notesAction.setIcon(build_icon(u':/services/service_notes.png'))
|
self.notesAction.setIcon(build_icon(u':/services/service_notes.png'))
|
||||||
self.deleteAction = self.menu.addAction(self.trUtf8('&Delete From Service'))
|
self.deleteAction = self.menu.addAction(
|
||||||
|
self.trUtf8('&Delete From Service'))
|
||||||
self.deleteAction.setIcon(build_icon(u':/general/general_delete.png'))
|
self.deleteAction.setIcon(build_icon(u':/general/general_delete.png'))
|
||||||
self.sep1 = self.menu.addAction(u'')
|
self.sep1 = self.menu.addAction(u'')
|
||||||
self.sep1.setSeparator(True)
|
self.sep1.setSeparator(True)
|
||||||
@ -402,8 +403,7 @@ class ServiceManager(QtGui.QWidget):
|
|||||||
Clear the list to create a new service
|
Clear the list to create a new service
|
||||||
"""
|
"""
|
||||||
if self.parent.serviceNotSaved and \
|
if self.parent.serviceNotSaved and \
|
||||||
str_to_bool(PluginConfig(u'General').
|
QtCore.QSettings().value(u'general/save prompt', False).toBool():
|
||||||
get_config(u'save prompt', u'False')):
|
|
||||||
ret = QtGui.QMessageBox.question(self,
|
ret = QtGui.QMessageBox.question(self,
|
||||||
self.trUtf8('Save Changes to Service?'),
|
self.trUtf8('Save Changes to Service?'),
|
||||||
self.trUtf8('Your service is unsaved, do you want to save '
|
self.trUtf8('Your service is unsaved, do you want to save '
|
||||||
@ -486,17 +486,18 @@ class ServiceManager(QtGui.QWidget):
|
|||||||
log.debug(u'onSaveService')
|
log.debug(u'onSaveService')
|
||||||
if not quick or self.isNew:
|
if not quick or self.isNew:
|
||||||
filename = QtGui.QFileDialog.getSaveFileName(self,
|
filename = QtGui.QFileDialog.getSaveFileName(self,
|
||||||
self.trUtf8(u'Save Service'), self.config.get_last_dir(),
|
self.trUtf8(u'Save Service'),
|
||||||
|
SettingsManager.get_last_dir(u'servicemanager'),
|
||||||
self.trUtf8(u'OpenLP Service Files (*.osz)'))
|
self.trUtf8(u'OpenLP Service Files (*.osz)'))
|
||||||
else:
|
else:
|
||||||
filename = self.config.get_last_dir()
|
filename = SettingsManager.get_last_dir(u'servicemanager')
|
||||||
if filename:
|
if filename:
|
||||||
splittedFile = filename.split(u'.')
|
splittedFile = filename.split(u'.')
|
||||||
if splittedFile[-1] != u'osz':
|
if splittedFile[-1] != u'osz':
|
||||||
filename = filename + u'.osz'
|
filename = filename + u'.osz'
|
||||||
filename = unicode(filename)
|
filename = unicode(filename)
|
||||||
self.isNew = False
|
self.isNew = False
|
||||||
self.config.set_last_dir(filename)
|
SettingsManager.set_last_dir(u'servicemanager', filename)
|
||||||
service = []
|
service = []
|
||||||
servicefile = filename + u'.osd'
|
servicefile = filename + u'.osd'
|
||||||
zip = None
|
zip = None
|
||||||
@ -537,11 +538,12 @@ class ServiceManager(QtGui.QWidget):
|
|||||||
|
|
||||||
def onLoadService(self, lastService=False):
|
def onLoadService(self, lastService=False):
|
||||||
if lastService:
|
if lastService:
|
||||||
filename = self.config.get_last_dir()
|
filename = SettingsManager.get_last_dir(u'servicemanager')
|
||||||
else:
|
else:
|
||||||
filename = QtGui.QFileDialog.getOpenFileName(
|
filename = QtGui.QFileDialog.getOpenFileName(
|
||||||
self, self.trUtf8('Open Service'),
|
self, self.trUtf8('Open Service'),
|
||||||
self.config.get_last_dir(), u'Services (*.osz)')
|
SettingsManager.get_last_dir(u'servicemanager'),
|
||||||
|
u'Services (*.osz)')
|
||||||
self.loadService(filename)
|
self.loadService(filename)
|
||||||
|
|
||||||
def loadService(self, filename=None):
|
def loadService(self, filename=None):
|
||||||
@ -570,7 +572,7 @@ class ServiceManager(QtGui.QWidget):
|
|||||||
filename = unicode(filename)
|
filename = unicode(filename)
|
||||||
name = filename.split(os.path.sep)
|
name = filename.split(os.path.sep)
|
||||||
if filename:
|
if filename:
|
||||||
self.config.set_last_dir(filename)
|
SettingsManager.set_last_dir(u'servicemanager', filename)
|
||||||
zip = None
|
zip = None
|
||||||
f = None
|
f = None
|
||||||
try:
|
try:
|
||||||
@ -639,7 +641,8 @@ class ServiceManager(QtGui.QWidget):
|
|||||||
"""
|
"""
|
||||||
self.service_theme = unicode(self.ThemeComboBox.currentText())
|
self.service_theme = unicode(self.ThemeComboBox.currentText())
|
||||||
self.parent.RenderManager.set_service_theme(self.service_theme)
|
self.parent.RenderManager.set_service_theme(self.service_theme)
|
||||||
self.config.set_config(u'service theme', self.service_theme)
|
QtCore.QSettings().setValue(u'service manager/service theme',
|
||||||
|
QtCore.QVariant(self.service_theme))
|
||||||
self.regenerateServiceItems()
|
self.regenerateServiceItems()
|
||||||
|
|
||||||
def regenerateServiceItems(self):
|
def regenerateServiceItems(self):
|
||||||
@ -651,7 +654,8 @@ class ServiceManager(QtGui.QWidget):
|
|||||||
self.serviceItems = []
|
self.serviceItems = []
|
||||||
self.isNew = True
|
self.isNew = True
|
||||||
for item in tempServiceItems:
|
for item in tempServiceItems:
|
||||||
self.addServiceItem(item[u'service_item'], False, item[u'expanded'])
|
self.addServiceItem(
|
||||||
|
item[u'service_item'], False, item[u'expanded'])
|
||||||
#Set to False as items may have changed rendering
|
#Set to False as items may have changed rendering
|
||||||
#does not impact the saved song so True may also be valid
|
#does not impact the saved song so True may also be valid
|
||||||
self.parent.serviceChanged(False, self.serviceName)
|
self.parent.serviceChanged(False, self.serviceName)
|
||||||
@ -720,11 +724,11 @@ class ServiceManager(QtGui.QWidget):
|
|||||||
item, count = self.findServiceItem()
|
item, count = self.findServiceItem()
|
||||||
self.parent.LiveController.addServiceManagerItem(
|
self.parent.LiveController.addServiceManagerItem(
|
||||||
self.serviceItems[item][u'service_item'], count)
|
self.serviceItems[item][u'service_item'], count)
|
||||||
if str_to_bool(PluginConfig(u'General').
|
if QtCore.QSettings().value(u'general/auto preview', False).toBool():
|
||||||
get_config(u'auto preview', u'False')):
|
|
||||||
item += 1
|
item += 1
|
||||||
if self.serviceItems and item < len(self.serviceItems) and \
|
if self.serviceItems and item < len(self.serviceItems) and \
|
||||||
self.serviceItems[item][u'service_item'].is_capable(ItemCapabilities.AllowsPreview):
|
self.serviceItems[item][u'service_item'].is_capable(
|
||||||
|
ItemCapabilities.AllowsPreview):
|
||||||
self.parent.PreviewController.addServiceManagerItem(
|
self.parent.PreviewController.addServiceManagerItem(
|
||||||
self.serviceItems[item][u'service_item'], 0)
|
self.serviceItems[item][u'service_item'], 0)
|
||||||
|
|
||||||
|
@ -41,8 +41,7 @@ class HideMode(object):
|
|||||||
Blank = 1
|
Blank = 1
|
||||||
Theme = 2
|
Theme = 2
|
||||||
|
|
||||||
from openlp.core.lib import OpenLPToolbar, Receiver, str_to_bool, \
|
from openlp.core.lib import OpenLPToolbar, Receiver, resize_image
|
||||||
PluginConfig, resize_image
|
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -96,7 +95,7 @@ class SlideController(QtGui.QWidget):
|
|||||||
self.settingsmanager = settingsmanager
|
self.settingsmanager = settingsmanager
|
||||||
self.isLive = isLive
|
self.isLive = isLive
|
||||||
self.parent = parent
|
self.parent = parent
|
||||||
self.songsconfig = PluginConfig(u'Songs')
|
self.mainDisplay = self.parent.displayManager.mainDisplay
|
||||||
self.loop_list = [
|
self.loop_list = [
|
||||||
u'Start Loop',
|
u'Start Loop',
|
||||||
u'Stop Loop',
|
u'Stop Loop',
|
||||||
@ -394,7 +393,7 @@ class SlideController(QtGui.QWidget):
|
|||||||
self.Toolbar.makeWidgetsInvisible(self.loop_list)
|
self.Toolbar.makeWidgetsInvisible(self.loop_list)
|
||||||
if item.is_text():
|
if item.is_text():
|
||||||
self.Toolbar.makeWidgetsInvisible(self.loop_list)
|
self.Toolbar.makeWidgetsInvisible(self.loop_list)
|
||||||
if str_to_bool(self.songsconfig.get_config(u'show songbar', True)) \
|
if QtCore.QSettings().value(u'songs/show songbar', True) \
|
||||||
and len(self.slideList) > 0:
|
and len(self.slideList) > 0:
|
||||||
self.Toolbar.makeWidgetsVisible([u'Song Menu'])
|
self.Toolbar.makeWidgetsVisible([u'Song Menu'])
|
||||||
if item.is_capable(ItemCapabilities.AllowsLoop) and \
|
if item.is_capable(ItemCapabilities.AllowsLoop) and \
|
||||||
@ -403,7 +402,7 @@ class SlideController(QtGui.QWidget):
|
|||||||
if item.is_media():
|
if item.is_media():
|
||||||
self.Toolbar.setVisible(False)
|
self.Toolbar.setVisible(False)
|
||||||
self.Mediabar.setVisible(True)
|
self.Mediabar.setVisible(True)
|
||||||
#self.volumeSlider.setAudioOutput(self.parent.mainDisplay.videoDisplay.audio)
|
#self.volumeSlider.setAudioOutput(self.mainDisplay.videoDisplay.audio)
|
||||||
|
|
||||||
def enablePreviewToolBar(self, item):
|
def enablePreviewToolBar(self, item):
|
||||||
"""
|
"""
|
||||||
@ -583,8 +582,8 @@ class SlideController(QtGui.QWidget):
|
|||||||
if force:
|
if force:
|
||||||
self.blankButton.setChecked(True)
|
self.blankButton.setChecked(True)
|
||||||
self.blankScreen(HideMode.Blank, self.blankButton.isChecked())
|
self.blankScreen(HideMode.Blank, self.blankButton.isChecked())
|
||||||
self.parent.generalConfig.set_config(u'screen blank',
|
QtCore.QSettings().setValue(u'general/screen blank',
|
||||||
self.blankButton.isChecked())
|
QtCore.QVariant(self.blankButton.isChecked()))
|
||||||
|
|
||||||
def onThemeDisplay(self, force=False):
|
def onThemeDisplay(self, force=False):
|
||||||
"""
|
"""
|
||||||
@ -603,9 +602,9 @@ class SlideController(QtGui.QWidget):
|
|||||||
if force:
|
if force:
|
||||||
self.hideButton.setChecked(True)
|
self.hideButton.setChecked(True)
|
||||||
if self.hideButton.isChecked():
|
if self.hideButton.isChecked():
|
||||||
self.parent.mainDisplay.hideDisplay()
|
self.mainDisplay.hideDisplay()
|
||||||
else:
|
else:
|
||||||
self.parent.mainDisplay.showDisplay()
|
self.mainDisplay.showDisplay()
|
||||||
|
|
||||||
def blankScreen(self, blankType, blanked=False):
|
def blankScreen(self, blankType, blanked=False):
|
||||||
"""
|
"""
|
||||||
@ -619,9 +618,9 @@ class SlideController(QtGui.QWidget):
|
|||||||
Receiver.send_message(u'%s_unblank'
|
Receiver.send_message(u'%s_unblank'
|
||||||
% self.serviceItem.name.lower(),
|
% self.serviceItem.name.lower(),
|
||||||
[self.serviceItem, self.isLive])
|
[self.serviceItem, self.isLive])
|
||||||
self.parent.mainDisplay.blankDisplay(blankType, blanked)
|
self.mainDisplay.blankDisplay(blankType, blanked)
|
||||||
else:
|
else:
|
||||||
self.parent.mainDisplay.blankDisplay(blankType, blanked)
|
self.mainDisplay.blankDisplay(blankType, blanked)
|
||||||
|
|
||||||
def onSlideSelected(self):
|
def onSlideSelected(self):
|
||||||
"""
|
"""
|
||||||
@ -642,12 +641,15 @@ class SlideController(QtGui.QWidget):
|
|||||||
self.SlidePreview.setPixmap(QtGui.QPixmap.fromImage(frame))
|
self.SlidePreview.setPixmap(QtGui.QPixmap.fromImage(frame))
|
||||||
else:
|
else:
|
||||||
if isinstance(frame[u'main'], basestring):
|
if isinstance(frame[u'main'], basestring):
|
||||||
self.SlidePreview.setPixmap(QtGui.QPixmap(frame[u'main']))
|
self.SlidePreview.setPixmap(
|
||||||
|
QtGui.QPixmap(frame[u'main']))
|
||||||
else:
|
else:
|
||||||
self.SlidePreview.setPixmap(QtGui.QPixmap.fromImage(frame[u'main']))
|
self.SlidePreview.setPixmap(
|
||||||
log.log(15, u'Slide Rendering took %4s' % (time.time() - before))
|
QtGui.QPixmap.fromImage(frame[u'main']))
|
||||||
|
log.log(
|
||||||
|
15, u'Slide Rendering took %4s' % (time.time() - before))
|
||||||
if self.isLive:
|
if self.isLive:
|
||||||
self.parent.displayManager.mainDisplay.frameView(frame, True)
|
self.mainDisplay.frameView(frame, True)
|
||||||
self.selectedRow = row
|
self.selectedRow = row
|
||||||
|
|
||||||
def onSlideChange(self, row):
|
def onSlideChange(self, row):
|
||||||
|
@ -33,10 +33,10 @@ from PyQt4 import QtCore, QtGui
|
|||||||
|
|
||||||
from openlp.core.ui import AmendThemeForm
|
from openlp.core.ui import AmendThemeForm
|
||||||
from openlp.core.theme import Theme
|
from openlp.core.theme import Theme
|
||||||
from openlp.core.lib import PluginConfig, OpenLPToolbar, contextMenuAction, \
|
from openlp.core.lib import OpenLPToolbar, contextMenuAction, \
|
||||||
ThemeXML, str_to_bool, get_text_file_string, build_icon, Receiver, \
|
ThemeXML, str_to_bool, get_text_file_string, build_icon, Receiver, \
|
||||||
contextMenuSeparator
|
contextMenuSeparator, SettingsManager
|
||||||
from openlp.core.utils import ConfigHelper
|
from openlp.core.utils import AppLocation
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -105,16 +105,14 @@ class ThemeManager(QtGui.QWidget):
|
|||||||
QtCore.SIGNAL(u'theme_update_global'), self.changeGlobalFromTab)
|
QtCore.SIGNAL(u'theme_update_global'), self.changeGlobalFromTab)
|
||||||
#Variables
|
#Variables
|
||||||
self.themelist = []
|
self.themelist = []
|
||||||
self.path = os.path.join(ConfigHelper.get_data_path(), u'themes')
|
self.path = AppLocation.get_section_data_path(u'themes')
|
||||||
self.checkThemesExists(self.path)
|
self.checkThemesExists(self.path)
|
||||||
self.thumbPath = os.path.join(self.path, u'.thumbnails')
|
self.thumbPath = os.path.join(self.path, u'.thumbnails')
|
||||||
self.checkThemesExists(self.thumbPath)
|
self.checkThemesExists(self.thumbPath)
|
||||||
self.amendThemeForm.path = self.path
|
self.amendThemeForm.path = self.path
|
||||||
# Last little bits of setting up
|
# Last little bits of setting up
|
||||||
self.config = PluginConfig(u'themes')
|
self.global_theme = unicode(QtCore.QSettings().value(
|
||||||
self.servicePath = self.config.get_data_path()
|
u'themes/global theme', u'').toString())
|
||||||
self.global_theme = unicode(
|
|
||||||
self.config.get_config(u'global theme', u''))
|
|
||||||
|
|
||||||
def changeGlobalFromTab(self, themeName):
|
def changeGlobalFromTab(self, themeName):
|
||||||
log.debug(u'changeGlobalFromTab %s', themeName)
|
log.debug(u'changeGlobalFromTab %s', themeName)
|
||||||
@ -146,7 +144,8 @@ class ThemeManager(QtGui.QWidget):
|
|||||||
self.ThemeListWidget.item(count).text())
|
self.ThemeListWidget.item(count).text())
|
||||||
name = u'%s (%s)' % (self.global_theme, self.trUtf8('default'))
|
name = u'%s (%s)' % (self.global_theme, self.trUtf8('default'))
|
||||||
self.ThemeListWidget.item(count).setText(name)
|
self.ThemeListWidget.item(count).setText(name)
|
||||||
self.config.set_config(u'global theme', self.global_theme)
|
QtCore.QSettings().setValue(u'themes/global theme',
|
||||||
|
self.global_theme)
|
||||||
Receiver.send_message(u'theme_update_global', self.global_theme)
|
Receiver.send_message(u'theme_update_global', self.global_theme)
|
||||||
self.pushThemes()
|
self.pushThemes()
|
||||||
|
|
||||||
@ -167,8 +166,8 @@ class ThemeManager(QtGui.QWidget):
|
|||||||
self.amendThemeForm.exec_()
|
self.amendThemeForm.exec_()
|
||||||
|
|
||||||
def onDeleteTheme(self):
|
def onDeleteTheme(self):
|
||||||
self.global_theme = unicode(
|
self.global_theme = unicode(QtCore.QSettings().value(
|
||||||
self.config.get_config(u'global theme', u''))
|
u'themes/global theme', u'').toString())
|
||||||
item = self.ThemeListWidget.currentItem()
|
item = self.ThemeListWidget.currentItem()
|
||||||
if item:
|
if item:
|
||||||
theme = unicode(item.text())
|
theme = unicode(item.text())
|
||||||
@ -221,10 +220,10 @@ class ThemeManager(QtGui.QWidget):
|
|||||||
theme = unicode(item.data(QtCore.Qt.UserRole).toString())
|
theme = unicode(item.data(QtCore.Qt.UserRole).toString())
|
||||||
path = QtGui.QFileDialog.getExistingDirectory(self,
|
path = QtGui.QFileDialog.getExistingDirectory(self,
|
||||||
unicode(self.trUtf8('Save Theme - (%s)')) % theme,
|
unicode(self.trUtf8('Save Theme - (%s)')) % theme,
|
||||||
self.config.get_last_dir(1) )
|
SettingsManager.get_last_dir(u'themes', 1))
|
||||||
path = unicode(path)
|
path = unicode(path)
|
||||||
if path:
|
if path:
|
||||||
self.config.set_last_dir(path, 1)
|
SettingsManager.set_last_dir(u'themes', path, 1)
|
||||||
themePath = os.path.join(path, theme + u'.theme')
|
themePath = os.path.join(path, theme + u'.theme')
|
||||||
zip = None
|
zip = None
|
||||||
try:
|
try:
|
||||||
@ -243,11 +242,11 @@ class ThemeManager(QtGui.QWidget):
|
|||||||
def onImportTheme(self):
|
def onImportTheme(self):
|
||||||
files = QtGui.QFileDialog.getOpenFileNames(
|
files = QtGui.QFileDialog.getOpenFileNames(
|
||||||
self, self.trUtf8('Select Theme Import File'),
|
self, self.trUtf8('Select Theme Import File'),
|
||||||
self.config.get_last_dir(), u'Theme (*.*)')
|
SettingsManager.get_last_dir(u'themes'), u'Theme (*.*)')
|
||||||
log.info(u'New Themes %s', unicode(files))
|
log.info(u'New Themes %s', unicode(files))
|
||||||
if files:
|
if files:
|
||||||
for file in files:
|
for file in files:
|
||||||
self.config.set_last_dir(unicode(file))
|
SettingsManager.set_last_dir(u'themes', unicode(file))
|
||||||
self.unzipTheme(file, self.path)
|
self.unzipTheme(file, self.path)
|
||||||
self.loadThemes()
|
self.loadThemes()
|
||||||
|
|
||||||
|
@ -123,9 +123,11 @@ class ThemesTab(SettingsTab):
|
|||||||
'songs.'))
|
'songs.'))
|
||||||
|
|
||||||
def load(self):
|
def load(self):
|
||||||
self.theme_level = int(self.config.get_config(u'theme level',
|
settings = QtCore.QSettings()
|
||||||
ThemeLevel.Global))
|
self.theme_level = settings.value(
|
||||||
self.global_theme = self.config.get_config(u'global theme', u'')
|
u'themes/theme level', ThemeLevel.Global).toInt()[0]
|
||||||
|
self.global_theme = unicode(settings.value(
|
||||||
|
u'themes/global theme', u'').toString())
|
||||||
if self.theme_level == ThemeLevel.Global:
|
if self.theme_level == ThemeLevel.Global:
|
||||||
self.GlobalLevelRadioButton.setChecked(True)
|
self.GlobalLevelRadioButton.setChecked(True)
|
||||||
elif self.theme_level == ThemeLevel.Service:
|
elif self.theme_level == ThemeLevel.Service:
|
||||||
@ -134,8 +136,11 @@ class ThemesTab(SettingsTab):
|
|||||||
self.SongLevelRadioButton.setChecked(True)
|
self.SongLevelRadioButton.setChecked(True)
|
||||||
|
|
||||||
def save(self):
|
def save(self):
|
||||||
self.config.set_config(u'theme level', self.theme_level)
|
settings = QtCore.QSettings()
|
||||||
self.config.set_config(u'global theme',self.global_theme)
|
settings.setValue(u'themes/theme level',
|
||||||
|
QtCore.QVariant(self.theme_level))
|
||||||
|
settings.setValue(u'themes/global theme',
|
||||||
|
QtCore.QVariant(self.global_theme))
|
||||||
Receiver.send_message(u'theme_update_global', self.global_theme)
|
Receiver.send_message(u'theme_update_global', self.global_theme)
|
||||||
self.parent.RenderManager.set_global_theme(
|
self.parent.RenderManager.set_global_theme(
|
||||||
self.global_theme, self.theme_level)
|
self.global_theme, self.theme_level)
|
||||||
@ -169,7 +174,8 @@ class ThemesTab(SettingsTab):
|
|||||||
Called from ThemeManager when the Themes have changed
|
Called from ThemeManager when the Themes have changed
|
||||||
"""
|
"""
|
||||||
#reload as may have been triggered by the ThemeManager
|
#reload as may have been triggered by the ThemeManager
|
||||||
self.global_theme = self.config.get_config(u'global theme', u'')
|
self.global_theme = unicode(QtCore.QSettings().value(
|
||||||
|
u'themes/global theme', u'').toString())
|
||||||
self.DefaultComboBox.clear()
|
self.DefaultComboBox.clear()
|
||||||
for theme in theme_list:
|
for theme in theme_list:
|
||||||
self.DefaultComboBox.addItem(theme)
|
self.DefaultComboBox.addItem(theme)
|
||||||
|
@ -98,23 +98,37 @@ class AppLocation(object):
|
|||||||
plugin_path = os.path.split(openlp.__file__)[0]
|
plugin_path = os.path.split(openlp.__file__)[0]
|
||||||
return plugin_path
|
return plugin_path
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def get_data_path():
|
||||||
|
path = AppLocation.get_directory(AppLocation.DataDir)
|
||||||
|
if not os.path.exists(path):
|
||||||
|
os.makedirs(path)
|
||||||
|
return path
|
||||||
|
|
||||||
def check_latest_version(config, current_version):
|
@staticmethod
|
||||||
|
def get_section_data_path(section):
|
||||||
|
data_path = AppLocation.get_data_path()
|
||||||
|
path = os.path.join(data_path, section)
|
||||||
|
if not os.path.exists(path):
|
||||||
|
os.makedirs(path)
|
||||||
|
return path
|
||||||
|
|
||||||
|
|
||||||
|
def check_latest_version(current_version):
|
||||||
"""
|
"""
|
||||||
Check the latest version of OpenLP against the version file on the OpenLP
|
Check the latest version of OpenLP against the version file on the OpenLP
|
||||||
site.
|
site.
|
||||||
|
|
||||||
``config``
|
|
||||||
The OpenLP config object.
|
|
||||||
|
|
||||||
``current_version``
|
``current_version``
|
||||||
The current version of OpenLP.
|
The current version of OpenLP.
|
||||||
"""
|
"""
|
||||||
version_string = current_version[u'full']
|
version_string = current_version[u'full']
|
||||||
#set to prod in the distribution config file.
|
#set to prod in the distribution config file.
|
||||||
last_test = config.get_config(u'last version test', datetime.now().date())
|
last_test = unicode(QtCore.QSettings().value(u'general/last version test',
|
||||||
|
datetime.now().date()).toString())
|
||||||
this_test = unicode(datetime.now().date())
|
this_test = unicode(datetime.now().date())
|
||||||
config.set_config(u'last version test', this_test)
|
QtCore.QSettings().setValue(
|
||||||
|
u'general/last version test', QtCore.QVariant(this_test))
|
||||||
if last_test != this_test:
|
if last_test != this_test:
|
||||||
version_string = u''
|
version_string = u''
|
||||||
if current_version[u'build']:
|
if current_version[u'build']:
|
||||||
@ -168,8 +182,4 @@ def add_actions(target, actions):
|
|||||||
else:
|
else:
|
||||||
target.addAction(action)
|
target.addAction(action)
|
||||||
|
|
||||||
from registry import Registry
|
__all__ = [u'AppLocation', u'check_latest_version', u'add_actions']
|
||||||
from confighelper import ConfigHelper
|
|
||||||
|
|
||||||
__all__ = [u'Registry', u'ConfigHelper', u'AppLocation',
|
|
||||||
u'check_latest_version', u'add_actions']
|
|
||||||
|
@ -1,76 +0,0 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
|
|
||||||
|
|
||||||
###############################################################################
|
|
||||||
# OpenLP - Open Source Lyrics Projection #
|
|
||||||
# --------------------------------------------------------------------------- #
|
|
||||||
# Copyright (c) 2008-2010 Raoul Snyman #
|
|
||||||
# Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael #
|
|
||||||
# Gorven, Scott Guerrieri, Christian Richter, Maikel Stuivenberg, Martin #
|
|
||||||
# Thompson, Jon Tibble, Carsten Tinggaard #
|
|
||||||
# --------------------------------------------------------------------------- #
|
|
||||||
# This program is free software; you can redistribute it and/or modify it #
|
|
||||||
# under the terms of the GNU General Public License as published by the Free #
|
|
||||||
# Software Foundation; version 2 of the License. #
|
|
||||||
# #
|
|
||||||
# This program is distributed in the hope that it will be useful, but WITHOUT #
|
|
||||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
|
|
||||||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for #
|
|
||||||
# more details. #
|
|
||||||
# #
|
|
||||||
# You should have received a copy of the GNU General Public License along #
|
|
||||||
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
|
|
||||||
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
|
||||||
###############################################################################
|
|
||||||
|
|
||||||
import os
|
|
||||||
|
|
||||||
from openlp.core.utils import AppLocation
|
|
||||||
from openlp.core.utils.registry import Registry
|
|
||||||
|
|
||||||
class ConfigHelper(object):
|
|
||||||
"""
|
|
||||||
Utility Helper to allow classes to find directories in a standard manner.
|
|
||||||
"""
|
|
||||||
__registry__ = None
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def get_data_path():
|
|
||||||
path = AppLocation.get_directory(AppLocation.DataDir)
|
|
||||||
if not os.path.exists(path):
|
|
||||||
os.makedirs(path)
|
|
||||||
return path
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def get_config(section, key, default=None):
|
|
||||||
reg = ConfigHelper.get_registry()
|
|
||||||
if reg.has_value(section, key):
|
|
||||||
return reg.get_value(section, key, default)
|
|
||||||
else:
|
|
||||||
if default:
|
|
||||||
ConfigHelper.set_config(section, key, default)
|
|
||||||
return default
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def set_config(section, key, value):
|
|
||||||
reg = ConfigHelper.get_registry()
|
|
||||||
if not reg.has_section(section):
|
|
||||||
reg.create_section(section)
|
|
||||||
return reg.set_value(section, key, value)
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def delete_config(section, key):
|
|
||||||
reg = ConfigHelper.get_registry()
|
|
||||||
reg.delete_value(section, key)
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def get_registry():
|
|
||||||
"""
|
|
||||||
This static method loads the appropriate registry class based on the
|
|
||||||
current operating system, and returns an instantiation of that class.
|
|
||||||
"""
|
|
||||||
if ConfigHelper.__registry__ is None:
|
|
||||||
config_path = AppLocation.get_directory(AppLocation.ConfigDir)
|
|
||||||
ConfigHelper.__registry__ = Registry(config_path)
|
|
||||||
return ConfigHelper.__registry__
|
|
||||||
|
|
@ -1,134 +0,0 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
|
|
||||||
|
|
||||||
###############################################################################
|
|
||||||
# OpenLP - Open Source Lyrics Projection #
|
|
||||||
# --------------------------------------------------------------------------- #
|
|
||||||
# Copyright (c) 2008-2010 Raoul Snyman #
|
|
||||||
# Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael #
|
|
||||||
# Gorven, Scott Guerrieri, Christian Richter, Maikel Stuivenberg, Martin #
|
|
||||||
# Thompson, Jon Tibble, Carsten Tinggaard #
|
|
||||||
# --------------------------------------------------------------------------- #
|
|
||||||
# This program is free software; you can redistribute it and/or modify it #
|
|
||||||
# under the terms of the GNU General Public License as published by the Free #
|
|
||||||
# Software Foundation; version 2 of the License. #
|
|
||||||
# #
|
|
||||||
# This program is distributed in the hope that it will be useful, but WITHOUT #
|
|
||||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
|
|
||||||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for #
|
|
||||||
# more details. #
|
|
||||||
# #
|
|
||||||
# You should have received a copy of the GNU General Public License along #
|
|
||||||
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
|
|
||||||
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
|
||||||
###############################################################################
|
|
||||||
|
|
||||||
import os
|
|
||||||
|
|
||||||
from ConfigParser import SafeConfigParser
|
|
||||||
|
|
||||||
class Registry(object):
|
|
||||||
"""
|
|
||||||
The Registry class is a high-level class for working with a configuration
|
|
||||||
file.
|
|
||||||
"""
|
|
||||||
def __init__(self, dir):
|
|
||||||
self.config = SafeConfigParser()
|
|
||||||
self.file_name = os.path.join(dir, u'openlp.conf')
|
|
||||||
self._load()
|
|
||||||
|
|
||||||
def has_value(self, section, key):
|
|
||||||
"""
|
|
||||||
Check if a value exists.
|
|
||||||
"""
|
|
||||||
return self.config.has_option(section.encode('utf-8'),
|
|
||||||
key.encode('utf-8'))
|
|
||||||
|
|
||||||
def get_value(self, section, key, default=None):
|
|
||||||
"""
|
|
||||||
Get a single value from the registry.
|
|
||||||
"""
|
|
||||||
try:
|
|
||||||
if self.config.get(section.encode('utf-8'), key.encode('utf-8')):
|
|
||||||
return self.config.get(section.encode('utf-8'),
|
|
||||||
key.encode('utf-8')).decode('utf-8')
|
|
||||||
else:
|
|
||||||
return default
|
|
||||||
except:
|
|
||||||
return default
|
|
||||||
|
|
||||||
def set_value(self, section, key, value):
|
|
||||||
"""
|
|
||||||
Set a single value in the registry.
|
|
||||||
"""
|
|
||||||
try :
|
|
||||||
self.config.set(section.encode('utf-8'), key.encode('utf-8'),
|
|
||||||
unicode(value).encode('utf-8'))
|
|
||||||
return self._save()
|
|
||||||
except:
|
|
||||||
return False
|
|
||||||
|
|
||||||
def delete_value(self, section, key):
|
|
||||||
"""
|
|
||||||
Delete a single value from the registry.
|
|
||||||
"""
|
|
||||||
try:
|
|
||||||
self.config.remove_option(section.encode('utf-8'),
|
|
||||||
key.encode('utf-8'))
|
|
||||||
return self._save()
|
|
||||||
except:
|
|
||||||
return False
|
|
||||||
|
|
||||||
def has_section(self, section):
|
|
||||||
"""
|
|
||||||
Check if a section exists.
|
|
||||||
"""
|
|
||||||
return self.config.has_section(section.encode('utf-8'))
|
|
||||||
|
|
||||||
def create_section(self, section):
|
|
||||||
"""
|
|
||||||
Create a new section in the registry.
|
|
||||||
"""
|
|
||||||
try:
|
|
||||||
self.config.add_section(section.encode('utf-8'))
|
|
||||||
return self._save()
|
|
||||||
except:
|
|
||||||
return False
|
|
||||||
|
|
||||||
def delete_section(self, section):
|
|
||||||
"""
|
|
||||||
Delete a section (including all values).
|
|
||||||
"""
|
|
||||||
try:
|
|
||||||
self.config.remove_section(section.encode('utf-8'))
|
|
||||||
return self._save()
|
|
||||||
except:
|
|
||||||
return False
|
|
||||||
|
|
||||||
def _load(self):
|
|
||||||
if not os.path.isfile(self.file_name):
|
|
||||||
return False
|
|
||||||
file_handle = None
|
|
||||||
try:
|
|
||||||
file_handle = open(self.file_name, u'r')
|
|
||||||
self.config.readfp(file_handle)
|
|
||||||
return True
|
|
||||||
except:
|
|
||||||
return False
|
|
||||||
finally:
|
|
||||||
if file_handle:
|
|
||||||
file_handle.close()
|
|
||||||
|
|
||||||
def _save(self):
|
|
||||||
file_handle = None
|
|
||||||
try:
|
|
||||||
if not os.path.exists(os.path.dirname(self.file_name)):
|
|
||||||
os.makedirs(os.path.dirname(self.file_name))
|
|
||||||
file_handle = open(self.file_name, u'w')
|
|
||||||
self.config.write(file_handle)
|
|
||||||
return self._load()
|
|
||||||
except:
|
|
||||||
return False
|
|
||||||
finally:
|
|
||||||
if file_handle:
|
|
||||||
file_handle.close()
|
|
@ -41,7 +41,7 @@ class alertsPlugin(Plugin):
|
|||||||
self.weight = -3
|
self.weight = -3
|
||||||
self.icon = build_icon(u':/media/media_image.png')
|
self.icon = build_icon(u':/media/media_image.png')
|
||||||
self.alertsmanager = AlertsManager(self)
|
self.alertsmanager = AlertsManager(self)
|
||||||
self.manager = DBManager(self.config)
|
self.manager = DBManager()
|
||||||
self.alertForm = AlertForm(self.manager, self)
|
self.alertForm = AlertForm(self.manager, self)
|
||||||
self.status = PluginStatus.Active
|
self.status = PluginStatus.Active
|
||||||
|
|
||||||
@ -83,7 +83,8 @@ class alertsPlugin(Plugin):
|
|||||||
|
|
||||||
def togglealertsState(self):
|
def togglealertsState(self):
|
||||||
self.alertsActive = not self.alertsActive
|
self.alertsActive = not self.alertsActive
|
||||||
self.config.set_config(u'active', self.alertsActive)
|
QtCore.QSettings().setValue(
|
||||||
|
u'alerts/active', QtCore.QVariant(self.alertsActive))
|
||||||
|
|
||||||
def onAlertsTrigger(self):
|
def onAlertsTrigger(self):
|
||||||
self.alertForm.loadList()
|
self.alertForm.loadList()
|
||||||
|
@ -31,10 +31,10 @@ class AlertsTab(SettingsTab):
|
|||||||
"""
|
"""
|
||||||
AlertsTab is the alerts settings tab in the settings dialog.
|
AlertsTab is the alerts settings tab in the settings dialog.
|
||||||
"""
|
"""
|
||||||
def __init__(self, parent, section=None):
|
def __init__(self, parent):
|
||||||
self.parent = parent
|
self.parent = parent
|
||||||
self.manager = parent.manager
|
self.manager = parent.manager
|
||||||
SettingsTab.__init__(self, parent.name, section)
|
SettingsTab.__init__(self, parent.name)
|
||||||
|
|
||||||
def setupUi(self):
|
def setupUi(self):
|
||||||
self.setObjectName(u'AlertsTab')
|
self.setObjectName(u'AlertsTab')
|
||||||
@ -228,15 +228,16 @@ class AlertsTab(SettingsTab):
|
|||||||
self.updateDisplay()
|
self.updateDisplay()
|
||||||
|
|
||||||
def load(self):
|
def load(self):
|
||||||
self.timeout = int(self.config.get_config(u'timeout', 5))
|
settings = QtCore.QSettings()
|
||||||
self.font_color = unicode(
|
self.timeout = settings.value(u'alerts/timeout', 5).toInt()[0]
|
||||||
self.config.get_config(u'font color', u'#ffffff'))
|
self.font_color = unicode(settings.value(
|
||||||
self.font_size = int(self.config.get_config(u'font size', 40))
|
u'alerts/font color', u'#ffffff').toString())
|
||||||
self.bg_color = unicode(
|
self.font_size = settings.value(u'alerts/font size', 40).toInt()[0]
|
||||||
self.config.get_config(u'background color', u'#660000'))
|
self.bg_color = unicode(settings.value(
|
||||||
self.font_face = unicode(
|
u'alerts/background color', u'#660000').toString())
|
||||||
self.config.get_config(u'font face', QtGui.QFont().family()))
|
self.font_face = unicode(settings.value(
|
||||||
self.location = int(self.config.get_config(u'location', 0))
|
u'alerts/font face', QtGui.QFont().family()).toString())
|
||||||
|
self.location = settings.value(u'alerts/location', 0).toInt()[0]
|
||||||
self.FontSizeSpinBox.setValue(self.font_size)
|
self.FontSizeSpinBox.setValue(self.font_size)
|
||||||
self.TimeoutSpinBox.setValue(self.timeout)
|
self.TimeoutSpinBox.setValue(self.timeout)
|
||||||
self.FontColorButton.setStyleSheet(
|
self.FontColorButton.setStyleSheet(
|
||||||
@ -254,14 +255,17 @@ class AlertsTab(SettingsTab):
|
|||||||
self.DeleteButton.setEnabled(True)
|
self.DeleteButton.setEnabled(True)
|
||||||
|
|
||||||
def save(self):
|
def save(self):
|
||||||
|
settings = QtCore.QSettings()
|
||||||
self.font_face = self.FontComboBox.currentFont().family()
|
self.font_face = self.FontComboBox.currentFont().family()
|
||||||
self.config.set_config(u'background color', unicode(self.bg_color))
|
settings.setValue(
|
||||||
self.config.set_config(u'font color', unicode(self.font_color))
|
u'alerts/background color', QtCore.QVariant(self.bg_color))
|
||||||
self.config.set_config(u'font size', unicode(self.font_size))
|
settings.setValue(
|
||||||
self.config.set_config(u'font face', unicode(self.font_face))
|
u'alerts/font color', QtCore.QVariant(self.font_color))
|
||||||
self.config.set_config(u'timeout', unicode(self.timeout))
|
settings.setValue(u'alerts/font size', QtCore.QVariant(self.font_size))
|
||||||
self.config.set_config(u'location',
|
settings.setValue(u'alerts/font face', QtCore.QVariant(self.font_face))
|
||||||
unicode(self.LocationComboBox.currentIndex()))
|
settings.setValue(u'alerts/timeout', QtCore.QVariant(self.timeout))
|
||||||
|
settings.setValue(u'alerts/location',
|
||||||
|
QtCore.QVariant(self.LocationComboBox.currentIndex()))
|
||||||
|
|
||||||
def updateDisplay(self):
|
def updateDisplay(self):
|
||||||
font = QtGui.QFont()
|
font = QtGui.QFont()
|
||||||
|
@ -25,6 +25,9 @@
|
|||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
from PyQt4 import QtCore
|
||||||
|
|
||||||
|
from openlp.core.utils import AppLocation
|
||||||
from openlp.plugins.alerts.lib.models import init_models, metadata, AlertItem
|
from openlp.plugins.alerts.lib.models import init_models, metadata, AlertItem
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
@ -36,24 +39,25 @@ class DBManager():
|
|||||||
"""
|
"""
|
||||||
log.info(u'Alerts DB loaded')
|
log.info(u'Alerts DB loaded')
|
||||||
|
|
||||||
def __init__(self, config):
|
def __init__(self):
|
||||||
"""
|
"""
|
||||||
Creates the connection to the database, and creates the tables if they
|
Creates the connection to the database, and creates the tables if they
|
||||||
don't exist.
|
don't exist.
|
||||||
"""
|
"""
|
||||||
self.config = config
|
settings = QtCore.QSettings()
|
||||||
log.debug(u'Alerts Initialising')
|
log.debug(u'Alerts Initialising')
|
||||||
self.db_url = u''
|
self.db_url = u''
|
||||||
db_type = self.config.get_config(u'db type', u'sqlite')
|
db_type = unicode(
|
||||||
|
settings.value(u'alerts/db type', u'sqlite').toString())
|
||||||
if db_type == u'sqlite':
|
if db_type == u'sqlite':
|
||||||
self.db_url = u'sqlite:///%s/alerts.sqlite' % \
|
self.db_url = u'sqlite:///%s/alerts.sqlite' % \
|
||||||
self.config.get_data_path()
|
AppLocation.get_section_data_path(u'alerts')
|
||||||
else:
|
else:
|
||||||
self.db_url = u'%s://%s:%s@%s/%s' % \
|
self.db_url = u'%s://%s:%s@%s/%s' % \
|
||||||
(db_type, self.config.get_config(u'db username'),
|
(db_type, settings.value(u'alerts/db username'),
|
||||||
self.config.get_config(u'db password'),
|
settings.value(u'alerts/db password'),
|
||||||
self.config.get_config(u'db hostname'),
|
settings.value(u'alerts/db hostname'),
|
||||||
self.config.get_config(u'db database'))
|
settings.value(u'alerts/db database'))
|
||||||
self.session = init_models(self.db_url)
|
self.session = init_models(self.db_url)
|
||||||
metadata.create_all(checkfirst=True)
|
metadata.create_all(checkfirst=True)
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ class BiblePlugin(Plugin):
|
|||||||
def initialise(self):
|
def initialise(self):
|
||||||
log.info(u'bibles Initialising')
|
log.info(u'bibles Initialising')
|
||||||
if self.manager is None:
|
if self.manager is None:
|
||||||
self.manager = BibleManager(self, self.config)
|
self.manager = BibleManager(self)
|
||||||
Plugin.initialise(self)
|
Plugin.initialise(self)
|
||||||
self.insert_toolbox_item()
|
self.insert_toolbox_item()
|
||||||
self.ImportBibleItem.setVisible(True)
|
self.ImportBibleItem.setVisible(True)
|
||||||
|
@ -31,7 +31,7 @@ import os.path
|
|||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
|
|
||||||
from bibleimportwizard import Ui_BibleImportWizard
|
from bibleimportwizard import Ui_BibleImportWizard
|
||||||
from openlp.core.lib import Receiver
|
from openlp.core.lib import Receiver, SettingsManager
|
||||||
from openlp.core.utils import AppLocation, variant_to_unicode
|
from openlp.core.utils import AppLocation, variant_to_unicode
|
||||||
from openlp.plugins.bibles.lib.manager import BibleFormat
|
from openlp.plugins.bibles.lib.manager import BibleFormat
|
||||||
|
|
||||||
@ -59,16 +59,13 @@ class ImportWizardForm(QtGui.QWizard, Ui_BibleImportWizard):
|
|||||||
"""
|
"""
|
||||||
log.info(u'BibleImportForm loaded')
|
log.info(u'BibleImportForm loaded')
|
||||||
|
|
||||||
def __init__(self, parent, config, manager, bibleplugin):
|
def __init__(self, parent, manager, bibleplugin):
|
||||||
"""
|
"""
|
||||||
Instantiate the wizard, and run any extra setup we need to.
|
Instantiate the wizard, and run any extra setup we need to.
|
||||||
|
|
||||||
``parent``
|
``parent``
|
||||||
The QWidget-derived parent of the wizard.
|
The QWidget-derived parent of the wizard.
|
||||||
|
|
||||||
``config``
|
|
||||||
The configuration object for storing and retrieving settings.
|
|
||||||
|
|
||||||
``manager``
|
``manager``
|
||||||
The Bible manager.
|
The Bible manager.
|
||||||
|
|
||||||
@ -81,7 +78,6 @@ class ImportWizardForm(QtGui.QWizard, Ui_BibleImportWizard):
|
|||||||
self.finishButton = self.button(QtGui.QWizard.FinishButton)
|
self.finishButton = self.button(QtGui.QWizard.FinishButton)
|
||||||
self.cancelButton = self.button(QtGui.QWizard.CancelButton)
|
self.cancelButton = self.button(QtGui.QWizard.CancelButton)
|
||||||
self.manager = manager
|
self.manager = manager
|
||||||
self.config = config
|
|
||||||
self.bibleplugin = bibleplugin
|
self.bibleplugin = bibleplugin
|
||||||
self.manager.set_process_dialog(self)
|
self.manager.set_process_dialog(self)
|
||||||
self.web_bible_list = {}
|
self.web_bible_list = {}
|
||||||
@ -277,6 +273,7 @@ class ImportWizardForm(QtGui.QWizard, Ui_BibleImportWizard):
|
|||||||
u'license_permission', self.PermissionEdit)
|
u'license_permission', self.PermissionEdit)
|
||||||
|
|
||||||
def setDefaults(self):
|
def setDefaults(self):
|
||||||
|
settings = QtCore.QSettings()
|
||||||
self.setField(u'source_format', QtCore.QVariant(0))
|
self.setField(u'source_format', QtCore.QVariant(0))
|
||||||
self.setField(u'osis_location', QtCore.QVariant(''))
|
self.setField(u'osis_location', QtCore.QVariant(''))
|
||||||
self.setField(u'csv_booksfile', QtCore.QVariant(''))
|
self.setField(u'csv_booksfile', QtCore.QVariant(''))
|
||||||
@ -285,14 +282,15 @@ class ImportWizardForm(QtGui.QWizard, Ui_BibleImportWizard):
|
|||||||
self.setField(u'web_location', QtCore.QVariant(WebDownload.Crosswalk))
|
self.setField(u'web_location', QtCore.QVariant(WebDownload.Crosswalk))
|
||||||
self.setField(u'web_biblename', QtCore.QVariant(self.BibleComboBox))
|
self.setField(u'web_biblename', QtCore.QVariant(self.BibleComboBox))
|
||||||
self.setField(u'proxy_server',
|
self.setField(u'proxy_server',
|
||||||
QtCore.QVariant(self.config.get_config(u'proxy address', '')))
|
settings.value(u'bibles/proxy address', u''))
|
||||||
self.setField(u'proxy_username',
|
self.setField(u'proxy_username',
|
||||||
QtCore.QVariant(self.config.get_config(u'proxy username','')))
|
settings.value(u'bibles/proxy username', u''))
|
||||||
self.setField(u'proxy_password',
|
self.setField(u'proxy_password',
|
||||||
QtCore.QVariant(self.config.get_config(u'proxy password','')))
|
settings.value(u'proxy password', u''))
|
||||||
self.setField(u'license_version', QtCore.QVariant(self.VersionNameEdit))
|
self.setField(u'license_version', QtCore.QVariant(self.VersionNameEdit))
|
||||||
self.setField(u'license_copyright', QtCore.QVariant(self.CopyrightEdit))
|
self.setField(u'license_copyright', QtCore.QVariant(self.CopyrightEdit))
|
||||||
self.setField(u'license_permission', QtCore.QVariant(self.PermissionEdit))
|
self.setField(u'license_permission',
|
||||||
|
QtCore.QVariant(self.PermissionEdit))
|
||||||
self.onLocationComboBoxChanged(WebDownload.Crosswalk)
|
self.onLocationComboBoxChanged(WebDownload.Crosswalk)
|
||||||
|
|
||||||
def loadWebBibles(self):
|
def loadWebBibles(self):
|
||||||
@ -302,10 +300,10 @@ class ImportWizardForm(QtGui.QWizard, Ui_BibleImportWizard):
|
|||||||
#Load and store Crosswalk Bibles
|
#Load and store Crosswalk Bibles
|
||||||
filepath = AppLocation.get_directory(AppLocation.PluginsDir)
|
filepath = AppLocation.get_directory(AppLocation.PluginsDir)
|
||||||
filepath = os.path.join(filepath, u'bibles', u'resources')
|
filepath = os.path.join(filepath, u'bibles', u'resources')
|
||||||
fbibles = None
|
|
||||||
try:
|
try:
|
||||||
self.web_bible_list[WebDownload.Crosswalk] = {}
|
self.web_bible_list[WebDownload.Crosswalk] = {}
|
||||||
books_file = open(os.path.join(filepath, u'crosswalkbooks.csv'), 'r')
|
books_file = open(
|
||||||
|
os.path.join(filepath, u'crosswalkbooks.csv'), 'r')
|
||||||
dialect = csv.Sniffer().sniff(books_file.read(1024))
|
dialect = csv.Sniffer().sniff(books_file.read(1024))
|
||||||
books_file.seek(0)
|
books_file.seek(0)
|
||||||
books_reader = csv.reader(books_file, dialect)
|
books_reader = csv.reader(books_file, dialect)
|
||||||
@ -345,10 +343,10 @@ class ImportWizardForm(QtGui.QWizard, Ui_BibleImportWizard):
|
|||||||
|
|
||||||
def getFileName(self, title, editbox):
|
def getFileName(self, title, editbox):
|
||||||
filename = QtGui.QFileDialog.getOpenFileName(self, title,
|
filename = QtGui.QFileDialog.getOpenFileName(self, title,
|
||||||
self.config.get_last_dir(1))
|
SettingsManager.get_last_dir(bibles, 1))
|
||||||
if filename:
|
if filename:
|
||||||
editbox.setText(filename)
|
editbox.setText(filename)
|
||||||
self.config.set_last_dir(filename, 1)
|
SettingsManager.set_last_dir(bibles, filename, 1)
|
||||||
|
|
||||||
def incrementProgressBar(self, status_text):
|
def incrementProgressBar(self, status_text):
|
||||||
log.debug(u'IncrementBar %s', status_text)
|
log.debug(u'IncrementBar %s', status_text)
|
||||||
@ -368,7 +366,8 @@ class ImportWizardForm(QtGui.QWizard, Ui_BibleImportWizard):
|
|||||||
bible_type = self.field(u'source_format').toInt()[0]
|
bible_type = self.field(u'source_format').toInt()[0]
|
||||||
license_version = variant_to_unicode(self.field(u'license_version'))
|
license_version = variant_to_unicode(self.field(u'license_version'))
|
||||||
license_copyright = variant_to_unicode(self.field(u'license_copyright'))
|
license_copyright = variant_to_unicode(self.field(u'license_copyright'))
|
||||||
license_permission = variant_to_unicode(self.field(u'license_permission'))
|
license_permission = variant_to_unicode(
|
||||||
|
self.field(u'license_permission'))
|
||||||
importer = None
|
importer = None
|
||||||
if bible_type == BibleFormat.OSIS:
|
if bible_type == BibleFormat.OSIS:
|
||||||
# Import an OSIS bible
|
# Import an OSIS bible
|
||||||
|
@ -27,7 +27,7 @@ import logging
|
|||||||
|
|
||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
|
|
||||||
from openlp.core.lib import str_to_bool, Receiver, SettingsTab
|
from openlp.core.lib import Receiver, SettingsTab
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -37,11 +37,11 @@ class BiblesTab(SettingsTab):
|
|||||||
"""
|
"""
|
||||||
log.info(u'Bible Tab loaded')
|
log.info(u'Bible Tab loaded')
|
||||||
|
|
||||||
def __init__(self, title, section=None):
|
def __init__(self, title):
|
||||||
self.paragraph_style = True
|
self.paragraph_style = True
|
||||||
self.show_new_chapters = False
|
self.show_new_chapters = False
|
||||||
self.display_style = 0
|
self.display_style = 0
|
||||||
SettingsTab.__init__(self, title, section)
|
SettingsTab.__init__(self, title)
|
||||||
|
|
||||||
def setupUi(self):
|
def setupUi(self):
|
||||||
self.setObjectName(u'BiblesTab')
|
self.setObjectName(u'BiblesTab')
|
||||||
@ -161,8 +161,8 @@ class BiblesTab(SettingsTab):
|
|||||||
self.DisplayStyleComboBox.setItemText(1, self.trUtf8('( and )'))
|
self.DisplayStyleComboBox.setItemText(1, self.trUtf8('( and )'))
|
||||||
self.DisplayStyleComboBox.setItemText(2, self.trUtf8('{ and }'))
|
self.DisplayStyleComboBox.setItemText(2, self.trUtf8('{ and }'))
|
||||||
self.DisplayStyleComboBox.setItemText(3, self.trUtf8('[ and ]'))
|
self.DisplayStyleComboBox.setItemText(3, self.trUtf8('[ and ]'))
|
||||||
self.ChangeNoteLabel.setText(
|
self.ChangeNoteLabel.setText(self.trUtf8(
|
||||||
self.trUtf8('Note:\nChanges don\'t affect verses already in the service'))
|
'Note:\nChanges don\'t affect verses already in the service'))
|
||||||
self.BibleDualCheckBox.setText(self.trUtf8('Display Dual Bible Verses'))
|
self.BibleDualCheckBox.setText(self.trUtf8('Display Dual Bible Verses'))
|
||||||
|
|
||||||
def onBibleThemeComboBoxChanged(self):
|
def onBibleThemeComboBoxChanged(self):
|
||||||
@ -187,29 +187,33 @@ class BiblesTab(SettingsTab):
|
|||||||
self.duel_bibles = True
|
self.duel_bibles = True
|
||||||
|
|
||||||
def load(self):
|
def load(self):
|
||||||
self.show_new_chapters = str_to_bool(
|
settings = QtCore.QSettings()
|
||||||
self.config.get_config(u'display new chapter', u'False'))
|
self.show_new_chapters = settings.value(
|
||||||
self.display_style = int(
|
u'bibles/display new chapter', False).toBool()
|
||||||
self.config.get_config(u'display brackets', u'0'))
|
self.display_style = settings.value(
|
||||||
self.layout_style = int(
|
u'bibles/display brackets', 0).toInt()[0]
|
||||||
self.config.get_config(u'verse layout style', u'0'))
|
self.layout_style = settings.value(
|
||||||
self.bible_theme = self.config.get_config(u'bible theme', u'0')
|
u'bibles/verse layout style', 0).toInt()[0]
|
||||||
self.duel_bibles = str_to_bool(
|
self.bible_theme = unicode(
|
||||||
self.config.get_config(u'dual bibles', u'True'))
|
settings.value(u'bibles/bible theme', u'').toString())
|
||||||
|
self.duel_bibles = settings.value(u'bibles/dual bibles', True).toBool()
|
||||||
self.NewChaptersCheckBox.setChecked(self.show_new_chapters)
|
self.NewChaptersCheckBox.setChecked(self.show_new_chapters)
|
||||||
self.DisplayStyleComboBox.setCurrentIndex(self.display_style)
|
self.DisplayStyleComboBox.setCurrentIndex(self.display_style)
|
||||||
self.LayoutStyleComboBox.setCurrentIndex(self.layout_style)
|
self.LayoutStyleComboBox.setCurrentIndex(self.layout_style)
|
||||||
self.BibleDualCheckBox.setChecked(self.duel_bibles)
|
self.BibleDualCheckBox.setChecked(self.duel_bibles)
|
||||||
|
|
||||||
def save(self):
|
def save(self):
|
||||||
self.config.set_config(
|
settings = QtCore.QSettings()
|
||||||
u'display new chapter', unicode(self.show_new_chapters))
|
settings.setValue(u'bibles/display new chapter',
|
||||||
self.config.set_config(
|
QtCore.QVariant(self.show_new_chapters))
|
||||||
u'display brackets', unicode(self.display_style))
|
settings.setValue(u'bibles/display brackets',
|
||||||
self.config.set_config(
|
QtCore.QVariant(self.display_style))
|
||||||
u'verse layout style', unicode(self.layout_style))
|
settings.setValue(u'bibles/verse layout style',
|
||||||
self.config.set_config(u'dual bibles', unicode(self.duel_bibles))
|
QtCore.QVariant(self.layout_style))
|
||||||
self.config.set_config(u'bible theme', unicode(self.bible_theme))
|
settings.setValue(u'bibles/dual bibles',
|
||||||
|
QtCore.QVariant(self.duel_bibles))
|
||||||
|
settings.setValue(u'bibles/bible theme',
|
||||||
|
QtCore.QVariant(self.bible_theme))
|
||||||
|
|
||||||
def updateThemeList(self, theme_list):
|
def updateThemeList(self, theme_list):
|
||||||
"""
|
"""
|
||||||
|
@ -56,20 +56,14 @@ class BibleDB(QtCore.QObject):
|
|||||||
``name``
|
``name``
|
||||||
The name of the database. This is also used as the file name for
|
The name of the database. This is also used as the file name for
|
||||||
SQLite databases.
|
SQLite databases.
|
||||||
|
|
||||||
``config``
|
|
||||||
The configuration object, passed in from the plugin.
|
|
||||||
"""
|
"""
|
||||||
log.info(u'BibleDB loaded')
|
log.info(u'BibleDB loaded')
|
||||||
QtCore.QObject.__init__(self)
|
QtCore.QObject.__init__(self)
|
||||||
if u'path' not in kwargs:
|
if u'path' not in kwargs:
|
||||||
raise KeyError(u'Missing keyword argument "path".')
|
raise KeyError(u'Missing keyword argument "path".')
|
||||||
if u'config' not in kwargs:
|
|
||||||
raise KeyError(u'Missing keyword argument "config".')
|
|
||||||
if u'name' not in kwargs and u'file' not in kwargs:
|
if u'name' not in kwargs and u'file' not in kwargs:
|
||||||
raise KeyError(u'Missing keyword argument "name" or "file".')
|
raise KeyError(u'Missing keyword argument "name" or "file".')
|
||||||
self.stop_import_flag = False
|
self.stop_import_flag = False
|
||||||
self.config = kwargs[u'config']
|
|
||||||
if u'name' in kwargs:
|
if u'name' in kwargs:
|
||||||
self.name = kwargs[u'name']
|
self.name = kwargs[u'name']
|
||||||
if not isinstance(self.name, unicode):
|
if not isinstance(self.name, unicode):
|
||||||
@ -79,16 +73,18 @@ class BibleDB(QtCore.QObject):
|
|||||||
self.file = kwargs[u'file']
|
self.file = kwargs[u'file']
|
||||||
self.db_file = os.path.join(kwargs[u'path'], self.file)
|
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)
|
log.debug(u'Load bible %s on path %s', self.file, self.db_file)
|
||||||
db_type = self.config.get_config(u'db type', u'sqlite')
|
settings = QtCore.QSettings()
|
||||||
|
db_type = unicode(
|
||||||
|
settings.value(u'bibles/db type', u'sqlite').toString())
|
||||||
db_url = u''
|
db_url = u''
|
||||||
if db_type == u'sqlite':
|
if db_type == u'sqlite':
|
||||||
db_url = u'sqlite:///' + self.db_file
|
db_url = u'sqlite:///' + self.db_file
|
||||||
else:
|
else:
|
||||||
db_url = u'%s://%s:%s@%s/%s' % \
|
db_url = u'%s://%s:%s@%s/%s' % \
|
||||||
(db_type, self.config.get_config(u'db username'),
|
(db_type, unicode(settings.value(u'bibles/db username')),
|
||||||
self.config.get_config(u'db password'),
|
unicode(settings.value(u'bibles/db password')),
|
||||||
self.config.get_config(u'db hostname'),
|
unicode(settings.value(u'bibles/db hostname')),
|
||||||
self.config.get_config(u'db database'))
|
unicode(settings.value(u'bibles/db database')))
|
||||||
self.metadata, self.session = init_models(db_url)
|
self.metadata, self.session = init_models(db_url)
|
||||||
self.metadata.create_all(checkfirst=True)
|
self.metadata.create_all(checkfirst=True)
|
||||||
if u'file' in kwargs:
|
if u'file' in kwargs:
|
||||||
|
@ -25,6 +25,11 @@
|
|||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
from PyQt4 import QtCore
|
||||||
|
|
||||||
|
from openlp.core.lib import SettingsManager
|
||||||
|
from openlp.core.utils import AppLocation
|
||||||
|
|
||||||
from common import parse_reference
|
from common import parse_reference
|
||||||
from opensong import OpenSongBible
|
from opensong import OpenSongBible
|
||||||
from osis import OSISBible
|
from osis import OSISBible
|
||||||
@ -94,24 +99,21 @@ class BibleManager(object):
|
|||||||
"""
|
"""
|
||||||
log.info(u'Bible manager loaded')
|
log.info(u'Bible manager loaded')
|
||||||
|
|
||||||
def __init__(self, parent, config):
|
def __init__(self, parent):
|
||||||
"""
|
"""
|
||||||
Finds all the bibles defined for the system and creates an interface
|
Finds all the bibles defined for the system and creates an interface
|
||||||
object for each bible containing connection information. Throws
|
object for each bible containing connection information. Throws
|
||||||
Exception if no Bibles are found.
|
Exception if no Bibles are found.
|
||||||
|
|
||||||
Init confirms the bible exists and stores the database path.
|
Init confirms the bible exists and stores the database path.
|
||||||
|
|
||||||
``config``
|
|
||||||
The plugin's configuration object.
|
|
||||||
"""
|
"""
|
||||||
log.debug(u'Bible Initialising')
|
log.debug(u'Bible Initialising')
|
||||||
self.config = config
|
|
||||||
self.parent = parent
|
self.parent = parent
|
||||||
self.web = u'Web'
|
self.web = u'Web'
|
||||||
self.db_cache = None
|
self.db_cache = None
|
||||||
self.path = self.config.get_data_path()
|
self.path = AppLocation.get_section_data_path(u'bibles')
|
||||||
self.proxy_name = self.config.get_config(u'proxy name')
|
self.proxy_name = unicode(
|
||||||
|
QtCore.QSettings().value(u'bibles/proxy name', u'').toString())
|
||||||
self.suffix = u'sqlite'
|
self.suffix = u'sqlite'
|
||||||
self.import_wizard = None
|
self.import_wizard = None
|
||||||
self.reload_bibles()
|
self.reload_bibles()
|
||||||
@ -124,12 +126,11 @@ class BibleManager(object):
|
|||||||
BibleDB class.
|
BibleDB class.
|
||||||
"""
|
"""
|
||||||
log.debug(u'Reload bibles')
|
log.debug(u'Reload bibles')
|
||||||
files = self.config.get_files(self.suffix)
|
files = SettingsManager.get_files(self.suffix)
|
||||||
log.debug(u'Bible Files %s', files)
|
log.debug(u'Bible Files %s', files)
|
||||||
self.db_cache = {}
|
self.db_cache = {}
|
||||||
for filename in files:
|
for filename in files:
|
||||||
bible = BibleDB(self.parent, path=self.path, file=filename,
|
bible = BibleDB(self.parent, path=self.path, file=filename)
|
||||||
config=self.config)
|
|
||||||
name = bible.get_name()
|
name = bible.get_name()
|
||||||
log.debug(u'Bible Name: "%s"', name)
|
log.debug(u'Bible Name: "%s"', name)
|
||||||
self.db_cache[name] = bible
|
self.db_cache[name] = bible
|
||||||
@ -139,8 +140,8 @@ class BibleManager(object):
|
|||||||
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')
|
meta_proxy = self.db_cache[name].get_meta(u'proxy url')
|
||||||
web_bible = HTTPBible(self.parent, path=self.path,
|
web_bible = HTTPBible(self.parent, path=self.path,
|
||||||
file=filename, config=self.config,
|
file=filename, download_source=source.value,
|
||||||
download_source=source.value, download_name=download_name)
|
download_name=download_name)
|
||||||
if meta_proxy:
|
if meta_proxy:
|
||||||
web_bible.set_proxy_server(meta_proxy.value)
|
web_bible.set_proxy_server(meta_proxy.value)
|
||||||
self.db_cache[name] = web_bible
|
self.db_cache[name] = web_bible
|
||||||
@ -167,7 +168,6 @@ class BibleManager(object):
|
|||||||
"""
|
"""
|
||||||
class_ = BibleFormat.get_class(type)
|
class_ = BibleFormat.get_class(type)
|
||||||
kwargs['path'] = self.path
|
kwargs['path'] = self.path
|
||||||
kwargs['config'] = self.config
|
|
||||||
importer = class_(self.parent, **kwargs)
|
importer = class_(self.parent, **kwargs)
|
||||||
name = importer.register(self.import_wizard)
|
name = importer.register(self.import_wizard)
|
||||||
self.db_cache[name] = importer
|
self.db_cache[name] = importer
|
||||||
@ -260,4 +260,3 @@ class BibleManager(object):
|
|||||||
if bible == name:
|
if bible == name:
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@ -28,8 +28,8 @@ import time
|
|||||||
|
|
||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
|
|
||||||
from openlp.core.lib import MediaManagerItem, Receiver, str_to_bool, \
|
from openlp.core.lib import MediaManagerItem, Receiver, BaseListWithDnD, \
|
||||||
BaseListWithDnD, ItemCapabilities
|
ItemCapabilities
|
||||||
from openlp.plugins.bibles.forms import ImportWizardForm
|
from openlp.plugins.bibles.forms import ImportWizardForm
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
@ -276,8 +276,7 @@ class BibleMediaItem(MediaManagerItem):
|
|||||||
self.SearchProgress.setObjectName(u'SearchProgress')
|
self.SearchProgress.setObjectName(u'SearchProgress')
|
||||||
|
|
||||||
def configUpdated(self):
|
def configUpdated(self):
|
||||||
if str_to_bool(
|
if QtCore.QSettings().value(u'bibles/dual bibles', False).toBool():
|
||||||
self.parent.config.get_config(u'dual bibles', u'False')):
|
|
||||||
self.AdvancedSecondBibleLabel.setVisible(True)
|
self.AdvancedSecondBibleLabel.setVisible(True)
|
||||||
self.AdvancedSecondBibleComboBox.setVisible(True)
|
self.AdvancedSecondBibleComboBox.setVisible(True)
|
||||||
self.QuickSecondVersionLabel.setVisible(True)
|
self.QuickSecondVersionLabel.setVisible(True)
|
||||||
@ -381,7 +380,7 @@ class BibleMediaItem(MediaManagerItem):
|
|||||||
self.AdvancedBookComboBox.itemData(item).toInt()[0])
|
self.AdvancedBookComboBox.itemData(item).toInt()[0])
|
||||||
|
|
||||||
def onImportClick(self):
|
def onImportClick(self):
|
||||||
self.bibleimportform = ImportWizardForm(self, self.parent.config,
|
self.bibleimportform = ImportWizardForm(self,
|
||||||
self.parent.manager, self.parent)
|
self.parent.manager, self.parent)
|
||||||
self.bibleimportform.exec_()
|
self.bibleimportform.exec_()
|
||||||
self.reloadBibles()
|
self.reloadBibles()
|
||||||
|
@ -98,7 +98,8 @@ class OSISBible(BibleDB):
|
|||||||
Loads a Bible from file.
|
Loads a Bible from file.
|
||||||
"""
|
"""
|
||||||
log.debug(u'Starting OSIS import from "%s"' % self.filename)
|
log.debug(u'Starting OSIS import from "%s"' % self.filename)
|
||||||
self.wizard.incrementProgressBar(u'Detecting encoding (this may take a few minutes)...')
|
self.wizard.incrementProgressBar(
|
||||||
|
u'Detecting encoding (this may take a few minutes)...')
|
||||||
detect_file = None
|
detect_file = None
|
||||||
try:
|
try:
|
||||||
detect_file = open(self.filename, u'r')
|
detect_file = open(self.filename, u'r')
|
||||||
|
@ -45,7 +45,7 @@ class CustomPlugin(Plugin):
|
|||||||
def __init__(self, plugin_helpers):
|
def __init__(self, plugin_helpers):
|
||||||
Plugin.__init__(self, u'Custom', u'1.9.1', plugin_helpers)
|
Plugin.__init__(self, u'Custom', u'1.9.1', plugin_helpers)
|
||||||
self.weight = -5
|
self.weight = -5
|
||||||
self.custommanager = CustomManager(self.config)
|
self.custommanager = CustomManager()
|
||||||
self.edit_custom_form = EditCustomForm(self.custommanager)
|
self.edit_custom_form = EditCustomForm(self.custommanager)
|
||||||
self.icon = build_icon(u':/media/media_custom.png')
|
self.icon = build_icon(u':/media/media_custom.png')
|
||||||
self.status = PluginStatus.Active
|
self.status = PluginStatus.Active
|
||||||
|
@ -25,14 +25,14 @@
|
|||||||
|
|
||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
|
|
||||||
from openlp.core.lib import SettingsTab, str_to_bool
|
from openlp.core.lib import SettingsTab
|
||||||
|
|
||||||
class CustomTab(SettingsTab):
|
class CustomTab(SettingsTab):
|
||||||
"""
|
"""
|
||||||
CustomTab is the Custom settings tab in the settings dialog.
|
CustomTab is the Custom settings tab in the settings dialog.
|
||||||
"""
|
"""
|
||||||
def __init__(self, title, section=None):
|
def __init__(self, title):
|
||||||
SettingsTab.__init__(self, title, section)
|
SettingsTab.__init__(self, title)
|
||||||
|
|
||||||
def setupUi(self):
|
def setupUi(self):
|
||||||
self.setObjectName(u'CustomTab')
|
self.setObjectName(u'CustomTab')
|
||||||
@ -66,9 +66,10 @@ class CustomTab(SettingsTab):
|
|||||||
self.displayFooter = True
|
self.displayFooter = True
|
||||||
|
|
||||||
def load(self):
|
def load(self):
|
||||||
self.displayFooter = str_to_bool(
|
self.displayFooter = QtCore.QSettings().value(
|
||||||
self.config.get_config(u'display footer', True))
|
u'custom/display footer', True).toBool()
|
||||||
self.DisplayFooterCheckBox.setChecked(self.displayFooter)
|
self.DisplayFooterCheckBox.setChecked(self.displayFooter)
|
||||||
|
|
||||||
def save(self):
|
def save(self):
|
||||||
self.config.set_config(u'display footer', unicode(self.displayFooter))
|
QtCore.QSettings().setValue(
|
||||||
|
u'custom/display footer', QtCore.QVariant(self.displayFooter))
|
||||||
|
@ -25,6 +25,9 @@
|
|||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
from PyQt4 import QtCore
|
||||||
|
|
||||||
|
from openlp.core.utils import AppLocation
|
||||||
from openlp.plugins.custom.lib.models import init_models, metadata, CustomSlide
|
from openlp.plugins.custom.lib.models import init_models, metadata, CustomSlide
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
@ -36,24 +39,25 @@ class CustomManager():
|
|||||||
"""
|
"""
|
||||||
log.info(u'Custom manager loaded')
|
log.info(u'Custom manager loaded')
|
||||||
|
|
||||||
def __init__(self, config):
|
def __init__(self):
|
||||||
"""
|
"""
|
||||||
Creates the connection to the database, and creates the tables if they
|
Creates the connection to the database, and creates the tables if they
|
||||||
don't exist.
|
don't exist.
|
||||||
"""
|
"""
|
||||||
self.config = config
|
|
||||||
log.debug(u'Custom Initialising')
|
log.debug(u'Custom Initialising')
|
||||||
|
settings = QtCore.QSettings()
|
||||||
self.db_url = u''
|
self.db_url = u''
|
||||||
db_type = self.config.get_config(u'db type', u'sqlite')
|
db_type = unicode(
|
||||||
|
settings.value(u'custom/db type', u'sqlite').toString())
|
||||||
if db_type == u'sqlite':
|
if db_type == u'sqlite':
|
||||||
self.db_url = u'sqlite:///%s/custom.sqlite' % \
|
self.db_url = u'sqlite:///%s/custom.sqlite' % \
|
||||||
self.config.get_data_path()
|
AppLocation.get_section_data_path(u'custom')
|
||||||
else:
|
else:
|
||||||
self.db_url = u'%s://%s:%s@%s/%s' % \
|
self.db_url = u'%s://%s:%s@%s/%s' % (db_type,
|
||||||
(db_type, self.config.get_config(u'db username'),
|
unicode(settings.value(u'custom/db username')),
|
||||||
self.config.get_config(u'db password'),
|
unicode(settings.value(u'custom/db password')),
|
||||||
self.config.get_config(u'db hostname'),
|
unicode(settings.value(u'custom/db hostname')),
|
||||||
self.config.get_config(u'db database'))
|
unicode(settings.value(u'custom/db database')))
|
||||||
self.session = init_models(self.db_url)
|
self.session = init_models(self.db_url)
|
||||||
metadata.create_all(checkfirst=True)
|
metadata.create_all(checkfirst=True)
|
||||||
|
|
||||||
@ -107,4 +111,5 @@ class CustomManager():
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
def get_customs_for_theme(self, theme):
|
def get_customs_for_theme(self, theme):
|
||||||
return self.session.query(CustomSlide).filter(CustomSlide.theme_name == theme).all()
|
return self.session.query(
|
||||||
|
CustomSlide).filter(CustomSlide.theme_name == theme).all()
|
||||||
|
@ -27,8 +27,8 @@ import logging
|
|||||||
|
|
||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
|
|
||||||
from openlp.core.lib import MediaManagerItem, SongXMLParser, BaseListWithDnD,\
|
from openlp.core.lib import MediaManagerItem, SongXMLParser, BaseListWithDnD, \
|
||||||
Receiver, str_to_bool, ItemCapabilities
|
Receiver, ItemCapabilities
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -164,7 +164,7 @@ class CustomMediaItem(MediaManagerItem):
|
|||||||
service_item.title = title
|
service_item.title = title
|
||||||
for slide in raw_slides:
|
for slide in raw_slides:
|
||||||
service_item.add_from_text(slide[:30], slide)
|
service_item.add_from_text(slide[:30], slide)
|
||||||
if str_to_bool(self.parent.config.get_config(u'display footer', True)) \
|
if QtCore.QSettings().value(u'custom/display footer', True).toBool() \
|
||||||
or credit:
|
or credit:
|
||||||
raw_footer.append(title + u' ' + credit)
|
raw_footer.append(title + u' ' + credit)
|
||||||
else:
|
else:
|
||||||
|
@ -31,8 +31,8 @@ class ImageTab(SettingsTab):
|
|||||||
"""
|
"""
|
||||||
ImageTab is the Image settings tab in the settings dialog.
|
ImageTab is the Image settings tab in the settings dialog.
|
||||||
"""
|
"""
|
||||||
def __init__(self, title, section=None):
|
def __init__(self, title):
|
||||||
SettingsTab.__init__(self, title, section)
|
SettingsTab.__init__(self, title)
|
||||||
|
|
||||||
def setupUi(self):
|
def setupUi(self):
|
||||||
self.setObjectName(u'ImageTab')
|
self.setObjectName(u'ImageTab')
|
||||||
@ -71,11 +71,13 @@ class ImageTab(SettingsTab):
|
|||||||
self.loop_delay = self.TimeoutSpinBox.value()
|
self.loop_delay = self.TimeoutSpinBox.value()
|
||||||
|
|
||||||
def load(self):
|
def load(self):
|
||||||
self.loop_delay = int(self.config.get_config(u'loop delay', 5))
|
self.loop_delay = QtCore.QSettings().value(
|
||||||
|
u'images/loop delay', 5).toInt()[0]
|
||||||
self.TimeoutSpinBox.setValue(self.loop_delay)
|
self.TimeoutSpinBox.setValue(self.loop_delay)
|
||||||
|
|
||||||
def save(self):
|
def save(self):
|
||||||
self.config.set_config(u'loop delay', self.loop_delay)
|
QtCore.QSettings().setValue(
|
||||||
|
u'images/loop delay', QtCore.QVariant(self.loop_delay))
|
||||||
Receiver.send_message(u'slidecontroller_live_spin_delay',
|
Receiver.send_message(u'slidecontroller_live_spin_delay',
|
||||||
self.loop_delay)
|
self.loop_delay)
|
||||||
|
|
||||||
|
@ -27,8 +27,10 @@ import logging
|
|||||||
import os
|
import os
|
||||||
|
|
||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
|
|
||||||
from openlp.core.lib import MediaManagerItem, BaseListWithDnD, build_icon, \
|
from openlp.core.lib import MediaManagerItem, BaseListWithDnD, build_icon, \
|
||||||
contextMenuAction, ItemCapabilities
|
contextMenuAction, ItemCapabilities, SettingsManager
|
||||||
|
from openlp.core.utils import AppLocation
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -76,10 +78,12 @@ class ImageMediaItem(MediaManagerItem):
|
|||||||
QtGui.QAbstractItemView.ExtendedSelection)
|
QtGui.QAbstractItemView.ExtendedSelection)
|
||||||
self.ListView.setIconSize(QtCore.QSize(88,50))
|
self.ListView.setIconSize(QtCore.QSize(88,50))
|
||||||
self.servicePath = os.path.join(
|
self.servicePath = os.path.join(
|
||||||
self.parent.config.get_data_path(), u'.thumbnails')
|
AppLocation.get_section_data_path(self.ConfigSection),
|
||||||
|
u'.thumbnails')
|
||||||
if not os.path.exists(self.servicePath):
|
if not os.path.exists(self.servicePath):
|
||||||
os.mkdir(self.servicePath)
|
os.mkdir(self.servicePath)
|
||||||
self.loadList(self.parent.config.load_list(self.ConfigSection))
|
self.loadList(SettingsManager.load_list(
|
||||||
|
self.ConfigSection, self.ConfigSection))
|
||||||
|
|
||||||
def addListViewToToolBar(self):
|
def addListViewToToolBar(self):
|
||||||
MediaManagerItem.addListViewToToolBar(self)
|
MediaManagerItem.addListViewToToolBar(self)
|
||||||
@ -112,12 +116,13 @@ class ImageMediaItem(MediaManagerItem):
|
|||||||
for item in items:
|
for item in items:
|
||||||
text = self.ListView.item(item.row())
|
text = self.ListView.item(item.row())
|
||||||
try:
|
try:
|
||||||
os.remove(os.path.join(self.servicePath, unicode(text.text())))
|
os.remove(
|
||||||
|
os.path.join(self.servicePath, unicode(text.text())))
|
||||||
except:
|
except:
|
||||||
#if not present do not worry
|
#if not present do not worry
|
||||||
pass
|
pass
|
||||||
self.ListView.takeItem(item.row())
|
self.ListView.takeItem(item.row())
|
||||||
self.parent.config.set_list(self.ConfigSection, self.getFileList())
|
SettingsManager.set_list(self.ConfigSection, self.getFileList())
|
||||||
|
|
||||||
def loadList(self, list):
|
def loadList(self, list):
|
||||||
for file in list:
|
for file in list:
|
||||||
|
@ -29,7 +29,7 @@ import os
|
|||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
|
|
||||||
from openlp.core.lib import MediaManagerItem, BaseListWithDnD, build_icon, \
|
from openlp.core.lib import MediaManagerItem, BaseListWithDnD, build_icon, \
|
||||||
ItemCapabilities
|
ItemCapabilities, SettingsManager
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -47,12 +47,12 @@ class MediaMediaItem(MediaManagerItem):
|
|||||||
def __init__(self, parent, icon, title):
|
def __init__(self, parent, icon, title):
|
||||||
self.PluginNameShort = u'Media'
|
self.PluginNameShort = u'Media'
|
||||||
self.IconPath = u'images/image'
|
self.IconPath = u'images/image'
|
||||||
self.ConfigSection = u'media'
|
|
||||||
self.ConfigSection = title
|
self.ConfigSection = title
|
||||||
# this next is a class, not an instance of a class - it will
|
# this next is a class, not an instance of a class - it will
|
||||||
# be instanced by the base MediaManagerItem
|
# be instanced by the base MediaManagerItem
|
||||||
self.ListViewWithDnD_class = MediaListView
|
self.ListViewWithDnD_class = MediaListView
|
||||||
self.PreviewFunction = QtGui.QPixmap(u':/media/media_video.png').toImage()
|
self.PreviewFunction = QtGui.QPixmap(
|
||||||
|
u':/media/media_video.png').toImage()
|
||||||
MediaManagerItem.__init__(self, parent, icon, title)
|
MediaManagerItem.__init__(self, parent, icon, title)
|
||||||
self.singleServiceItem = False
|
self.singleServiceItem = False
|
||||||
self.ServiceItemIconName = u':/media/media_video.png'
|
self.ServiceItemIconName = u':/media/media_video.png'
|
||||||
@ -89,15 +89,15 @@ class MediaMediaItem(MediaManagerItem):
|
|||||||
self.ListView.setSelectionMode(
|
self.ListView.setSelectionMode(
|
||||||
QtGui.QAbstractItemView.ExtendedSelection)
|
QtGui.QAbstractItemView.ExtendedSelection)
|
||||||
self.ListView.setIconSize(QtCore.QSize(88,50))
|
self.ListView.setIconSize(QtCore.QSize(88,50))
|
||||||
self.loadList(self.parent.config.load_list(self.ConfigSection))
|
self.loadList(SettingsManager.load_list(
|
||||||
|
self.ConfigSection, self.ConfigSection))
|
||||||
|
|
||||||
def onDeleteClick(self):
|
def onDeleteClick(self):
|
||||||
item = self.ListView.currentItem()
|
item = self.ListView.currentItem()
|
||||||
if item:
|
if item:
|
||||||
row = self.ListView.row(item)
|
row = self.ListView.row(item)
|
||||||
self.ListView.takeItem(row)
|
self.ListView.takeItem(row)
|
||||||
self.parent.config.set_list(
|
SettingsManager.set_list(self.ConfigSection, self.getFileList())
|
||||||
self.ConfigSection, self.getFileList())
|
|
||||||
|
|
||||||
def loadList(self, list):
|
def loadList(self, list):
|
||||||
for file in list:
|
for file in list:
|
||||||
|
@ -28,7 +28,9 @@ import os
|
|||||||
|
|
||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
|
|
||||||
from openlp.core.lib import MediaManagerItem, BaseListWithDnD, build_icon
|
from openlp.core.lib import MediaManagerItem, BaseListWithDnD, build_icon, \
|
||||||
|
SettingsManager
|
||||||
|
from openlp.core.utils import AppLocation
|
||||||
from openlp.plugins.presentations.lib import MessageListener
|
from openlp.plugins.presentations.lib import MessageListener
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
@ -68,7 +70,8 @@ class PresentationMediaItem(MediaManagerItem):
|
|||||||
fileType = u''
|
fileType = u''
|
||||||
for controller in self.controllers:
|
for controller in self.controllers:
|
||||||
if self.controllers[controller].enabled:
|
if self.controllers[controller].enabled:
|
||||||
types = self.controllers[controller].supports + self.controllers[controller].alsosupports
|
types = self.controllers[controller].supports + \
|
||||||
|
self.controllers[controller].alsosupports
|
||||||
for type in types:
|
for type in types:
|
||||||
if fileType.find(type) == -1:
|
if fileType.find(type) == -1:
|
||||||
fileType += u'*%s ' % type
|
fileType += u'*%s ' % type
|
||||||
@ -104,10 +107,11 @@ class PresentationMediaItem(MediaManagerItem):
|
|||||||
|
|
||||||
def initialise(self):
|
def initialise(self):
|
||||||
self.servicePath = os.path.join(
|
self.servicePath = os.path.join(
|
||||||
self.parent.config.get_data_path(), u'thumbnails')
|
AppLocation.get_section_data_path(self.ConfigSection),
|
||||||
|
u'thumbnails')
|
||||||
if not os.path.exists(self.servicePath):
|
if not os.path.exists(self.servicePath):
|
||||||
os.mkdir(self.servicePath)
|
os.mkdir(self.servicePath)
|
||||||
list = self.parent.config.load_list(u'presentations')
|
list = SettingsManager.load_list(self.ConfigSection, u'presentations')
|
||||||
self.loadList(list)
|
self.loadList(list)
|
||||||
for item in self.controllers:
|
for item in self.controllers:
|
||||||
#load the drop down selection
|
#load the drop down selection
|
||||||
@ -134,17 +138,20 @@ class PresentationMediaItem(MediaManagerItem):
|
|||||||
else:
|
else:
|
||||||
icon = None
|
icon = None
|
||||||
for controller in self.controllers:
|
for controller in self.controllers:
|
||||||
thumbPath = os.path.join(self.parent.config.get_data_path(), \
|
thumbPath = os.path.join(
|
||||||
|
AppLocation.get_section_data_path(self.ConfigSection),
|
||||||
u'thumbnails', controller, filename)
|
u'thumbnails', controller, filename)
|
||||||
thumb = os.path.join(thumbPath, u'slide1.png')
|
thumb = os.path.join(thumbPath, u'slide1.png')
|
||||||
preview = os.path.join(self.parent.config.get_data_path(), \
|
preview = os.path.join(
|
||||||
|
AppLocation.get_section_data_path(self.ConfigSection),
|
||||||
controller, u'thumbnails', filename, u'slide1.png')
|
controller, u'thumbnails', filename, u'slide1.png')
|
||||||
if os.path.exists(preview):
|
if os.path.exists(preview):
|
||||||
if os.path.exists(thumb):
|
if os.path.exists(thumb):
|
||||||
if self.validate(preview, thumb):
|
if self.validate(preview, thumb):
|
||||||
icon = build_icon(thumb)
|
icon = build_icon(thumb)
|
||||||
else:
|
else:
|
||||||
icon = build_icon(u':/general/general_delete.png')
|
icon = build_icon(
|
||||||
|
u':/general/general_delete.png')
|
||||||
else:
|
else:
|
||||||
os.makedirs(thumbPath)
|
os.makedirs(thumbPath)
|
||||||
icon = self.IconFromFile(preview, thumb)
|
icon = self.IconFromFile(preview, thumb)
|
||||||
@ -160,8 +167,7 @@ class PresentationMediaItem(MediaManagerItem):
|
|||||||
if item:
|
if item:
|
||||||
row = self.ListView.row(item)
|
row = self.ListView.row(item)
|
||||||
self.ListView.takeItem(row)
|
self.ListView.takeItem(row)
|
||||||
self.parent.config.set_list(
|
SettingsManager.set_list(self.ConfigSection, self.getFileList())
|
||||||
self.ConfigSection, self.getFileList())
|
|
||||||
filepath = unicode((item.data(QtCore.Qt.UserRole)).toString())
|
filepath = unicode((item.data(QtCore.Qt.UserRole)).toString())
|
||||||
#not sure of this has errors
|
#not sure of this has errors
|
||||||
#John please can you look at .
|
#John please can you look at .
|
||||||
|
@ -30,6 +30,7 @@ import shutil
|
|||||||
from PyQt4 import QtCore
|
from PyQt4 import QtCore
|
||||||
|
|
||||||
from openlp.core.lib import Receiver
|
from openlp.core.lib import Receiver
|
||||||
|
from openlp.core.utils import AppLocation
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -68,7 +69,8 @@ class PresentationController(object):
|
|||||||
Called at system exit to clean up any running presentations
|
Called at system exit to clean up any running presentations
|
||||||
|
|
||||||
``check_available()``
|
``check_available()``
|
||||||
Returns True if presentation application is installed/can run on this machine
|
Returns True if presentation application is installed/can run on this
|
||||||
|
machine
|
||||||
|
|
||||||
``presentation_deleted()``
|
``presentation_deleted()``
|
||||||
Deletes presentation specific files, e.g. thumbnails
|
Deletes presentation specific files, e.g. thumbnails
|
||||||
@ -78,13 +80,14 @@ class PresentationController(object):
|
|||||||
|
|
||||||
def __init__(self, plugin=None, name=u'PresentationController'):
|
def __init__(self, plugin=None, name=u'PresentationController'):
|
||||||
"""
|
"""
|
||||||
This is the constructor for the presentationcontroller object.
|
This is the constructor for the presentationcontroller object. This
|
||||||
This provides an easy way for descendent plugins to populate common data.
|
provides an easy way for descendent plugins to populate common data.
|
||||||
This method *must* be overridden, like so::
|
This method *must* be overridden, like so::
|
||||||
|
|
||||||
class MyPresentationController(PresentationController):
|
class MyPresentationController(PresentationController):
|
||||||
def __init__(self, plugin):
|
def __init__(self, plugin):
|
||||||
PresentationController.__init(self, plugin, u'My Presenter App')
|
PresentationController.__init(
|
||||||
|
self, plugin, u'My Presenter App')
|
||||||
|
|
||||||
``plugin``
|
``plugin``
|
||||||
Defaults to *None*. The presentationplugin object
|
Defaults to *None*. The presentationplugin object
|
||||||
@ -99,11 +102,12 @@ class PresentationController(object):
|
|||||||
self.name = name
|
self.name = name
|
||||||
self.available = self.check_available()
|
self.available = self.check_available()
|
||||||
if self.available:
|
if self.available:
|
||||||
self.enabled = int(plugin.config.get_config(
|
self.enabled = QtCore.QSettings().value(
|
||||||
name, QtCore.Qt.Unchecked)) == QtCore.Qt.Checked
|
name, QtCore.Qt.Unchecked).toInt()[0] == QtCore.Qt.Checked
|
||||||
else:
|
else:
|
||||||
self.enabled = False
|
self.enabled = False
|
||||||
self.thumbnailroot = os.path.join(plugin.config.get_data_path(),
|
self.thumbnailroot = os.path.join(
|
||||||
|
AppLocation.get_section_data_path(u'presentations'),
|
||||||
name, u'thumbnails')
|
name, u'thumbnails')
|
||||||
self.thumbnailprefix = u'slide'
|
self.thumbnailprefix = u'slide'
|
||||||
if not os.path.isdir(self.thumbnailroot):
|
if not os.path.isdir(self.thumbnailroot):
|
||||||
@ -241,7 +245,8 @@ class PresentationDocument(object):
|
|||||||
return os.path.split(presentation)[1]
|
return os.path.split(presentation)[1]
|
||||||
|
|
||||||
def get_thumbnail_path(self, presentation):
|
def get_thumbnail_path(self, presentation):
|
||||||
return os.path.join(self.controller.thumbnailroot, self.get_file_name(presentation))
|
return os.path.join(
|
||||||
|
self.controller.thumbnailroot, self.get_file_name(presentation))
|
||||||
|
|
||||||
def check_thumbnails(self):
|
def check_thumbnails(self):
|
||||||
"""
|
"""
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
from PyQt4 import QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
|
|
||||||
from openlp.core.lib import SettingsTab
|
from openlp.core.lib import SettingsTab
|
||||||
|
|
||||||
@ -31,9 +31,9 @@ class PresentationTab(SettingsTab):
|
|||||||
"""
|
"""
|
||||||
PresentationsTab is the Presentations settings tab in the settings dialog.
|
PresentationsTab is the Presentations settings tab in the settings dialog.
|
||||||
"""
|
"""
|
||||||
def __init__(self, title, controllers, section=None):
|
def __init__(self, title, controllers):
|
||||||
self.controllers = controllers
|
self.controllers = controllers
|
||||||
SettingsTab.__init__(self, title, section)
|
SettingsTab.__init__(self, title)
|
||||||
|
|
||||||
def setupUi(self):
|
def setupUi(self):
|
||||||
self.setObjectName(u'PresentationTab')
|
self.setObjectName(u'PresentationTab')
|
||||||
@ -100,12 +100,12 @@ class PresentationTab(SettingsTab):
|
|||||||
controller = self.controllers[key]
|
controller = self.controllers[key]
|
||||||
if controller.available:
|
if controller.available:
|
||||||
checkbox = self.PresenterCheckboxes[controller.name]
|
checkbox = self.PresenterCheckboxes[controller.name]
|
||||||
checkbox.setChecked(
|
checkbox.setChecked(QtCore.QSettings().value(
|
||||||
int(self.config.get_config(controller.name, 0)))
|
u'presentations/' + controller.name, 0).toInt()[0])
|
||||||
|
|
||||||
def save(self):
|
def save(self):
|
||||||
for key in self.controllers:
|
for key in self.controllers:
|
||||||
controller = self.controllers[key]
|
controller = self.controllers[key]
|
||||||
checkbox = self.PresenterCheckboxes[controller.name]
|
checkbox = self.PresenterCheckboxes[controller.name]
|
||||||
self.config.set_config(
|
QtCore.QSettings().setValue(u'presentations/' + controller.name,
|
||||||
controller.name, unicode(checkbox.checkState()))
|
QtCore.QVariant(checkbox.checkState()))
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
from PyQt4 import QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
|
|
||||||
from openlp.core.lib import SettingsTab
|
from openlp.core.lib import SettingsTab
|
||||||
|
|
||||||
@ -31,8 +31,8 @@ class RemoteTab(SettingsTab):
|
|||||||
"""
|
"""
|
||||||
RemoteTab is the Remotes settings tab in the settings dialog.
|
RemoteTab is the Remotes settings tab in the settings dialog.
|
||||||
"""
|
"""
|
||||||
def __init__(self, title, section=None):
|
def __init__(self, title):
|
||||||
SettingsTab.__init__(self, title, section)
|
SettingsTab.__init__(self, title)
|
||||||
|
|
||||||
def setupUi(self):
|
def setupUi(self):
|
||||||
self.setObjectName(u'RemoteTab')
|
self.setObjectName(u'RemoteTab')
|
||||||
@ -57,8 +57,8 @@ class RemoteTab(SettingsTab):
|
|||||||
|
|
||||||
def load(self):
|
def load(self):
|
||||||
self.RemotePortSpinBox.setValue(
|
self.RemotePortSpinBox.setValue(
|
||||||
int(self.config.get_config(u'remote port', 4316)))
|
QtCore.QSettings().value(u'remotes/remote port', 4316).toInt()[0])
|
||||||
|
|
||||||
def save(self):
|
def save(self):
|
||||||
self.config.set_config(
|
QtCore.QSettings().setValue(u'remotes/remote port',
|
||||||
u'remote port', unicode(self.RemotePortSpinBox.value()))
|
QtCore.QVariant(self.RemotePortSpinBox.value()))
|
||||||
|
@ -45,7 +45,8 @@ class RemotesPlugin(Plugin):
|
|||||||
Plugin.initialise(self)
|
Plugin.initialise(self)
|
||||||
self.insert_toolbox_item()
|
self.insert_toolbox_item()
|
||||||
self.server = QtNetwork.QUdpSocket()
|
self.server = QtNetwork.QUdpSocket()
|
||||||
self.server.bind(int(self.config.get_config(u'remote port', 4316)))
|
self.server.bind(
|
||||||
|
QtCore.QSettings().value(u'remotes/remote port', 4316).toInt()[0])
|
||||||
QtCore.QObject.connect(self.server,
|
QtCore.QObject.connect(self.server,
|
||||||
QtCore.SIGNAL(u'readyRead()'), self.readData)
|
QtCore.SIGNAL(u'readyRead()'), self.readData)
|
||||||
|
|
||||||
|
@ -25,6 +25,9 @@
|
|||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
from PyQt4 import QtCore
|
||||||
|
|
||||||
|
from openlp.core.utils import AppLocation
|
||||||
from openlp.plugins.songs.lib.models import init_models, metadata, Song, \
|
from openlp.plugins.songs.lib.models import init_models, metadata, Song, \
|
||||||
Author, Topic, Book
|
Author, Topic, Book
|
||||||
|
|
||||||
@ -37,24 +40,25 @@ class SongManager():
|
|||||||
"""
|
"""
|
||||||
log.info(u'Song manager loaded')
|
log.info(u'Song manager loaded')
|
||||||
|
|
||||||
def __init__(self, config):
|
def __init__(self):
|
||||||
"""
|
"""
|
||||||
Creates the connection to the database, and creates the tables if they
|
Creates the connection to the database, and creates the tables if they
|
||||||
don't exist.
|
don't exist.
|
||||||
"""
|
"""
|
||||||
self.config = config
|
|
||||||
log.debug(u'Song Initialising')
|
log.debug(u'Song Initialising')
|
||||||
|
settings = QtCore.QSettings()
|
||||||
self.db_url = u''
|
self.db_url = u''
|
||||||
db_type = self.config.get_config(u'db type', u'sqlite')
|
db_type = unicode(
|
||||||
|
settings.value(u'songs/db type', u'sqlite').toString())
|
||||||
if db_type == u'sqlite':
|
if db_type == u'sqlite':
|
||||||
self.db_url = u'sqlite:///%s/songs.sqlite' % \
|
self.db_url = u'sqlite:///%s/songs.sqlite' % \
|
||||||
self.config.get_data_path()
|
AppLocation.get_section_data_path(u'songs')
|
||||||
else:
|
else:
|
||||||
self.db_url = db_type + 'u://' + \
|
self.db_url = db_type + 'u://' + \
|
||||||
self.config.get_config(u'db username') + u':' + \
|
unicode(settings.value(u'songs/db username', u'').toString()) + u':' + \
|
||||||
self.config.get_config(u'db password') + u'@' + \
|
unicode(settings.value(u'songs/db password', u'').toString()) + u'@' + \
|
||||||
self.config.get_config(u'db hostname') + u'/' + \
|
unicode(settings.value(u'songs/db hostname', u'').toString()) + u'/' + \
|
||||||
self.config.get_config(u'db database')
|
unicode(settings.value(u'songs/db database', u'').toString())
|
||||||
self.session = init_models(self.db_url)
|
self.session = init_models(self.db_url)
|
||||||
metadata.create_all(checkfirst=True)
|
metadata.create_all(checkfirst=True)
|
||||||
log.debug(u'Song Initialised')
|
log.debug(u'Song Initialised')
|
||||||
|
@ -28,7 +28,7 @@ import logging
|
|||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
|
|
||||||
from openlp.core.lib import MediaManagerItem, SongXMLParser, \
|
from openlp.core.lib import MediaManagerItem, SongXMLParser, \
|
||||||
BaseListWithDnD, Receiver, str_to_bool, ItemCapabilities
|
BaseListWithDnD, Receiver, ItemCapabilities
|
||||||
from openlp.plugins.songs.forms import EditSongForm, SongMaintenanceForm
|
from openlp.plugins.songs.forms import EditSongForm, SongMaintenanceForm
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
@ -133,8 +133,8 @@ class SongMediaItem(MediaManagerItem):
|
|||||||
QtCore.SIGNAL(u'songs_edit_clear'), self.onRemoteEditClear)
|
QtCore.SIGNAL(u'songs_edit_clear'), self.onRemoteEditClear)
|
||||||
|
|
||||||
def configUpdated(self):
|
def configUpdated(self):
|
||||||
self.searchAsYouType = str_to_bool(
|
self.searchAsYouType = QtCore.QSettings().value(
|
||||||
self.parent.config.get_config(u'search as type', u'False'))
|
u'songs/search as type', u'False').toBool()
|
||||||
|
|
||||||
def retranslateUi(self):
|
def retranslateUi(self):
|
||||||
self.SearchTextLabel.setText(self.trUtf8('Search:'))
|
self.SearchTextLabel.setText(self.trUtf8('Search:'))
|
||||||
@ -350,7 +350,7 @@ class SongMediaItem(MediaManagerItem):
|
|||||||
author_list = author_list + unicode(author.display_name)
|
author_list = author_list + unicode(author.display_name)
|
||||||
author_audit.append(unicode(author.display_name))
|
author_audit.append(unicode(author.display_name))
|
||||||
if song.ccli_number is None or len(song.ccli_number) == 0:
|
if song.ccli_number is None or len(song.ccli_number) == 0:
|
||||||
ccli = self.parent.settings.GeneralTab.CCLINumber
|
ccli = self.parent.settings_form.GeneralTab.CCLINumber
|
||||||
else:
|
else:
|
||||||
ccli = unicode(song.ccli_number)
|
ccli = unicode(song.ccli_number)
|
||||||
raw_footer.append(song.title)
|
raw_footer.append(song.title)
|
||||||
|
@ -25,14 +25,14 @@
|
|||||||
|
|
||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
|
|
||||||
from openlp.core.lib import SettingsTab, str_to_bool
|
from openlp.core.lib import SettingsTab
|
||||||
|
|
||||||
class SongsTab(SettingsTab):
|
class SongsTab(SettingsTab):
|
||||||
"""
|
"""
|
||||||
SongsTab is the Songs settings tab in the settings dialog.
|
SongsTab is the Songs settings tab in the settings dialog.
|
||||||
"""
|
"""
|
||||||
def __init__(self, title, section=None):
|
def __init__(self, title):
|
||||||
SettingsTab.__init__(self, title, section)
|
SettingsTab.__init__(self, title)
|
||||||
|
|
||||||
def setupUi(self):
|
def setupUi(self):
|
||||||
self.setObjectName(u'SongsTab')
|
self.setObjectName(u'SongsTab')
|
||||||
@ -80,13 +80,16 @@ class SongsTab(SettingsTab):
|
|||||||
self.song_bar = True
|
self.song_bar = True
|
||||||
|
|
||||||
def load(self):
|
def load(self):
|
||||||
self.song_search = str_to_bool(
|
settings = QtCore.QSettings()
|
||||||
self.config.get_config(u'search as type', False))
|
self.song_search = settings.value(
|
||||||
self.song_bar = str_to_bool(
|
u'songs/search as type', False).toBool()
|
||||||
self.config.get_config(u'display songbar', True))
|
self.song_bar = settings.value(u'songs/display songbar', True).toBool()
|
||||||
self.SearchAsTypeCheckBox.setChecked(self.song_search)
|
self.SearchAsTypeCheckBox.setChecked(self.song_search)
|
||||||
self.SongBarActiveCheckBox.setChecked(self.song_bar)
|
self.SongBarActiveCheckBox.setChecked(self.song_bar)
|
||||||
|
|
||||||
def save(self):
|
def save(self):
|
||||||
self.config.set_config(u'search as type', unicode(self.song_search))
|
settings = QtCore.QSettings()
|
||||||
self.config.set_config(u'display songbar', unicode(self.song_bar))
|
settings.setValue(
|
||||||
|
u'songs/search as type', QtCore.QVariant(self.song_search))
|
||||||
|
settings.setValue(
|
||||||
|
u'songs/display songbar', QtCore.QVariant(self.song_bar))
|
||||||
|
@ -51,7 +51,7 @@ class SongsPlugin(Plugin):
|
|||||||
"""
|
"""
|
||||||
Plugin.__init__(self, u'Songs', u'1.9.1', plugin_helpers)
|
Plugin.__init__(self, u'Songs', u'1.9.1', plugin_helpers)
|
||||||
self.weight = -10
|
self.weight = -10
|
||||||
self.songmanager = SongManager(self.config)
|
self.songmanager = SongManager()
|
||||||
self.openlp_import_form = OpenLPImportForm()
|
self.openlp_import_form = OpenLPImportForm()
|
||||||
self.opensong_import_form = OpenSongImportForm()
|
self.opensong_import_form = OpenSongImportForm()
|
||||||
self.openlp_export_form = OpenLPExportForm()
|
self.openlp_export_form = OpenLPExportForm()
|
||||||
@ -65,7 +65,7 @@ class SongsPlugin(Plugin):
|
|||||||
def initialise(self):
|
def initialise(self):
|
||||||
log.info(u'Songs Initialising')
|
log.info(u'Songs Initialising')
|
||||||
#if self.songmanager is None:
|
#if self.songmanager is None:
|
||||||
# self.songmanager = SongManager(self.config)
|
# self.songmanager = SongManager()
|
||||||
Plugin.initialise(self)
|
Plugin.initialise(self)
|
||||||
self.insert_toolbox_item()
|
self.insert_toolbox_item()
|
||||||
self.ImportSongMenu.menuAction().setVisible(True)
|
self.ImportSongMenu.menuAction().setVisible(True)
|
||||||
|
@ -23,10 +23,12 @@
|
|||||||
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
|
import logging
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
import logging
|
|
||||||
|
from openlp.core.lib import SettingsManager
|
||||||
|
|
||||||
from songusagedetaildialog import Ui_SongUsageDetailDialog
|
from songusagedetaildialog import Ui_SongUsageDetailDialog
|
||||||
|
|
||||||
@ -53,15 +55,15 @@ class SongUsageDetailForm(QtGui.QDialog, Ui_SongUsageDetailDialog):
|
|||||||
fromDate = QtCore.QDate(year - 1, 9, 1)
|
fromDate = QtCore.QDate(year - 1, 9, 1)
|
||||||
self.FromDate.setSelectedDate(fromDate)
|
self.FromDate.setSelectedDate(fromDate)
|
||||||
self.ToDate.setSelectedDate(toDate)
|
self.ToDate.setSelectedDate(toDate)
|
||||||
self.FileLineEdit.setText(self.parent.config.get_last_dir(1))
|
self.FileLineEdit.setText(SettingsManager.get_last_dir(u'songusage', 1))
|
||||||
|
|
||||||
def defineOutputLocation(self):
|
def defineOutputLocation(self):
|
||||||
path = QtGui.QFileDialog.getExistingDirectory(self,
|
path = QtGui.QFileDialog.getExistingDirectory(self,
|
||||||
self.trUtf8('Output File Location'),
|
self.trUtf8('Output File Location'),
|
||||||
self.parent.config.get_last_dir(1) )
|
SettingsManager.get_last_dir(u'songusage', 1))
|
||||||
path = unicode(path)
|
path = unicode(path)
|
||||||
if path != u'':
|
if path != u'':
|
||||||
self.parent.config.set_last_dir(path, 1)
|
SettingsManager.set_last_dir(u'songusage', path, 1)
|
||||||
self.FileLineEdit.setText(path)
|
self.FileLineEdit.setText(path)
|
||||||
|
|
||||||
def accept(self):
|
def accept(self):
|
||||||
|
@ -25,7 +25,11 @@
|
|||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from openlp.plugins.songusage.lib.models import init_models, metadata, SongUsageItem
|
from PyQt4 import QtCore
|
||||||
|
|
||||||
|
from openlp.core.utils import AppLocation
|
||||||
|
from openlp.plugins.songusage.lib.models import init_models, metadata, \
|
||||||
|
SongUsageItem
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -36,24 +40,25 @@ class SongUsageManager():
|
|||||||
"""
|
"""
|
||||||
log.info(u'SongUsage manager loaded')
|
log.info(u'SongUsage manager loaded')
|
||||||
|
|
||||||
def __init__(self, config):
|
def __init__(self):
|
||||||
"""
|
"""
|
||||||
Creates the connection to the database, and creates the tables if they
|
Creates the connection to the database, and creates the tables if they
|
||||||
don't exist.
|
don't exist.
|
||||||
"""
|
"""
|
||||||
self.config = config
|
settings = QtCore.QSettings()
|
||||||
log.debug(u'SongUsage Initialising')
|
log.debug(u'SongUsage Initialising')
|
||||||
self.db_url = u''
|
self.db_url = u''
|
||||||
db_type = self.config.get_config(u'db type', u'sqlite')
|
db_type = unicode(
|
||||||
|
settings.value(u'songusage/db type', u'sqlite').toString())
|
||||||
if db_type == u'sqlite':
|
if db_type == u'sqlite':
|
||||||
self.db_url = u'sqlite:///%s/songusage.sqlite' % \
|
self.db_url = u'sqlite:///%s/songusage.sqlite' % \
|
||||||
self.config.get_data_path()
|
AppLocation.get_section_data_path(u'songusage')
|
||||||
else:
|
else:
|
||||||
self.db_url = u'%s://%s:%s@%s/%s' % \
|
self.db_url = u'%s://%s:%s@%s/%s' % (db_type,
|
||||||
(db_type, self.config.get_config(u'db username'),
|
unicode(settings.value(u'songusage/db username', u'')),
|
||||||
self.config.get_config(u'db password'),
|
unicode(settings.value(u'songusage/db password', u'')),
|
||||||
self.config.get_config(u'db hostname'),
|
unicode(settings.value(u'songusage/db hostname', u'')),
|
||||||
self.config.get_config(u'db database'))
|
unicode(settings.value(u'songusage/db database', u'')))
|
||||||
self.session = init_models(self.db_url)
|
self.session = init_models(self.db_url)
|
||||||
metadata.create_all(checkfirst=True)
|
metadata.create_all(checkfirst=True)
|
||||||
|
|
||||||
|
@ -28,9 +28,10 @@ import logging
|
|||||||
|
|
||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
|
|
||||||
from openlp.core.lib import Plugin, Receiver, str_to_bool, build_icon
|
from openlp.core.lib import Plugin, Receiver, build_icon
|
||||||
from openlp.plugins.songusage.lib import SongUsageManager
|
from openlp.plugins.songusage.lib import SongUsageManager
|
||||||
from openlp.plugins.songusage.forms import SongUsageDetailForm, SongUsageDeleteForm
|
from openlp.plugins.songusage.forms import SongUsageDetailForm, \
|
||||||
|
SongUsageDeleteForm
|
||||||
from openlp.plugins.songusage.lib.models import SongUsageItem
|
from openlp.plugins.songusage.lib.models import SongUsageItem
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
@ -107,12 +108,13 @@ class SongUsagePlugin(Plugin):
|
|||||||
log.info(u'SongUsage Initialising')
|
log.info(u'SongUsage Initialising')
|
||||||
Plugin.initialise(self)
|
Plugin.initialise(self)
|
||||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||||
QtCore.SIGNAL(u'slidecontroller_live_started'), self.onReceiveSongUsage)
|
QtCore.SIGNAL(u'slidecontroller_live_started'),
|
||||||
self.SongUsageActive = str_to_bool(
|
self.onReceiveSongUsage)
|
||||||
self.config.get_config(u'active', False))
|
self.SongUsageActive = QtCore.QSettings().value(
|
||||||
|
u'songusage/active', False).toBool()
|
||||||
self.SongUsageStatus.setChecked(self.SongUsageActive)
|
self.SongUsageStatus.setChecked(self.SongUsageActive)
|
||||||
if self.songusagemanager is None:
|
if self.songusagemanager is None:
|
||||||
self.songusagemanager = SongUsageManager(self.config)
|
self.songusagemanager = SongUsageManager()
|
||||||
self.SongUsagedeleteform = SongUsageDeleteForm(self.songusagemanager)
|
self.SongUsagedeleteform = SongUsageDeleteForm(self.songusagemanager)
|
||||||
self.SongUsagedetailform = SongUsageDetailForm(self)
|
self.SongUsagedetailform = SongUsageDetailForm(self)
|
||||||
self.SongUsageMenu.menuAction().setVisible(True)
|
self.SongUsageMenu.menuAction().setVisible(True)
|
||||||
@ -125,7 +127,8 @@ class SongUsagePlugin(Plugin):
|
|||||||
|
|
||||||
def toggleSongUsageState(self):
|
def toggleSongUsageState(self):
|
||||||
self.SongUsageActive = not self.SongUsageActive
|
self.SongUsageActive = not self.SongUsageActive
|
||||||
self.config.set_config(u'active', self.SongUsageActive)
|
QtCore.QSettings().setValue(
|
||||||
|
u'songusage/active', QtCore.QVariant(self.SongUsageActive))
|
||||||
|
|
||||||
def onReceiveSongUsage(self, items):
|
def onReceiveSongUsage(self, items):
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user