35
35
from openlp.core.lib import MediaManagerItem, build_icon, ItemCapabilities, \
36
36
SettingsManager, translate, check_item_selected, check_directory_exists, \
37
Receiver, create_thumb, validate_thumb, ServiceItemContext
37
Receiver, create_thumb, validate_thumb, ServiceItemContext, Settings
38
38
from openlp.core.lib.ui import UiStrings, critical_error_message_box
39
from openlp.core.lib.settings import Settings
40
39
from openlp.core.utils import AppLocation, delete_file, locale_compare, \
113
112
for row in row_list:
114
113
text = self.listView.item(row)
116
delete_file(os.path.join(self.servicePath,
117
unicode(text.text())))
115
delete_file(os.path.join(self.servicePath, text.text()))
118
116
self.listView.takeItem(row)
119
117
self.plugin.formParent.incrementProgressBar()
120
118
SettingsManager.set_list(self.settingsSection,
144
142
item_name = QtGui.QListWidgetItem(filename)
145
143
item_name.setIcon(icon)
146
144
item_name.setToolTip(imageFile)
147
item_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(imageFile))
145
item_name.setData(QtCore.Qt.UserRole, imageFile)
148
146
self.listView.addItem(item_name)
149
147
if not initialLoad:
150
148
self.plugin.formParent.incrementProgressBar()
155
153
def generateSlideData(self, service_item, item=None, xmlVersion=False,
156
154
remote=False, context=ServiceItemContext.Service):
157
155
background = QtGui.QColor(Settings().value(self.settingsSection
158
+ u'/background color', QtCore.QVariant(u'#000000')))
156
+ u'/background color', u'#000000'))
172
170
missing_items = []
173
171
missing_items_filenames = []
174
172
for bitem in items:
175
filename = unicode(bitem.data(QtCore.Qt.UserRole).toString())
173
filename = bitem.data(QtCore.Qt.UserRole)
176
174
if not os.path.exists(filename):
177
175
missing_items.append(bitem)
178
176
missing_items_filenames.append(filename)
184
182
critical_error_message_box(
185
183
translate('ImagePlugin.MediaItem', 'Missing Image(s)'),
186
unicode(translate('ImagePlugin.MediaItem',
187
'The following image(s) no longer exist: %s')) %
184
translate('ImagePlugin.MediaItem',
185
'The following image(s) no longer exist: %s') %
188
186
u'\n'.join(missing_items_filenames))
190
188
# We have missing as well as existing images. We ask what to do.
191
189
elif missing_items and QtGui.QMessageBox.question(self,
192
190
translate('ImagePlugin.MediaItem', 'Missing Image(s)'),
193
unicode(translate('ImagePlugin.MediaItem', 'The following '
191
translate('ImagePlugin.MediaItem', 'The following '
194
192
'image(s) no longer exist: %s\nDo you want to add the other '
195
'images anyway?')) % u'\n'.join(missing_items_filenames),
193
'images anyway?') % u'\n'.join(missing_items_filenames),
196
194
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.No |
197
195
QtGui.QMessageBox.Yes)) == QtGui.QMessageBox.No:
199
197
# Continue with the existing images.
200
198
for bitem in items:
201
filename = unicode(bitem.data(QtCore.Qt.UserRole).toString())
199
filename = bitem.data(QtCore.Qt.UserRole)
202
200
name = os.path.split(filename)[1]
203
201
service_item.add_from_image(filename, name, background)
224
222
translate('ImagePlugin.MediaItem',
225
223
'You must select an image to replace the background with.')):
226
224
background = QtGui.QColor(Settings().value(
227
self.settingsSection + u'/background color',
228
QtCore.QVariant(u'#000000')))
225
self.settingsSection + u'/background color', u'#000000'))
229
226
item = self.listView.selectedIndexes()[0]
230
227
bitem = self.listView.item(item.row())
231
filename = unicode(bitem.data(QtCore.Qt.UserRole).toString())
228
filename = bitem.data(QtCore.Qt.UserRole)
232
229
if os.path.exists(filename):
233
230
if self.plugin.liveController.display.directImage(
234
231
filename, background):
239
236
'There was no display item to amend.'))
241
238
critical_error_message_box(UiStrings().LiveBGError,
242
unicode(translate('ImagePlugin.MediaItem',
239
translate('ImagePlugin.MediaItem',
243
240
'There was a problem replacing your background, '
244
'the image file "%s" no longer exists.')) % filename)
241
'the image file "%s" no longer exists.') % filename)
246
243
def search(self, string, showError):
247
244
files = SettingsManager.load_list(self.settingsSection, u'images')