Various small fixes

* Correctly hide network stream button in the theme background page.
* Fix traceback in the FTW due to the mainwindow (which is not yet created) being used.
This commit is contained in:
Tomas Groth 2020-05-08 05:44:41 +00:00 committed by Raoul Snyman
parent 63de3d2021
commit b2843c50a1
6 changed files with 24 additions and 11 deletions

View File

@ -115,7 +115,12 @@ def critical_error_message_box(title=None, message=None, parent=None, question=F
return QtWidgets.QMessageBox.critical(parent, UiStrings().Error, message, return QtWidgets.QMessageBox.critical(parent, UiStrings().Error, message,
QtWidgets.QMessageBox.StandardButtons(QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.StandardButtons(QtWidgets.QMessageBox.Yes |
QtWidgets.QMessageBox.No)) QtWidgets.QMessageBox.No))
return Registry().get('main_window').error_message(title if title else UiStrings().Error, message) # If used before the main window is created, fall back to direct use of QMessageBox
main_window = Registry().get('main_window')
if main_window:
return main_window.error_message(title if title else UiStrings().Error, message)
else:
QtWidgets.QMessageBox.critical(parent, title, message)
def create_horizontal_adjusting_combo_box(parent, name): def create_horizontal_adjusting_combo_box(parent, name):

View File

@ -150,7 +150,7 @@ class BackgroundPage(GridLayoutPage):
self.stream_color_button.setObjectName('stream_color_button') self.stream_color_button.setObjectName('stream_color_button')
self.layout.addWidget(self.stream_color_button, 7, 1) self.layout.addWidget(self.stream_color_button, 7, 1)
self.stream_widgets = [self.stream_label, self.stream_lineedit, self.device_stream_select_button, self.stream_widgets = [self.stream_label, self.stream_lineedit, self.device_stream_select_button,
self.stream_color_label, self.stream_color_button] self.network_stream_select_button, self.stream_color_label, self.stream_color_button]
# Force everything up # Force everything up
self.layout_spacer = QtWidgets.QSpacerItem(1, 1) self.layout_spacer = QtWidgets.QSpacerItem(1, 1)
self.layout.addItem(self.layout_spacer, 8, 0, 1, 4) self.layout.addItem(self.layout_spacer, 8, 0, 1, 4)

View File

@ -67,7 +67,9 @@ def run_thread(worker, thread_name, can_start=True):
thread.started.connect(worker.start) thread.started.connect(worker.start)
worker.quit.connect(thread.quit) worker.quit.connect(thread.quit)
worker.quit.connect(worker.deleteLater) worker.quit.connect(worker.deleteLater)
worker.error.connect(main_window.error_message) # when used from the FTW the main window is not yet available
if main_window:
worker.error.connect(main_window.error_message)
thread.finished.connect(thread.deleteLater) thread.finished.connect(thread.deleteLater)
thread.finished.connect(make_remove_thread(thread_name)) thread.finished.connect(make_remove_thread(thread_name))
if can_start: if can_start:

View File

@ -219,10 +219,10 @@ class FirstTimeForm(QtWidgets.QWizard, UiFirstTimeWizard, RegistryProperties):
self.application.process_events() self.application.process_events()
except Exception: except Exception:
log.exception('Unable to parse sample config file %s', web_config) log.exception('Unable to parse sample config file %s', web_config)
critical_error_message_box( QtWidgets.QMessageBox.critical(self, translate('OpenLP.FirstTimeWizard', 'Invalid index file'),
translate('OpenLP.FirstTimeWizard', 'Invalid index file'), translate('OpenLP.FirstTimeWizard',
translate('OpenLP.FirstTimeWizard', 'OpenLP was unable to read the resource index file. ' 'OpenLP was unable to read the resource index file. '
'Please try again later.')) 'Please try again later.'))
return False return False
return True return True

View File

@ -289,7 +289,11 @@ class SongFormat(object):
'prefix': 'liveWorship', 'prefix': 'liveWorship',
'selectMode': SongFormatSelect.SingleFile, 'selectMode': SongFormatSelect.SingleFile,
'filter': '{text} (*.xml)'.format(text=translate('SongsPlugin.ImportWizardForm', 'filter': '{text} (*.xml)'.format(text=translate('SongsPlugin.ImportWizardForm',
'LiveWorship Database')) 'LiveWorship Database')),
'descriptionText': translate('SongsPlugin.ImportWizardForm',
'First convert your LiveWorship database to an XML text file, as '
'explained in the <a href="http://manual.openlp.org/songs.html'
'#importing-from-liveworship">User Manual</a>.')
}, },
Lyrix: { Lyrix: {
'class': LyrixImport, 'class': LyrixImport,

View File

@ -278,8 +278,8 @@ def test_on_custom_button_clicked_internet_settings(mocked_proxy_dialog):
mocked_proxy_dialog().exec.assert_called_once() mocked_proxy_dialog().exec.assert_called_once()
@patch('openlp.core.ui.firsttimeform.critical_error_message_box') @patch('openlp.core.ui.firsttimeform.QtWidgets.QMessageBox')
def test__parse_config_invalid_config(mocked_critical_error_message_box): def test__parse_config_invalid_config(mocked_message_box):
""" """
Test `FirstTimeForm._parse_config` when called with invalid data Test `FirstTimeForm._parse_config` when called with invalid data
""" """
@ -291,7 +291,9 @@ def test__parse_config_invalid_config(mocked_critical_error_message_box):
# THEN: _parse_data should return False and the user should have should have been informed. # THEN: _parse_data should return False and the user should have should have been informed.
assert result is False assert result is False
mocked_critical_error_message_box.assert_called_once() mocked_message_box.critical.assert_called_once_with(
first_time_form, 'Invalid index file',
'OpenLP was unable to read the resource index file. Please try again later.')
@patch('openlp.core.ui.firsttimeform.get_web_page') @patch('openlp.core.ui.firsttimeform.get_web_page')