forked from openlp/openlp
Alter form removal complete
This commit is contained in:
parent
60a3468edb
commit
13608bedae
@ -89,10 +89,6 @@ class alertsPlugin(Plugin):
|
||||
self.alertForm.loadList()
|
||||
self.alertForm.exec_()
|
||||
|
||||
def onAlertsEdit(self):
|
||||
self.alertEditForm.loadList()
|
||||
self.alertEditForm.exec_()
|
||||
|
||||
def about(self):
|
||||
about_text = self.trUtf8('<b>Alerts Plugin</b><br>This plugin '
|
||||
'controls the displaying of alerts on the presentations screen')
|
||||
|
@ -26,6 +26,7 @@
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.lib import SettingsTab, str_to_bool
|
||||
from openlp.plugins.alerts.lib.models import AlertItem
|
||||
|
||||
class AlertsTab(SettingsTab):
|
||||
"""
|
||||
@ -33,6 +34,7 @@ class AlertsTab(SettingsTab):
|
||||
"""
|
||||
def __init__(self, parent, section=None):
|
||||
self.parent = parent
|
||||
self.manager = parent.manager
|
||||
SettingsTab.__init__(self, parent.name, section)
|
||||
|
||||
def setupUi(self):
|
||||
@ -149,22 +151,6 @@ class AlertsTab(SettingsTab):
|
||||
QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
|
||||
self.HistoryLayout.addItem(self.HistorySpacer)
|
||||
self.FontLayout.addWidget(self.HistoryWidget)
|
||||
self.HistoryEditWidget = QtGui.QWidget(self.FontGroupBox)
|
||||
self.HistoryEditWidget.setObjectName(u'HistoryEditWidget')
|
||||
self.HistoryEditLayout = QtGui.QHBoxLayout(self.HistoryEditWidget)
|
||||
self.HistoryEditLayout.setSpacing(8)
|
||||
self.HistoryEditLayout.setMargin(0)
|
||||
self.HistoryEditLayout.setObjectName(u'HistoryEditLayout')
|
||||
self.HistoryEditLabel = QtGui.QLabel(self.HistoryEditWidget)
|
||||
self.HistoryEditLabel.setObjectName(u'HistoryEditLabel')
|
||||
self.HistoryEditLayout.addWidget(self.HistoryEditLabel)
|
||||
self.HistoryEditPushButton = QtGui.QPushButton(self.HistoryEditWidget)
|
||||
self.HistoryEditPushButton.setObjectName(u'HistoryEditPushButton')
|
||||
self.HistoryEditLayout.addWidget(self.HistoryEditPushButton)
|
||||
self.HistoryEditSpacer = QtGui.QSpacerItem(147, 20,
|
||||
QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
|
||||
self.HistoryEditLayout.addItem(self.HistoryEditSpacer)
|
||||
self.FontLayout.addWidget(self.HistoryEditWidget)
|
||||
self.SlideLeftLayout.addWidget(self.FontGroupBox)
|
||||
self.SlideLeftSpacer = QtGui.QSpacerItem(20, 94,
|
||||
QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
|
||||
@ -201,6 +187,43 @@ 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,
|
||||
@ -210,8 +233,6 @@ class AlertsTab(SettingsTab):
|
||||
QtCore.SIGNAL(u'pressed()'), self.onBackgroundColorButtonClicked)
|
||||
QtCore.QObject.connect(self.FontColorButton,
|
||||
QtCore.SIGNAL(u'pressed()'), self.onFontColorButtonClicked)
|
||||
QtCore.QObject.connect(self.HistoryEditPushButton,
|
||||
QtCore.SIGNAL(u'pressed()'), self.onHistoryEditButtonClicked)
|
||||
QtCore.QObject.connect(self.FontComboBox,
|
||||
QtCore.SIGNAL(u'activated(int)'), self.onFontComboBoxClicked)
|
||||
QtCore.QObject.connect(self.LocationComboBox,
|
||||
@ -220,6 +241,27 @@ 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'))
|
||||
@ -232,11 +274,15 @@ class AlertsTab(SettingsTab):
|
||||
self.TimeoutSpinBox.setSuffix(self.trUtf8('s'))
|
||||
self.LocationLabel.setText(self.trUtf8('Location:'))
|
||||
self.HistoryLabel.setText(self.trUtf8('Keep History:'))
|
||||
self.HistoryEditLabel.setText(self.trUtf8('Edit History:'))
|
||||
self.PreviewGroupBox.setTitle(self.trUtf8('Preview'))
|
||||
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(
|
||||
@ -271,9 +317,6 @@ class AlertsTab(SettingsTab):
|
||||
self.font_size = self.FontSizeSpinBox.value()
|
||||
self.updateDisplay()
|
||||
|
||||
def onHistoryEditButtonClicked(self):
|
||||
self.parent.onAlertsEdit()
|
||||
|
||||
def load(self):
|
||||
self.timeout = int(self.config.get_config(u'timeout', 5))
|
||||
self.font_color = unicode(
|
||||
@ -298,6 +341,75 @@ 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()
|
||||
|
Loading…
Reference in New Issue
Block a user