Fix transparent theme on OS X

Got the branch from https://code.launchpad.net/~marmyshev/openlp/bug_1117098 and fixed the tests

bzr-revno: 2362
This commit is contained in:
Samuel Mehrbrodt 2014-04-16 05:44:21 +01:00 committed by Tim Bentley
commit 49773de4f6
2 changed files with 30 additions and 0 deletions

View File

@ -168,8 +168,10 @@ class MainDisplay(OpenLPMixin, Display, RegistryProperties):
""" """
if enabled: if enabled:
self.setAutoFillBackground(False) self.setAutoFillBackground(False)
self.setStyleSheet("QGraphicsView {background: transparent; border: 0px;}")
else: else:
self.setAttribute(QtCore.Qt.WA_NoSystemBackground, False) self.setAttribute(QtCore.Qt.WA_NoSystemBackground, False)
self.setStyleSheet("QGraphicsView {}")
self.setAttribute(QtCore.Qt.WA_TranslucentBackground, enabled) self.setAttribute(QtCore.Qt.WA_TranslucentBackground, enabled)
self.repaint() self.repaint()

View File

@ -79,3 +79,31 @@ class TestMainDisplay(TestCase):
# THEN: The controller should not be a live controller. # THEN: The controller should not be a live controller.
self.assertEqual(main_display.is_live, True, 'The main display should be a live controller') self.assertEqual(main_display.is_live, True, 'The main display should be a live controller')
def set_transparency_test(self):
"""
Test creating an instance of the MainDisplay class
"""
# GIVEN: get an instance of MainDisplay
display = MagicMock()
main_display = MainDisplay(display)
# WHEN: We enable transparency
main_display.set_transparency(True)
# THEN: There should be a Stylesheet
self.assertEqual('QGraphicsView {background: transparent; border: 0px;}', main_display.styleSheet(),
'MainDisplay instance should be transparent')
self.assertFalse(main_display.autoFillBackground(),
'MainDisplay instance should be without background auto fill')
self.assertTrue(main_display.testAttribute(QtCore.Qt.WA_TranslucentBackground),
'MainDisplay hasnt translucent background')
# WHEN: We disable transparency
main_display.set_transparency(False)
# THEN: The Stylesheet should be empty
self.assertEqual('QGraphicsView {}', main_display.styleSheet(),
'MainDisplay instance should not be transparent')
self.assertFalse(main_display.testAttribute(QtCore.Qt.WA_TranslucentBackground),
'MainDisplay hasnt translucent background')