Separate the visible name of the controller from the internal name

This commit is contained in:
Raoul Snyman 2016-11-08 21:59:33 +02:00
parent f76c9adc39
commit 487ff4e8d3
5 changed files with 10 additions and 6 deletions

View File

@ -54,7 +54,7 @@ class MacLOController(PresentationController):
Initialise the class
"""
log.debug('Initialising')
super(MacLOController, self).__init__(plugin, 'Impress on macOS', MacLODocument)
super(MacLOController, self).__init__(plugin, 'maclo', MacLODocument, 'Impress on macOS')
self.supports = ['odp']
self.also_supports = ['ppt', 'pps', 'pptx', 'ppsx', 'pptm']
self.server_process = None

View File

@ -392,7 +392,8 @@ class PresentationController(object):
"""
log.info('PresentationController loaded')
def __init__(self, plugin=None, name='PresentationController', document_class=PresentationDocument):
def __init__(self, plugin=None, name='PresentationController', document_class=PresentationDocument,
display_name=None):
"""
This is the constructor for the presentationcontroller object. This provides an easy way for descendent plugins
@ -412,6 +413,7 @@ class PresentationController(object):
self.docs = []
self.plugin = plugin
self.name = name
self.display_name = display_name if display_name is not None else name
self.document_class = document_class
self.settings_section = self.plugin.settings_section
self.available = None

View File

@ -135,10 +135,10 @@ class PresentationTab(SettingsTab):
def set_controller_text(self, checkbox, controller):
if checkbox.isEnabled():
checkbox.setText(controller.name)
checkbox.setText(controller.display_name)
else:
checkbox.setText(translate('PresentationPlugin.PresentationTab',
'{name} (unavailable)').format(name=controller.name))
'{name} (unavailable)').format(name=controller.display_name))
def load(self):
"""

View File

@ -40,7 +40,7 @@ __default_settings__ = {
'presentations/override app': QtCore.Qt.Unchecked,
'presentations/enable_pdf_program': QtCore.Qt.Unchecked,
'presentations/pdf_program': '',
'presentations/Impress on macOS': QtCore.Qt.Checked,
'presentations/maclo': QtCore.Qt.Checked,
'presentations/Impress': QtCore.Qt.Checked,
'presentations/Powerpoint': QtCore.Qt.Checked,
'presentations/Powerpoint Viewer': QtCore.Qt.Checked,

View File

@ -77,8 +77,10 @@ class TestMacLOController(TestCase, TestMixin):
controller = MacLOController(plugin=self.mock_plugin)
# THEN: The name of the presentation controller should be correct
assert controller.name == 'Impress on macOS', \
assert controller.name == 'maclo', \
'The name of the presentation controller should be correct'
assert controller.display_name == 'Impress on macOS', \
'The display name of the presentation controller should be correct'
MockedPopen.assert_called_once_with(['/Applications/LibreOffice.app/Contents/Resources/python',
'/libreofficeserver.py'])
assert controller.server_process == mocked_process