forked from openlp/openlp
Show warning when adding images and there is no group yet. Also show a message when trying to delete the special 'Imported' group.
This commit is contained in:
parent
3f4df4f22c
commit
c72831df5d
@ -139,7 +139,7 @@ class ImageMediaItem(MediaManagerItem):
|
|||||||
# Turn off auto preview triggers.
|
# Turn off auto preview triggers.
|
||||||
self.listView.blockSignals(True)
|
self.listView.blockSignals(True)
|
||||||
if check_item_selected(self.listView, translate('ImagePlugin.MediaItem',
|
if check_item_selected(self.listView, translate('ImagePlugin.MediaItem',
|
||||||
'You must select an image to delete.')):
|
'You must select an image or group to delete.')):
|
||||||
item_list = self.listView.selectedItems()
|
item_list = self.listView.selectedItems()
|
||||||
Receiver.send_message(u'cursor_busy')
|
Receiver.send_message(u'cursor_busy')
|
||||||
self.main_window.displayProgressBar(len(item_list))
|
self.main_window.displayProgressBar(len(item_list))
|
||||||
@ -165,6 +165,11 @@ class ImageMediaItem(MediaManagerItem):
|
|||||||
row_item.parent().removeChild(row_item)
|
row_item.parent().removeChild(row_item)
|
||||||
self.fill_groups_combobox(self.choosegroupform.group_combobox)
|
self.fill_groups_combobox(self.choosegroupform.group_combobox)
|
||||||
self.fill_groups_combobox(self.addgroupform.parent_group_combobox)
|
self.fill_groups_combobox(self.addgroupform.parent_group_combobox)
|
||||||
|
elif item_data == u'Imported':
|
||||||
|
QtGui.QMessageBox.information(self, translate('ImagePlugin.MediaItem', 'Can\'t delete group'),
|
||||||
|
translate('ImagePlugin.MediaItem', 'The Imported group is a special group and can not be '
|
||||||
|
'deleted. It will disappear when it doesn\'t contain any images anymore.'),
|
||||||
|
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok))
|
||||||
self.main_window.incrementProgressBar()
|
self.main_window.incrementProgressBar()
|
||||||
self.main_window.finishedProgressBar()
|
self.main_window.finishedProgressBar()
|
||||||
Receiver.send_message(u'cursor_normal')
|
Receiver.send_message(u'cursor_normal')
|
||||||
@ -252,6 +257,7 @@ class ImageMediaItem(MediaManagerItem):
|
|||||||
# configuration file
|
# configuration file
|
||||||
imported_group = QtGui.QTreeWidgetItem()
|
imported_group = QtGui.QTreeWidgetItem()
|
||||||
imported_group.setText(0, translate('ImagePlugin.MediaItem', 'Imported'))
|
imported_group.setText(0, translate('ImagePlugin.MediaItem', 'Imported'))
|
||||||
|
imported_group.setData(0, QtCore.Qt.UserRole, u'Imported')
|
||||||
self.listView.insertTopLevelItem(0, imported_group)
|
self.listView.insertTopLevelItem(0, imported_group)
|
||||||
group_items[0] = imported_group
|
group_items[0] = imported_group
|
||||||
group_items[imageFile.group_id].addChild(item_name)
|
group_items[imageFile.group_id].addChild(item_name)
|
||||||
@ -279,6 +285,13 @@ class ImageMediaItem(MediaManagerItem):
|
|||||||
"""
|
"""
|
||||||
Add new images to the database. This method is called when adding images using the Add button or DnD.
|
Add new images to the database. This method is called when adding images using the Add button or DnD.
|
||||||
"""
|
"""
|
||||||
|
if self.manager.get_object_count(ImageGroups) == 0:
|
||||||
|
QtGui.QMessageBox.warning(self, translate('ImagePlugin.MediaItem', 'No image groups'),
|
||||||
|
translate('ImagePlugin.MediaItem', 'No image groups exist yet. Please create one before adding images.'),
|
||||||
|
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok))
|
||||||
|
self.loadFullList(self.manager.get_all_objects(ImageFilenames, order_by_ref=ImageFilenames.filename),
|
||||||
|
initial_load=initial_load)
|
||||||
|
return
|
||||||
if target_group is None:
|
if target_group is None:
|
||||||
# Ask which group the images should be saved in
|
# Ask which group the images should be saved in
|
||||||
if self.choosegroupform.exec_():
|
if self.choosegroupform.exec_():
|
||||||
@ -417,6 +430,18 @@ class ImageMediaItem(MediaManagerItem):
|
|||||||
groups = self.manager.get_all_objects(ImageGroups, ImageGroups.group_name == newGroup.group_name)
|
groups = self.manager.get_all_objects(ImageGroups, ImageGroups.group_name == newGroup.group_name)
|
||||||
return self.__checkObject(groups, newGroup, edit)
|
return self.__checkObject(groups, newGroup, edit)
|
||||||
|
|
||||||
|
def onFileClick(self):
|
||||||
|
"""
|
||||||
|
Called when the user clicks the 'Load images' button. This method is overloaded from MediaManagerItem.
|
||||||
|
"""
|
||||||
|
if self.manager.get_object_count(ImageGroups) == 0:
|
||||||
|
QtGui.QMessageBox.warning(self, translate('ImagePlugin.MediaItem', 'No image groups'),
|
||||||
|
translate('ImagePlugin.MediaItem', 'No image groups exist yet. Please create one before adding images.'),
|
||||||
|
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok))
|
||||||
|
else:
|
||||||
|
# At least one group exists, so we run the regular file adding code
|
||||||
|
MediaManagerItem.onFileClick(self)
|
||||||
|
|
||||||
def onAddGroupClick(self):
|
def onAddGroupClick(self):
|
||||||
"""
|
"""
|
||||||
Called to add a new group
|
Called to add a new group
|
||||||
|
Loading…
Reference in New Issue
Block a user