This commit is contained in:
Jonathan Corwin 2010-04-22 22:23:14 +01:00
commit 496b7befce
7 changed files with 128 additions and 145 deletions

View File

@ -357,11 +357,14 @@ class MediaManagerItem(QtGui.QWidget):
Validates to see if the file still exists or Validates to see if the file still exists or
thumbnail is up to date thumbnail is up to date
""" """
if os.path.exists(file):
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)
return True
return False
def IconFromFile(self, file, thumb): def IconFromFile(self, file, thumb):
icon = build_icon(unicode(file)) icon = build_icon(unicode(file))

View File

@ -1,82 +1,92 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
# Form implementation generated from reading ui file 'alertdialog.ui' ###############################################################################
# # OpenLP - Open Source Lyrics Projection #
# Created: Sat Apr 17 08:07:40 2010 # --------------------------------------------------------------------------- #
# by: PyQt4 UI code generator 4.7 # Copyright (c) 2008-2010 Raoul Snyman #
# # Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael #
# WARNING! All changes made in this file will be lost! # Gorven, Scott Guerrieri, Christian Richter, Maikel Stuivenberg, Martin #
# Thompson, Jon Tibble, Carsten Tinggaard #
# --------------------------------------------------------------------------- #
# This program is free software; you can redistribute it and/or modify it #
# under the terms of the GNU General Public License as published by the Free #
# Software Foundation; version 2 of the License. #
# #
# This program is distributed in the hope that it will be useful, but WITHOUT #
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for #
# more details. #
# #
# You should have received a copy of the GNU General Public License along #
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
###############################################################################
from PyQt4 import QtCore, QtGui from PyQt4 import QtCore, QtGui
class Ui_AlertDialog(object): class Ui_AlertDialog(object):
def setupUi(self, AlertDialog): def setupUi(self, AlertDialog):
AlertDialog.setObjectName("AlertDialog") AlertDialog.setObjectName(u'AlertDialog')
AlertDialog.resize(567, 440) AlertDialog.resize(567, 440)
icon = QtGui.QIcon() icon = QtGui.QIcon()
icon.addPixmap(QtGui.QPixmap(":/icon/openlp.org-icon-32.bmp"), QtGui.QIcon.Normal, QtGui.QIcon.Off) icon.addPixmap(QtGui.QPixmap(u':/icon/openlp.org-icon-32.bmp'), QtGui.QIcon.Normal, QtGui.QIcon.Off)
AlertDialog.setWindowIcon(icon) AlertDialog.setWindowIcon(icon)
self.AlertFormLayout = QtGui.QVBoxLayout(AlertDialog) self.AlertFormLayout = QtGui.QVBoxLayout(AlertDialog)
self.AlertFormLayout.setSpacing(8) self.AlertFormLayout.setSpacing(8)
self.AlertFormLayout.setMargin(8) self.AlertFormLayout.setMargin(8)
self.AlertFormLayout.setObjectName("AlertFormLayout") self.AlertFormLayout.setObjectName(u'AlertFormLayout')
self.AlertTextLayout = QtGui.QFormLayout() self.AlertTextLayout = QtGui.QFormLayout()
self.AlertTextLayout.setContentsMargins(0, 0, -1, -1) self.AlertTextLayout.setContentsMargins(0, 0, -1, -1)
self.AlertTextLayout.setSpacing(8) self.AlertTextLayout.setSpacing(8)
self.AlertTextLayout.setObjectName("AlertTextLayout") self.AlertTextLayout.setObjectName(u'AlertTextLayout')
self.AlertEntryLabel = QtGui.QLabel(AlertDialog) self.AlertEntryLabel = QtGui.QLabel(AlertDialog)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Fixed) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0) sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0) sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.AlertEntryLabel.sizePolicy().hasHeightForWidth()) sizePolicy.setHeightForWidth(self.AlertEntryLabel.sizePolicy().hasHeightForWidth())
self.AlertEntryLabel.setSizePolicy(sizePolicy) self.AlertEntryLabel.setSizePolicy(sizePolicy)
self.AlertEntryLabel.setObjectName("AlertEntryLabel") self.AlertEntryLabel.setObjectName(u'AlertEntryLabel')
self.AlertTextLayout.setWidget(0, QtGui.QFormLayout.LabelRole, self.AlertEntryLabel) self.AlertTextLayout.setWidget(0, QtGui.QFormLayout.LabelRole, self.AlertEntryLabel)
self.AlertParameter = QtGui.QLabel(AlertDialog) self.AlertParameter = QtGui.QLabel(AlertDialog)
self.AlertParameter.setObjectName("AlertParameter") self.AlertParameter.setObjectName(u'AlertParameter')
self.AlertTextLayout.setWidget(1, QtGui.QFormLayout.LabelRole, self.AlertParameter) self.AlertTextLayout.setWidget(1, QtGui.QFormLayout.LabelRole, self.AlertParameter)
self.ParameterEdit = QtGui.QLineEdit(AlertDialog) self.ParameterEdit = QtGui.QLineEdit(AlertDialog)
self.ParameterEdit.setObjectName("ParameterEdit") self.ParameterEdit.setObjectName(u'ParameterEdit')
self.AlertTextLayout.setWidget(1, QtGui.QFormLayout.FieldRole, self.ParameterEdit) self.AlertTextLayout.setWidget(1, QtGui.QFormLayout.FieldRole, self.ParameterEdit)
self.AlertTextEdit = QtGui.QLineEdit(AlertDialog) self.AlertTextEdit = QtGui.QLineEdit(AlertDialog)
self.AlertTextEdit.setObjectName("AlertTextEdit") self.AlertTextEdit.setObjectName(u'AlertTextEdit')
self.AlertTextLayout.setWidget(0, QtGui.QFormLayout.FieldRole, self.AlertTextEdit) self.AlertTextLayout.setWidget(0, QtGui.QFormLayout.FieldRole, self.AlertTextEdit)
self.AlertFormLayout.addLayout(self.AlertTextLayout) self.AlertFormLayout.addLayout(self.AlertTextLayout)
self.ManagementLayout = QtGui.QHBoxLayout() self.ManagementLayout = QtGui.QHBoxLayout()
self.ManagementLayout.setSpacing(8) self.ManagementLayout.setSpacing(8)
self.ManagementLayout.setContentsMargins(-1, -1, -1, 0) self.ManagementLayout.setContentsMargins(-1, -1, -1, 0)
self.ManagementLayout.setObjectName("ManagementLayout") self.ManagementLayout.setObjectName(u'ManagementLayout')
self.AlertListWidget = QtGui.QListWidget(AlertDialog) self.AlertListWidget = QtGui.QListWidget(AlertDialog)
self.AlertListWidget.setAlternatingRowColors(True) self.AlertListWidget.setAlternatingRowColors(True)
self.AlertListWidget.setObjectName("AlertListWidget") self.AlertListWidget.setObjectName(u'AlertListWidget')
self.ManagementLayout.addWidget(self.AlertListWidget) self.ManagementLayout.addWidget(self.AlertListWidget)
self.ManageButtonLayout = QtGui.QVBoxLayout() self.ManageButtonLayout = QtGui.QVBoxLayout()
self.ManageButtonLayout.setSpacing(8) self.ManageButtonLayout.setSpacing(8)
self.ManageButtonLayout.setObjectName("ManageButtonLayout") self.ManageButtonLayout.setObjectName(u'ManageButtonLayout')
self.NewButton = QtGui.QPushButton(AlertDialog) self.NewButton = QtGui.QPushButton(AlertDialog)
icon1 = QtGui.QIcon() icon1 = QtGui.QIcon()
icon1.addPixmap(QtGui.QPixmap(":/general/general_new.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) icon1.addPixmap(QtGui.QPixmap(u':/general/general_new.png'), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.NewButton.setIcon(icon1) self.NewButton.setIcon(icon1)
self.NewButton.setObjectName("NewButton") self.NewButton.setObjectName(u'NewButton')
self.ManageButtonLayout.addWidget(self.NewButton) self.ManageButtonLayout.addWidget(self.NewButton)
self.SaveButton = QtGui.QPushButton(AlertDialog) self.SaveButton = QtGui.QPushButton(AlertDialog)
self.SaveButton.setEnabled(False) self.SaveButton.setEnabled(False)
icon2 = QtGui.QIcon() icon2 = QtGui.QIcon()
icon2.addPixmap(QtGui.QPixmap(":/general/general_save.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) icon2.addPixmap(QtGui.QPixmap(u':/general/general_save.png'), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.SaveButton.setIcon(icon2) self.SaveButton.setIcon(icon2)
self.SaveButton.setObjectName("SaveButton") self.SaveButton.setObjectName(u'SaveButton')
self.ManageButtonLayout.addWidget(self.SaveButton) self.ManageButtonLayout.addWidget(self.SaveButton)
self.EditButton = QtGui.QPushButton(AlertDialog)
icon3 = QtGui.QIcon()
icon3.addPixmap(QtGui.QPixmap(":/general/general_edit.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.EditButton.setIcon(icon3)
self.EditButton.setObjectName("EditButton")
self.ManageButtonLayout.addWidget(self.EditButton)
self.DeleteButton = QtGui.QPushButton(AlertDialog) self.DeleteButton = QtGui.QPushButton(AlertDialog)
icon4 = QtGui.QIcon() icon3 = QtGui.QIcon()
icon4.addPixmap(QtGui.QPixmap(":/general/general_delete.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) icon3.addPixmap(QtGui.QPixmap(u':/general/general_delete.png'), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.DeleteButton.setIcon(icon4) self.DeleteButton.setIcon(icon3)
self.DeleteButton.setObjectName("DeleteButton") self.DeleteButton.setObjectName(u'DeleteButton')
self.ManageButtonLayout.addWidget(self.DeleteButton) self.ManageButtonLayout.addWidget(self.DeleteButton)
spacerItem = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) spacerItem = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
self.ManageButtonLayout.addItem(spacerItem) self.ManageButtonLayout.addItem(spacerItem)
@ -84,51 +94,52 @@ class Ui_AlertDialog(object):
self.AlertFormLayout.addLayout(self.ManagementLayout) self.AlertFormLayout.addLayout(self.ManagementLayout)
self.AlertButtonLayout = QtGui.QHBoxLayout() self.AlertButtonLayout = QtGui.QHBoxLayout()
self.AlertButtonLayout.setSpacing(8) self.AlertButtonLayout.setSpacing(8)
self.AlertButtonLayout.setObjectName("AlertButtonLayout") self.AlertButtonLayout.setObjectName(u'AlertButtonLayout')
spacerItem1 = QtGui.QSpacerItem(181, 0, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) spacerItem1 = QtGui.QSpacerItem(181, 0, QtGui.QSizePolicy.Expanding,
QtGui.QSizePolicy.Minimum)
self.AlertButtonLayout.addItem(spacerItem1) self.AlertButtonLayout.addItem(spacerItem1)
self.DisplayButton = QtGui.QPushButton(AlertDialog) self.DisplayButton = QtGui.QPushButton(AlertDialog)
icon5 = QtGui.QIcon() icon4 = QtGui.QIcon()
icon5.addPixmap(QtGui.QPixmap(":/general/general_live.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) icon4.addPixmap(QtGui.QPixmap(u':/general/general_live.png'),
self.DisplayButton.setIcon(icon5) QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.DisplayButton.setObjectName("DisplayButton") self.DisplayButton.setIcon(icon4)
self.DisplayButton.setObjectName(u'DisplayButton')
self.AlertButtonLayout.addWidget(self.DisplayButton) self.AlertButtonLayout.addWidget(self.DisplayButton)
self.DisplayCloseButton = QtGui.QPushButton(AlertDialog) self.DisplayCloseButton = QtGui.QPushButton(AlertDialog)
self.DisplayCloseButton.setIcon(icon5) self.DisplayCloseButton.setIcon(icon4)
self.DisplayCloseButton.setObjectName("DisplayCloseButton") self.DisplayCloseButton.setObjectName(u'DisplayCloseButton')
self.AlertButtonLayout.addWidget(self.DisplayCloseButton) self.AlertButtonLayout.addWidget(self.DisplayCloseButton)
self.CloseButton = QtGui.QPushButton(AlertDialog) self.CloseButton = QtGui.QPushButton(AlertDialog)
icon6 = QtGui.QIcon() icon5 = QtGui.QIcon()
icon6.addPixmap(QtGui.QPixmap(":/system/system_close.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) icon5.addPixmap(QtGui.QPixmap(u':/system/system_close.png'),
self.CloseButton.setIcon(icon6) QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.CloseButton.setObjectName("CloseButton") self.CloseButton.setIcon(icon5)
self.CloseButton.setObjectName(u'CloseButton')
self.AlertButtonLayout.addWidget(self.CloseButton) self.AlertButtonLayout.addWidget(self.CloseButton)
self.AlertFormLayout.addLayout(self.AlertButtonLayout) self.AlertFormLayout.addLayout(self.AlertButtonLayout)
self.AlertEntryLabel.setBuddy(self.AlertTextEdit) self.AlertEntryLabel.setBuddy(self.AlertTextEdit)
self.AlertParameter.setBuddy(self.ParameterEdit) self.AlertParameter.setBuddy(self.ParameterEdit)
self.retranslateUi(AlertDialog) self.retranslateUi(AlertDialog)
QtCore.QObject.connect(self.CloseButton, QtCore.SIGNAL("clicked()"), AlertDialog.close) QtCore.QObject.connect(self.CloseButton, QtCore.SIGNAL(u'clicked()'), AlertDialog.close)
QtCore.QMetaObject.connectSlotsByName(AlertDialog) QtCore.QMetaObject.connectSlotsByName(AlertDialog)
AlertDialog.setTabOrder(self.AlertTextEdit, self.ParameterEdit) AlertDialog.setTabOrder(self.AlertTextEdit, self.ParameterEdit)
AlertDialog.setTabOrder(self.ParameterEdit, self.AlertListWidget) AlertDialog.setTabOrder(self.ParameterEdit, self.AlertListWidget)
AlertDialog.setTabOrder(self.AlertListWidget, self.NewButton) AlertDialog.setTabOrder(self.AlertListWidget, self.NewButton)
AlertDialog.setTabOrder(self.NewButton, self.SaveButton) AlertDialog.setTabOrder(self.NewButton, self.SaveButton)
AlertDialog.setTabOrder(self.SaveButton, self.EditButton) AlertDialog.setTabOrder(self.SaveButton, self.DeleteButton)
AlertDialog.setTabOrder(self.EditButton, self.DeleteButton)
AlertDialog.setTabOrder(self.DeleteButton, self.DisplayButton) AlertDialog.setTabOrder(self.DeleteButton, self.DisplayButton)
AlertDialog.setTabOrder(self.DisplayButton, self.DisplayCloseButton) AlertDialog.setTabOrder(self.DisplayButton, self.DisplayCloseButton)
AlertDialog.setTabOrder(self.DisplayCloseButton, self.CloseButton) AlertDialog.setTabOrder(self.DisplayCloseButton, self.CloseButton)
def retranslateUi(self, AlertDialog): def retranslateUi(self, AlertDialog):
AlertDialog.setWindowTitle(QtGui.QApplication.translate("AlertDialog", "Alert Message", None, QtGui.QApplication.UnicodeUTF8)) AlertDialog.setWindowTitle(self.trUtf8('Alert Message'))
self.AlertEntryLabel.setText(QtGui.QApplication.translate("AlertDialog", "Alert &text:", None, QtGui.QApplication.UnicodeUTF8)) self.AlertEntryLabel.setText(self.trUtf8('Alert &text:'))
self.AlertParameter.setText(QtGui.QApplication.translate("AlertDialog", "&Parameter(s):", None, QtGui.QApplication.UnicodeUTF8)) self.AlertParameter.setText(self.trUtf8('&Parameter(s):'))
self.NewButton.setText(QtGui.QApplication.translate("AlertDialog", "&New", None, QtGui.QApplication.UnicodeUTF8)) self.NewButton.setText(self.trUtf8('&New'))
self.SaveButton.setText(QtGui.QApplication.translate("AlertDialog", "&Save", None, QtGui.QApplication.UnicodeUTF8)) self.SaveButton.setText(self.trUtf8('&Save'))
self.EditButton.setText(QtGui.QApplication.translate("AlertDialog", "&Edit", None, QtGui.QApplication.UnicodeUTF8)) self.DeleteButton.setText(self.trUtf8('&Delete'))
self.DeleteButton.setText(QtGui.QApplication.translate("AlertDialog", "&Delete", None, QtGui.QApplication.UnicodeUTF8)) self.DisplayButton.setText(self.trUtf8('Displ&ay'))
self.DisplayButton.setText(QtGui.QApplication.translate("AlertDialog", "Displ&ay", None, QtGui.QApplication.UnicodeUTF8)) self.DisplayCloseButton.setText(self.trUtf8('Display && Cl&ose'))
self.DisplayCloseButton.setText(QtGui.QApplication.translate("AlertDialog", "Display && Cl&ose", None, QtGui.QApplication.UnicodeUTF8)) self.CloseButton.setText(self.trUtf8('&Close'))
self.CloseButton.setText(QtGui.QApplication.translate("AlertDialog", "&Close", None, QtGui.QApplication.UnicodeUTF8))

View File

@ -39,7 +39,7 @@ class AlertForm(QtGui.QDialog, Ui_AlertDialog):
""" """
self.manager = manager self.manager = manager
self.parent = parent self.parent = parent
self.history_required = True self.item_id = None
QtGui.QDialog.__init__(self, None) QtGui.QDialog.__init__(self, None)
self.setupUi(self) self.setupUi(self)
QtCore.QObject.connect(self.DisplayButton, QtCore.QObject.connect(self.DisplayButton,
@ -57,9 +57,6 @@ class AlertForm(QtGui.QDialog, Ui_AlertDialog):
QtCore.QObject.connect(self.DeleteButton, QtCore.QObject.connect(self.DeleteButton,
QtCore.SIGNAL(u'clicked()'), QtCore.SIGNAL(u'clicked()'),
self.onDeleteClick) self.onDeleteClick)
QtCore.QObject.connect(self.EditButton,
QtCore.SIGNAL(u'clicked()'),
self.onEditClick)
QtCore.QObject.connect(self.SaveButton, QtCore.QObject.connect(self.SaveButton,
QtCore.SIGNAL(u'clicked()'), QtCore.SIGNAL(u'clicked()'),
self.onSaveClick) self.onSaveClick)
@ -79,12 +76,10 @@ class AlertForm(QtGui.QDialog, Ui_AlertDialog):
QtCore.Qt.UserRole, QtCore.QVariant(alert.id)) QtCore.Qt.UserRole, QtCore.QVariant(alert.id))
self.AlertListWidget.addItem(item_name) self.AlertListWidget.addItem(item_name)
self.SaveButton.setEnabled(False) self.SaveButton.setEnabled(False)
self.EditButton.setEnabled(False)
self.DeleteButton.setEnabled(False) self.DeleteButton.setEnabled(False)
def onDisplayClicked(self): def onDisplayClicked(self):
if self.triggerAlert(unicode(self.AlertTextEdit.text())): if self.triggerAlert(unicode(self.AlertTextEdit.text())):
self.history_required = False
self.loadList() self.loadList()
def onDisplayCloseClicked(self): def onDisplayCloseClicked(self):
@ -103,15 +98,6 @@ class AlertForm(QtGui.QDialog, Ui_AlertDialog):
self.DeleteButton.setEnabled(False) self.DeleteButton.setEnabled(False)
self.EditButton.setEnabled(False) self.EditButton.setEnabled(False)
def onEditClick(self):
item = self.AlertListWidget.currentItem()
if item:
self.item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
self.AlertTextEdit.setText(unicode(item.text()))
self.SaveButton.setEnabled(True)
self.DeleteButton.setEnabled(True)
self.EditButton.setEnabled(False)
def onNewClick(self): def onNewClick(self):
if len(self.AlertTextEdit.text()) == 0: if len(self.AlertTextEdit.text()) == 0:
QtGui.QMessageBox.information(self, QtGui.QMessageBox.information(self,
@ -121,19 +107,22 @@ class AlertForm(QtGui.QDialog, Ui_AlertDialog):
alert = AlertItem() alert = AlertItem()
alert.text = unicode(self.AlertTextEdit.text()) alert.text = unicode(self.AlertTextEdit.text())
self.manager.save_alert(alert) self.manager.save_alert(alert)
self.onClearClick() self.AlertTextEdit.setText(u'')
self.loadList() self.loadList()
def onSaveClick(self): def onSaveClick(self):
if self.item_id:
alert = self.manager.get_alert(self.item_id) alert = self.manager.get_alert(self.item_id)
alert.text = unicode(self.AlertTextEdit.text()) alert.text = unicode(self.AlertTextEdit.text())
self.manager.save_alert(alert) self.manager.save_alert(alert)
self.onClearClick() self.item_id = None
self.loadList() self.loadList()
else:
self.onNewClick()
def onTextChanged(self): def onTextChanged(self):
#Data has changed by editing it so potential storage required #Data has changed by editing it so potential storage required
self.history_required = True self.SaveButton.setEnabled(True)
def onDoubleClick(self): def onDoubleClick(self):
""" """
@ -143,7 +132,10 @@ class AlertForm(QtGui.QDialog, Ui_AlertDialog):
for item in items: for item in items:
bitem = self.AlertListWidget.item(item.row()) bitem = self.AlertListWidget.item(item.row())
self.triggerAlert(bitem.text()) self.triggerAlert(bitem.text())
self.history_required = False self.AlertTextEdit.setText(bitem.text())
self.item_id = (bitem.data(QtCore.Qt.UserRole)).toInt()[0]
self.SaveButton.setEnabled(False)
self.DeleteButton.setEnabled(True)
def onSingleClick(self): def onSingleClick(self):
""" """
@ -154,16 +146,13 @@ class AlertForm(QtGui.QDialog, Ui_AlertDialog):
for item in items: for item in items:
bitem = self.AlertListWidget.item(item.row()) bitem = self.AlertListWidget.item(item.row())
self.AlertTextEdit.setText(bitem.text()) self.AlertTextEdit.setText(bitem.text())
self.history_required = False self.item_id = (bitem.data(QtCore.Qt.UserRole)).toInt()[0]
self.EditButton.setEnabled(True) self.SaveButton.setEnabled(False)
self.DeleteButton.setEnabled(True) self.DeleteButton.setEnabled(True)
def triggerAlert(self, text): def triggerAlert(self, text):
if text: if text:
text = text.replace(u'<>', unicode(self.ParameterEdit.text()))
self.parent.alertsmanager.displayAlert(text) self.parent.alertsmanager.displayAlert(text)
if self.parent.alertsTab.save_history and self.history_required:
alert = AlertItem()
alert.text = unicode(self.AlertTextEdit.text())
self.manager.save_alert(alert)
return True return True
return False return False

View File

@ -34,7 +34,6 @@ class AlertsTab(SettingsTab):
def __init__(self, parent, section=None): def __init__(self, parent, section=None):
self.parent = parent self.parent = parent
self.manager = parent.manager self.manager = parent.manager
self.alertsmanager = parent.alertsmanager
SettingsTab.__init__(self, parent.name, section) SettingsTab.__init__(self, parent.name, section)
def setupUi(self): def setupUi(self):
@ -135,22 +134,6 @@ class AlertsTab(SettingsTab):
QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
self.LocationLayout.addItem(self.LocationSpacer) self.LocationLayout.addItem(self.LocationSpacer)
self.FontLayout.addWidget(self.LocationWidget) self.FontLayout.addWidget(self.LocationWidget)
self.HistoryWidget = QtGui.QWidget(self.FontGroupBox)
self.HistoryWidget.setObjectName(u'HistoryWidget')
self.HistoryLayout = QtGui.QHBoxLayout(self.HistoryWidget)
self.HistoryLayout.setSpacing(8)
self.HistoryLayout.setMargin(0)
self.HistoryLayout.setObjectName(u'HistoryLayout')
self.HistoryLabel = QtGui.QLabel(self.HistoryWidget)
self.HistoryLabel.setObjectName(u'HistoryLabel')
self.HistoryLayout.addWidget(self.HistoryLabel)
self.HistoryCheckBox = QtGui.QCheckBox(self.HistoryWidget)
self.HistoryCheckBox.setObjectName(u'HistoryCheckBox')
self.HistoryLayout.addWidget(self.HistoryCheckBox)
self.HistorySpacer = QtGui.QSpacerItem(147, 20,
QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
self.HistoryLayout.addItem(self.HistorySpacer)
self.FontLayout.addWidget(self.HistoryWidget)
self.SlideLeftLayout.addWidget(self.FontGroupBox) self.SlideLeftLayout.addWidget(self.FontGroupBox)
self.SlideLeftSpacer = QtGui.QSpacerItem(20, 94, self.SlideLeftSpacer = QtGui.QSpacerItem(20, 94,
QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
@ -189,9 +172,6 @@ class AlertsTab(SettingsTab):
self.SlideRightLayout.addItem(self.SlideRightSpacer) self.SlideRightLayout.addItem(self.SlideRightSpacer)
self.AlertsLayout.addWidget(self.AlertRightColumn) self.AlertsLayout.addWidget(self.AlertRightColumn)
# Signals and slots # Signals and slots
QtCore.QObject.connect(self.HistoryCheckBox,
QtCore.SIGNAL(u'stateChanged(int)'),
self.onHistoryCheckBoxChanged)
QtCore.QObject.connect(self.BackgroundColorButton, QtCore.QObject.connect(self.BackgroundColorButton,
QtCore.SIGNAL(u'pressed()'), self.onBackgroundColorButtonClicked) QtCore.SIGNAL(u'pressed()'), self.onBackgroundColorButtonClicked)
QtCore.QObject.connect(self.FontColorButton, QtCore.QObject.connect(self.FontColorButton,
@ -215,7 +195,6 @@ class AlertsTab(SettingsTab):
self.TimeoutLabel.setText(self.trUtf8('Alert timeout:')) self.TimeoutLabel.setText(self.trUtf8('Alert timeout:'))
self.TimeoutSpinBox.setSuffix(self.trUtf8('s')) self.TimeoutSpinBox.setSuffix(self.trUtf8('s'))
self.LocationLabel.setText(self.trUtf8('Location:')) self.LocationLabel.setText(self.trUtf8('Location:'))
self.HistoryLabel.setText(self.trUtf8('Keep History:'))
self.PreviewGroupBox.setTitle(self.trUtf8('Preview')) self.PreviewGroupBox.setTitle(self.trUtf8('Preview'))
self.FontPreview.setText(self.trUtf8('openlp.org')) self.FontPreview.setText(self.trUtf8('openlp.org'))
self.LocationComboBox.setItemText(0, self.trUtf8('Top')) self.LocationComboBox.setItemText(0, self.trUtf8('Top'))
@ -234,12 +213,6 @@ class AlertsTab(SettingsTab):
def onLocationComboBoxClicked(self, location): def onLocationComboBoxClicked(self, location):
self.location = location self.location = location
def onHistoryCheckBoxChanged(self, check_state):
self.save_history = False
# we have a set value convert to True/False
if check_state == QtCore.Qt.Checked:
self.save_history = True
def onFontColorButtonClicked(self): def onFontColorButtonClicked(self):
self.font_color = QtGui.QColorDialog.getColor( self.font_color = QtGui.QColorDialog.getColor(
QtGui.QColor(self.font_color), self).name() QtGui.QColor(self.font_color), self).name()
@ -264,8 +237,6 @@ class AlertsTab(SettingsTab):
self.font_face = unicode( self.font_face = unicode(
self.config.get_config(u'font face', QtGui.QFont().family())) self.config.get_config(u'font face', QtGui.QFont().family()))
self.location = int(self.config.get_config(u'location', 0)) self.location = int(self.config.get_config(u'location', 0))
self.save_history = str_to_bool(
self.config.get_config(u'save history', u'False'))
self.FontSizeSpinBox.setValue(self.font_size) self.FontSizeSpinBox.setValue(self.font_size)
self.TimeoutSpinBox.setValue(self.timeout) self.TimeoutSpinBox.setValue(self.timeout)
self.FontColorButton.setStyleSheet( self.FontColorButton.setStyleSheet(
@ -273,7 +244,6 @@ class AlertsTab(SettingsTab):
self.BackgroundColorButton.setStyleSheet( self.BackgroundColorButton.setStyleSheet(
u'background-color: %s' % self.bg_color) u'background-color: %s' % self.bg_color)
self.LocationComboBox.setCurrentIndex(self.location) self.LocationComboBox.setCurrentIndex(self.location)
self.HistoryCheckBox.setChecked(self.save_history)
font = QtGui.QFont() font = QtGui.QFont()
font.setFamily(self.font_face) font.setFamily(self.font_face)
self.FontComboBox.setCurrentFont(font) self.FontComboBox.setCurrentFont(font)
@ -292,7 +262,6 @@ class AlertsTab(SettingsTab):
self.config.set_config(u'timeout', unicode(self.timeout)) self.config.set_config(u'timeout', unicode(self.timeout))
self.config.set_config(u'location', self.config.set_config(u'location',
unicode(self.LocationComboBox.currentIndex())) unicode(self.LocationComboBox.currentIndex()))
self.config.set_config(u'save history', unicode(self.save_history))
def updateDisplay(self): def updateDisplay(self):
font = QtGui.QFont() font = QtGui.QFont()

View File

@ -124,8 +124,10 @@ class ImageMediaItem(MediaManagerItem):
(path, filename) = os.path.split(unicode(file)) (path, filename) = os.path.split(unicode(file))
thumb = os.path.join(self.servicePath, filename) thumb = os.path.join(self.servicePath, filename)
if os.path.exists(thumb): if os.path.exists(thumb):
self.validate(file, thumb) if self.validate(file, thumb):
icon = build_icon(thumb) icon = build_icon(thumb)
else:
icon = build_icon(u':/general/general_delete.png')
else: else:
icon = self.IconFromFile(file, thumb) icon = self.IconFromFile(file, thumb)
item_name = QtGui.QListWidgetItem(filename) item_name = QtGui.QListWidgetItem(filename)

View File

@ -28,7 +28,7 @@ import os
from PyQt4 import QtCore, QtGui from PyQt4 import QtCore, QtGui
from openlp.core.lib import MediaManagerItem, BaseListWithDnD from openlp.core.lib import MediaManagerItem, BaseListWithDnD, build_icon
from openlp.plugins.presentations.lib import MessageListener from openlp.plugins.presentations.lib import MessageListener
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
@ -103,6 +103,10 @@ class PresentationMediaItem(MediaManagerItem):
self.PageLayout.addWidget(self.PresentationWidget) self.PageLayout.addWidget(self.PresentationWidget)
def initialise(self): def initialise(self):
self.servicePath = os.path.join(
self.parent.config.get_data_path(), u'thumbnails')
if not os.path.exists(self.servicePath):
os.mkdir(self.servicePath)
list = self.parent.config.load_list(u'presentations') list = self.parent.config.load_list(u'presentations')
self.loadList(list) self.loadList(list)
for item in self.controllers: for item in self.controllers:
@ -128,8 +132,27 @@ class PresentationMediaItem(MediaManagerItem):
'A presentation with that filename already exists.'), 'A presentation with that filename already exists.'),
QtGui.QMessageBox.Ok) QtGui.QMessageBox.Ok)
else: else:
icon = None
for controller in self.controllers:
thumbPath = os.path.join(self.parent.config.get_data_path(), \
u'thumbnails', controller, filename)
thumb = os.path.join(thumbPath, u'slide1.png')
preview = os.path.join(self.parent.config.get_data_path(), \
controller, u'thumbnails', filename, u'slide1.png')
if os.path.exists(preview):
if os.path.exists(thumb):
if self.validate(preview, thumb):
icon = build_icon(thumb)
else:
icon = build_icon(u':/general/general_delete.png')
else:
os.makedirs(thumbPath)
icon = self.IconFromFile(preview, thumb)
if not icon:
icon = build_icon(u':/general/general_delete.png')
item_name = QtGui.QListWidgetItem(filename) item_name = QtGui.QListWidgetItem(filename)
item_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(file)) item_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(file))
item_name.setIcon(icon)
self.ListView.addItem(item_name) self.ListView.addItem(item_name)
def onDeleteClick(self): def onDeleteClick(self):

View File

@ -98,7 +98,7 @@
<string>&amp;New</string> <string>&amp;New</string>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="../Projects/OpenLP/trunk/resources/images/openlp-2.qrc"> <iconset>
<normaloff>:/general/general_new.png</normaloff>:/general/general_new.png</iconset> <normaloff>:/general/general_new.png</normaloff>:/general/general_new.png</iconset>
</property> </property>
</widget> </widget>
@ -112,29 +112,18 @@
<string>&amp;Save</string> <string>&amp;Save</string>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="../Projects/OpenLP/trunk/resources/images/openlp-2.qrc"> <iconset>
<normaloff>:/general/general_save.png</normaloff>:/general/general_save.png</iconset> <normaloff>:/general/general_save.png</normaloff>:/general/general_save.png</iconset>
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QPushButton" name="EditButton">
<property name="text">
<string>&amp;Edit</string>
</property>
<property name="icon">
<iconset resource="../Projects/OpenLP/trunk/resources/images/openlp-2.qrc">
<normaloff>:/general/general_edit.png</normaloff>:/general/general_edit.png</iconset>
</property>
</widget>
</item>
<item> <item>
<widget class="QPushButton" name="DeleteButton"> <widget class="QPushButton" name="DeleteButton">
<property name="text"> <property name="text">
<string>&amp;Delete</string> <string>&amp;Delete</string>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="../Projects/OpenLP/trunk/resources/images/openlp-2.qrc"> <iconset>
<normaloff>:/general/general_delete.png</normaloff>:/general/general_delete.png</iconset> <normaloff>:/general/general_delete.png</normaloff>:/general/general_delete.png</iconset>
</property> </property>
</widget> </widget>
@ -180,7 +169,7 @@
<string>Displ&amp;ay</string> <string>Displ&amp;ay</string>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="../Projects/OpenLP/trunk/resources/images/openlp-2.qrc"> <iconset>
<normaloff>:/general/general_live.png</normaloff>:/general/general_live.png</iconset> <normaloff>:/general/general_live.png</normaloff>:/general/general_live.png</iconset>
</property> </property>
</widget> </widget>
@ -191,7 +180,7 @@
<string>Display &amp;&amp; Cl&amp;ose</string> <string>Display &amp;&amp; Cl&amp;ose</string>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="../Projects/OpenLP/trunk/resources/images/openlp-2.qrc"> <iconset>
<normaloff>:/general/general_live.png</normaloff>:/general/general_live.png</iconset> <normaloff>:/general/general_live.png</normaloff>:/general/general_live.png</iconset>
</property> </property>
</widget> </widget>
@ -202,7 +191,7 @@
<string>&amp;Close</string> <string>&amp;Close</string>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="../Projects/OpenLP/trunk/resources/images/openlp-2.qrc"> <iconset>
<normaloff>:/system/system_close.png</normaloff>:/system/system_close.png</iconset> <normaloff>:/system/system_close.png</normaloff>:/system/system_close.png</iconset>
</property> </property>
</widget> </widget>
@ -217,15 +206,12 @@
<tabstop>AlertListWidget</tabstop> <tabstop>AlertListWidget</tabstop>
<tabstop>NewButton</tabstop> <tabstop>NewButton</tabstop>
<tabstop>SaveButton</tabstop> <tabstop>SaveButton</tabstop>
<tabstop>EditButton</tabstop>
<tabstop>DeleteButton</tabstop> <tabstop>DeleteButton</tabstop>
<tabstop>DisplayButton</tabstop> <tabstop>DisplayButton</tabstop>
<tabstop>DisplayCloseButton</tabstop> <tabstop>DisplayCloseButton</tabstop>
<tabstop>CloseButton</tabstop> <tabstop>CloseButton</tabstop>
</tabstops> </tabstops>
<resources> <resources/>
<include location="../Projects/OpenLP/trunk/resources/images/openlp-2.qrc"/>
</resources>
<connections> <connections>
<connection> <connection>
<sender>CloseButton</sender> <sender>CloseButton</sender>