forked from openlp/openlp
head
This commit is contained in:
commit
0efd1931b4
@ -249,7 +249,7 @@ class MainDisplay(OpenLPMixin, Display, RegistryProperties):
|
|||||||
"""
|
"""
|
||||||
Set up and build the output screen
|
Set up and build the output screen
|
||||||
"""
|
"""
|
||||||
self.log_debug('Start MainDisplay setup (live = %s)' % self.is_live)
|
self.log_debug('Start MainDisplay setup (live = {islive})'.format(islive=self.is_live))
|
||||||
self.screen = self.screens.current
|
self.screen = self.screens.current
|
||||||
self.setVisible(False)
|
self.setVisible(False)
|
||||||
Display.setup(self)
|
Display.setup(self)
|
||||||
@ -290,7 +290,9 @@ class MainDisplay(OpenLPMixin, Display, RegistryProperties):
|
|||||||
self.application.process_events()
|
self.application.process_events()
|
||||||
self.setGeometry(self.screen['size'])
|
self.setGeometry(self.screen['size'])
|
||||||
if animate:
|
if animate:
|
||||||
self.frame.evaluateJavaScript('show_text("%s")' % slide.replace('\\', '\\\\').replace('\"', '\\\"'))
|
# NOTE: Verify this works with ''.format()
|
||||||
|
_text = slide.replace('\\', '\\\\').replace('\"', '\\\"')
|
||||||
|
self.frame.evaluateJavaScript('show_text("{text}")'.format(text=_text))
|
||||||
else:
|
else:
|
||||||
# This exists for https://bugs.launchpad.net/openlp/+bug/1016843
|
# This exists for https://bugs.launchpad.net/openlp/+bug/1016843
|
||||||
# For unknown reasons if evaluateJavaScript is called
|
# For unknown reasons if evaluateJavaScript is called
|
||||||
@ -311,10 +313,10 @@ class MainDisplay(OpenLPMixin, Display, RegistryProperties):
|
|||||||
text_prepared = expand_tags(html.escape(text)).replace('\\', '\\\\').replace('\"', '\\\"')
|
text_prepared = expand_tags(html.escape(text)).replace('\\', '\\\\').replace('\"', '\\\"')
|
||||||
if self.height() != self.screen['size'].height() or not self.isVisible():
|
if self.height() != self.screen['size'].height() or not self.isVisible():
|
||||||
shrink = True
|
shrink = True
|
||||||
js = 'show_alert("%s", "%s")' % (text_prepared, 'top')
|
js = 'show_alert("{text}", "{top}")'.format(text=text_prepared, top='top')
|
||||||
else:
|
else:
|
||||||
shrink = False
|
shrink = False
|
||||||
js = 'show_alert("%s", "")' % text_prepared
|
js = 'show_alert("{text}", "")'.format(text=text_prepared)
|
||||||
height = self.frame.evaluateJavaScript(js)
|
height = self.frame.evaluateJavaScript(js)
|
||||||
if shrink:
|
if shrink:
|
||||||
if text:
|
if text:
|
||||||
@ -370,7 +372,7 @@ class MainDisplay(OpenLPMixin, Display, RegistryProperties):
|
|||||||
"""
|
"""
|
||||||
self.setGeometry(self.screen['size'])
|
self.setGeometry(self.screen['size'])
|
||||||
if image:
|
if image:
|
||||||
js = 'show_image("data:image/png;base64,%s");' % image
|
js = 'show_image("data:image/png;base64,{image}");'.format(image=image)
|
||||||
else:
|
else:
|
||||||
js = 'show_image("");'
|
js = 'show_image("");'
|
||||||
self.frame.evaluateJavaScript(js)
|
self.frame.evaluateJavaScript(js)
|
||||||
@ -505,7 +507,7 @@ class MainDisplay(OpenLPMixin, Display, RegistryProperties):
|
|||||||
|
|
||||||
:param mode: How the screen is to be hidden
|
:param mode: How the screen is to be hidden
|
||||||
"""
|
"""
|
||||||
self.log_debug('hide_display mode = %d' % mode)
|
self.log_debug('hide_display mode = {mode:d}'.format(mode=mode))
|
||||||
if self.screens.display_count == 1:
|
if self.screens.display_count == 1:
|
||||||
# Only make visible if setting enabled.
|
# Only make visible if setting enabled.
|
||||||
if not Settings().value('core/display on monitor'):
|
if not Settings().value('core/display on monitor'):
|
||||||
|
@ -622,11 +622,10 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow, RegistryProperties):
|
|||||||
:param version: The Version to be displayed.
|
:param version: The Version to be displayed.
|
||||||
"""
|
"""
|
||||||
log.debug('version_notice')
|
log.debug('version_notice')
|
||||||
version_text = translate('OpenLP.MainWindow', 'Version %s of OpenLP is now available for download (you are '
|
version_text = translate('OpenLP.MainWindow', 'Version {new} of OpenLP is now available for download (you are '
|
||||||
'currently running version %s). \n\nYou can download the latest version from '
|
'currently running version {current}). \n\nYou can download the latest version from '
|
||||||
'http://openlp.org/.')
|
'http://openlp.org/.').format(new=version, current=get_application_version()[u'full'])
|
||||||
QtWidgets.QMessageBox.question(self, translate('OpenLP.MainWindow', 'OpenLP Version Updated'),
|
QtWidgets.QMessageBox.question(self, translate('OpenLP.MainWindow', 'OpenLP Version Updated'), version_text)
|
||||||
version_text % (version, get_application_version()[u'full']))
|
|
||||||
|
|
||||||
def show(self):
|
def show(self):
|
||||||
"""
|
"""
|
||||||
@ -642,7 +641,7 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow, RegistryProperties):
|
|||||||
self.service_manager_contents.load_last_file()
|
self.service_manager_contents.load_last_file()
|
||||||
# This will store currently used layout preset so it remains enabled on next startup.
|
# This will store currently used layout preset so it remains enabled on next startup.
|
||||||
# If any panel is enabled/disabled after preset is set, this setting is not saved.
|
# If any panel is enabled/disabled after preset is set, this setting is not saved.
|
||||||
view_mode = Settings().value('%s/view mode' % self.general_settings_section)
|
view_mode = Settings().value('{section}/view mode'.format(section=self.general_settings_section))
|
||||||
if view_mode == 'default' and Settings().value('user interface/is preset layout'):
|
if view_mode == 'default' and Settings().value('user interface/is preset layout'):
|
||||||
self.mode_default_item.setChecked(True)
|
self.mode_default_item.setChecked(True)
|
||||||
elif view_mode == 'setup' and Settings().value('user interface/is preset layout'):
|
elif view_mode == 'setup' and Settings().value('user interface/is preset layout'):
|
||||||
@ -731,8 +730,8 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow, RegistryProperties):
|
|||||||
"""
|
"""
|
||||||
settings = Settings()
|
settings = Settings()
|
||||||
self.live_controller.main_display_set_background()
|
self.live_controller.main_display_set_background()
|
||||||
if settings.value('%s/screen blank' % self.general_settings_section):
|
if settings.value('{section}/screen blank'.format(section=self.general_settings_section)):
|
||||||
if settings.value('%s/blank warning' % self.general_settings_section):
|
if settings.value('{section}/blank warning'.format(section=self.general_settings_section)):
|
||||||
QtWidgets.QMessageBox.question(self, translate('OpenLP.MainWindow', 'OpenLP Main Display Blanked'),
|
QtWidgets.QMessageBox.question(self, translate('OpenLP.MainWindow', 'OpenLP Main Display Blanked'),
|
||||||
translate('OpenLP.MainWindow', 'The Main Display has been blanked out'))
|
translate('OpenLP.MainWindow', 'The Main Display has been blanked out'))
|
||||||
|
|
||||||
@ -924,9 +923,9 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow, RegistryProperties):
|
|||||||
try:
|
try:
|
||||||
value = import_settings.value(section_key)
|
value = import_settings.value(section_key)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
log.warning('The key "%s" does not exist (anymore), so it will be skipped.' % section_key)
|
log.warning('The key "{key}" does not exist (anymore), so it will be skipped.'.format(key=section_key))
|
||||||
if value is not None:
|
if value is not None:
|
||||||
settings.setValue('%s' % (section_key), value)
|
settings.setValue('{key}'.format(key=section_key), value)
|
||||||
now = datetime.now()
|
now = datetime.now()
|
||||||
settings.beginGroup(self.header_section)
|
settings.beginGroup(self.header_section)
|
||||||
settings.setValue('file_imported', import_file_name)
|
settings.setValue('file_imported', import_file_name)
|
||||||
@ -1003,9 +1002,9 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow, RegistryProperties):
|
|||||||
key_value = settings.value(section_key)
|
key_value = settings.value(section_key)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
QtWidgets.QMessageBox.critical(self, translate('OpenLP.MainWindow', 'Export setting error'),
|
QtWidgets.QMessageBox.critical(self, translate('OpenLP.MainWindow', 'Export setting error'),
|
||||||
translate('OpenLP.MainWindow', 'The key "%s" does not have a default '
|
translate('OpenLP.MainWindow', 'The key "{key}" does not have a default '
|
||||||
'value so it will be skipped in this '
|
'value so it will be skipped in this '
|
||||||
'export.') % section_key,
|
'export.').format(key=section_key),
|
||||||
QtWidgets.QMessageBox.StandardButtons(QtWidgets.QMessageBox.Ok))
|
QtWidgets.QMessageBox.StandardButtons(QtWidgets.QMessageBox.Ok))
|
||||||
key_value = None
|
key_value = None
|
||||||
if key_value is not None:
|
if key_value is not None:
|
||||||
@ -1027,8 +1026,9 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow, RegistryProperties):
|
|||||||
os.remove(temp_file)
|
os.remove(temp_file)
|
||||||
except OSError as ose:
|
except OSError as ose:
|
||||||
QtWidgets.QMessageBox.critical(self, translate('OpenLP.MainWindow', 'Export setting error'),
|
QtWidgets.QMessageBox.critical(self, translate('OpenLP.MainWindow', 'Export setting error'),
|
||||||
translate('OpenLP.MainWindow', 'An error occurred while exporting the '
|
translate('OpenLP.MainWindow',
|
||||||
'settings: %s') % ose.strerror,
|
'An error occurred while exporting the '
|
||||||
|
'settings: {err}').format(err=ose.strerror),
|
||||||
QtWidgets.QMessageBox.StandardButtons(QtWidgets.QMessageBox.Ok))
|
QtWidgets.QMessageBox.StandardButtons(QtWidgets.QMessageBox.Ok))
|
||||||
|
|
||||||
def on_mode_default_item_clicked(self):
|
def on_mode_default_item_clicked(self):
|
||||||
@ -1061,7 +1061,7 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow, RegistryProperties):
|
|||||||
"""
|
"""
|
||||||
if mode:
|
if mode:
|
||||||
settings = Settings()
|
settings = Settings()
|
||||||
settings.setValue('%s/view mode' % self.general_settings_section, mode)
|
settings.setValue('{section}/view mode'.format(section=self.general_settings_section), mode)
|
||||||
self.media_manager_dock.setVisible(media)
|
self.media_manager_dock.setVisible(media)
|
||||||
self.service_manager_dock.setVisible(service)
|
self.service_manager_dock.setVisible(service)
|
||||||
self.theme_manager_dock.setVisible(theme)
|
self.theme_manager_dock.setVisible(theme)
|
||||||
@ -1168,9 +1168,9 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow, RegistryProperties):
|
|||||||
:param file_name: The file name of the service file.
|
:param file_name: The file name of the service file.
|
||||||
"""
|
"""
|
||||||
if modified:
|
if modified:
|
||||||
title = '%s - %s*' % (UiStrings().OLPV2x, file_name)
|
title = '{title} - {name}*'.format(title=UiStrings().OLPV2x, name=file_name)
|
||||||
else:
|
else:
|
||||||
title = '%s - %s' % (UiStrings().OLPV2x, file_name)
|
title = '{title} - {name}'.format(title=UiStrings().OLPV2x, name=file_name)
|
||||||
self.setWindowTitle(title)
|
self.setWindowTitle(title)
|
||||||
|
|
||||||
def show_status_message(self, message):
|
def show_status_message(self, message):
|
||||||
@ -1183,8 +1183,9 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow, RegistryProperties):
|
|||||||
"""
|
"""
|
||||||
Update the default theme indicator in the status bar
|
Update the default theme indicator in the status bar
|
||||||
"""
|
"""
|
||||||
self.default_theme_label.setText(translate('OpenLP.MainWindow', 'Default Theme: %s') %
|
theme_name = Settings().value('themes/global theme')
|
||||||
Settings().value('themes/global theme'))
|
self.default_theme_label.setText(translate('OpenLP.MainWindow',
|
||||||
|
'Default Theme: {theme}').format(theme=theme_name))
|
||||||
|
|
||||||
def toggle_media_manager(self):
|
def toggle_media_manager(self):
|
||||||
"""
|
"""
|
||||||
@ -1331,7 +1332,8 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow, RegistryProperties):
|
|||||||
recent_files_to_display = existing_recent_files[0:recent_file_count]
|
recent_files_to_display = existing_recent_files[0:recent_file_count]
|
||||||
self.recent_files_menu.clear()
|
self.recent_files_menu.clear()
|
||||||
for file_id, filename in enumerate(recent_files_to_display):
|
for file_id, filename in enumerate(recent_files_to_display):
|
||||||
log.debug('Recent file name: %s', filename)
|
log.debug('Recent file name: {name}'.format(name=filename))
|
||||||
|
# TODO: Verify ''.format() before committing
|
||||||
action = create_action(self, '', text='&%d %s' % (file_id + 1,
|
action = create_action(self, '', text='&%d %s' % (file_id + 1,
|
||||||
os.path.splitext(os.path.basename(str(filename)))[0]), data=filename,
|
os.path.splitext(os.path.basename(str(filename)))[0]), data=filename,
|
||||||
triggers=self.service_manager_contents.on_recent_service_clicked)
|
triggers=self.service_manager_contents.on_recent_service_clicked)
|
||||||
@ -1424,7 +1426,7 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow, RegistryProperties):
|
|||||||
"""
|
"""
|
||||||
Change the data directory.
|
Change the data directory.
|
||||||
"""
|
"""
|
||||||
log.info('Changing data path to %s' % self.new_data_path)
|
log.info('Changing data path to {newpath}'.format(newpath=self.new_data_path))
|
||||||
old_data_path = str(AppLocation.get_data_path())
|
old_data_path = str(AppLocation.get_data_path())
|
||||||
# Copy OpenLP data to new location if requested.
|
# Copy OpenLP data to new location if requested.
|
||||||
self.application.set_busy_cursor()
|
self.application.set_busy_cursor()
|
||||||
@ -1432,17 +1434,17 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow, RegistryProperties):
|
|||||||
log.info('Copying data to new path')
|
log.info('Copying data to new path')
|
||||||
try:
|
try:
|
||||||
self.show_status_message(
|
self.show_status_message(
|
||||||
translate('OpenLP.MainWindow', 'Copying OpenLP data to new data directory location - %s '
|
translate('OpenLP.MainWindow', 'Copying OpenLP data to new data directory location - {path} '
|
||||||
'- Please wait for copy to finish').replace('%s', self.new_data_path))
|
'- Please wait for copy to finish').format(path=self.new_data_path))
|
||||||
dir_util.copy_tree(old_data_path, self.new_data_path)
|
dir_util.copy_tree(old_data_path, self.new_data_path)
|
||||||
log.info('Copy successful')
|
log.info('Copy successful')
|
||||||
except (IOError, os.error, DistutilsFileError) as why:
|
except (IOError, os.error, DistutilsFileError) as why:
|
||||||
self.application.set_normal_cursor()
|
self.application.set_normal_cursor()
|
||||||
log.exception('Data copy failed %s' % str(why))
|
log.exception('Data copy failed {err}'.format(err=str(why)))
|
||||||
|
err_text = translate('OpenLP.MainWindow',
|
||||||
|
'OpenLP Data directory copy failed\n\n{err}').format(err=str(why)),
|
||||||
QtWidgets.QMessageBox.critical(self, translate('OpenLP.MainWindow', 'New Data Directory Error'),
|
QtWidgets.QMessageBox.critical(self, translate('OpenLP.MainWindow', 'New Data Directory Error'),
|
||||||
translate('OpenLP.MainWindow',
|
err_text,
|
||||||
'OpenLP Data directory copy failed\n\n%s').
|
|
||||||
replace('%s', str(why)),
|
|
||||||
QtWidgets.QMessageBox.StandardButtons(QtWidgets.QMessageBox.Ok))
|
QtWidgets.QMessageBox.StandardButtons(QtWidgets.QMessageBox.Ok))
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
|
@ -28,7 +28,7 @@ PREREQUISITE: add_record() and get_all() functions validated.
|
|||||||
import os
|
import os
|
||||||
from unittest import TestCase
|
from unittest import TestCase
|
||||||
|
|
||||||
from openlp.core.lib.projector.db import Projector, ProjectorDB, ProjectorSource
|
from openlp.core.lib.projector.db import Manufacturer, Model, Projector, ProjectorDB, ProjectorSource
|
||||||
|
|
||||||
from tests.functional import MagicMock, patch
|
from tests.functional import MagicMock, patch
|
||||||
from tests.resources.projector.data import TEST_DB, TEST1_DATA, TEST2_DATA, TEST3_DATA
|
from tests.resources.projector.data import TEST_DB, TEST1_DATA, TEST2_DATA, TEST3_DATA
|
||||||
@ -82,12 +82,12 @@ class TestProjectorDB(TestCase):
|
|||||||
"""
|
"""
|
||||||
Test case for ProjectorDB
|
Test case for ProjectorDB
|
||||||
"""
|
"""
|
||||||
def setUp(self):
|
@patch('openlp.core.lib.projector.db.init_url')
|
||||||
|
def setUp(self, mocked_init_url):
|
||||||
"""
|
"""
|
||||||
Set up anything necessary for all tests
|
Set up anything necessary for all tests
|
||||||
"""
|
"""
|
||||||
with patch('openlp.core.lib.projector.db.init_url') as mocked_init_url:
|
mocked_init_url.return_value = 'sqlite:///{db}'.format(db=TEST_DB)
|
||||||
mocked_init_url.return_value = 'sqlite:///%s' % TEST_DB
|
|
||||||
self.projector = ProjectorDB()
|
self.projector = ProjectorDB()
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
@ -192,3 +192,17 @@ class TestProjectorDB(TestCase):
|
|||||||
# THEN: Projector should have the same source entry
|
# THEN: Projector should have the same source entry
|
||||||
item = self.projector.get_projector_by_id(item_id)
|
item = self.projector.get_projector_by_id(item_id)
|
||||||
self.assertTrue(compare_source(item.source_list[0], source))
|
self.assertTrue(compare_source(item.source_list[0], source))
|
||||||
|
|
||||||
|
def manufacturer_repr_test(self):
|
||||||
|
"""
|
||||||
|
Test manufacturer class __repr__ text
|
||||||
|
"""
|
||||||
|
# GIVEN: Test object
|
||||||
|
manufacturer = Manufacturer()
|
||||||
|
|
||||||
|
# WHEN: Name is set
|
||||||
|
manufacturer.name = 'OpenLP Test'
|
||||||
|
|
||||||
|
# THEN: __repr__ should return a proper string
|
||||||
|
self.assertEqual(str(manufacturer), '<Manufacturer(name="OpenLP Test")>',
|
||||||
|
'Manufacturer.__repr__() should have returned a proper representation string')
|
||||||
|
Loading…
Reference in New Issue
Block a user