Clean up complete for now

This commit is contained in:
Tim Bentley 2013-01-24 06:00:51 +00:00
parent c801e45668
commit 1e3590a152
4 changed files with 33 additions and 16 deletions

View File

@ -163,7 +163,7 @@ class Ui_MainWindow(object):
mainWindow.addDockWidget(QtCore.Qt.RightDockWidgetArea, self.serviceManagerDock)
# Create the theme manager
self.themeManagerDock = OpenLPDockWidget(mainWindow, u'themeManagerDock', u':/system/system_thememanager.png')
self.themeManagerContents = ThemeManager(mainWindow, self.themeManagerDock)
self.themeManagerContents = ThemeManager(self.themeManagerDock)
self.themeManagerContents.setObjectName(u'themeManagerContents')
self.themeManagerDock.setWidget(self.themeManagerContents)
mainWindow.addDockWidget(QtCore.Qt.RightDockWidgetArea, self.themeManagerDock)
@ -1330,3 +1330,4 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
# Check if the new data path is our default.
if self.newDataPath == AppLocation.get_directory(AppLocation.DataDir):
settings.remove(u'advanced/data path')

View File

@ -48,9 +48,6 @@ from openlp.core.ui.printserviceform import PrintServiceForm
from openlp.core.utils import AppLocation, delete_file, split_filename, format_time
from openlp.core.utils.actions import ActionList, CategoryOrder
ACTIVE = build_icon(QtGui.QImage(u':/media/auto-start_active.png'))
INACTIVE = build_icon(QtGui.QImage(u':/media/auto-start_inactive.png'))
class ServiceManagerList(QtGui.QTreeWidget):
"""
Set up key bindings and mouse behaviour for the service list
@ -106,6 +103,8 @@ class ServiceManager(QtGui.QWidget):
Sets up the service manager, toolbars, list view, et al.
"""
QtGui.QWidget.__init__(self, parent)
self.active = build_icon(QtGui.QImage(u':/media/auto-start_active.png'))
self.inactive = build_icon(QtGui.QImage(u':/media/auto-start_inactive.png'))
Registry().register(u'service_manager', self)
self.serviceItems = []
self.suffixes = []
@ -796,11 +795,11 @@ class ServiceManager(QtGui.QWidget):
self.timeAction.setVisible(True)
if serviceItem[u'service_item'].is_capable(ItemCapabilities.CanAutoStartForLive):
self.autoStartAction.setVisible(True)
self.autoStartAction.setIcon(INACTIVE)
self.autoStartAction.setIcon(self.inactive)
self.autoStartAction.setText(translate('OpenLP.ServiceManager','&Auto Start - inactive'))
if serviceItem[u'service_item'].will_auto_start:
self.autoStartAction.setText(translate('OpenLP.ServiceManager', '&Auto Start - active'))
self.autoStartAction.setIcon(ACTIVE)
self.autoStartAction.setIcon(self.active)
if serviceItem[u'service_item'].is_text():
for plugin in self.plugin_manager.plugins:
if plugin.name == u'custom' and plugin.status == PluginStatus.Active:

View File

@ -51,10 +51,9 @@ class ThemeManager(QtGui.QWidget):
"""
Manages the orders of Theme.
"""
def __init__(self, mainwindow, parent=None):
def __init__(self, parent=None):
QtGui.QWidget.__init__(self, parent)
Registry().register(u'theme_manager', self)
self.mainwindow = mainwindow
self.settingsSection = u'themes'
self.themeForm = ThemeForm(self)
self.fileRenameForm = FileRenameForm(self)
@ -681,11 +680,11 @@ class ThemeManager(QtGui.QWidget):
"""
Called to update the themes' preview images.
"""
self.mainwindow.displayProgressBar(len(self.themeList))
self.main_window.displayProgressBar(len(self.themeList))
for theme in self.themeList:
self.mainwindow.incrementProgressBar()
self.main_window.incrementProgressBar()
self.generateAndSaveImage(self.path, theme, self.getThemeData(theme))
self.mainwindow.finishedProgressBar()
self.main_window.finishedProgressBar()
self.loadThemes()
def generateImage(self, theme_data, forcePage=False):
@ -835,3 +834,13 @@ class ThemeManager(QtGui.QWidget):
return self._plugin_manager
plugin_manager = property(_get_plugin_manager)
def _get_main_window(self):
"""
Adds the main window to the class dynamically
"""
if not hasattr(self, u'_main_window'):
self._main_window = Registry().get(u'main_window')
return self._main_window
main_window = property(_get_main_window)

View File

@ -18,15 +18,23 @@ class TestServiceItem(TestCase):
# GIVEN: A new registry
registry = Registry.create()
# WHEN:A service item is created (without a plugin)
# WHEN: I add a service it should save it
mock_1 = MagicMock()
Registry().register(u'test1', mock_1)
# THEN: we should be able retrieve the saved object
assert Registry().get(u'test1') == mock_1, u'The saved object can be retrieved'
#assert service_item.missing_frames() is True, u'There should not be any frames in the service item'
assert Registry().get(u'test1') == mock_1, u'The saved service can be retrieved and matches'
# THEN: We should get back a valid service item
# WHEN: I add a service it should save it a second time
# THEN I will get an exception
try:
Registry().register(u'test1', mock_1)
except Exception, e:
pass
# WHEN I try to get back a non existent service
# THEN I will get an exception
try:
assert Registry().get(u'test2') == mock_1, u'This should not be fired'
except Exception, e: