VirtualBox

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

Last change on this file was 104358, checked in by vboxsync, 5 weeks ago

FE/Qt. bugref:10622. More refactoring around the retranslation functionality.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.7 KB
Line 
1/* $Id: UIPopupPane.h 104358 2024-04-18 05:33:40Z 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 "UILibraryDefs.h"
40
41/* Forward declaration: */
42class QEvent;
43class QObject;
44class QPainter;
45class QPaintEvent;
46class QRect;
47class QShowEvent;
48class QSize;
49class QString;
50class QWidget;
51class UIAnimation;
52class UIPopupPaneDetails;
53class UIPopupPaneMessage;
54class UIPopupPaneButtonPane;
55
56/** QWidget extension used as popup-center pane prototype. */
57class SHARED_LIBRARY_STUFF UIPopupPane : public QWidget
58{
59 Q_OBJECT;
60 Q_PROPERTY(QSize hiddenSizeHint READ hiddenSizeHint);
61 Q_PROPERTY(QSize shownSizeHint READ shownSizeHint);
62 Q_PROPERTY(QSize minimumSizeHint READ minimumSizeHint WRITE setMinimumSizeHint);
63 Q_PROPERTY(int defaultOpacity READ defaultOpacity);
64 Q_PROPERTY(int hoveredOpacity READ hoveredOpacity);
65 Q_PROPERTY(int opacity READ opacity WRITE setOpacity);
66
67signals:
68
69 /** Asks to show itself asynchronously. */
70 void sigToShow();
71 /** Asks to hide itself asynchronously. */
72 void sigToHide();
73 /** Asks to show itself instantly. */
74 void sigShow();
75 /** Asks to hide itself instantly. */
76 void sigHide();
77
78 /** Notifies about hover enter. */
79 void sigHoverEnter();
80 /** Notifies about hover leave. */
81 void sigHoverLeave();
82
83 /** Notifies about focus enter. */
84 void sigFocusEnter();
85 /** Notifies about focus leave. */
86 void sigFocusLeave();
87
88 /** Proposes pane @a iWidth. */
89 void sigProposePaneWidth(int iWidth);
90 /** Proposes details pane @a iHeight. */
91 void sigProposeDetailsPaneHeight(int iHeight);
92 /** Notifies about size-hint changed. */
93 void sigSizeHintChanged();
94
95 /** Asks to close with @a iResultCode. */
96 void sigDone(int iResultCode) const;
97
98public:
99
100 /** Constructs popup-pane.
101 * @param pParent Brings the parent.
102 * @param strMessage Brings the pane message.
103 * @param strDetails Brings the pane details.
104 * @param buttonDescriptions Brings the button descriptions. */
105 UIPopupPane(QWidget *pParent,
106 const QString &strMessage, const QString &strDetails,
107 const QMap<int, QString> &buttonDescriptions);
108
109 /** Recalls itself. */
110 void recall();
111
112 /** Defines the @a strMessage. */
113 void setMessage(const QString &strMessage);
114 /** Defines the @a strDetails. */
115 void setDetails(const QString &strDetails);
116
117 /** Returns minimum size-hint. */
118 QSize minimumSizeHint() const RT_OVERRIDE { return m_minimumSizeHint; }
119 /** Defines @a minimumSizeHint. */
120 void setMinimumSizeHint(const QSize &minimumSizeHint);
121 /** Lays the content out. */
122 void layoutContent();
123
124public slots:
125
126 /** Handles proposal for a @a newSize. */
127 void sltHandleProposalForSize(QSize newSize);
128
129private slots:
130
131 /** Marks pane as fully shown. */
132 void sltMarkAsShown();
133
134 /** Updates size-hint. */
135 void sltUpdateSizeHint();
136
137 /** Handles a click of button with @a iButtonID. */
138 void sltButtonClicked(int iButtonID);
139
140 /** Handles translation event. */
141 void sltRetranslateUI();
142
143private:
144
145 /** A pair of strings. */
146 typedef QPair<QString, QString> QStringPair;
147 /** A list of string pairs. */
148 typedef QList<QStringPair> QStringPairList;
149
150 /** Prepares all. */
151 void prepare();
152 /** Prepares background. */
153 void prepareBackground();
154 /** Prepares content. */
155 void prepareContent();
156 /** Prepares animation. */
157 void prepareAnimation();
158
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 */
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use