From d4ce5489ad4b6b0d590d18ee1b149e2761ec9a1f Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Thu, 19 Dec 2013 20:17:06 +0000 Subject: [PATCH] updates and fix up slidecontroller --- openlp/core/__init__.py | 2 +- openlp/core/common/openlpmixin.py | 11 ++-- openlp/core/common/registry.py | 2 +- openlp/core/common/registrymixin.py | 9 +-- openlp/core/lib/pluginmanager.py | 6 +- openlp/core/ui/__init__.py | 2 +- openlp/core/ui/mainwindow.py | 21 ++++--- openlp/core/ui/slidecontroller.py | 85 ++++++++++++++++++++--------- 8 files changed, 88 insertions(+), 50 deletions(-) diff --git a/openlp/core/__init__.py b/openlp/core/__init__.py index 0e69e2432..05b59e164 100644 --- a/openlp/core/__init__.py +++ b/openlp/core/__init__.py @@ -151,7 +151,7 @@ class OpenLP(QtGui.QApplication): update_check = Settings().value('core/update check') if update_check: VersionThread(self.main_window).start() - self.main_window.is_display_blank() + #self.main_window.is_display_blank() self.main_window.app_startup() return self.exec_() diff --git a/openlp/core/common/openlpmixin.py b/openlp/core/common/openlpmixin.py index 65d642f2c..1914be1b8 100644 --- a/openlp/core/common/openlpmixin.py +++ b/openlp/core/common/openlpmixin.py @@ -40,12 +40,15 @@ class OpenLPMixin(object): """ Base Calling object for OpenLP classes. """ - def __init__(self): - super().__init__() - self.logger = logging.getLogger(self.__module__) + def __init__(self, parent): + try: + super(OpenLPMixin, self).__init__(parent) + except TypeError: + super(OpenLPMixin, self).__init__() + self.logger = logging.getLogger("%s.%s" % (self.__module__, self.__class__.__name__)) for name, m in inspect.getmembers(self, inspect.ismethod): if name not in DO_NOT_TRACE_EVENTS: - if not name.startswith("_") and not name.startswith("log_"): + if not name.startswith("_") and not name.startswith("log"): setattr(self, name, self.logging_wrapper(m, self)) def logging_wrapper(self, func, parent): diff --git a/openlp/core/common/registry.py b/openlp/core/common/registry.py index 14f70e073..cbd685ba2 100644 --- a/openlp/core/common/registry.py +++ b/openlp/core/common/registry.py @@ -80,7 +80,7 @@ class Registry(object): else: trace_error_handler(log) log.error('Service %s not found in list' % key) - raise KeyError('Service %s not found in list' % key) + #raise KeyError('Service %s not found in list' % key) def register(self, key, reference): """ diff --git a/openlp/core/common/registrymixin.py b/openlp/core/common/registrymixin.py index 3330eb2a4..a474084b0 100644 --- a/openlp/core/common/registrymixin.py +++ b/openlp/core/common/registrymixin.py @@ -29,8 +29,6 @@ """ Provide Registry Services """ - - from openlp.core.common import Registry, de_hump @@ -38,14 +36,17 @@ class RegistryMixin(object): """ This adds registry components to classes to use at run time. """ - def __init__(self): + def __init__(self, parent): """ Register the class and bootstrap hooks. """ + try: + super(RegistryMixin, self).__init__(parent) + except TypeError: + super(RegistryMixin, self).__init__() Registry().register(de_hump(self.__class__.__name__), self) Registry().register_function('bootstrap_initialise', self.bootstrap_initialise) Registry().register_function('bootstrap_post_set_up', self.bootstrap_post_set_up) - super().__init__() def bootstrap_initialise(self): """ diff --git a/openlp/core/lib/pluginmanager.py b/openlp/core/lib/pluginmanager.py index 8c36466c0..0ff1285fc 100644 --- a/openlp/core/lib/pluginmanager.py +++ b/openlp/core/lib/pluginmanager.py @@ -37,17 +37,17 @@ from openlp.core.lib import Plugin, PluginStatus from openlp.core.common import AppLocation, Registry, OpenLPMixin, RegistryMixin -class PluginManager(OpenLPMixin, RegistryMixin): +class PluginManager(RegistryMixin, OpenLPMixin): """ This is the Plugin manager, which loads all the plugins, and executes all the hooks, as and when necessary. """ - def __init__(self): + def __init__(self, parent=None): """ The constructor for the plugin manager. Passes the controllers on to the plugins for them to interact with via their ServiceItems. """ - super(PluginManager, self).__init__() + super(PluginManager, self).__init__(parent) self.log_info('Plugin manager Initialising') self.base_path = os.path.abspath(AppLocation.get_directory(AppLocation.PluginsDir)) self.log_debug('Base path %s ' % self.base_path) diff --git a/openlp/core/ui/__init__.py b/openlp/core/ui/__init__.py index 691736c8f..9b4ca0c87 100644 --- a/openlp/core/ui/__init__.py +++ b/openlp/core/ui/__init__.py @@ -86,7 +86,7 @@ from .starttimeform import StartTimeForm from .maindisplay import MainDisplay, Display from .servicenoteform import ServiceNoteForm from .serviceitemeditform import ServiceItemEditForm -from .slidecontroller import SlideController, DisplayController +from .slidecontroller import SlideController, DisplayController, PreviewController, LiveController from .splashscreen import SplashScreen from .generaltab import GeneralTab from .themestab import ThemesTab diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 6f87ba77a..2e1e2c260 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -45,8 +45,8 @@ from openlp.core.common import Registry, AppLocation, Settings, check_directory_ from openlp.core.lib import Renderer, OpenLPDockWidget, PluginManager, ImageManager, PluginStatus, ScreenList, \ build_icon from openlp.core.lib.ui import UiStrings, create_action -from openlp.core.ui import AboutForm, SettingsForm, ServiceManager, ThemeManager, SlideController, PluginForm, \ - MediaDockManager, ShortcutListForm, FormattingTagForm +from openlp.core.ui import AboutForm, SettingsForm, ServiceManager, ThemeManager, LiveController, PluginForm, \ + MediaDockManager, ShortcutListForm, FormattingTagForm, PreviewController from openlp.core.ui.media import MediaController from openlp.core.utils import LanguageManager, add_actions, get_application_version @@ -106,13 +106,13 @@ class Ui_MainWindow(object): self.control_splitter.setObjectName('control_splitter') self.main_contentLayout.addWidget(self.control_splitter) # Create slide controllers - self.preview_controller = SlideController(self) - self.live_controller = SlideController(self, True) + self.preview_controller = PreviewController(self) + self.live_controller = LiveController(self) preview_visible = Settings().value('user interface/preview panel') - self.preview_controller.panel.setVisible(preview_visible) + #self.preview_controller.panel.setVisible(preview_visible) live_visible = Settings().value('user interface/live panel') panel_locked = Settings().value('user interface/lock panel') - self.live_controller.panel.setVisible(live_visible) + #self.live_controller.panel.setVisible(live_visible) # Create menu self.menu_bar = QtGui.QMenuBar(main_window) self.menu_bar.setObjectName('menu_bar') @@ -504,7 +504,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): self.formatting_tag_form = FormattingTagForm(self) self.shortcut_form = ShortcutListForm(self) # Set up the path with plugins - self.plugin_manager = PluginManager() + self.plugin_manager = PluginManager(self) self.image_manager = ImageManager() # Set up the interface self.setupUi(self) @@ -592,6 +592,9 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): """ QtGui.QWidget.show(self) if self.live_controller.display.isVisible(): + + + self.live_controller.display.setFocus() self.activateWindow() if self.arguments: @@ -1194,8 +1197,8 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): self.move(settings.value('main window position')) self.restoreGeometry(settings.value('main window geometry')) self.restoreState(settings.value('main window state')) - self.live_controller.splitter.restoreState(settings.value('live splitter geometry')) - self.preview_controller.splitter.restoreState(settings.value('preview splitter geometry')) + #self.live_controller.splitter.restoreState(settings.value('live splitter geometry')) + #self.preview_controller.splitter.restoreState(settings.value('preview splitter geometry')) self.control_splitter.restoreState(settings.value('main window splitter geometry')) #This needs to be called after restoreState(), because saveState() also saves the "Collapsible" property #which was True (by default) < OpenLP 2.1. diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index 64707b7c1..73c094016 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -80,12 +80,12 @@ class DisplayController(QtGui.QWidget): """ Controller is a general display controller widget. """ - def __init__(self, parent, is_live=False): + def __init__(self, parent): """ Set up the general Controller. """ super(DisplayController, self).__init__(parent) - self.is_live = is_live + self.is_live = False self.display = None self.controller_type = DisplayControllerType.Plugin @@ -105,12 +105,20 @@ class SlideController(DisplayController): SlideController is the slide controller widget. This widget is what the user uses to control the displaying of verses/slides/etc on the screen. """ - def __init__(self, parent, is_live=False): + def __init__(self, parent): """ Set up the Slide Controller. """ - super(SlideController, self).__init__(parent, is_live) - Registry().register_function('bootstrap_post_set_up', self.bootstrap_post_set_up) + super(SlideController, self).__init__(parent) + + def post_set_up(self): + """ + Call by bootstrap functions + """ + self.initialise() + self.screen_size_changed() + + def initialise(self): self.screens = ScreenList() try: self.ratio = self.screens.current['size'].width() / self.screens.current['size'].height() @@ -122,7 +130,7 @@ class SlideController(DisplayController): self.service_item = None self.slide_limits = None self.update_slide_limits() - self.panel = QtGui.QWidget(parent.control_splitter) + self.panel = QtGui.QWidget(self.main_window.control_splitter) self.slide_list = {} self.slide_count = 0 self.slide_image = None @@ -132,21 +140,6 @@ class SlideController(DisplayController): self.panel_layout.setMargin(0) # Type label for the top of the slide controller self.type_label = QtGui.QLabel(self.panel) - if self.is_live: - Registry().register('live_controller', self) - self.type_label.setText(UiStrings().Live) - self.split = 1 - self.type_prefix = 'live' - self.keypress_queue = deque() - self.keypress_loop = False - self.category = UiStrings().LiveToolbar - ActionList.get_instance().add_category(str(self.category), CategoryOrder.standard_toolbar) - else: - Registry().register('preview_controller', self) - self.type_label.setText(UiStrings().Preview) - self.split = 0 - self.type_prefix = 'preview' - self.category = None self.type_label.setStyleSheet('font-weight: bold; font-size: 12pt;') self.type_label.setAlignment(QtCore.Qt.AlignCenter) self.panel_layout.addWidget(self.type_label) @@ -392,12 +385,6 @@ class SlideController(DisplayController): QtCore.QObject.connect(self, QtCore.SIGNAL('slidecontroller_%s_previous' % self.type_prefix), self.on_slide_selected_previous) - def bootstrap_post_set_up(self): - """ - Call by bootstrap functions - """ - self.screen_size_changed() - def _slide_shortcut_activated(self): """ Called, when a shortcut has been activated to jump to a chorus, verse, etc. @@ -1350,3 +1337,47 @@ class SlideController(DisplayController): return self._main_window main_window = property(_get_main_window) + + +class PreviewController(RegistryMixin, SlideController, OpenLPMixin): + """ + Set up the Live Controller. + """ + def __init__(self, parent): + """ + Set up the general Controller. + """ + super(PreviewController, self).__init__(parent) + self.split = 0 + self.type_prefix = 'preview' + self.category = None + + def bootstrap_post_set_up(self): + """ + process the bootstrap post setup request + """ + self.post_set_up() + + +class LiveController(RegistryMixin, OpenLPMixin, SlideController): + """ + Set up the Live Controller. + """ + def __init__(self, parent): + """ + Set up the general Controller. + """ + super(LiveController, self).__init__(parent) + self.is_live = True + self.split = 1 + self.type_prefix = 'live' + self.keypress_queue = deque() + self.keypress_loop = False + self.category = UiStrings().LiveToolbar + ActionList.get_instance().add_category(str(self.category), CategoryOrder.standard_toolbar) + + def bootstrap_post_set_up(self): + """ + process the bootstrap post setup request + """ + self.post_set_up() \ No newline at end of file