diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index 678169e64..c4dfe7fc0 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -1054,8 +1054,23 @@ class EditSongForm(QtWidgets.QDialog, Ui_EditSongDialog, RegistryProperties): filename = item.data(QtCore.Qt.UserRole) if not filename.startswith(save_path): old_file, filename = filename, os.path.join(save_path, os.path.split(filename)[1]) - shutil.copyfile(old_file, filename) + try: + shutil.copyfile(old_file, filename) + except FileNotFoundError: + # show a dialog + button = QtWidgets.QMessageBox.critical( + self, + translate('SongsPlugin.EditSongForm', 'File not found'), + translate('SongsPlugin.EditSongForm', 'Unable to find the following file:\n' + + '%s\nDo you want to remove the entry from the song?') % old_file, + QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No, + QtWidgets.QMessageBox.Yes + ) + if button == QtWidgets.QMessageBox.Yes: + # If they want the file removed, skip the rest and move onto the next file + continue files.append(filename) + # Add the file to the media_file table media_file = MediaFile() media_file.file_name = filename media_file.type = 'audio' diff --git a/tests/functional/openlp_core_ui/test_firsttimeform.py b/tests/functional/openlp_core_ui/test_firsttimeform.py index 8b9a0f8b5..08854acdb 100644 --- a/tests/functional/openlp_core_ui/test_firsttimeform.py +++ b/tests/functional/openlp_core_ui/test_firsttimeform.py @@ -78,6 +78,23 @@ class TestFirstTimeForm(TestCase, TestMixin): if os.path.isfile(self.tempfile): os.remove(self.tempfile) + @patch('openlp.core.ui.firsttimewizard.is_macosx') + def constructor_macosx_test(self, mocked_is_macosx): + """ + Test that the form is resized correctly on OS X + """ + # GIVEN: The platform is OS X + mocked_is_macosx.return_value = True + + # WHEN: The wizard is created + frw = FirstTimeForm(None) + + # THEN: The form should have been resized + size = frw.size() + self.assertEqual(634, size.width()) + self.assertEqual(386, size.height()) + + def initialise_test(self): """ Test if we can intialise the FirstTimeForm