[55401] | 1 | /* $Id: QIMessageBox.h 106061 2024-09-16 14:03:52Z vboxsync $ */
|
---|
[25177] | 2 | /** @file
|
---|
[71900] | 3 | * VBox Qt GUI - Qt extensions: QIMessageBox class declaration.
|
---|
[25177] | 4 | */
|
---|
| 5 |
|
---|
| 6 | /*
|
---|
[106061] | 7 | * Copyright (C) 2006-2024 Oracle and/or its affiliates.
|
---|
[25177] | 8 | *
|
---|
[96407] | 9 | * This file is part of VirtualBox base platform packages, as
|
---|
| 10 | * available from https://www.virtualbox.org.
|
---|
| 11 | *
|
---|
| 12 | * This program is free software; you can redistribute it and/or
|
---|
| 13 | * modify it under the terms of the GNU General Public License
|
---|
| 14 | * as published by the Free Software Foundation, in version 3 of the
|
---|
| 15 | * License.
|
---|
| 16 | *
|
---|
| 17 | * This program is distributed in the hope that it will be useful, but
|
---|
| 18 | * WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
| 20 | * General Public License for more details.
|
---|
| 21 | *
|
---|
| 22 | * You should have received a copy of the GNU General Public License
|
---|
| 23 | * along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
| 24 | *
|
---|
| 25 | * SPDX-License-Identifier: GPL-3.0-only
|
---|
[25177] | 26 | */
|
---|
| 27 |
|
---|
[76581] | 28 | #ifndef FEQT_INCLUDED_SRC_extensions_QIMessageBox_h
|
---|
| 29 | #define FEQT_INCLUDED_SRC_extensions_QIMessageBox_h
|
---|
[76532] | 30 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
| 31 | # pragma once
|
---|
| 32 | #endif
|
---|
[25177] | 33 |
|
---|
[45295] | 34 | /* Qt includes: */
|
---|
[25177] | 35 | #include <QMessageBox>
|
---|
| 36 |
|
---|
[45295] | 37 | /* GUI includes: */
|
---|
| 38 | #include "QIDialog.h"
|
---|
[71630] | 39 | #include "UILibraryDefs.h"
|
---|
[25177] | 40 |
|
---|
[45295] | 41 | /* Forward declarations: */
|
---|
[45308] | 42 | class QCheckBox;
|
---|
[71401] | 43 | class QLabel;
|
---|
| 44 | class QPushButton;
|
---|
[45295] | 45 | class QIArrowSplitter;
|
---|
| 46 | class QIDialogButtonBox;
|
---|
[83524] | 47 | class QIRichTextLabel;
|
---|
[25177] | 48 |
|
---|
[71401] | 49 |
|
---|
[51873] | 50 | /** Button types. */
|
---|
[45296] | 51 | enum AlertButton
|
---|
| 52 | {
|
---|
| 53 | AlertButton_NoButton = 0x0, /* 00000000 00000000 */
|
---|
| 54 | AlertButton_Ok = 0x1, /* 00000000 00000001 */
|
---|
| 55 | AlertButton_Cancel = 0x2, /* 00000000 00000010 */
|
---|
[45362] | 56 | AlertButton_Choice1 = 0x4, /* 00000000 00000100 */
|
---|
| 57 | AlertButton_Choice2 = 0x8, /* 00000000 00001000 */
|
---|
| 58 | AlertButton_Copy = 0x10, /* 00000000 00010000 */
|
---|
[89946] | 59 | AlertButton_Help = 0x11, /* 00000000 00010001 */
|
---|
[45296] | 60 | AlertButtonMask = 0xFF /* 00000000 11111111 */
|
---|
| 61 | };
|
---|
| 62 |
|
---|
[71401] | 63 |
|
---|
[51873] | 64 | /** Button options. */
|
---|
[45296] | 65 | enum AlertButtonOption
|
---|
| 66 | {
|
---|
| 67 | AlertButtonOption_Default = 0x100, /* 00000001 00000000 */
|
---|
| 68 | AlertButtonOption_Escape = 0x200, /* 00000010 00000000 */
|
---|
| 69 | AlertButtonOptionMask = 0x300 /* 00000011 00000000 */
|
---|
| 70 | };
|
---|
| 71 |
|
---|
[71401] | 72 |
|
---|
[51873] | 73 | /** Alert options. */
|
---|
[45296] | 74 | enum AlertOption
|
---|
| 75 | {
|
---|
[45690] | 76 | AlertOption_AutoConfirmed = 0x400, /* 00000100 00000000 */
|
---|
| 77 | AlertOption_CheckBox = 0x800, /* 00001000 00000000 */
|
---|
[45296] | 78 | AlertOptionMask = 0xFC00 /* 11111100 00000000 */
|
---|
| 79 | };
|
---|
| 80 |
|
---|
[71401] | 81 |
|
---|
[51873] | 82 | /** Icon types. */
|
---|
[45296] | 83 | enum AlertIconType
|
---|
| 84 | {
|
---|
[51873] | 85 | AlertIconType_NoIcon = QMessageBox::NoIcon,
|
---|
| 86 | AlertIconType_Information = QMessageBox::Information,
|
---|
| 87 | AlertIconType_Warning = QMessageBox::Warning,
|
---|
| 88 | AlertIconType_Critical = QMessageBox::Critical,
|
---|
| 89 | AlertIconType_Question = QMessageBox::Question,
|
---|
[45296] | 90 | AlertIconType_GuruMeditation
|
---|
| 91 | };
|
---|
| 92 |
|
---|
[71401] | 93 |
|
---|
| 94 | /** QIDialog extension representing GUI alerts. */
|
---|
[71630] | 95 | class SHARED_LIBRARY_STUFF QIMessageBox : public QIDialog
|
---|
[25177] | 96 | {
|
---|
| 97 | Q_OBJECT;
|
---|
| 98 |
|
---|
| 99 | public:
|
---|
| 100 |
|
---|
[71401] | 101 | /** Constructs message-box passing @a pParent to the base-class.
|
---|
| 102 | * @param strTitle Brings the title.
|
---|
| 103 | * @param strMessage Brings the message.
|
---|
[89933] | 104 | * @param strMessage Brings the help keyword for context sensitive help
|
---|
[71401] | 105 | * @param iconType Brings the icon-type.
|
---|
| 106 | * @param iButton1 Brings the integer-code for the 1st button.
|
---|
| 107 | * @param iButton2 Brings the integer-code for the 2nd button.
|
---|
| 108 | * @param iButton3 Brings the integer-code for the 3rd button. */
|
---|
[89950] | 109 | QIMessageBox(const QString &strTitle, const QString &strMessage, AlertIconType iconType,
|
---|
| 110 | int iButton1 = 0, int iButton2 = 0, int iButton3 = 0, QWidget *pParent = 0,
|
---|
| 111 | const QString &strHelpKeyword = QString());
|
---|
[25177] | 112 |
|
---|
[51873] | 113 | /** Defines details-text. */
|
---|
[45308] | 114 | void setDetailsText(const QString &strText);
|
---|
[25177] | 115 |
|
---|
[51873] | 116 | /** Returns whether flag is checked. */
|
---|
[45308] | 117 | bool flagChecked() const;
|
---|
[51873] | 118 | /** Defines whether flag is @a fChecked. */
|
---|
[45308] | 119 | void setFlagChecked(bool fChecked);
|
---|
[51873] | 120 | /** Defines @a strFlagText. */
|
---|
| 121 | void setFlagText(const QString &strFlagText);
|
---|
[25177] | 122 |
|
---|
[51873] | 123 | /** Defines @a iButton @a strText. */
|
---|
[45308] | 124 | void setButtonText(int iButton, const QString &strText);
|
---|
[25177] | 125 |
|
---|
[71401] | 126 | protected:
|
---|
| 127 |
|
---|
| 128 | /** Handles polish @a pEvent. */
|
---|
[93990] | 129 | virtual void polishEvent(QShowEvent *pEvent) RT_OVERRIDE;
|
---|
[71401] | 130 |
|
---|
| 131 | /** Handles close @a pEvent. */
|
---|
[93990] | 132 | virtual void closeEvent(QCloseEvent *pEvent) RT_OVERRIDE;
|
---|
[71401] | 133 |
|
---|
[45308] | 134 | private slots:
|
---|
[25177] | 135 |
|
---|
[51873] | 136 | /** Updates dialog size: */
|
---|
| 137 | void sltUpdateSize();
|
---|
[25177] | 138 |
|
---|
[51873] | 139 | /** Copy details-text. */
|
---|
| 140 | void sltCopy() const;
|
---|
[25177] | 141 |
|
---|
[51873] | 142 | /** Closes dialog like user would press the Cancel button. */
|
---|
[93990] | 143 | virtual void reject() RT_OVERRIDE;
|
---|
[45303] | 144 |
|
---|
[51873] | 145 | /** Closes dialog like user would press the 1st button. */
|
---|
| 146 | void sltDone1() { m_fDone = true; done(m_iButton1 & AlertButtonMask); }
|
---|
| 147 | /** Closes dialog like user would press the 2nd button. */
|
---|
| 148 | void sltDone2() { m_fDone = true; done(m_iButton2 & AlertButtonMask); }
|
---|
| 149 | /** Closes dialog like user would press the 3rd button. */
|
---|
| 150 | void sltDone3() { m_fDone = true; done(m_iButton3 & AlertButtonMask); }
|
---|
[25177] | 151 |
|
---|
[45308] | 152 | private:
|
---|
[25177] | 153 |
|
---|
[71401] | 154 | /** Prepares all. */
|
---|
[51873] | 155 | void prepare();
|
---|
| 156 |
|
---|
[57627] | 157 | /** Prepares focus. */
|
---|
| 158 | void prepareFocus();
|
---|
| 159 |
|
---|
[51873] | 160 | /** Push-button factory. */
|
---|
[71401] | 161 | QPushButton *createButton(int iButton);
|
---|
[25177] | 162 |
|
---|
[51873] | 163 | /** Visibility update routine for details-container. */
|
---|
[45308] | 164 | void updateDetailsContainer();
|
---|
[51873] | 165 | /** Visibility update routine for check-box. */
|
---|
[45308] | 166 | void updateCheckBox();
|
---|
[38185] | 167 |
|
---|
[51873] | 168 | /** Generates standard pixmap for passed @a iconType using @a pWidget as hint. */
|
---|
[45308] | 169 | static QPixmap standardPixmap(AlertIconType iconType, QWidget *pWidget = 0);
|
---|
[25177] | 170 |
|
---|
[83535] | 171 | /** Compresses @a strText with ellipsis on the basis of certain logic. */
|
---|
| 172 | static QString compressLongWords(QString strText);
|
---|
| 173 |
|
---|
[51873] | 174 | /** Holds the title. */
|
---|
| 175 | QString m_strTitle;
|
---|
| 176 |
|
---|
| 177 | /** Holds the icon-type. */
|
---|
[45303] | 178 | AlertIconType m_iconType;
|
---|
[51873] | 179 | /** Holds the icon-label instance. */
|
---|
| 180 | QLabel *m_pLabelIcon;
|
---|
| 181 |
|
---|
| 182 | /** Holds the message. */
|
---|
| 183 | QString m_strMessage;
|
---|
| 184 | /** Holds the message-label instance. */
|
---|
[83524] | 185 | QIRichTextLabel *m_pLabelText;
|
---|
[51873] | 186 |
|
---|
| 187 | /** Holds the flag check-box instance. */
|
---|
[45308] | 188 | QCheckBox *m_pFlagCheckBox;
|
---|
[51873] | 189 |
|
---|
| 190 | /** Holds the flag details-container instance. */
|
---|
[45308] | 191 | QIArrowSplitter *m_pDetailsContainer;
|
---|
[51873] | 192 |
|
---|
| 193 | /** Holds the integer-code for the 1st button. */
|
---|
| 194 | int m_iButton1;
|
---|
| 195 | /** Holds the integer-code for the 2nd button. */
|
---|
| 196 | int m_iButton2;
|
---|
| 197 | /** Holds the integer-code for the 3rd button. */
|
---|
| 198 | int m_iButton3;
|
---|
| 199 | /** Holds the integer-code of the cancel-button. */
|
---|
| 200 | int m_iButtonEsc;
|
---|
| 201 | /** Holds the 1st button instance. */
|
---|
| 202 | QPushButton *m_pButton1;
|
---|
| 203 | /** Holds the 2nd button instance. */
|
---|
| 204 | QPushButton *m_pButton2;
|
---|
| 205 | /** Holds the 3rd button instance. */
|
---|
| 206 | QPushButton *m_pButton3;
|
---|
[89946] | 207 | /** Holds the help-button instance. */
|
---|
| 208 | QPushButton *m_pButtonHelp;
|
---|
| 209 |
|
---|
[51873] | 210 | /** Holds the button-box instance. */
|
---|
[45303] | 211 | QIDialogButtonBox *m_pButtonBox;
|
---|
[51873] | 212 |
|
---|
[89946] | 213 | /** Holds the help keyword string. */
|
---|
| 214 | QString m_strHelpKeyword;
|
---|
| 215 |
|
---|
[51873] | 216 | /** Defines whether message was accepted. */
|
---|
[45297] | 217 | bool m_fDone : 1;
|
---|
[25177] | 218 | };
|
---|
| 219 |
|
---|
[71401] | 220 |
|
---|
[76581] | 221 | #endif /* !FEQT_INCLUDED_SRC_extensions_QIMessageBox_h */
|
---|