VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIPopupPane.h@ 100347

Last change on this file since 100347 was 98103, checked in by vboxsync, 23 months ago

Copyright year updates by scm.

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