Index: /trunk/src/VBox/Frontends/VirtualBox/src/VBoxLicenseViewer.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/VBoxLicenseViewer.cpp	(revision 71551)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/VBoxLicenseViewer.cpp	(revision 71552)
@@ -5,5 +5,5 @@
 
 /*
- * Copyright (C) 2006-2017 Oracle Corporation
+ * Copyright (C) 2006-2018 Oracle Corporation
  *
  * This file is part of VirtualBox Open Source Edition (OSE), as
@@ -20,14 +20,15 @@
 #else  /* !VBOX_WITH_PRECOMPILED_HEADERS */
 
+/* Qt includes: */
+# include <QFile>
+# include <QPushButton>
+# include <QScrollBar>
+# include <QTextBrowser>
+# include <QVBoxLayout>
+
+/* GUI includes: */
+# include "QIDialogButtonBox.h"
 # include "VBoxLicenseViewer.h"
-# include "QIDialogButtonBox.h"
 # include "UIMessageCenter.h"
-
-/* Qt includes */
-# include <QTextBrowser>
-# include <QPushButton>
-# include <QVBoxLayout>
-# include <QScrollBar>
-# include <QFile>
 
 #endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
@@ -36,34 +37,74 @@
 VBoxLicenseViewer::VBoxLicenseViewer(QWidget *pParent /* = 0 */)
     : QIWithRetranslateUI2<QDialog>(pParent)
-    , mLicenseText (0)
-    , mAgreeButton (0)
-    , mDisagreeButton (0)
+    , m_pLicenseBrowser(0)
+    , m_pButtonAgree(0)
+    , m_pButtonDisagree(0)
 {
-#ifndef VBOX_WS_WIN
-    /* Application icon. On Win32, it's built-in to the executable. */
-    setWindowIcon (QIcon (":/VirtualBox_48px.png"));
+#if !(defined(VBOX_WS_WIN) || defined(VBOX_WS_MAC))
+    /* Assign application icon: */
+    setWindowIcon(QIcon(":/VirtualBox_48px.png"));
 #endif
 
-    mLicenseText = new QTextBrowser (this);
-    mAgreeButton = new QPushButton (this);
-    mDisagreeButton = new QPushButton (this);
-    QDialogButtonBox *dbb = new QIDialogButtonBox (this);
-    dbb->addButton (mAgreeButton, QDialogButtonBox::AcceptRole);
-    dbb->addButton (mDisagreeButton, QDialogButtonBox::RejectRole);
+    /* Create main layout: */
+    QVBoxLayout *pMainLayout = new QVBoxLayout(this);
+    if (pMainLayout)
+    {
+        /* Create license browser: */
+        m_pLicenseBrowser = new QTextBrowser(this);
+        if (m_pLicenseBrowser)
+        {
+            /* Configure license browser: */
+            m_pLicenseBrowser->verticalScrollBar()->installEventFilter(this);
+            connect(m_pLicenseBrowser->verticalScrollBar(), &QScrollBar::valueChanged,
+                    this, &VBoxLicenseViewer::sltHandleScrollBarMoved);
 
-    connect (mLicenseText->verticalScrollBar(), SIGNAL (valueChanged (int)),
-             SLOT (onScrollBarMoving (int)));
-    connect (mAgreeButton, SIGNAL (clicked()), SLOT (accept()));
-    connect (mDisagreeButton, SIGNAL (clicked()), SLOT (reject()));
+            /* Add into layout: */
+            pMainLayout->addWidget(m_pLicenseBrowser);
+        }
 
-    QVBoxLayout *mainLayout = new QVBoxLayout (this);
-    mainLayout->addWidget (mLicenseText);
-    mainLayout->addWidget (dbb);
+        /* Create agree button: */
+        /** todo rework buttons to be a part of button-box itself */
+        QDialogButtonBox *pDialogButtonBox = new QIDialogButtonBox;
+        if (pDialogButtonBox)
+        {
+            /* Create agree button: */
+            m_pButtonAgree = new QPushButton;
+            if (m_pButtonAgree)
+            {
+                /* Configure button: */
+                connect(m_pButtonAgree, &QPushButton::clicked, this, &QDialog::accept);
 
-    mLicenseText->verticalScrollBar()->installEventFilter (this);
+                /* Add into button-box: */
+                pDialogButtonBox->addButton(m_pButtonAgree, QDialogButtonBox::AcceptRole);
+            }
 
-    resize (600, 450);
+            /* Create agree button: */
+            m_pButtonDisagree = new QPushButton;
+            if (m_pButtonDisagree)
+            {
+                /* Configure button: */
+                connect(m_pButtonDisagree, &QPushButton::clicked, this, &QDialog::reject);
 
+                /* Add into button-box: */
+                pDialogButtonBox->addButton(m_pButtonDisagree, QDialogButtonBox::RejectRole);
+            }
+        }
+
+        /* Add into layout: */
+        pMainLayout->addWidget(pDialogButtonBox);
+    }
+
+    /* Configure self: */
+    resize(600, 450);
+
+    /* Apply language settings: */
     retranslateUi();
+}
+
+int VBoxLicenseViewer::showLicenseFromString(const QString &strLicenseText)
+{
+    /* Set license text: */
+    m_pLicenseBrowser->setText(strLicenseText);
+    return exec();
 }
 
@@ -73,7 +114,5 @@
     QFile file(strLicenseFileName);
     if (file.open(QIODevice::ReadOnly))
-    {
         return showLicenseFromString(file.readAll());
-    }
     else
     {
@@ -83,58 +122,59 @@
 }
 
-int VBoxLicenseViewer::showLicenseFromString(const QString &strLicenseText)
+bool VBoxLicenseViewer::eventFilter(QObject *pObject, QEvent *pEvent)
 {
-    /* Set license text: */
-    mLicenseText->setText(strLicenseText);
-    return exec();
+    /* Handle known event types: */
+    switch (pEvent->type())
+    {
+        case QEvent::Hide:
+            if (pObject == m_pLicenseBrowser->verticalScrollBar())
+                /* Doesn't work on wm's like ion3 where the window starts maximized: isActiveWindow() */
+                sltUnlockButtons();
+        default:
+            break;
+    }
+
+    /* Call to base-class: */
+    return QDialog::eventFilter(pObject, pEvent);
+}
+
+void VBoxLicenseViewer::showEvent(QShowEvent *pEvent)
+{
+    /* Call to base-class: */
+    QDialog::showEvent(pEvent);
+
+    /* Enable/disable buttons accordingly: */
+    bool fScrollBarHidden =    !m_pLicenseBrowser->verticalScrollBar()->isVisible()
+                            && !(windowState() & Qt::WindowMinimized);
+    m_pButtonAgree->setEnabled(fScrollBarHidden);
+    m_pButtonDisagree->setEnabled(fScrollBarHidden);
 }
 
 void VBoxLicenseViewer::retranslateUi()
 {
-    setWindowTitle (tr ("VirtualBox License"));
+    /* Translate dialog title: */
+    setWindowTitle(tr("VirtualBox License"));
 
-    mAgreeButton->setText (tr ("I &Agree"));
-    mDisagreeButton->setText (tr ("I &Disagree"));
+    /* Translate buttons: */
+    m_pButtonAgree->setText(tr("I &Agree"));
+    m_pButtonDisagree->setText(tr("I &Disagree"));
 }
 
 int VBoxLicenseViewer::exec()
 {
+    /* Nothing wrong with that, just hiding slot: */
     return QDialog::exec();
 }
 
-void VBoxLicenseViewer::onScrollBarMoving (int aValue)
+void VBoxLicenseViewer::sltHandleScrollBarMoved(int iValue)
 {
-    if (aValue == mLicenseText->verticalScrollBar()->maximum())
-        unlockButtons();
+    if (iValue == m_pLicenseBrowser->verticalScrollBar()->maximum())
+        sltUnlockButtons();
 }
 
-void VBoxLicenseViewer::unlockButtons()
+void VBoxLicenseViewer::sltUnlockButtons()
 {
-    mAgreeButton->setEnabled (true);
-    mDisagreeButton->setEnabled (true);
+    m_pButtonAgree->setEnabled(true);
+    m_pButtonDisagree->setEnabled(true);
 }
 
-void VBoxLicenseViewer::showEvent (QShowEvent *aEvent)
-{
-    QDialog::showEvent (aEvent);
-    bool isScrollBarHidden = !mLicenseText->verticalScrollBar()->isVisible()
-        && !(windowState() & Qt::WindowMinimized);
-    mAgreeButton->setEnabled (isScrollBarHidden);
-    mDisagreeButton->setEnabled (isScrollBarHidden);
-}
-
-bool VBoxLicenseViewer::eventFilter (QObject *aObject, QEvent *aEvent)
-{
-    switch (aEvent->type())
-    {
-        case QEvent::Hide:
-            if (aObject == mLicenseText->verticalScrollBar())
-                /* Doesn't work on wm's like ion3 where the window starts
-                 * maximized: isActiveWindow() */
-                unlockButtons();
-        default:
-            break;
-    }
-    return QDialog::eventFilter (aObject, aEvent);
-}
-
Index: /trunk/src/VBox/Frontends/VirtualBox/src/VBoxLicenseViewer.h
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/VBoxLicenseViewer.h	(revision 71551)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/VBoxLicenseViewer.h	(revision 71552)
@@ -5,5 +5,5 @@
 
 /*
- * Copyright (C) 2006-2017 Oracle Corporation
+ * Copyright (C) 2006-2018 Oracle Corporation
  *
  * This file is part of VirtualBox Open Source Edition (OSE), as
@@ -16,18 +16,18 @@
  */
 
-#ifndef __VBoxLicenseViewer__
-#define __VBoxLicenseViewer__
+#ifndef ___VBoxLicenseViewer___
+#define ___VBoxLicenseViewer___
 
+/* Qt includes: */
+#include <QDialog>
+
+/* GUI includes: */
 #include "QIWithRetranslateUI.h"
 
-/* Qt includes */
-#include <QDialog>
-
+/* Forward declarations: */
 class QTextBrowser;
 class QPushButton;
 
-/**
- *  This class is used to show a user license under linux.
- */
+/** QDialog subclass used to show a user license under linux. */
 class VBoxLicenseViewer : public QIWithRetranslateUI2<QDialog>
 {
@@ -36,33 +36,45 @@
 public:
 
+    /** Constructs license viewer passing @a pParent to the base-class. */
     VBoxLicenseViewer(QWidget *pParent = 0);
 
+    /** Shows license from passed @a strLicenseText. */
+    int showLicenseFromString(const QString &strLicenseText);
+    /** Shows license from file with passed @a strLicenseFileName. */
     int showLicenseFromFile(const QString &strLicenseFileName);
-    int showLicenseFromString(const QString &strLicenseText);
 
 protected:
 
-    void retranslateUi();
+    /** Preprocesses Qt @a pEvent for passed @a pObject. */
+    virtual bool eventFilter(QObject *pObject, QEvent *pEvent) /* override */;
+
+    /** Handles Qt show @a pEvent. */
+    virtual void showEvent(QShowEvent *pEvent) /* override */;
+
+    /** Handles translation event. */
+    virtual void retranslateUi() /* override */;
 
 private slots:
 
+    /** Executes the dialog. */
     int exec();
 
-    void onScrollBarMoving (int aValue);
+    /** Handles scroll-bar moving by a certain @a iValue. */
+    void sltHandleScrollBarMoved(int iValue);
 
-    void unlockButtons();
+    /** Uplocks buttons. */
+    void sltUnlockButtons();
 
 private:
 
-    void showEvent (QShowEvent *aEvent);
+    /** Holds the licence text browser instance. */
+    QTextBrowser *m_pLicenseBrowser;
 
-    bool eventFilter (QObject *aObject, QEvent *aEvent);
-
-    /* Private member vars */
-    QTextBrowser *mLicenseText;
-    QPushButton  *mAgreeButton;
-    QPushButton  *mDisagreeButton;
+    /** Holds the licence agree button instance. */
+    QPushButton *m_pButtonAgree;
+    /** Holds the licence disagree button instance. */
+    QPushButton *m_pButtonDisagree;
 };
 
-#endif /* __VBoxLicenseViewer__ */
+#endif /* !___VBoxLicenseViewer___ */
 
