VirtualBox

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

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

© 2023 Oracle
ContactPrivacy policyTerms of Use