File indexing completed on 2024-05-12 04:55:02
0001 /** 0002 * \file messagedialog.h 0003 * Message dialog. 0004 * 0005 * \b Project: Kid3 0006 * \author Urs Fleisch 0007 * \date 18 Aug 2011 0008 * 0009 * Copyright (C) 2011-2024 Urs Fleisch 0010 * 0011 * This file is part of Kid3. 0012 * 0013 * Kid3 is free software; you can redistribute it and/or modify 0014 * it under the terms of the GNU General Public License as published by 0015 * the Free Software Foundation; either version 2 of the License, or 0016 * (at your option) any later version. 0017 * 0018 * Kid3 is distributed in the hope that it will be useful, 0019 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0020 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0021 * GNU General Public License for more details. 0022 * 0023 * You should have received a copy of the GNU General Public License 0024 * along with this program. If not, see <http://www.gnu.org/licenses/>. 0025 */ 0026 0027 #pragma once 0028 0029 #include <QDialog> 0030 #include <QMessageBox> 0031 0032 class QLabel; 0033 class QTextEdit; 0034 class QDialogButtonBox; 0035 0036 /** 0037 * Message dialog. 0038 * Drop-in replacement for QMessageBox, but suitable for large texts. 0039 */ 0040 class MessageDialog : public QDialog { 0041 Q_OBJECT 0042 public: 0043 /** 0044 * Constructor. 0045 * 0046 * @param parent parent widget 0047 */ 0048 explicit MessageDialog(QWidget* parent = nullptr); 0049 0050 /** 0051 * Destructor. 0052 */ 0053 ~MessageDialog() override = default; 0054 0055 /** 0056 * Set the text to be displayed. 0057 * 0058 * @param text message text. 0059 */ 0060 void setText(const QString& text); 0061 0062 /** 0063 * Set the informative text. 0064 * This text can be large and is displayed in a text edit. 0065 * 0066 * @param text message text. 0067 */ 0068 void setInformativeText(const QString& text); 0069 0070 /** 0071 * Set the message box's icon. 0072 * 0073 * @param icon icon to be displayed 0074 */ 0075 void setIcon(QMessageBox::Icon icon); 0076 0077 /** 0078 * Set buttons to be displayed. 0079 * 0080 * @param buttons buttons to be displayed 0081 */ 0082 void setStandardButtons(QMessageBox::StandardButtons buttons); 0083 0084 /** 0085 * Set default button. 0086 * 0087 * @param button button which gets default focus 0088 */ 0089 void setDefaultButton(QMessageBox::StandardButton button); 0090 0091 /** 0092 * Display a modal dialog with a list of items. 0093 * 0094 * @param parent parent widget 0095 * @param title dialog title 0096 * @param text dialog text 0097 * @param list list of items 0098 * @param buttons buttons shown 0099 * 0100 * @return QMessageBox::Ok or QMessageBox::Cancel. 0101 */ 0102 static int warningList(QWidget* parent, const QString& title, 0103 const QString& text, const QStringList& list, 0104 QMessageBox::StandardButtons buttons = 0105 QMessageBox::Ok | QMessageBox::Cancel); 0106 0107 private slots: 0108 /** 0109 * Called when a button is clicked. 0110 * 0111 * @param button button which was clicked 0112 */ 0113 void buttonClicked(QAbstractButton* button); 0114 0115 private: 0116 QLabel* m_iconLabel; 0117 QLabel* m_textLabel; 0118 QTextEdit* m_textEdit; 0119 QDialogButtonBox* m_buttonBox; 0120 };