updates and fix up slidecontroller

This commit is contained in:
Tim Bentley 2013-12-19 20:17:06 +00:00
parent e9a7850bc8
commit d4ce5489ad
8 changed files with 88 additions and 50 deletions

View File

@ -151,7 +151,7 @@ class OpenLP(QtGui.QApplication):
update_check = Settings().value('core/update check') update_check = Settings().value('core/update check')
if update_check: if update_check:
VersionThread(self.main_window).start() VersionThread(self.main_window).start()
self.main_window.is_display_blank() #self.main_window.is_display_blank()
self.main_window.app_startup() self.main_window.app_startup()
return self.exec_() return self.exec_()

View File

@ -40,12 +40,15 @@ class OpenLPMixin(object):
""" """
Base Calling object for OpenLP classes. Base Calling object for OpenLP classes.
""" """
def __init__(self): def __init__(self, parent):
super().__init__() try:
self.logger = logging.getLogger(self.__module__) 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): for name, m in inspect.getmembers(self, inspect.ismethod):
if name not in DO_NOT_TRACE_EVENTS: 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)) setattr(self, name, self.logging_wrapper(m, self))
def logging_wrapper(self, func, parent): def logging_wrapper(self, func, parent):

View File

@ -80,7 +80,7 @@ class Registry(object):
else: else:
trace_error_handler(log) trace_error_handler(log)
log.error('Service %s not found in list' % key) 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): def register(self, key, reference):
""" """

View File

@ -29,8 +29,6 @@
""" """
Provide Registry Services Provide Registry Services
""" """
from openlp.core.common import Registry, de_hump 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. This adds registry components to classes to use at run time.
""" """
def __init__(self): def __init__(self, parent):
""" """
Register the class and bootstrap hooks. 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(de_hump(self.__class__.__name__), self)
Registry().register_function('bootstrap_initialise', self.bootstrap_initialise) Registry().register_function('bootstrap_initialise', self.bootstrap_initialise)
Registry().register_function('bootstrap_post_set_up', self.bootstrap_post_set_up) Registry().register_function('bootstrap_post_set_up', self.bootstrap_post_set_up)
super().__init__()
def bootstrap_initialise(self): def bootstrap_initialise(self):
""" """

View File

@ -37,17 +37,17 @@ from openlp.core.lib import Plugin, PluginStatus
from openlp.core.common import AppLocation, Registry, OpenLPMixin, RegistryMixin 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, This is the Plugin manager, which loads all the plugins,
and executes all the hooks, as and when necessary. 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 constructor for the plugin manager. Passes the controllers on to
the plugins for them to interact with via their ServiceItems. 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.log_info('Plugin manager Initialising')
self.base_path = os.path.abspath(AppLocation.get_directory(AppLocation.PluginsDir)) self.base_path = os.path.abspath(AppLocation.get_directory(AppLocation.PluginsDir))
self.log_debug('Base path %s ' % self.base_path) self.log_debug('Base path %s ' % self.base_path)

View File

@ -86,7 +86,7 @@ from .starttimeform import StartTimeForm
from .maindisplay import MainDisplay, Display from .maindisplay import MainDisplay, Display
from .servicenoteform import ServiceNoteForm from .servicenoteform import ServiceNoteForm
from .serviceitemeditform import ServiceItemEditForm from .serviceitemeditform import ServiceItemEditForm
from .slidecontroller import SlideController, DisplayController from .slidecontroller import SlideController, DisplayController, PreviewController, LiveController
from .splashscreen import SplashScreen from .splashscreen import SplashScreen
from .generaltab import GeneralTab from .generaltab import GeneralTab
from .themestab import ThemesTab from .themestab import ThemesTab

View File

@ -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, \ from openlp.core.lib import Renderer, OpenLPDockWidget, PluginManager, ImageManager, PluginStatus, ScreenList, \
build_icon build_icon
from openlp.core.lib.ui import UiStrings, create_action from openlp.core.lib.ui import UiStrings, create_action
from openlp.core.ui import AboutForm, SettingsForm, ServiceManager, ThemeManager, SlideController, PluginForm, \ from openlp.core.ui import AboutForm, SettingsForm, ServiceManager, ThemeManager, LiveController, PluginForm, \
MediaDockManager, ShortcutListForm, FormattingTagForm MediaDockManager, ShortcutListForm, FormattingTagForm, PreviewController
from openlp.core.ui.media import MediaController from openlp.core.ui.media import MediaController
from openlp.core.utils import LanguageManager, add_actions, get_application_version 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.control_splitter.setObjectName('control_splitter')
self.main_contentLayout.addWidget(self.control_splitter) self.main_contentLayout.addWidget(self.control_splitter)
# Create slide controllers # Create slide controllers
self.preview_controller = SlideController(self) self.preview_controller = PreviewController(self)
self.live_controller = SlideController(self, True) self.live_controller = LiveController(self)
preview_visible = Settings().value('user interface/preview panel') 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') live_visible = Settings().value('user interface/live panel')
panel_locked = Settings().value('user interface/lock 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 # Create menu
self.menu_bar = QtGui.QMenuBar(main_window) self.menu_bar = QtGui.QMenuBar(main_window)
self.menu_bar.setObjectName('menu_bar') self.menu_bar.setObjectName('menu_bar')
@ -504,7 +504,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
self.formatting_tag_form = FormattingTagForm(self) self.formatting_tag_form = FormattingTagForm(self)
self.shortcut_form = ShortcutListForm(self) self.shortcut_form = ShortcutListForm(self)
# Set up the path with plugins # Set up the path with plugins
self.plugin_manager = PluginManager() self.plugin_manager = PluginManager(self)
self.image_manager = ImageManager() self.image_manager = ImageManager()
# Set up the interface # Set up the interface
self.setupUi(self) self.setupUi(self)
@ -592,6 +592,9 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
""" """
QtGui.QWidget.show(self) QtGui.QWidget.show(self)
if self.live_controller.display.isVisible(): if self.live_controller.display.isVisible():
self.live_controller.display.setFocus() self.live_controller.display.setFocus()
self.activateWindow() self.activateWindow()
if self.arguments: if self.arguments:
@ -1194,8 +1197,8 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
self.move(settings.value('main window position')) self.move(settings.value('main window position'))
self.restoreGeometry(settings.value('main window geometry')) self.restoreGeometry(settings.value('main window geometry'))
self.restoreState(settings.value('main window state')) self.restoreState(settings.value('main window state'))
self.live_controller.splitter.restoreState(settings.value('live splitter geometry')) #self.live_controller.splitter.restoreState(settings.value('live splitter geometry'))
self.preview_controller.splitter.restoreState(settings.value('preview splitter geometry')) #self.preview_controller.splitter.restoreState(settings.value('preview splitter geometry'))
self.control_splitter.restoreState(settings.value('main window 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 #This needs to be called after restoreState(), because saveState() also saves the "Collapsible" property
#which was True (by default) < OpenLP 2.1. #which was True (by default) < OpenLP 2.1.

View File

@ -80,12 +80,12 @@ class DisplayController(QtGui.QWidget):
""" """
Controller is a general display controller widget. Controller is a general display controller widget.
""" """
def __init__(self, parent, is_live=False): def __init__(self, parent):
""" """
Set up the general Controller. Set up the general Controller.
""" """
super(DisplayController, self).__init__(parent) super(DisplayController, self).__init__(parent)
self.is_live = is_live self.is_live = False
self.display = None self.display = None
self.controller_type = DisplayControllerType.Plugin self.controller_type = DisplayControllerType.Plugin
@ -105,12 +105,20 @@ class SlideController(DisplayController):
SlideController is the slide controller widget. This widget is what the SlideController is the slide controller widget. This widget is what the
user uses to control the displaying of verses/slides/etc on the screen. 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. Set up the Slide Controller.
""" """
super(SlideController, self).__init__(parent, is_live) super(SlideController, self).__init__(parent)
Registry().register_function('bootstrap_post_set_up', self.bootstrap_post_set_up)
def post_set_up(self):
"""
Call by bootstrap functions
"""
self.initialise()
self.screen_size_changed()
def initialise(self):
self.screens = ScreenList() self.screens = ScreenList()
try: try:
self.ratio = self.screens.current['size'].width() / self.screens.current['size'].height() self.ratio = self.screens.current['size'].width() / self.screens.current['size'].height()
@ -122,7 +130,7 @@ class SlideController(DisplayController):
self.service_item = None self.service_item = None
self.slide_limits = None self.slide_limits = None
self.update_slide_limits() 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_list = {}
self.slide_count = 0 self.slide_count = 0
self.slide_image = None self.slide_image = None
@ -132,21 +140,6 @@ class SlideController(DisplayController):
self.panel_layout.setMargin(0) self.panel_layout.setMargin(0)
# Type label for the top of the slide controller # Type label for the top of the slide controller
self.type_label = QtGui.QLabel(self.panel) 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.setStyleSheet('font-weight: bold; font-size: 12pt;')
self.type_label.setAlignment(QtCore.Qt.AlignCenter) self.type_label.setAlignment(QtCore.Qt.AlignCenter)
self.panel_layout.addWidget(self.type_label) 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), QtCore.QObject.connect(self, QtCore.SIGNAL('slidecontroller_%s_previous' % self.type_prefix),
self.on_slide_selected_previous) self.on_slide_selected_previous)
def bootstrap_post_set_up(self):
"""
Call by bootstrap functions
"""
self.screen_size_changed()
def _slide_shortcut_activated(self): def _slide_shortcut_activated(self):
""" """
Called, when a shortcut has been activated to jump to a chorus, verse, etc. 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 return self._main_window
main_window = property(_get_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()