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

100 lines
5.5 KiB
Python
Raw Normal View History

2010-02-14 13:27:32 +00:00
# -*- coding: utf-8 -*-
2019-04-13 13:00:22 +00:00
##########################################################################
# OpenLP - Open Source Lyrics Projection #
# ---------------------------------------------------------------------- #
2022-02-06 09:10:17 +00:00
# Copyright (c) 2008-2022 OpenLP Developers #
2019-04-13 13:00:22 +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, either version 3 of the License, or #
# (at your option) any later version. #
# #
# 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, see <https://www.gnu.org/licenses/>. #
##########################################################################
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.lib.ui import create_button, create_button_box
2018-10-02 04:39:42 +00:00
from openlp.core.ui.icons import UiIcons
2010-02-14 13:27:32 +00:00
2013-02-14 21:31:17 +00:00
2020-06-06 16:05:36 +00:00
class AlertDialog(object):
2014-01-11 21:46:20 +00:00
"""
Alert UI Class
"""
def setup_ui(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)
2018-04-21 19:57:51 +00:00
alert_dialog.setWindowIcon(UiIcons().main_icon)
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)
2021-08-25 21:14:19 +00:00
self.button_box = create_button_box(alert_dialog, 'button_box', ['close', 'help'],
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.retranslate_ui(alert_dialog)
2010-02-14 13:27:32 +00:00
def retranslate_ui(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'))