forked from openlp/openlp
Small style cleanups
Add guards for Presentations / Images / Media which are removed from files system after loading Fix 694079 on Linux by adding css into build Add guard to delay exiting as shutting down in middle of a service is not a good idea bzr-revno: 1171 Fixes: https://launchpad.net/bugs/694079
This commit is contained in:
commit
e8ddb4c751
@ -3,6 +3,7 @@ recursive-include openlp *.sqlite
|
|||||||
recursive-include openlp *.csv
|
recursive-include openlp *.csv
|
||||||
recursive-include openlp *.html
|
recursive-include openlp *.html
|
||||||
recursive-include openlp *.js
|
recursive-include openlp *.js
|
||||||
|
recursive-include openlp *.css
|
||||||
recursive-include openlp *.qm
|
recursive-include openlp *.qm
|
||||||
recursive-include documentation *
|
recursive-include documentation *
|
||||||
recursive-include resources/forms *
|
recursive-include resources/forms *
|
||||||
|
@ -381,7 +381,7 @@ class MediaManagerItem(QtGui.QWidget):
|
|||||||
if os.path.exists(thumb):
|
if os.path.exists(thumb):
|
||||||
filedate = os.stat(file).st_mtime
|
filedate = os.stat(file).st_mtime
|
||||||
thumbdate = os.stat(thumb).st_mtime
|
thumbdate = os.stat(thumb).st_mtime
|
||||||
#if file updated rebuild icon
|
# if file updated rebuild icon
|
||||||
if filedate > thumbdate:
|
if filedate > thumbdate:
|
||||||
self.iconFromFile(file, thumb)
|
self.iconFromFile(file, thumb)
|
||||||
else:
|
else:
|
||||||
@ -544,4 +544,4 @@ class MediaManagerItem(QtGui.QWidget):
|
|||||||
Method to add processing when a service has been loaded and
|
Method to add processing when a service has been loaded and
|
||||||
individual service items need to be processed by the plugins
|
individual service items need to be processed by the plugins
|
||||||
"""
|
"""
|
||||||
pass
|
pass
|
||||||
|
@ -825,8 +825,18 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
|||||||
else:
|
else:
|
||||||
event.ignore()
|
event.ignore()
|
||||||
else:
|
else:
|
||||||
self.cleanUp()
|
ret = QtGui.QMessageBox.question(self,
|
||||||
event.accept()
|
translate('OpenLP.MainWindow', 'Close OpenLP'),
|
||||||
|
translate('OpenLP.MainWindow', 'Are you sure you want to Exit?'),
|
||||||
|
QtGui.QMessageBox.StandardButtons(
|
||||||
|
QtGui.QMessageBox.Yes |
|
||||||
|
QtGui.QMessageBox.No),
|
||||||
|
QtGui.QMessageBox.Yes)
|
||||||
|
if ret == QtGui.QMessageBox.Yes:
|
||||||
|
self.cleanUp()
|
||||||
|
event.accept()
|
||||||
|
else:
|
||||||
|
event.ignore()
|
||||||
|
|
||||||
def cleanUp(self):
|
def cleanUp(self):
|
||||||
"""
|
"""
|
||||||
|
@ -132,7 +132,7 @@ class ImageMediaItem(MediaManagerItem):
|
|||||||
os.remove(os.path.join(self.servicePath,
|
os.remove(os.path.join(self.servicePath,
|
||||||
unicode(text.text())))
|
unicode(text.text())))
|
||||||
except OSError:
|
except OSError:
|
||||||
#if not present do not worry
|
# if not present do not worry
|
||||||
pass
|
pass
|
||||||
self.listView.takeItem(row)
|
self.listView.takeItem(row)
|
||||||
SettingsManager.set_list(self.settingsSection,
|
SettingsManager.set_list(self.settingsSection,
|
||||||
@ -172,9 +172,18 @@ class ImageMediaItem(MediaManagerItem):
|
|||||||
for item in items:
|
for item in items:
|
||||||
bitem = self.listView.item(item.row())
|
bitem = self.listView.item(item.row())
|
||||||
filename = unicode(bitem.data(QtCore.Qt.UserRole).toString())
|
filename = unicode(bitem.data(QtCore.Qt.UserRole).toString())
|
||||||
(path, name) = os.path.split(filename)
|
if os.path.exists(filename):
|
||||||
service_item.add_from_image(filename, name)
|
(path, name) = os.path.split(filename)
|
||||||
return True
|
service_item.add_from_image(filename, name)
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
# File is no longer present
|
||||||
|
QtGui.QMessageBox.critical(
|
||||||
|
self, translate('ImagePlugin.MediaItem',
|
||||||
|
'Missing Image'),
|
||||||
|
unicode(translate('ImagePlugin.MediaItem',
|
||||||
|
'The Image %s no longer exists.')) % filename)
|
||||||
|
return False
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@ -195,4 +204,4 @@ class ImageMediaItem(MediaManagerItem):
|
|||||||
self.resetButton.setVisible(True)
|
self.resetButton.setVisible(True)
|
||||||
|
|
||||||
def onPreviewClick(self):
|
def onPreviewClick(self):
|
||||||
MediaManagerItem.onPreviewClick(self)
|
MediaManagerItem.onPreviewClick(self)
|
||||||
|
@ -89,7 +89,7 @@ class MediaMediaItem(MediaManagerItem):
|
|||||||
self.ImageWidget.sizePolicy().hasHeightForWidth())
|
self.ImageWidget.sizePolicy().hasHeightForWidth())
|
||||||
self.ImageWidget.setSizePolicy(sizePolicy)
|
self.ImageWidget.setSizePolicy(sizePolicy)
|
||||||
self.ImageWidget.setObjectName(u'ImageWidget')
|
self.ImageWidget.setObjectName(u'ImageWidget')
|
||||||
#Replace backgrounds do not work at present so remove functionality.
|
# Replace backgrounds do not work at present so remove functionality.
|
||||||
self.blankButton = self.toolbar.addToolbarButton(
|
self.blankButton = self.toolbar.addToolbarButton(
|
||||||
translate('MediaPlugin.MediaItem', 'Replace Background'),
|
translate('MediaPlugin.MediaItem', 'Replace Background'),
|
||||||
u':/slides/slide_blank.png',
|
u':/slides/slide_blank.png',
|
||||||
@ -122,15 +122,24 @@ class MediaMediaItem(MediaManagerItem):
|
|||||||
if item is None:
|
if item is None:
|
||||||
return False
|
return False
|
||||||
filename = unicode(item.data(QtCore.Qt.UserRole).toString())
|
filename = unicode(item.data(QtCore.Qt.UserRole).toString())
|
||||||
service_item.title = unicode(
|
if os.path.exists(filename):
|
||||||
translate('MediaPlugin.MediaItem', 'Media'))
|
service_item.title = unicode(
|
||||||
service_item.add_capability(ItemCapabilities.RequiresMedia)
|
translate('MediaPlugin.MediaItem', 'Media'))
|
||||||
# force a nonexistent theme
|
service_item.add_capability(ItemCapabilities.RequiresMedia)
|
||||||
service_item.theme = -1
|
# force a nonexistent theme
|
||||||
frame = u':/media/image_clapperboard.png'
|
service_item.theme = -1
|
||||||
(path, name) = os.path.split(filename)
|
frame = u':/media/image_clapperboard.png'
|
||||||
service_item.add_from_command(path, name, frame)
|
(path, name) = os.path.split(filename)
|
||||||
return True
|
service_item.add_from_command(path, name, frame)
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
# File is no longer present
|
||||||
|
QtGui.QMessageBox.critical(
|
||||||
|
self, translate('MediaPlugin.MediaItem',
|
||||||
|
'Missing Media File'),
|
||||||
|
unicode(translate('MediaPlugin.MediaItem',
|
||||||
|
'The file %s no longer exists.')) % filename)
|
||||||
|
return False
|
||||||
|
|
||||||
def initialise(self):
|
def initialise(self):
|
||||||
self.listView.setSelectionMode(
|
self.listView.setSelectionMode(
|
||||||
@ -159,4 +168,4 @@ class MediaMediaItem(MediaManagerItem):
|
|||||||
img = QtGui.QPixmap(u':/media/media_video.png').toImage()
|
img = QtGui.QPixmap(u':/media/media_video.png').toImage()
|
||||||
item_name.setIcon(build_icon(img))
|
item_name.setIcon(build_icon(img))
|
||||||
item_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(file))
|
item_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(file))
|
||||||
self.listView.addItem(item_name)
|
self.listView.addItem(item_name)
|
||||||
|
@ -255,8 +255,9 @@ class ImpressDocument(PresentationDocument):
|
|||||||
self.document = desktop.loadComponentFromURL(url, u'_blank',
|
self.document = desktop.loadComponentFromURL(url, u'_blank',
|
||||||
0, properties)
|
0, properties)
|
||||||
except:
|
except:
|
||||||
log.exception(u'Failed to load presentation')
|
log.exception(u'Failed to load presentation %s' % url)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
self.presentation = self.document.getPresentation()
|
self.presentation = self.document.getPresentation()
|
||||||
self.presentation.Display = \
|
self.presentation.Display = \
|
||||||
self.controller.plugin.renderManager.screens.current_display + 1
|
self.controller.plugin.renderManager.screens.current_display + 1
|
||||||
@ -478,4 +479,4 @@ class ImpressDocument(PresentationDocument):
|
|||||||
shape = notes.getByIndex(idx)
|
shape = notes.getByIndex(idx)
|
||||||
if shape.supportsService("com.sun.star.drawing.Text"):
|
if shape.supportsService("com.sun.star.drawing.Text"):
|
||||||
text += shape.getString() + '\n'
|
text += shape.getString() + '\n'
|
||||||
return text
|
return text
|
||||||
|
@ -153,7 +153,7 @@ class PresentationMediaItem(MediaManagerItem):
|
|||||||
"""
|
"""
|
||||||
self.DisplayTypeComboBox.clear()
|
self.DisplayTypeComboBox.clear()
|
||||||
for item in self.controllers:
|
for item in self.controllers:
|
||||||
#load the drop down selection
|
# load the drop down selection
|
||||||
if self.controllers[item].enabled():
|
if self.controllers[item].enabled():
|
||||||
self.DisplayTypeComboBox.addItem(item)
|
self.DisplayTypeComboBox.addItem(item)
|
||||||
if self.DisplayTypeComboBox.count() > 1:
|
if self.DisplayTypeComboBox.count() > 1:
|
||||||
@ -254,23 +254,33 @@ class PresentationMediaItem(MediaManagerItem):
|
|||||||
for item in items:
|
for item in items:
|
||||||
bitem = self.listView.item(item.row())
|
bitem = self.listView.item(item.row())
|
||||||
filename = unicode(bitem.data(QtCore.Qt.UserRole).toString())
|
filename = unicode(bitem.data(QtCore.Qt.UserRole).toString())
|
||||||
if shortname == self.Automatic:
|
if os.path.exists(filename):
|
||||||
service_item.shortname = self.findControllerByType(filename)
|
if shortname == self.Automatic:
|
||||||
if not service_item.shortname:
|
service_item.shortname = \
|
||||||
return False
|
self.findControllerByType(filename)
|
||||||
controller = self.controllers[service_item.shortname]
|
if not service_item.shortname:
|
||||||
(path, name) = os.path.split(filename)
|
return False
|
||||||
doc = controller.add_doc(filename)
|
controller = self.controllers[service_item.shortname]
|
||||||
if doc.get_thumbnail_path(1, True) is None:
|
(path, name) = os.path.split(filename)
|
||||||
doc.load_presentation()
|
doc = controller.add_doc(filename)
|
||||||
i = 1
|
if doc.get_thumbnail_path(1, True) is None:
|
||||||
img = doc.get_thumbnail_path(i, True)
|
doc.load_presentation()
|
||||||
while img:
|
i = 1
|
||||||
service_item.add_from_command(path, name, img)
|
|
||||||
i = i + 1
|
|
||||||
img = doc.get_thumbnail_path(i, True)
|
img = doc.get_thumbnail_path(i, True)
|
||||||
doc.close_presentation()
|
while img:
|
||||||
return True
|
service_item.add_from_command(path, name, img)
|
||||||
|
i = i + 1
|
||||||
|
img = doc.get_thumbnail_path(i, True)
|
||||||
|
doc.close_presentation()
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
# File is no longer present
|
||||||
|
QtGui.QMessageBox.critical(
|
||||||
|
self, translate('PresentationPlugin.MediaItem',
|
||||||
|
'Missing Presentation'),
|
||||||
|
unicode(translate('PresentationPlugin.MediaItem',
|
||||||
|
'The Presentation %s no longer exists.')) % filename)
|
||||||
|
return False
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@ -280,7 +290,7 @@ class PresentationMediaItem(MediaManagerItem):
|
|||||||
file type. This is used if "Automatic" is set as the preferred
|
file type. This is used if "Automatic" is set as the preferred
|
||||||
controller. Find the first (alphabetic) enabled controller which
|
controller. Find the first (alphabetic) enabled controller which
|
||||||
"supports" the extension. If none found, then look for a controller
|
"supports" the extension. If none found, then look for a controller
|
||||||
which "alsosupports" it instead.
|
which "also supports" it instead.
|
||||||
"""
|
"""
|
||||||
filetype = filename.split(u'.')[1]
|
filetype = filename.split(u'.')[1]
|
||||||
if not filetype:
|
if not filetype:
|
||||||
@ -293,4 +303,4 @@ class PresentationMediaItem(MediaManagerItem):
|
|||||||
if self.controllers[controller].enabled():
|
if self.controllers[controller].enabled():
|
||||||
if filetype in self.controllers[controller].alsosupports:
|
if filetype in self.controllers[controller].alsosupports:
|
||||||
return controller
|
return controller
|
||||||
return None
|
return None
|
||||||
|
Loading…
Reference in New Issue
Block a user