1 | /** @file
|
---|
2 | *
|
---|
3 | * VBox frontends: Qt GUI ("VirtualBox"):
|
---|
4 | * VirtualBox Qt extensions: QIMessageBox class declaration
|
---|
5 | */
|
---|
6 |
|
---|
7 | /*
|
---|
8 | * Copyright (C) 2006-2009 Oracle Corporation
|
---|
9 | *
|
---|
10 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
11 | * available from http://www.virtualbox.org. This file is free software;
|
---|
12 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
13 | * General Public License (GPL) as published by the Free Software
|
---|
14 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
15 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
16 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
17 | */
|
---|
18 |
|
---|
19 | #ifndef __QIMessageBox_h__
|
---|
20 | #define __QIMessageBox_h__
|
---|
21 |
|
---|
22 | /* VBox includes */
|
---|
23 | #include "QIDialog.h"
|
---|
24 | #include "QIArrowSplitter.h"
|
---|
25 |
|
---|
26 | /* Qt includes */
|
---|
27 | #include <QCheckBox>
|
---|
28 | #include <QMessageBox>
|
---|
29 | #include <QTextEdit>
|
---|
30 |
|
---|
31 | /* VBox forwards */
|
---|
32 | class QIArrowSplitter;
|
---|
33 | class QIDialogButtonBox;
|
---|
34 | class QILabel;
|
---|
35 |
|
---|
36 | /* Qt forwards */
|
---|
37 | class QCloseEvent;
|
---|
38 | class QLabel;
|
---|
39 | class QPushButton;
|
---|
40 | class QSpacerItem;
|
---|
41 |
|
---|
42 | /** @class QIMessageBox
|
---|
43 | *
|
---|
44 | * The QIMessageBox class is a message box similar to QMessageBox.
|
---|
45 | * It partly implements the QMessageBox interface and adds some enhanced
|
---|
46 | * functionality.
|
---|
47 | */
|
---|
48 | class QIMessageBox : public QIDialog
|
---|
49 | {
|
---|
50 | Q_OBJECT;
|
---|
51 |
|
---|
52 | public:
|
---|
53 |
|
---|
54 | // for compatibility with QMessageBox
|
---|
55 | enum Icon
|
---|
56 | {
|
---|
57 | NoIcon = QMessageBox::NoIcon,
|
---|
58 | Information = QMessageBox::Information,
|
---|
59 | Warning = QMessageBox::Warning,
|
---|
60 | Critical = QMessageBox::Critical,
|
---|
61 | Question = QMessageBox::Question,
|
---|
62 | GuruMeditation,
|
---|
63 | };
|
---|
64 |
|
---|
65 | enum
|
---|
66 | {
|
---|
67 | NoButton = 0, Ok = 1, Cancel = 2, Yes = 3, No = 4, Abort = 5,
|
---|
68 | Retry = 6, Ignore = 7, YesAll = 8, NoAll = 9,
|
---|
69 | ButtonMask = 0xFF,
|
---|
70 |
|
---|
71 | Default = 0x100, Escape = 0x200,
|
---|
72 | FlagMask = 0x300
|
---|
73 | };
|
---|
74 |
|
---|
75 | QIMessageBox (const QString &aCaption, const QString &aText,
|
---|
76 | Icon aIcon, int aButton0, int aButton1 = 0, int aButton2 = 0,
|
---|
77 | QWidget *aParent = 0, const char *aName = 0, bool aModal = TRUE);
|
---|
78 |
|
---|
79 | QString buttonText (int aButton) const;
|
---|
80 | void setButtonText (int aButton, const QString &aText);
|
---|
81 |
|
---|
82 | QString flagText() const { return mFlagCB->isVisible() ? mFlagCB->text() : QString::null; }
|
---|
83 | void setFlagText (const QString &aText);
|
---|
84 |
|
---|
85 | bool isFlagChecked() const { return mFlagCB->isChecked(); }
|
---|
86 | void setFlagChecked (bool aChecked) { mFlagCB->setChecked (aChecked); }
|
---|
87 |
|
---|
88 | QString detailsText () const { return mDetailsText->toHtml(); }
|
---|
89 | void setDetailsText (const QString &aText);
|
---|
90 |
|
---|
91 | QPixmap standardPixmap (QIMessageBox::Icon aIcon);
|
---|
92 |
|
---|
93 | private:
|
---|
94 |
|
---|
95 | QPushButton *createButton (int aButton);
|
---|
96 |
|
---|
97 | void closeEvent (QCloseEvent *e);
|
---|
98 | void showEvent (QShowEvent *e);
|
---|
99 |
|
---|
100 | void refreshDetails();
|
---|
101 | void setDetailsShown (bool aShown);
|
---|
102 |
|
---|
103 | private slots:
|
---|
104 |
|
---|
105 | void detailsBack();
|
---|
106 | void detailsNext();
|
---|
107 |
|
---|
108 | void done0() { mWasDone = true; done (mButton0 & ButtonMask); }
|
---|
109 | void done1() { mWasDone = true; done (mButton1 & ButtonMask); }
|
---|
110 | void done2() { mWasDone = true; done (mButton2 & ButtonMask); }
|
---|
111 |
|
---|
112 | void reject();
|
---|
113 |
|
---|
114 | private:
|
---|
115 |
|
---|
116 | int mButton0, mButton1, mButton2, mButtonEsc;
|
---|
117 | QLabel *mIconLabel;
|
---|
118 | QILabel *mTextLabel;
|
---|
119 | QPushButton *mButton0PB, *mButton1PB, *mButton2PB;
|
---|
120 | QCheckBox *mFlagCB, *mFlagCB_Main, *mFlagCB_Details;
|
---|
121 | QWidget *mDetailsVBox;
|
---|
122 | QIArrowSplitter *mDetailsSplitter;
|
---|
123 | QTextEdit *mDetailsText;
|
---|
124 | QSpacerItem *mSpacer;
|
---|
125 | QIDialogButtonBox *mButtonBox;
|
---|
126 | QString mText;
|
---|
127 | QList < QPair <QString, QString> > mDetailsList;
|
---|
128 | int mDetailsIndex;
|
---|
129 | bool mWasDone : 1;
|
---|
130 | bool mWasPolished : 1;
|
---|
131 | };
|
---|
132 |
|
---|
133 | #endif
|
---|
134 |
|
---|