- Added 'add group' and 'load images' to contextmenu

- Fixed focus in the 'choose group' dialog
- Fixed error when clicking 'replace live background' when a group is selected
This commit is contained in:
Arjan Schrijver 2013-03-07 11:37:26 +01:00
parent 66a41ee8ba
commit 9f1b09af6e

View File

@ -151,6 +151,17 @@ class ImageMediaItem(MediaManagerItem):
self.listView.customContextMenuRequested.connect(self.contextMenu)
self.listView.addAction(self.replaceAction)
def addCustomContextActions(self):
create_widget_action(self.listView, separator=True)
create_widget_action(self.listView,
text=UiStrings().AddGroup,
icon=u':/images/image_new_group.png',
triggers=self.onAddGroupClick)
create_widget_action(self.listView,
text=self.plugin.getString(StringContent.Load)[u'tooltip'],
icon=u':/general/general_open.png',
triggers=self.onFileClick)
def addStartHeaderBar(self):
self.addGroupAction = self.toolbar.addToolbarAction(u'addGroupAction',
icon=u':/images/image_new_group.png', triggers=self.onAddGroupClick)
@ -333,12 +344,14 @@ class ImageMediaItem(MediaManagerItem):
# Enable and disable parts of the 'choose group' form
if preselect_group is None:
self.choose_group_form.nogroup_radio_button.setChecked(True)
self.choose_group_form.nogroup_radio_button.setFocus()
self.choose_group_form.existing_radio_button.setChecked(False)
self.choose_group_form.new_radio_button.setChecked(False)
else:
self.choose_group_form.nogroup_radio_button.setChecked(False)
self.choose_group_form.existing_radio_button.setChecked(True)
self.choose_group_form.new_radio_button.setChecked(False)
self.choose_group_form.group_combobox.setFocus()
if self.manager.get_object_count(ImageGroups) == 0:
self.choose_group_form.existing_radio_button.setDisabled(True)
self.choose_group_form.group_combobox.setDisabled(True)
@ -564,6 +577,9 @@ class ImageMediaItem(MediaManagerItem):
translate('ImagePlugin.MediaItem', 'You must select an image to replace the background with.')):
background = QtGui.QColor(Settings().value(self.settingsSection + u'/background color'))
bitem = self.listView.selectedItems()[0]
if not isinstance(bitem.data(0, QtCore.Qt.UserRole), ImageFilenames):
# Only continue when an image is selected
return
filename = bitem.data(0, QtCore.Qt.UserRole).filename
if os.path.exists(filename):
if self.live_controller.display.directImage(filename, background):