Head 1186

This commit is contained in:
M2j 2011-01-04 10:19:53 +01:00
commit 6de12718f6
5 changed files with 83 additions and 41 deletions

View File

@ -67,6 +67,10 @@ class AdvancedTab(SettingsTab):
self.expandServiceItemCheckBox.setObjectName( self.expandServiceItemCheckBox.setObjectName(
u'expandServiceItemCheckBox') u'expandServiceItemCheckBox')
self.uiLayout.addRow(self.expandServiceItemCheckBox) self.uiLayout.addRow(self.expandServiceItemCheckBox)
self.enableAutoCloseCheckBox = QtGui.QCheckBox(self.uiGroupBox)
self.enableAutoCloseCheckBox.setObjectName(
u'enableAutoCloseCheckBox')
self.uiLayout.addRow(self.enableAutoCloseCheckBox)
self.leftLayout.addWidget(self.uiGroupBox) self.leftLayout.addWidget(self.uiGroupBox)
# self.sharedDirGroupBox = QtGui.QGroupBox(self.leftColumn) # self.sharedDirGroupBox = QtGui.QGroupBox(self.leftColumn)
# self.sharedDirGroupBox.setObjectName(u'sharedDirGroupBox') # self.sharedDirGroupBox.setObjectName(u'sharedDirGroupBox')
@ -111,6 +115,8 @@ class AdvancedTab(SettingsTab):
'Double-click to send items straight to live')) 'Double-click to send items straight to live'))
self.expandServiceItemCheckBox.setText(translate('OpenLP.AdvancedTab', self.expandServiceItemCheckBox.setText(translate('OpenLP.AdvancedTab',
'Expand new service items on creation')) 'Expand new service items on creation'))
self.enableAutoCloseCheckBox.setText(translate('OpenLP.AdvancedTab',
'Enable application exit confirmation'))
# self.sharedDirGroupBox.setTitle( # self.sharedDirGroupBox.setTitle(
# translate('AdvancedTab', 'Central Data Store')) # translate('AdvancedTab', 'Central Data Store'))
# self.sharedCheckBox.setText( # self.sharedCheckBox.setText(
@ -141,6 +147,9 @@ class AdvancedTab(SettingsTab):
self.expandServiceItemCheckBox.setChecked( self.expandServiceItemCheckBox.setChecked(
settings.value(u'expand service item', settings.value(u'expand service item',
QtCore.QVariant(False)).toBool()) QtCore.QVariant(False)).toBool())
self.enableAutoCloseCheckBox.setChecked(
settings.value(u'enable exit confirmation',
QtCore.QVariant(True)).toBool())
settings.endGroup() settings.endGroup()
def save(self): def save(self):
@ -157,12 +166,14 @@ class AdvancedTab(SettingsTab):
QtCore.QVariant(self.doubleClickLiveCheckBox.isChecked())) QtCore.QVariant(self.doubleClickLiveCheckBox.isChecked()))
settings.setValue(u'expand service item', settings.setValue(u'expand service item',
QtCore.QVariant(self.expandServiceItemCheckBox.isChecked())) QtCore.QVariant(self.expandServiceItemCheckBox.isChecked()))
settings.setValue(u'enable exit confirmation',
QtCore.QVariant(self.enableAutoCloseCheckBox.isChecked()))
settings.endGroup() settings.endGroup()
def onSharedCheckBoxChanged(self, checked): # def onSharedCheckBoxChanged(self, checked):
""" # """
Enables the widgets to allow a shared data location # Enables the widgets to allow a shared data location
""" # """
self.sharedLabel.setEnabled(checked) # self.sharedLabel.setEnabled(checked)
self.sharedTextEdit.setEnabled(checked) # self.sharedTextEdit.setEnabled(checked)
self.sharedPushButton.setEnabled(checked) # self.sharedPushButton.setEnabled(checked)

View File

@ -95,7 +95,6 @@ class MainDisplay(DisplayWidget):
""" """
This is the display screen. This is the display screen.
""" """
def __init__(self, parent, screens, live): def __init__(self, parent, screens, live):
DisplayWidget.__init__(self, live, parent=None) DisplayWidget.__init__(self, live, parent=None)
self.parent = parent self.parent = parent
@ -123,7 +122,7 @@ class MainDisplay(DisplayWidget):
""" """
Set up and build the output screen Set up and build the output screen
""" """
log.debug(u'Setup live = %s for %s ' % (self.isLive, log.debug(u'Setup live = %s for monitor %s ' % (self.isLive,
self.screens.monitor_number)) self.screens.monitor_number))
self.usePhonon = QtCore.QSettings().value( self.usePhonon = QtCore.QSettings().value(
u'media/use phonon', QtCore.QVariant(True)).toBool() u'media/use phonon', QtCore.QVariant(True)).toBool()

View File

@ -820,7 +820,6 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
QtGui.QMessageBox.Save), QtGui.QMessageBox.Save),
QtGui.QMessageBox.Save) QtGui.QMessageBox.Save)
if ret == QtGui.QMessageBox.Save: if ret == QtGui.QMessageBox.Save:
#self.ServiceManagerContents.onSaveService(True)
if self.ServiceManagerContents.saveFile(): if self.ServiceManagerContents.saveFile():
self.cleanUp() self.cleanUp()
event.accept() event.accept()
@ -832,18 +831,25 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
else: else:
event.ignore() event.ignore()
else: else:
ret = QtGui.QMessageBox.question(self, if QtCore.QSettings().value(u'advanced/enable exit confirmation',
translate('OpenLP.MainWindow', 'Close OpenLP'), QtCore.QVariant(True)).toBool():
translate('OpenLP.MainWindow', ret = QtGui.QMessageBox.question(self,
'Are you sure you want to close OpenLP?'), translate('OpenLP.MainWindow', 'Close OpenLP'),
QtGui.QMessageBox.StandardButtons( translate('OpenLP.MainWindow',
QtGui.QMessageBox.Yes | QtGui.QMessageBox.No), 'Are you sure you want to close OpenLP?'),
QtGui.QMessageBox.Yes) QtGui.QMessageBox.StandardButtons(
if ret == QtGui.QMessageBox.Yes: QtGui.QMessageBox.Yes |
QtGui.QMessageBox.No),
QtGui.QMessageBox.Yes)
if ret == QtGui.QMessageBox.Yes:
self.cleanUp()
event.accept()
else:
event.ignore()
else:
self.cleanUp() self.cleanUp()
event.accept() event.accept()
else:
event.ignore()
def cleanUp(self): def cleanUp(self):
""" """

View File

@ -41,7 +41,7 @@ class ImagePlugin(Plugin):
self.icon = build_icon(self.icon_path) self.icon = build_icon(self.icon_path)
def getMediaManagerItem(self): def getMediaManagerItem(self):
# Create the MediaManagerItem object # Create the MediaManagerItem object.
return ImageMediaItem(self, self, self.icon) return ImageMediaItem(self, self, self.icon)
def about(self): def about(self):

View File

@ -31,7 +31,7 @@ from PyQt4 import QtCore, QtGui
from openlp.core.lib import MediaManagerItem, BaseListWithDnD, build_icon, \ from openlp.core.lib import MediaManagerItem, BaseListWithDnD, build_icon, \
context_menu_action, ItemCapabilities, SettingsManager, translate, \ context_menu_action, ItemCapabilities, SettingsManager, translate, \
check_item_selected, Receiver check_item_selected
from openlp.core.utils import AppLocation, get_images_filter from openlp.core.utils import AppLocation, get_images_filter
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
@ -43,6 +43,7 @@ class ImageListView(BaseListWithDnD):
self.PluginName = u'Images' self.PluginName = u'Images'
BaseListWithDnD.__init__(self, parent) BaseListWithDnD.__init__(self, parent)
class ImageMediaItem(MediaManagerItem): class ImageMediaItem(MediaManagerItem):
""" """
This is the custom media manager item for images. This is the custom media manager item for images.
@ -51,8 +52,8 @@ class ImageMediaItem(MediaManagerItem):
def __init__(self, parent, plugin, icon): def __init__(self, parent, plugin, icon):
self.IconPath = u'images/image' self.IconPath = u'images/image'
# this next is a class, not an instance of a class - it will # This next is a class, not an instance of a class - it will
# be instanced by the base MediaManagerItem # be instanced by the base MediaManagerItem.
self.ListViewWithDnD_class = ImageListView self.ListViewWithDnD_class = ImageListView
MediaManagerItem.__init__(self, parent, self, icon) MediaManagerItem.__init__(self, parent, self, icon)
@ -113,7 +114,7 @@ class ImageMediaItem(MediaManagerItem):
u':/system/system_close.png', u':/system/system_close.png',
translate('ImagePlugin.MediaItem', 'Reset Live Background'), translate('ImagePlugin.MediaItem', 'Reset Live Background'),
self.onResetClick, False) self.onResetClick, False)
# Add the song widget to the page layout # Add the song widget to the page layout.
self.pageLayout.addWidget(self.ImageWidget) self.pageLayout.addWidget(self.ImageWidget)
self.resetButton.setVisible(False) self.resetButton.setVisible(False)
@ -165,21 +166,40 @@ class ImageMediaItem(MediaManagerItem):
service_item.add_capability(ItemCapabilities.AllowsAdditions) service_item.add_capability(ItemCapabilities.AllowsAdditions)
# force a nonexistent theme # force a nonexistent theme
service_item.theme = -1 service_item.theme = -1
missing_items = []
missing_items_filenames = []
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 not os.path.exists(filename):
(path, name) = os.path.split(filename) missing_items.append(item)
service_item.add_from_image(filename, name) missing_items_filenames.append(filename)
return True for item in missing_items:
else: items.remove(item)
# File is no longer present # We cannot continue, as all images do not exist.
QtGui.QMessageBox.critical( if not items:
self, translate('ImagePlugin.MediaItem', QtGui.QMessageBox.critical(self,
'Missing Image'), translate('ImagePlugin.MediaItem', 'Missing Image(s)'),
unicode(translate('ImagePlugin.MediaItem', unicode(translate('ImagePlugin.MediaItem',
'The Image %s no longer exists.')) % filename) 'The following image(s) no longer exist: %s')) %
return False u'\n'.join(missing_items_filenames))
return False
# We have missing as well as existing images. We ask what to do.
elif missing_items and QtGui.QMessageBox.question(self,
translate('ImagePlugin.MediaItem', 'Missing Image(s)'),
unicode(translate('ImagePlugin.MediaItem', 'The following '
'image(s) no longer exist: %s\nDo you want to add the other '
'images anyway?')) % u'\n'.join(missing_items_filenames),
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.No |
QtGui.QMessageBox.Yes)) == QtGui.QMessageBox.No:
return False
# Continue with the existing images.
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
else: else:
return False return False
@ -191,12 +211,18 @@ class ImageMediaItem(MediaManagerItem):
if check_item_selected(self.listView, if check_item_selected(self.listView,
translate('ImagePlugin.MediaItem', translate('ImagePlugin.MediaItem',
'You must select an image to replace the background with.')): 'You must select an image to replace the background with.')):
items = self.listView.selectedIndexes() item = self.listView.selectedIndexes()[0]
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)
self.parent.liveController.display.directImage(name, filename) self.parent.liveController.display.directImage(name, filename)
else:
QtGui.QMessageBox.critical(self,
translate('ImagePlugin.MediaItem', 'Live Background Could '
'Not Be Replaced'),
unicode(translate('ImagePlugin.MediaItem',
'The image %s no longer exists.')) % filename)
self.resetButton.setVisible(True) self.resetButton.setVisible(True)
def onPreviewClick(self): def onPreviewClick(self):