openlp/openlp/plugins/alerts/forms/alertdialog.py

102 lines
5.7 KiB
Python
Raw Normal View History

2010-02-14 13:27:32 +00:00
# -*- coding: utf-8 -*-
2013-01-01 16:33:41 +00:00
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
2010-02-14 13:27:32 +00:00
2010-04-21 17:21:56 +00:00
###############################################################################
# OpenLP - Open Source Lyrics Projection #
# --------------------------------------------------------------------------- #
2017-12-29 09:15:48 +00:00
# Copyright (c) 2008-2018 OpenLP Developers #
2010-04-21 17:21:56 +00:00
# --------------------------------------------------------------------------- #
# 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 #
###############################################################################
2010-02-14 13:27:32 +00:00
2015-11-07 00:49:40 +00:00
from PyQt5 import QtWidgets
2010-06-01 17:13:54 +00:00
2018-04-10 19:26:56 +00:00
from openlp.core.common.i18n import translate
from openlp.core.ui.icons import UiIcons
2013-10-13 21:07:28 +00:00
from openlp.core.lib import build_icon
from openlp.core.lib.ui import create_button, create_button_box
2010-02-14 13:27:32 +00:00
2013-02-14 21:31:17 +00:00
2010-02-14 13:27:32 +00:00
class Ui_AlertDialog(object):
2014-01-11 21:46:20 +00:00
"""
Alert UI Class
"""
2013-02-14 21:31:17 +00:00
def setupUi(self, alert_dialog):
2014-01-01 09:33:07 +00:00
"""
Setup the Alert UI dialog
2014-01-01 09:57:06 +00:00
:param alert_dialog: The dialog
2014-01-01 09:33:07 +00:00
"""
2013-08-31 18:17:38 +00:00
alert_dialog.setObjectName('alert_dialog')
2013-02-14 21:31:17 +00:00
alert_dialog.resize(400, 300)
2016-10-27 17:45:50 +00:00
alert_dialog.setWindowIcon(build_icon(':/icon/openlp-logo.svg'))
2015-11-07 00:49:40 +00:00
self.alert_dialog_layout = QtWidgets.QGridLayout(alert_dialog)
2013-08-31 18:17:38 +00:00
self.alert_dialog_layout.setObjectName('alert_dialog_layout')
2015-11-07 00:49:40 +00:00
self.alert_text_layout = QtWidgets.QFormLayout()
2013-08-31 18:17:38 +00:00
self.alert_text_layout.setObjectName('alert_text_layout')
2015-11-07 00:49:40 +00:00
self.alert_entry_label = QtWidgets.QLabel(alert_dialog)
2013-08-31 18:17:38 +00:00
self.alert_entry_label.setObjectName('alert_entry_label')
2015-11-07 00:49:40 +00:00
self.alert_text_edit = QtWidgets.QLineEdit(alert_dialog)
2013-08-31 18:17:38 +00:00
self.alert_text_edit.setObjectName('alert_text_edit')
2013-02-14 21:31:17 +00:00
self.alert_entry_label.setBuddy(self.alert_text_edit)
self.alert_text_layout.addRow(self.alert_entry_label, self.alert_text_edit)
2015-11-07 00:49:40 +00:00
self.alert_parameter = QtWidgets.QLabel(alert_dialog)
2013-08-31 18:17:38 +00:00
self.alert_parameter.setObjectName('alert_parameter')
2015-11-07 00:49:40 +00:00
self.parameter_edit = QtWidgets.QLineEdit(alert_dialog)
2013-08-31 18:17:38 +00:00
self.parameter_edit.setObjectName('parameter_edit')
2013-02-14 21:31:17 +00:00
self.alert_parameter.setBuddy(self.parameter_edit)
self.alert_text_layout.addRow(self.alert_parameter, self.parameter_edit)
self.alert_dialog_layout.addLayout(self.alert_text_layout, 0, 0, 1, 2)
2015-11-07 00:49:40 +00:00
self.alert_list_widget = QtWidgets.QListWidget(alert_dialog)
2013-02-14 21:31:17 +00:00
self.alert_list_widget.setAlternatingRowColors(True)
2013-08-31 18:17:38 +00:00
self.alert_list_widget.setObjectName('alert_list_widget')
2013-02-14 21:31:17 +00:00
self.alert_dialog_layout.addWidget(self.alert_list_widget, 1, 0)
2015-11-07 00:49:40 +00:00
self.manage_button_layout = QtWidgets.QVBoxLayout()
2013-08-31 18:17:38 +00:00
self.manage_button_layout.setObjectName('manage_button_layout')
2015-11-07 00:49:40 +00:00
self.new_button = QtWidgets.QPushButton(alert_dialog)
2018-04-21 05:47:20 +00:00
self.new_button.setIcon(UiIcons().new)
2013-08-31 18:17:38 +00:00
self.new_button.setObjectName('new_button')
2013-02-14 21:31:17 +00:00
self.manage_button_layout.addWidget(self.new_button)
2015-11-07 00:49:40 +00:00
self.save_button = QtWidgets.QPushButton(alert_dialog)
2013-02-14 21:31:17 +00:00
self.save_button.setEnabled(False)
2018-04-21 05:47:20 +00:00
self.save_button.setIcon(UiIcons().save)
2013-08-31 18:17:38 +00:00
self.save_button.setObjectName('save_button')
2013-02-14 21:31:17 +00:00
self.manage_button_layout.addWidget(self.save_button)
2013-08-31 18:17:38 +00:00
self.delete_button = create_button(alert_dialog, 'delete_button', role='delete', enabled=False,
2014-01-01 09:33:07 +00:00
click=alert_dialog.on_delete_button_clicked)
2013-02-14 21:31:17 +00:00
self.manage_button_layout.addWidget(self.delete_button)
self.manage_button_layout.addStretch()
self.alert_dialog_layout.addLayout(self.manage_button_layout, 1, 1)
2018-04-13 18:54:42 +00:00
self.display_button = create_button(alert_dialog, 'display_button', icon=UiIcons().live, enabled=False)
self.display_close_button = create_button(alert_dialog, 'display_close_button', icon=UiIcons().live,
2014-01-01 09:33:07 +00:00
enabled=False)
2013-08-31 18:17:38 +00:00
self.button_box = create_button_box(alert_dialog, 'button_box', ['close'],
2014-01-01 09:33:07 +00:00
[self.display_button, self.display_close_button])
2013-02-14 21:31:17 +00:00
self.alert_dialog_layout.addWidget(self.button_box, 2, 0, 1, 2)
self.retranslateUi(alert_dialog)
2010-02-14 13:27:32 +00:00
2013-02-14 21:31:17 +00:00
def retranslateUi(self, alert_dialog):
2014-01-01 09:33:07 +00:00
"""
Retranslate the UI strings
2014-01-01 09:57:06 +00:00
:param alert_dialog: The dialog
2014-01-01 09:33:07 +00:00
"""
2013-02-14 21:31:17 +00:00
alert_dialog.setWindowTitle(translate('AlertsPlugin.AlertForm', 'Alert Message'))
self.alert_entry_label.setText(translate('AlertsPlugin.AlertForm', 'Alert &text:'))
self.alert_parameter.setText(translate('AlertsPlugin.AlertForm', '&Parameter:'))
self.new_button.setText(translate('AlertsPlugin.AlertForm', '&New'))
self.save_button.setText(translate('AlertsPlugin.AlertForm', '&Save'))
self.display_button.setText(translate('AlertsPlugin.AlertForm', 'Displ&ay'))
self.display_close_button.setText(translate('AlertsPlugin.AlertForm', 'Display && Cl&ose'))