1 | /* $Id: UIPopupPane.h 76553 2019-01-01 01:45:53Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBox Qt GUI - UIPopupPane class declaration.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2013-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 ___UIPopupPane_h___
|
---|
19 | #define ___UIPopupPane_h___
|
---|
20 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
21 | # pragma once
|
---|
22 | #endif
|
---|
23 |
|
---|
24 | /* Qt includes: */
|
---|
25 | #include <QMap>
|
---|
26 | #include <QWidget>
|
---|
27 |
|
---|
28 | /* GUI includes: */
|
---|
29 | #include "QIWithRetranslateUI.h"
|
---|
30 | #include "UILibraryDefs.h"
|
---|
31 |
|
---|
32 | /* Forward declaration: */
|
---|
33 | class QEvent;
|
---|
34 | class QObject;
|
---|
35 | class QPainter;
|
---|
36 | class QPaintEvent;
|
---|
37 | class QRect;
|
---|
38 | class QShowEvent;
|
---|
39 | class QSize;
|
---|
40 | class QString;
|
---|
41 | class QWidget;
|
---|
42 | class UIAnimation;
|
---|
43 | class UIPopupPaneDetails;
|
---|
44 | class UIPopupPaneMessage;
|
---|
45 | class UIPopupPaneButtonPane;
|
---|
46 |
|
---|
47 | /** QWidget extension used as popup-center pane prototype. */
|
---|
48 | class SHARED_LIBRARY_STUFF UIPopupPane : public QIWithRetranslateUI<QWidget>
|
---|
49 | {
|
---|
50 | Q_OBJECT;
|
---|
51 | Q_PROPERTY(QSize hiddenSizeHint READ hiddenSizeHint);
|
---|
52 | Q_PROPERTY(QSize shownSizeHint READ shownSizeHint);
|
---|
53 | Q_PROPERTY(QSize minimumSizeHint READ minimumSizeHint WRITE setMinimumSizeHint);
|
---|
54 | Q_PROPERTY(int defaultOpacity READ defaultOpacity);
|
---|
55 | Q_PROPERTY(int hoveredOpacity READ hoveredOpacity);
|
---|
56 | Q_PROPERTY(int opacity READ opacity WRITE setOpacity);
|
---|
57 |
|
---|
58 | signals:
|
---|
59 |
|
---|
60 | /** Asks to show itself asynchronously. */
|
---|
61 | void sigToShow();
|
---|
62 | /** Asks to hide itself asynchronously. */
|
---|
63 | void sigToHide();
|
---|
64 | /** Asks to show itself instantly. */
|
---|
65 | void sigShow();
|
---|
66 | /** Asks to hide itself instantly. */
|
---|
67 | void sigHide();
|
---|
68 |
|
---|
69 | /** Notifies about hover enter. */
|
---|
70 | void sigHoverEnter();
|
---|
71 | /** Notifies about hover leave. */
|
---|
72 | void sigHoverLeave();
|
---|
73 |
|
---|
74 | /** Notifies about focus enter. */
|
---|
75 | void sigFocusEnter();
|
---|
76 | /** Notifies about focus leave. */
|
---|
77 | void sigFocusLeave();
|
---|
78 |
|
---|
79 | /** Proposes pane @a iWidth. */
|
---|
80 | void sigProposePaneWidth(int iWidth);
|
---|
81 | /** Proposes details pane @a iHeight. */
|
---|
82 | void sigProposeDetailsPaneHeight(int iHeight);
|
---|
83 | /** Notifies about size-hint changed. */
|
---|
84 | void sigSizeHintChanged();
|
---|
85 |
|
---|
86 | /** Asks to close with @a iResultCode. */
|
---|
87 | void sigDone(int iResultCode) const;
|
---|
88 |
|
---|
89 | public:
|
---|
90 |
|
---|
91 | /** Constructs popup-pane.
|
---|
92 | * @param pParent Brings the parent.
|
---|
93 | * @param strMessage Brings the pane message.
|
---|
94 | * @param strDetails Brings the pane details.
|
---|
95 | * @param buttonDescriptions Brings the button descriptions. */
|
---|
96 | UIPopupPane(QWidget *pParent,
|
---|
97 | const QString &strMessage, const QString &strDetails,
|
---|
98 | const QMap<int, QString> &buttonDescriptions);
|
---|
99 |
|
---|
100 | /** Recalls itself. */
|
---|
101 | void recall();
|
---|
102 |
|
---|
103 | /** Defines the @a strMessage. */
|
---|
104 | void setMessage(const QString &strMessage);
|
---|
105 | /** Defines the @a strDetails. */
|
---|
106 | void setDetails(const QString &strDetails);
|
---|
107 |
|
---|
108 | /** Returns minimum size-hint. */
|
---|
109 | QSize minimumSizeHint() const { return m_minimumSizeHint; }
|
---|
110 | /** Defines @a minimumSizeHint. */
|
---|
111 | void setMinimumSizeHint(const QSize &minimumSizeHint);
|
---|
112 | /** Lays the content out. */
|
---|
113 | void layoutContent();
|
---|
114 |
|
---|
115 | public slots:
|
---|
116 |
|
---|
117 | /** Handles proposal for a @a newSize. */
|
---|
118 | void sltHandleProposalForSize(QSize newSize);
|
---|
119 |
|
---|
120 | private slots:
|
---|
121 |
|
---|
122 | /** Marks pane as fully shown. */
|
---|
123 | void sltMarkAsShown();
|
---|
124 |
|
---|
125 | /** Updates size-hint. */
|
---|
126 | void sltUpdateSizeHint();
|
---|
127 |
|
---|
128 | /** Handles a click of button with @a iButtonID. */
|
---|
129 | void sltButtonClicked(int iButtonID);
|
---|
130 |
|
---|
131 | private:
|
---|
132 |
|
---|
133 | /** A pair of strings. */
|
---|
134 | typedef QPair<QString, QString> QStringPair;
|
---|
135 | /** A list of string pairs. */
|
---|
136 | typedef QList<QStringPair> QStringPairList;
|
---|
137 |
|
---|
138 | /** Prepares all. */
|
---|
139 | void prepare();
|
---|
140 | /** Prepares background. */
|
---|
141 | void prepareBackground();
|
---|
142 | /** Prepares content. */
|
---|
143 | void prepareContent();
|
---|
144 | /** Prepares animation. */
|
---|
145 | void prepareAnimation();
|
---|
146 |
|
---|
147 | /** Handles translation event. */
|
---|
148 | virtual void retranslateUi() /* override */;
|
---|
149 | /** Translats tool-tips. */
|
---|
150 | void retranslateToolTips();
|
---|
151 |
|
---|
152 | /** Pre-handles standard Qt @a pEvent for passed @a pObject. */
|
---|
153 | virtual bool eventFilter(QObject *pObject, QEvent *pEvent) /* override */;
|
---|
154 |
|
---|
155 | /** Handles show @a pEvent. */
|
---|
156 | virtual void showEvent(QShowEvent *pEvent); /* override */;
|
---|
157 | /** Handles first show @a pEvent. */
|
---|
158 | void polishEvent(QShowEvent *pEvent);
|
---|
159 |
|
---|
160 | /** Handles paint @a pEvent. */
|
---|
161 | virtual void paintEvent(QPaintEvent *pEvent) /* override */;
|
---|
162 |
|
---|
163 | /** Assigns clipping of @a rect geometry for passed @a painter. */
|
---|
164 | void configureClipping(const QRect &rect, QPainter &painter);
|
---|
165 | /** Paints background of @a rect geometry using @a painter. */
|
---|
166 | void paintBackground(const QRect &rect, QPainter &painter);
|
---|
167 | /** Paints frame of @a rect geometry using @a painter. */
|
---|
168 | void paintFrame(QPainter &painter);
|
---|
169 |
|
---|
170 | /** Closes pane with @a iResultCode. */
|
---|
171 | void done(int iResultCode);
|
---|
172 |
|
---|
173 | /** Returns size-hint in hidden state. */
|
---|
174 | QSize hiddenSizeHint() const { return m_hiddenSizeHint; }
|
---|
175 | /** Returns size-hint in shown state. */
|
---|
176 | QSize shownSizeHint() const { return m_shownSizeHint; }
|
---|
177 |
|
---|
178 | /** Returns default opacity. */
|
---|
179 | int defaultOpacity() const { return m_iDefaultOpacity; }
|
---|
180 | /** Returns hovered opacity. */
|
---|
181 | int hoveredOpacity() const { return m_iHoveredOpacity; }
|
---|
182 | /** Returns current opacity. */
|
---|
183 | int opacity() const { return m_iOpacity; }
|
---|
184 | /** Defines current @a iOpacity. */
|
---|
185 | void setOpacity(int iOpacity) { m_iOpacity = iOpacity; update(); }
|
---|
186 |
|
---|
187 | /** Returns details text. */
|
---|
188 | QString prepareDetailsText() const;
|
---|
189 | /** Prepares passed @a aDetailsList. */
|
---|
190 | void prepareDetailsList(QStringPairList &aDetailsList) const;
|
---|
191 |
|
---|
192 | /** Holds whether the pane was polished. */
|
---|
193 | bool m_fPolished;
|
---|
194 |
|
---|
195 | /** Holds the pane ID. */
|
---|
196 | const QString m_strId;
|
---|
197 |
|
---|
198 | /** Holds the layout margin. */
|
---|
199 | const int m_iLayoutMargin;
|
---|
200 | /** Holds the layout spacing. */
|
---|
201 | const int m_iLayoutSpacing;
|
---|
202 |
|
---|
203 | /** Holds the minimum size-hint. */
|
---|
204 | QSize m_minimumSizeHint;
|
---|
205 |
|
---|
206 | /** Holds the pane message. */
|
---|
207 | QString m_strMessage;
|
---|
208 | /** Holds the pane details. */
|
---|
209 | QString m_strDetails;
|
---|
210 |
|
---|
211 | /** Holds the button descriptions. */
|
---|
212 | QMap<int, QString> m_buttonDescriptions;
|
---|
213 |
|
---|
214 | /** Holds whether the pane is shown fully. */
|
---|
215 | bool m_fShown;
|
---|
216 | /** Holds the show/hide animation instance. */
|
---|
217 | UIAnimation *m_pShowAnimation;
|
---|
218 | /** Holds the size-hint of pane in hidden state. */
|
---|
219 | QSize m_hiddenSizeHint;
|
---|
220 | /** Holds the size-hint of pane in shown state. */
|
---|
221 | QSize m_shownSizeHint;
|
---|
222 |
|
---|
223 | /** Holds whether the pane can loose focus. */
|
---|
224 | bool m_fCanLooseFocus;
|
---|
225 | /** Holds whether the pane is focused. */
|
---|
226 | bool m_fFocused;
|
---|
227 |
|
---|
228 | /** Holds whether the pane is hovered. */
|
---|
229 | bool m_fHovered;
|
---|
230 | /** Holds the default opacity. */
|
---|
231 | const int m_iDefaultOpacity;
|
---|
232 | /** Holds the hovered opacity. */
|
---|
233 | const int m_iHoveredOpacity;
|
---|
234 | /** Holds the current opacity. */
|
---|
235 | int m_iOpacity;
|
---|
236 |
|
---|
237 | /** Holds the message pane instance. */
|
---|
238 | UIPopupPaneMessage *m_pMessagePane;
|
---|
239 | /** Holds the details pane instance. */
|
---|
240 | UIPopupPaneDetails *m_pDetailsPane;
|
---|
241 | /** Holds the buttons pane instance. */
|
---|
242 | UIPopupPaneButtonPane *m_pButtonPane;
|
---|
243 | };
|
---|
244 |
|
---|
245 | #endif /* !___UIPopupPane_h___ */
|
---|
246 |
|
---|