forked from openlp/openlp
Fix widget
This commit is contained in:
parent
51178b2ede
commit
259b2b074f
@ -106,11 +106,11 @@ class Ui_ServiceManager(object):
|
||||
Define the UI
|
||||
"""
|
||||
# start with the layout
|
||||
self.layout = QtGui.QVBoxLayout(self)
|
||||
self.layout = QtGui.QVBoxLayout(widget)
|
||||
self.layout.setSpacing(0)
|
||||
self.layout.setMargin(0)
|
||||
# Create the top toolbar
|
||||
self.toolbar = OpenLPToolbar(self)
|
||||
self.toolbar = OpenLPToolbar(widget)
|
||||
self.toolbar.add_toolbar_action('newService', text=UiStrings().NewService, icon=':/general/general_new.png',
|
||||
tooltip=UiStrings().CreateService, triggers=self.on_new_service_clicked)
|
||||
self.toolbar.add_toolbar_action('openService', text=UiStrings().OpenService,
|
||||
@ -122,7 +122,7 @@ class Ui_ServiceManager(object):
|
||||
tooltip=translate('OpenLP.ServiceManager', 'Save this service.'),
|
||||
triggers=self.decide_save_method)
|
||||
self.toolbar.addSeparator()
|
||||
self.theme_label = QtGui.QLabel('%s:' % UiStrings().Theme, self)
|
||||
self.theme_label = QtGui.QLabel('%s:' % UiStrings().Theme, widget)
|
||||
self.theme_label.setMargin(3)
|
||||
self.theme_label.setObjectName('theme_label')
|
||||
self.toolbar.add_toolbar_widget(self.theme_label)
|
||||
@ -135,7 +135,7 @@ class Ui_ServiceManager(object):
|
||||
self.toolbar.setObjectName('toolbar')
|
||||
self.layout.addWidget(self.toolbar)
|
||||
# Create the service manager list
|
||||
self.service_manager_list = ServiceManagerList(self)
|
||||
self.service_manager_list = ServiceManagerList(widget)
|
||||
self.service_manager_list.setEditTriggers(
|
||||
QtGui.QAbstractItemView.CurrentChanged |
|
||||
QtGui.QAbstractItemView.DoubleClicked |
|
||||
@ -153,7 +153,7 @@ class Ui_ServiceManager(object):
|
||||
self.service_manager_list.__class__.dropEvent = self.drop_event
|
||||
self.layout.addWidget(self.service_manager_list)
|
||||
# Add the bottom toolbar
|
||||
self.order_toolbar = OpenLPToolbar(self)
|
||||
self.order_toolbar = OpenLPToolbar(widget)
|
||||
action_list = ActionList.get_instance()
|
||||
action_list.add_category(UiStrings().Service, CategoryOrder.standard_toolbar)
|
||||
self.service_manager_list.move_top = self.order_toolbar.add_toolbar_action(
|
||||
|
@ -56,11 +56,11 @@ class Ui_ThemeManager(object):
|
||||
"""
|
||||
|
||||
# start with the layout
|
||||
self.layout = QtGui.QVBoxLayout(self)
|
||||
self.layout = QtGui.QVBoxLayout(widget)
|
||||
self.layout.setSpacing(0)
|
||||
self.layout.setMargin(0)
|
||||
self.layout.setObjectName('layout')
|
||||
self.toolbar = OpenLPToolbar(self)
|
||||
self.toolbar = OpenLPToolbar(widget)
|
||||
self.toolbar.setObjectName('toolbar')
|
||||
self.toolbar.add_toolbar_action('newTheme',
|
||||
text=UiStrings().NewTheme, icon=':/themes/theme_new.png',
|
||||
@ -93,7 +93,7 @@ class Ui_ThemeManager(object):
|
||||
self.theme_widget = QtGui.QWidgetAction(self.toolbar)
|
||||
self.theme_widget.setObjectName('theme_widget')
|
||||
# create theme manager list
|
||||
self.theme_list_widget = QtGui.QListWidget(self)
|
||||
self.theme_list_widget = QtGui.QListWidget(widget)
|
||||
self.theme_list_widget.setAlternatingRowColors(True)
|
||||
self.theme_list_widget.setIconSize(QtCore.QSize(88, 50))
|
||||
self.theme_list_widget.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
|
||||
|
@ -33,10 +33,7 @@ import os
|
||||
from unittest import TestCase
|
||||
from tempfile import mkstemp
|
||||
|
||||
from PyQt4 import QtGui, QtTest, QtCore
|
||||
|
||||
from openlp.core.common import Registry, Settings
|
||||
from openlp.core.lib import ScreenList
|
||||
from openlp.core.ui import ThemeManager
|
||||
from tests.functional import patch, MagicMock
|
||||
|
||||
@ -98,5 +95,21 @@ class TestThemeManager(TestCase):
|
||||
self.theme_manager.build_theme_path()
|
||||
|
||||
# THEN:
|
||||
self.assertEqual(self.theme_manager.path, self.theme_manager.theme_form.path,
|
||||
'The theme path and the main path should be the same value')
|
||||
assert self.theme_manager.thumb_path.startswith(self.theme_manager.path) is True, \
|
||||
'The thumb path and the main path should start with the same value'
|
||||
|
||||
def click_on_new_theme_test(self):
|
||||
"""
|
||||
Test the on_add_theme event handler is called by the UI
|
||||
"""
|
||||
# GIVEN: An initial form
|
||||
Settings().setValue('themes/global theme', 'my_theme')
|
||||
mocked_event = MagicMock()
|
||||
self.theme_manager.on_add_theme = mocked_event
|
||||
self.theme_manager.setup_ui(self.theme_manager)
|
||||
|
||||
# WHEN displaying the UI and pressing cancel
|
||||
new_theme = self.theme_manager.toolbar.actions['newTheme']
|
||||
new_theme.trigger()
|
||||
|
||||
assert mocked_event.call_count == 1, 'The on_add_theme method should have been called once'
|
||||
|
Loading…
Reference in New Issue
Block a user