forked from openlp/openlp
Show a message asking the user if they want to remove a file that doesn't exist
bzr-revno: 2629 Fixes: https://launchpad.net/bugs/1559336
This commit is contained in:
commit
654241246d
@ -1054,8 +1054,23 @@ class EditSongForm(QtWidgets.QDialog, Ui_EditSongDialog, RegistryProperties):
|
|||||||
filename = item.data(QtCore.Qt.UserRole)
|
filename = item.data(QtCore.Qt.UserRole)
|
||||||
if not filename.startswith(save_path):
|
if not filename.startswith(save_path):
|
||||||
old_file, filename = filename, os.path.join(save_path, os.path.split(filename)[1])
|
old_file, filename = filename, os.path.join(save_path, os.path.split(filename)[1])
|
||||||
|
try:
|
||||||
shutil.copyfile(old_file, filename)
|
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)
|
files.append(filename)
|
||||||
|
# Add the file to the media_file table
|
||||||
media_file = MediaFile()
|
media_file = MediaFile()
|
||||||
media_file.file_name = filename
|
media_file.file_name = filename
|
||||||
media_file.type = 'audio'
|
media_file.type = 'audio'
|
||||||
|
@ -78,6 +78,23 @@ class TestFirstTimeForm(TestCase, TestMixin):
|
|||||||
if os.path.isfile(self.tempfile):
|
if os.path.isfile(self.tempfile):
|
||||||
os.remove(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):
|
def initialise_test(self):
|
||||||
"""
|
"""
|
||||||
Test if we can intialise the FirstTimeForm
|
Test if we can intialise the FirstTimeForm
|
||||||
|
Loading…
Reference in New Issue
Block a user