From dcd48d1042556bc1a3ed022b3a202ee1f67337ad Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sat, 17 Apr 2010 08:31:15 +0100 Subject: [PATCH] Clean up alert dialog with new layout Alerts over video starting to work Fix bug in impress close down --- openlp/core/ui/maindisplay.py | 30 +- openlp/core/ui/mainwindow.py | 13 +- openlp/plugins/alerts/alertsplugin.py | 3 +- openlp/plugins/alerts/forms/alertdialog.py | 187 +++++++----- openlp/plugins/alerts/forms/alertform.py | 85 +++++- openlp/plugins/alerts/forms/alertstab.py | 128 -------- openlp/plugins/alerts/lib/alertsmanager.py | 16 +- .../presentations/lib/impresscontroller.py | 1 - resources/forms/alertdialog.ui | 275 +++++++++++++----- resources/forms/alerteditdialog.ui | 101 ------- 10 files changed, 432 insertions(+), 407 deletions(-) delete mode 100644 resources/forms/alerteditdialog.ui diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index c0f9e7648..fe16e7d8b 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -51,8 +51,7 @@ class DisplayWidget(QtGui.QWidget): log.info(u'MainDisplay loaded') def __init__(self, parent=None, name=None): - QtGui.QWidget.__init__(self, None, QtCore.Qt.WindowStaysOnTopHint \ - | QtCore.Qt.FramelessWindowHint) + QtGui.QWidget.__init__(self, None) self.parent = parent self.hotkey_map = {QtCore.Qt.Key_Return: 'servicemanager_next_item', QtCore.Qt.Key_Space: 'live_slidecontroller_next_noloop', @@ -193,6 +192,13 @@ class MainDisplay(DisplayWidget): self.display_image.setPixmap(self.transparent) self.display_alert.setPixmap(self.transparent) self.display_text.setPixmap(self.transparent) + self.moveToTop() + + def moveToTop(self): + log.debug(u'moveToTop') + self.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint \ + | QtCore.Qt.FramelessWindowHint | QtCore.Qt.Dialog) + self.show() def showDisplay(self): log.debug(u'showDisplay') @@ -207,6 +213,7 @@ class MainDisplay(DisplayWidget): self.screen[u'size'].width(), self.screen[u'size'].height() ) self.display_image.setPixmap(QtGui.QPixmap.fromImage(frame)) + self.moveToTop() def setAlertSize(self, top, height): log.debug(u'setAlertSize') @@ -220,6 +227,7 @@ class MainDisplay(DisplayWidget): self.display_alert.setPixmap(self.transparent) else: self.display_alert.setPixmap(frame) + self.moveToTop() def frameView(self, frame, transition=False): """ @@ -277,7 +285,7 @@ class MainDisplay(DisplayWidget): def onMediaQueue(self, message): log.debug(u'Queue new media message %s' % message) - self.activateWindow() + #self.activateWindow() self.hideDisplay() class VideoWidget(QtGui.QWidget): @@ -288,8 +296,7 @@ class VideoWidget(QtGui.QWidget): log.info(u'MainDisplay loaded') def __init__(self, parent=None, name=None): - QtGui.QWidget.__init__(self, None, QtCore.Qt.WindowStaysOnBottomHint \ - | QtCore.Qt.FramelessWindowHint) + QtGui.QWidget.__init__(self, None) self.parent = parent def keyPressEvent(self, event): @@ -330,7 +337,6 @@ class VideoDisplay(VideoWidget): self.audio = Phonon.AudioOutput(Phonon.VideoCategory, self.mediaObject) Phonon.createPath(self.mediaObject, self.video) Phonon.createPath(self.mediaObject, self.audio) - self.firstTime = True QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'media_start'), self.onMediaQueue) QtCore.QObject.connect(Receiver.get_receiver(), @@ -357,30 +363,27 @@ class VideoDisplay(VideoWidget): def onMediaQueue(self, message): log.debug(u'VideoDisplay Queue new media message %s' % message) file = os.path.join(message[1], message[2]) - if self.firstTime: - source = self.mediaObject.setCurrentSource(Phonon.MediaSource(file)) - self.firstTime = False - else: - self.mediaObject.enqueue(Phonon.MediaSource(file)) + source = self.mediaObject.setCurrentSource(Phonon.MediaSource(file)) self.onMediaPlay() def onMediaPlay(self): log.debug(u'VideoDisplay Play the new media, Live ') - self.firstTime = True self.setWindowState(QtCore.Qt.WindowMinimized) self.video.setFullScreen(True) self.mediaObject.play() self.setVisible(True) - self.video.lower() + self.show() def onMediaPause(self): log.debug(u'VideoDisplay Media paused by user') self.mediaObject.pause() + self.show() def onMediaStop(self): log.debug(u'VideoDisplay Media stopped by user') self.mediaObject.stop() self.onMediaFinish() + self.show() def onMediaFinish(self): log.debug(u'VideoDisplay Reached end of media playlist') @@ -388,3 +391,4 @@ class VideoDisplay(VideoWidget): self.mediaObject.clearQueue() self.video.setVisible(False) self.setVisible(False) + diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 6e96ad1b9..6035aaebc 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -500,6 +500,8 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): QtCore.SIGNAL(u'blank_check'), self.blankCheck) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'screen_changed'), self.screenChanged) + QtCore.QObject.connect(Receiver.get_receiver(), + QtCore.SIGNAL(u'status_message'), self.showStatusMessage) QtCore.QObject.connect(self.FileNewItem, QtCore.SIGNAL(u'triggered()'), self.ServiceManagerContents.onNewService) @@ -581,8 +583,6 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): self.activateWindow() if str_to_bool(self.generalConfig.get_config(u'auto open', False)): self.ServiceManagerContents.onLoadService(True) - self.displayManager.videoDisplay.lower() - self.displayManager.mainDisplay.raise_() def blankCheck(self): """ @@ -631,8 +631,8 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): their locations """ self.RenderManager.update_display() - self.mainDisplay.setup() - self.videoDisplay.setup() + self.displayManager.mainDisplay.setup() + self.displayManager.videoDisplay.setup() self.setFocus() self.activateWindow() @@ -677,7 +677,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): def serviceChanged(self, reset=False, serviceName=None): """ - Hook to change the main window title when the service changes + Hook to change the main window title when the service chmainwindow.pyanges ``reset`` Shows if the service has been cleared or saved @@ -697,6 +697,9 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): title = u'%s - %s*' % (self.mainTitle, service_name) self.setWindowTitle(title) + def showStatusMessage(self, message): + self.StatusBar.showMessage(message) + def defaultThemeChanged(self, theme): self.DefaultThemeLabel.setText( u'%s %s' % (self.defaultThemeText, theme)) diff --git a/openlp/plugins/alerts/alertsplugin.py b/openlp/plugins/alerts/alertsplugin.py index 819e8eed6..aeba0ab41 100644 --- a/openlp/plugins/alerts/alertsplugin.py +++ b/openlp/plugins/alerts/alertsplugin.py @@ -27,7 +27,7 @@ import logging from PyQt4 import QtCore, QtGui -from openlp.core.lib import Plugin, build_icon, PluginStatus +from openlp.core.lib import Plugin, build_icon, PluginStatus, Receiver from openlp.plugins.alerts.lib import AlertsManager, DBManager from openlp.plugins.alerts.forms import AlertsTab, AlertForm @@ -88,6 +88,7 @@ class alertsPlugin(Plugin): def onAlertsTrigger(self): self.alertForm.loadList() self.alertForm.exec_() + Receiver.send_message(u'text_onTop') def about(self): about_text = self.trUtf8('Alerts Plugin
This plugin ' diff --git a/openlp/plugins/alerts/forms/alertdialog.py b/openlp/plugins/alerts/forms/alertdialog.py index 442cfadd2..804975ff1 100644 --- a/openlp/plugins/alerts/forms/alertdialog.py +++ b/openlp/plugins/alerts/forms/alertdialog.py @@ -1,87 +1,134 @@ # -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 -############################################################################### -# OpenLP - Open Source Lyrics Projection # -# --------------------------------------------------------------------------- # -# Copyright (c) 2008-2010 Raoul Snyman # -# Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael # -# 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 # -############################################################################### +# Form implementation generated from reading ui file 'alertdialog.ui' +# +# Created: Sat Apr 17 08:07:40 2010 +# by: PyQt4 UI code generator 4.7 +# +# WARNING! All changes made in this file will be lost! from PyQt4 import QtCore, QtGui class Ui_AlertDialog(object): - def setupUi(self, AlertForm): - AlertForm.setObjectName(u'AlertDialog') - AlertForm.resize(430, 320) + def setupUi(self, AlertDialog): + AlertDialog.setObjectName("AlertDialog") + AlertDialog.resize(567, 440) icon = QtGui.QIcon() - icon.addPixmap(QtGui.QPixmap(u':/icon/openlp.org-icon-32.bmp'), QtGui.QIcon.Normal, QtGui.QIcon.Off) - AlertForm.setWindowIcon(icon) - self.AlertFormLayout = QtGui.QVBoxLayout(AlertForm) + icon.addPixmap(QtGui.QPixmap(":/icon/openlp.org-icon-32.bmp"), QtGui.QIcon.Normal, QtGui.QIcon.Off) + AlertDialog.setWindowIcon(icon) + self.AlertFormLayout = QtGui.QVBoxLayout(AlertDialog) self.AlertFormLayout.setSpacing(8) self.AlertFormLayout.setMargin(8) - self.AlertFormLayout.setObjectName(u'AlertFormLayout') - self.AlertEntryWidget = QtGui.QWidget(AlertForm) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Preferred) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.AlertEntryWidget.sizePolicy().hasHeightForWidth()) - self.AlertEntryWidget.setSizePolicy(sizePolicy) - self.AlertEntryWidget.setObjectName(u'AlertEntryWidget') - self.verticalLayout_2 = QtGui.QVBoxLayout(self.AlertEntryWidget) - self.verticalLayout_2.setObjectName(u'verticalLayout_2') - self.verticalLayout = QtGui.QVBoxLayout() - self.verticalLayout.setObjectName(u'verticalLayout') - self.AlertEntryLabel = QtGui.QLabel(self.AlertEntryWidget) + self.AlertFormLayout.setObjectName("AlertFormLayout") + self.AlertTextLayout = QtGui.QFormLayout() + self.AlertTextLayout.setContentsMargins(0, 0, -1, -1) + self.AlertTextLayout.setSpacing(8) + self.AlertTextLayout.setObjectName("AlertTextLayout") + self.AlertEntryLabel = QtGui.QLabel(AlertDialog) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.AlertEntryLabel.sizePolicy().hasHeightForWidth()) self.AlertEntryLabel.setSizePolicy(sizePolicy) - self.AlertEntryLabel.setObjectName(u'AlertEntryLabel') - self.verticalLayout.addWidget(self.AlertEntryLabel) - self.AlertEntryEditItem = QtGui.QLineEdit(self.AlertEntryWidget) - self.AlertEntryEditItem.setObjectName(u'AlertEntryEditItem') - self.verticalLayout.addWidget(self.AlertEntryEditItem) - self.AlertListWidget = QtGui.QListWidget(self.AlertEntryWidget) + self.AlertEntryLabel.setObjectName("AlertEntryLabel") + self.AlertTextLayout.setWidget(0, QtGui.QFormLayout.LabelRole, self.AlertEntryLabel) + self.AlertParameter = QtGui.QLabel(AlertDialog) + self.AlertParameter.setObjectName("AlertParameter") + self.AlertTextLayout.setWidget(1, QtGui.QFormLayout.LabelRole, self.AlertParameter) + self.ParameterEdit = QtGui.QLineEdit(AlertDialog) + self.ParameterEdit.setObjectName("ParameterEdit") + self.AlertTextLayout.setWidget(1, QtGui.QFormLayout.FieldRole, self.ParameterEdit) + self.AlertTextEdit = QtGui.QLineEdit(AlertDialog) + self.AlertTextEdit.setObjectName("AlertTextEdit") + self.AlertTextLayout.setWidget(0, QtGui.QFormLayout.FieldRole, self.AlertTextEdit) + self.AlertFormLayout.addLayout(self.AlertTextLayout) + self.ManagementLayout = QtGui.QHBoxLayout() + self.ManagementLayout.setSpacing(8) + self.ManagementLayout.setContentsMargins(-1, -1, -1, 0) + self.ManagementLayout.setObjectName("ManagementLayout") + self.AlertListWidget = QtGui.QListWidget(AlertDialog) self.AlertListWidget.setAlternatingRowColors(True) - self.AlertListWidget.setObjectName(u'AlertListWidget') - self.verticalLayout.addWidget(self.AlertListWidget) - self.verticalLayout_2.addLayout(self.verticalLayout) - self.horizontalLayout = QtGui.QHBoxLayout() - self.horizontalLayout.setObjectName(u'horizontalLayout') - spacerItem = QtGui.QSpacerItem(181, 38, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) - self.horizontalLayout.addItem(spacerItem) - self.DisplayButton = QtGui.QPushButton(self.AlertEntryWidget) - self.DisplayButton.setObjectName(u'DisplayButton') - self.horizontalLayout.addWidget(self.DisplayButton) - self.CancelButton = QtGui.QPushButton(self.AlertEntryWidget) - self.CancelButton.setObjectName(u'CancelButton') - self.horizontalLayout.addWidget(self.CancelButton) - self.verticalLayout_2.addLayout(self.horizontalLayout) - self.AlertFormLayout.addWidget(self.AlertEntryWidget) + self.AlertListWidget.setObjectName("AlertListWidget") + self.ManagementLayout.addWidget(self.AlertListWidget) + self.ManageButtonLayout = QtGui.QVBoxLayout() + self.ManageButtonLayout.setSpacing(8) + self.ManageButtonLayout.setObjectName("ManageButtonLayout") + self.NewButton = QtGui.QPushButton(AlertDialog) + icon1 = QtGui.QIcon() + icon1.addPixmap(QtGui.QPixmap(":/general/general_new.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) + self.NewButton.setIcon(icon1) + self.NewButton.setObjectName("NewButton") + self.ManageButtonLayout.addWidget(self.NewButton) + self.SaveButton = QtGui.QPushButton(AlertDialog) + self.SaveButton.setEnabled(False) + icon2 = QtGui.QIcon() + icon2.addPixmap(QtGui.QPixmap(":/general/general_save.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) + self.SaveButton.setIcon(icon2) + self.SaveButton.setObjectName("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) + icon4 = QtGui.QIcon() + icon4.addPixmap(QtGui.QPixmap(":/general/general_delete.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) + self.DeleteButton.setIcon(icon4) + self.DeleteButton.setObjectName("DeleteButton") + self.ManageButtonLayout.addWidget(self.DeleteButton) + spacerItem = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) + self.ManageButtonLayout.addItem(spacerItem) + self.ManagementLayout.addLayout(self.ManageButtonLayout) + self.AlertFormLayout.addLayout(self.ManagementLayout) + self.AlertButtonLayout = QtGui.QHBoxLayout() + self.AlertButtonLayout.setSpacing(8) + self.AlertButtonLayout.setObjectName("AlertButtonLayout") + spacerItem1 = QtGui.QSpacerItem(181, 0, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) + self.AlertButtonLayout.addItem(spacerItem1) + self.DisplayButton = QtGui.QPushButton(AlertDialog) + icon5 = QtGui.QIcon() + icon5.addPixmap(QtGui.QPixmap(":/general/general_live.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) + self.DisplayButton.setIcon(icon5) + self.DisplayButton.setObjectName("DisplayButton") + self.AlertButtonLayout.addWidget(self.DisplayButton) + self.DisplayCloseButton = QtGui.QPushButton(AlertDialog) + self.DisplayCloseButton.setIcon(icon5) + self.DisplayCloseButton.setObjectName("DisplayCloseButton") + self.AlertButtonLayout.addWidget(self.DisplayCloseButton) + self.CloseButton = QtGui.QPushButton(AlertDialog) + icon6 = QtGui.QIcon() + icon6.addPixmap(QtGui.QPixmap(":/system/system_close.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) + self.CloseButton.setIcon(icon6) + self.CloseButton.setObjectName("CloseButton") + self.AlertButtonLayout.addWidget(self.CloseButton) + self.AlertFormLayout.addLayout(self.AlertButtonLayout) + self.AlertEntryLabel.setBuddy(self.AlertTextEdit) + self.AlertParameter.setBuddy(self.ParameterEdit) - self.retranslateUi(AlertForm) - QtCore.QObject.connect(self.CancelButton, QtCore.SIGNAL(u'clicked()'), self.close) - QtCore.QMetaObject.connectSlotsByName(AlertForm) + self.retranslateUi(AlertDialog) + QtCore.QObject.connect(self.CloseButton, QtCore.SIGNAL("clicked()"), AlertDialog.close) + QtCore.QMetaObject.connectSlotsByName(AlertDialog) + AlertDialog.setTabOrder(self.AlertTextEdit, self.ParameterEdit) + AlertDialog.setTabOrder(self.ParameterEdit, self.AlertListWidget) + AlertDialog.setTabOrder(self.AlertListWidget, self.NewButton) + AlertDialog.setTabOrder(self.NewButton, self.SaveButton) + AlertDialog.setTabOrder(self.SaveButton, self.EditButton) + AlertDialog.setTabOrder(self.EditButton, self.DeleteButton) + AlertDialog.setTabOrder(self.DeleteButton, self.DisplayButton) + AlertDialog.setTabOrder(self.DisplayButton, self.DisplayCloseButton) + AlertDialog.setTabOrder(self.DisplayCloseButton, self.CloseButton) + + def retranslateUi(self, AlertDialog): + AlertDialog.setWindowTitle(QtGui.QApplication.translate("AlertDialog", "Alert Message", None, QtGui.QApplication.UnicodeUTF8)) + self.AlertEntryLabel.setText(QtGui.QApplication.translate("AlertDialog", "Alert &text:", None, QtGui.QApplication.UnicodeUTF8)) + self.AlertParameter.setText(QtGui.QApplication.translate("AlertDialog", "&Parameter(s):", None, QtGui.QApplication.UnicodeUTF8)) + self.NewButton.setText(QtGui.QApplication.translate("AlertDialog", "&New", None, QtGui.QApplication.UnicodeUTF8)) + self.SaveButton.setText(QtGui.QApplication.translate("AlertDialog", "&Save", None, QtGui.QApplication.UnicodeUTF8)) + self.EditButton.setText(QtGui.QApplication.translate("AlertDialog", "&Edit", None, QtGui.QApplication.UnicodeUTF8)) + self.DeleteButton.setText(QtGui.QApplication.translate("AlertDialog", "&Delete", None, QtGui.QApplication.UnicodeUTF8)) + self.DisplayButton.setText(QtGui.QApplication.translate("AlertDialog", "Displ&ay", None, QtGui.QApplication.UnicodeUTF8)) + self.DisplayCloseButton.setText(QtGui.QApplication.translate("AlertDialog", "Display && Cl&ose", None, QtGui.QApplication.UnicodeUTF8)) + self.CloseButton.setText(QtGui.QApplication.translate("AlertDialog", "&Close", None, QtGui.QApplication.UnicodeUTF8)) - def retranslateUi(self, AlertForm): - AlertForm.setWindowTitle(self.trUtf8('Alert Message')) - self.AlertEntryLabel.setText(self.trUtf8('Alert Text:')) - self.DisplayButton.setText(self.trUtf8('Display')) - self.CancelButton.setText(self.trUtf8('Cancel')) diff --git a/openlp/plugins/alerts/forms/alertform.py b/openlp/plugins/alerts/forms/alertform.py index 0d21cf4b9..08e5f5e02 100644 --- a/openlp/plugins/alerts/forms/alertform.py +++ b/openlp/plugins/alerts/forms/alertform.py @@ -45,9 +45,24 @@ class AlertForm(QtGui.QDialog, Ui_AlertDialog): QtCore.QObject.connect(self.DisplayButton, QtCore.SIGNAL(u'clicked()'), self.onDisplayClicked) - QtCore.QObject.connect(self.AlertEntryEditItem, + QtCore.QObject.connect(self.DisplayCloseButton, + QtCore.SIGNAL(u'clicked()'), + self.onDisplayCloseClicked) + QtCore.QObject.connect(self.AlertTextEdit, QtCore.SIGNAL(u'textChanged(const QString&)'), self.onTextChanged) + QtCore.QObject.connect(self.NewButton, + QtCore.SIGNAL(u'clicked()'), + self.onNewClick) + QtCore.QObject.connect(self.DeleteButton, + QtCore.SIGNAL(u'clicked()'), + self.onDeleteClick) + QtCore.QObject.connect(self.EditButton, + QtCore.SIGNAL(u'clicked()'), + self.onEditClick) + QtCore.QObject.connect(self.SaveButton, + QtCore.SIGNAL(u'clicked()'), + self.onSaveClick) QtCore.QObject.connect(self.AlertListWidget, QtCore.SIGNAL(u'doubleClicked(QModelIndex)'), self.onDoubleClick) @@ -60,19 +75,64 @@ class AlertForm(QtGui.QDialog, Ui_AlertDialog): alerts = self.manager.get_all_alerts() for alert in alerts: item_name = QtGui.QListWidgetItem(alert.text) + item_name.setData( + QtCore.Qt.UserRole, QtCore.QVariant(alert.id)) self.AlertListWidget.addItem(item_name) + self.SaveButton.setEnabled(False) + self.EditButton.setEnabled(False) + self.DeleteButton.setEnabled(False) def onDisplayClicked(self): - self.triggerAlert(unicode(self.AlertEntryEditItem.text())) - if self.parent.alertsTab.save_history and self.history_required: + if self.triggerAlert(unicode(self.AlertTextEdit.text())): + self.history_required = False + self.loadList() + + def onDisplayCloseClicked(self): + if self.triggerAlert(unicode(self.AlertTextEdit.text())): + self.close() + + def onDeleteClick(self): + item = self.AlertListWidget.currentItem() + if item: + item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0] + self.parent.manager.delete_alert(item_id) + row = self.AlertListWidget.row(item) + self.AlertListWidget.takeItem(row) + self.AlertTextEdit.setText(u'') + self.SaveButton.setEnabled(False) + self.DeleteButton.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): + if len(self.AlertTextEdit.text()) == 0: + QtGui.QMessageBox.information(self, + self.trUtf8('Item selected to Add'), + self.trUtf8('Missing data')) + else: alert = AlertItem() - alert.text = unicode(self.AlertEntryEditItem.text()) + alert.text = unicode(self.AlertTextEdit.text()) self.manager.save_alert(alert) - self.history_required = False + self.onClearClick() + self.loadList() + + def onSaveClick(self): + alert = self.manager.get_alert(self.item_id) + alert.text = unicode(self.AlertTextEdit.text()) + self.manager.save_alert(alert) + self.onClearClick() self.loadList() def onTextChanged(self): - #Data has changed by editing it so potential storage + #Data has changed by editing it so potential storage required self.history_required = True def onDoubleClick(self): @@ -93,8 +153,17 @@ class AlertForm(QtGui.QDialog, Ui_AlertDialog): items = self.AlertListWidget.selectedIndexes() for item in items: bitem = self.AlertListWidget.item(item.row()) - self.AlertEntryEditItem.setText(bitem.text()) + self.AlertTextEdit.setText(bitem.text()) self.history_required = False + self.EditButton.setEnabled(True) + self.DeleteButton.setEnabled(True) def triggerAlert(self, text): - self.parent.alertsmanager.displayAlert(text) + if 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 False diff --git a/openlp/plugins/alerts/forms/alertstab.py b/openlp/plugins/alerts/forms/alertstab.py index fe1b7cb6d..7820b658a 100644 --- a/openlp/plugins/alerts/forms/alertstab.py +++ b/openlp/plugins/alerts/forms/alertstab.py @@ -189,43 +189,6 @@ class AlertsTab(SettingsTab): self.SlideRightSpacer = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) self.SlideRightLayout.addItem(self.SlideRightSpacer) - self.layoutWidget = QtGui.QWidget(self) - self.layoutWidget.setGeometry(QtCore.QRect(20, 10, 361, 251)) - self.layoutWidget.setObjectName(u'layoutWidget') - self.verticalLayout_2 = QtGui.QVBoxLayout(self.layoutWidget) - self.verticalLayout_2.setObjectName(u'verticalLayout_2') - self.horizontalLayout_2 = QtGui.QHBoxLayout() - self.horizontalLayout_2.setObjectName(u'horizontalLayout_2') - self.AlertLineEdit = QtGui.QLineEdit(self.layoutWidget) - self.AlertLineEdit.setObjectName(u'AlertLineEdit') - self.horizontalLayout_2.addWidget(self.AlertLineEdit) - self.verticalLayout_2.addLayout(self.horizontalLayout_2) - self.horizontalLayout = QtGui.QHBoxLayout() - self.horizontalLayout.setObjectName(u'horizontalLayout') - self.AlertListWidget = QtGui.QListWidget(self.layoutWidget) - self.AlertListWidget.setAlternatingRowColors(True) - self.AlertListWidget.setObjectName(u'AlertListWidget') - self.horizontalLayout.addWidget(self.AlertListWidget) - self.verticalLayout = QtGui.QVBoxLayout() - self.verticalLayout.setObjectName(u'verticalLayout') - self.SaveButton = QtGui.QPushButton(self.layoutWidget) - self.SaveButton.setObjectName(u'SaveButton') - self.verticalLayout.addWidget(self.SaveButton) - self.ClearButton = QtGui.QPushButton(self.layoutWidget) - self.ClearButton.setObjectName(u'ClearButton') - self.verticalLayout.addWidget(self.ClearButton) - self.AddButton = QtGui.QPushButton(self.layoutWidget) - self.AddButton.setObjectName(u'AddButton') - self.verticalLayout.addWidget(self.AddButton) - self.EditButton = QtGui.QPushButton(self.layoutWidget) - self.EditButton.setObjectName(u'EditButton') - self.verticalLayout.addWidget(self.EditButton) - self.DeleteButton = QtGui.QPushButton(self.layoutWidget) - self.DeleteButton.setObjectName(u'DeleteButton') - self.verticalLayout.addWidget(self.DeleteButton) - self.horizontalLayout.addLayout(self.verticalLayout) - self.verticalLayout_2.addLayout(self.horizontalLayout) - self.SlideRightLayout.addWidget(self.layoutWidget) self.AlertsLayout.addWidget(self.AlertRightColumn) # Signals and slots QtCore.QObject.connect(self.HistoryCheckBox, @@ -243,27 +206,6 @@ class AlertsTab(SettingsTab): QtCore.SIGNAL(u'valueChanged(int)'), self.onTimeoutSpinBoxChanged) QtCore.QObject.connect(self.FontSizeSpinBox, QtCore.SIGNAL(u'valueChanged(int)'), self.onFontSizeSpinBoxChanged) - QtCore.QObject.connect(self.DeleteButton, - QtCore.SIGNAL(u'clicked()'), - self.onDeleteClick) - QtCore.QObject.connect(self.ClearButton, - QtCore.SIGNAL(u'clicked()'), - self.onClearClick) - QtCore.QObject.connect(self.EditButton, - QtCore.SIGNAL(u'clicked()'), - self.onEditClick) - QtCore.QObject.connect(self.AddButton, - QtCore.SIGNAL(u'clicked()'), - self.onAddClick) - QtCore.QObject.connect(self.SaveButton, - QtCore.SIGNAL(u'clicked()'), - self.onSaveClick) - QtCore.QObject.connect(self.AlertListWidget, - QtCore.SIGNAL(u'doubleClicked(QModelIndex)'), - self.onItemSelected) - QtCore.QObject.connect(self.AlertListWidget, - QtCore.SIGNAL(u'clicked(QModelIndex)'), - self.onItemSelected) def retranslateUi(self): self.FontGroupBox.setTitle(self.trUtf8('Font')) @@ -280,11 +222,6 @@ class AlertsTab(SettingsTab): self.FontPreview.setText(self.trUtf8('openlp.org')) self.LocationComboBox.setItemText(0, self.trUtf8('Top')) self.LocationComboBox.setItemText(1, self.trUtf8('Bottom')) - self.SaveButton.setText(self.trUtf8('Save')) - self.ClearButton.setText(self.trUtf8('Clear')) - self.AddButton.setText(self.trUtf8('Add')) - self.EditButton.setText(self.trUtf8('Edit')) - self.DeleteButton.setText(self.trUtf8('Delete')) def onBackgroundColorButtonClicked(self): self.bg_color = QtGui.QColorDialog.getColor( @@ -343,76 +280,11 @@ class AlertsTab(SettingsTab): font.setFamily(self.font_face) self.FontComboBox.setCurrentFont(font) self.updateDisplay() - self.loadList() - - def loadList(self): - self.AlertListWidget.clear() - alerts = self.manager.get_all_alerts() - for alert in alerts: - item_name = QtGui.QListWidgetItem(alert.text) - item_name.setData( - QtCore.Qt.UserRole, QtCore.QVariant(alert.id)) - self.AlertListWidget.addItem(item_name) - self.AddButton.setEnabled(True) - self.ClearButton.setEnabled(False) - self.SaveButton.setEnabled(False) - self.EditButton.setEnabled(False) - self.DeleteButton.setEnabled(False) def onItemSelected(self): self.EditButton.setEnabled(True) self.DeleteButton.setEnabled(True) - def onDeleteClick(self): - item = self.AlertListWidget.currentItem() - if item: - item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0] - self.parent.manager.delete_alert(item_id) - row = self.AlertListWidget.row(item) - self.AlertListWidget.takeItem(row) - self.AddButton.setEnabled(True) - self.SaveButton.setEnabled(False) - self.DeleteButton.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.AlertLineEdit.setText(unicode(item.text())) - self.AddButton.setEnabled(True) - self.ClearButton.setEnabled(True) - self.SaveButton.setEnabled(True) - self.DeleteButton.setEnabled(True) - self.EditButton.setEnabled(False) - - def onClearClick(self): - self.AlertLineEdit.setText(u'') - self.AddButton.setEnabled(False) - self.ClearButton.setEnabled(True) - self.SaveButton.setEnabled(False) - self.DeleteButton.setEnabled(False) - self.EditButton.setEnabled(False) - - def onAddClick(self): - if len(self.AlertLineEdit.text()) == 0: - QtGui.QMessageBox.information(self, - self.trUtf8('Item selected to Add'), - self.trUtf8('Missing data')) - else: - alert = AlertItem() - alert.text = unicode(self.AlertLineEdit.text()) - self.manager.save_alert(alert) - self.onClearClick() - self.loadList() - - def onSaveClick(self): - alert = self.manager.get_alert(self.item_id) - alert.text = unicode(self.AlertLineEdit.text()) - self.manager.save_alert(alert) - self.onClearClick() - self.loadList() - def save(self): self.font_face = self.FontComboBox.currentFont().family() self.config.set_config(u'background color', unicode(self.bg_color)) diff --git a/openlp/plugins/alerts/lib/alertsmanager.py b/openlp/plugins/alerts/lib/alertsmanager.py index 6e3aee58e..2243b5bef 100644 --- a/openlp/plugins/alerts/lib/alertsmanager.py +++ b/openlp/plugins/alerts/lib/alertsmanager.py @@ -65,9 +65,12 @@ class AlertsManager(QtCore.QObject): if self.alertTab.location == 0: self.alertScreenPosition = 0 else: - self.alertScreenPosition = self.screen[u'size'].height() - self.alertHeight - self.alertHeight = self.screen[u'size'].height() - self.alertScreenPosition - self.parent.maindisplay.setAlertSize(self.alertScreenPosition, self.alertHeight) + self.alertScreenPosition = self.screen[u'size'].height() \ + - self.alertHeight + self.alertHeight = self.screen[u'size'].height() \ + - self.alertScreenPosition + self.parent.maindisplay.setAlertSize(self.alertScreenPosition,\ + self.alertHeight) def displayAlert(self, text=u''): """ @@ -79,12 +82,12 @@ class AlertsManager(QtCore.QObject): log.debug(u'display alert called %s' % text) if not self.screen: self.screenChanged() - #self.parent.maindisplay.parent.StatusBar.showMessage(u'') self.alertList.append(text) if self.timer_id != 0: -# self.parent.maindisplay.parent.StatusBar.showMessage(\ -# self.trUtf8(u'Alert message created and delayed')) + Receiver.send_message(u'status_message', + self.trUtf8(u'Alert message created and delayed')) return + Receiver.send_message(u'status_message', u'') self.generateAlert() def generateAlert(self): @@ -116,6 +119,7 @@ class AlertsManager(QtCore.QObject): self.timer_id = self.startTimer(int(alertTab.timeout) * 1000) def timerEvent(self, event): + log.debug(u'timer event') if event.timerId() == self.timer_id: self.parent.maindisplay.addAlertImage(None, True) self.killTimer(self.timer_id) diff --git a/openlp/plugins/presentations/lib/impresscontroller.py b/openlp/plugins/presentations/lib/impresscontroller.py index c1c1804b8..92717b6d7 100644 --- a/openlp/plugins/presentations/lib/impresscontroller.py +++ b/openlp/plugins/presentations/lib/impresscontroller.py @@ -157,7 +157,6 @@ class ImpressController(PresentationController): desktop = self.get_com_desktop() #Sometimes we get a failure and desktop is None if not desktop: - desktop.terminate() log.exception(u'Failed to terminate OpenOffice') return docs = desktop.getComponents() diff --git a/resources/forms/alertdialog.ui b/resources/forms/alertdialog.ui index da56f3847..fd4cee5fc 100644 --- a/resources/forms/alertdialog.ui +++ b/resources/forms/alertdialog.ui @@ -1,13 +1,13 @@ - AlertForm - + AlertDialog + 0 0 - 430 - 320 + 567 + 440 @@ -25,85 +25,212 @@ 8 - - - - 0 - 0 - + + + 8 - - - - - - - - 0 - 0 - - - - Alert Text: - - - - - - - - - - true - - - - - - - - - - - Qt::Horizontal - - - - 181 - 38 - - - - - - - - Display - - - - - - - Cancel - - - - - - - + + 8 + + + 0 + + + 0 + + + + + + 0 + 0 + + + + Alert &text: + + + AlertTextEdit + + + + + + + &Parameter(s): + + + ParameterEdit + + + + + + + + + + + + + + + 8 + + + 0 + + + + + true + + + + + + + 8 + + + + + &New + + + + :/general/general_new.png:/general/general_new.png + + + + + + + false + + + &Save + + + + :/general/general_save.png:/general/general_save.png + + + + + + + &Edit + + + + :/general/general_edit.png:/general/general_edit.png + + + + + + + &Delete + + + + :/general/general_delete.png:/general/general_delete.png + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + 8 + + + + + Qt::Horizontal + + + + 181 + 0 + + + + + + + + Displ&ay + + + + :/general/general_live.png:/general/general_live.png + + + + + + + Display && Cl&ose + + + + :/general/general_live.png:/general/general_live.png + + + + + + + &Close + + + + :/system/system_close.png:/system/system_close.png + + + + + + AlertTextEdit + ParameterEdit + AlertListWidget + NewButton + SaveButton + EditButton + DeleteButton + DisplayButton + DisplayCloseButton + CloseButton + - + - CancelButton + CloseButton clicked() - AlertForm + AlertDialog close() diff --git a/resources/forms/alerteditdialog.ui b/resources/forms/alerteditdialog.ui deleted file mode 100644 index 352e3d7b1..000000000 --- a/resources/forms/alerteditdialog.ui +++ /dev/null @@ -1,101 +0,0 @@ - - - AlertEditDialog - - - - 0 - 0 - 400 - 300 - - - - Maintain Alerts - - - - - 220 - 270 - 173 - 27 - - - - QDialogButtonBox::Cancel - - - - - - 20 - 10 - 361 - 251 - - - - - - - - - - - - - - - - true - - - - - - - - - Save - - - - - - - Clear - - - - - - - Add - - - - - - - Edit - - - - - - - Delete - - - - - - - - - - - - -