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:
Tim Bentley 2010-12-29 17:43:26 +00:00
commit e8ddb4c751
7 changed files with 81 additions and 41 deletions

View File

@ -3,6 +3,7 @@ recursive-include openlp *.sqlite
recursive-include openlp *.csv
recursive-include openlp *.html
recursive-include openlp *.js
recursive-include openlp *.css
recursive-include openlp *.qm
recursive-include documentation *
recursive-include resources/forms *

View File

@ -381,7 +381,7 @@ class MediaManagerItem(QtGui.QWidget):
if os.path.exists(thumb):
filedate = os.stat(file).st_mtime
thumbdate = os.stat(thumb).st_mtime
#if file updated rebuild icon
# if file updated rebuild icon
if filedate > thumbdate:
self.iconFromFile(file, thumb)
else:

View File

@ -825,8 +825,18 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
else:
event.ignore()
else:
self.cleanUp()
event.accept()
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()
event.accept()
else:
event.ignore()
def cleanUp(self):
"""

View File

@ -132,7 +132,7 @@ class ImageMediaItem(MediaManagerItem):
os.remove(os.path.join(self.servicePath,
unicode(text.text())))
except OSError:
#if not present do not worry
# if not present do not worry
pass
self.listView.takeItem(row)
SettingsManager.set_list(self.settingsSection,
@ -172,9 +172,18 @@ class ImageMediaItem(MediaManagerItem):
for item in items:
bitem = self.listView.item(item.row())
filename = unicode(bitem.data(QtCore.Qt.UserRole).toString())
(path, name) = os.path.split(filename)
service_item.add_from_image(filename, name)
return True
if os.path.exists(filename):
(path, name) = os.path.split(filename)
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:
return False

View File

@ -89,7 +89,7 @@ class MediaMediaItem(MediaManagerItem):
self.ImageWidget.sizePolicy().hasHeightForWidth())
self.ImageWidget.setSizePolicy(sizePolicy)
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(
translate('MediaPlugin.MediaItem', 'Replace Background'),
u':/slides/slide_blank.png',
@ -122,15 +122,24 @@ class MediaMediaItem(MediaManagerItem):
if item is None:
return False
filename = unicode(item.data(QtCore.Qt.UserRole).toString())
service_item.title = unicode(
translate('MediaPlugin.MediaItem', 'Media'))
service_item.add_capability(ItemCapabilities.RequiresMedia)
# force a nonexistent theme
service_item.theme = -1
frame = u':/media/image_clapperboard.png'
(path, name) = os.path.split(filename)
service_item.add_from_command(path, name, frame)
return True
if os.path.exists(filename):
service_item.title = unicode(
translate('MediaPlugin.MediaItem', 'Media'))
service_item.add_capability(ItemCapabilities.RequiresMedia)
# force a nonexistent theme
service_item.theme = -1
frame = u':/media/image_clapperboard.png'
(path, name) = os.path.split(filename)
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):
self.listView.setSelectionMode(

View File

@ -255,8 +255,9 @@ class ImpressDocument(PresentationDocument):
self.document = desktop.loadComponentFromURL(url, u'_blank',
0, properties)
except:
log.exception(u'Failed to load presentation')
log.exception(u'Failed to load presentation %s' % url)
return False
self.presentation = self.document.getPresentation()
self.presentation.Display = \
self.controller.plugin.renderManager.screens.current_display + 1

View File

@ -153,7 +153,7 @@ class PresentationMediaItem(MediaManagerItem):
"""
self.DisplayTypeComboBox.clear()
for item in self.controllers:
#load the drop down selection
# load the drop down selection
if self.controllers[item].enabled():
self.DisplayTypeComboBox.addItem(item)
if self.DisplayTypeComboBox.count() > 1:
@ -254,23 +254,33 @@ class PresentationMediaItem(MediaManagerItem):
for item in items:
bitem = self.listView.item(item.row())
filename = unicode(bitem.data(QtCore.Qt.UserRole).toString())
if shortname == self.Automatic:
service_item.shortname = self.findControllerByType(filename)
if not service_item.shortname:
return False
controller = self.controllers[service_item.shortname]
(path, name) = os.path.split(filename)
doc = controller.add_doc(filename)
if doc.get_thumbnail_path(1, True) is None:
doc.load_presentation()
i = 1
img = doc.get_thumbnail_path(i, True)
while img:
service_item.add_from_command(path, name, img)
i = i + 1
if os.path.exists(filename):
if shortname == self.Automatic:
service_item.shortname = \
self.findControllerByType(filename)
if not service_item.shortname:
return False
controller = self.controllers[service_item.shortname]
(path, name) = os.path.split(filename)
doc = controller.add_doc(filename)
if doc.get_thumbnail_path(1, True) is None:
doc.load_presentation()
i = 1
img = doc.get_thumbnail_path(i, True)
doc.close_presentation()
return True
while img:
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:
return False
@ -280,7 +290,7 @@ class PresentationMediaItem(MediaManagerItem):
file type. This is used if "Automatic" is set as the preferred
controller. Find the first (alphabetic) enabled controller which
"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]
if not filetype: