VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/extensions/QIMessageBox.h@ 82781

Last change on this file since 82781 was 76581, checked in by vboxsync, 5 years ago

Fe/QT: scm header guard alignment.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 6.0 KB
Line 
1/* $Id: QIMessageBox.h 76581 2019-01-01 06:24:57Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - Qt extensions: QIMessageBox class declaration.
4 */
5
6/*
7 * Copyright (C) 2006-2019 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18#ifndef FEQT_INCLUDED_SRC_extensions_QIMessageBox_h
19#define FEQT_INCLUDED_SRC_extensions_QIMessageBox_h
20#ifndef RT_WITHOUT_PRAGMA_ONCE
21# pragma once
22#endif
23
24/* Qt includes: */
25#include <QMessageBox>
26
27/* GUI includes: */
28#include "QIDialog.h"
29#include "UILibraryDefs.h"
30
31/* Forward declarations: */
32class QCheckBox;
33class QLabel;
34class QPushButton;
35class QIArrowSplitter;
36class QIDialogButtonBox;
37class QILabel;
38
39
40/** Button types. */
41enum AlertButton
42{
43 AlertButton_NoButton = 0x0, /* 00000000 00000000 */
44 AlertButton_Ok = 0x1, /* 00000000 00000001 */
45 AlertButton_Cancel = 0x2, /* 00000000 00000010 */
46 AlertButton_Choice1 = 0x4, /* 00000000 00000100 */
47 AlertButton_Choice2 = 0x8, /* 00000000 00001000 */
48 AlertButton_Copy = 0x10, /* 00000000 00010000 */
49 AlertButtonMask = 0xFF /* 00000000 11111111 */
50};
51
52
53/** Button options. */
54enum AlertButtonOption
55{
56 AlertButtonOption_Default = 0x100, /* 00000001 00000000 */
57 AlertButtonOption_Escape = 0x200, /* 00000010 00000000 */
58 AlertButtonOptionMask = 0x300 /* 00000011 00000000 */
59};
60
61
62/** Alert options. */
63enum AlertOption
64{
65 AlertOption_AutoConfirmed = 0x400, /* 00000100 00000000 */
66 AlertOption_CheckBox = 0x800, /* 00001000 00000000 */
67 AlertOptionMask = 0xFC00 /* 11111100 00000000 */
68};
69
70
71/** Icon types. */
72enum AlertIconType
73{
74 AlertIconType_NoIcon = QMessageBox::NoIcon,
75 AlertIconType_Information = QMessageBox::Information,
76 AlertIconType_Warning = QMessageBox::Warning,
77 AlertIconType_Critical = QMessageBox::Critical,
78 AlertIconType_Question = QMessageBox::Question,
79 AlertIconType_GuruMeditation
80};
81
82
83/** QIDialog extension representing GUI alerts. */
84class SHARED_LIBRARY_STUFF QIMessageBox : public QIDialog
85{
86 Q_OBJECT;
87
88public:
89
90 /** Constructs message-box passing @a pParent to the base-class.
91 * @param strTitle Brings the title.
92 * @param strMessage Brings the message.
93 * @param iconType Brings the icon-type.
94 * @param iButton1 Brings the integer-code for the 1st button.
95 * @param iButton2 Brings the integer-code for the 2nd button.
96 * @param iButton3 Brings the integer-code for the 3rd button. */
97 QIMessageBox(const QString &strTitle, const QString &strMessage, AlertIconType iconType,
98 int iButton1 = 0, int iButton2 = 0, int iButton3 = 0, QWidget *pParent = 0);
99
100 /** Defines details-text. */
101 void setDetailsText(const QString &strText);
102
103 /** Returns whether flag is checked. */
104 bool flagChecked() const;
105 /** Defines whether flag is @a fChecked. */
106 void setFlagChecked(bool fChecked);
107 /** Defines @a strFlagText. */
108 void setFlagText(const QString &strFlagText);
109
110 /** Defines @a iButton @a strText. */
111 void setButtonText(int iButton, const QString &strText);
112
113protected:
114
115 /** Handles polish @a pEvent. */
116 virtual void polishEvent(QShowEvent *pEvent) /* override */;
117
118 /** Handles close @a pEvent. */
119 virtual void closeEvent(QCloseEvent *pEvent) /* override */;
120
121private slots:
122
123 /** Updates dialog size: */
124 void sltUpdateSize();
125
126 /** Copy details-text. */
127 void sltCopy() const;
128
129 /** Closes dialog like user would press the Cancel button. */
130 virtual void reject() /* override */;
131
132 /** Closes dialog like user would press the 1st button. */
133 void sltDone1() { m_fDone = true; done(m_iButton1 & AlertButtonMask); }
134 /** Closes dialog like user would press the 2nd button. */
135 void sltDone2() { m_fDone = true; done(m_iButton2 & AlertButtonMask); }
136 /** Closes dialog like user would press the 3rd button. */
137 void sltDone3() { m_fDone = true; done(m_iButton3 & AlertButtonMask); }
138
139private:
140
141 /** Prepares all. */
142 void prepare();
143
144 /** Prepares focus. */
145 void prepareFocus();
146
147 /** Push-button factory. */
148 QPushButton *createButton(int iButton);
149
150 /** Visibility update routine for details-container. */
151 void updateDetailsContainer();
152 /** Visibility update routine for check-box. */
153 void updateCheckBox();
154
155 /** Generates standard pixmap for passed @a iconType using @a pWidget as hint. */
156 static QPixmap standardPixmap(AlertIconType iconType, QWidget *pWidget = 0);
157
158 /** Holds the title. */
159 QString m_strTitle;
160
161 /** Holds the icon-type. */
162 AlertIconType m_iconType;
163 /** Holds the icon-label instance. */
164 QLabel *m_pLabelIcon;
165
166 /** Holds the message. */
167 QString m_strMessage;
168 /** Holds the message-label instance. */
169 QILabel *m_pLabelText;
170
171 /** Holds the flag check-box instance. */
172 QCheckBox *m_pFlagCheckBox;
173
174 /** Holds the flag details-container instance. */
175 QIArrowSplitter *m_pDetailsContainer;
176
177 /** Holds the integer-code for the 1st button. */
178 int m_iButton1;
179 /** Holds the integer-code for the 2nd button. */
180 int m_iButton2;
181 /** Holds the integer-code for the 3rd button. */
182 int m_iButton3;
183 /** Holds the integer-code of the cancel-button. */
184 int m_iButtonEsc;
185 /** Holds the 1st button instance. */
186 QPushButton *m_pButton1;
187 /** Holds the 2nd button instance. */
188 QPushButton *m_pButton2;
189 /** Holds the 3rd button instance. */
190 QPushButton *m_pButton3;
191 /** Holds the button-box instance. */
192 QIDialogButtonBox *m_pButtonBox;
193
194 /** Defines whether message was accepted. */
195 bool m_fDone : 1;
196};
197
198
199#endif /* !FEQT_INCLUDED_SRC_extensions_QIMessageBox_h */
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use