Index: trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIPopupBox.cpp
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIPopupBox.cpp	(revision 71479)
+++ trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIPopupBox.cpp	(revision 71484)
@@ -5,5 +5,5 @@
 
 /*
- * Copyright (C) 2010-2017 Oracle Corporation
+ * Copyright (C) 2010-2018 Oracle Corporation
  *
  * This file is part of VirtualBox Open Source Edition (OSE), as
@@ -22,9 +22,9 @@
 /* Qt includes: */
 # include <QApplication>
-# include <QStyle>
 # include <QLabel>
 # include <QPainter>
+# include <QPaintEvent>
+# include <QStyle>
 # include <QVBoxLayout>
-# include <QPaintEvent>
 
 /* GUI includes: */
@@ -36,43 +36,80 @@
 #endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
 
+
+/*********************************************************************************************************************************
+*   Class UIPopupBox implementation.                                                                                             *
+*********************************************************************************************************************************/
+
 UIPopupBox::UIPopupBox(QWidget *pParent)
   : QWidget(pParent)
-  , m_pTitleIcon(new QLabel(this))
-  , m_pWarningIcon(new QLabel(this))
-  , m_pTitleLabel(new QLabel(this))
+  , m_pTitleIcon(0)
+  , m_pWarningIcon(0)
+  , m_pTitleLabel(0)
   , m_fLinkEnabled(false)
+  , m_fOpened(true)
+  , m_fHovered(false)
   , m_pContentWidget(0)
-  , m_fOpen(true)
   , m_pLabelPath(0)
   , m_iArrowWidth(9)
-  , m_fHeaderHover(false)
-{
-    /* Setup main-layout: */
-    QVBoxLayout *pMainLayout = new QVBoxLayout(this);
-    /* Setup title-layout: */
-    QHBoxLayout *pTitleLayout = new QHBoxLayout;
-    pTitleLayout->addWidget(m_pTitleIcon);
-    pTitleLayout->addWidget(m_pWarningIcon);
-    pTitleLayout->addWidget(m_pTitleLabel, Qt::AlignLeft);
-    /* Add title-layout into main-layout: */
-    pMainLayout->addLayout(pTitleLayout);
-
-    /* Configure widgets: */
-    m_pWarningIcon->setHidden(true);
+{
+    /* Configure self: */
+    installEventFilter(this);
+
+    /* Configure painter-path: */
     m_arrowPath.lineTo(m_iArrowWidth / 2.0, m_iArrowWidth / 2.0);
     m_arrowPath.lineTo(m_iArrowWidth, 0);
 
-    /* Setup connections: */
-    connect(m_pTitleLabel, SIGNAL(linkActivated(const QString)), this, SIGNAL(sigTitleClicked(const QString)));
-
-    /* Install local event-filters: */
-    installEventFilter(this);
-    m_pTitleIcon->installEventFilter(this);
-    m_pWarningIcon->installEventFilter(this);
-    m_pTitleLabel->installEventFilter(this);
+    /* Create main-layout: */
+    QVBoxLayout *pMainLayout = new QVBoxLayout(this);
+    if (pMainLayout)
+    {
+        /* Create title-layout: */
+        QHBoxLayout *pTitleLayout = new QHBoxLayout;
+        if (pTitleLayout)
+        {
+            /* Create title-icon label. */
+            m_pTitleIcon = new QLabel;
+            if (m_pTitleIcon)
+            {
+                /* Configure label: */
+                m_pTitleIcon->installEventFilter(this);
+
+                /* Add into layout: */
+                pTitleLayout->addWidget(m_pTitleIcon);
+            }
+            /* Create warning-icon label. */
+            m_pWarningIcon = new QLabel;
+            if (m_pWarningIcon)
+            {
+                /* Configure label: */
+                m_pWarningIcon->setHidden(true);
+                m_pWarningIcon->installEventFilter(this);
+
+                /* Add into layout: */
+                pTitleLayout->addWidget(m_pWarningIcon);
+            }
+            /* Create title-text label. */
+            m_pTitleLabel = new QLabel;
+            if (m_pTitleLabel)
+            {
+                /* Configure label: */
+                m_pTitleLabel->installEventFilter(this);
+                connect(m_pTitleLabel, SIGNAL(linkActivated(const QString)),
+                        this, SIGNAL(sigTitleClicked(const QString)));
+
+                /* Add into layout: */
+                pTitleLayout->addWidget(m_pTitleLabel, Qt::AlignLeft);
+            }
+
+            /* Add into layout: */
+            pMainLayout->addLayout(pTitleLayout);
+        }
+    }
+
 }
 
 UIPopupBox::~UIPopupBox()
 {
+    /* Delete label painter-path if any: */
     if (m_pLabelPath)
         delete m_pLabelPath;
@@ -170,16 +207,16 @@
 }
 
-void UIPopupBox::setOpen(bool fOpen)
+void UIPopupBox::setOpen(bool fOpened)
 {
     /* Check if we should toggle popup-box: */
-    if (m_fOpen == fOpen)
+    if (m_fOpened == fOpened)
         return;
 
     /* Store new value: */
-    m_fOpen = fOpen;
+    m_fOpened = fOpened;
 
     /* Update content-widget if present or this itself: */
     if (m_pContentWidget)
-        m_pContentWidget->setVisible(m_fOpen);
+        m_pContentWidget->setVisible(m_fOpened);
     else
         update();
@@ -193,16 +230,16 @@
 {
     /* Switch 'opened' state: */
-    setOpen(!m_fOpen);
+    setOpen(!m_fOpened);
 
     /* Notify listeners about toggling: */
-    emit sigToggled(m_fOpen);
+    emit sigToggled(m_fOpened);
 }
 
 bool UIPopupBox::isOpen() const
 {
-    return m_fOpen;
-}
-
-bool UIPopupBox::eventFilter(QObject *pWatched, QEvent *pEvent)
+    return m_fOpened;
+}
+
+bool UIPopupBox::eventFilter(QObject *pObject, QEvent *pEvent)
 {
     /* Handle all mouse-event to update hover: */
@@ -214,5 +251,5 @@
         updateHover();
     /* Call to base-class: */
-    return QWidget::eventFilter(pWatched, pEvent);
+    return QWidget::eventFilter(pObject, pEvent);
 }
 
@@ -223,10 +260,4 @@
     /* Call to base-class: */
     QWidget::resizeEvent(pEvent);
-}
-
-void UIPopupBox::mouseDoubleClickEvent(QMouseEvent * /* pEvent */)
-{
-    /* Toggle popup-box: */
-    toggleOpen();
 }
 
@@ -250,5 +281,5 @@
     lg.setColorAt(1, base.darker(110));
     int theight = rect.height();
-    if (m_fOpen)
+    if (m_fOpened)
         theight = 2 * 5 + iMaxHeightHint;
     painter.fillRect(QRect(rect.x(), rect.y(), rect.width(), theight), lg);
@@ -257,10 +288,10 @@
     painter.strokePath(*m_pLabelPath, base.darker(110));
     /* Arrow */
-    if (m_fHeaderHover)
+    if (m_fHovered)
     {
         painter.setBrush(base.darker(106));
         painter.setPen(QPen(base.darker(128), 3, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
         QSizeF s = m_arrowPath.boundingRect().size();
-        if (m_fOpen)
+        if (m_fOpened)
         {
             painter.translate(rect.x() + rect.width() - s.width() - 10, rect.y() + theight / 2 + s.height() / 2);
@@ -274,4 +305,10 @@
         painter.drawPath(m_arrowPath);
     }
+}
+
+void UIPopupBox::mouseDoubleClickEvent(QMouseEvent *)
+{
+    /* Toggle popup-box: */
+    toggleOpen();
 }
 
@@ -308,5 +345,5 @@
         QPalette pal = m_pTitleLabel->palette();
         m_pTitleLabel->setText(QString("<b><a style=\"text-decoration: none; color: %1\" href=\"%2\">%3</a></b>")
-                               .arg(m_fHeaderHover ? pal.color(QPalette::Link).name() : pal.color(QPalette::WindowText).name())
+                               .arg(m_fHovered ? pal.color(QPalette::Link).name() : pal.color(QPalette::WindowText).name())
                                .arg(m_strLink)
                                .arg(m_strTitle));
@@ -317,21 +354,21 @@
 {
     /* Calculate new header-hover state: */
-    bool fNewHeaderHover = m_fHeaderHover;
+    bool fNewHovered = m_fHovered;
     if (m_pLabelPath && m_pLabelPath->contains(mapFromGlobal(QCursor::pos())))
-        fNewHeaderHover = true;
+        fNewHovered = true;
     else
-        fNewHeaderHover = false;
+        fNewHovered = false;
 
     /* Check if we should toggle hover: */
-    if (m_fHeaderHover == fNewHeaderHover)
+    if (m_fHovered == fNewHovered)
         return;
 
     /* If header-hover state switched from disabled to enabled: */
-    if (!m_fHeaderHover && fNewHeaderHover)
+    if (!m_fHovered && fNewHovered)
         /* Notify listeners: */
         emit sigGotHover();
 
     /* Toggle hover: */
-    toggleHover(fNewHeaderHover);
+    toggleHover(fNewHovered);
 }
 
@@ -339,5 +376,5 @@
 {
     /* Check if we should toggle hover: */
-    if (m_fHeaderHover == false)
+    if (m_fHovered == false)
         return;
 
@@ -349,5 +386,5 @@
 {
     /* Remember header-hover state: */
-    m_fHeaderHover = fHeaderHover;
+    m_fHovered = fHeaderHover;
 
     /* Update title: */
@@ -373,4 +410,9 @@
 }
 
+
+/*********************************************************************************************************************************
+*   Class UIPopupBoxGroup implementation.                                                                                        *
+*********************************************************************************************************************************/
+
 UIPopupBoxGroup::UIPopupBoxGroup(QObject *pParent)
     : QObject(pParent)
Index: trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIPopupBox.h
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIPopupBox.h	(revision 71479)
+++ trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIPopupBox.h	(revision 71484)
@@ -5,5 +5,5 @@
 
 /*
- * Copyright (C) 2010-2017 Oracle Corporation
+ * Copyright (C) 2010-2018 Oracle Corporation
  *
  * This file is part of VirtualBox Open Source Edition (OSE), as
@@ -16,16 +16,26 @@
  */
 
-#ifndef __UIPopupBoxStuff_h__
-#define __UIPopupBoxStuff_h__
-
-/* Global includes: */
+#ifndef ___UIPopupBoxStuff_h___
+#define ___UIPopupBoxStuff_h___
+
+/* Qt includes: */
 #include <QIcon>
 #include <QWidget>
 
 /* Forward declarations: */
+class QEvent;
+class QIcon;
 class QLabel;
-
-/* QWidget reimplementation,
- * wraps content-widget with nice/collapsable frame: */
+class QMouseEvent;
+class QObject;
+class QPainterPath;
+class QPaintEvent;
+class QResizeEvent;
+class QString;
+class QWidget;
+
+
+/** QWidget extension,
+  * wrapping content-widget with nice collapsable frame. */
 class UIPopupBox : public QWidget
 {
@@ -34,91 +44,134 @@
 signals:
 
-    /* Signals: */
+    /** Notifies about title with @a strLink was clicked. */
     void sigTitleClicked(const QString &strLink);
+
+    /** Notifies box was toggled and currently @a fOpened. */
     void sigToggled(bool fOpened);
+
+    /** Asks to update contents widget. */
     void sigUpdateContentWidget();
+
+    /** Notify about box is hovered. */
     void sigGotHover();
 
 public:
 
-    /* Constructor/destructor: */
+    /** Construct popup-box passing @a pParent to the base-class. */
     UIPopupBox(QWidget *pParent);
-    ~UIPopupBox();
-
-    /* Title-icon stuff: */
+    /** Destruct popup-box. */
+    virtual ~UIPopupBox() /* override */;
+
+    /** Defines title @a icon. */
     void setTitleIcon(const QIcon &icon);
+    /** Returns title icon. */
     QIcon titleIcon() const;
 
-    /* Warning-icon stuff: */
+    /** Defines warning @a icon. */
     void setWarningIcon(const QIcon &icon);
+    /** Returns warnings icon. */
     QIcon warningIcon() const;
 
-    /* Title stuff: */
+    /** Defines @a strTitle. */
     void setTitle(const QString &strTitle);
+    /** Returns title. */
     QString title() const;
 
-    /* Link stuff: */
+    /** Defines title @a strLink. */
     void setTitleLink(const QString &strLink);
+    /** Returns title link. */
     QString titleLink() const;
+    /** Defines whether title link is @a fEnabled. */
     void setTitleLinkEnabled(bool fEnabled);
+    /** Returns whether title link is enabled. */
     bool isTitleLinkEnabled() const;
 
-    /* Content-widget stuff: */
+    /** Defines content @a pWidget. */
     void setContentWidget(QWidget *pWidget);
-    QWidget* contentWidget() const;
-
-    /* Toggle stuff: */
-    void setOpen(bool fOpen);
+    /** Returns content widget. */
+    QWidget *contentWidget() const;
+
+    /** Defines whether box is @a fOpened. */
+    void setOpen(bool fOpened);
+    /** Toggles current opened state. */
     void toggleOpen();
+    /** Returns whether box is opened. */
     bool isOpen() const;
 
-    /* Update stuff: */
+    /** Calls for content iwdget update. */
     void callForUpdateContentWidget() { emit sigUpdateContentWidget(); }
 
 protected:
 
-    /* Event filter: */
-    bool eventFilter(QObject *pWatched, QEvent *pEvent);
-
-    /* Event handlers: */
-    void resizeEvent(QResizeEvent *pEvent);
-    void mouseDoubleClickEvent(QMouseEvent *pEvent);
-    void paintEvent(QPaintEvent *pEvent);
+    /** Pre-handles standard Qt @a pEvent for passed @a pObject. */
+    virtual bool eventFilter(QObject *pObject, QEvent *pEvent) /* override */;
+
+    /** Handles resize @a pEvent. */
+    virtual void resizeEvent(QResizeEvent *pEvent) /* override */;
+
+    /** Handles paint @a pEvent. */
+    virtual void paintEvent(QPaintEvent *pEvent) /* override */;
+
+    /** Handles mouse double-click @a pEvent. */
+    virtual void mouseDoubleClickEvent(QMouseEvent *pEvent) /* override */;
 
 private:
 
-    /* Helpers: */
+    /** Updates title icon. */
     void updateTitleIcon();
+    /** Updates warning icon. */
     void updateWarningIcon();
+    /** Updates title. */
     void updateTitle();
+    /** Updates hovered state. */
     void updateHover();
+    /** Revokes hovered state. */
     void revokeHover();
+    /** Toggles hovered state to @a fHeaderHover. */
     void toggleHover(bool fHeaderHover);
+    /** Recalculates geometry. */
     void recalc();
 
-    /* Widgets: */
+    /** Holds the title icon label. */
     QLabel *m_pTitleIcon;
+    /** Holds the warning icon label. */
     QLabel *m_pWarningIcon;
+    /** Holds the title label. */
     QLabel *m_pTitleLabel;
 
-    /* Variables: */
-    QIcon m_titleIcon;
-    QIcon m_warningIcon;
-    QString m_strTitle;
-    QString m_strLink;
-    bool m_fLinkEnabled;
+    /** Holds the title icon. */
+    QIcon    m_titleIcon;
+    /** Holds the warning icon. */
+    QIcon    m_warningIcon;
+    /** Holds the title text. */
+    QString  m_strTitle;
+    /** Holds the link icon. */
+    QString  m_strLink;
+
+    /** Holds whether the link is enabled. */
+    bool m_fLinkEnabled : 1;
+    /** Holds whether box is opened. */
+    bool m_fOpened      : 1;
+    /** Holds whether header is hovered. */
+    bool m_fHovered     : 1;
+
+    /** Holds the content widget. */
     QWidget *m_pContentWidget;
-    bool m_fOpen;
+
+    /** Holds the label painter path. */
     QPainterPath *m_pLabelPath;
+
+    /** Holds the arrow width. */
     const int m_iArrowWidth;
+    /** Holds the arrow painter-path. */
     QPainterPath m_arrowPath;
-    bool m_fHeaderHover;
-
-    /* Friend class: */
+
+    /** Allow popup-box group to access private API. */
     friend class UIPopupBoxGroup;
 };
 
-/* QObject reimplementation,
- * provides a container to organize groups of popup-boxes: */
+
+/** QObject extension,
+  * provides a container to organize groups of popup-boxes. */
 class UIPopupBoxGroup : public QObject
 {
@@ -127,22 +180,24 @@
 public:
 
-    /* Constructor/destructor: */
+    /** Construct popup-box passing @a pParent to the base-class. */
     UIPopupBoxGroup(QObject *pParent);
-    ~UIPopupBoxGroup();
-
-    /* Add popup-box: */
+    /** Destruct popup-box. */
+    virtual ~UIPopupBoxGroup() /* override */;
+
+    /** Adds @a pPopupBox into group. */
     void addPopupBox(UIPopupBox *pPopupBox);
 
 private slots:
 
-    /* Hover-change handler: */
+    /** Handles group hovering. */
     void sltHoverChanged();
 
 private:
 
-    /* Variables: */
+    /** Holds the list of popup-boxes. */
     QList<UIPopupBox*> m_list;
 };
 
-#endif /* !__UIPopupBoxStuff_h__ */
-
+
+#endif /* !___UIPopupBoxStuff_h___ */
+
