diff --git a/openlp/plugins/songs/forms/songselectdialog.py b/openlp/plugins/songs/forms/songselectdialog.py index 77a195a0b..781d22dfc 100644 --- a/openlp/plugins/songs/forms/songselectdialog.py +++ b/openlp/plugins/songs/forms/songselectdialog.py @@ -127,9 +127,10 @@ class Ui_SongSelectDialog(object): self.close_button.setIcon(UiIcons().close) self.close_button.setObjectName('close_button') self.bottom_button_layout.addWidget(self.close_button, 0, 0, 1, 1) - self.spacer = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, - QtWidgets.QSizePolicy.Minimum) - self.bottom_button_layout.addItem(self.spacer, 0, 1, 1, 7) + self.message_area = QtWidgets.QLabel() + self.message_area.setWordWrap(True) + self.message_area.setObjectName('message_area') + self.bottom_button_layout.addWidget(self.message_area, 0, 1, 1, 7) self.view_button = QtWidgets.QPushButton(songselect_dialog) self.view_button.setIcon(UiIcons().search) self.view_button.setObjectName('view_button') diff --git a/openlp/plugins/songs/forms/songselectform.py b/openlp/plugins/songs/forms/songselectform.py index 09c7b72c0..1a455c220 100644 --- a/openlp/plugins/songs/forms/songselectform.py +++ b/openlp/plugins/songs/forms/songselectform.py @@ -89,6 +89,7 @@ class SongSelectForm(QtWidgets.QDialog, Ui_SongSelectDialog, RegistryProperties) self.import_button.setEnabled(False) self.view_button.setEnabled(False) self.back_button.setEnabled(False) + self.message_area.setText('') def page_loaded(self, successful): self.song = None @@ -103,11 +104,9 @@ class SongSelectForm(QtWidgets.QDialog, Ui_SongSelectDialog, RegistryProperties) self.import_button.setEnabled(True) self.view_button.setEnabled(True) else: - QtWidgets.QMessageBox.critical( - self, translate('SongsPlugin.SongSelectForm', 'No access to song'), - translate('SongsPlugin.SongSelectForm', 'This song cannot be read. Perhaps your CCLI account ' - 'does not give you access to this song.'), - QtWidgets.QMessageBox.StandardButtons(QtWidgets.QMessageBox.Ok), QtWidgets.QMessageBox.Ok) + message = translate('SongsPlugin.SongSelectForm', 'This song cannot be read. Perhaps your CCLI account ' + 'does not give you access to this song.') + self.message_area.setText(message) self.back_button.setEnabled(True) if page_type == Pages.Other: self.back_button.setEnabled(True) diff --git a/tests/functional/openlp_plugins/songs/test_songselect.py b/tests/functional/openlp_plugins/songs/test_songselect.py index b83e4c856..60149bf54 100644 --- a/tests/functional/openlp_plugins/songs/test_songselect.py +++ b/tests/functional/openlp_plugins/songs/test_songselect.py @@ -649,6 +649,7 @@ class TestSongSelectForm(TestCase, TestMixin): ssform.view_button = MagicMock() ssform.back_button = MagicMock() ssform.url_bar = MagicMock() + ssform.message_area = MagicMock() # WHEN: The method is run ssform.page_load_started() @@ -659,6 +660,7 @@ class TestSongSelectForm(TestCase, TestMixin): ssform.import_button.setEnabled.assert_called_with(False) ssform.view_button.setEnabled.assert_called_with(False) ssform.back_button.setEnabled.assert_called_with(False) + ssform.message_area.setText.assert_called_with('') def test_page_loaded_login(self): """ @@ -695,6 +697,28 @@ class TestSongSelectForm(TestCase, TestMixin): ssform.song_progress_bar.setMaximum.assert_called_with(3) ssform.song_progress_bar.setVisible.call_count == 2 + @patch('openlp.plugins.songs.forms.songselectform.translate') + def test_page_loaded_song_no_access(self, mocked_translate): + """ + Test the page_loaded method for a "Song" page to which the CCLI account has no access + """ + # GIVEN: The SongSelectForm and mocked song page and translate function + ssform = SongSelectForm(None, MagicMock(), MagicMock()) + ssform.song_select_importer = MagicMock() + ssform.song_select_importer.get_page_type.return_value = Pages.Song + ssform.song_select_importer.get_song.return_value = None + ssform.song_progress_bar = MagicMock() + ssform.url_bar = MagicMock() + ssform.message_area = MagicMock() + mocked_translate.return_value = 'some message' + + # WHEN: The method is run + ssform.page_loaded(True) + + # THEN: The no access message should be shown and the progress bar should be less than 3 + ssform.message_area.setText.assert_called_with('some message') + ssform.song_progress_bar.setValue.call_count < 4 + def test_page_loaded_other(self): """ Test the page_loaded method for an "Other" page