VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/include/QIMessageBox.h@ 17108

Last change on this file since 17108 was 17108, checked in by vboxsync, 16 years ago

FE/Qt4: 3627: Shorten error dialogs: 1 - focus rectangle around the text when focused, 2 - clicking over the text toggles related button, 3 - allowing to resize message vertically.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.9 KB
Line 
1/** @file
2 *
3 * VBox frontends: Qt GUI ("VirtualBox"):
4 * VirtualBox Qt extensions: QIMessageBox class declaration
5 */
6
7/*
8 * Copyright (C) 2006-2008 Sun Microsystems, Inc.
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 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
19 * Clara, CA 95054 USA or visit http://www.sun.com if you need
20 * additional information or have any questions.
21 */
22
23#ifndef __QIMessageBox_h__
24#define __QIMessageBox_h__
25
26/* VBox includes */
27#include "QIDialog.h"
28
29/* Qt includes */
30#include <QMessageBox>
31#include <QCheckBox>
32#include <QTextEdit>
33
34/* VBox forwards */
35class QIArrowSplitter;
36class QIDialogButtonBox;
37class QILabel;
38
39/* Qt forwards */
40class QCloseEvent;
41class QLabel;
42class QPushButton;
43class QSpacerItem;
44class QToolButton;
45class QVBoxLayout;
46
47/** @class QIArrowButton
48 *
49 * The QIArrowButton class is an arrow tool-botton with text-label.
50 * It is declared here until moved into separate file in case
51 * of it will be used somewhere except problem-reporter dialog.
52 */
53class QIArrowButton : public QWidget
54{
55 Q_OBJECT;
56
57public:
58
59 QIArrowButton (const QString &aName, QWidget *aParent = 0);
60
61 bool isExpanded() const;
62
63 void animateClick();
64
65signals:
66
67 void clicked();
68
69private slots:
70
71 void buttonClicked();
72
73private:
74
75 void updateIcon();
76
77 bool eventFilter (QObject *aObject, QEvent *aEvent);
78
79 void paintEvent (QPaintEvent *aEvent);
80
81 bool mIsExpanded;
82 QToolButton *mButton;
83 QLabel *mLabel;
84};
85
86/** @class QIArrowSplitter
87 *
88 * The QIArrowSplitter class is a folding widget placeholder.
89 * It is declared here until moved into separate file in case
90 * of it will be used somewhere except problem-reporter dialog.
91 */
92class QIArrowSplitter : public QWidget
93{
94 Q_OBJECT;
95
96public:
97
98 QIArrowSplitter (QWidget *aParent = 0);
99
100 void addWidget (const QString &aName, QWidget *aWidget);
101
102public slots:
103
104 void toggleWidget();
105
106private:
107
108 bool eventFilter (QObject *aObject, QEvent *aEvent);
109
110 QVBoxLayout *mMainLayout;
111 QList <QIArrowButton*> mButtonsList;
112 QList <QWidget*> mWidgetsList;
113};
114
115/** @class QIMessageBox
116 *
117 * The QIMessageBox class is a message box similar to QMessageBox.
118 * It partly implements the QMessageBox interface and adds some enhanced
119 * functionality.
120 */
121class QIMessageBox : public QIDialog
122{
123 Q_OBJECT;
124
125public:
126
127 // for compatibility with QMessageBox
128 enum Icon
129 {
130 NoIcon = QMessageBox::NoIcon,
131 Information = QMessageBox::Information,
132 Warning = QMessageBox::Warning,
133 Critical = QMessageBox::Critical,
134 Question = QMessageBox::Question,
135 GuruMeditation,
136 };
137
138 enum
139 {
140 NoButton = 0, Ok = 1, Cancel = 2, Yes = 3, No = 4, Abort = 5,
141 Retry = 6, Ignore = 7, YesAll = 8, NoAll = 9,
142 ButtonMask = 0xFF,
143
144 Default = 0x100, Escape = 0x200,
145 FlagMask = 0x300
146 };
147
148 QIMessageBox (const QString &aCaption, const QString &aText,
149 Icon aIcon, int aButton0, int aButton1 = 0, int aButton2 = 0,
150 QWidget *aParent = 0, const char *aName = 0, bool aModal = TRUE);
151
152 QString buttonText (int aButton) const;
153 void setButtonText (int aButton, const QString &aText);
154
155 QString flagText() const { return mFlagCB->isVisible() ? mFlagCB->text() : QString::null; }
156 void setFlagText (const QString &aText);
157
158 bool isFlagChecked() const { return mFlagCB->isChecked(); }
159 void setFlagChecked (bool aChecked) { mFlagCB->setChecked (aChecked); }
160
161 QString detailsText () const { return mDetailsText->toHtml(); }
162 void setDetailsText (const QString &aText);
163
164 bool isDetailsShown() const { return mDetailsVBox->isVisible(); }
165 void setDetailsShown (bool aShown);
166
167 QPixmap standardPixmap (QIMessageBox::Icon aIcon);
168
169private:
170
171 QPushButton *createButton (int aButton);
172
173 void closeEvent (QCloseEvent *e);
174 void showEvent (QShowEvent *e);
175
176private slots:
177
178 void done0() { mWasDone = true; done (mButton0 & ButtonMask); }
179 void done1() { mWasDone = true; done (mButton1 & ButtonMask); }
180 void done2() { mWasDone = true; done (mButton2 & ButtonMask); }
181
182 void reject();
183
184private:
185
186 int mButton0, mButton1, mButton2, mButtonEsc;
187 QLabel *mIconLabel;
188 QILabel *mTextLabel;
189 QPushButton *mButton0PB, *mButton1PB, *mButton2PB;
190 QCheckBox *mFlagCB, *mFlagCB_Main, *mFlagCB_Details;
191 QWidget *mDetailsVBox;
192 QIArrowSplitter *mDetailsSplitter;
193 QTextEdit *mDetailsText;
194 QSpacerItem *mSpacer;
195 QIDialogButtonBox *mButtonBox;
196 bool mWasDone : 1;
197 bool mWasPolished : 1;
198};
199
200#endif
201
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette