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:
|
||||||
|
@ -825,8 +825,18 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
|||||||
else:
|
else:
|
||||||
event.ignore()
|
event.ignore()
|
||||||
else:
|
else:
|
||||||
|
ret = QtGui.QMessageBox.question(self,
|
||||||
|
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()
|
self.cleanUp()
|
||||||
event.accept()
|
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())
|
||||||
|
if os.path.exists(filename):
|
||||||
(path, name) = os.path.split(filename)
|
(path, name) = os.path.split(filename)
|
||||||
service_item.add_from_image(filename, name)
|
service_item.add_from_image(filename, name)
|
||||||
return True
|
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
|
||||||
|
|
||||||
|
@ -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,6 +122,7 @@ 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())
|
||||||
|
if os.path.exists(filename):
|
||||||
service_item.title = unicode(
|
service_item.title = unicode(
|
||||||
translate('MediaPlugin.MediaItem', 'Media'))
|
translate('MediaPlugin.MediaItem', 'Media'))
|
||||||
service_item.add_capability(ItemCapabilities.RequiresMedia)
|
service_item.add_capability(ItemCapabilities.RequiresMedia)
|
||||||
@ -131,6 +132,14 @@ class MediaMediaItem(MediaManagerItem):
|
|||||||
(path, name) = os.path.split(filename)
|
(path, name) = os.path.split(filename)
|
||||||
service_item.add_from_command(path, name, frame)
|
service_item.add_from_command(path, name, frame)
|
||||||
return True
|
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(
|
||||||
|
@ -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
|
||||||
|
@ -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,8 +254,10 @@ 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 os.path.exists(filename):
|
||||||
if shortname == self.Automatic:
|
if shortname == self.Automatic:
|
||||||
service_item.shortname = self.findControllerByType(filename)
|
service_item.shortname = \
|
||||||
|
self.findControllerByType(filename)
|
||||||
if not service_item.shortname:
|
if not service_item.shortname:
|
||||||
return False
|
return False
|
||||||
controller = self.controllers[service_item.shortname]
|
controller = self.controllers[service_item.shortname]
|
||||||
@ -271,6 +273,14 @@ class PresentationMediaItem(MediaManagerItem):
|
|||||||
img = doc.get_thumbnail_path(i, True)
|
img = doc.get_thumbnail_path(i, True)
|
||||||
doc.close_presentation()
|
doc.close_presentation()
|
||||||
return True
|
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:
|
||||||
|
Loading…
Reference in New Issue
Block a user