Index: trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk	(revision 72158)
+++ trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk	(revision 72166)
@@ -576,7 +576,4 @@
  endif
 endif
-
-VirtualBox_QT_MOCHDRS.darwin += \
-	src/platform/darwin/UIWindowMenuManager.h
 
 ifndef VBOX_GUI_WITH_SHARED_LIBRARY
@@ -723,5 +720,6 @@
 
  VirtualBox_QT_MOCHDRS.darwin += \
-	src/platform/darwin/UICocoaSpecialControls.h
+	src/platform/darwin/UICocoaSpecialControls.h \
+	src/platform/darwin/UIWindowMenuManager.h
 endif
 
@@ -873,5 +871,6 @@
 
 VBoxGlobal_QT_MOCHDRS.darwin += \
-	src/platform/darwin/UICocoaSpecialControls.h
+	src/platform/darwin/UICocoaSpecialControls.h \
+	src/platform/darwin/UIWindowMenuManager.h
 
 
@@ -896,7 +895,4 @@
 	src/widgets/UITabBar.cpp \
 	src/wizards/importappliance/UIWizardImportApp.cpp
-
-VirtualBox_QT_MOCSRCS.darwin += \
-	src/platform/darwin/UIWindowMenuManager.cpp
 
 ifndef VBOX_GUI_WITH_SHARED_LIBRARY
@@ -928,4 +924,18 @@
 	src/widgets/UIStatusBarEditorWindow.cpp
 
+ ifdef VBOX_GUI_WITH_NETWORK_MANAGER
+  VirtualBox_QT_MOCSRCS += \
+	src/net/UINetworkReply.cpp \
+	src/net/UIUpdateManager.cpp
+ endif
+
+ ifdef VBOX_WITH_XPCOM
+  VirtualBox_QT_MOCSRCS += \
+	src/globals/COMDefs.cpp
+ endif
+
+ VirtualBox_QT_MOCSRCS.darwin += \
+	src/platform/darwin/UIWindowMenuManager.cpp
+
  VirtualBox_QT_MOCSRCS.linux += \
 	src/globals/UIDesktopWidgetWatchdog.cpp
@@ -934,15 +944,4 @@
  VirtualBox_QT_MOCSRCS.freebsd += \
 	src/globals/UIDesktopWidgetWatchdog.cpp
-
- ifdef VBOX_GUI_WITH_NETWORK_MANAGER
-  VirtualBox_QT_MOCSRCS += \
-	src/net/UINetworkReply.cpp \
-	src/net/UIUpdateManager.cpp
- endif
-
- ifdef VBOX_WITH_XPCOM
-  VirtualBox_QT_MOCSRCS += \
-	src/globals/COMDefs.cpp
- endif
 endif
 
@@ -979,4 +978,17 @@
 	src/widgets/UIStatusBarEditorWindow.cpp
 
+ifdef VBOX_GUI_WITH_NETWORK_MANAGER
+ VBoxGlobal_QT_MOCSRCS += \
+	src/net/UINetworkReply.cpp \
+	src/net/UIUpdateManager.cpp
+endif
+
+ifdef VBOX_WITH_XPCOM
+ VBoxGlobal_QT_MOCSRCS += \
+	src/globals/COMDefs.cpp
+
+VBoxGlobal_QT_MOCSRCS.darwin += \
+	src/platform/darwin/UIWindowMenuManager.cpp
+
 VBoxGlobal_QT_MOCSRCS.linux += \
 	src/globals/UIDesktopWidgetWatchdog.cpp
@@ -985,14 +997,4 @@
 VBoxGlobal_QT_MOCSRCS.freebsd += \
 	src/globals/UIDesktopWidgetWatchdog.cpp
-
-ifdef VBOX_GUI_WITH_NETWORK_MANAGER
- VBoxGlobal_QT_MOCSRCS += \
-	src/net/UINetworkReply.cpp \
-	src/net/UIUpdateManager.cpp
-endif
-
-ifdef VBOX_WITH_XPCOM
- VBoxGlobal_QT_MOCSRCS += \
-	src/globals/COMDefs.cpp
 endif
 
@@ -1127,5 +1129,6 @@
 	src/platform/darwin/UIAbstractDockIconPreview.cpp \
 	src/platform/darwin/UICocoaDockIconPreview.mm \
-	src/platform/darwin/UIWindowMenuManager.cpp \
+	src/platform/darwin/UIDesktopServices_darwin.cpp \
+	src/platform/darwin/UIDesktopServices_darwin_cocoa.mm
 
 if1of ($(KBUILD_TARGET), freebsd linux netbsd openbsd solaris) # X11
@@ -1137,8 +1140,4 @@
 	src/platform/win/VirtualBox.rc \
 	src/platform/win/UIDesktopServices_win.cpp
-
-VirtualBox_SOURCES.darwin += \
-	src/platform/darwin/UIDesktopServices_darwin.cpp \
-	src/platform/darwin/UIDesktopServices_darwin_cocoa.mm
 
 ifdef VBOX_WITH_ICHAT_THEATER
@@ -1335,4 +1334,5 @@
 	src/platform/darwin/UICocoaApplication.mm \
 	src/platform/darwin/UICocoaSpecialControls.mm \
+	src/platform/darwin/UIWindowMenuManager.cpp \
 	src/platform/darwin/VBoxUtils-darwin-cocoa.mm \
 	src/platform/darwin/VBoxUtils-darwin.cpp
@@ -1511,4 +1511,5 @@
 	src/platform/darwin/UICocoaApplication.mm \
 	src/platform/darwin/UICocoaSpecialControls.mm \
+	src/platform/darwin/UIWindowMenuManager.cpp \
 	src/platform/darwin/VBoxUtils-darwin-cocoa.mm \
 	src/platform/darwin/VBoxUtils-darwin.cpp
Index: trunk/src/VBox/Frontends/VirtualBox/src/platform/darwin/UIWindowMenuManager.cpp
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/src/platform/darwin/UIWindowMenuManager.cpp	(revision 72158)
+++ trunk/src/VBox/Frontends/VirtualBox/src/platform/darwin/UIWindowMenuManager.cpp	(revision 72166)
@@ -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
@@ -32,4 +32,5 @@
 #endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
 
+
 /** QObject extension
   * used as Mac OS X 'Window' menu helper. */
@@ -41,150 +42,177 @@
 
     /** Constructs menu-helper on the basis of passed @a windows. */
-    UIMenuHelper(const QList<QWidget*> &windows)
-    {
-        /* Prepare 'Window' menu: */
-        m_pWindowMenu = new QMenu;
-        /* Prepare action group: */
-        m_pGroup = new QActionGroup(this);
-        m_pGroup->setExclusive(true);
-        /* Prepare 'Minimize' action: */
-        m_pMinimizeAction = new QAction(this);
-        m_pWindowMenu->addAction(m_pMinimizeAction);
-        connect(m_pMinimizeAction, SIGNAL(triggered(bool)),
-                this, SLOT(sltMinimizeActiveWindow()));
-        /* Make sure all already available windows are
-         * properly registered within this menu: */
-        for (int i = 0; i < windows.size(); ++i)
-            addWindow(windows.at(i));
-        /* Translate finally: */
-        retranslateUi();
-    }
-
+    UIMenuHelper(const QList<QWidget*> &windows);
     /** Destructs menu-helper. */
-    ~UIMenuHelper()
-    {
-        /* Cleanup 'Window' menu: */
-        delete m_pWindowMenu;
-        /* Cleanup actions: */
-        qDeleteAll(m_windows);
-    }
+    virtual ~UIMenuHelper() /* override */;
 
     /** Returns 'Window' menu. */
-    QMenu* menu() const { return m_pWindowMenu; }
+    QMenu *menu() const { return m_pWindowMenu; }
 
     /** Adds @a pWindow into 'Window' menu. */
-    QAction* addWindow(QWidget *pWindow)
-    {
-        QAction *pAction = 0;
-        if (   pWindow
-            && !m_windows.contains(pWindow))
+    QAction *addWindow(QWidget *pWindow);
+    /** Removes @a pWindow from 'Window' menu. */
+    void removeWindow(QWidget *pWindow);
+
+    /** Handles translation event. */
+    void retranslateUi();
+
+    /** Updates toggle action states according to passed @a pActiveWindow. */
+    void updateStatus(QWidget *pActiveWindow);
+
+private slots:
+
+    /** Handles request to minimize active-window. */
+    void sltMinimizeActiveWindow();
+
+    /** Handles request to raise sender window. */
+    void sltRaiseSender();
+
+private:
+
+    /** Holds the 'Window' menu instance. */
+    QMenu                     *m_pWindowMenu;
+    /** Holds the action group instance. */
+    QActionGroup              *m_pGroup;
+    /** Holds the 'Minimize' action instance. */
+    QAction                   *m_pMinimizeAction;
+    /** Holds the hash of the registered menu-helper instances. */
+    QHash<QWidget*, QAction*>  m_windows;
+};
+
+
+/*********************************************************************************************************************************
+*   Class UIMenuHelper implementation.                                                                                           *
+*********************************************************************************************************************************/
+
+UIMenuHelper::UIMenuHelper(const QList<QWidget*> &windows)
+{
+    /* Prepare 'Window' menu: */
+    m_pWindowMenu = new QMenu;
+
+    /* Prepare action group: */
+    m_pGroup = new QActionGroup(this);
+    m_pGroup->setExclusive(true);
+
+    /* Prepare 'Minimize' action: */
+    m_pMinimizeAction = new QAction(this);
+    m_pWindowMenu->addAction(m_pMinimizeAction);
+    connect(m_pMinimizeAction, SIGNAL(triggered(bool)),
+            this, SLOT(sltMinimizeActiveWindow()));
+
+    /* Make sure all already available windows are
+     * properly registered within this menu: */
+    for (int i = 0; i < windows.size(); ++i)
+        addWindow(windows.at(i));
+
+    /* Apply language settings: */
+    retranslateUi();
+}
+
+UIMenuHelper::~UIMenuHelper()
+{
+    /* Cleanup 'Window' menu: */
+    delete m_pWindowMenu;
+
+    /* Cleanup actions: */
+    qDeleteAll(m_windows);
+}
+
+QAction *UIMenuHelper::addWindow(QWidget *pWindow)
+{
+    QAction *pAction = 0;
+    if (   pWindow
+        && !m_windows.contains(pWindow))
+    {
+        if (m_windows.size() < 2)
+            m_pWindowMenu->addSeparator();
+
+        /* The main window always first: */
+        pAction = new QAction(this);
+        pAction->setText(pWindow->windowTitle());
+        pAction->setMenuRole(QAction::NoRole);
+        pAction->setData(QVariant::fromValue(pWindow));
+        pAction->setCheckable(true);
+
+        /* The first registered one is always
+         * considered as the main window: */
+        if (m_windows.size() == 0)
+            pAction->setShortcut(QKeySequence("Ctrl+0"));
+        m_pGroup->addAction(pAction);
+        connect(pAction, SIGNAL(triggered(bool)),
+                this, SLOT(sltRaiseSender()));
+        m_pWindowMenu->addAction(pAction);
+        m_windows[pWindow] = pAction;
+    }
+    return pAction;
+}
+
+void UIMenuHelper::removeWindow(QWidget *pWindow)
+{
+    if (m_windows.contains(pWindow))
+    {
+        delete m_windows.value(pWindow);
+        m_windows.remove(pWindow);
+    }
+}
+
+void UIMenuHelper::retranslateUi()
+{
+    /* Translate menu: */
+    m_pWindowMenu->setTitle(QApplication::translate("UIActionPool", "&Window"));
+
+    /* Translate menu 'Minimize' action: */
+    m_pMinimizeAction->setText(QApplication::translate("UIActionPool", "&Minimize"));
+    m_pMinimizeAction->setShortcut(QKeySequence("Ctrl+M"));
+
+    /* Translate other menu-actions: */
+    foreach (QAction *pAction, m_windows.values())
+    {
+        /* Get corresponding window from action's data: */
+        QWidget *pWindow = pAction->data().value<QWidget*>();
+        /* Use the window's title as the action's text: */
+        pAction->setText(pWindow->windowTitle());
+    }
+}
+
+void UIMenuHelper::updateStatus(QWidget *pActiveWindow)
+{
+    /* 'Minimize' action is enabled if there is active-window: */
+    m_pMinimizeAction->setEnabled(pActiveWindow != 0);
+
+    /* If there is active-window: */
+    if (pActiveWindow)
+    {
+        /* Toggle corresponding action on: */
+        if (m_windows.contains(pActiveWindow))
+            m_windows.value(pActiveWindow)->setChecked(true);
+    }
+    /* If there is no active-window: */
+    else
+    {
+        /* Make sure corresponding action toggled off: */
+        if (QAction *pChecked = m_pGroup->checkedAction())
+            pChecked->setChecked(false);
+    }
+}
+
+void UIMenuHelper::sltMinimizeActiveWindow()
+{
+    if (QWidget *pActiveWindow = qApp->activeWindow())
+        pActiveWindow->showMinimized();
+}
+
+void UIMenuHelper::sltRaiseSender()
+{
+    AssertReturnVoid(sender());
+    if (QAction *pAction = qobject_cast<QAction*>(sender()))
+    {
+        if (QWidget *pWidget = pAction->data().value<QWidget*>())
         {
-            if (m_windows.size() < 2)
-                m_pWindowMenu->addSeparator();
-            /* The main window always first: */
-            pAction = new QAction(this);
-            pAction->setText(pWindow->windowTitle());
-            pAction->setMenuRole(QAction::NoRole);
-            pAction->setData(QVariant::fromValue(pWindow));
-            pAction->setCheckable(true);
-            /* The first registered one is always
-             * considered as the main window: */
-            if (m_windows.size() == 0)
-                pAction->setShortcut(QKeySequence("Ctrl+0"));
-            m_pGroup->addAction(pAction);
-            connect(pAction, SIGNAL(triggered(bool)),
-                    this, SLOT(sltRaiseSender()));
-            m_pWindowMenu->addAction(pAction);
-            m_windows[pWindow] = pAction;
+            pWidget->show();
+            pWidget->raise();
+            pWidget->activateWindow();
         }
-        return pAction;
-    }
-
-    /** Removes @a pWindow from 'Window' menu. */
-    void removeWindow(QWidget *pWindow)
-    {
-        if (m_windows.contains(pWindow))
-        {
-            delete m_windows.value(pWindow);
-            m_windows.remove(pWindow);
-        }
-    }
-
-    /** Handles translation event. */
-    void retranslateUi()
-    {
-        /* Translate menu: */
-        m_pWindowMenu->setTitle(QApplication::translate("UIActionPool", "&Window"));
-
-        /* Translate menu 'Minimize' action: */
-        m_pMinimizeAction->setText(QApplication::translate("UIActionPool", "&Minimize"));
-        m_pMinimizeAction->setShortcut(QKeySequence("Ctrl+M"));
-
-        /* Translate other menu-actions: */
-        foreach (QAction *pAction, m_windows.values())
-        {
-            /* Get corresponding window from action's data: */
-            QWidget *pWindow = pAction->data().value<QWidget*>();
-            /* Use the window's title as the action's text: */
-            pAction->setText(pWindow->windowTitle());
-        }
-    }
-
-    /** Updates toggle action states according to passed @a pActiveWindow. */
-    void updateStatus(QWidget *pActiveWindow)
-    {
-        /* 'Minimize' action is enabled if there is active-window: */
-        m_pMinimizeAction->setEnabled(pActiveWindow != 0);
-        /* If there is active-window: */
-        if (pActiveWindow)
-        {
-            /* Toggle corresponding action on: */
-            if (m_windows.contains(pActiveWindow))
-                m_windows.value(pActiveWindow)->setChecked(true);
-        }
-        /* If there is no active-window: */
-        else
-        {
-            /* Make sure corresponding action toggled off: */
-            if (QAction *pChecked = m_pGroup->checkedAction())
-                pChecked->setChecked(false);
-        }
-    }
-
-private slots:
-
-    /** Handles request to minimize active-window. */
-    void sltMinimizeActiveWindow()
-    {
-        if (QWidget *pActiveWindow = qApp->activeWindow())
-            pActiveWindow->showMinimized();
-    }
-
-    /** Handles request to raise sender window. */
-    void sltRaiseSender()
-    {
-        AssertReturnVoid(sender());
-        if (QAction *pAction = qobject_cast<QAction*>(sender()))
-        {
-            if (QWidget *pWidget = pAction->data().value<QWidget*>())
-            {
-                pWidget->show();
-                pWidget->raise();
-                pWidget->activateWindow();
-            }
-        }
-    }
-
-private:
-
-    /** Holds the 'Window' menu instance. */
-    QMenu *m_pWindowMenu;
-    /** Holds the action group instance. */
-    QActionGroup *m_pGroup;
-    /** Holds the 'Minimize' action instance. */
-    QAction *m_pMinimizeAction;
-    /** Holds the hash of the registered menu-helper instances. */
-    QHash<QWidget*, QAction*> m_windows;
-};
+    }
+}
 
 
@@ -194,5 +222,5 @@
 
 /* static */
-UIWindowMenuManager* UIWindowMenuManager::m_spInstance = 0;
+UIWindowMenuManager* UIWindowMenuManager::s_pInstance = 0;
 
 /* static */
@@ -200,5 +228,5 @@
 {
     /* Make sure 'Window' menu Manager is not created: */
-    AssertReturnVoid(!m_spInstance);
+    AssertReturnVoid(!s_pInstance);
 
     /* Create 'Window' menu Manager: */
@@ -210,26 +238,8 @@
 {
     /* Make sure 'Window' menu Manager is created: */
-    AssertPtrReturnVoid(m_spInstance);
+    AssertPtrReturnVoid(s_pInstance);
 
     /* Delete 'Window' menu Manager: */
-    delete m_spInstance;
-}
-
-UIWindowMenuManager::UIWindowMenuManager()
-{
-    /* Assign instance: */
-    m_spInstance = this;
-
-    /* Install global event-filter: */
-    qApp->installEventFilter(this);
-}
-
-UIWindowMenuManager::~UIWindowMenuManager()
-{
-    /* Cleanup all helpers: */
-    qDeleteAll(m_helpers);
-
-    /* Unassign instance: */
-    m_spInstance = 0;
+    delete s_pInstance;
 }
 
@@ -282,4 +292,22 @@
 }
 
+UIWindowMenuManager::UIWindowMenuManager()
+{
+    /* Assign instance: */
+    s_pInstance = this;
+
+    /* Install global event-filter: */
+    qApp->installEventFilter(this);
+}
+
+UIWindowMenuManager::~UIWindowMenuManager()
+{
+    /* Cleanup all helpers: */
+    qDeleteAll(m_helpers);
+
+    /* Unassign instance: */
+    s_pInstance = 0;
+}
+
 bool UIWindowMenuManager::eventFilter(QObject *pObject, QEvent *pEvent)
 {
@@ -288,9 +316,10 @@
 
 #ifdef VBOX_OSE /// @todo Do we still need it?
-    /* Stupid Qt: Qt doesn't check if a window is minimized when a command is
-     * executed. This leads to strange behaviour. The minimized window is
-     * partly restored, but not usable. As a workaround we raise the parent
-     * window before we let execute the command.
-     * Note: fixed in our local Qt build since 4.7.0. */
+    // WORKAROUND:
+    // Stupid Qt: Qt doesn't check if a window is minimized when a command is
+    // executed. This leads to strange behaviour. The minimized window is
+    // partly restored, but not usable. As a workaround we raise the parent
+    // window before we let execute the command.
+    // Note: fixed in our local Qt build since 4.7.0.
     if (pObject && type == QEvent::Show)
     {
@@ -335,4 +364,4 @@
 }
 
+
 #include "UIWindowMenuManager.moc"
-
Index: trunk/src/VBox/Frontends/VirtualBox/src/platform/darwin/UIWindowMenuManager.h
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/src/platform/darwin/UIWindowMenuManager.h	(revision 72158)
+++ trunk/src/VBox/Frontends/VirtualBox/src/platform/darwin/UIWindowMenuManager.h	(revision 72166)
@@ -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
@@ -20,6 +20,6 @@
 
 /* Qt includes: */
+#include <QHash>
 #include <QObject>
-#include <QHash>
 
 /* GUI includes: */
@@ -27,10 +27,10 @@
 
 /* Forward declarations: */
+class QMenu;
 class UIMenuHelper;
-class QMenu;
 
 /** Singleton QObject extension
   * used as Mac OS X 'Window' menu Manager. */
-class UIWindowMenuManager : public QIWithRetranslateUI3<QObject>
+class SHARED_LIBRARY_STUFF UIWindowMenuManager : public QIWithRetranslateUI3<QObject>
 {
     Q_OBJECT;
@@ -38,13 +38,13 @@
 public:
 
-    /** Static constructor. */
+    /** Creates instance. */
     static void create();
-    /** Static destructor. */
+    /** Destroyes instance. */
     static void destroy();
-    /** Static instance provider. */
-    static UIWindowMenuManager* instance() { return m_spInstance; }
+    /** Returns current instance. */
+    static UIWindowMenuManager *instance() { return s_pInstance; }
 
     /** Creates 'Window' menu for passed @a pWindow. */
-    QMenu* createMenu(QWidget *pWindow);
+    QMenu *createMenu(QWidget *pWindow);
     /** Destroys 'Window' menu for passed @a pWindow. */
     void destroyMenu(QWidget *pWindow);
@@ -56,5 +56,5 @@
 
     /** Handles translation event. */
-    virtual void retranslateUi();
+    virtual void retranslateUi() /* override */;
 
 protected:
@@ -66,20 +66,20 @@
 
     /** Preprocesses any Qt @a pEvent for passed @a pObject. */
-    virtual bool eventFilter(QObject *pObject, QEvent *pEvent);
+    virtual bool eventFilter(QObject *pObject, QEvent *pEvent) /* override */;
 
 private:
 
     /** Holds the static instance. */
-    static UIWindowMenuManager *m_spInstance;
+    static UIWindowMenuManager *s_pInstance;
 
     /** Holds the list of the registered window references. */
-    QList<QWidget*> m_windows;
+    QList<QWidget*>  m_windows;
 
     /** Holds the hash of the registered menu-helper instances. */
-    QHash<QWidget*, UIMenuHelper*> m_helpers;
+    QHash<QWidget*, UIMenuHelper*>  m_helpers;
 };
 
+/** Singleton 'Window' menu Manager 'official' name. */
 #define gpWindowMenuManager UIWindowMenuManager::instance()
 
 #endif /* !___UIWindowMenuManager_h___ */
-
