forked from openlp/openlp
Bootstrap cleanup
This commit is contained in:
parent
de6ce12092
commit
e8b123925f
@ -43,7 +43,7 @@ from traceback import format_exception
|
|||||||
|
|
||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
|
|
||||||
from openlp.core.lib import Settings, ScreenList, UiStrings, Registry, check_directory_exists, bootstrap
|
from openlp.core.lib import Settings, ScreenList, UiStrings, Registry, check_directory_exists
|
||||||
from openlp.core.resources import qInitResources
|
from openlp.core.resources import qInitResources
|
||||||
from openlp.core.ui.mainwindow import MainWindow
|
from openlp.core.ui.mainwindow import MainWindow
|
||||||
from openlp.core.ui.firsttimelanguageform import FirstTimeLanguageForm
|
from openlp.core.ui.firsttimelanguageform import FirstTimeLanguageForm
|
||||||
@ -135,7 +135,6 @@ class OpenLP(QtGui.QApplication):
|
|||||||
# make sure Qt really display the splash screen
|
# make sure Qt really display the splash screen
|
||||||
self.processEvents()
|
self.processEvents()
|
||||||
# start the main app window
|
# start the main app window
|
||||||
bootstrap()
|
|
||||||
self.main_window = MainWindow()
|
self.main_window = MainWindow()
|
||||||
self.main_window.show()
|
self.main_window.show()
|
||||||
if show_splash:
|
if show_splash:
|
||||||
|
@ -386,35 +386,6 @@ def create_separated_list(stringlist):
|
|||||||
return translate('OpenLP.core.lib', '%s, %s', u'Locale list separator: start') % (stringlist[0], merged)
|
return translate('OpenLP.core.lib', '%s, %s', u'Locale list separator: start') % (stringlist[0], merged)
|
||||||
|
|
||||||
|
|
||||||
def bootstrap():
|
|
||||||
"""
|
|
||||||
Bootstrap control function to build all the components and initialise them.
|
|
||||||
"""
|
|
||||||
print "bs"
|
|
||||||
bootstrap_phase_1()
|
|
||||||
bootstrap_phase_2()
|
|
||||||
|
|
||||||
|
|
||||||
def bootstrap_phase_1():
|
|
||||||
"""
|
|
||||||
Bootstrap phase to define all the components so they are registered correctly.
|
|
||||||
"""
|
|
||||||
print "ba1"
|
|
||||||
from openlp.core.lib import ImageManager
|
|
||||||
ImageManager()
|
|
||||||
|
|
||||||
|
|
||||||
def bootstrap_phase_2():
|
|
||||||
"""
|
|
||||||
Bootstrap phase to initialise any components.
|
|
||||||
"""
|
|
||||||
print "bs2"
|
|
||||||
from openlp.core.lib import Settings, PluginManager
|
|
||||||
from openlp.core.utils import AppLocation
|
|
||||||
Settings().set_up_default_values()
|
|
||||||
Settings().remove_obsolete_settings()
|
|
||||||
PluginManager(AppLocation.get_directory(AppLocation.PluginsDir))
|
|
||||||
|
|
||||||
from registry import Registry
|
from registry import Registry
|
||||||
from uistrings import UiStrings
|
from uistrings import UiStrings
|
||||||
from screen import ScreenList
|
from screen import ScreenList
|
||||||
|
@ -106,12 +106,12 @@ class Ui_MainWindow(object):
|
|||||||
self.mainContentLayout.addWidget(self.controlSplitter)
|
self.mainContentLayout.addWidget(self.controlSplitter)
|
||||||
# Create slide controllers
|
# Create slide controllers
|
||||||
self.previewController = SlideController(self)
|
self.previewController = SlideController(self)
|
||||||
self.liveController = SlideController(self, True)
|
self.live_controller = SlideController(self, True)
|
||||||
previewVisible = Settings().value(u'user interface/preview panel')
|
previewVisible = Settings().value(u'user interface/preview panel')
|
||||||
self.previewController.panel.setVisible(previewVisible)
|
self.previewController.panel.setVisible(previewVisible)
|
||||||
liveVisible = Settings().value(u'user interface/live panel')
|
liveVisible = Settings().value(u'user interface/live panel')
|
||||||
panelLocked = Settings().value(u'user interface/lock panel')
|
panelLocked = Settings().value(u'user interface/lock panel')
|
||||||
self.liveController.panel.setVisible(liveVisible)
|
self.live_controller.panel.setVisible(liveVisible)
|
||||||
# Create menu
|
# Create menu
|
||||||
self.menuBar = QtGui.QMenuBar(main_window)
|
self.menuBar = QtGui.QMenuBar(main_window)
|
||||||
self.menuBar.setObjectName(u'menuBar')
|
self.menuBar.setObjectName(u'menuBar')
|
||||||
@ -475,9 +475,11 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
|||||||
self.playersSettingsSection = u'players'
|
self.playersSettingsSection = u'players'
|
||||||
self.displayTagsSection = u'displayTags'
|
self.displayTagsSection = u'displayTags'
|
||||||
self.headerSection = u'SettingsImport'
|
self.headerSection = u'SettingsImport'
|
||||||
|
Settings().set_up_default_values()
|
||||||
|
Settings().remove_obsolete_settings()
|
||||||
self.serviceNotSaved = False
|
self.serviceNotSaved = False
|
||||||
self.aboutForm = AboutForm(self)
|
self.aboutForm = AboutForm(self)
|
||||||
self.mediaController = MediaController(self)
|
self.media_controller = MediaController(self)
|
||||||
self.settingsForm = SettingsForm(self)
|
self.settingsForm = SettingsForm(self)
|
||||||
self.formattingTagForm = FormattingTagForm(self)
|
self.formattingTagForm = FormattingTagForm(self)
|
||||||
self.shortcutForm = ShortcutListForm(self)
|
self.shortcutForm = ShortcutListForm(self)
|
||||||
@ -485,10 +487,12 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
|||||||
self.timer_id = 0
|
self.timer_id = 0
|
||||||
self.timer_version_id = 0
|
self.timer_version_id = 0
|
||||||
# Set up the path with plugins
|
# Set up the path with plugins
|
||||||
|
self.plugin_manager = PluginManager(AppLocation.get_directory(AppLocation.PluginsDir))
|
||||||
|
self.image_manager = ImageManager()
|
||||||
# Set up the interface
|
# Set up the interface
|
||||||
self.setupUi(self)
|
self.setupUi(self)
|
||||||
# Register the active media players and suffixes
|
# Register the active media players and suffixes
|
||||||
self.mediaController.check_available_media_players()
|
self.media_controller.check_available_media_players()
|
||||||
# Load settings after setupUi so default UI sizes are overwritten
|
# Load settings after setupUi so default UI sizes are overwritten
|
||||||
self.loadSettings()
|
self.loadSettings()
|
||||||
# Once settings are loaded update the menu with the recent files.
|
# Once settings are loaded update the menu with the recent files.
|
||||||
@ -557,7 +561,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
|||||||
self.plugin_manager.initialise_plugins()
|
self.plugin_manager.initialise_plugins()
|
||||||
# Create the displays as all necessary components are loaded.
|
# Create the displays as all necessary components are loaded.
|
||||||
self.previewController.screenSizeChanged()
|
self.previewController.screenSizeChanged()
|
||||||
self.liveController.screenSizeChanged()
|
self.live_controller.screenSizeChanged()
|
||||||
log.info(u'Load data from Settings')
|
log.info(u'Load data from Settings')
|
||||||
if Settings().value(u'advanced/save current plugin'):
|
if Settings().value(u'advanced/save current plugin'):
|
||||||
savedPlugin = Settings().value(u'advanced/current media plugin')
|
savedPlugin = Settings().value(u'advanced/current media plugin')
|
||||||
@ -601,8 +605,8 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
|||||||
Show the main form, as well as the display form
|
Show the main form, as well as the display form
|
||||||
"""
|
"""
|
||||||
QtGui.QWidget.show(self)
|
QtGui.QWidget.show(self)
|
||||||
if self.liveController.display.isVisible():
|
if self.live_controller.display.isVisible():
|
||||||
self.liveController.display.setFocus()
|
self.live_controller.display.setFocus()
|
||||||
self.activateWindow()
|
self.activateWindow()
|
||||||
if self.arguments:
|
if self.arguments:
|
||||||
args = []
|
args = []
|
||||||
@ -695,7 +699,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
|||||||
Check and display message if screen blank on setup.
|
Check and display message if screen blank on setup.
|
||||||
"""
|
"""
|
||||||
settings = Settings()
|
settings = Settings()
|
||||||
self.liveController.mainDisplaySetBackground()
|
self.live_controller.mainDisplaySetBackground()
|
||||||
if settings.value(u'%s/screen blank' % self.generalSettingsSection):
|
if settings.value(u'%s/screen blank' % self.generalSettingsSection):
|
||||||
if settings.value(u'%s/blank warning' % self.generalSettingsSection):
|
if settings.value(u'%s/blank warning' % self.generalSettingsSection):
|
||||||
QtGui.QMessageBox.question(self, translate('OpenLP.MainWindow', 'OpenLP Main Display Blanked'),
|
QtGui.QMessageBox.question(self, translate('OpenLP.MainWindow', 'OpenLP Main Display Blanked'),
|
||||||
@ -803,7 +807,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
|||||||
We need to make sure, that the SlidePreview's size is correct.
|
We need to make sure, that the SlidePreview's size is correct.
|
||||||
"""
|
"""
|
||||||
self.previewController.previewSizeChanged()
|
self.previewController.previewSizeChanged()
|
||||||
self.liveController.previewSizeChanged()
|
self.live_controller.previewSizeChanged()
|
||||||
|
|
||||||
def onSettingsShortcutsItemClicked(self):
|
def onSettingsShortcutsItemClicked(self):
|
||||||
"""
|
"""
|
||||||
@ -1014,7 +1018,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
|||||||
self.image_manager.update_display()
|
self.image_manager.update_display()
|
||||||
self.renderer.update_display()
|
self.renderer.update_display()
|
||||||
self.previewController.screenSizeChanged()
|
self.previewController.screenSizeChanged()
|
||||||
self.liveController.screenSizeChanged()
|
self.live_controller.screenSizeChanged()
|
||||||
self.setFocus()
|
self.setFocus()
|
||||||
self.activateWindow()
|
self.activateWindow()
|
||||||
self.application.set_normal_cursor()
|
self.application.set_normal_cursor()
|
||||||
@ -1085,9 +1089,9 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
|||||||
if self.new_data_path:
|
if self.new_data_path:
|
||||||
self.changeDataDirectory()
|
self.changeDataDirectory()
|
||||||
# Close down the display
|
# Close down the display
|
||||||
if self.liveController.display:
|
if self.live_controller.display:
|
||||||
self.liveController.display.close()
|
self.live_controller.display.close()
|
||||||
self.liveController.display = None
|
self.live_controller.display = None
|
||||||
|
|
||||||
def serviceChanged(self, reset=False, serviceName=None):
|
def serviceChanged(self, reset=False, serviceName=None):
|
||||||
"""
|
"""
|
||||||
@ -1168,7 +1172,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
|||||||
True - Visible
|
True - Visible
|
||||||
False - Hidden
|
False - Hidden
|
||||||
"""
|
"""
|
||||||
self.previewController.panel.setVisible(visible)
|
self.preview_controller.panel.setVisible(visible)
|
||||||
Settings().setValue(u'user interface/preview panel', visible)
|
Settings().setValue(u'user interface/preview panel', visible)
|
||||||
self.viewPreviewPanel.setChecked(visible)
|
self.viewPreviewPanel.setChecked(visible)
|
||||||
|
|
||||||
@ -1206,7 +1210,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
|||||||
True - Visible
|
True - Visible
|
||||||
False - Hidden
|
False - Hidden
|
||||||
"""
|
"""
|
||||||
self.liveController.panel.setVisible(visible)
|
self.live_controller.panel.setVisible(visible)
|
||||||
Settings().setValue(u'user interface/live panel', visible)
|
Settings().setValue(u'user interface/live panel', visible)
|
||||||
self.viewLivePanel.setChecked(visible)
|
self.viewLivePanel.setChecked(visible)
|
||||||
|
|
||||||
@ -1226,8 +1230,8 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
|||||||
self.move(settings.value(u'main window position'))
|
self.move(settings.value(u'main window position'))
|
||||||
self.restoreGeometry(settings.value(u'main window geometry'))
|
self.restoreGeometry(settings.value(u'main window geometry'))
|
||||||
self.restoreState(settings.value(u'main window state'))
|
self.restoreState(settings.value(u'main window state'))
|
||||||
self.liveController.splitter.restoreState(settings.value(u'live splitter geometry'))
|
self.live_controller.splitter.restoreState(settings.value(u'live splitter geometry'))
|
||||||
self.previewController.splitter.restoreState(settings.value(u'preview splitter geometry'))
|
self.preview_controller.splitter.restoreState(settings.value(u'preview splitter geometry'))
|
||||||
self.controlSplitter.restoreState(settings.value(u'main window splitter geometry'))
|
self.controlSplitter.restoreState(settings.value(u'main window splitter geometry'))
|
||||||
settings.endGroup()
|
settings.endGroup()
|
||||||
|
|
||||||
@ -1247,8 +1251,8 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
|||||||
settings.setValue(u'main window position', self.pos())
|
settings.setValue(u'main window position', self.pos())
|
||||||
settings.setValue(u'main window state', self.saveState())
|
settings.setValue(u'main window state', self.saveState())
|
||||||
settings.setValue(u'main window geometry', self.saveGeometry())
|
settings.setValue(u'main window geometry', self.saveGeometry())
|
||||||
settings.setValue(u'live splitter geometry', self.liveController.splitter.saveState())
|
settings.setValue(u'live splitter geometry', self.live_controller.splitter.saveState())
|
||||||
settings.setValue(u'preview splitter geometry', self.previewController.splitter.saveState())
|
settings.setValue(u'preview splitter geometry', self.preview_controller.splitter.saveState())
|
||||||
settings.setValue(u'main window splitter geometry', self.controlSplitter.saveState())
|
settings.setValue(u'main window splitter geometry', self.controlSplitter.saveState())
|
||||||
settings.endGroup()
|
settings.endGroup()
|
||||||
|
|
||||||
@ -1404,23 +1408,3 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
|||||||
return self._application
|
return self._application
|
||||||
|
|
||||||
application = property(_get_application)
|
application = property(_get_application)
|
||||||
|
|
||||||
def _get_plugin_manager(self):
|
|
||||||
"""
|
|
||||||
Adds the plugin manager to the class dynamically
|
|
||||||
"""
|
|
||||||
if not hasattr(self, u'_plugin_manager'):
|
|
||||||
self._plugin_manager = Registry().get(u'plugin_manager')
|
|
||||||
return self._plugin_manager
|
|
||||||
|
|
||||||
plugin_manager = property(_get_plugin_manager)
|
|
||||||
|
|
||||||
def _get_image_manager(self):
|
|
||||||
"""
|
|
||||||
Adds the image manager to the class dynamically
|
|
||||||
"""
|
|
||||||
if not hasattr(self, u'_image_manager'):
|
|
||||||
self._image_manager = Registry().get(u'image_manager')
|
|
||||||
return self._image_manager
|
|
||||||
|
|
||||||
image_manager = property(_get_image_manager)
|
|
||||||
|
Loading…
Reference in New Issue
Block a user