1 | /** @file
|
---|
2 | *
|
---|
3 | * VBox frontends: Qt GUI ("VirtualBox"):
|
---|
4 | * innotek Qt extensions: QIMessageBox class declaration
|
---|
5 | */
|
---|
6 |
|
---|
7 | /*
|
---|
8 | * Copyright (C) 2006-2007 innotek GmbH
|
---|
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 as published by the Free Software Foundation,
|
---|
14 | * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
|
---|
15 | * distribution. VirtualBox OSE is distributed in the hope that it will
|
---|
16 | * be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
17 | */
|
---|
18 |
|
---|
19 | #ifndef __QIMessageBox_h__
|
---|
20 | #define __QIMessageBox_h__
|
---|
21 |
|
---|
22 | #include <qdialog.h>
|
---|
23 | #include <qvbox.h>
|
---|
24 | #include <qmessagebox.h>
|
---|
25 | #include <qcheckbox.h>
|
---|
26 | #include <qtextedit.h>
|
---|
27 |
|
---|
28 | class QIRichLabel;
|
---|
29 | class QLabel;
|
---|
30 | class QPushButton;
|
---|
31 | class QSpacerItem;
|
---|
32 |
|
---|
33 | class QIMessageBox : public QDialog
|
---|
34 | {
|
---|
35 | Q_OBJECT
|
---|
36 |
|
---|
37 | public:
|
---|
38 |
|
---|
39 | // for compatibility with QMessageBox
|
---|
40 | enum Icon
|
---|
41 | {
|
---|
42 | NoIcon = QMessageBox::NoIcon,
|
---|
43 | Information = QMessageBox::Information,
|
---|
44 | Warning = QMessageBox::Warning,
|
---|
45 | Critical = QMessageBox::Critical,
|
---|
46 | Question = QMessageBox::Question
|
---|
47 | };
|
---|
48 |
|
---|
49 | enum
|
---|
50 | {
|
---|
51 | NoButton = 0, Ok = 1, Cancel = 2, Yes = 3, No = 4, Abort = 5,
|
---|
52 | Retry = 6, Ignore = 7, YesAll = 8, NoAll = 9, ButtonMask = 0xff,
|
---|
53 | Default = 0x100, Escape = 0x200, FlagMask = 0x300
|
---|
54 | };
|
---|
55 |
|
---|
56 | QIMessageBox (const QString &aCaption, const QString &aText,
|
---|
57 | Icon aIcon, int aButton0, int aButton1 = 0, int aButton2 = 0,
|
---|
58 | QWidget *aParent = 0, const char *aName = 0, bool aModal = TRUE,
|
---|
59 | WFlags aFlags = WStyle_DialogBorder);
|
---|
60 |
|
---|
61 | QString flagText() const { return mFlagCB->isShown() ? mFlagCB->text() : QString::null; }
|
---|
62 | void setFlagText (const QString &aText);
|
---|
63 |
|
---|
64 | bool isFlagChecked() const { return mFlagCB->isChecked(); }
|
---|
65 | void setFlagChecked (bool aChecked) { mFlagCB->setChecked (aChecked); }
|
---|
66 |
|
---|
67 | QString detailsText () const { return mDetailsText->text(); }
|
---|
68 | void setDetailsText (const QString &aText);
|
---|
69 |
|
---|
70 | bool isDetailsShown() const { return mDetailsVBox->isShown(); }
|
---|
71 | void setDetailsShown (bool aShown);
|
---|
72 |
|
---|
73 | private:
|
---|
74 |
|
---|
75 | QPushButton *createButton (QWidget *aParent, int aButton);
|
---|
76 |
|
---|
77 | private slots:
|
---|
78 |
|
---|
79 | void done0() { done (mButton0 & ButtonMask); }
|
---|
80 | void done1() { done (mButton1 & ButtonMask); }
|
---|
81 | void done2() { done (mButton2 & ButtonMask); }
|
---|
82 |
|
---|
83 | void reject() {
|
---|
84 | QDialog::reject();
|
---|
85 | if (mButtonEsc)
|
---|
86 | setResult (mButtonEsc & ButtonMask);
|
---|
87 | }
|
---|
88 |
|
---|
89 | private:
|
---|
90 |
|
---|
91 | int mButton0, mButton1, mButton2, mButtonEsc;
|
---|
92 | QLabel *mIconLabel;
|
---|
93 | QIRichLabel *mTextLabel;
|
---|
94 | QPushButton *mButton0PB, *mButton1PB, *mButton2PB;
|
---|
95 | QVBox *mMessageVBox;
|
---|
96 | QCheckBox *mFlagCB, *mFlagCB_Main, *mFlagCB_Details;
|
---|
97 | QVBox *mDetailsVBox;
|
---|
98 | QTextEdit *mDetailsText;
|
---|
99 | QSpacerItem *mSpacer;
|
---|
100 | };
|
---|
101 |
|
---|
102 | #endif
|
---|