VirtualBox

Ignore:
Timestamp:
Mar 23, 2018 3:49:49 PM (7 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
121462
Message:

FE/Qt: bugref:9049: Heavy cleanup for UIPopupPane.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/widgets
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIPopupPane.cpp

    r70474 r71490  
    55
    66/*
    7  * Copyright (C) 2013-2017 Oracle Corporation
     7 * Copyright (C) 2013-2018 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    1919# include <precomp.h>
    2020#else  /* !VBOX_WITH_PRECOMPILED_HEADERS */
     21
    2122/* Qt includes: */
    2223# include <QPainter>
     
    327328}
    328329
    329 bool UIPopupPane::eventFilter(QObject *pWatched, QEvent *pEvent)
     330bool UIPopupPane::eventFilter(QObject *pObject, QEvent *pEvent)
    330331{
    331332    /* Depending on event-type: */
     
    348349        {
    349350            /* Unhover pane if hovered but not focused: */
    350             if (pWatched == this && m_fHovered && !m_fFocused)
     351            if (pObject == this && m_fHovered && !m_fFocused)
    351352            {
    352353                m_fHovered = false;
     
    414415}
    415416
    416 void UIPopupPane::polishEvent(QShowEvent*)
     417void UIPopupPane::polishEvent(QShowEvent *)
    417418{
    418419    /* Focus if marked as 'focused': */
     
    424425}
    425426
    426 void UIPopupPane::paintEvent(QPaintEvent*)
     427void UIPopupPane::paintEvent(QPaintEvent *)
    427428{
    428429    /* Compose painting rectangle,
     
    537538    }
    538539}
     540
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIPopupPane.h

    r69500 r71490  
    55
    66/*
    7  * Copyright (C) 2013-2017 Oracle Corporation
     7 * Copyright (C) 2013-2018 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    1616 */
    1717
    18 #ifndef __UIPopupPane_h__
    19 #define __UIPopupPane_h__
     18#ifndef ___UIPopupPane_h___
     19#define ___UIPopupPane_h___
    2020
    2121/* Qt includes: */
     22#include <QMap>
    2223#include <QWidget>
    23 #include <QMap>
    2424
    2525/* GUI includes: */
     
    2727
    2828/* Forward declaration: */
     29class QEvent;
     30class QObject;
     31class QPainter;
     32class QPaintEvent;
     33class QRect;
     34class QShowEvent;
     35class QSize;
     36class QString;
     37class QWidget;
     38class UIAnimation;
     39class UIPopupPaneDetails;
    2940class UIPopupPaneMessage;
    30 class UIPopupPaneDetails;
    3141class UIPopupPaneButtonPane;
    32 class UIAnimation;
    33 
    34 /* Popup-pane prototype: */
     42
     43/** QWidget extension used as popup-center pane prototype. */
    3544class UIPopupPane : public QIWithRetranslateUI<QWidget>
    3645{
     
    4554signals:
    4655
    47     /* Notifiers: Show/hide stuff: */
     56    /** Asks to show itself asynchronously. */
    4857    void sigToShow();
     58    /** Asks to hide itself asynchronously. */
    4959    void sigToHide();
     60    /** Asks to show itself instantly. */
    5061    void sigShow();
     62    /** Asks to hide itself instantly. */
    5163    void sigHide();
    5264
    53     /* Notifiers: Hover stuff: */
     65    /** Notifies about hover enter. */
    5466    void sigHoverEnter();
     67    /** Notifies about hover leave. */
    5568    void sigHoverLeave();
    5669
    57     /* Notifiers: Focus stuff: */
     70    /** Notifies about focus enter. */
    5871    void sigFocusEnter();
     72    /** Notifies about focus leave. */
    5973    void sigFocusLeave();
    6074
    61     /* Notifiers: Layout stuff: */
     75    /** Proposes pane @a iWidth. */
    6276    void sigProposePaneWidth(int iWidth);
     77    /** Proposes details pane @a iHeight. */
    6378    void sigProposeDetailsPaneHeight(int iHeight);
     79    /** Notifies about size-hint changed. */
    6480    void sigSizeHintChanged();
    6581
    66     /* Notifier: Complete stuff: */
     82    /** Asks to close with @a iResultCode. */
    6783    void sigDone(int iResultCode) const;
    6884
    6985public:
    7086
    71     /* Constructor: */
     87    /** Constructs popup-pane.
     88      * @param  pParent             Brings the parent.
     89      * @param  strMessage          Brings the pane message.
     90      * @param  strDetails          Brings the pane details.
     91      * @param  buttonDescriptions  Brings the button descriptions. */
    7292    UIPopupPane(QWidget *pParent,
    7393                const QString &strMessage, const QString &strDetails,
    7494                const QMap<int, QString> &buttonDescriptions);
    7595
    76     /* API: Recall stuff: */
     96    /** Recalls itself. */
    7797    void recall();
    7898
    79     /* API: Text stuff: */
     99    /** Defines the @a strMessage. */
    80100    void setMessage(const QString &strMessage);
     101    /** Defines the @a strDetails. */
    81102    void setDetails(const QString &strDetails);
    82103
    83     /* API: Layout stuff: */
     104    /** Returns minimum size-hint. */
    84105    QSize minimumSizeHint() const { return m_minimumSizeHint; }
     106    /** Defines @a minimumSizeHint. */
    85107    void setMinimumSizeHint(const QSize &minimumSizeHint);
     108    /** Lays the content out. */
    86109    void layoutContent();
    87110
    88111public slots:
    89112
    90     /* Handler: Layout stuff: */
     113    /** Handles proposal for a @a newSize. */
    91114    void sltHandleProposalForSize(QSize newSize);
    92115
    93116private slots:
    94117
    95     /* Handler: Show/hide stuff: */
     118    /** Marks pane as fully shown. */
    96119    void sltMarkAsShown();
    97120
    98     /* Handler: Layout stuff: */
     121    /** Updates size-hint. */
    99122    void sltUpdateSizeHint();
    100123
    101     /* Handler: Button stuff: */
     124    /** Handles a click of button with @a iButtonID. */
    102125    void sltButtonClicked(int iButtonID);
    103126
    104127private:
    105128
    106     /* Type definitions: */
     129    /** A pair of strings. */
    107130    typedef QPair<QString, QString> QStringPair;
     131    /** A list of string pairs. */
    108132    typedef QList<QStringPair> QStringPairList;
    109133
    110     /* Helpers: Prepare stuff: */
     134    /** Prepares all. */
    111135    void prepare();
     136    /** Prepares background. */
    112137    void prepareBackground();
     138    /** Prepares content. */
    113139    void prepareContent();
     140    /** Prepares animation. */
    114141    void prepareAnimation();
    115142
    116     /* Helpers: Translate stuff: */
    117     void retranslateUi();
     143    /** Handles translation event. */
     144    virtual void retranslateUi() /* override */;
     145    /** Translats tool-tips. */
    118146    void retranslateToolTips();
    119147
    120     /* Handler: Event-filter stuff: */
    121     bool eventFilter(QObject *pWatched, QEvent *pEvent);
    122 
    123     /* Handlers: Event stuff: */
    124     void showEvent(QShowEvent *pEvent);
     148    /** Pre-handles standard Qt @a pEvent for passed @a pObject. */
     149    virtual bool eventFilter(QObject *pObject, QEvent *pEvent) /* override */;
     150
     151    /** Handles show @a pEvent. */
     152    virtual void showEvent(QShowEvent *pEvent); /* override */;
     153    /** Handles first show @a pEvent. */
    125154    void polishEvent(QShowEvent *pEvent);
    126     void paintEvent(QPaintEvent *pEvent);
    127 
    128     /* Helpers: Paint stuff: */
     155
     156    /** Handles paint @a pEvent. */
     157    virtual void paintEvent(QPaintEvent *pEvent) /* override */;
     158
     159    /** Assigns clipping of @a rect geometry for passed @a painter. */
    129160    void configureClipping(const QRect &rect, QPainter &painter);
     161    /** Paints background of @a rect geometry using @a painter. */
    130162    void paintBackground(const QRect &rect, QPainter &painter);
     163    /** Paints frame of @a rect geometry using @a painter. */
    131164    void paintFrame(QPainter &painter);
    132165
    133     /* Helper: Complete stuff: */
     166    /** Closes pane with @a iResultCode. */
    134167    void done(int iResultCode);
    135168
    136     /* Property: Show/hide stuff: */
     169    /** Returns size-hint in hidden state. */
    137170    QSize hiddenSizeHint() const { return m_hiddenSizeHint; }
     171    /** Returns size-hint in shown state. */
    138172    QSize shownSizeHint() const { return m_shownSizeHint; }
    139173
    140     /* Property: Hover stuff: */
     174    /** Returns default opacity. */
    141175    int defaultOpacity() const { return m_iDefaultOpacity; }
     176    /** Returns hovered opacity. */
    142177    int hoveredOpacity() const { return m_iHoveredOpacity; }
     178    /** Returns current opacity. */
    143179    int opacity() const { return m_iOpacity; }
     180    /** Defines current @a iOpacity. */
    144181    void setOpacity(int iOpacity) { m_iOpacity = iOpacity; update(); }
    145182
    146     /* Helpers: Details stuff: */
     183    /** Returns details text. */
    147184    QString prepareDetailsText() const;
     185    /** Prepares passed @a aDetailsList. */
    148186    void prepareDetailsList(QStringPairList &aDetailsList) const;
    149187
    150     /* Variables: General stuff: */
     188    /** Holds whether the pane was polished. */
    151189    bool m_fPolished;
     190
     191    /** Holds the pane ID. */
    152192    const QString m_strId;
     193
     194    /** Holds the layout margin. */
    153195    const int m_iLayoutMargin;
     196    /** Holds the layout spacing. */
    154197    const int m_iLayoutSpacing;
     198
     199    /** Holds the minimum size-hint. */
    155200    QSize m_minimumSizeHint;
    156201
    157     /* Variables: Text stuff: */
    158     QString m_strMessage, m_strDetails;
    159 
    160     /* Variables: Button stuff: */
     202    /** Holds the pane message. */
     203    QString m_strMessage;
     204    /** Holds the pane details. */
     205    QString m_strDetails;
     206
     207    /** Holds the button descriptions. */
    161208    QMap<int, QString> m_buttonDescriptions;
    162209
    163     /* Variables: Show/hide stuff: */
    164     bool m_fShown;
     210    /** Holds whether the pane is shown fully. */
     211    bool         m_fShown;
     212    /** Holds the show/hide animation instance. */
    165213    UIAnimation *m_pShowAnimation;
    166     QSize m_hiddenSizeHint;
    167     QSize m_shownSizeHint;
    168 
    169     /* Variables: Focus stuff: */
     214    /** Holds the size-hint of pane in hidden state. */
     215    QSize        m_hiddenSizeHint;
     216    /** Holds the size-hint of pane in shown state. */
     217    QSize        m_shownSizeHint;
     218
     219    /** Holds whether the pane can loose focus. */
    170220    bool m_fCanLooseFocus;
     221    /** Holds whether the pane is focused. */
    171222    bool m_fFocused;
    172223
    173     /* Variables: Hover stuff: */
    174     bool m_fHovered;
     224    /** Holds whether the pane is hovered. */
     225    bool      m_fHovered;
     226    /** Holds the default opacity. */
    175227    const int m_iDefaultOpacity;
     228    /** Holds the hovered opacity. */
    176229    const int m_iHoveredOpacity;
    177     int m_iOpacity;
    178 
    179     /* Widgets: */
     230    /** Holds the current opacity. */
     231    int       m_iOpacity;
     232
     233    /** Holds the message pane instance. */
    180234    UIPopupPaneMessage    *m_pMessagePane;
     235    /** Holds the details pane instance. */
    181236    UIPopupPaneDetails    *m_pDetailsPane;
     237    /** Holds the buttons pane instance. */
    182238    UIPopupPaneButtonPane *m_pButtonPane;
    183239};
    184240
    185 #endif /* __UIPopupPane_h__ */
     241#endif /* !___UIPopupPane_h___ */
     242
Note: See TracChangeset for help on using the changeset viewer.

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