From 325fab92dabe3724dcea5dd2f3f317b1eb5839ca Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sat, 27 Feb 2010 15:31:23 +0000 Subject: [PATCH 01/11] Clean up all the Gloab log statements --- openlp.pyw | 2 +- openlp/core/lib/eventreceiver.py | 5 ++--- openlp/core/lib/mediamanageritem.py | 5 ++--- openlp/core/lib/plugin.py | 4 ++-- openlp/core/lib/pluginmanager.py | 4 ++-- openlp/core/lib/renderer.py | 4 ++-- openlp/core/lib/rendermanager.py | 4 ++-- openlp/core/lib/serviceitem.py | 4 ++-- openlp/core/lib/songxmlhandler.py | 8 +++----- openlp/core/ui/maindisplay.py | 6 ++---- openlp/core/ui/mainwindow.py | 4 ++-- openlp/core/ui/pluginform.py | 6 +++--- openlp/core/ui/screen.py | 4 ++-- openlp/core/ui/servicemanager.py | 5 ++--- openlp/core/ui/slidecontroller.py | 5 ++--- openlp/core/ui/thememanager.py | 5 ++--- openlp/migration/display.py | 6 +++--- openlp/plugins/alerts/alertsplugin.py | 4 ++-- openlp/plugins/alerts/lib/alertsmanager.py | 6 +++--- openlp/plugins/alerts/lib/manager.py | 5 ++--- openlp/plugins/bibles/bibleplugin.py | 4 ++-- openlp/plugins/bibles/forms/importwizardform.py | 7 +++---- openlp/plugins/bibles/lib/biblestab.py | 4 ++-- openlp/plugins/bibles/lib/manager.py | 4 ++-- openlp/plugins/bibles/lib/mediaitem.py | 4 ++-- openlp/plugins/bibles/lib/osis.py | 4 ++-- openlp/plugins/custom/customplugin.py | 4 +--- openlp/plugins/custom/forms/editcustomform.py | 4 ++-- openlp/plugins/custom/lib/manager.py | 5 ++--- openlp/plugins/custom/lib/mediaitem.py | 4 ++-- openlp/plugins/images/imageplugin.py | 4 ++-- openlp/plugins/images/lib/mediaitem.py | 4 ++-- openlp/plugins/presentations/lib/impresscontroller.py | 6 +++--- openlp/plugins/presentations/lib/mediaitem.py | 4 ++-- openlp/plugins/presentations/lib/messagelistener.py | 6 ++---- openlp/plugins/presentations/lib/powerpointcontroller.py | 6 +++--- openlp/plugins/presentations/lib/pptviewcontroller.py | 6 +++--- .../plugins/presentations/lib/presentationcontroller.py | 4 ++-- openlp/plugins/presentations/presentationplugin.py | 4 ++-- openlp/plugins/remotes/remoteplugin.py | 5 ++--- openlp/plugins/songs/lib/manager.py | 5 ++--- openlp/plugins/songs/lib/mediaitem.py | 4 ++-- openlp/plugins/songs/songsplugin.py | 5 ++--- openlp/plugins/songusage/forms/songusagedetailform.py | 4 ++-- openlp/plugins/songusage/lib/manager.py | 5 ++--- openlp/plugins/songusage/songusageplugin.py | 4 ++-- 46 files changed, 98 insertions(+), 118 deletions(-) diff --git a/openlp.pyw b/openlp.pyw index 5c18486b6..31869e797 100755 --- a/openlp.pyw +++ b/openlp.pyw @@ -59,13 +59,13 @@ QToolBar padding: 0; } """ +log = logging.getLogger(__name__) class OpenLP(QtGui.QApplication): """ The core application class. This class inherits from Qt's QApplication class in order to provide the core of the application. """ - global log log.info(u'OpenLP Application Loaded') def notify(self, obj, evt): diff --git a/openlp/core/lib/eventreceiver.py b/openlp/core/lib/eventreceiver.py index 9bd7cd652..be7dff67a 100644 --- a/openlp/core/lib/eventreceiver.py +++ b/openlp/core/lib/eventreceiver.py @@ -27,6 +27,8 @@ import logging from PyQt4 import QtCore +log = logging.getLogger(__name__) + class EventReceiver(QtCore.QObject): """ Class to allow events to be passed from different parts of the @@ -108,9 +110,6 @@ class EventReceiver(QtCore.QObject): Informs all components of the presentation types supported. """ - global log - log = logging.getLogger(u'EventReceiver') - def __init__(self): """ Initialise the event receiver, calling the parent constructor. diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index 5f490eed1..ff87f0b0d 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -32,6 +32,8 @@ from openlp.core.lib.toolbar import * from openlp.core.lib import contextMenuAction, contextMenuSeparator from serviceitem import ServiceItem +log = logging.getLogger(__name__) + class MediaManagerItem(QtGui.QWidget): """ MediaManagerItem is a helper widget for plugins. @@ -92,9 +94,6 @@ class MediaManagerItem(QtGui.QWidget): method is not defined, a default will be used (treat the filename as an image). """ - - global log - log = logging.getLogger(u'MediaManagerItem') log.info(u'Media Item loaded') def __init__(self, parent=None, icon=None, title=None): diff --git a/openlp/core/lib/plugin.py b/openlp/core/lib/plugin.py index ca291d578..e15369145 100644 --- a/openlp/core/lib/plugin.py +++ b/openlp/core/lib/plugin.py @@ -28,6 +28,8 @@ from PyQt4 import QtCore from openlp.core.lib import PluginConfig, Receiver +log = logging.getLogger(__name__) + class PluginStatus(object): """ Defines the status of the plugin @@ -88,8 +90,6 @@ class Plugin(QtCore.QObject): Used in the plugin manager, when a person clicks on the 'About' button. """ - global log - log = logging.getLogger(u'Plugin') log.info(u'loaded') def __init__(self, name, version=None, plugin_helpers=None): diff --git a/openlp/core/lib/pluginmanager.py b/openlp/core/lib/pluginmanager.py index b06f23953..2ea5751ec 100644 --- a/openlp/core/lib/pluginmanager.py +++ b/openlp/core/lib/pluginmanager.py @@ -29,13 +29,13 @@ import logging from openlp.core.lib import Plugin, PluginStatus +log = logging.getLogger(__name__) + class PluginManager(object): """ This is the Plugin manager, which loads all the plugins, and executes all the hooks, as and when necessary. """ - global log - log = logging.getLogger(u'PluginMgr') log.info(u'Plugin manager loaded') def __init__(self, dir): diff --git a/openlp/core/lib/renderer.py b/openlp/core/lib/renderer.py index cc976dae5..ea6e849d8 100644 --- a/openlp/core/lib/renderer.py +++ b/openlp/core/lib/renderer.py @@ -28,13 +28,13 @@ import logging from PyQt4 import QtGui, QtCore from openlp.core.lib import resize_image +log = logging.getLogger(__name__) + class Renderer(object): """ Genarates a pixmap image of a array of text. The Text is formatted to make sure it fits on the screen and if not extra frames are generated. """ - global log - log = logging.getLogger(u'Renderer') log.info(u'Renderer Loaded') def __init__(self): diff --git a/openlp/core/lib/rendermanager.py b/openlp/core/lib/rendermanager.py index 1e8363228..edab3d309 100644 --- a/openlp/core/lib/rendermanager.py +++ b/openlp/core/lib/rendermanager.py @@ -30,6 +30,8 @@ from PyQt4 import QtCore from renderer import Renderer from openlp.core.lib import ThemeLevel +log = logging.getLogger(__name__) + class RenderManager(object): """ Class to pull all Renderer interactions into one place. The plugins will @@ -45,8 +47,6 @@ class RenderManager(object): ``screen_number`` Defaults to *0*. The index of the output/display screen. """ - global log - log = logging.getLogger(u'RenderManager') log.info(u'RenderManager Loaded') def __init__(self, theme_manager, screens, screen_number=0): diff --git a/openlp/core/lib/serviceitem.py b/openlp/core/lib/serviceitem.py index e62b24d8e..52deafc06 100644 --- a/openlp/core/lib/serviceitem.py +++ b/openlp/core/lib/serviceitem.py @@ -32,6 +32,8 @@ from PyQt4 import QtGui from openlp.core.lib import build_icon, Receiver, resize_image +log = logging.getLogger(__name__) + class ServiceItemType(object): """ Defines the type of service item @@ -46,8 +48,6 @@ class ServiceItem(object): the service manager, the slide controller, and the projection screen compositor. """ - global log - log = logging.getLogger(u'ServiceItem') log.info(u'Service Item created') def __init__(self, plugin=None): diff --git a/openlp/core/lib/songxmlhandler.py b/openlp/core/lib/songxmlhandler.py index 596866934..7a532970d 100644 --- a/openlp/core/lib/songxmlhandler.py +++ b/openlp/core/lib/songxmlhandler.py @@ -27,6 +27,8 @@ import logging from xml.dom.minidom import Document from xml.etree.ElementTree import ElementTree, XML, dump +log = logging.getLogger(__name__) + class SongXMLBuilder(object): """ This class builds the XML used to describe songs. @@ -42,8 +44,6 @@ class SongXMLBuilder(object): """ - global log - log = logging.getLogger(u'SongXMLBuilder') log.info(u'SongXMLBuilder Loaded') def __init__(self): @@ -123,8 +123,6 @@ class SongXMLParser(object): """ - global log - log = logging.getLogger(u'SongXMLParser') log.info(u'SongXMLParser Loaded') def __init__(self, xml): @@ -158,4 +156,4 @@ class SongXMLParser(object): """ Debugging aid to dump XML so that we can see what we have. """ - return dump(self.song_xml) \ No newline at end of file + return dump(self.song_xml) diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index bdb396498..87935cf5e 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -31,13 +31,13 @@ from PyQt4.phonon import Phonon from openlp.core.lib import Receiver, resize_image +log = logging.getLogger(__name__) + class DisplayWidget(QtGui.QWidget): """ Customised version of QTableWidget which can respond to keyboard events. """ - global log - log = logging.getLogger(u'MainDisplay') log.info(u'MainDisplay loaded') def __init__(self, parent=None, name=None): @@ -78,8 +78,6 @@ class MainDisplay(DisplayWidget): """ This is the form that is used to display things on the projector. """ - global log - log = logging.getLogger(u'MainDisplay') log.info(u'MainDisplay Loaded') def __init__(self, parent, screens): diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 96a089df1..7e822fb8a 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -36,6 +36,8 @@ from openlp.core.lib import RenderManager, PluginConfig, build_icon, \ OpenLPDockWidget, SettingsManager, PluginManager, Receiver, str_to_bool from openlp.core.utils import check_latest_version +log = logging.getLogger(__name__) + media_manager_style = """ QToolBox::tab { background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, @@ -420,8 +422,6 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): """ The main window. """ - global log - log = logging.getLogger(u'MainWindow') log.info(u'MainWindow loaded') def __init__(self, screens, applicationVersion): diff --git a/openlp/core/ui/pluginform.py b/openlp/core/ui/pluginform.py index fa48c0723..9af8b7ca3 100644 --- a/openlp/core/ui/pluginform.py +++ b/openlp/core/ui/pluginform.py @@ -30,9 +30,9 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib.plugin import PluginStatus from plugindialog import Ui_PluginViewDialog +log = logging.getLogger(__name__) + class PluginForm(QtGui.QDialog, Ui_PluginViewDialog): - global log - log = logging.getLogger(u'PluginForm') def __init__(self, parent=None): QtGui.QDialog.__init__(self, parent) @@ -126,4 +126,4 @@ class PluginForm(QtGui.QDialog, Ui_PluginViewDialog): elif self.activePlugin.status == PluginStatus.Disabled: status_text = 'Disabled' self.PluginListWidget.currentItem().setText( - u'%s (%s)' % (self.activePlugin.name, status_text)) \ No newline at end of file + u'%s (%s)' % (self.activePlugin.name, status_text)) diff --git a/openlp/core/ui/screen.py b/openlp/core/ui/screen.py index 2321c3020..9fad9ca9b 100644 --- a/openlp/core/ui/screen.py +++ b/openlp/core/ui/screen.py @@ -24,12 +24,12 @@ ############################################################################### import logging +log = logging.getLogger(__name__) + class ScreenList(object): """ Wrapper to handle the parameters of the display screen """ - global log - log = logging.getLogger(u'Screen') log.info(u'Screen loaded') def __init__(self): diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 22fbb7ecc..f13cca760 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -28,6 +28,8 @@ import logging import cPickle import zipfile +log = logging.getLogger(__name__) + from PyQt4 import QtCore, QtGui from openlp.core.lib import PluginConfig, OpenLPToolbar, ServiceItem, \ contextMenuAction, contextMenuSeparator, contextMenu, Receiver, \ @@ -105,9 +107,6 @@ class ServiceManager(QtGui.QWidget): the resources used into one OSZ file for use on any OpenLP v2 installation. Also handles the UI tasks of moving things up and down etc. """ - global log - log = logging.getLogger(u'ServiceManager') - def __init__(self, parent): """ Sets up the service manager, toolbars, list view, et al. diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index 515fb2d3c..81ff030ae 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -33,6 +33,8 @@ from PyQt4.phonon import Phonon from openlp.core.lib import OpenLPToolbar, Receiver, str_to_bool, \ PluginConfig, resize_image +log = logging.getLogger(__name__) + class SlideList(QtGui.QTableWidget): """ Customised version of QTableWidget which can respond to keyboard @@ -74,9 +76,6 @@ class SlideController(QtGui.QWidget): SlideController is the slide controller widget. This widget is what the user uses to control the displaying of verses/slides/etc on the screen. """ - global log - log = logging.getLogger(u'SlideController') - def __init__(self, parent, settingsmanager, isLive=False): """ Set up the Slide Controller. diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index 577021418..ba541aa6e 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -38,13 +38,12 @@ from openlp.core.lib import PluginConfig, OpenLPToolbar, contextMenuAction, \ contextMenuSeparator from openlp.core.utils import ConfigHelper +log = logging.getLogger(__name__) + class ThemeManager(QtGui.QWidget): """ Manages the orders of Theme. """ - global log - log = logging.getLogger(u'ThemeManager') - def __init__(self, parent): QtGui.QWidget.__init__(self, parent) self.parent = parent diff --git a/openlp/migration/display.py b/openlp/migration/display.py index 9a3f6e44e..bffef5b17 100644 --- a/openlp/migration/display.py +++ b/openlp/migration/display.py @@ -25,9 +25,9 @@ import logging +log = logging.getLogger(__name__) + class Display(): - global log - log = logging.getLogger(u'Display Logger') log.info(u'Display Class loaded') @staticmethod @@ -39,4 +39,4 @@ class Display(): def sub_output(string): if not string is None: log.debug(u' '+string); - print (u' '+string) \ No newline at end of file + print (u' '+string) diff --git a/openlp/plugins/alerts/alertsplugin.py b/openlp/plugins/alerts/alertsplugin.py index 5bf268394..3e065f6af 100644 --- a/openlp/plugins/alerts/alertsplugin.py +++ b/openlp/plugins/alerts/alertsplugin.py @@ -31,9 +31,9 @@ from openlp.core.lib import Plugin, build_icon, PluginStatus from openlp.plugins.alerts.lib import AlertsManager, DBManager from openlp.plugins.alerts.forms import AlertsTab, AlertForm, AlertEditForm +log = logging.getLogger(__name__) + class alertsPlugin(Plugin): - global log - log = logging.getLogger(u'AlertsPlugin') log.info(u'Alerts Plugin loaded') def __init__(self, plugin_helpers): diff --git a/openlp/plugins/alerts/lib/alertsmanager.py b/openlp/plugins/alerts/lib/alertsmanager.py index deda11240..6838fefa0 100644 --- a/openlp/plugins/alerts/lib/alertsmanager.py +++ b/openlp/plugins/alerts/lib/alertsmanager.py @@ -29,12 +29,12 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import Receiver +log = logging.getLogger(__name__) + class AlertsManager(QtCore.QObject): """ - BiblesTab is the Bibles settings tab in the settings dialog. + AlertsTab is the Alerts settings tab in the settings dialog. """ - global log - log = logging.getLogger(u'AlertManager') log.info(u'Alert Manager loaded') def __init__(self, parent): diff --git a/openlp/plugins/alerts/lib/manager.py b/openlp/plugins/alerts/lib/manager.py index 3480b3103..a3ed1ee7e 100644 --- a/openlp/plugins/alerts/lib/manager.py +++ b/openlp/plugins/alerts/lib/manager.py @@ -27,14 +27,13 @@ import logging from openlp.plugins.alerts.lib.models import init_models, metadata, AlertItem +log = logging.getLogger(__name__) + class DBManager(): """ The Song Manager provides a central location for all database code. This class takes care of connecting to the database and running all the queries. """ - - global log - log = logging.getLogger(u'AlertsDBManager') log.info(u'Alerts DB loaded') def __init__(self, config): diff --git a/openlp/plugins/bibles/bibleplugin.py b/openlp/plugins/bibles/bibleplugin.py index 9d85a90a0..8cf15e942 100644 --- a/openlp/plugins/bibles/bibleplugin.py +++ b/openlp/plugins/bibles/bibleplugin.py @@ -30,9 +30,9 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import Plugin, build_icon, PluginStatus from openlp.plugins.bibles.lib import BibleManager, BiblesTab, BibleMediaItem +log = logging.getLogger(__name__) + class BiblePlugin(Plugin): - global log - log = logging.getLogger(u'BiblePlugin') log.info(u'Bible Plugin loaded') def __init__(self, plugin_helpers): diff --git a/openlp/plugins/bibles/forms/importwizardform.py b/openlp/plugins/bibles/forms/importwizardform.py index 2f5e84867..dfca754a8 100644 --- a/openlp/plugins/bibles/forms/importwizardform.py +++ b/openlp/plugins/bibles/forms/importwizardform.py @@ -34,6 +34,8 @@ from bibleimportwizard import Ui_BibleImportWizard from openlp.core.lib import Receiver from openlp.plugins.bibles.lib.manager import BibleFormat +log = logging.getLogger(__name__) + class DownloadLocation(object): Unknown = -1 Crosswalk = 0 @@ -54,9 +56,6 @@ class ImportWizardForm(QtGui.QWizard, Ui_BibleImportWizard): This is the Bible Import Wizard, which allows easy importing of Bibles into OpenLP from other formats like OSIS, CSV and OpenSong. """ - - global log - log = logging.getLogger(u'BibleImportForm') log.info(u'BibleImportForm loaded') def __init__(self, parent, config, manager, bibleplugin): @@ -371,4 +370,4 @@ class ImportWizardForm(QtGui.QWizard, Ui_BibleImportWizard): self.ImportProgressBar.setValue(self.ImportProgressBar.maximum()) self.finishButton.setVisible(True) self.cancelButton.setVisible(False) - Receiver.send_message(u'process_events') \ No newline at end of file + Receiver.send_message(u'process_events') diff --git a/openlp/plugins/bibles/lib/biblestab.py b/openlp/plugins/bibles/lib/biblestab.py index ef8e6a090..398040fd8 100644 --- a/openlp/plugins/bibles/lib/biblestab.py +++ b/openlp/plugins/bibles/lib/biblestab.py @@ -29,12 +29,12 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import str_to_bool, Receiver, SettingsTab +log = logging.getLogger(__name__) + class BiblesTab(SettingsTab): """ BiblesTab is the Bibles settings tab in the settings dialog. """ - global log - log = logging.getLogger(u'BibleTab') log.info(u'Bible Tab loaded') def __init__(self, title, section=None): diff --git a/openlp/plugins/bibles/lib/manager.py b/openlp/plugins/bibles/lib/manager.py index 965d0433f..d24982532 100644 --- a/openlp/plugins/bibles/lib/manager.py +++ b/openlp/plugins/bibles/lib/manager.py @@ -33,6 +33,8 @@ from csvbible import CSVBible from db import BibleDB from http import HTTPBible +log = logging.getLogger(__name__) + class BibleMode(object): """ This is basically an enumeration class which specifies the mode of a Bible. @@ -85,8 +87,6 @@ class BibleManager(object): """ The Bible manager which holds and manages all the Bibles. """ - global log - log = logging.getLogger(u'BibleManager') log.info(u'Bible manager loaded') def __init__(self, parent, config): diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index c0a3bde35..30403e69d 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -32,6 +32,8 @@ from openlp.core.lib import MediaManagerItem, Receiver, str_to_bool, \ BaseListWithDnD from openlp.plugins.bibles.forms import ImportWizardForm +log = logging.getLogger(__name__) + class BibleListView(BaseListWithDnD): """ Drag and drop capable list for Bibles. @@ -47,8 +49,6 @@ class BibleMediaItem(MediaManagerItem): """ This is the custom media manager item for Bibles. """ - global log - log = logging.getLogger(u'BibleMediaItem') log.info(u'Bible Media Item loaded') def __init__(self, parent, icon, title): diff --git a/openlp/plugins/bibles/lib/osis.py b/openlp/plugins/bibles/lib/osis.py index cfa68b213..6498e4d34 100644 --- a/openlp/plugins/bibles/lib/osis.py +++ b/openlp/plugins/bibles/lib/osis.py @@ -33,12 +33,12 @@ import re from openlp.core.lib import Receiver from db import BibleDB +log = logging.getLogger(__name__) + class OSISBible(BibleDB): """ OSIS Bible format importer class. """ - global log - log = logging.getLogger(u'BibleOSISImpl') log.info(u'BibleOSISImpl loaded') def __init__(self, parent, **kwargs): diff --git a/openlp/plugins/custom/customplugin.py b/openlp/plugins/custom/customplugin.py index fb30bed9f..3e21228df 100644 --- a/openlp/plugins/custom/customplugin.py +++ b/openlp/plugins/custom/customplugin.py @@ -29,6 +29,7 @@ from forms import EditCustomForm from openlp.core.lib import Plugin, build_icon, PluginStatus from openlp.plugins.custom.lib import CustomManager, CustomMediaItem, CustomTab +log = logging.getLogger(__name__) class CustomPlugin(Plugin): """ @@ -39,9 +40,6 @@ class CustomPlugin(Plugin): the songs plugin has become restrictive. Examples could be Welcome slides, Bible Reading information, Orders of service. """ - - global log - log = logging.getLogger(u'CustomPlugin') log.info(u'Custom Plugin loaded') def __init__(self, plugin_helpers): diff --git a/openlp/plugins/custom/forms/editcustomform.py b/openlp/plugins/custom/forms/editcustomform.py index e701c0938..577142f23 100644 --- a/openlp/plugins/custom/forms/editcustomform.py +++ b/openlp/plugins/custom/forms/editcustomform.py @@ -30,12 +30,12 @@ from editcustomdialog import Ui_customEditDialog from openlp.core.lib import SongXMLBuilder, SongXMLParser, Receiver from openlp.plugins.custom.lib.models import CustomSlide +log = logging.getLogger(__name__) + class EditCustomForm(QtGui.QDialog, Ui_customEditDialog): """ Class documentation goes here. """ - global log - log = logging.getLogger(u'EditCustomForm') log.info(u'Custom Editor loaded') def __init__(self, custommanager, parent = None): """ diff --git a/openlp/plugins/custom/lib/manager.py b/openlp/plugins/custom/lib/manager.py index d1d3e0349..e88e72b5c 100644 --- a/openlp/plugins/custom/lib/manager.py +++ b/openlp/plugins/custom/lib/manager.py @@ -27,14 +27,13 @@ import logging from openlp.plugins.custom.lib.models import init_models, metadata, CustomSlide +log = logging.getLogger(__name__) + class CustomManager(): """ The Song Manager provides a central location for all database code. This class takes care of connecting to the database and running all the queries. """ - - global log - log = logging.getLogger(u'CustomManager') log.info(u'Custom manager loaded') def __init__(self, config): diff --git a/openlp/plugins/custom/lib/mediaitem.py b/openlp/plugins/custom/lib/mediaitem.py index c4b9ef16a..2a3090cf2 100644 --- a/openlp/plugins/custom/lib/mediaitem.py +++ b/openlp/plugins/custom/lib/mediaitem.py @@ -30,6 +30,8 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import MediaManagerItem, SongXMLParser, BaseListWithDnD,\ Receiver, str_to_bool +log = logging.getLogger(__name__) + class CustomListView(BaseListWithDnD): def __init__(self, parent=None): self.PluginName = u'Custom' @@ -39,8 +41,6 @@ class CustomMediaItem(MediaManagerItem): """ This is the custom media manager item for Custom Slides. """ - global log - log = logging.getLogger(u'CustomMediaItem') log.info(u'Custom Media Item loaded') def __init__(self, parent, icon, title): diff --git a/openlp/plugins/images/imageplugin.py b/openlp/plugins/images/imageplugin.py index e6895c767..40e9c1e1d 100644 --- a/openlp/plugins/images/imageplugin.py +++ b/openlp/plugins/images/imageplugin.py @@ -28,9 +28,9 @@ import logging from openlp.core.lib import Plugin, build_icon, PluginStatus from openlp.plugins.images.lib import ImageMediaItem, ImageTab +log = logging.getLogger(__name__) + class ImagePlugin(Plugin): - global log - log = logging.getLogger(u'ImagePlugin') log.info(u'Image Plugin loaded') def __init__(self, plugin_helpers): diff --git a/openlp/plugins/images/lib/mediaitem.py b/openlp/plugins/images/lib/mediaitem.py index e418ee44e..830459843 100644 --- a/openlp/plugins/images/lib/mediaitem.py +++ b/openlp/plugins/images/lib/mediaitem.py @@ -29,6 +29,8 @@ import os from PyQt4 import QtCore, QtGui from openlp.core.lib import MediaManagerItem, BaseListWithDnD, build_icon +log = logging.getLogger(__name__) + # We have to explicitly create separate classes for each plugin # in order for DnD to the Service manager to work correctly. class ImageListView(BaseListWithDnD): @@ -40,8 +42,6 @@ class ImageMediaItem(MediaManagerItem): """ This is the custom media manager item for images. """ - global log - log = logging.getLogger(u'ImageMediaItem') log.info(u'Image Media Item loaded') def __init__(self, parent, icon, title): diff --git a/openlp/plugins/presentations/lib/impresscontroller.py b/openlp/plugins/presentations/lib/impresscontroller.py index 31b3ac5f6..0ea5c4d3a 100644 --- a/openlp/plugins/presentations/lib/impresscontroller.py +++ b/openlp/plugins/presentations/lib/impresscontroller.py @@ -46,15 +46,15 @@ from PyQt4 import QtCore from presentationcontroller import PresentationController +log = logging.getLogger(__name__) + class ImpressController(PresentationController): """ Class to control interactions with Impress presentations. It creates the runtime environment, loads and closes the presentation as well as triggering the correct activities based on the users input """ - global log - log = logging.getLogger(u'ImpressController') - log.info(u'loaded') + log.info(u'ImpressController loaded') def __init__(self, plugin): """ diff --git a/openlp/plugins/presentations/lib/mediaitem.py b/openlp/plugins/presentations/lib/mediaitem.py index 590074ead..90487cdf5 100644 --- a/openlp/plugins/presentations/lib/mediaitem.py +++ b/openlp/plugins/presentations/lib/mediaitem.py @@ -31,6 +31,8 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import MediaManagerItem, BaseListWithDnD from openlp.plugins.presentations.lib import MessageListener +log = logging.getLogger(__name__) + # We have to explicitly create separate classes for each plugin # in order for DnD to the Service manager to work correctly. class PresentationListView(BaseListWithDnD): @@ -43,8 +45,6 @@ class PresentationMediaItem(MediaManagerItem): This is the Presentation media manager item for Presentation Items. It can present files using Openoffice """ - global log - log = logging.getLogger(u'PresentationsMediaItem') log.info(u'Presentations Media Item loaded') def __init__(self, parent, icon, title, controllers): diff --git a/openlp/plugins/presentations/lib/messagelistener.py b/openlp/plugins/presentations/lib/messagelistener.py index 3c665004b..5d4bef4db 100644 --- a/openlp/plugins/presentations/lib/messagelistener.py +++ b/openlp/plugins/presentations/lib/messagelistener.py @@ -30,13 +30,13 @@ from PyQt4 import QtCore from openlp.core.lib import Receiver +log = logging.getLogger(__name__) + class Controller(object): """ This is the Presentation listener who acts on events from the slide controller and passes the messages on the the correct presentation handlers """ - global log - log = logging.getLogger(u'Controller') log.info(u'Controller loaded') def __init__(self, live): @@ -149,8 +149,6 @@ class MessageListener(object): This is the Presentation listener who acts on events from the slide controller and passes the messages on the the correct presentation handlers """ - global log - log = logging.getLogger(u'MessageListener') log.info(u'Message Listener loaded') def __init__(self, controllers): diff --git a/openlp/plugins/presentations/lib/powerpointcontroller.py b/openlp/plugins/presentations/lib/powerpointcontroller.py index a9775e086..42bc160de 100644 --- a/openlp/plugins/presentations/lib/powerpointcontroller.py +++ b/openlp/plugins/presentations/lib/powerpointcontroller.py @@ -33,6 +33,8 @@ if os.name == u'nt': from presentationcontroller import PresentationController +log = logging.getLogger(__name__) + # PPT API documentation: # http://msdn.microsoft.com/en-us/library/aa269321(office.10).aspx @@ -42,9 +44,7 @@ class PowerpointController(PresentationController): It creates the runtime Environment , Loads the and Closes the Presentation As well as triggering the correct activities based on the users input """ - global log - log = logging.getLogger(u'PowerpointController') - log.info(u'loaded') + log.info(u'PowerpointController loaded') def __init__(self, plugin): """ diff --git a/openlp/plugins/presentations/lib/pptviewcontroller.py b/openlp/plugins/presentations/lib/pptviewcontroller.py index 2ed457fc0..ddfa5ab7a 100644 --- a/openlp/plugins/presentations/lib/pptviewcontroller.py +++ b/openlp/plugins/presentations/lib/pptviewcontroller.py @@ -32,15 +32,15 @@ if os.name == u'nt': from presentationcontroller import PresentationController +log = logging.getLogger(__name__) + class PptviewController(PresentationController): """ Class to control interactions with PowerPOint Viewer Presentations It creates the runtime Environment , Loads the and Closes the Presentation As well as triggering the correct activities based on the users input """ - global log - log = logging.getLogger(u'PptviewController') - log.info(u'loaded') + log.info(u'PPTViewController loaded') def __init__(self, plugin): """ diff --git a/openlp/plugins/presentations/lib/presentationcontroller.py b/openlp/plugins/presentations/lib/presentationcontroller.py index db42a482d..b0f3e4e79 100644 --- a/openlp/plugins/presentations/lib/presentationcontroller.py +++ b/openlp/plugins/presentations/lib/presentationcontroller.py @@ -31,6 +31,8 @@ from PyQt4 import QtCore from openlp.core.lib import Receiver +log = logging.getLogger(__name__) + class PresentationController(object): """ Base class for presentation controllers to inherit from @@ -116,8 +118,6 @@ class PresentationController(object): Returns a path to an image containing a preview for the requested slide """ - global log - log = logging.getLogger(u'PresentationController') log.info(u'PresentationController loaded') def __init__(self, plugin=None, name=u'PresentationController'): diff --git a/openlp/plugins/presentations/presentationplugin.py b/openlp/plugins/presentations/presentationplugin.py index 7103a3a2c..061eb737f 100644 --- a/openlp/plugins/presentations/presentationplugin.py +++ b/openlp/plugins/presentations/presentationplugin.py @@ -29,9 +29,9 @@ import logging from openlp.core.lib import Plugin, build_icon, Receiver, PluginStatus from openlp.plugins.presentations.lib import * -class PresentationPlugin(Plugin): +log = logging.getLogger(__name__) - global log +class PresentationPlugin(Plugin): log = logging.getLogger(u'PresentationPlugin') def __init__(self, plugin_helpers): diff --git a/openlp/plugins/remotes/remoteplugin.py b/openlp/plugins/remotes/remoteplugin.py index bd8d8974b..acfa6f97d 100644 --- a/openlp/plugins/remotes/remoteplugin.py +++ b/openlp/plugins/remotes/remoteplugin.py @@ -30,10 +30,9 @@ from PyQt4 import QtNetwork, QtCore from openlp.core.lib import Plugin, Receiver from openlp.plugins.remotes.lib import RemoteTab -class RemotesPlugin(Plugin): +log = logging.getLogger(__name__) - global log - log = logging.getLogger(u'RemotesPlugin') +class RemotesPlugin(Plugin): log.info(u'Remote Plugin loaded') def __init__(self, plugin_helpers): diff --git a/openlp/plugins/songs/lib/manager.py b/openlp/plugins/songs/lib/manager.py index ceb596942..74bd4cf82 100644 --- a/openlp/plugins/songs/lib/manager.py +++ b/openlp/plugins/songs/lib/manager.py @@ -28,14 +28,13 @@ import logging from openlp.plugins.songs.lib.models import init_models, metadata, Song, \ Author, Topic, Book +log = logging.getLogger(__name__) + class SongManager(): """ The Song Manager provides a central location for all database code. This class takes care of connecting to the database and running all the queries. """ - - global log - log = logging.getLogger(u'SongManager') log.info(u'Song manager loaded') def __init__(self, config): diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index 63fd69d48..cd440e54f 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -31,6 +31,8 @@ from openlp.core.lib import MediaManagerItem, SongXMLParser, \ BaseListWithDnD, Receiver, str_to_bool from openlp.plugins.songs.forms import EditSongForm, SongMaintenanceForm +log = logging.getLogger(__name__) + class SongListView(BaseListWithDnD): def __init__(self, parent=None): self.PluginName = u'Songs' @@ -40,8 +42,6 @@ class SongMediaItem(MediaManagerItem): """ This is the custom media manager item for Songs. """ - global log - log = logging.getLogger(u'SongMediaItem') log.info(u'Song Media Item loaded') def __init__(self, parent, icon, title): diff --git a/openlp/plugins/songs/songsplugin.py b/openlp/plugins/songs/songsplugin.py index 088b9a1cf..eb6eb2c2a 100644 --- a/openlp/plugins/songs/songsplugin.py +++ b/openlp/plugins/songs/songsplugin.py @@ -32,6 +32,8 @@ from openlp.plugins.songs.lib import SongManager, SongMediaItem, SongsTab from openlp.plugins.songs.forms import OpenLPImportForm, OpenSongExportForm, \ OpenSongImportForm, OpenLPExportForm +log = logging.getLogger(__name__) + class SongsPlugin(Plugin): """ This is the number 1 plugin, if importance were placed on any @@ -40,9 +42,6 @@ class SongsPlugin(Plugin): specified. Authors, topics and song books can be assigned to songs as well. """ - - global log - log = logging.getLogger(u'SongsPlugin') log.info(u'Song Plugin loaded') def __init__(self, plugin_helpers): diff --git a/openlp/plugins/songusage/forms/songusagedetailform.py b/openlp/plugins/songusage/forms/songusagedetailform.py index df749d8c0..be548ac35 100644 --- a/openlp/plugins/songusage/forms/songusagedetailform.py +++ b/openlp/plugins/songusage/forms/songusagedetailform.py @@ -29,9 +29,9 @@ import logging from songusagedetaildialog import Ui_SongUsageDetailDialog +log = logging.getLogger(__name__) + class SongUsageDetailForm(QtGui.QDialog, Ui_SongUsageDetailDialog): - global log - log = logging.getLogger(u'SongUsageDetailForm') log.info(u'SongUsage Detail Form loaded') """ Class documentation goes here. diff --git a/openlp/plugins/songusage/lib/manager.py b/openlp/plugins/songusage/lib/manager.py index 6cae4c372..d9f7feb6f 100644 --- a/openlp/plugins/songusage/lib/manager.py +++ b/openlp/plugins/songusage/lib/manager.py @@ -27,14 +27,13 @@ import logging from openlp.plugins.songusage.lib.models import init_models, metadata, SongUsageItem +log = logging.getLogger(__name__) + class SongUsageManager(): """ The Song Manager provides a central location for all database code. This class takes care of connecting to the database and running all the queries. """ - - global log - log = logging.getLogger(u'SongUsageManager') log.info(u'SongUsage manager loaded') def __init__(self, config): diff --git a/openlp/plugins/songusage/songusageplugin.py b/openlp/plugins/songusage/songusageplugin.py index d0ebe68ef..d30bd4bea 100644 --- a/openlp/plugins/songusage/songusageplugin.py +++ b/openlp/plugins/songusage/songusageplugin.py @@ -33,9 +33,9 @@ from openlp.plugins.songusage.lib import SongUsageManager from openlp.plugins.songusage.forms import SongUsageDetailForm, SongUsageDeleteForm from openlp.plugins.songusage.lib.models import SongUsageItem +log = logging.getLogger(__name__) + class SongUsagePlugin(Plugin): - global log - log = logging.getLogger(u'SongUsagePlugin') log.info(u'SongUsage Plugin loaded') def __init__(self, plugin_helpers): From 4abcbe86b285150e832c1f83b98fcc13597c1084 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Tue, 2 Mar 2010 19:44:55 +0000 Subject: [PATCH 02/11] ServiceItem Cleanups --- openlp/core/lib/serviceitem.py | 3 ++ openlp/core/ui/maindisplay.py | 1 + openlp/core/ui/servicemanager.py | 45 +++++++++++++++++---------- openlp/core/ui/slidecontroller.py | 4 +++ openlp/plugins/images/lib/imagetab.py | 3 +- 5 files changed, 39 insertions(+), 17 deletions(-) diff --git a/openlp/core/lib/serviceitem.py b/openlp/core/lib/serviceitem.py index 52deafc06..00d043870 100644 --- a/openlp/core/lib/serviceitem.py +++ b/openlp/core/lib/serviceitem.py @@ -73,6 +73,7 @@ class ServiceItem(object): self._display_frames = [] self._uuid = unicode(uuid.uuid1()) self.autoPreviewAllowed = False + self.notes = u'' def addIcon(self, icon): """ @@ -202,6 +203,7 @@ class ServiceItem(object): u'footer':self.raw_footer, u'type':self.service_item_type, u'audit':self.audit, + u'notes':self.notes, u'preview':self.autoPreviewAllowed } service_data = [] @@ -237,6 +239,7 @@ class ServiceItem(object): self.raw_footer = header[u'footer'] self.audit = header[u'audit'] self.autoPreviewAllowed = header[u'preview'] + self.notes = header[u'notes'] if self.service_item_type == ServiceItemType.Text: for slide in serviceitem[u'serviceitem'][u'data']: self._raw_frames.append(slide) diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index 87935cf5e..7082bad8d 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -186,6 +186,7 @@ class MainDisplay(DisplayWidget): Receiver.send_message(u'screen_changed') def resetDisplay(self): + Receiver.send_message(u'stop_display_loop') if self.primary: self.setVisible(False) else: diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index f13cca760..eda29d187 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -41,24 +41,31 @@ class ServiceManagerList(QtGui.QTreeWidget): QtGui.QTreeWidget.__init__(self,parent) self.parent = parent -# def mousePressEvent(self, event): -# if event.button() == QtCore.Qt.RightButton: -# item = self.itemAt(event.pos()) -# parentitem = item.parent() -# if parentitem is None: -# pos = item.data(0, QtCore.Qt.UserRole).toInt()[0] -# else: -# pos = parentitem.data(0, QtCore.Qt.UserRole).toInt()[0] -# serviceItem = self.parent.serviceItems[pos - 1] -# if serviceItem[u'data'].edit_enabled: -# self.parent.editAction.setVisible(True) -# else: -# self.parent.editAction.setVisible(False) -# event.accept() -# else: -# event.ignore() + def mouseDoubleClickEvent(self, event): + self.parent.makeLive() + event.ignore() + + def mousePressEvent(self, event): + if event.button() == QtCore.Qt.RightButton: + item = self.itemAt(event.pos()) + parentitem = item.parent() + self.parent.noteAction.setVisible(False) + if parentitem is None: + pos = item.data(0, QtCore.Qt.UserRole).toInt()[0] + self.parent.noteAction.setVisible(True) + else: + pos = parentitem.data(0, QtCore.Qt.UserRole).toInt()[0] + serviceItem = self.parent.serviceItems[pos - 1] + if serviceItem[u'service_item'].edit_enabled: + self.parent.editAction.setVisible(True) + else: + self.parent.editAction.setVisible(False) + event.accept() + else: + event.ignore() def keyPressEvent(self, event): + print event.isAutoRepeat() if type(event) == QtGui.QKeyEvent: #here accept the event and do something if event.key() == QtCore.Qt.Key_Enter: @@ -93,6 +100,7 @@ class ServiceManagerList(QtGui.QTreeWidget): just tell it what plugin to call """ if event.buttons() != QtCore.Qt.LeftButton: + event.ignore() return drag = QtGui.QDrag(self) mimeData = QtCore.QMimeData() @@ -171,7 +179,11 @@ class ServiceManager(QtGui.QWidget): self.editAction = contextMenuAction( self.ServiceManagerList, ':/system/system_live.png', self.trUtf8('&Edit Item'), self.remoteEdit) + self.noteAction = contextMenuAction( + self.ServiceManagerList, ':/system/system_live.png', + self.trUtf8('&Notes'), self.remoteEdit) self.ServiceManagerList.addAction(self.editAction) + self.ServiceManagerList.addAction(self.noteAction) self.ServiceManagerList.addAction(contextMenuSeparator( self.ServiceManagerList)) self.ServiceManagerList.addAction(contextMenuAction( @@ -625,6 +637,7 @@ class ServiceManager(QtGui.QWidget): """ Send the current item to the Live slide controller """ + print "ml" item, count = self.findServiceItem() self.parent.LiveController.addServiceManagerItem( self.serviceItems[item][u'service_item'], count) diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index 81ff030ae..46280ed2b 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -193,6 +193,8 @@ class SlideController(QtGui.QWidget): u'Stop Loop', u':/media/media_stop.png', self.trUtf8('Stop continuous loop'), self.onStopLoop) self.DelaySpinBox = QtGui.QSpinBox() + self.DelaySpinBox.setMinimum(1) + self.DelaySpinBox.setMaximum(180) self.Toolbar.addToolbarWidget( u'Image SpinBox', self.DelaySpinBox) self.DelaySpinBox.setSuffix(self.trUtf8('s')) @@ -279,6 +281,8 @@ class SlideController(QtGui.QWidget): else: self.Toolbar.makeWidgetsInvisible(self.song_edit_list) self.Mediabar.setVisible(False) + QtCore.QObject.connect(Receiver.get_receiver(), + QtCore.SIGNAL(u'stop_display_loop'), self.onStopLoop) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'%s_first' % prefix), self.onSlideSelectedFirst) QtCore.QObject.connect(Receiver.get_receiver(), diff --git a/openlp/plugins/images/lib/imagetab.py b/openlp/plugins/images/lib/imagetab.py index 2dbea8181..b70006bdb 100644 --- a/openlp/plugins/images/lib/imagetab.py +++ b/openlp/plugins/images/lib/imagetab.py @@ -49,6 +49,7 @@ class ImageTab(SettingsTab): self.TimeoutLabel.setObjectName(u'TimeoutLabel') self.TimeoutLayout.addWidget(self.TimeoutLabel) self.TimeoutSpinBox = QtGui.QSpinBox(self.ImageSettingsGroupBox) + self.TimeoutSpinBox.setMinimum(1) self.TimeoutSpinBox.setMaximum(180) self.TimeoutSpinBox.setObjectName(u'TimeoutSpinBox') self.TimeoutLayout.addWidget(self.TimeoutSpinBox) @@ -78,4 +79,4 @@ class ImageTab(SettingsTab): Receiver.send_message(u'update_spin_delay', self.loop_delay) def postSetUp(self): - Receiver.send_message(u'update_spin_delay', self.loop_delay) \ No newline at end of file + Receiver.send_message(u'update_spin_delay', self.loop_delay) From bfd3f28c6ed71bedeb3ec5987c1342fc0f3340d2 Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Tue, 2 Mar 2010 22:40:01 +0200 Subject: [PATCH 03/11] Create the config directory if it doesn't exist yet, in order to save the log file. --- openlp.pyw | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/openlp.pyw b/openlp.pyw index 5c18486b6..3910156ce 100755 --- a/openlp.pyw +++ b/openlp.pyw @@ -158,7 +158,10 @@ def main(): parser.add_option("-s", "--style", dest="style", help="Set the Qt4 style (passed directly to Qt4).") # Set up logging - filename = os.path.join(get_config_directory(), u'openlp.log') + log_path = get_config_directory() + if not os.path.exists(log_path): + os.makedirs(log_path) + filename = os.path.join(log_path, u'openlp.log') logfile = FileHandler(filename, u'w') logfile.setFormatter(logging.Formatter( u'%(asctime)s %(name)-15s %(levelname)-8s %(message)s')) From 6bff7936eb1502f48af772d724414020b16dba89 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Wed, 3 Mar 2010 17:48:37 +0000 Subject: [PATCH 04/11] Add ServiceItemNoteForm and handling --- openlp.pyw | 4 +-- openlp/core/ui/__init__.py | 3 +- openlp/core/ui/serviceitemdialog.py | 34 +++++++++++++++++++++ openlp/core/ui/serviceitemform.py | 44 ++++++++++++++++++++++++++++ openlp/core/ui/servicemanager.py | 30 ++++++++++++++----- openlp/core/ui/slidecontroller.py | 2 +- resources/forms/serviceitemdialog.ui | 41 ++++++++++++++++++++++++++ 7 files changed, 146 insertions(+), 12 deletions(-) create mode 100644 openlp/core/ui/serviceitemdialog.py create mode 100644 openlp/core/ui/serviceitemform.py create mode 100644 resources/forms/serviceitemdialog.ui diff --git a/openlp.pyw b/openlp.pyw index 31869e797..3fd7c051a 100755 --- a/openlp.pyw +++ b/openlp.pyw @@ -32,13 +32,13 @@ from logging import FileHandler from optparse import OptionParser from PyQt4 import QtCore, QtGui +log = logging.getLogger() + from openlp.core.lib import Receiver, str_to_bool from openlp.core.resources import qInitResources from openlp.core.ui import MainWindow, SplashScreen, ScreenList from openlp.core.utils import get_config_directory, ConfigHelper -log = logging.getLogger() - application_stylesheet = u""" QMainWindow::separator { diff --git a/openlp/core/ui/__init__.py b/openlp/core/ui/__init__.py index 6e37afc7f..c2f571c3b 100644 --- a/openlp/core/ui/__init__.py +++ b/openlp/core/ui/__init__.py @@ -23,6 +23,7 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### +from serviceitemform import ServiceItemNoteForm from screen import ScreenList from maindisplay import MainDisplay from amendthemeform import AmendThemeForm @@ -40,4 +41,4 @@ from mainwindow import MainWindow __all__ = ['SplashScreen', 'AboutForm', 'SettingsForm', 'MainWindow', 'MainDisplay', 'SlideController', 'ServiceManager', 'ThemeManager', - 'AmendThemeForm', 'MediaDockManager'] + 'AmendThemeForm', 'MediaDockManager', 'ServiceItemNoteForm'] diff --git a/openlp/core/ui/serviceitemdialog.py b/openlp/core/ui/serviceitemdialog.py new file mode 100644 index 000000000..150375da9 --- /dev/null +++ b/openlp/core/ui/serviceitemdialog.py @@ -0,0 +1,34 @@ +# -*- coding: utf-8 -*- + +# Form implementation generated from reading ui file 'serviceitemdialog.ui' +# +# Created: Tue Mar 2 20:17:21 2010 +# by: PyQt4 UI code generator 4.7 +# +# WARNING! All changes made in this file will be lost! + +from PyQt4 import QtCore, QtGui + +class Ui_ServiceNoteEdit(object): + def setupUi(self, ServiceNoteEdit): + ServiceNoteEdit.setObjectName("ServiceNoteEdit") + ServiceNoteEdit.resize(400, 243) + self.widget = QtGui.QWidget(ServiceNoteEdit) + self.widget.setGeometry(QtCore.QRect(20, 10, 361, 223)) + self.widget.setObjectName("widget") + self.verticalLayout = QtGui.QVBoxLayout(self.widget) + self.verticalLayout.setObjectName("verticalLayout") + self.textEdit = QtGui.QTextEdit(self.widget) + self.textEdit.setObjectName("textEdit") + self.verticalLayout.addWidget(self.textEdit) + self.buttonBox = QtGui.QDialogButtonBox(self.widget) + self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Save) + self.buttonBox.setObjectName("buttonBox") + self.verticalLayout.addWidget(self.buttonBox) + + self.retranslateUi(ServiceNoteEdit) + QtCore.QMetaObject.connectSlotsByName(ServiceNoteEdit) + + def retranslateUi(self, ServiceNoteEdit): + ServiceNoteEdit.setWindowTitle(QtGui.QApplication.translate("ServiceNoteEdit", "Service Item Notes", None, QtGui.QApplication.UnicodeUTF8)) + diff --git a/openlp/core/ui/serviceitemform.py b/openlp/core/ui/serviceitemform.py new file mode 100644 index 000000000..43011ead8 --- /dev/null +++ b/openlp/core/ui/serviceitemform.py @@ -0,0 +1,44 @@ +# -*- 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, 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 # +############################################################################### + +from PyQt4 import QtCore, QtGui +from serviceitemdialog import Ui_ServiceNoteEdit + +class ServiceItemNoteForm(QtGui.QDialog, Ui_ServiceNoteEdit): + """ + This is the form that is used to edit the verses of the song. + """ + def __init__(self, parent=None): + """ + Constructor + """ + QtGui.QDialog.__init__(self, parent) + self.setupUi(self) + QtCore.QObject.connect(self.buttonBox, + QtCore.SIGNAL(u'accepted()'), + self.accept) + QtCore.QObject.connect(self.buttonBox, + QtCore.SIGNAL(u'rejected()'), + self.reject) diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index a36b44fed..e55ce7936 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -31,9 +31,11 @@ import zipfile log = logging.getLogger(__name__) from PyQt4 import QtCore, QtGui + from openlp.core.lib import PluginConfig, OpenLPToolbar, ServiceItem, \ contextMenuAction, contextMenuSeparator, contextMenu, Receiver, \ contextMenu, str_to_bool +from openlp.core.ui import ServiceItemNoteForm class ServiceManagerList(QtGui.QTreeWidget): @@ -56,6 +58,11 @@ class ServiceManagerList(QtGui.QTreeWidget): else: pos = parentitem.data(0, QtCore.Qt.UserRole).toInt()[0] serviceItem = self.parent.serviceItems[pos - 1] + self.parent.menuServiceItem = serviceItem + if serviceItem[u'service_item'].is_text(): + self.parent.themeMenu.menuAction().setVisible(True) + else: + self.parent.themeMenu.menuAction().setVisible(False) if serviceItem[u'service_item'].edit_enabled: self.parent.editAction.setVisible(True) else: @@ -128,6 +135,7 @@ class ServiceManager(QtGui.QWidget): #Indicates if remoteTriggering is active. If it is the next addServiceItem call #will replace the currently selected one. self.remoteEditTriggered = False + self.serviceItemNoteForm = ServiceItemNoteForm() #start with the layout self.Layout = QtGui.QVBoxLayout(self) self.Layout.setSpacing(0) @@ -180,8 +188,8 @@ class ServiceManager(QtGui.QWidget): self.ServiceManagerList, ':/services/service_edit.png', self.trUtf8('&Edit Item'), self.remoteEdit) self.noteAction = contextMenuAction( - self.ServiceManagerList, ':/system/system_live.png', - self.trUtf8('&Notes'), self.remoteEdit) + self.ServiceManagerList, ':/services/service_notes.png', + self.trUtf8('&Notes'), self.onServiceItemNoteForm) self.ServiceManagerList.addAction(self.editAction) self.ServiceManagerList.addAction(self.noteAction) self.ServiceManagerList.addAction(contextMenuSeparator( @@ -199,10 +207,10 @@ class ServiceManager(QtGui.QWidget): self.trUtf8('&Remove from Service'), self.onDeleteFromService)) self.ServiceManagerList.addAction(contextMenuSeparator( self.ServiceManagerList)) - self.ThemeMenu = contextMenu( + self.themeMenu = contextMenu( self.ServiceManagerList, '', self.trUtf8('&Change Item Theme')) - self.ServiceManagerList.addAction(self.ThemeMenu.menuAction()) + self.ServiceManagerList.addAction(self.themeMenu.menuAction()) self.Layout.addWidget(self.ServiceManagerList) # Add the bottom toolbar self.OrderToolbar = OpenLPToolbar(self) @@ -226,8 +234,6 @@ class ServiceManager(QtGui.QWidget): # Connect up our signals and slots QtCore.QObject.connect(self.ThemeComboBox, QtCore.SIGNAL(u'activated(int)'), self.onThemeComboBoxSelected) - QtCore.QObject.connect(self.ServiceManagerList, - QtCore.SIGNAL(u'doubleClicked(QModelIndex)'), self.makeLive) QtCore.QObject.connect(self.ServiceManagerList, QtCore.SIGNAL(u'itemCollapsed(QTreeWidgetItem*)'), self.collapsed) QtCore.QObject.connect(self.ServiceManagerList, @@ -249,6 +255,14 @@ class ServiceManager(QtGui.QWidget): def onPresentationTypes(self, presentation_types): self.presentation_types = presentation_types + def onServiceItemNoteForm(self): + item, count = self.findServiceItem() + self.serviceItemNoteForm.textEdit.setPlainText( + self.menuServiceItem[u'service_item'].notes) + if self.serviceItemNoteForm.exec_(): + self.menuServiceItem[u'service_item'].notes = \ + self.serviceItemNoteForm.textEdit.toPlainText() + def nextItem(self): """ Called by the SlideController to select the @@ -734,7 +748,7 @@ class ServiceManager(QtGui.QWidget): A list of current themes to be displayed """ self.ThemeComboBox.clear() - self.ThemeMenu.clear() + self.themeMenu.clear() self.ThemeComboBox.addItem(u'') for theme in theme_list: self.ThemeComboBox.addItem(theme) @@ -742,7 +756,7 @@ class ServiceManager(QtGui.QWidget): self.ServiceManagerList, None, theme , self.onThemeChangeAction) - self.ThemeMenu.addAction(action) + self.themeMenu.addAction(action) id = self.ThemeComboBox.findText(self.service_theme, QtCore.Qt.MatchExactly) # Not Found diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index 46280ed2b..ff8507f5d 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -182,7 +182,7 @@ class SlideController(QtGui.QWidget): self.trUtf8('Move to live'), self.onGoLive) self.Toolbar.addToolbarSeparator(u'Close Separator') self.Toolbar.addToolbarButton( - u'Edit Song', u':/songs/song_edit.png', + u'Edit Song', u':/services/service_edit.png', self.trUtf8('Edit and re-preview Song'), self.onEditSong) if isLive: self.Toolbar.addToolbarSeparator(u'Loop Separator') diff --git a/resources/forms/serviceitemdialog.ui b/resources/forms/serviceitemdialog.ui new file mode 100644 index 000000000..6615b08aa --- /dev/null +++ b/resources/forms/serviceitemdialog.ui @@ -0,0 +1,41 @@ + + + ServiceNoteEdit + + + + 0 + 0 + 400 + 243 + + + + Service Item Notes + + + + + 20 + 10 + 361 + 223 + + + + + + + + + + QDialogButtonBox::Cancel|QDialogButtonBox::Save + + + + + + + + + From 3084140741da63615ed44108f86deb824b2fe53b Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Wed, 3 Mar 2010 17:49:28 +0000 Subject: [PATCH 05/11] Remove extra line --- openlp/core/ui/servicemanager.py | 1 - 1 file changed, 1 deletion(-) diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index e55ce7936..e28826696 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -256,7 +256,6 @@ class ServiceManager(QtGui.QWidget): self.presentation_types = presentation_types def onServiceItemNoteForm(self): - item, count = self.findServiceItem() self.serviceItemNoteForm.textEdit.setPlainText( self.menuServiceItem[u'service_item'].notes) if self.serviceItemNoteForm.exec_(): From 9ada2f00b0a3504cc96ab4c8a4e0cd6bc08e7b40 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Thu, 4 Mar 2010 19:03:09 +0000 Subject: [PATCH 06/11] Theme Deletes only work for unused themes --- openlp/core/lib/plugin.py | 6 ++++++ openlp/core/ui/thememanager.py | 13 +++++++++++++ openlp/plugins/bibles/bibleplugin.py | 6 ++++++ openlp/plugins/custom/customplugin.py | 5 +++++ openlp/plugins/custom/lib/manager.py | 3 +++ openlp/plugins/songs/lib/manager.py | 3 +++ openlp/plugins/songs/songsplugin.py | 5 +++++ 7 files changed, 41 insertions(+) diff --git a/openlp/core/lib/plugin.py b/openlp/core/lib/plugin.py index e15369145..e98c789d0 100644 --- a/openlp/core/lib/plugin.py +++ b/openlp/core/lib/plugin.py @@ -254,3 +254,9 @@ class Plugin(QtCore.QObject): self.mediadock.insert_dock(self.media_item, self.icon, self.weight) if self.settings_tab: self.settings.insertTab(self.settings_tab, self.weight) + + def can_delete_theme(self, theme): + """ + Called to ask the plugin if a theme can be deleted + """ + return True diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index ba541aa6e..b6396c7db 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -180,6 +180,19 @@ class ThemeManager(QtGui.QWidget): self.trUtf8('You are unable to delete the default theme!'), QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok)) else: + for plugin in self.parent.plugin_manager.plugins: + if not plugin.can_delete_theme(theme): + QtGui.QMessageBox.critical( + self, self.trUtf8('Error'), + self.trUtf8('theme %s is use in %s plugin' % (theme, plugin.name)), + QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok)) + return + if unicode(self.parent.ServiceManagerContents.ThemeComboBox.currentText()) == theme: + QtGui.QMessageBox.critical( + self, self.trUtf8('Error'), + self.trUtf8('theme %s is use Service Manager' % theme), + QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok)) + return self.themelist.remove(theme) th = theme + u'.png' row = self.ThemeListWidget.row(item) diff --git a/openlp/plugins/bibles/bibleplugin.py b/openlp/plugins/bibles/bibleplugin.py index 8cf15e942..bd65b6622 100644 --- a/openlp/plugins/bibles/bibleplugin.py +++ b/openlp/plugins/bibles/bibleplugin.py @@ -92,3 +92,9 @@ class BiblePlugin(Plugin): 'plugin allows bible verses from different sources to be ' 'displayed on the screen during the service.') return about_text + + + def can_delete_theme(self, theme): + if self.settings_tab.bible_theme == theme: + return False + return True diff --git a/openlp/plugins/custom/customplugin.py b/openlp/plugins/custom/customplugin.py index 3e21228df..ac5384390 100644 --- a/openlp/plugins/custom/customplugin.py +++ b/openlp/plugins/custom/customplugin.py @@ -72,3 +72,8 @@ class CustomPlugin(Plugin): 'songs are. This plugin provides greater freedom over the ' 'songs plugin.
') return about_text + + def can_delete_theme(self, theme): + if len(self.custommanager.get_customs_for_theme(theme)) == 0: + return True + return False diff --git a/openlp/plugins/custom/lib/manager.py b/openlp/plugins/custom/lib/manager.py index e88e72b5c..1368b89ee 100644 --- a/openlp/plugins/custom/lib/manager.py +++ b/openlp/plugins/custom/lib/manager.py @@ -105,3 +105,6 @@ class CustomManager(): return False else: return True + + def get_customs_for_theme(self, theme): + return self.session.query(CustomSlide).filter(CustomSlide.theme_name == theme).all() diff --git a/openlp/plugins/songs/lib/manager.py b/openlp/plugins/songs/lib/manager.py index 74bd4cf82..0e662dcbc 100644 --- a/openlp/plugins/songs/lib/manager.py +++ b/openlp/plugins/songs/lib/manager.py @@ -237,3 +237,6 @@ class SongManager(): self.session.rollback() log.exception(u'Could not delete book from song database') return False + + def get_songs_for_theme(self, theme): + return self.session.query(Song).filter(Song.theme_name == theme).all() diff --git a/openlp/plugins/songs/songsplugin.py b/openlp/plugins/songs/songsplugin.py index eb6eb2c2a..9ebaa99b2 100644 --- a/openlp/plugins/songs/songsplugin.py +++ b/openlp/plugins/songs/songsplugin.py @@ -179,3 +179,8 @@ class SongsPlugin(Plugin): about_text = self.trUtf8('Song Plugin
This plugin allows ' 'Songs to be managed and displayed.
') return about_text + + def can_delete_theme(self, theme): + if len(self.songmanager.get_songs_for_theme(theme)) == 0: + return True + return False From 181c7c99468157bc968b9f7d0eb1aff94f414257 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Thu, 4 Mar 2010 22:03:43 +0000 Subject: [PATCH 07/11] Event clean ups and fixes --- openlp.pyw | 1 - openlp/core/ui/servicemanager.py | 68 ++++++++++++++++++-------------- 2 files changed, 39 insertions(+), 30 deletions(-) diff --git a/openlp.pyw b/openlp.pyw index cb08e419c..6763ea6c1 100755 --- a/openlp.pyw +++ b/openlp.pyw @@ -60,7 +60,6 @@ QToolBar padding: 0; } """ -log = logging.getLogger(__name__) class OpenLP(QtGui.QApplication): """ diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index e28826696..6a9223508 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -42,37 +42,47 @@ class ServiceManagerList(QtGui.QTreeWidget): def __init__(self, parent=None, name=None): QtGui.QTreeWidget.__init__(self,parent) self.parent = parent + self.setExpandsOnDoubleClick(False) + + def mousePressEvent(self, event): + #Implement item selection + item = self.itemAt(event.pos()) + if item is not None: + self.setCurrentItem(item) + parentitem = item.parent() + if event.button() == QtCore.Qt.RightButton: + self.parent.noteAction.setVisible(False) + if parentitem is None: + pos = item.data(0, QtCore.Qt.UserRole).toInt()[0] + self.parent.noteAction.setVisible(True) + else: + pos = parentitem.data(0, QtCore.Qt.UserRole).toInt()[0] + serviceItem = self.parent.serviceItems[pos - 1] + if serviceItem[u'service_item'].is_text(): + self.parent.themeMenu.menuAction().setVisible(True) + else: + self.parent.themeMenu.menuAction().setVisible(False) + if serviceItem[u'service_item'].edit_enabled: + self.parent.editAction.setVisible(True) + else: + self.parent.editAction.setVisible(False) + event.accept() + elif event.button() == QtCore.Qt.LeftButton: + if parentitem is None: + if self.isItemExpanded(item): + self.collapseItem(item) + else: + self.expandItem(item) + else: + event.accept() + else: + event.accept() def mouseDoubleClickEvent(self, event): self.parent.makeLive() - event.ignore() - - def mousePressEvent(self, event): - if event.button() == QtCore.Qt.RightButton: - item = self.itemAt(event.pos()) - parentitem = item.parent() - self.parent.noteAction.setVisible(False) - if parentitem is None: - pos = item.data(0, QtCore.Qt.UserRole).toInt()[0] - self.parent.noteAction.setVisible(True) - else: - pos = parentitem.data(0, QtCore.Qt.UserRole).toInt()[0] - serviceItem = self.parent.serviceItems[pos - 1] - self.parent.menuServiceItem = serviceItem - if serviceItem[u'service_item'].is_text(): - self.parent.themeMenu.menuAction().setVisible(True) - else: - self.parent.themeMenu.menuAction().setVisible(False) - if serviceItem[u'service_item'].edit_enabled: - self.parent.editAction.setVisible(True) - else: - self.parent.editAction.setVisible(False) - event.accept() - else: - event.ignore() + event.accept() def keyPressEvent(self, event): - print event.isAutoRepeat() if type(event) == QtGui.QKeyEvent: #here accept the event and do something if event.key() == QtCore.Qt.Key_Enter: @@ -256,10 +266,11 @@ class ServiceManager(QtGui.QWidget): self.presentation_types = presentation_types def onServiceItemNoteForm(self): + item, count = self.findServiceItem() self.serviceItemNoteForm.textEdit.setPlainText( - self.menuServiceItem[u'service_item'].notes) + self.serviceItems[item][u'service_item'].notes) if self.serviceItemNoteForm.exec_(): - self.menuServiceItem[u'service_item'].notes = \ + self.serviceItems[item][u'service_item'].notes = \ self.serviceItemNoteForm.textEdit.toPlainText() def nextItem(self): @@ -650,7 +661,6 @@ class ServiceManager(QtGui.QWidget): """ Send the current item to the Live slide controller """ - print "ml" item, count = self.findServiceItem() self.parent.LiveController.addServiceManagerItem( self.serviceItems[item][u'service_item'], count) From f4e25bf329fe7acc3c49785f3ed4d35a291a2409 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Thu, 4 Mar 2010 22:09:03 +0000 Subject: [PATCH 08/11] Finish logging cleanup --- openlp.pyw | 2 +- openlp/core/lib/dockwidget.py | 7 ++++--- openlp/core/lib/toolbar.py | 9 +++++---- openlp/core/ui/mediadockmanager.py | 4 ++-- openlp/core/ui/settingsform.py | 2 +- 5 files changed, 13 insertions(+), 11 deletions(-) diff --git a/openlp.pyw b/openlp.pyw index 6763ea6c1..7fd7fcbe1 100755 --- a/openlp.pyw +++ b/openlp.pyw @@ -161,7 +161,7 @@ def main(): filename = os.path.join(get_config_directory(), u'openlp.log') logfile = FileHandler(filename, u'w') logfile.setFormatter(logging.Formatter( - u'%(asctime)s %(name)-15s %(levelname)-8s %(message)s')) + u'%(asctime)s %(name)-20s %(levelname)-8s %(message)s')) log.addHandler(logfile) logging.addLevelName(15, u'Timer') # Parse command line options and deal with them. diff --git a/openlp/core/lib/dockwidget.py b/openlp/core/lib/dockwidget.py index 6d205cb29..ce8302b43 100644 --- a/openlp/core/lib/dockwidget.py +++ b/openlp/core/lib/dockwidget.py @@ -27,6 +27,8 @@ import logging from PyQt4 import QtGui +log = logging.getLogger(__name__) + class OpenLPDockWidget(QtGui.QDockWidget): """ Custom DockWidget class to handle events @@ -40,10 +42,9 @@ class OpenLPDockWidget(QtGui.QDockWidget): if name: self.setObjectName(name) self.setFloating(False) - self.log = logging.getLogger(u'OpenLPDockWidget') - self.log.debug(u'Init done') + log.debug(u'Init done') def closeEvent(self, event): self.parent.settingsmanager.setUIItemVisibility( self.objectName(), False) - event.accept() \ No newline at end of file + event.accept() diff --git a/openlp/core/lib/toolbar.py b/openlp/core/lib/toolbar.py index d4985fd70..3753fedc0 100644 --- a/openlp/core/lib/toolbar.py +++ b/openlp/core/lib/toolbar.py @@ -29,6 +29,8 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import build_icon +log = logging.getLogger(__name__) + class OpenLPToolbar(QtGui.QToolBar): """ Lots of toolbars around the place, so it makes sense to have a common way @@ -43,8 +45,7 @@ class OpenLPToolbar(QtGui.QToolBar): self.icons = {} self.setIconSize(QtCore.QSize(20, 20)) self.actions = {} - self.log = logging.getLogger(u'OpenLPToolbar') - self.log.debug(u'Init done') + log.debug(u'Init done') def addToolbarButton(self, title, icon, tooltip=None, slot=None, checkable=False): @@ -119,7 +120,7 @@ class OpenLPToolbar(QtGui.QToolBar): if self.icons[title]: return self.icons[title] else: - self.log.error(u'getIconFromTitle - no icon for %s' % title) + log.error(u'getIconFromTitle - no icon for %s' % title) return QtGui.QIcon() def makeWidgetsInvisible(self, widgets): @@ -152,4 +153,4 @@ class OpenLPToolbar(QtGui.QToolBar): push_button.setCheckable(True) push_button.setFlat(True) self.addWidget(push_button) - return push_button \ No newline at end of file + return push_button diff --git a/openlp/core/ui/mediadockmanager.py b/openlp/core/ui/mediadockmanager.py index 4d76075df..0873133b2 100644 --- a/openlp/core/ui/mediadockmanager.py +++ b/openlp/core/ui/mediadockmanager.py @@ -25,7 +25,7 @@ import logging -log = logging.getLogger(u'MediaDockManager') +log = logging.getLogger(__name__) class MediaDockManager(object): @@ -58,4 +58,4 @@ class MediaDockManager(object): if self.media_dock.widget(dock_index): if self.media_dock.widget(dock_index).ConfigSection == name: self.media_dock.widget(dock_index).hide() - self.media_dock.removeItem(dock_index) \ No newline at end of file + self.media_dock.removeItem(dock_index) diff --git a/openlp/core/ui/settingsform.py b/openlp/core/ui/settingsform.py index c8989625d..4a3902347 100644 --- a/openlp/core/ui/settingsform.py +++ b/openlp/core/ui/settingsform.py @@ -31,7 +31,7 @@ from openlp.core.ui import GeneralTab, ThemesTab from openlp.core.lib import Receiver from settingsdialog import Ui_SettingsDialog -log = logging.getLogger(u'SettingsForm') +log = logging.getLogger(__name__) class SettingsForm(QtGui.QDialog, Ui_SettingsDialog): From 763b7cfeedca1277743c5bd40049f55874a8e992 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Fri, 5 Mar 2010 09:24:42 +0000 Subject: [PATCH 09/11] Fix up context menu for serviceitem --- openlp/core/ui/servicemanager.py | 116 +++++++++++++------------------ 1 file changed, 47 insertions(+), 69 deletions(-) diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 6a9223508..324dd1ec3 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -34,7 +34,7 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import PluginConfig, OpenLPToolbar, ServiceItem, \ contextMenuAction, contextMenuSeparator, contextMenu, Receiver, \ - contextMenu, str_to_bool + contextMenu, str_to_bool, build_icon from openlp.core.ui import ServiceItemNoteForm class ServiceManagerList(QtGui.QTreeWidget): @@ -44,44 +44,6 @@ class ServiceManagerList(QtGui.QTreeWidget): self.parent = parent self.setExpandsOnDoubleClick(False) - def mousePressEvent(self, event): - #Implement item selection - item = self.itemAt(event.pos()) - if item is not None: - self.setCurrentItem(item) - parentitem = item.parent() - if event.button() == QtCore.Qt.RightButton: - self.parent.noteAction.setVisible(False) - if parentitem is None: - pos = item.data(0, QtCore.Qt.UserRole).toInt()[0] - self.parent.noteAction.setVisible(True) - else: - pos = parentitem.data(0, QtCore.Qt.UserRole).toInt()[0] - serviceItem = self.parent.serviceItems[pos - 1] - if serviceItem[u'service_item'].is_text(): - self.parent.themeMenu.menuAction().setVisible(True) - else: - self.parent.themeMenu.menuAction().setVisible(False) - if serviceItem[u'service_item'].edit_enabled: - self.parent.editAction.setVisible(True) - else: - self.parent.editAction.setVisible(False) - event.accept() - elif event.button() == QtCore.Qt.LeftButton: - if parentitem is None: - if self.isItemExpanded(item): - self.collapseItem(item) - else: - self.expandItem(item) - else: - event.accept() - else: - event.accept() - - def mouseDoubleClickEvent(self, event): - self.parent.makeLive() - event.accept() - def keyPressEvent(self, event): if type(event) == QtGui.QKeyEvent: #here accept the event and do something @@ -186,41 +148,13 @@ class ServiceManager(QtGui.QWidget): self.ServiceManagerList.setAlternatingRowColors(True) self.ServiceManagerList.setHeaderHidden(True) self.ServiceManagerList.setExpandsOnDoubleClick(False) + self.ServiceManagerList.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) + self.ServiceManagerList.customContextMenuRequested.connect(self.contextMenu) self.ServiceManagerList.setObjectName(u'ServiceManagerList') # enable drop self.ServiceManagerList.__class__.dragEnterEvent = self.dragEnterEvent self.ServiceManagerList.__class__.dragMoveEvent = self.dragEnterEvent self.ServiceManagerList.__class__.dropEvent = self.dropEvent - # Add a context menu to the service manager list - self.ServiceManagerList.setContextMenuPolicy( - QtCore.Qt.ActionsContextMenu) - self.editAction = contextMenuAction( - self.ServiceManagerList, ':/services/service_edit.png', - self.trUtf8('&Edit Item'), self.remoteEdit) - self.noteAction = contextMenuAction( - self.ServiceManagerList, ':/services/service_notes.png', - self.trUtf8('&Notes'), self.onServiceItemNoteForm) - self.ServiceManagerList.addAction(self.editAction) - self.ServiceManagerList.addAction(self.noteAction) - self.ServiceManagerList.addAction(contextMenuSeparator( - self.ServiceManagerList)) - self.ServiceManagerList.addAction(contextMenuAction( - self.ServiceManagerList, ':/system/system_preview.png', - self.trUtf8('&Preview Verse'), self.makePreview)) - self.ServiceManagerList.addAction(contextMenuAction( - self.ServiceManagerList, ':/system/system_live.png', - self.trUtf8('&Show Live'), self.makeLive)) - self.ServiceManagerList.addAction(contextMenuSeparator( - self.ServiceManagerList)) - self.ServiceManagerList.addAction(contextMenuAction( - self.ServiceManagerList, ':/services/service_delete', - self.trUtf8('&Remove from Service'), self.onDeleteFromService)) - self.ServiceManagerList.addAction(contextMenuSeparator( - self.ServiceManagerList)) - self.themeMenu = contextMenu( - self.ServiceManagerList, '', - self.trUtf8('&Change Item Theme')) - self.ServiceManagerList.addAction(self.themeMenu.menuAction()) self.Layout.addWidget(self.ServiceManagerList) # Add the bottom toolbar self.OrderToolbar = OpenLPToolbar(self) @@ -244,6 +178,8 @@ class ServiceManager(QtGui.QWidget): # Connect up our signals and slots QtCore.QObject.connect(self.ThemeComboBox, QtCore.SIGNAL(u'activated(int)'), self.onThemeComboBoxSelected) + QtCore.QObject.connect(self.ServiceManagerList, + QtCore.SIGNAL(u'doubleClicked(QModelIndex)'), self.makeLive) QtCore.QObject.connect(self.ServiceManagerList, QtCore.SIGNAL(u'itemCollapsed(QTreeWidgetItem*)'), self.collapsed) QtCore.QObject.connect(self.ServiceManagerList, @@ -261,6 +197,48 @@ class ServiceManager(QtGui.QWidget): self.servicePath = self.config.get_data_path() self.service_theme = unicode( self.config.get_config(u'service theme', u'')) + #build the context menu + self.menu = QtGui.QMenu() + self.editAction = self.menu.addAction(self.trUtf8('&Edit Item')) + self.editAction.setIcon(build_icon(':/services/service_edit.png')) + self.notesAction = self.menu.addAction(self.trUtf8('&Notes')) + self.notesAction.setIcon(build_icon(':/services/service_notes.png')) + self.sep1 = self.menu.addAction(u'') + self.sep1.setSeparator(True) + self.previewAction = self.menu.addAction(self.trUtf8('&Preview Verse')) + self.previewAction.setIcon(build_icon(':/system/system_preview.png')) + self.liveAction = self.menu.addAction(self.trUtf8('&Live Verse')) + self.liveAction.setIcon(build_icon(':/system/system_live.png')) + self.sep2 = self.menu.addAction(u'') + self.sep2.setSeparator(True) + self.themeMenu = QtGui.QMenu(self.trUtf8('&Change Item Theme')) + self.menu.addMenu(self.themeMenu) + + def contextMenu(self, point): + item = self.ServiceManagerList.itemAt(point) + if item.parent() is None: + pos = item.data(0, QtCore.Qt.UserRole).toInt()[0] + else: + pos = item.parent().data(0, QtCore.Qt.UserRole).toInt()[0] + serviceItem = self.serviceItems[pos - 1] + self.editAction.setVisible(False) + self.notesAction.setVisible(False) + if serviceItem[u'service_item'].edit_enabled: + self.editAction.setVisible(True) + if item.parent() is None: + self.notesAction.setVisible(True) + self.themeMenu.menuAction().setVisible(False) + if serviceItem[u'service_item'].is_text(): + self.themeMenu.menuAction().setVisible(True) + action = self.menu.exec_(self.ServiceManagerList.mapToGlobal(point)) + if action == self.editAction: + self.remoteEdit() + if action == self.notesAction: + self.onServiceItemNoteForm() + if action == self.previewAction: + self.makePreview() + if action == self.liveAction: + self.makeLive() def onPresentationTypes(self, presentation_types): self.presentation_types = presentation_types From d2b4bc4314a13d173bc3456ddde0286cf708a5cc Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Fri, 5 Mar 2010 10:04:49 +0000 Subject: [PATCH 10/11] Fix up Copyright and utf8 --- openlp/core/ui/serviceitemdialog.py | 41 ++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 13 deletions(-) diff --git a/openlp/core/ui/serviceitemdialog.py b/openlp/core/ui/serviceitemdialog.py index 150375da9..1fe86a913 100644 --- a/openlp/core/ui/serviceitemdialog.py +++ b/openlp/core/ui/serviceitemdialog.py @@ -1,34 +1,49 @@ # -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 -# Form implementation generated from reading ui file 'serviceitemdialog.ui' -# -# Created: Tue Mar 2 20:17:21 2010 -# by: PyQt4 UI code generator 4.7 -# -# WARNING! All changes made in this file will be lost! +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2010 Raoul Snyman # +# Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael # +# Gorven, Scott Guerrieri, 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 # +############################################################################### from PyQt4 import QtCore, QtGui class Ui_ServiceNoteEdit(object): def setupUi(self, ServiceNoteEdit): - ServiceNoteEdit.setObjectName("ServiceNoteEdit") + ServiceNoteEdit.setObjectName(u'ServiceNoteEdit') ServiceNoteEdit.resize(400, 243) self.widget = QtGui.QWidget(ServiceNoteEdit) self.widget.setGeometry(QtCore.QRect(20, 10, 361, 223)) - self.widget.setObjectName("widget") + self.widget.setObjectName(u'widget') self.verticalLayout = QtGui.QVBoxLayout(self.widget) - self.verticalLayout.setObjectName("verticalLayout") + self.verticalLayout.setObjectName(u'verticalLayout') self.textEdit = QtGui.QTextEdit(self.widget) - self.textEdit.setObjectName("textEdit") + self.textEdit.setObjectName(u'textEdit') self.verticalLayout.addWidget(self.textEdit) self.buttonBox = QtGui.QDialogButtonBox(self.widget) self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Save) - self.buttonBox.setObjectName("buttonBox") + self.buttonBox.setObjectName(u'buttonBox') self.verticalLayout.addWidget(self.buttonBox) self.retranslateUi(ServiceNoteEdit) QtCore.QMetaObject.connectSlotsByName(ServiceNoteEdit) def retranslateUi(self, ServiceNoteEdit): - ServiceNoteEdit.setWindowTitle(QtGui.QApplication.translate("ServiceNoteEdit", "Service Item Notes", None, QtGui.QApplication.UnicodeUTF8)) - + ServiceNoteEdit.setWindowTitle(self.trUtf8('Service Item Notes')) From eec672c944e70d6974fe1d8a18d32729f6b623ab Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Fri, 5 Mar 2010 12:06:19 +0000 Subject: [PATCH 11/11] Fix up bug for Theme savings and OOS --- openlp/core/ui/servicemanager.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 324dd1ec3..ad0da357b 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -590,9 +590,14 @@ class ServiceManager(QtGui.QWidget): self.parent.RenderManager.themedata = None if len(self.serviceItems) > 0: tempServiceItems = self.serviceItems - self.onNewService() + self.ServiceManagerList.clear() + self.serviceItems = [] + self.isNew = True for item in tempServiceItems: self.addServiceItem(item[u'service_item'], True) + #Set to False as items may have changed rendering + #does not impact the saved song so True may aslo be valid + self.parent.serviceChanged(False, self.serviceName) def addServiceItem(self, item, rebuild=False): """