Index: trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp	(revision 72411)
+++ trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp	(revision 72413)
@@ -171,5 +171,4 @@
 #endif /* VBOX_WS_X11 */
 
-
 //#define VBOX_WITH_FULL_DETAILS_REPORT /* hidden for now */
 
@@ -178,6 +177,53 @@
 
 
-// VBoxGlobal
-////////////////////////////////////////////////////////////////////////////////
+class VBoxTranslator : public QTranslator
+{
+public:
+
+    VBoxTranslator (QObject *aParent = 0)
+        : QTranslator (aParent) {}
+
+    bool loadFile (const QString &aFileName)
+    {
+        QFile file (aFileName);
+        if (!file.open (QIODevice::ReadOnly))
+            return false;
+        mData = file.readAll();
+        return load ((uchar*) mData.data(), mData.size());
+    }
+
+private:
+
+    QByteArray mData;
+};
+
+static VBoxTranslator *sTranslator = 0;
+
+
+struct PortConfig
+{
+    const char *name;
+    const ulong IRQ;
+    const ulong IOBase;
+};
+
+static const PortConfig kComKnownPorts[] =
+{
+    { "COM1", 4, 0x3F8 },
+    { "COM2", 3, 0x2F8 },
+    { "COM3", 4, 0x3E8 },
+    { "COM4", 3, 0x2E8 },
+    /* must not contain an element with IRQ=0 and IOBase=0 used to cause
+     * toCOMPortName() to return the "User-defined" string for these values. */
+};
+
+static const PortConfig kLptKnownPorts[] =
+{
+    { "LPT1", 7, 0x378 },
+    { "LPT2", 5, 0x278 },
+    { "LPT1", 2, 0x3BC },
+    /* must not contain an element with IRQ=0 and IOBase=0 used to cause
+     * toLPTPortName() to return the "User-defined" string for these values. */
+};
 
 
@@ -242,14 +288,12 @@
 #ifdef VBOX_WS_MAC
     , m_osRelease(MacOSXRelease_Old)
-#endif /* VBOX_WS_MAC */
-    , m_fWrappersValid(false)
-    , m_fVBoxSVCAvailable(true)
-    , m_fSeparateProcess(false)
-    , m_pMediumEnumerator(0)
-    , m_fEPInstallationRequested(false)
+#endif
 #ifdef VBOX_WS_X11
     , m_fCompositingManagerRunning(false)
     , m_enmWindowManagerType(X11WMType_Unknown)
-#endif /* VBOX_WS_X11 */
+#endif
+    , mVerString("1.0")
+    , m_fSeparateProcess(false)
+    , mShowStartVMErrors(true)
 #if defined(DEBUG_bird)
     , mAgressiveCaching(false)
@@ -264,9 +308,12 @@
     , mExecuteAllInIem(false)
     , mWarpPct(100)
-    , mVerString("1.0")
+    , mSettingsPwSet(false)
+    , m_fWrappersValid(false)
+    , m_fVBoxSVCAvailable(true)
     , m3DAvailable(-1)
-    , mSettingsPwSet(false)
+    , m_pThreadPool(0)
     , m_pIconPool(0)
-    , m_pThreadPool(0)
+    , m_pMediumEnumerator(0)
+    , m_fEPInstallationRequested(false)
 {
     /* Assign instance: */
@@ -353,28 +400,101 @@
 #endif /* VBOX_WS_MAC */
 
-/**
- * Inner worker that for lazily querying for 3D support.
- *
- * Rational is that when starting a text mode guest (like DOS) that does not
- * have 3D enabled, don't wast the developer's or user's time on launching the
- * test application when starting the VM or editing it's settings.
- *
- * @returns true / false.
- * @note If we ever end up checking this concurrently on multiple threads, use a
- *       RTONCE construct to serialize the efforts.
- */
-bool VBoxGlobal::is3DAvailableWorker() const
-{
-#ifdef VBOX_WITH_CROGL
-    bool fSupported = VBoxOglIs3DAccelerationSupported();
-#else
-    bool fSupported = false;
-#endif
-    unconst(this)->m3DAvailable = fSupported;
-    return fSupported;
-}
-
+bool VBoxGlobal::brandingIsActive (bool aForce /* = false*/)
+{
+    if (aForce)
+        return true;
+
+    if (mBrandingConfig.isEmpty())
+    {
+        mBrandingConfig = QDir(QApplication::applicationDirPath()).absolutePath();
+        mBrandingConfig += "/custom/custom.ini";
+    }
+    return QFile::exists (mBrandingConfig);
+}
+
+/**
+  * Gets a value from the custom .ini file
+  */
+QString VBoxGlobal::brandingGetKey (QString aKey)
+{
+    QSettings s(mBrandingConfig, QSettings::IniFormat);
+    return s.value(QString("%1").arg(aKey)).toString();
+}
+
+bool VBoxGlobal::processArgs()
+{
+    bool fResult = false;
+    QStringList args = qApp->arguments();
+    QList<QUrl> list;
+    for (int i = 1; i < args.size(); ++i)
+    {
+        /* We break out after the first parameter, cause there could be
+           parameters with arguments (e.g. --comment comment). */
+        if (args.at(i).startsWith("-"))
+            break;
+#ifdef VBOX_WS_MAC
+        QString strArg = ::darwinResolveAlias(args.at(i));
+#else /* VBOX_WS_MAC */
+        QString strArg = args.at(i);
+#endif /* !VBOX_WS_MAC */
+        if (   !strArg.isEmpty()
+            && QFile::exists(strArg))
+            list << QUrl::fromLocalFile(strArg);
+    }
+    if (!list.isEmpty())
+    {
+        for (int i = 0; i < list.size(); ++i)
+        {
+            const QString& strFile = list.at(i).toLocalFile();
+            if (VBoxGlobal::hasAllowedExtension(strFile, VBoxFileExts))
+            {
+                CVirtualBox vbox = virtualBox();
+                CMachine machine = vbox.FindMachine(strFile);
+                if (!machine.isNull())
+                {
+                    fResult = true;
+                    launchMachine(machine);
+                    /* Remove from the arg list. */
+                    list.removeAll(strFile);
+                }
+            }
+        }
+    }
+    if (!list.isEmpty())
+    {
+        /* Store the URLs: */
+        m_ArgUrlList = list;
+        /* Ask UIStarter to open them: */
+        emit sigAskToOpenURLs();
+    }
+    return fResult;
+}
+
+#ifdef VBOX_WITH_DEBUGGER_GUI
+
+bool VBoxGlobal::isDebuggerEnabled() const
+{
+    return isDebuggerWorker(&m_fDbgEnabled, GUI_Dbg_Enabled);
+}
+
+bool VBoxGlobal::isDebuggerAutoShowEnabled() const
+{
+    return isDebuggerWorker(&m_fDbgAutoShow, GUI_Dbg_AutoShow);
+}
+
+bool VBoxGlobal::isDebuggerAutoShowCommandLineEnabled() const
+{
+    return isDebuggerWorker(&m_fDbgAutoShowCommandLine, GUI_Dbg_AutoShow);
+}
+
+bool VBoxGlobal::isDebuggerAutoShowStatisticsEnabled() const
+{
+    return isDebuggerWorker(&m_fDbgAutoShowStatistics, GUI_Dbg_AutoShow);
+}
+
+#endif /* VBOX_WITH_DEBUGGER_GUI */
 
 #ifdef VBOX_GUI_WITH_PIDFILE
+
 void VBoxGlobal::createPidfile()
 {
@@ -399,1257 +519,6 @@
         QFile::remove(m_strPidfile);
 }
-#endif
-
-bool VBoxGlobal::brandingIsActive (bool aForce /* = false*/)
-{
-    if (aForce)
-        return true;
-
-    if (mBrandingConfig.isEmpty())
-    {
-        mBrandingConfig = QDir(QApplication::applicationDirPath()).absolutePath();
-        mBrandingConfig += "/custom/custom.ini";
-    }
-    return QFile::exists (mBrandingConfig);
-}
-
-/**
-  * Gets a value from the custom .ini file
-  */
-QString VBoxGlobal::brandingGetKey (QString aKey)
-{
-    QSettings s(mBrandingConfig, QSettings::IniFormat);
-    return s.value(QString("%1").arg(aKey)).toString();
-}
-
-#ifdef VBOX_WS_X11
-QList<QRect> XGetDesktopList()
-{
-    /* Prepare empty resulting list: */
-    QList<QRect> result;
-
-    /* Get current display: */
-    Display* pDisplay = QX11Info::display();
-
-    /* If it's a Xinerama desktop: */
-    if (XineramaIsActive(pDisplay))
-    {
-        /* Reading Xinerama data: */
-        int iScreens = 0;
-        XineramaScreenInfo *pScreensData = XineramaQueryScreens(pDisplay, &iScreens);
-
-        /* Fill resulting list: */
-        for (int i = 0; i < iScreens; ++ i)
-            result << QRect(pScreensData[i].x_org, pScreensData[i].y_org,
-                            pScreensData[i].width, pScreensData[i].height);
-
-        /* Free screens data: */
-        XFree(pScreensData);
-    }
-
-    /* Return resulting list: */
-    return result;
-}
-
-QList<Window> XGetWindowIDList()
-{
-    /* Get current display: */
-    Display *pDisplay = QX11Info::display();
-
-    /* Get virtual desktop window: */
-    Window window = QX11Info::appRootWindow();
-
-    /* Get 'client list' atom: */
-    Atom propNameAtom = XInternAtom(pDisplay, "_NET_CLIENT_LIST", True /* only if exists */);
-
-    /* Prepare empty resulting list: */
-    QList<Window> result;
-
-    /* If atom does not exists return empty list: */
-    if (propNameAtom == None)
-        return result;
-
-    /* Get atom value: */
-    Atom realAtomType = None;
-    int iRealFormat = 0;
-    unsigned long uItemsCount = 0;
-    unsigned long uBytesAfter = 0;
-    unsigned char *pData = 0;
-    int rc = XGetWindowProperty(pDisplay, window, propNameAtom,
-                                0, 0x7fffffff /*LONG_MAX*/, False /* delete */,
-                                XA_WINDOW, &realAtomType, &iRealFormat,
-                                &uItemsCount, &uBytesAfter, &pData);
-
-    /* If get property is failed return empty list: */
-    if (rc != Success)
-        return result;
-
-    /* Fill resulting list with win ids: */
-    Window *pWindowData = reinterpret_cast<Window*>(pData);
-    for (ulong i = 0; i < uItemsCount; ++ i)
-        result << pWindowData[i];
-
-    /* Releasing resources: */
-    XFree(pData);
-
-    /* Return resulting list: */
-    return result;
-}
-
-QList<ulong> XGetStrut(Window window)
-{
-    /* Get current display: */
-    Display *pDisplay = QX11Info::display();
-
-    /* Get 'strut' atom: */
-    Atom propNameAtom = XInternAtom(pDisplay, "_NET_WM_STRUT_PARTIAL", True /* only if exists */);
-
-    /* Prepare empty resulting list: */
-    QList<ulong> result;
-
-    /* If atom does not exists return empty list: */
-    if (propNameAtom == None)
-        return result;
-
-    /* Get atom value: */
-    Atom realAtomType = None;
-    int iRealFormat = 0;
-    ulong uItemsCount = 0;
-    ulong uBytesAfter = 0;
-    unsigned char *pData = 0;
-    int rc = XGetWindowProperty(pDisplay, window, propNameAtom,
-                                0, LONG_MAX, False /* delete */,
-                                XA_CARDINAL, &realAtomType, &iRealFormat,
-                                &uItemsCount, &uBytesAfter, &pData);
-
-    /* If get property is failed return empty list: */
-    if (rc != Success)
-        return result;
-
-    /* Fill resulting list with strut shifts: */
-    ulong *pStrutsData = reinterpret_cast<ulong*>(pData);
-    for (ulong i = 0; i < uItemsCount; ++ i)
-        result << pStrutsData[i];
-
-    /* Releasing resources: */
-    XFree(pData);
-
-    /* Return resulting list: */
-    return result;
-}
-#endif /* ifdef VBOX_WS_X11 */
-
-/**
- *  Returns the list of few guest OS types, queried from
- *  IVirtualBox corresponding to every family id.
- */
-QList<CGuestOSType> VBoxGlobal::vmGuestOSFamilyList() const
-{
-    QList<CGuestOSType> result;
-    for (int i = 0; i < m_guestOSFamilyIDs.size(); ++i)
-        result << m_guestOSTypes[i][0];
-    return result;
-}
-
-/**
- *  Returns the list of all guest OS types, queried from
- *  IVirtualBox corresponding to passed family id.
- */
-QList<CGuestOSType> VBoxGlobal::vmGuestOSTypeList(const QString &aFamilyId) const
-{
-    AssertMsg(m_guestOSFamilyIDs.contains(aFamilyId), ("Family ID incorrect: '%s'.", aFamilyId.toLatin1().constData()));
-    return m_guestOSFamilyIDs.contains(aFamilyId) ?
-           m_guestOSTypes[m_guestOSFamilyIDs.indexOf(aFamilyId)] : QList<CGuestOSType>();
-}
-
-QIcon VBoxGlobal::vmUserIcon(const CMachine &comMachine) const
-{
-    /* Prepare fallback icon: */
-    static QIcon nullIcon;
-
-    /* Make sure general icon-pool initialized: */
-    AssertReturn(m_pIconPool, nullIcon);
-
-    /* Redirect to general icon-pool: */
-    return m_pIconPool->userMachineIcon(comMachine);
-}
-
-QPixmap VBoxGlobal::vmUserPixmap(const CMachine &comMachine, const QSize &size) const
-{
-    /* Prepare fallback pixmap: */
-    static QPixmap nullPixmap;
-
-    /* Make sure general icon-pool initialized: */
-    AssertReturn(m_pIconPool, nullPixmap);
-
-    /* Redirect to general icon-pool: */
-    return m_pIconPool->userMachinePixmap(comMachine, size);
-}
-
-QPixmap VBoxGlobal::vmUserPixmapDefault(const CMachine &comMachine, QSize *pLogicalSize /* = 0 */) const
-{
-    /* Prepare fallback pixmap: */
-    static QPixmap nullPixmap;
-
-    /* Make sure general icon-pool initialized: */
-    AssertReturn(m_pIconPool, nullPixmap);
-
-    /* Redirect to general icon-pool: */
-    return m_pIconPool->userMachinePixmapDefault(comMachine, pLogicalSize);
-}
-
-QIcon VBoxGlobal::vmGuestOSTypeIcon(const QString &strOSTypeID) const
-{
-    /* Prepare fallback icon: */
-    static QIcon nullIcon;
-
-    /* Make sure general icon-pool initialized: */
-    AssertReturn(m_pIconPool, nullIcon);
-
-    /* Redirect to general icon-pool: */
-    return m_pIconPool->guestOSTypeIcon(strOSTypeID);
-}
-
-QPixmap VBoxGlobal::vmGuestOSTypePixmap(const QString &strOSTypeID, const QSize &size) const
-{
-    /* Prepare fallback pixmap: */
-    static QPixmap nullPixmap;
-
-    /* Make sure general icon-pool initialized: */
-    AssertReturn(m_pIconPool, nullPixmap);
-
-    /* Redirect to general icon-pool: */
-    return m_pIconPool->guestOSTypePixmap(strOSTypeID, size);
-}
-
-QPixmap VBoxGlobal::vmGuestOSTypePixmapDefault(const QString &strOSTypeID, QSize *pLogicalSize /* = 0 */) const
-{
-    /* Prepare fallback pixmap: */
-    static QPixmap nullPixmap;
-
-    /* Make sure general icon-pool initialized: */
-    AssertReturn(m_pIconPool, nullPixmap);
-
-    /* Redirect to general icon-pool: */
-    return m_pIconPool->guestOSTypePixmapDefault(strOSTypeID, pLogicalSize);
-}
-
-/**
- *  Returns the guest OS type object corresponding to the given type id of list
- *  containing OS types related to OS family determined by family id attribute.
- *  If the index is invalid a null object is returned.
- */
-CGuestOSType VBoxGlobal::vmGuestOSType(const QString &aTypeId,
-             const QString &aFamilyId /* = QString::null */) const
-{
-    QList <CGuestOSType> list;
-    if (m_guestOSFamilyIDs.contains (aFamilyId))
-    {
-        list = m_guestOSTypes [m_guestOSFamilyIDs.indexOf (aFamilyId)];
-    }
-    else
-    {
-        for (int i = 0; i < m_guestOSFamilyIDs.size(); ++ i)
-            list += m_guestOSTypes [i];
-    }
-    for (int j = 0; j < list.size(); ++ j)
-        if (!list [j].GetId().compare (aTypeId))
-            return list [j];
-    AssertMsgFailed (("Type ID incorrect: '%s'.", aTypeId.toLatin1().constData()));
-    return CGuestOSType();
-}
-
-/**
- *  Returns the description corresponding to the given guest OS type id.
- */
-QString VBoxGlobal::vmGuestOSTypeDescription (const QString &aTypeId) const
-{
-    for (int i = 0; i < m_guestOSFamilyIDs.size(); ++ i)
-    {
-        QList <CGuestOSType> list (m_guestOSTypes [i]);
-        for ( int j = 0; j < list.size(); ++ j)
-            if (!list [j].GetId().compare (aTypeId))
-                return list [j].GetDescription();
-    }
-    return QString::null;
-}
-
-struct PortConfig
-{
-    const char *name;
-    const ulong IRQ;
-    const ulong IOBase;
-};
-
-static const PortConfig kComKnownPorts[] =
-{
-    { "COM1", 4, 0x3F8 },
-    { "COM2", 3, 0x2F8 },
-    { "COM3", 4, 0x3E8 },
-    { "COM4", 3, 0x2E8 },
-    /* must not contain an element with IRQ=0 and IOBase=0 used to cause
-     * toCOMPortName() to return the "User-defined" string for these values. */
-};
-
-static const PortConfig kLptKnownPorts[] =
-{
-    { "LPT1", 7, 0x378 },
-    { "LPT2", 5, 0x278 },
-    { "LPT1", 2, 0x3BC },
-    /* must not contain an element with IRQ=0 and IOBase=0 used to cause
-     * toLPTPortName() to return the "User-defined" string for these values. */
-};
-
-/**
- *  Returns the list of the standard COM port names (i.e. "COMx").
- */
-QStringList VBoxGlobal::COMPortNames() const
-{
-    QStringList list;
-    for (size_t i = 0; i < RT_ELEMENTS (kComKnownPorts); ++ i)
-        list << kComKnownPorts [i].name;
-
-    return list;
-}
-
-/**
- *  Returns the list of the standard LPT port names (i.e. "LPTx").
- */
-QStringList VBoxGlobal::LPTPortNames() const
-{
-    QStringList list;
-    for (size_t i = 0; i < RT_ELEMENTS (kLptKnownPorts); ++ i)
-        list << kLptKnownPorts [i].name;
-
-    return list;
-}
-
-/**
- *  Returns the name of the standard COM port corresponding to the given
- *  parameters, or "User-defined" (which is also returned when both
- *  @a aIRQ and @a aIOBase are 0).
- */
-QString VBoxGlobal::toCOMPortName (ulong aIRQ, ulong aIOBase) const
-{
-    for (size_t i = 0; i < RT_ELEMENTS (kComKnownPorts); ++ i)
-        if (kComKnownPorts [i].IRQ == aIRQ &&
-            kComKnownPorts [i].IOBase == aIOBase)
-            return kComKnownPorts [i].name;
-
-    return mUserDefinedPortName;
-}
-
-/**
- *  Returns the name of the standard LPT port corresponding to the given
- *  parameters, or "User-defined" (which is also returned when both
- *  @a aIRQ and @a aIOBase are 0).
- */
-QString VBoxGlobal::toLPTPortName (ulong aIRQ, ulong aIOBase) const
-{
-    for (size_t i = 0; i < RT_ELEMENTS (kLptKnownPorts); ++ i)
-        if (kLptKnownPorts [i].IRQ == aIRQ &&
-            kLptKnownPorts [i].IOBase == aIOBase)
-            return kLptKnownPorts [i].name;
-
-    return mUserDefinedPortName;
-}
-
-/**
- *  Returns port parameters corresponding to the given standard COM name.
- *  Returns @c true on success, or @c false if the given port name is not one
- *  of the standard names (i.e. "COMx").
- */
-bool VBoxGlobal::toCOMPortNumbers (const QString &aName, ulong &aIRQ,
-                                   ulong &aIOBase) const
-{
-    for (size_t i = 0; i < RT_ELEMENTS (kComKnownPorts); ++ i)
-        if (strcmp (kComKnownPorts [i].name, aName.toUtf8().data()) == 0)
-        {
-            aIRQ = kComKnownPorts [i].IRQ;
-            aIOBase = kComKnownPorts [i].IOBase;
-            return true;
-        }
-
-    return false;
-}
-
-/**
- *  Returns port parameters corresponding to the given standard LPT name.
- *  Returns @c true on success, or @c false if the given port name is not one
- *  of the standard names (i.e. "LPTx").
- */
-bool VBoxGlobal::toLPTPortNumbers (const QString &aName, ulong &aIRQ,
-                                   ulong &aIOBase) const
-{
-    for (size_t i = 0; i < RT_ELEMENTS (kLptKnownPorts); ++ i)
-        if (strcmp (kLptKnownPorts [i].name, aName.toUtf8().data()) == 0)
-        {
-            aIRQ = kLptKnownPorts [i].IRQ;
-            aIOBase = kLptKnownPorts [i].IOBase;
-            return true;
-        }
-
-    return false;
-}
-
-QString VBoxGlobal::details(const CMedium &cmedium, bool fPredictDiff, bool fUseHtml /* = true*/)
-{
-    /* Search for corresponding UI medium: */
-    const QString strMediumID = cmedium.isNull() ? UIMedium::nullID() : cmedium.GetId();
-    UIMedium uimedium = medium(strMediumID);
-    if (!cmedium.isNull() && uimedium.isNull())
-    {
-        /* UI medium may be new and not among our mediums, request enumeration: */
-        startMediumEnumeration();
-
-        /* Search for corresponding UI medium again: */
-
-        uimedium = medium(strMediumID);
-        if (uimedium.isNull())
-        {
-            /* Medium might be deleted already, return null string: */
-            return QString();
-        }
-    }
-
-    /* Return UI medium details: */
-    return fUseHtml ? uimedium.detailsHTML(true /* aNoDiffs */, fPredictDiff) :
-                      uimedium.details(true /* aNoDiffs */, fPredictDiff);
-}
-
-/**
- *  Returns the details of the given USB device as a single-line string.
- */
-QString VBoxGlobal::details (const CUSBDevice &aDevice) const
-{
-    QString sDetails;
-    if (aDevice.isNull())
-        sDetails = tr("Unknown device", "USB device details");
-    else
-    {
-        QVector<QString> devInfoVector = aDevice.GetDeviceInfo();
-        QString m;
-        QString p;
-
-        if (devInfoVector.size() >= 1)
-            m = devInfoVector[0].trimmed();
-        if (devInfoVector.size() >= 2)
-            p = devInfoVector[1].trimmed();
-
-        if (m.isEmpty() && p.isEmpty())
-        {
-            sDetails =
-                tr ("Unknown device %1:%2", "USB device details")
-                .arg (QString().sprintf ("%04hX", aDevice.GetVendorId()))
-                .arg (QString().sprintf ("%04hX", aDevice.GetProductId()));
-        }
-        else
-        {
-            if (p.toUpper().startsWith (m.toUpper()))
-                sDetails = p;
-            else
-                sDetails = m + " " + p;
-        }
-        ushort r = aDevice.GetRevision();
-        if (r != 0)
-            sDetails += QString().sprintf (" [%04hX]", r);
-    }
-
-    return sDetails.trimmed();
-}
-
-/**
- *  Returns the multi-line description of the given USB device.
- */
-QString VBoxGlobal::toolTip (const CUSBDevice &aDevice) const
-{
-    QString tip =
-        tr ("<nobr>Vendor ID: %1</nobr><br>"
-            "<nobr>Product ID: %2</nobr><br>"
-            "<nobr>Revision: %3</nobr>", "USB device tooltip")
-        .arg (QString().sprintf ("%04hX", aDevice.GetVendorId()))
-        .arg (QString().sprintf ("%04hX", aDevice.GetProductId()))
-        .arg (QString().sprintf ("%04hX", aDevice.GetRevision()));
-
-    QString ser = aDevice.GetSerialNumber();
-    if (!ser.isEmpty())
-        tip += QString (tr ("<br><nobr>Serial No. %1</nobr>", "USB device tooltip"))
-                        .arg (ser);
-
-    /* add the state field if it's a host USB device */
-    CHostUSBDevice hostDev (aDevice);
-    if (!hostDev.isNull())
-    {
-        tip += QString (tr ("<br><nobr>State: %1</nobr>", "USB device tooltip"))
-                        .arg (gpConverter->toString (hostDev.GetState()));
-    }
-
-    return tip;
-}
-
-/**
- *  Returns the multi-line description of the given USB filter
- */
-QString VBoxGlobal::toolTip (const CUSBDeviceFilter &aFilter) const
-{
-    QString tip;
-
-    QString vendorId = aFilter.GetVendorId();
-    if (!vendorId.isEmpty())
-        tip += tr ("<nobr>Vendor ID: %1</nobr>", "USB filter tooltip")
-                   .arg (vendorId);
-
-    QString productId = aFilter.GetProductId();
-    if (!productId.isEmpty())
-        tip += tip.isEmpty() ? "":"<br/>" + tr ("<nobr>Product ID: %2</nobr>", "USB filter tooltip")
-                                                .arg (productId);
-
-    QString revision = aFilter.GetRevision();
-    if (!revision.isEmpty())
-        tip += tip.isEmpty() ? "":"<br/>" + tr ("<nobr>Revision: %3</nobr>", "USB filter tooltip")
-                                                .arg (revision);
-
-    QString product = aFilter.GetProduct();
-    if (!product.isEmpty())
-        tip += tip.isEmpty() ? "":"<br/>" + tr ("<nobr>Product: %4</nobr>", "USB filter tooltip")
-                                                .arg (product);
-
-    QString manufacturer = aFilter.GetManufacturer();
-    if (!manufacturer.isEmpty())
-        tip += tip.isEmpty() ? "":"<br/>" + tr ("<nobr>Manufacturer: %5</nobr>", "USB filter tooltip")
-                                                .arg (manufacturer);
-
-    QString serial = aFilter.GetSerialNumber();
-    if (!serial.isEmpty())
-        tip += tip.isEmpty() ? "":"<br/>" + tr ("<nobr>Serial No.: %1</nobr>", "USB filter tooltip")
-                                                .arg (serial);
-
-    QString port = aFilter.GetPort();
-    if (!port.isEmpty())
-        tip += tip.isEmpty() ? "":"<br/>" + tr ("<nobr>Port: %1</nobr>", "USB filter tooltip")
-                                                .arg (port);
-
-    /* add the state field if it's a host USB device */
-    CHostUSBDevice hostDev (aFilter);
-    if (!hostDev.isNull())
-    {
-        tip += tip.isEmpty() ? "":"<br/>" + tr ("<nobr>State: %1</nobr>", "USB filter tooltip")
-                                                .arg (gpConverter->toString (hostDev.GetState()));
-    }
-
-    return tip;
-}
-
-/** Returns the multi-line description of the given CHostVideoInputDevice filter. */
-QString VBoxGlobal::toolTip(const CHostVideoInputDevice &webcam) const
-{
-    QStringList records;
-
-    QString strName = webcam.GetName();
-    if (!strName.isEmpty())
-        records << strName;
-
-    QString strPath = webcam.GetPath();
-    if (!strPath.isEmpty())
-        records << strPath;
-
-    return records.join("<br>");
-}
-
-CSession VBoxGlobal::openSession(const QString &strId, KLockType lockType /* = KLockType_Shared */)
-{
-    /* Prepare session: */
-    CSession session;
-
-    /* Simulate try-catch block: */
-    bool fSuccess = false;
-    do
-    {
-        /* Create empty session instance: */
-        session.createInstance(CLSID_Session);
-        if (session.isNull())
-        {
-            msgCenter().cannotOpenSession(session);
-            break;
-        }
-
-        /* Search for the corresponding machine: */
-        CMachine machine = m_vbox.FindMachine(strId);
-        if (machine.isNull())
-        {
-            msgCenter().cannotFindMachineById(m_vbox, strId);
-            break;
-        }
-
-        if (lockType == KLockType_VM)
-            session.SetName("GUI/Qt");
-
-        /* Lock found machine to session: */
-        machine.LockMachine(session, lockType);
-        if (!machine.isOk())
-        {
-            msgCenter().cannotOpenSession(machine);
-            break;
-        }
-
-        /* Pass the language ID as the property to the guest: */
-        if (session.GetType() == KSessionType_Shared)
-        {
-            CMachine startedMachine = session.GetMachine();
-            /* Make sure that the language is in two letter code.
-             * Note: if languageId() returns an empty string lang.name() will
-             * return "C" which is an valid language code. */
-            QLocale lang(VBoxGlobal::languageId());
-            startedMachine.SetGuestPropertyValue("/VirtualBox/HostInfo/GUI/LanguageID", lang.name());
-        }
-
-        /* Success finally: */
-        fSuccess = true;
-    }
-    while (0);
-    /* Cleanup try-catch block: */
-    if (!fSuccess)
-        session.detach();
-
-    /* Return session: */
-    return session;
-}
-
-void VBoxGlobal::createMedium(const UIMedium &medium)
-{
-    if (m_mediumEnumeratorDtorRwLock.tryLockForRead())
-    {
-        /* Create medium in medium-enumerator: */
-        if (m_pMediumEnumerator)
-            m_pMediumEnumerator->createMedium(medium);
-        m_mediumEnumeratorDtorRwLock.unlock();
-    }
-}
-
-void VBoxGlobal::deleteMedium(const QString &strMediumID)
-{
-    if (m_mediumEnumeratorDtorRwLock.tryLockForRead())
-    {
-        /* Delete medium from medium-enumerator: */
-        if (m_pMediumEnumerator)
-            m_pMediumEnumerator->deleteMedium(strMediumID);
-        m_mediumEnumeratorDtorRwLock.unlock();
-    }
-}
-
-
-/**
- * Create a VISO using the file open dialog.
- *
- * Temporarily caches (enumerate) it in GUI inner mediums cache.
- *
- * @returns Medium ID string, empty on abort.
- */
-QString VBoxGlobal::createVisoMediumWithFileOpenDialog(QWidget *pParent, const QString &strMachineFolder)
-{
-    AssertReturn(!strMachineFolder.isEmpty(), QString());
-
-    /* Figure out where to start browsing for content. */
-    QString strDirectory = gEDataManager->recentFolderForVISOContent();
-    if (strDirectory.isEmpty())
-        strDirectory = QDir::homePath();
-    if (strDirectory.isEmpty())
-        strDirectory = homeFolder();
-
-    /* Execute the open file dialog, getting a list of files & dirs back. */
-    /** @todo make it possible to select directories... */
-    QStringList files = QIFileDialog::getOpenFileNames(strDirectory, tr("All files (*)"), pParent,
-                                                       /// @todo tr("Please select files and directories to be on the VISO"),
-                                                       tr("Please select files to be on the VISO"),
-                                                       0, true /*aResolveSymlinks*/, false /*aSingleFile*/);
-
-    /* Return if no result. */
-    if (files.empty() || files[0].isEmpty())
-        return QString();
-
-    /* Remember folder for the next time. */
-    gEDataManager->setRecentFolderForVISOContent(QFileInfo(files[0]).absolutePath());
-
-    /* Produce the VISO. */
-    char szVisoPath[RTPATH_MAX];
-    int vrc = RTPathJoin(szVisoPath, sizeof(szVisoPath), strMachineFolder.toUtf8().constData(), "ad-hoc.viso");
-    if (RT_SUCCESS(vrc))
-    {
-        PRTSTREAM pStrmViso;
-        vrc = RTStrmOpen(szVisoPath, "w", &pStrmViso);
-        if (RT_SUCCESS(vrc))
-        {
-            RTUUID Uuid;
-            vrc = RTUuidCreate(&Uuid);
-            if (RT_SUCCESS(vrc))
-            {
-                RTStrmPrintf(pStrmViso, "--iprt-iso-maker-file-marker-bourne-sh %RTuuid\n", &Uuid);
-
-                for (int iFile = 0; iFile < files.size(); iFile++)
-                {
-                    QByteArray const utf8Name = files[iFile].toUtf8();
-                    const char *apszArgv[2] = { utf8Name.constData(), NULL };
-                    char *pszQuoted;
-                    vrc = RTGetOptArgvToString(&pszQuoted, apszArgv, RTGETOPTARGV_CNV_QUOTE_BOURNE_SH);
-                    if (RT_SUCCESS(vrc))
-                    {
-                        RTStrmPrintf(pStrmViso, "%s\n", pszQuoted);
-                        RTStrFree(pszQuoted);
-                    }
-                    else
-                        break;
-                }
-
-                RTStrmFlush(pStrmViso);
-                if (RT_SUCCESS(vrc))
-                    vrc = RTStrmError(pStrmViso);
-            }
-
-            RTStrmClose(pStrmViso);
-        }
-    }
-
-    /* Done. */
-    if (RT_SUCCESS(vrc))
-        return openMedium(UIMediumType_DVD, QString(szVisoPath), pParent);
-
-    /** @todo error message. */
-    return QString();
-}
-
-/* Open some external medium using file open dialog
- * and temporary cache (enumerate) it in GUI inner mediums cache: */
-QString VBoxGlobal::openMediumWithFileOpenDialog(UIMediumType mediumType, QWidget *pParent,
-                                                 const QString &strDefaultFolder /* = QString() */,
-                                                 bool fUseLastFolder /* = false */)
-{
-    /* Initialize variables: */
-    QList < QPair <QString, QString> > filters;
-    QStringList backends;
-    QStringList prefixes;
-    QString strFilter;
-    QString strTitle;
-    QString allType;
-    QString strLastFolder;
-    switch (mediumType)
-    {
-        case UIMediumType_HardDisk:
-        {
-            filters = vboxGlobal().HDDBackends();
-            strTitle = tr("Please choose a virtual hard disk file");
-            allType = tr("All virtual hard disk files (%1)");
-            strLastFolder = gEDataManager->recentFolderForHardDrives();
-            if (strLastFolder.isEmpty())
-                strLastFolder = gEDataManager->recentFolderForOpticalDisks();
-            if (strLastFolder.isEmpty())
-                strLastFolder = gEDataManager->recentFolderForFloppyDisks();
-            break;
-        }
-        case UIMediumType_DVD:
-        {
-            filters = vboxGlobal().DVDBackends();
-            strTitle = tr("Please choose a virtual optical disk file");
-            allType = tr("All virtual optical disk files (%1)");
-            strLastFolder = gEDataManager->recentFolderForOpticalDisks();
-            if (strLastFolder.isEmpty())
-                strLastFolder = gEDataManager->recentFolderForFloppyDisks();
-            if (strLastFolder.isEmpty())
-                strLastFolder = gEDataManager->recentFolderForHardDrives();
-            break;
-        }
-        case UIMediumType_Floppy:
-        {
-            filters = vboxGlobal().FloppyBackends();
-            strTitle = tr("Please choose a virtual floppy disk file");
-            allType = tr("All virtual floppy disk files (%1)");
-            strLastFolder = gEDataManager->recentFolderForFloppyDisks();
-            if (strLastFolder.isEmpty())
-                strLastFolder = gEDataManager->recentFolderForOpticalDisks();
-            if (strLastFolder.isEmpty())
-                strLastFolder = gEDataManager->recentFolderForHardDrives();
-            break;
-        }
-        default:
-            break;
-    }
-    QString strHomeFolder = fUseLastFolder && !strLastFolder.isEmpty() ? strLastFolder :
-                            strDefaultFolder.isEmpty() ? vboxGlobal().homeFolder() : strDefaultFolder;
-
-    /* Prepare filters and backends: */
-    for (int i = 0; i < filters.count(); ++i)
-    {
-        /* Get iterated filter: */
-        QPair <QString, QString> item = filters.at(i);
-        /* Create one backend filter string: */
-        backends << QString("%1 (%2)").arg(item.first).arg(item.second);
-        /* Save the suffix's for the "All" entry: */
-        prefixes << item.second;
-    }
-    if (!prefixes.isEmpty())
-        backends.insert(0, allType.arg(prefixes.join(" ").trimmed()));
-    backends << tr("All files (*)");
-    strFilter = backends.join(";;").trimmed();
-
-    /* Create open file dialog: */
-    QStringList files = QIFileDialog::getOpenFileNames(strHomeFolder, strFilter, pParent, strTitle, 0, true, true);
-
-    /* If dialog has some result: */
-    if (!files.empty() && !files[0].isEmpty())
-        return openMedium(mediumType, files[0], pParent);
-
-    return QString();
-}
-
-QString VBoxGlobal::openMedium(UIMediumType mediumType, QString strMediumLocation, QWidget *pParent /* = 0*/)
-{
-    /* Convert to native separators: */
-    strMediumLocation = QDir::toNativeSeparators(strMediumLocation);
-
-    /* Initialize variables: */
-    CVirtualBox vbox = virtualBox();
-
-    /* Remember the path of the last chosen medium: */
-    switch (mediumType)
-    {
-        case UIMediumType_HardDisk: gEDataManager->setRecentFolderForHardDrives(QFileInfo(strMediumLocation).absolutePath()); break;
-        case UIMediumType_DVD:      gEDataManager->setRecentFolderForOpticalDisks(QFileInfo(strMediumLocation).absolutePath()); break;
-        case UIMediumType_Floppy:   gEDataManager->setRecentFolderForFloppyDisks(QFileInfo(strMediumLocation).absolutePath()); break;
-        default: break;
-    }
-
-    /* Update recently used list: */
-    QStringList recentMediumList;
-    switch (mediumType)
-    {
-        case UIMediumType_HardDisk: recentMediumList = gEDataManager->recentListOfHardDrives(); break;
-        case UIMediumType_DVD:      recentMediumList = gEDataManager->recentListOfOpticalDisks(); break;
-        case UIMediumType_Floppy:   recentMediumList = gEDataManager->recentListOfFloppyDisks(); break;
-        default: break;
-    }
-    if (recentMediumList.contains(strMediumLocation))
-        recentMediumList.removeAll(strMediumLocation);
-    recentMediumList.prepend(strMediumLocation);
-    while(recentMediumList.size() > 5) recentMediumList.removeLast();
-    switch (mediumType)
-    {
-        case UIMediumType_HardDisk: gEDataManager->setRecentListOfHardDrives(recentMediumList); break;
-        case UIMediumType_DVD:      gEDataManager->setRecentListOfOpticalDisks(recentMediumList); break;
-        case UIMediumType_Floppy:   gEDataManager->setRecentListOfFloppyDisks(recentMediumList); break;
-        default: break;
-    }
-
-    /* Open corresponding medium: */
-    CMedium cmedium = vbox.OpenMedium(strMediumLocation, mediumTypeToGlobal(mediumType), KAccessMode_ReadWrite, false);
-
-    if (vbox.isOk())
-    {
-        /* Prepare vbox medium wrapper: */
-        UIMedium uimedium = medium(cmedium.GetId());
-
-        /* First of all we should test if that medium already opened: */
-        if (uimedium.isNull())
-        {
-            /* And create new otherwise: */
-            uimedium = UIMedium(cmedium, mediumType, KMediumState_Created);
-            vboxGlobal().createMedium(uimedium);
-        }
-
-        /* Return uimedium id: */
-        return uimedium.id();
-    }
-    else
-        msgCenter().cannotOpenMedium(vbox, mediumType, strMediumLocation, pParent);
-
-    return QString();
-}
-
-void VBoxGlobal::startMediumEnumeration()
-{
-    /* Make sure VBoxGlobal is already valid: */
-    AssertReturnVoid(mValid);
-
-    /* Make sure medium-enumerator is already created: */
-    if (!m_pMediumEnumerator)
-        return;
-
-    /* Make sure enumeration is not already started: */
-    if (isMediumEnumerationInProgress())
-        return;
-
-    /* Ignore the request during VBoxGlobal cleanup: */
-    if (s_fCleanupInProgress)
-        return;
-
-    /* If asked to restore snapshot, don't do this till *after* we're done
-     * restoring or the code with have a heart attack. */
-    if (shouldRestoreCurrentSnapshot())
-        return;
-
-    if (m_mediumEnumeratorDtorRwLock.tryLockForRead())
-    {
-        /* Redirect request to medium-enumerator: */
-        if (m_pMediumEnumerator)
-            m_pMediumEnumerator->enumerateMediums();
-        m_mediumEnumeratorDtorRwLock.unlock();
-    }
-}
-
-bool VBoxGlobal::isMediumEnumerationInProgress() const
-{
-    /* Redirect request to medium-enumerator: */
-    return m_pMediumEnumerator
-        && m_pMediumEnumerator->isMediumEnumerationInProgress();
-}
-
-UIMedium VBoxGlobal::medium(const QString &strMediumID) const
-{
-    if (m_mediumEnumeratorDtorRwLock.tryLockForRead())
-    {
-        /* Redirect call to medium-enumerator: */
-        UIMedium result;
-        if (m_pMediumEnumerator)
-            result = m_pMediumEnumerator->medium(strMediumID);
-        m_mediumEnumeratorDtorRwLock.unlock();
-        return result;
-    }
-    return UIMedium();
-}
-
-QList<QString> VBoxGlobal::mediumIDs() const
-{
-    if (m_mediumEnumeratorDtorRwLock.tryLockForRead())
-    {
-        /* Redirect call to medium-enumerator: */
-        QList<QString> result;
-        if (m_pMediumEnumerator)
-            result = m_pMediumEnumerator->mediumIDs();
-        m_mediumEnumeratorDtorRwLock.unlock();
-        return result;
-    }
-    return QList<QString>();
-}
-
-void VBoxGlobal::prepareStorageMenu(QMenu &menu,
-                                    QObject *pListener, const char *pszSlotName,
-                                    const CMachine &machine, const QString &strControllerName, const StorageSlot &storageSlot)
-{
-    /* Current attachment attributes: */
-    const CMediumAttachment currentAttachment = machine.GetMediumAttachment(strControllerName, storageSlot.port, storageSlot.device);
-    const CMedium currentMedium = currentAttachment.GetMedium();
-    const QString strCurrentID = currentMedium.isNull() ? QString() : currentMedium.GetId();
-    const QString strCurrentLocation = currentMedium.isNull() ? QString() : currentMedium.GetLocation();
-
-    /* Other medium-attachments of same machine: */
-    const CMediumAttachmentVector attachments = machine.GetMediumAttachments();
-
-    /* Determine device & medium types: */
-    const UIMediumType mediumType = mediumTypeToLocal(currentAttachment.GetType());
-    AssertMsgReturnVoid(mediumType != UIMediumType_Invalid, ("Incorrect storage medium type!\n"));
-
-
-    /* Prepare open-existing-medium action: */
-    QAction *pActionOpenExistingMedium = menu.addAction(UIIconPool::iconSet(":/select_file_16px.png"), QString(), pListener, pszSlotName);
-    pActionOpenExistingMedium->setData(QVariant::fromValue(UIMediumTarget(strControllerName, currentAttachment.GetPort(), currentAttachment.GetDevice(),
-                                                                          mediumType)));
-    pActionOpenExistingMedium->setText(QApplication::translate("UIMachineSettingsStorage", "Choose disk image...", "This is used for hard disks, optical media and floppies"));
-
-    /* Prepare ad-hoc-viso action for DVD-ROMs: */
-    if (mediumType == UIMediumType_DVD)
-    {
-        QAction *pActionAdHocViso = menu.addAction(UIIconPool::iconSet(":/select_file_16px.png"), QString(),
-                                                   pListener, pszSlotName);
-        pActionAdHocViso->setData(QVariant::fromValue(UIMediumTarget(strControllerName, currentAttachment.GetPort(),
-                                                                     currentAttachment.GetDevice(), mediumType,
-                                                                     UIMediumTarget::UIMediumTargetType_CreateAdHocVISO)));
-        pActionAdHocViso->setText(QApplication::translate("UIMachineSettingsStorage", "Create ad hoc VISO...", "This is used for optical media"));
-    }
-
-    /* Insert separator: */
-    menu.addSeparator();
-
-
-    /* Get existing-host-drive vector: */
-    CMediumVector mediums;
-    switch (mediumType)
-    {
-        case UIMediumType_DVD:    mediums = vboxGlobal().host().GetDVDDrives(); break;
-        case UIMediumType_Floppy: mediums = vboxGlobal().host().GetFloppyDrives(); break;
-        default: break;
-    }
-    /* Prepare choose-existing-host-drive actions: */
-    foreach (const CMedium &medium, mediums)
-    {
-        /* Make sure host-drive usage is unique: */
-        bool fIsHostDriveUsed = false;
-        foreach (const CMediumAttachment &otherAttachment, attachments)
-        {
-            if (otherAttachment != currentAttachment)
-            {
-                const CMedium &otherMedium = otherAttachment.GetMedium();
-                if (!otherMedium.isNull() && otherMedium.GetId() == medium.GetId())
-                {
-                    fIsHostDriveUsed = true;
-                    break;
-                }
-            }
-        }
-        /* If host-drives usage is unique: */
-        if (!fIsHostDriveUsed)
-        {
-            QAction *pActionChooseHostDrive = menu.addAction(UIMedium(medium, mediumType).name(), pListener, pszSlotName);
-            pActionChooseHostDrive->setCheckable(true);
-            pActionChooseHostDrive->setChecked(!currentMedium.isNull() && medium.GetId() == strCurrentID);
-            pActionChooseHostDrive->setData(QVariant::fromValue(UIMediumTarget(strControllerName, currentAttachment.GetPort(), currentAttachment.GetDevice(),
-                                                                               mediumType, UIMediumTarget::UIMediumTargetType_WithID, medium.GetId())));
-        }
-    }
-
-
-    /* Get recent-medium list: */
-    QStringList recentMediumList;
-    QStringList recentMediumListUsed;
-    switch (mediumType)
-    {
-        case UIMediumType_HardDisk: recentMediumList = gEDataManager->recentListOfHardDrives(); break;
-        case UIMediumType_DVD:      recentMediumList = gEDataManager->recentListOfOpticalDisks(); break;
-        case UIMediumType_Floppy:   recentMediumList = gEDataManager->recentListOfFloppyDisks(); break;
-        default: break;
-    }
-    /* Prepare choose-recent-medium actions: */
-    foreach (const QString &strRecentMediumLocationBase, recentMediumList)
-    {
-        /* Confirm medium uniqueness: */
-        if (recentMediumListUsed.contains(strRecentMediumLocationBase))
-            continue;
-        /* Mark medium as known: */
-        recentMediumListUsed << strRecentMediumLocationBase;
-        /* Convert separators to native: */
-        const QString strRecentMediumLocation = QDir::toNativeSeparators(strRecentMediumLocationBase);
-        /* Confirm medium presence: */
-        if (!QFile::exists(strRecentMediumLocation))
-            continue;
-        /* Make sure recent-medium usage is unique: */
-        bool fIsRecentMediumUsed = false;
-        foreach (const CMediumAttachment &otherAttachment, attachments)
-        {
-            if (otherAttachment != currentAttachment)
-            {
-                const CMedium &otherMedium = otherAttachment.GetMedium();
-                if (!otherMedium.isNull() && otherMedium.GetLocation() == strRecentMediumLocation)
-                {
-                    fIsRecentMediumUsed = true;
-                    break;
-                }
-            }
-        }
-        /* If recent-medium usage is unique: */
-        if (!fIsRecentMediumUsed)
-        {
-            QAction *pActionChooseRecentMedium = menu.addAction(QFileInfo(strRecentMediumLocation).fileName(), pListener, pszSlotName);
-            pActionChooseRecentMedium->setCheckable(true);
-            pActionChooseRecentMedium->setChecked(!currentMedium.isNull() && strRecentMediumLocation == strCurrentLocation);
-            pActionChooseRecentMedium->setData(QVariant::fromValue(UIMediumTarget(strControllerName, currentAttachment.GetPort(), currentAttachment.GetDevice(),
-                                                                                  mediumType, UIMediumTarget::UIMediumTargetType_WithLocation, strRecentMediumLocation)));
-            pActionChooseRecentMedium->setToolTip(strRecentMediumLocation);
-        }
-    }
-
-
-    /* Last action for optical/floppy attachments only: */
-    if (mediumType == UIMediumType_DVD || mediumType == UIMediumType_Floppy)
-    {
-        /* Insert separator: */
-        menu.addSeparator();
-
-        /* Prepare unmount-current-medium action: */
-        QAction *pActionUnmountMedium = menu.addAction(QString(), pListener, pszSlotName);
-        pActionUnmountMedium->setEnabled(!currentMedium.isNull());
-        pActionUnmountMedium->setData(QVariant::fromValue(UIMediumTarget(strControllerName, currentAttachment.GetPort(), currentAttachment.GetDevice())));
-        pActionUnmountMedium->setText(QApplication::translate("UIMachineSettingsStorage", "Remove disk from virtual drive"));
-        if (mediumType == UIMediumType_DVD)
-            pActionUnmountMedium->setIcon(UIIconPool::iconSet(":/cd_unmount_16px.png", ":/cd_unmount_disabled_16px.png"));
-        else if (mediumType == UIMediumType_Floppy)
-            pActionUnmountMedium->setIcon(UIIconPool::iconSet(":/fd_unmount_16px.png", ":/fd_unmount_disabled_16px.png"));
-    }
-}
-
-void VBoxGlobal::updateMachineStorage(const CMachine &constMachine, const UIMediumTarget &target)
-{
-    /* Mount (by default): */
-    bool fMount = true;
-    /* Null medium (by default): */
-    CMedium cmedium;
-    /* With null ID (by default): */
-    QString strActualID;
-
-    /* Current mount-target attributes: */
-    const CStorageController currentController = constMachine.GetStorageControllerByName(target.name);
-    const KStorageBus currentStorageBus = currentController.GetBus();
-    const CMediumAttachment currentAttachment = constMachine.GetMediumAttachment(target.name, target.port, target.device);
-    const CMedium currentMedium = currentAttachment.GetMedium();
-    const QString strCurrentID = currentMedium.isNull() ? QString() : currentMedium.GetId();
-    const QString strCurrentLocation = currentMedium.isNull() ? QString() : currentMedium.GetLocation();
-
-    /* Which additional info do we have? */
-    switch (target.type)
-    {
-        /* Do we have an exact ID or do we let the user open a medium? */
-        case UIMediumTarget::UIMediumTargetType_WithID:
-        case UIMediumTarget::UIMediumTargetType_CreateAdHocVISO:
-        {
-            /* New mount-target attributes: */
-            QString strNewID;
-
-            /* Invoke file-open dialog to choose medium ID: */
-            if (target.mediumType != UIMediumType_Invalid && target.data.isNull())
-            {
-                /* Keyboard can be captured by machine-view.
-                 * So we should clear machine-view focus to let file-open dialog get it.
-                 * That way the keyboard will be released too.. */
-                QWidget *pLastFocusedWidget = 0;
-                if (QApplication::focusWidget())
-                {
-                    pLastFocusedWidget = QApplication::focusWidget();
-                    pLastFocusedWidget->clearFocus();
-                }
-                /* Call for file-open dialog: */
-                const QString strMachineFolder(QFileInfo(constMachine.GetSettingsFilePath()).absolutePath());
-                const QString strMediumID = target.type != UIMediumTarget::UIMediumTargetType_CreateAdHocVISO
-                                          ? vboxGlobal().openMediumWithFileOpenDialog(target.mediumType,
-                                                                                      windowManager().mainWindowShown(),
-                                                                                      strMachineFolder)
-                                          : vboxGlobal().createVisoMediumWithFileOpenDialog(windowManager().mainWindowShown(),
-                                                                                            strMachineFolder);
-                /* Return focus back: */
-                if (pLastFocusedWidget)
-                    pLastFocusedWidget->setFocus();
-                /* Accept new medium ID: */
-                if (!strMediumID.isNull())
-                    strNewID = strMediumID;
-                /* Else just exit: */
-                else return;
-            }
-            /* Use medium ID which was passed: */
-            else if (!target.data.isNull() && target.data != strCurrentID)
-                strNewID = target.data;
-
-            /* Should we mount or unmount? */
-            fMount = !strNewID.isEmpty();
-
-            /* Prepare target medium: */
-            const UIMedium uimedium = vboxGlobal().medium(strNewID);
-            cmedium = uimedium.medium();
-            strActualID = fMount ? strNewID : strCurrentID;
-            break;
-        }
-        /* Do we have a resent location? */
-        case UIMediumTarget::UIMediumTargetType_WithLocation:
-        {
-            /* Open medium by location and get new medium ID if any: */
-            const QString strNewID = vboxGlobal().openMedium(target.mediumType, target.data);
-            /* Else just exit: */
-            if (strNewID.isEmpty())
-                return;
-
-            /* Should we mount or unmount? */
-            fMount = strNewID != strCurrentID;
-
-            /* Prepare target medium: */
-            const UIMedium uimedium = fMount ? vboxGlobal().medium(strNewID) : UIMedium();
-            cmedium = fMount ? uimedium.medium() : CMedium();
-            strActualID = fMount ? strNewID : strCurrentID;
-            break;
-        }
-    }
-
-    /* Do not unmount hard-drives: */
-    if (target.mediumType == UIMediumType_HardDisk && !fMount)
-        return;
-
-    /* Get editable machine: */
-    CSession session;
-    CMachine machine = constMachine;
-    KSessionState sessionState = machine.GetSessionState();
-    /* Session state unlocked? */
-    if (sessionState == KSessionState_Unlocked)
-    {
-        /* Open own 'write' session: */
-        session = openSession(machine.GetId());
-        AssertReturnVoid(!session.isNull());
-        machine = session.GetMachine();
-    }
-    /* Is it Selector UI call? */
-    else if (!isVMConsoleProcess())
-    {
-        /* Open existing 'shared' session: */
-        session = openExistingSession(machine.GetId());
-        AssertReturnVoid(!session.isNull());
-        machine = session.GetMachine();
-    }
-    /* Else this is Runtime UI call
-     * which has session locked for itself. */
-
-    /* Remount medium to the predefined port/device: */
-    bool fWasMounted = false;
-    /* Hard drive case: */
-    if (target.mediumType == UIMediumType_HardDisk)
-    {
-        /* Detaching: */
-        machine.DetachDevice(target.name, target.port, target.device);
-        fWasMounted = machine.isOk();
-        if (!fWasMounted)
-            msgCenter().cannotDetachDevice(machine, UIMediumType_HardDisk, strCurrentLocation,
-                                           StorageSlot(currentStorageBus, target.port, target.device));
-        else
-        {
-            /* Attaching: */
-            machine.AttachDevice(target.name, target.port, target.device, KDeviceType_HardDisk, cmedium);
-            fWasMounted = machine.isOk();
-            if (!fWasMounted)
-                msgCenter().cannotAttachDevice(machine, UIMediumType_HardDisk, strCurrentLocation,
-                                               StorageSlot(currentStorageBus, target.port, target.device));
-        }
-    }
-    /* Optical/floppy drive case: */
-    else
-    {
-        /* Remounting: */
-        machine.MountMedium(target.name, target.port, target.device, cmedium, false /* force? */);
-        fWasMounted = machine.isOk();
-        if (!fWasMounted)
-        {
-            /* Ask for force remounting: */
-            if (msgCenter().cannotRemountMedium(machine, vboxGlobal().medium(strActualID),
-                                                fMount, true /* retry? */))
-            {
-                /* Force remounting: */
-                machine.MountMedium(target.name, target.port, target.device, cmedium, true /* force? */);
-                fWasMounted = machine.isOk();
-                if (!fWasMounted)
-                    msgCenter().cannotRemountMedium(machine, vboxGlobal().medium(strActualID),
-                                                    fMount, false /* retry? */);
-            }
-        }
-        /* If mounting was successful: */
-        if (fWasMounted)
-        {
-            /* Disable First RUN Wizard: */
-            if (gEDataManager->machineFirstTimeStarted(machine.GetId()))
-                gEDataManager->setMachineFirstTimeStarted(false, machine.GetId());
-        }
-    }
-
-    /* Save settings: */
-    if (fWasMounted)
-    {
-        machine.SaveSettings();
-        if (!machine.isOk())
-            msgCenter().cannotSaveMachineSettings(machine, windowManager().mainWindowShown());
-    }
-
-    /* Close session to editable machine if necessary: */
-    if (!session.isNull())
-        session.UnlockMachine();
-}
+
+#endif /* VBOX_GUI_WITH_PIDFILE */
 
 /**
@@ -1712,66 +581,4 @@
                             "Comma-separated list of translators");
 }
-
-/**
- *  Changes the language of all global string constants according to the
- *  currently installed translations tables.
- */
-void VBoxGlobal::retranslateUi()
-{
-    mUserDefinedPortName = tr ("User-defined", "serial port");
-
-    mWarningIcon = UIIconPool::defaultIcon(UIIconPool::UIDefaultIconType_MessageBoxWarning).pixmap (16, 16);
-    Assert (!mWarningIcon.isNull());
-
-    mErrorIcon = UIIconPool::defaultIcon(UIIconPool::UIDefaultIconType_MessageBoxCritical).pixmap (16, 16);
-    Assert (!mErrorIcon.isNull());
-
-    /* Re-enumerate uimedium since they contain some translations too: */
-    if (mValid)
-        startMediumEnumeration();
-
-#ifdef VBOX_WS_X11
-    /* As X11 do not have functionality for providing human readable key names,
-     * we keep a table of them, which must be updated when the language is changed. */
-    UINativeHotKey::retranslateKeyNames();
-#endif /* VBOX_WS_X11 */
-}
-
-// public static stuff
-////////////////////////////////////////////////////////////////////////////////
-
-/* static */
-bool VBoxGlobal::isDOSType (const QString &aOSTypeId)
-{
-    if (aOSTypeId.left (3) == "dos" ||
-        aOSTypeId.left (3) == "win" ||
-        aOSTypeId.left (3) == "os2")
-        return true;
-
-    return false;
-}
-
-class VBoxTranslator : public QTranslator
-{
-public:
-
-    VBoxTranslator (QObject *aParent = 0)
-        : QTranslator (aParent) {}
-
-    bool loadFile (const QString &aFileName)
-    {
-        QFile file (aFileName);
-        if (!file.open (QIODevice::ReadOnly))
-            return false;
-        mData = file.readAll();
-        return load ((uchar*) mData.data(), mData.size());
-    }
-
-private:
-
-    QByteArray mData;
-};
-
-static VBoxTranslator *sTranslator = 0;
 
 /* static */
@@ -1821,4 +628,39 @@
 {
     return s_strLoadedLanguageId;
+}
+
+/**
+ *  This does exactly the same as QLocale::system().name() but corrects its
+ *  wrong behavior on Linux systems (LC_NUMERIC for some strange reason takes
+ *  precedence over any other locale setting in the QLocale::system()
+ *  implementation). This implementation first looks at LC_ALL (as defined by
+ *  SUS), then looks at LC_MESSAGES which is designed to define a language for
+ *  program messages in case if it differs from the language for other locale
+ *  categories. Then it looks for LANG and finally falls back to
+ *  QLocale::system().name().
+ *
+ *  The order of precedence is well defined here:
+ *  http://opengroup.org/onlinepubs/007908799/xbd/envvar.html
+ *
+ *  @note This method will return "C" when the requested locale is invalid or
+ *  when the "C" locale is set explicitly.
+ */
+/* static */
+QString VBoxGlobal::systemLanguageId()
+{
+#if defined (VBOX_WS_MAC)
+    /* QLocale return the right id only if the user select the format of the
+     * language also. So we use our own implementation */
+    return ::darwinSystemLanguage();
+#elif defined (Q_OS_UNIX)
+    const char *s = RTEnvGet ("LC_ALL");
+    if (s == 0)
+        s = RTEnvGet ("LC_MESSAGES");
+    if (s == 0)
+        s = RTEnvGet ("LANG");
+    if (s != 0)
+        return QLocale (s).name();
+#endif
+    return  QLocale::system().name();
 }
 
@@ -1970,324 +812,4 @@
 }
 
-QString VBoxGlobal::helpFile() const
-{
-#if defined (VBOX_WS_WIN)
-    const QString name = "VirtualBox";
-    const QString suffix = "chm";
-#elif defined (VBOX_WS_MAC)
-    const QString name = "UserManual";
-    const QString suffix = "pdf";
-#elif defined (VBOX_WS_X11)
-# if defined VBOX_OSE
-    const QString name = "UserManual";
-    const QString suffix = "pdf";
-# else
-    const QString name = "VirtualBox";
-    const QString suffix = "chm";
-# endif
-#endif
-    /* Where are the docs located? */
-    char szDocsPath[RTPATH_MAX];
-    int rc = RTPathAppDocs (szDocsPath, sizeof (szDocsPath));
-    AssertRC (rc);
-    /* Make sure that the language is in two letter code.
-     * Note: if languageId() returns an empty string lang.name() will
-     * return "C" which is an valid language code. */
-    QLocale lang (VBoxGlobal::languageId());
-
-    /* Construct the path and the filename */
-    QString manual = QString ("%1/%2_%3.%4").arg (szDocsPath)
-                                            .arg (name)
-                                            .arg (lang.name())
-                                            .arg (suffix);
-    /* Check if a help file with that name exists */
-    QFileInfo fi (manual);
-    if (fi.exists())
-        return manual;
-
-    /* Fall back to the standard */
-    manual = QString ("%1/%2.%4").arg (szDocsPath)
-                                 .arg (name)
-                                 .arg (suffix);
-    return manual;
-}
-
-/**
- *  Replacement for QToolButton::setTextLabel() that handles the shortcut
- *  letter (if it is present in the argument string) as if it were a setText()
- *  call: the shortcut letter is used to automatically assign an "Alt+<letter>"
- *  accelerator key sequence to the given tool button.
- *
- *  @note This method preserves the icon set if it was assigned before. Only
- *  the text label and the accelerator are changed.
- *
- *  @param aToolButton  Tool button to set the text label on.
- *  @param aTextLabel   Text label to set.
- */
-/* static */
-void VBoxGlobal::setTextLabel (QToolButton *aToolButton,
-                               const QString &aTextLabel)
-{
-    AssertReturnVoid (aToolButton != NULL);
-
-    /* remember the icon set as setText() will kill it */
-    QIcon iset = aToolButton->icon();
-    /* re-use the setText() method to detect and set the accelerator */
-    aToolButton->setText (aTextLabel);
-    QKeySequence accel = aToolButton->shortcut();
-    aToolButton->setText (aTextLabel);
-    aToolButton->setIcon (iset);
-    /* set the accel last as setIconSet() would kill it */
-    aToolButton->setShortcut (accel);
-}
-
-/**
- *  Performs direct and flipped search of position for \a aRectangle to make sure
- *  it is fully contained inside \a aBoundRegion region by moving & resizing
- *  \a aRectangle if necessary. Selects the minimum shifted result between direct
- *  and flipped variants.
- */
-/* static */
-QRect VBoxGlobal::normalizeGeometry (const QRect &aRectangle, const QRegion &aBoundRegion,
-                                     bool aCanResize /* = true */)
-{
-    /* Direct search for normalized rectangle */
-    QRect var1 (getNormalized (aRectangle, aBoundRegion, aCanResize));
-
-    /* Flipped search for normalized rectangle */
-    QRect var2 (flip (getNormalized (flip (aRectangle).boundingRect(),
-                                     flip (aBoundRegion), aCanResize)).boundingRect());
-
-    /* Calculate shift from starting position for both variants */
-    double length1 = sqrt (pow ((double) (var1.x() - aRectangle.x()), (double) 2) +
-                           pow ((double) (var1.y() - aRectangle.y()), (double) 2));
-    double length2 = sqrt (pow ((double) (var2.x() - aRectangle.x()), (double) 2) +
-                           pow ((double) (var2.y() - aRectangle.y()), (double) 2));
-
-    /* Return minimum shifted variant */
-    return length1 > length2 ? var2 : var1;
-}
-
-/**
- *  Ensures that the given rectangle \a aRectangle is fully contained within the
- *  region \a aBoundRegion by moving \a aRectangle if necessary. If \a aRectangle is
- *  larger than \a aBoundRegion, top left corner of \a aRectangle is aligned with the
- *  top left corner of maximum available rectangle and, if \a aCanResize is true,
- *  \a aRectangle is shrinked to become fully visible.
- */
-/* static */
-QRect VBoxGlobal::getNormalized (const QRect &aRectangle, const QRegion &aBoundRegion,
-                                 bool /* aCanResize = true */)
-{
-    /* Storing available horizontal sub-rectangles & vertical shifts */
-    int windowVertical = aRectangle.center().y();
-    QVector <QRect> rectanglesVector (aBoundRegion.rects());
-    QList <QRect> rectanglesList;
-    QList <int> shiftsList;
-    foreach (QRect currentItem, rectanglesVector)
-    {
-        int currentDelta = qAbs (windowVertical - currentItem.center().y());
-        int shift2Top = currentItem.top() - aRectangle.top();
-        int shift2Bot = currentItem.bottom() - aRectangle.bottom();
-
-        int itemPosition = 0;
-        foreach (QRect item, rectanglesList)
-        {
-            int delta = qAbs (windowVertical - item.center().y());
-            if (delta > currentDelta) break; else ++ itemPosition;
-        }
-        rectanglesList.insert (itemPosition, currentItem);
-
-        int shift2TopPos = 0;
-        foreach (int shift, shiftsList)
-            if (qAbs (shift) > qAbs (shift2Top)) break; else ++ shift2TopPos;
-        shiftsList.insert (shift2TopPos, shift2Top);
-
-        int shift2BotPos = 0;
-        foreach (int shift, shiftsList)
-            if (qAbs (shift) > qAbs (shift2Bot)) break; else ++ shift2BotPos;
-        shiftsList.insert (shift2BotPos, shift2Bot);
-    }
-
-    /* Trying to find the appropriate place for window */
-    QRect result;
-    for (int i = -1; i < shiftsList.size(); ++ i)
-    {
-        /* Move to appropriate vertical */
-        QRect rectangle (aRectangle);
-        if (i >= 0) rectangle.translate (0, shiftsList [i]);
-
-        /* Search horizontal shift */
-        int maxShift = 0;
-        foreach (QRect item, rectanglesList)
-        {
-            QRect trectangle (rectangle.translated (item.left() - rectangle.left(), 0));
-            if (!item.intersects (trectangle))
-                continue;
-
-            if (rectangle.left() < item.left())
-            {
-                int shift = item.left() - rectangle.left();
-                maxShift = qAbs (shift) > qAbs (maxShift) ? shift : maxShift;
-            }
-            else if (rectangle.right() > item.right())
-            {
-                int shift = item.right() - rectangle.right();
-                maxShift = qAbs (shift) > qAbs (maxShift) ? shift : maxShift;
-            }
-        }
-
-        /* Shift across the horizontal direction */
-        rectangle.translate (maxShift, 0);
-
-        /* Check the translated rectangle to feat the rules */
-        if (aBoundRegion.united (rectangle) == aBoundRegion)
-            result = rectangle;
-
-        if (!result.isNull()) break;
-    }
-
-    if (result.isNull())
-    {
-        /* Resize window to feat desirable size
-         * using max of available rectangles */
-        QRect maxRectangle;
-        quint64 maxSquare = 0;
-        foreach (QRect item, rectanglesList)
-        {
-            quint64 square = item.width() * item.height();
-            if (square > maxSquare)
-            {
-                maxSquare = square;
-                maxRectangle = item;
-            }
-        }
-
-        result = aRectangle;
-        result.moveTo (maxRectangle.x(), maxRectangle.y());
-        if (maxRectangle.right() < result.right())
-            result.setRight (maxRectangle.right());
-        if (maxRectangle.bottom() < result.bottom())
-            result.setBottom (maxRectangle.bottom());
-    }
-
-    return result;
-}
-
-/**
- *  Returns the flipped (transposed) region.
- */
-/* static */
-QRegion VBoxGlobal::flip (const QRegion &aRegion)
-{
-    QRegion result;
-    QVector <QRect> rectangles (aRegion.rects());
-    foreach (QRect rectangle, rectangles)
-        result += QRect (rectangle.y(), rectangle.x(),
-                         rectangle.height(), rectangle.width());
-    return result;
-}
-
-/**
- *  Aligns the center of \a aWidget with the center of \a aRelative.
- *
- *  If necessary, \a aWidget's position is adjusted to make it fully visible
- *  within the available desktop area. If \a aWidget is bigger then this area,
- *  it will also be resized unless \a aCanResize is false or there is an
- *  inappropriate minimum size limit (in which case the top left corner will be
- *  simply aligned with the top left corner of the available desktop area).
- *
- *  \a aWidget must be a top-level widget. \a aRelative may be any widget, but
- *  if it's not top-level itself, its top-level widget will be used for
- *  calculations. \a aRelative can also be NULL, in which case \a aWidget will
- *  be centered relative to the available desktop area.
- */
-/* static */
-void VBoxGlobal::centerWidget (QWidget *aWidget, QWidget *aRelative,
-                               bool aCanResize /* = true */)
-{
-    AssertReturnVoid (aWidget);
-    AssertReturnVoid (aWidget->isTopLevel());
-
-    QRect deskGeo, parentGeo;
-    QWidget *w = aRelative;
-    if (w)
-    {
-        w = w->window();
-        deskGeo = gpDesktop->availableGeometry (w);
-        parentGeo = w->frameGeometry();
-        /* On X11/Gnome, geo/frameGeo.x() and y() are always 0 for top level
-         * widgets with parents, what a shame. Use mapToGlobal() to workaround. */
-        QPoint d = w->mapToGlobal (QPoint (0, 0));
-        d.rx() -= w->geometry().x() - w->x();
-        d.ry() -= w->geometry().y() - w->y();
-        parentGeo.moveTopLeft (d);
-    }
-    else
-    {
-        deskGeo = gpDesktop->availableGeometry();
-        parentGeo = deskGeo;
-    }
-
-    /* On X11, there is no way to determine frame geometry (including WM
-     * decorations) before the widget is shown for the first time. Stupidly
-     * enumerate other top level widgets to find the thickest frame. The code
-     * is based on the idea taken from QDialog::adjustPositionInternal(). */
-
-    int extraw = 0, extrah = 0;
-
-    QWidgetList list = QApplication::topLevelWidgets();
-    QListIterator<QWidget*> it (list);
-    while ((extraw == 0 || extrah == 0) && it.hasNext())
-    {
-        int framew, frameh;
-        QWidget *current = it.next();
-        if (!current->isVisible())
-            continue;
-
-        framew = current->frameGeometry().width() - current->width();
-        frameh = current->frameGeometry().height() - current->height();
-
-        extraw = qMax (extraw, framew);
-        extrah = qMax (extrah, frameh);
-    }
-
-    /// @todo (r=dmik) not sure if we really need this
-#if 0
-    /* sanity check for decoration frames. With embedding, we
-     * might get extraordinary values */
-    if (extraw == 0 || extrah == 0 || extraw > 20 || extrah > 50)
-    {
-        extrah = 50;
-        extraw = 20;
-    }
-#endif
-
-    /* On non-X11 platforms, the following would be enough instead of the
-     * above workaround: */
-    // QRect geo = frameGeometry();
-    QRect geo = QRect (0, 0, aWidget->width() + extraw,
-                             aWidget->height() + extrah);
-
-    geo.moveCenter (QPoint (parentGeo.x() + (parentGeo.width() - 1) / 2,
-                            parentGeo.y() + (parentGeo.height() - 1) / 2));
-
-    /* ensure the widget is within the available desktop area */
-    QRect newGeo = normalizeGeometry (geo, deskGeo, aCanResize);
-#ifdef VBOX_WS_MAC
-    /* No idea why, but Qt doesn't respect if there is a unified toolbar on the
-     * ::move call. So manually add the height of the toolbar before setting
-     * the position. */
-    if (w)
-        newGeo.translate (0, ::darwinWindowToolBarHeight (aWidget));
-#endif /* VBOX_WS_MAC */
-
-    aWidget->move (newGeo.topLeft());
-
-    if (aCanResize &&
-        (geo.width() != newGeo.width() || geo.height() != newGeo.height()))
-        aWidget->resize (newGeo.width() - extraw, newGeo.height() - extrah);
-}
-
 /**
  *  Returns the decimal separator for the current locale.
@@ -2487,83 +1009,112 @@
 }
 
-/**
- *  Returns the required video memory in bytes for the current desktop
- *  resolution at maximum possible screen depth in bpp.
- */
-/* static */
-quint64 VBoxGlobal::requiredVideoMemory(const QString &strGuestOSTypeId, int cMonitors /* = 1 */)
-{
-    /* We create a list of the size of all available host monitors. This list
-     * is sorted by value and by starting with the biggest one, we calculate
-     * the memory requirements for every guest screen. This is of course not
-     * correct, but as we can't predict on which host screens the user will
-     * open the guest windows, this is the best assumption we can do, cause it
-     * is the worst case. */
-    const int cHostScreens = gpDesktop->screenCount();
-    QVector<int> screenSize(qMax(cMonitors, cHostScreens), 0);
-    for (int i = 0; i < cHostScreens; ++i)
-    {
-        QRect r = gpDesktop->screenGeometry(i);
-        screenSize[i] = r.width() * r.height();
-    }
-    /* Now sort the vector */
-    qSort(screenSize.begin(), screenSize.end(), qGreater<int>());
-    /* For the case that there are more guest screens configured then host
-     * screens available, replace all zeros with the greatest value in the
-     * vector. */
-    for (int i = 0; i < screenSize.size(); ++i)
-        if (screenSize.at(i) == 0)
-            screenSize.replace(i, screenSize.at(0));
-
-    quint64 needBits = 0;
-    for (int i = 0; i < cMonitors; ++i)
-    {
-        /* Calculate summary required memory amount in bits */
-        needBits += (screenSize.at(i) * /* with x height */
-                     32 + /* we will take the maximum possible bpp for now */
-                     8 * _1M) + /* current cache per screen - may be changed in future */
-                    8 * 4096; /* adapter info */
-    }
-    /* Translate value into megabytes with rounding to highest side */
-    quint64 needMBytes = needBits % (8 * _1M) ? needBits / (8 * _1M) + 1 :
-                         needBits / (8 * _1M) /* convert to megabytes */;
-
-    if (strGuestOSTypeId.startsWith("Windows"))
-    {
-       /* Windows guests need offscreen VRAM too for graphics acceleration features: */
-#ifdef VBOX_WITH_CRHGSMI
-       if (isWddmCompatibleOsType(strGuestOSTypeId))
-       {
-           /* wddm mode, there are two surfaces for each screen: shadow & primary */
-           needMBytes *= 3;
-       }
-       else
-#endif /* VBOX_WITH_CRHGSMI */
-       {
-           needMBytes *= 2;
-       }
-    }
-
-    return needMBytes * _1M;
-}
-
-/**
- * Puts soft hyphens after every path component in the given file name.
- *
- * @param aFileName File name (must be a full path name).
- */
-/* static */
-QString VBoxGlobal::locationForHTML (const QString &aFileName)
-{
-/// @todo (dmik) remove?
-//    QString result = QDir::toNativeSeparators (fn);
-//#ifdef Q_OS_LINUX
-//    result.replace ('/', "/<font color=red>&shy;</font>");
-//#else
-//    result.replace ('\\', "\\<font color=red>&shy;</font>");
-//#endif
-//    return result;
-    QFileInfo fi (aFileName);
-    return fi.fileName();
+/* static */
+QString VBoxGlobal::fullMediumFormatName(const QString &strBaseMediumFormatName)
+{
+    if (strBaseMediumFormatName == "VDI")
+        return tr("VDI (VirtualBox Disk Image)");
+    else if (strBaseMediumFormatName == "VMDK")
+        return tr("VMDK (Virtual Machine Disk)");
+    else if (strBaseMediumFormatName == "VHD")
+        return tr("VHD (Virtual Hard Disk)");
+    else if (strBaseMediumFormatName == "Parallels")
+        return tr("HDD (Parallels Hard Disk)");
+    else if (strBaseMediumFormatName == "QED")
+        return tr("QED (QEMU enhanced disk)");
+    else if (strBaseMediumFormatName == "QCOW")
+        return tr("QCOW (QEMU Copy-On-Write)");
+    return strBaseMediumFormatName;
+}
+
+/**
+ *  Returns the list of the standard COM port names (i.e. "COMx").
+ */
+QStringList VBoxGlobal::COMPortNames() const
+{
+    QStringList list;
+    for (size_t i = 0; i < RT_ELEMENTS (kComKnownPorts); ++ i)
+        list << kComKnownPorts [i].name;
+
+    return list;
+}
+
+/**
+ *  Returns the name of the standard COM port corresponding to the given
+ *  parameters, or "User-defined" (which is also returned when both
+ *  @a aIRQ and @a aIOBase are 0).
+ */
+QString VBoxGlobal::toCOMPortName (ulong aIRQ, ulong aIOBase) const
+{
+    for (size_t i = 0; i < RT_ELEMENTS (kComKnownPorts); ++ i)
+        if (kComKnownPorts [i].IRQ == aIRQ &&
+            kComKnownPorts [i].IOBase == aIOBase)
+            return kComKnownPorts [i].name;
+
+    return mUserDefinedPortName;
+}
+
+/**
+ *  Returns port parameters corresponding to the given standard COM name.
+ *  Returns @c true on success, or @c false if the given port name is not one
+ *  of the standard names (i.e. "COMx").
+ */
+bool VBoxGlobal::toCOMPortNumbers (const QString &aName, ulong &aIRQ,
+                                   ulong &aIOBase) const
+{
+    for (size_t i = 0; i < RT_ELEMENTS (kComKnownPorts); ++ i)
+        if (strcmp (kComKnownPorts [i].name, aName.toUtf8().data()) == 0)
+        {
+            aIRQ = kComKnownPorts [i].IRQ;
+            aIOBase = kComKnownPorts [i].IOBase;
+            return true;
+        }
+
+    return false;
+}
+
+/**
+ *  Returns the list of the standard LPT port names (i.e. "LPTx").
+ */
+QStringList VBoxGlobal::LPTPortNames() const
+{
+    QStringList list;
+    for (size_t i = 0; i < RT_ELEMENTS (kLptKnownPorts); ++ i)
+        list << kLptKnownPorts [i].name;
+
+    return list;
+}
+
+/**
+ *  Returns the name of the standard LPT port corresponding to the given
+ *  parameters, or "User-defined" (which is also returned when both
+ *  @a aIRQ and @a aIOBase are 0).
+ */
+QString VBoxGlobal::toLPTPortName (ulong aIRQ, ulong aIOBase) const
+{
+    for (size_t i = 0; i < RT_ELEMENTS (kLptKnownPorts); ++ i)
+        if (kLptKnownPorts [i].IRQ == aIRQ &&
+            kLptKnownPorts [i].IOBase == aIOBase)
+            return kLptKnownPorts [i].name;
+
+    return mUserDefinedPortName;
+}
+
+/**
+ *  Returns port parameters corresponding to the given standard LPT name.
+ *  Returns @c true on success, or @c false if the given port name is not one
+ *  of the standard names (i.e. "LPTx").
+ */
+bool VBoxGlobal::toLPTPortNumbers (const QString &aName, ulong &aIRQ,
+                                   ulong &aIOBase) const
+{
+    for (size_t i = 0; i < RT_ELEMENTS (kLptKnownPorts); ++ i)
+        if (strcmp (kLptKnownPorts [i].name, aName.toUtf8().data()) == 0)
+        {
+            aIRQ = kLptKnownPorts [i].IRQ;
+            aIOBase = kLptKnownPorts [i].IOBase;
+            return true;
+        }
+
+    return false;
 }
 
@@ -2625,14 +1176,4 @@
 }
 
-/* static */
-QString VBoxGlobal::replaceHtmlEntities(QString strText)
-{
-    return strText
-        .replace('&', "&amp;")
-        .replace('<', "&lt;")
-        .replace('>', "&gt;")
-        .replace('\"', "&quot;");
-}
-
 /**
  *  Reformats the input string @a aStr so that:
@@ -2680,378 +1221,4 @@
     return text;
 }
-
-/**
- *  This does exactly the same as QLocale::system().name() but corrects its
- *  wrong behavior on Linux systems (LC_NUMERIC for some strange reason takes
- *  precedence over any other locale setting in the QLocale::system()
- *  implementation). This implementation first looks at LC_ALL (as defined by
- *  SUS), then looks at LC_MESSAGES which is designed to define a language for
- *  program messages in case if it differs from the language for other locale
- *  categories. Then it looks for LANG and finally falls back to
- *  QLocale::system().name().
- *
- *  The order of precedence is well defined here:
- *  http://opengroup.org/onlinepubs/007908799/xbd/envvar.html
- *
- *  @note This method will return "C" when the requested locale is invalid or
- *  when the "C" locale is set explicitly.
- */
-/* static */
-QString VBoxGlobal::systemLanguageId()
-{
-#if defined (VBOX_WS_MAC)
-    /* QLocale return the right id only if the user select the format of the
-     * language also. So we use our own implementation */
-    return ::darwinSystemLanguage();
-#elif defined (Q_OS_UNIX)
-    const char *s = RTEnvGet ("LC_ALL");
-    if (s == 0)
-        s = RTEnvGet ("LC_MESSAGES");
-    if (s == 0)
-        s = RTEnvGet ("LANG");
-    if (s != 0)
-        return QLocale (s).name();
-#endif
-    return  QLocale::system().name();
-}
-
-#if defined (VBOX_WS_X11)
-
-static char *XXGetProperty (Display *aDpy, Window aWnd,
-                            Atom aPropType, const char *aPropName)
-{
-    Atom propNameAtom = XInternAtom (aDpy, aPropName,
-                                     True /* only_if_exists */);
-    if (propNameAtom == None)
-        return NULL;
-
-    Atom actTypeAtom = None;
-    int actFmt = 0;
-    unsigned long nItems = 0;
-    unsigned long nBytesAfter = 0;
-    unsigned char *propVal = NULL;
-    int rc = XGetWindowProperty (aDpy, aWnd, propNameAtom,
-                                 0, LONG_MAX, False /* delete */,
-                                 aPropType, &actTypeAtom, &actFmt,
-                                 &nItems, &nBytesAfter, &propVal);
-    if (rc != Success)
-        return NULL;
-
-    return reinterpret_cast <char *> (propVal);
-}
-
-static Bool XXSendClientMessage (Display *aDpy, Window aWnd, const char *aMsg,
-                                 unsigned long aData0 = 0, unsigned long aData1 = 0,
-                                 unsigned long aData2 = 0, unsigned long aData3 = 0,
-                                 unsigned long aData4 = 0)
-{
-    Atom msgAtom = XInternAtom (aDpy, aMsg, True /* only_if_exists */);
-    if (msgAtom == None)
-        return False;
-
-    XEvent ev;
-
-    ev.xclient.type = ClientMessage;
-    ev.xclient.serial = 0;
-    ev.xclient.send_event = True;
-    ev.xclient.display = aDpy;
-    ev.xclient.window = aWnd;
-    ev.xclient.message_type = msgAtom;
-
-    /* always send as 32 bit for now */
-    ev.xclient.format = 32;
-    ev.xclient.data.l [0] = aData0;
-    ev.xclient.data.l [1] = aData1;
-    ev.xclient.data.l [2] = aData2;
-    ev.xclient.data.l [3] = aData3;
-    ev.xclient.data.l [4] = aData4;
-
-    return XSendEvent (aDpy, DefaultRootWindow (aDpy), False,
-                       SubstructureRedirectMask, &ev) != 0;
-}
-
-#endif
-
-/**
- * Activates the specified window. If necessary, the window will be
- * de-iconified activation.
- *
- * @note On X11, it is implied that @a aWid represents a window of the same
- * display the application was started on.
- *
- * @param aWId              Window ID to activate.
- * @param aSwitchDesktop    @c true to switch to the window's desktop before
- *                          activation.
- *
- * @return @c true on success and @c false otherwise.
- */
-/* static */
-bool VBoxGlobal::activateWindow (WId aWId, bool aSwitchDesktop /* = true */)
-{
-    RT_NOREF(aSwitchDesktop);
-    bool result = true;
-
-#if defined (VBOX_WS_WIN)
-
-    HWND handle = (HWND)aWId;
-
-    if (IsIconic (handle))
-        result &= !!ShowWindow (handle, SW_RESTORE);
-    else if (!IsWindowVisible (handle))
-        result &= !!ShowWindow (handle, SW_SHOW);
-
-    result &= !!SetForegroundWindow (handle);
-
-#elif defined (VBOX_WS_X11)
-
-    Display *dpy = QX11Info::display();
-
-    if (aSwitchDesktop)
-    {
-        /* try to find the desktop ID using the NetWM property */
-        CARD32 *desktop = (CARD32 *) XXGetProperty (dpy, aWId, XA_CARDINAL,
-                                                    "_NET_WM_DESKTOP");
-        if (desktop == NULL)
-            /* if the NetWM properly is not supported try to find the desktop
-             * ID using the GNOME WM property */
-            desktop = (CARD32 *) XXGetProperty (dpy, aWId, XA_CARDINAL,
-                                                "_WIN_WORKSPACE");
-
-        if (desktop != NULL)
-        {
-            Bool ok = XXSendClientMessage (dpy, DefaultRootWindow (dpy),
-                                           "_NET_CURRENT_DESKTOP",
-                                           *desktop);
-            if (!ok)
-            {
-                Log1WarningFunc(("Couldn't switch to desktop=%08X\n", desktop));
-                result = false;
-            }
-            XFree (desktop);
-        }
-        else
-        {
-            Log1WarningFunc(("Couldn't find a desktop ID for aWId=%08X\n", aWId));
-            result = false;
-        }
-    }
-
-    Bool ok = XXSendClientMessage (dpy, aWId, "_NET_ACTIVE_WINDOW");
-    result &= !!ok;
-
-    XRaiseWindow (dpy, aWId);
-
-#else
-
-    NOREF (aWId);
-    NOREF (aSwitchDesktop);
-    AssertFailed();
-    result = false;
-
-#endif
-
-    if (!result)
-        Log1WarningFunc(("Couldn't activate aWId=%08X\n", aWId));
-
-    return result;
-}
-
-#ifdef VBOX_WS_X11
-/* This method tests whether the current X11 window manager supports full-screen mode as we need it.
- * Unfortunately the EWMH specification was not fully clear about whether we can expect to find
- * all of these atoms on the _NET_SUPPORTED root window property, so we have to test with all
- * interesting window managers. If this fails for a user when you think it should succeed
- * they should try executing:
- * xprop -root | egrep -w '_NET_WM_FULLSCREEN_MONITORS|_NET_WM_STATE|_NET_WM_STATE_FULLSCREEN'
- * in an X11 terminal window.
- * All three strings should be found under a property called "_NET_SUPPORTED(ATOM)". */
-/* static */
-bool VBoxGlobal::supportsFullScreenMonitorsProtocolX11()
-{
-    /* Using a global to get at the display does not feel right, but that is
-     * how it is done elsewhere in the code. */
-    Display *pDisplay = QX11Info::display();
-    Atom atomSupported            = XInternAtom(pDisplay, "_NET_SUPPORTED",
-                                                True /* only_if_exists */);
-    Atom atomWMFullScreenMonitors = XInternAtom(pDisplay,
-                                                "_NET_WM_FULLSCREEN_MONITORS",
-                                                True /* only_if_exists */);
-    Atom atomWMState              = XInternAtom(pDisplay,
-                                                "_NET_WM_STATE",
-                                                True /* only_if_exists */);
-    Atom atomWMStateFullScreen    = XInternAtom(pDisplay,
-                                                "_NET_WM_STATE_FULLSCREEN",
-                                                True /* only_if_exists */);
-    bool fFoundFullScreenMonitors = false;
-    bool fFoundState              = false;
-    bool fFoundStateFullScreen    = false;
-    Atom atomType;
-    int cFormat;
-    unsigned long cItems;
-    unsigned long cbLeft;
-    Atom *pAtomHints;
-    int rc;
-    unsigned i;
-
-    if (   atomSupported == None || atomWMFullScreenMonitors == None
-        || atomWMState == None || atomWMStateFullScreen == None)
-        return false;
-    /* Get atom value: */
-    rc = XGetWindowProperty(pDisplay, DefaultRootWindow(pDisplay),
-                            atomSupported, 0, 0x7fffffff /*LONG_MAX*/,
-                            False /* delete */, XA_ATOM, &atomType,
-                            &cFormat, &cItems, &cbLeft,
-                            (unsigned char **)&pAtomHints);
-    if (rc != Success)
-        return false;
-    if (pAtomHints == NULL)
-        return false;
-    if (atomType == XA_ATOM && cFormat == 32 && cbLeft == 0)
-        for (i = 0; i < cItems; ++i)
-        {
-            if (pAtomHints[i] == atomWMFullScreenMonitors)
-                fFoundFullScreenMonitors = true;
-            if (pAtomHints[i] == atomWMState)
-                fFoundState = true;
-            if (pAtomHints[i] == atomWMStateFullScreen)
-                fFoundStateFullScreen = true;
-        }
-    XFree(pAtomHints);
-    return fFoundFullScreenMonitors && fFoundState && fFoundStateFullScreen;
-}
-
-/* static */
-bool VBoxGlobal::setFullScreenMonitorX11(QWidget *pWidget, ulong uScreenId)
-{
-    return XXSendClientMessage(QX11Info::display(),
-                               pWidget->window()->winId(),
-                               "_NET_WM_FULLSCREEN_MONITORS",
-                               uScreenId, uScreenId, uScreenId, uScreenId,
-                               1 /* Source indication (1 = normal application) */);
-}
-
-/* static */
-QVector<Atom> VBoxGlobal::flagsNetWmState(QWidget *pWidget)
-{
-    /* Get display: */
-    Display *pDisplay = QX11Info::display();
-
-    /* Prepare atoms: */
-    QVector<Atom> resultNetWmState;
-    Atom net_wm_state = XInternAtom(pDisplay, "_NET_WM_STATE", True /* only if exists */);
-
-    /* Get the size of the property data: */
-    Atom actual_type;
-    int iActualFormat;
-    ulong uPropertyLength;
-    ulong uBytesLeft;
-    uchar *pPropertyData = 0;
-    if (XGetWindowProperty(pDisplay, pWidget->window()->winId(),
-                           net_wm_state, 0, 0, False, XA_ATOM, &actual_type, &iActualFormat,
-                           &uPropertyLength, &uBytesLeft, &pPropertyData) == Success &&
-        actual_type == XA_ATOM && iActualFormat == 32)
-    {
-        resultNetWmState.resize(uBytesLeft / 4);
-        XFree((char*)pPropertyData);
-        pPropertyData = 0;
-
-        /* Fetch all data: */
-        if (XGetWindowProperty(pDisplay, pWidget->window()->winId(),
-                               net_wm_state, 0, resultNetWmState.size(), False, XA_ATOM, &actual_type, &iActualFormat,
-                               &uPropertyLength, &uBytesLeft, &pPropertyData) != Success)
-            resultNetWmState.clear();
-        else if (uPropertyLength != (ulong)resultNetWmState.size())
-            resultNetWmState.resize(uPropertyLength);
-
-        /* Put it into resultNetWmState: */
-        if (!resultNetWmState.isEmpty())
-            memcpy(resultNetWmState.data(), pPropertyData, resultNetWmState.size() * sizeof(Atom));
-        if (pPropertyData)
-            XFree((char*)pPropertyData);
-    }
-
-    /* Return result: */
-    return resultNetWmState;
-}
-
-/* static */
-bool VBoxGlobal::isFullScreenFlagSet(QWidget *pWidget)
-{
-    /* Get display: */
-    Display *pDisplay = QX11Info::display();
-
-    /* Prepare atoms: */
-    Atom net_wm_state_fullscreen = XInternAtom(pDisplay, "_NET_WM_STATE_FULLSCREEN", True /* only if exists */);
-
-    /* Check if flagsNetWmState(pWidget) contains full-screen flag: */
-    return flagsNetWmState(pWidget).contains(net_wm_state_fullscreen);
-}
-
-/* static */
-void VBoxGlobal::setFullScreenFlag(QWidget *pWidget)
-{
-    /* Get display: */
-    Display *pDisplay = QX11Info::display();
-
-    /* Prepare atoms: */
-    QVector<Atom> resultNetWmState = flagsNetWmState(pWidget);
-    Atom net_wm_state = XInternAtom(pDisplay, "_NET_WM_STATE", True /* only if exists */);
-    Atom net_wm_state_fullscreen = XInternAtom(pDisplay, "_NET_WM_STATE_FULLSCREEN", True /* only if exists */);
-
-    /* Append resultNetWmState with fullscreen flag if necessary: */
-    if (!resultNetWmState.contains(net_wm_state_fullscreen))
-    {
-        resultNetWmState.append(net_wm_state_fullscreen);
-        /* Apply property to widget again: */
-        XChangeProperty(pDisplay, pWidget->window()->winId(),
-                        net_wm_state, XA_ATOM, 32, PropModeReplace,
-                        (unsigned char*)resultNetWmState.data(), resultNetWmState.size());
-    }
-}
-
-/* static */
-void VBoxGlobal::setSkipTaskBarFlag(QWidget *pWidget)
-{
-    /* Get display: */
-    Display *pDisplay = QX11Info::display();
-
-    /* Prepare atoms: */
-    QVector<Atom> resultNetWmState = flagsNetWmState(pWidget);
-    Atom net_wm_state = XInternAtom(pDisplay, "_NET_WM_STATE", True /* only if exists */);
-    Atom net_wm_state_skip_taskbar = XInternAtom(pDisplay, "_NET_WM_STATE_SKIP_TASKBAR", True /* only if exists */);
-
-    /* Append resultNetWmState with skip-taskbar flag if necessary: */
-    if (!resultNetWmState.contains(net_wm_state_skip_taskbar))
-    {
-        resultNetWmState.append(net_wm_state_skip_taskbar);
-        /* Apply property to widget again: */
-        XChangeProperty(pDisplay, pWidget->window()->winId(),
-                        net_wm_state, XA_ATOM, 32, PropModeReplace,
-                        (unsigned char*)resultNetWmState.data(), resultNetWmState.size());
-    }
-}
-
-/* static */
-void VBoxGlobal::setSkipPagerFlag(QWidget *pWidget)
-{
-    /* Get display: */
-    Display *pDisplay = QX11Info::display();
-
-    /* Prepare atoms: */
-    QVector<Atom> resultNetWmState = flagsNetWmState(pWidget);
-    Atom net_wm_state = XInternAtom(pDisplay, "_NET_WM_STATE", True /* only if exists */);
-    Atom net_wm_state_skip_pager = XInternAtom(pDisplay, "_NET_WM_STATE_SKIP_PAGER", True /* only if exists */);
-
-    /* Append resultNetWmState with skip-pager flag if necessary: */
-    if (!resultNetWmState.contains(net_wm_state_skip_pager))
-    {
-        resultNetWmState.append(net_wm_state_skip_pager);
-        /* Apply property to widget again: */
-        XChangeProperty(pDisplay, pWidget->window()->winId(),
-                        net_wm_state, XA_ATOM, 32, PropModeReplace,
-                        (unsigned char*)resultNetWmState.data(), resultNetWmState.size());
-    }
-}
-#endif /* VBOX_WS_X11 */
 
 /**
@@ -3107,133 +1274,55 @@
 }
 
-/**
- * Joins two pixmaps horizontally with 2px space between them and returns the
- * result.
- *
- * @param aPM1 Left pixmap.
- * @param aPM2 Right pixmap.
- */
-/* static */
-QPixmap VBoxGlobal::joinPixmaps (const QPixmap &aPM1, const QPixmap &aPM2)
-{
-    if (aPM1.isNull())
-        return aPM2;
-    if (aPM2.isNull())
-        return aPM1;
-
-    QPixmap result (aPM1.width() + aPM2.width() + 2,
-                    qMax (aPM1.height(), aPM2.height()));
-    result.fill (Qt::transparent);
-
-    QPainter painter (&result);
-    painter.drawPixmap (0, 0, aPM1);
-    painter.drawPixmap (aPM1.width() + 2, result.height() - aPM2.height(), aPM2);
-    painter.end();
-
-    return result;
-}
-
-/**
- *  Searches for a widget that with @a aName (if it is not NULL) which inherits
- *  @a aClassName (if it is not NULL) and among children of @a aParent. If @a
- *  aParent is NULL, all top-level widgets are searched. If @a aRecursive is
- *  true, child widgets are recursively searched as well.
- */
-/* static */
-QWidget *VBoxGlobal::findWidget (QWidget *aParent, const char *aName,
-                                 const char *aClassName /* = NULL */,
-                                 bool aRecursive /* = false */)
-{
-    if (aParent == NULL)
-    {
-        QWidgetList list = QApplication::topLevelWidgets();
-        foreach(QWidget *w, list)
-        {
-            if ((!aName || strcmp (w->objectName().toLatin1().constData(), aName) == 0) &&
-                (!aClassName || strcmp (w->metaObject()->className(), aClassName) == 0))
-                return w;
-            if (aRecursive)
-            {
-                w = findWidget (w, aName, aClassName, aRecursive);
-                if (w)
-                    return w;
-            }
-        }
-        return NULL;
-    }
-
-    /* Find the first children of aParent with the appropriate properties.
-     * Please note that this call is recursively. */
-    QList<QWidget *> list = aParent->findChildren<QWidget*>(aName);
-    foreach(QWidget *child, list)
-    {
-        if (!aClassName || strcmp (child->metaObject()->className(), aClassName) == 0)
-            return child;
-    }
-    return NULL;
-}
-
-/**
- * Figures out which medium formats are currently supported by VirtualBox for
- * the given device type.
- * Returned is a list of pairs with the form
- *   <tt>{"Backend Name", "*.suffix1 .suffix2 ..."}</tt>.
- */
-/* static */
-QList <QPair <QString, QString> > VBoxGlobal::MediumBackends(KDeviceType enmType)
-{
-    CSystemProperties systemProperties = vboxGlobal().virtualBox().GetSystemProperties();
-    QVector<CMediumFormat> mediumFormats = systemProperties.GetMediumFormats();
-    QList< QPair<QString, QString> > backendPropList;
-    for (int i = 0; i < mediumFormats.size(); ++ i)
-    {
-        /* File extensions */
-        QVector <QString> fileExtensions;
-        QVector <KDeviceType> deviceTypes;
-
-        mediumFormats [i].DescribeFileExtensions(fileExtensions, deviceTypes);
-
-        QStringList f;
-        for (int a = 0; a < fileExtensions.size(); ++ a)
-            if (deviceTypes [a] == enmType)
-                f << QString ("*.%1").arg (fileExtensions [a]);
-        /* Create a pair out of the backend description and all suffix's. */
-        if (!f.isEmpty())
-            backendPropList << QPair<QString, QString> (mediumFormats [i].GetName(), f.join(" "));
-    }
-    return backendPropList;
-}
-
-/**
- * Figures out which hard disk formats are currently supported by VirtualBox.
- * Returned is a list of pairs with the form
- *   <tt>{"Backend Name", "*.suffix1 .suffix2 ..."}</tt>.
- */
-/* static */
-QList <QPair <QString, QString> > VBoxGlobal::HDDBackends()
-{
-    return MediumBackends(KDeviceType_HardDisk);
-}
-
-/**
- * Figures out which optical disk formats are currently supported by VirtualBox.
- * Returned is a list of pairs with the form
- *   <tt>{"Backend Name", "*.suffix1 .suffix2 ..."}</tt>.
- */
-/* static */
-QList <QPair <QString, QString> > VBoxGlobal::DVDBackends()
-{
-    return MediumBackends(KDeviceType_DVD);
-}
-
-/**
- * Figures out which floppy disk formats are currently supported by VirtualBox.
- * Returned is a list of pairs with the form
- *   <tt>{"Backend Name", "*.suffix1 .suffix2 ..."}</tt>.
- */
-/* static */
-QList <QPair <QString, QString> > VBoxGlobal::FloppyBackends()
-{
-    return MediumBackends(KDeviceType_Floppy);
+/* static */
+QString VBoxGlobal::replaceHtmlEntities(QString strText)
+{
+    return strText
+        .replace('&', "&amp;")
+        .replace('<', "&lt;")
+        .replace('>', "&gt;")
+        .replace('\"', "&quot;");
+}
+
+QString VBoxGlobal::helpFile() const
+{
+#if defined (VBOX_WS_WIN)
+    const QString name = "VirtualBox";
+    const QString suffix = "chm";
+#elif defined (VBOX_WS_MAC)
+    const QString name = "UserManual";
+    const QString suffix = "pdf";
+#elif defined (VBOX_WS_X11)
+# if defined VBOX_OSE
+    const QString name = "UserManual";
+    const QString suffix = "pdf";
+# else
+    const QString name = "VirtualBox";
+    const QString suffix = "chm";
+# endif
+#endif
+    /* Where are the docs located? */
+    char szDocsPath[RTPATH_MAX];
+    int rc = RTPathAppDocs (szDocsPath, sizeof (szDocsPath));
+    AssertRC (rc);
+    /* Make sure that the language is in two letter code.
+     * Note: if languageId() returns an empty string lang.name() will
+     * return "C" which is an valid language code. */
+    QLocale lang (VBoxGlobal::languageId());
+
+    /* Construct the path and the filename */
+    QString manual = QString ("%1/%2_%3.%4").arg (szDocsPath)
+                                            .arg (name)
+                                            .arg (lang.name())
+                                            .arg (suffix);
+    /* Check if a help file with that name exists */
+    QFileInfo fi (manual);
+    if (fi.exists())
+        return manual;
+
+    /* Fall back to the standard */
+    manual = QString ("%1/%2.%4").arg (szDocsPath)
+                                 .arg (name)
+                                 .arg (suffix);
+    return manual;
 }
 
@@ -3255,88 +1344,250 @@
 }
 
-#ifdef VBOX_WITH_CRHGSMI
-/* static */
-bool VBoxGlobal::isWddmCompatibleOsType(const QString &strGuestOSTypeId)
-{
-    return    strGuestOSTypeId.startsWith("WindowsVista")
-           || strGuestOSTypeId.startsWith("Windows7")
-           || strGuestOSTypeId.startsWith("Windows8")
-           || strGuestOSTypeId.startsWith("Windows81")
-           || strGuestOSTypeId.startsWith("Windows10")
-           || strGuestOSTypeId.startsWith("Windows2008")
-           || strGuestOSTypeId.startsWith("Windows2012");
-}
-#endif /* VBOX_WITH_CRHGSMI */
-
-/* static */
-QString VBoxGlobal::fullMediumFormatName(const QString &strBaseMediumFormatName)
-{
-    if (strBaseMediumFormatName == "VDI")
-        return tr("VDI (VirtualBox Disk Image)");
-    else if (strBaseMediumFormatName == "VMDK")
-        return tr("VMDK (Virtual Machine Disk)");
-    else if (strBaseMediumFormatName == "VHD")
-        return tr("VHD (Virtual Hard Disk)");
-    else if (strBaseMediumFormatName == "Parallels")
-        return tr("HDD (Parallels Hard Disk)");
-    else if (strBaseMediumFormatName == "QED")
-        return tr("QED (QEMU enhanced disk)");
-    else if (strBaseMediumFormatName == "QCOW")
-        return tr("QCOW (QEMU Copy-On-Write)");
-    return strBaseMediumFormatName;
-}
-
-#ifdef RT_OS_LINUX
-/* static */
-void VBoxGlobal::checkForWrongUSBMounted()
-{
-    /* Make sure '/proc/mounts' exists and can be opened: */
-    QFile file("/proc/mounts");
-    if (!file.exists() || !file.open(QIODevice::ReadOnly | QIODevice::Text))
-        return;
-
-    /* Fetch contents: */
-    QStringList contents;
-    for (;;)
-    {
-        QByteArray line = file.readLine();
-        if (line.isEmpty())
-            break;
-        contents << line;
-    }
-    /* Grep contents for usbfs presence: */
-    QStringList grep1(contents.filter("/sys/bus/usb/drivers"));
-    QStringList grep2(grep1.filter("usbfs"));
-    if (grep2.isEmpty())
-        return;
-
-    /* Show corresponding warning: */
-    msgCenter().warnAboutWrongUSBMounted();
-}
-#endif /* RT_OS_LINUX */
-
-/* static */
-void VBoxGlobal::setMinimumWidthAccordingSymbolCount(QSpinBox *pSpinBox, int cCount)
-{
-    /* Load options: */
-    QStyleOptionSpinBox option;
-    option.initFrom(pSpinBox);
-
-    /* Acquire edit-field rectangle: */
-    QRect rect = pSpinBox->style()->subControlRect(QStyle::CC_SpinBox,
-                                                   &option,
-                                                   QStyle::SC_SpinBoxEditField,
-                                                   pSpinBox);
-
-    /* Calculate minimum-width magic: */
-    int iSpinBoxWidth = pSpinBox->width();
-    int iSpinBoxEditFieldWidth = rect.width();
-    int iSpinBoxDelta = qMax(0, iSpinBoxWidth - iSpinBoxEditFieldWidth);
-    QFontMetrics metrics(pSpinBox->font(), pSpinBox);
-    QString strDummy(cCount, '0');
-    int iTextWidth = metrics.width(strDummy);
-
-    /* Tune spin-box minimum-width: */
-    pSpinBox->setMinimumWidth(iTextWidth + iSpinBoxDelta);
+/**
+ *  Performs direct and flipped search of position for \a aRectangle to make sure
+ *  it is fully contained inside \a aBoundRegion region by moving & resizing
+ *  \a aRectangle if necessary. Selects the minimum shifted result between direct
+ *  and flipped variants.
+ */
+/* static */
+QRect VBoxGlobal::normalizeGeometry (const QRect &aRectangle, const QRegion &aBoundRegion,
+                                     bool aCanResize /* = true */)
+{
+    /* Direct search for normalized rectangle */
+    QRect var1 (getNormalized (aRectangle, aBoundRegion, aCanResize));
+
+    /* Flipped search for normalized rectangle */
+    QRect var2 (flip (getNormalized (flip (aRectangle).boundingRect(),
+                                     flip (aBoundRegion), aCanResize)).boundingRect());
+
+    /* Calculate shift from starting position for both variants */
+    double length1 = sqrt (pow ((double) (var1.x() - aRectangle.x()), (double) 2) +
+                           pow ((double) (var1.y() - aRectangle.y()), (double) 2));
+    double length2 = sqrt (pow ((double) (var2.x() - aRectangle.x()), (double) 2) +
+                           pow ((double) (var2.y() - aRectangle.y()), (double) 2));
+
+    /* Return minimum shifted variant */
+    return length1 > length2 ? var2 : var1;
+}
+
+/**
+ *  Ensures that the given rectangle \a aRectangle is fully contained within the
+ *  region \a aBoundRegion by moving \a aRectangle if necessary. If \a aRectangle is
+ *  larger than \a aBoundRegion, top left corner of \a aRectangle is aligned with the
+ *  top left corner of maximum available rectangle and, if \a aCanResize is true,
+ *  \a aRectangle is shrinked to become fully visible.
+ */
+/* static */
+QRect VBoxGlobal::getNormalized (const QRect &aRectangle, const QRegion &aBoundRegion,
+                                 bool /* aCanResize = true */)
+{
+    /* Storing available horizontal sub-rectangles & vertical shifts */
+    int windowVertical = aRectangle.center().y();
+    QVector <QRect> rectanglesVector (aBoundRegion.rects());
+    QList <QRect> rectanglesList;
+    QList <int> shiftsList;
+    foreach (QRect currentItem, rectanglesVector)
+    {
+        int currentDelta = qAbs (windowVertical - currentItem.center().y());
+        int shift2Top = currentItem.top() - aRectangle.top();
+        int shift2Bot = currentItem.bottom() - aRectangle.bottom();
+
+        int itemPosition = 0;
+        foreach (QRect item, rectanglesList)
+        {
+            int delta = qAbs (windowVertical - item.center().y());
+            if (delta > currentDelta) break; else ++ itemPosition;
+        }
+        rectanglesList.insert (itemPosition, currentItem);
+
+        int shift2TopPos = 0;
+        foreach (int shift, shiftsList)
+            if (qAbs (shift) > qAbs (shift2Top)) break; else ++ shift2TopPos;
+        shiftsList.insert (shift2TopPos, shift2Top);
+
+        int shift2BotPos = 0;
+        foreach (int shift, shiftsList)
+            if (qAbs (shift) > qAbs (shift2Bot)) break; else ++ shift2BotPos;
+        shiftsList.insert (shift2BotPos, shift2Bot);
+    }
+
+    /* Trying to find the appropriate place for window */
+    QRect result;
+    for (int i = -1; i < shiftsList.size(); ++ i)
+    {
+        /* Move to appropriate vertical */
+        QRect rectangle (aRectangle);
+        if (i >= 0) rectangle.translate (0, shiftsList [i]);
+
+        /* Search horizontal shift */
+        int maxShift = 0;
+        foreach (QRect item, rectanglesList)
+        {
+            QRect trectangle (rectangle.translated (item.left() - rectangle.left(), 0));
+            if (!item.intersects (trectangle))
+                continue;
+
+            if (rectangle.left() < item.left())
+            {
+                int shift = item.left() - rectangle.left();
+                maxShift = qAbs (shift) > qAbs (maxShift) ? shift : maxShift;
+            }
+            else if (rectangle.right() > item.right())
+            {
+                int shift = item.right() - rectangle.right();
+                maxShift = qAbs (shift) > qAbs (maxShift) ? shift : maxShift;
+            }
+        }
+
+        /* Shift across the horizontal direction */
+        rectangle.translate (maxShift, 0);
+
+        /* Check the translated rectangle to feat the rules */
+        if (aBoundRegion.united (rectangle) == aBoundRegion)
+            result = rectangle;
+
+        if (!result.isNull()) break;
+    }
+
+    if (result.isNull())
+    {
+        /* Resize window to feat desirable size
+         * using max of available rectangles */
+        QRect maxRectangle;
+        quint64 maxSquare = 0;
+        foreach (QRect item, rectanglesList)
+        {
+            quint64 square = item.width() * item.height();
+            if (square > maxSquare)
+            {
+                maxSquare = square;
+                maxRectangle = item;
+            }
+        }
+
+        result = aRectangle;
+        result.moveTo (maxRectangle.x(), maxRectangle.y());
+        if (maxRectangle.right() < result.right())
+            result.setRight (maxRectangle.right());
+        if (maxRectangle.bottom() < result.bottom())
+            result.setBottom (maxRectangle.bottom());
+    }
+
+    return result;
+}
+
+/**
+ *  Returns the flipped (transposed) region.
+ */
+/* static */
+QRegion VBoxGlobal::flip (const QRegion &aRegion)
+{
+    QRegion result;
+    QVector <QRect> rectangles (aRegion.rects());
+    foreach (QRect rectangle, rectangles)
+        result += QRect (rectangle.y(), rectangle.x(),
+                         rectangle.height(), rectangle.width());
+    return result;
+}
+
+/**
+ *  Aligns the center of \a aWidget with the center of \a aRelative.
+ *
+ *  If necessary, \a aWidget's position is adjusted to make it fully visible
+ *  within the available desktop area. If \a aWidget is bigger then this area,
+ *  it will also be resized unless \a aCanResize is false or there is an
+ *  inappropriate minimum size limit (in which case the top left corner will be
+ *  simply aligned with the top left corner of the available desktop area).
+ *
+ *  \a aWidget must be a top-level widget. \a aRelative may be any widget, but
+ *  if it's not top-level itself, its top-level widget will be used for
+ *  calculations. \a aRelative can also be NULL, in which case \a aWidget will
+ *  be centered relative to the available desktop area.
+ */
+/* static */
+void VBoxGlobal::centerWidget (QWidget *aWidget, QWidget *aRelative,
+                               bool aCanResize /* = true */)
+{
+    AssertReturnVoid (aWidget);
+    AssertReturnVoid (aWidget->isTopLevel());
+
+    QRect deskGeo, parentGeo;
+    QWidget *w = aRelative;
+    if (w)
+    {
+        w = w->window();
+        deskGeo = gpDesktop->availableGeometry (w);
+        parentGeo = w->frameGeometry();
+        /* On X11/Gnome, geo/frameGeo.x() and y() are always 0 for top level
+         * widgets with parents, what a shame. Use mapToGlobal() to workaround. */
+        QPoint d = w->mapToGlobal (QPoint (0, 0));
+        d.rx() -= w->geometry().x() - w->x();
+        d.ry() -= w->geometry().y() - w->y();
+        parentGeo.moveTopLeft (d);
+    }
+    else
+    {
+        deskGeo = gpDesktop->availableGeometry();
+        parentGeo = deskGeo;
+    }
+
+    /* On X11, there is no way to determine frame geometry (including WM
+     * decorations) before the widget is shown for the first time. Stupidly
+     * enumerate other top level widgets to find the thickest frame. The code
+     * is based on the idea taken from QDialog::adjustPositionInternal(). */
+
+    int extraw = 0, extrah = 0;
+
+    QWidgetList list = QApplication::topLevelWidgets();
+    QListIterator<QWidget*> it (list);
+    while ((extraw == 0 || extrah == 0) && it.hasNext())
+    {
+        int framew, frameh;
+        QWidget *current = it.next();
+        if (!current->isVisible())
+            continue;
+
+        framew = current->frameGeometry().width() - current->width();
+        frameh = current->frameGeometry().height() - current->height();
+
+        extraw = qMax (extraw, framew);
+        extrah = qMax (extrah, frameh);
+    }
+
+    /// @todo (r=dmik) not sure if we really need this
+#if 0
+    /* sanity check for decoration frames. With embedding, we
+     * might get extraordinary values */
+    if (extraw == 0 || extrah == 0 || extraw > 20 || extrah > 50)
+    {
+        extrah = 50;
+        extraw = 20;
+    }
+#endif
+
+    /* On non-X11 platforms, the following would be enough instead of the
+     * above workaround: */
+    // QRect geo = frameGeometry();
+    QRect geo = QRect (0, 0, aWidget->width() + extraw,
+                             aWidget->height() + extrah);
+
+    geo.moveCenter (QPoint (parentGeo.x() + (parentGeo.width() - 1) / 2,
+                            parentGeo.y() + (parentGeo.height() - 1) / 2));
+
+    /* ensure the widget is within the available desktop area */
+    QRect newGeo = normalizeGeometry (geo, deskGeo, aCanResize);
+#ifdef VBOX_WS_MAC
+    /* No idea why, but Qt doesn't respect if there is a unified toolbar on the
+     * ::move call. So manually add the height of the toolbar before setting
+     * the position. */
+    if (w)
+        newGeo.translate (0, ::darwinWindowToolBarHeight (aWidget));
+#endif /* VBOX_WS_MAC */
+
+    aWidget->move (newGeo.topLeft());
+
+    if (aCanResize &&
+        (geo.width() != newGeo.width() || geo.height() != newGeo.height()))
+        aWidget->resize (newGeo.width() - extraw, newGeo.height() - extrah);
 }
 
@@ -3431,5 +1682,339 @@
 }
 
-#ifdef VBOX_WS_X11
+/**
+ * Activates the specified window. If necessary, the window will be
+ * de-iconified activation.
+ *
+ * @note On X11, it is implied that @a aWid represents a window of the same
+ * display the application was started on.
+ *
+ * @param aWId              Window ID to activate.
+ * @param aSwitchDesktop    @c true to switch to the window's desktop before
+ *                          activation.
+ *
+ * @return @c true on success and @c false otherwise.
+ */
+/* static */
+bool VBoxGlobal::activateWindow (WId aWId, bool aSwitchDesktop /* = true */)
+{
+    RT_NOREF(aSwitchDesktop);
+    bool result = true;
+
+#if defined (VBOX_WS_WIN)
+
+    HWND handle = (HWND)aWId;
+
+    if (IsIconic (handle))
+        result &= !!ShowWindow (handle, SW_RESTORE);
+    else if (!IsWindowVisible (handle))
+        result &= !!ShowWindow (handle, SW_SHOW);
+
+    result &= !!SetForegroundWindow (handle);
+
+#elif defined (VBOX_WS_X11)
+
+    Display *dpy = QX11Info::display();
+
+    if (aSwitchDesktop)
+    {
+        /* try to find the desktop ID using the NetWM property */
+        CARD32 *desktop = (CARD32 *) XXGetProperty (dpy, aWId, XA_CARDINAL,
+                                                    "_NET_WM_DESKTOP");
+        if (desktop == NULL)
+            /* if the NetWM properly is not supported try to find the desktop
+             * ID using the GNOME WM property */
+            desktop = (CARD32 *) XXGetProperty (dpy, aWId, XA_CARDINAL,
+                                                "_WIN_WORKSPACE");
+
+        if (desktop != NULL)
+        {
+            Bool ok = XXSendClientMessage (dpy, DefaultRootWindow (dpy),
+                                           "_NET_CURRENT_DESKTOP",
+                                           *desktop);
+            if (!ok)
+            {
+                Log1WarningFunc(("Couldn't switch to desktop=%08X\n", desktop));
+                result = false;
+            }
+            XFree (desktop);
+        }
+        else
+        {
+            Log1WarningFunc(("Couldn't find a desktop ID for aWId=%08X\n", aWId));
+            result = false;
+        }
+    }
+
+    Bool ok = XXSendClientMessage (dpy, aWId, "_NET_ACTIVE_WINDOW");
+    result &= !!ok;
+
+    XRaiseWindow (dpy, aWId);
+
+#else
+
+    NOREF (aWId);
+    NOREF (aSwitchDesktop);
+    AssertFailed();
+    result = false;
+
+#endif
+
+    if (!result)
+        Log1WarningFunc(("Couldn't activate aWId=%08X\n", aWId));
+
+    return result;
+}
+
+#if defined (VBOX_WS_X11)
+
+static char *XXGetProperty (Display *aDpy, Window aWnd,
+                            Atom aPropType, const char *aPropName)
+{
+    Atom propNameAtom = XInternAtom (aDpy, aPropName,
+                                     True /* only_if_exists */);
+    if (propNameAtom == None)
+        return NULL;
+
+    Atom actTypeAtom = None;
+    int actFmt = 0;
+    unsigned long nItems = 0;
+    unsigned long nBytesAfter = 0;
+    unsigned char *propVal = NULL;
+    int rc = XGetWindowProperty (aDpy, aWnd, propNameAtom,
+                                 0, LONG_MAX, False /* delete */,
+                                 aPropType, &actTypeAtom, &actFmt,
+                                 &nItems, &nBytesAfter, &propVal);
+    if (rc != Success)
+        return NULL;
+
+    return reinterpret_cast <char *> (propVal);
+}
+
+static Bool XXSendClientMessage (Display *aDpy, Window aWnd, const char *aMsg,
+                                 unsigned long aData0 = 0, unsigned long aData1 = 0,
+                                 unsigned long aData2 = 0, unsigned long aData3 = 0,
+                                 unsigned long aData4 = 0)
+{
+    Atom msgAtom = XInternAtom (aDpy, aMsg, True /* only_if_exists */);
+    if (msgAtom == None)
+        return False;
+
+    XEvent ev;
+
+    ev.xclient.type = ClientMessage;
+    ev.xclient.serial = 0;
+    ev.xclient.send_event = True;
+    ev.xclient.display = aDpy;
+    ev.xclient.window = aWnd;
+    ev.xclient.message_type = msgAtom;
+
+    /* always send as 32 bit for now */
+    ev.xclient.format = 32;
+    ev.xclient.data.l [0] = aData0;
+    ev.xclient.data.l [1] = aData1;
+    ev.xclient.data.l [2] = aData2;
+    ev.xclient.data.l [3] = aData3;
+    ev.xclient.data.l [4] = aData4;
+
+    return XSendEvent (aDpy, DefaultRootWindow (aDpy), False,
+                       SubstructureRedirectMask, &ev) != 0;
+}
+
+/* This method tests whether the current X11 window manager supports full-screen mode as we need it.
+ * Unfortunately the EWMH specification was not fully clear about whether we can expect to find
+ * all of these atoms on the _NET_SUPPORTED root window property, so we have to test with all
+ * interesting window managers. If this fails for a user when you think it should succeed
+ * they should try executing:
+ * xprop -root | egrep -w '_NET_WM_FULLSCREEN_MONITORS|_NET_WM_STATE|_NET_WM_STATE_FULLSCREEN'
+ * in an X11 terminal window.
+ * All three strings should be found under a property called "_NET_SUPPORTED(ATOM)". */
+/* static */
+bool VBoxGlobal::supportsFullScreenMonitorsProtocolX11()
+{
+    /* Using a global to get at the display does not feel right, but that is
+     * how it is done elsewhere in the code. */
+    Display *pDisplay = QX11Info::display();
+    Atom atomSupported            = XInternAtom(pDisplay, "_NET_SUPPORTED",
+                                                True /* only_if_exists */);
+    Atom atomWMFullScreenMonitors = XInternAtom(pDisplay,
+                                                "_NET_WM_FULLSCREEN_MONITORS",
+                                                True /* only_if_exists */);
+    Atom atomWMState              = XInternAtom(pDisplay,
+                                                "_NET_WM_STATE",
+                                                True /* only_if_exists */);
+    Atom atomWMStateFullScreen    = XInternAtom(pDisplay,
+                                                "_NET_WM_STATE_FULLSCREEN",
+                                                True /* only_if_exists */);
+    bool fFoundFullScreenMonitors = false;
+    bool fFoundState              = false;
+    bool fFoundStateFullScreen    = false;
+    Atom atomType;
+    int cFormat;
+    unsigned long cItems;
+    unsigned long cbLeft;
+    Atom *pAtomHints;
+    int rc;
+    unsigned i;
+
+    if (   atomSupported == None || atomWMFullScreenMonitors == None
+        || atomWMState == None || atomWMStateFullScreen == None)
+        return false;
+    /* Get atom value: */
+    rc = XGetWindowProperty(pDisplay, DefaultRootWindow(pDisplay),
+                            atomSupported, 0, 0x7fffffff /*LONG_MAX*/,
+                            False /* delete */, XA_ATOM, &atomType,
+                            &cFormat, &cItems, &cbLeft,
+                            (unsigned char **)&pAtomHints);
+    if (rc != Success)
+        return false;
+    if (pAtomHints == NULL)
+        return false;
+    if (atomType == XA_ATOM && cFormat == 32 && cbLeft == 0)
+        for (i = 0; i < cItems; ++i)
+        {
+            if (pAtomHints[i] == atomWMFullScreenMonitors)
+                fFoundFullScreenMonitors = true;
+            if (pAtomHints[i] == atomWMState)
+                fFoundState = true;
+            if (pAtomHints[i] == atomWMStateFullScreen)
+                fFoundStateFullScreen = true;
+        }
+    XFree(pAtomHints);
+    return fFoundFullScreenMonitors && fFoundState && fFoundStateFullScreen;
+}
+
+/* static */
+bool VBoxGlobal::setFullScreenMonitorX11(QWidget *pWidget, ulong uScreenId)
+{
+    return XXSendClientMessage(QX11Info::display(),
+                               pWidget->window()->winId(),
+                               "_NET_WM_FULLSCREEN_MONITORS",
+                               uScreenId, uScreenId, uScreenId, uScreenId,
+                               1 /* Source indication (1 = normal application) */);
+}
+
+/* static */
+QVector<Atom> VBoxGlobal::flagsNetWmState(QWidget *pWidget)
+{
+    /* Get display: */
+    Display *pDisplay = QX11Info::display();
+
+    /* Prepare atoms: */
+    QVector<Atom> resultNetWmState;
+    Atom net_wm_state = XInternAtom(pDisplay, "_NET_WM_STATE", True /* only if exists */);
+
+    /* Get the size of the property data: */
+    Atom actual_type;
+    int iActualFormat;
+    ulong uPropertyLength;
+    ulong uBytesLeft;
+    uchar *pPropertyData = 0;
+    if (XGetWindowProperty(pDisplay, pWidget->window()->winId(),
+                           net_wm_state, 0, 0, False, XA_ATOM, &actual_type, &iActualFormat,
+                           &uPropertyLength, &uBytesLeft, &pPropertyData) == Success &&
+        actual_type == XA_ATOM && iActualFormat == 32)
+    {
+        resultNetWmState.resize(uBytesLeft / 4);
+        XFree((char*)pPropertyData);
+        pPropertyData = 0;
+
+        /* Fetch all data: */
+        if (XGetWindowProperty(pDisplay, pWidget->window()->winId(),
+                               net_wm_state, 0, resultNetWmState.size(), False, XA_ATOM, &actual_type, &iActualFormat,
+                               &uPropertyLength, &uBytesLeft, &pPropertyData) != Success)
+            resultNetWmState.clear();
+        else if (uPropertyLength != (ulong)resultNetWmState.size())
+            resultNetWmState.resize(uPropertyLength);
+
+        /* Put it into resultNetWmState: */
+        if (!resultNetWmState.isEmpty())
+            memcpy(resultNetWmState.data(), pPropertyData, resultNetWmState.size() * sizeof(Atom));
+        if (pPropertyData)
+            XFree((char*)pPropertyData);
+    }
+
+    /* Return result: */
+    return resultNetWmState;
+}
+
+/* static */
+bool VBoxGlobal::isFullScreenFlagSet(QWidget *pWidget)
+{
+    /* Get display: */
+    Display *pDisplay = QX11Info::display();
+
+    /* Prepare atoms: */
+    Atom net_wm_state_fullscreen = XInternAtom(pDisplay, "_NET_WM_STATE_FULLSCREEN", True /* only if exists */);
+
+    /* Check if flagsNetWmState(pWidget) contains full-screen flag: */
+    return flagsNetWmState(pWidget).contains(net_wm_state_fullscreen);
+}
+
+/* static */
+void VBoxGlobal::setFullScreenFlag(QWidget *pWidget)
+{
+    /* Get display: */
+    Display *pDisplay = QX11Info::display();
+
+    /* Prepare atoms: */
+    QVector<Atom> resultNetWmState = flagsNetWmState(pWidget);
+    Atom net_wm_state = XInternAtom(pDisplay, "_NET_WM_STATE", True /* only if exists */);
+    Atom net_wm_state_fullscreen = XInternAtom(pDisplay, "_NET_WM_STATE_FULLSCREEN", True /* only if exists */);
+
+    /* Append resultNetWmState with fullscreen flag if necessary: */
+    if (!resultNetWmState.contains(net_wm_state_fullscreen))
+    {
+        resultNetWmState.append(net_wm_state_fullscreen);
+        /* Apply property to widget again: */
+        XChangeProperty(pDisplay, pWidget->window()->winId(),
+                        net_wm_state, XA_ATOM, 32, PropModeReplace,
+                        (unsigned char*)resultNetWmState.data(), resultNetWmState.size());
+    }
+}
+
+/* static */
+void VBoxGlobal::setSkipTaskBarFlag(QWidget *pWidget)
+{
+    /* Get display: */
+    Display *pDisplay = QX11Info::display();
+
+    /* Prepare atoms: */
+    QVector<Atom> resultNetWmState = flagsNetWmState(pWidget);
+    Atom net_wm_state = XInternAtom(pDisplay, "_NET_WM_STATE", True /* only if exists */);
+    Atom net_wm_state_skip_taskbar = XInternAtom(pDisplay, "_NET_WM_STATE_SKIP_TASKBAR", True /* only if exists */);
+
+    /* Append resultNetWmState with skip-taskbar flag if necessary: */
+    if (!resultNetWmState.contains(net_wm_state_skip_taskbar))
+    {
+        resultNetWmState.append(net_wm_state_skip_taskbar);
+        /* Apply property to widget again: */
+        XChangeProperty(pDisplay, pWidget->window()->winId(),
+                        net_wm_state, XA_ATOM, 32, PropModeReplace,
+                        (unsigned char*)resultNetWmState.data(), resultNetWmState.size());
+    }
+}
+
+/* static */
+void VBoxGlobal::setSkipPagerFlag(QWidget *pWidget)
+{
+    /* Get display: */
+    Display *pDisplay = QX11Info::display();
+
+    /* Prepare atoms: */
+    QVector<Atom> resultNetWmState = flagsNetWmState(pWidget);
+    Atom net_wm_state = XInternAtom(pDisplay, "_NET_WM_STATE", True /* only if exists */);
+    Atom net_wm_state_skip_pager = XInternAtom(pDisplay, "_NET_WM_STATE_SKIP_PAGER", True /* only if exists */);
+
+    /* Append resultNetWmState with skip-pager flag if necessary: */
+    if (!resultNetWmState.contains(net_wm_state_skip_pager))
+    {
+        resultNetWmState.append(net_wm_state_skip_pager);
+        /* Apply property to widget again: */
+        XChangeProperty(pDisplay, pWidget->window()->winId(),
+                        net_wm_state, XA_ATOM, 32, PropModeReplace,
+                        (unsigned char*)resultNetWmState.data(), resultNetWmState.size());
+    }
+}
+
 void VBoxGlobal::setWMClass(QWidget *pWidget, const QString &strNameString, const QString &strClassString)
 {
@@ -3455,5 +2040,1396 @@
     XSetClassHint(QX11Info::display(), pWidget->window()->winId(), &windowClass);
 }
+
+QList<QRect> XGetDesktopList()
+{
+    /* Prepare empty resulting list: */
+    QList<QRect> result;
+
+    /* Get current display: */
+    Display* pDisplay = QX11Info::display();
+
+    /* If it's a Xinerama desktop: */
+    if (XineramaIsActive(pDisplay))
+    {
+        /* Reading Xinerama data: */
+        int iScreens = 0;
+        XineramaScreenInfo *pScreensData = XineramaQueryScreens(pDisplay, &iScreens);
+
+        /* Fill resulting list: */
+        for (int i = 0; i < iScreens; ++ i)
+            result << QRect(pScreensData[i].x_org, pScreensData[i].y_org,
+                            pScreensData[i].width, pScreensData[i].height);
+
+        /* Free screens data: */
+        XFree(pScreensData);
+    }
+
+    /* Return resulting list: */
+    return result;
+}
+
+QList<Window> XGetWindowIDList()
+{
+    /* Get current display: */
+    Display *pDisplay = QX11Info::display();
+
+    /* Get virtual desktop window: */
+    Window window = QX11Info::appRootWindow();
+
+    /* Get 'client list' atom: */
+    Atom propNameAtom = XInternAtom(pDisplay, "_NET_CLIENT_LIST", True /* only if exists */);
+
+    /* Prepare empty resulting list: */
+    QList<Window> result;
+
+    /* If atom does not exists return empty list: */
+    if (propNameAtom == None)
+        return result;
+
+    /* Get atom value: */
+    Atom realAtomType = None;
+    int iRealFormat = 0;
+    unsigned long uItemsCount = 0;
+    unsigned long uBytesAfter = 0;
+    unsigned char *pData = 0;
+    int rc = XGetWindowProperty(pDisplay, window, propNameAtom,
+                                0, 0x7fffffff /*LONG_MAX*/, False /* delete */,
+                                XA_WINDOW, &realAtomType, &iRealFormat,
+                                &uItemsCount, &uBytesAfter, &pData);
+
+    /* If get property is failed return empty list: */
+    if (rc != Success)
+        return result;
+
+    /* Fill resulting list with win ids: */
+    Window *pWindowData = reinterpret_cast<Window*>(pData);
+    for (ulong i = 0; i < uItemsCount; ++ i)
+        result << pWindowData[i];
+
+    /* Releasing resources: */
+    XFree(pData);
+
+    /* Return resulting list: */
+    return result;
+}
+
+QList<ulong> XGetStrut(Window window)
+{
+    /* Get current display: */
+    Display *pDisplay = QX11Info::display();
+
+    /* Get 'strut' atom: */
+    Atom propNameAtom = XInternAtom(pDisplay, "_NET_WM_STRUT_PARTIAL", True /* only if exists */);
+
+    /* Prepare empty resulting list: */
+    QList<ulong> result;
+
+    /* If atom does not exists return empty list: */
+    if (propNameAtom == None)
+        return result;
+
+    /* Get atom value: */
+    Atom realAtomType = None;
+    int iRealFormat = 0;
+    ulong uItemsCount = 0;
+    ulong uBytesAfter = 0;
+    unsigned char *pData = 0;
+    int rc = XGetWindowProperty(pDisplay, window, propNameAtom,
+                                0, LONG_MAX, False /* delete */,
+                                XA_CARDINAL, &realAtomType, &iRealFormat,
+                                &uItemsCount, &uBytesAfter, &pData);
+
+    /* If get property is failed return empty list: */
+    if (rc != Success)
+        return result;
+
+    /* Fill resulting list with strut shifts: */
+    ulong *pStrutsData = reinterpret_cast<ulong*>(pData);
+    for (ulong i = 0; i < uItemsCount; ++ i)
+        result << pStrutsData[i];
+
+    /* Releasing resources: */
+    XFree(pData);
+
+    /* Return resulting list: */
+    return result;
+}
+#endif
+
+/* static */
+void VBoxGlobal::setMinimumWidthAccordingSymbolCount(QSpinBox *pSpinBox, int cCount)
+{
+    /* Load options: */
+    QStyleOptionSpinBox option;
+    option.initFrom(pSpinBox);
+
+    /* Acquire edit-field rectangle: */
+    QRect rect = pSpinBox->style()->subControlRect(QStyle::CC_SpinBox,
+                                                   &option,
+                                                   QStyle::SC_SpinBoxEditField,
+                                                   pSpinBox);
+
+    /* Calculate minimum-width magic: */
+    int iSpinBoxWidth = pSpinBox->width();
+    int iSpinBoxEditFieldWidth = rect.width();
+    int iSpinBoxDelta = qMax(0, iSpinBoxWidth - iSpinBoxEditFieldWidth);
+    QFontMetrics metrics(pSpinBox->font(), pSpinBox);
+    QString strDummy(cCount, '0');
+    int iTextWidth = metrics.width(strDummy);
+
+    /* Tune spin-box minimum-width: */
+    pSpinBox->setMinimumWidth(iTextWidth + iSpinBoxDelta);
+}
+
+/**
+ *  Returns the list of few guest OS types, queried from
+ *  IVirtualBox corresponding to every family id.
+ */
+QList<CGuestOSType> VBoxGlobal::vmGuestOSFamilyList() const
+{
+    QList<CGuestOSType> result;
+    for (int i = 0; i < m_guestOSFamilyIDs.size(); ++i)
+        result << m_guestOSTypes[i][0];
+    return result;
+}
+
+/**
+ *  Returns the list of all guest OS types, queried from
+ *  IVirtualBox corresponding to passed family id.
+ */
+QList<CGuestOSType> VBoxGlobal::vmGuestOSTypeList(const QString &aFamilyId) const
+{
+    AssertMsg(m_guestOSFamilyIDs.contains(aFamilyId), ("Family ID incorrect: '%s'.", aFamilyId.toLatin1().constData()));
+    return m_guestOSFamilyIDs.contains(aFamilyId) ?
+           m_guestOSTypes[m_guestOSFamilyIDs.indexOf(aFamilyId)] : QList<CGuestOSType>();
+}
+
+/**
+ *  Returns the guest OS type object corresponding to the given type id of list
+ *  containing OS types related to OS family determined by family id attribute.
+ *  If the index is invalid a null object is returned.
+ */
+CGuestOSType VBoxGlobal::vmGuestOSType(const QString &aTypeId,
+             const QString &aFamilyId /* = QString::null */) const
+{
+    QList <CGuestOSType> list;
+    if (m_guestOSFamilyIDs.contains (aFamilyId))
+    {
+        list = m_guestOSTypes [m_guestOSFamilyIDs.indexOf (aFamilyId)];
+    }
+    else
+    {
+        for (int i = 0; i < m_guestOSFamilyIDs.size(); ++ i)
+            list += m_guestOSTypes [i];
+    }
+    for (int j = 0; j < list.size(); ++ j)
+        if (!list [j].GetId().compare (aTypeId))
+            return list [j];
+    AssertMsgFailed (("Type ID incorrect: '%s'.", aTypeId.toLatin1().constData()));
+    return CGuestOSType();
+}
+
+/**
+ *  Returns the description corresponding to the given guest OS type id.
+ */
+QString VBoxGlobal::vmGuestOSTypeDescription (const QString &aTypeId) const
+{
+    for (int i = 0; i < m_guestOSFamilyIDs.size(); ++ i)
+    {
+        QList <CGuestOSType> list (m_guestOSTypes [i]);
+        for ( int j = 0; j < list.size(); ++ j)
+            if (!list [j].GetId().compare (aTypeId))
+                return list [j].GetDescription();
+    }
+    return QString::null;
+}
+
+/* static */
+bool VBoxGlobal::isDOSType (const QString &aOSTypeId)
+{
+    if (aOSTypeId.left (3) == "dos" ||
+        aOSTypeId.left (3) == "win" ||
+        aOSTypeId.left (3) == "os2")
+        return true;
+
+    return false;
+}
+
+bool VBoxGlobal::switchToMachine(CMachine &machine)
+{
+#ifdef VBOX_WS_MAC
+    ULONG64 id = machine.ShowConsoleWindow();
+#else
+    WId id = (WId) machine.ShowConsoleWindow();
+#endif
+    AssertWrapperOk(machine);
+    if (!machine.isOk())
+        return false;
+
+    /* winId = 0 it means the console window has already done everything
+     * necessary to implement the "show window" semantics. */
+    if (id == 0)
+        return true;
+
+#if defined(VBOX_WS_WIN) || defined(VBOX_WS_X11)
+
+    return vboxGlobal().activateWindow(id, true);
+
+#elif defined(VBOX_WS_MAC)
+    /*
+     * This is just for the case were the other process cannot steal
+     * the focus from us. It will send us a PSN so we can try.
+     */
+    ProcessSerialNumber psn;
+    psn.highLongOfPSN = id >> 32;
+    psn.lowLongOfPSN = (UInt32)id;
+# ifdef __clang__
+#  pragma GCC diagnostic push
+#  pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+    OSErr rc = ::SetFrontProcess(&psn);
+#  pragma GCC diagnostic pop
+# else
+    OSErr rc = ::SetFrontProcess(&psn);
+# endif
+    if (!rc)
+        Log(("GUI: %#RX64 couldn't do SetFrontProcess on itself, the selector (we) had to do it...\n", id));
+    else
+        Log(("GUI: Failed to bring %#RX64 to front. rc=%#x\n", id, rc));
+    return !rc;
+
+#else
+
+    return false;
+
+#endif
+
+
+    /// @todo Below is the old method of switching to the console window
+    //  based on the process ID of the console process. It should go away
+    //  after the new (callback-based) method is fully tested.
+#if 0
+
+    if (!canSwitchTo())
+        return false;
+
+#if defined (VBOX_WS_WIN)
+
+    HWND hwnd = mWinId;
+
+    /* if there are blockers (modal and modeless dialogs, etc), find the
+     * topmost one */
+    HWND hwndAbove = NULL;
+    do
+    {
+        hwndAbove = GetNextWindow(hwnd, GW_HWNDPREV);
+        HWND hwndOwner;
+        if (hwndAbove != NULL &&
+            ((hwndOwner = GetWindow(hwndAbove, GW_OWNER)) == hwnd ||
+             hwndOwner  == hwndAbove))
+            hwnd = hwndAbove;
+        else
+            break;
+    }
+    while (1);
+
+    /* first, check that the primary window is visible */
+    if (IsIconic(mWinId))
+        ShowWindow(mWinId, SW_RESTORE);
+    else if (!IsWindowVisible(mWinId))
+        ShowWindow(mWinId, SW_SHOW);
+
+#if 0
+    LogFlowFunc(("mWinId=%08X hwnd=%08X\n", mWinId, hwnd));
+#endif
+
+    /* then, activate the topmost in the group */
+    AllowSetForegroundWindow(m_pid);
+    SetForegroundWindow(hwnd);
+
+    return true;
+
+#elif defined (VBOX_WS_X11)
+
+    return false;
+
+#elif defined (VBOX_WS_MAC)
+
+    ProcessSerialNumber psn;
+    OSStatus rc = ::GetProcessForPID(m_pid, &psn);
+    if (!rc)
+    {
+        rc = ::SetFrontProcess(&psn);
+
+        if (!rc)
+        {
+            ShowHideProcess(&psn, true);
+            return true;
+        }
+    }
+    return false;
+
+#else
+
+    return false;
+
+#endif
+
+#endif
+}
+
+bool VBoxGlobal::launchMachine(CMachine &machine, LaunchMode enmLaunchMode /* = LaunchMode_Default */)
+{
+    /* Switch to machine window(s) if possible: */
+    if (   machine.GetSessionState() == KSessionState_Locked /* precondition for CanShowConsoleWindow() */
+        && machine.CanShowConsoleWindow())
+    {
+        /* For the Selector UI: */
+        if (!isVMConsoleProcess())
+        {
+            /* Just switch to existing VM window: */
+            return VBoxGlobal::switchToMachine(machine);
+        }
+        /* For the Runtime UI: */
+        else
+        {
+            /* Only separate UI process can reach that place,
+             * switch to existing VM window and exit. */
+            VBoxGlobal::switchToMachine(machine);
+            return false;
+        }
+    }
+
+    if (enmLaunchMode != LaunchMode_Separate)
+    {
+        /* Make sure machine-state is one of required: */
+        KMachineState state = machine.GetState(); NOREF(state);
+        AssertMsg(   state == KMachineState_PoweredOff
+                  || state == KMachineState_Saved
+                  || state == KMachineState_Teleported
+                  || state == KMachineState_Aborted
+                  , ("Machine must be PoweredOff/Saved/Teleported/Aborted (%d)", state));
+    }
+
+    /* Create empty session instance: */
+    CSession session;
+    session.createInstance(CLSID_Session);
+    if (session.isNull())
+    {
+        msgCenter().cannotOpenSession(session);
+        return false;
+    }
+
+    /* Configure environment: */
+    QString strEnv;
+#ifdef Q_OS_WIN
+    /* Allow started VM process to be foreground window: */
+    AllowSetForegroundWindow(ASFW_ANY);
+#endif /* Q_OS_WIN */
+#ifdef VBOX_WS_X11
+    /* Make sure VM process will start on the same display as the VM selector: */
+    const char *pDisplay = RTEnvGet("DISPLAY");
+    if (pDisplay)
+        strEnv.append(QString("DISPLAY=%1\n").arg(pDisplay));
+    const char *pXauth = RTEnvGet("XAUTHORITY");
+    if (pXauth)
+        strEnv.append(QString("XAUTHORITY=%1\n").arg(pXauth));
 #endif /* VBOX_WS_X11 */
+    QString strType;
+    switch (enmLaunchMode)
+    {
+        case LaunchMode_Default:  strType = ""; break;
+        case LaunchMode_Separate: strType = vboxGlobal().isSeparateProcess() ? "headless" : "separate"; break;
+        case LaunchMode_Headless: strType = "headless"; break;
+        default: AssertFailedReturn(false);
+    }
+
+    /* Prepare "VM spawning" progress: */
+    CProgress progress = machine.LaunchVMProcess(session, strType, strEnv);
+    if (!machine.isOk())
+    {
+        /* If the VM is started separately and the VM process is already running, then it is OK. */
+        if (enmLaunchMode == LaunchMode_Separate)
+        {
+            KMachineState state = machine.GetState();
+            if (   state >= KMachineState_FirstOnline
+                && state <= KMachineState_LastOnline)
+            {
+                /* Already running. */
+                return true;
+            }
+        }
+
+        msgCenter().cannotOpenSession(machine);
+        return false;
+    }
+
+    /* Postpone showing "VM spawning" progress.
+     * Hope 1 minute will be enough to spawn any running VM silently,
+     * otherwise we better show the progress...
+     * If starting separately, then show the progress now. */
+    int iSpawningDuration = enmLaunchMode == LaunchMode_Separate ? 0 : 60000;
+    msgCenter().showModalProgressDialog(progress, machine.GetName(),
+                                        ":/progress_start_90px.png", 0, iSpawningDuration);
+    if (!progress.isOk() || progress.GetResultCode() != 0)
+        msgCenter().cannotOpenSession(progress, machine.GetName());
+
+    /* Unlock machine, close session: */
+    session.UnlockMachine();
+
+    /* True finally: */
+    return true;
+}
+
+CSession VBoxGlobal::openSession(const QString &strId, KLockType lockType /* = KLockType_Shared */)
+{
+    /* Prepare session: */
+    CSession session;
+
+    /* Simulate try-catch block: */
+    bool fSuccess = false;
+    do
+    {
+        /* Create empty session instance: */
+        session.createInstance(CLSID_Session);
+        if (session.isNull())
+        {
+            msgCenter().cannotOpenSession(session);
+            break;
+        }
+
+        /* Search for the corresponding machine: */
+        CMachine machine = m_vbox.FindMachine(strId);
+        if (machine.isNull())
+        {
+            msgCenter().cannotFindMachineById(m_vbox, strId);
+            break;
+        }
+
+        if (lockType == KLockType_VM)
+            session.SetName("GUI/Qt");
+
+        /* Lock found machine to session: */
+        machine.LockMachine(session, lockType);
+        if (!machine.isOk())
+        {
+            msgCenter().cannotOpenSession(machine);
+            break;
+        }
+
+        /* Pass the language ID as the property to the guest: */
+        if (session.GetType() == KSessionType_Shared)
+        {
+            CMachine startedMachine = session.GetMachine();
+            /* Make sure that the language is in two letter code.
+             * Note: if languageId() returns an empty string lang.name() will
+             * return "C" which is an valid language code. */
+            QLocale lang(VBoxGlobal::languageId());
+            startedMachine.SetGuestPropertyValue("/VirtualBox/HostInfo/GUI/LanguageID", lang.name());
+        }
+
+        /* Success finally: */
+        fSuccess = true;
+    }
+    while (0);
+    /* Cleanup try-catch block: */
+    if (!fSuccess)
+        session.detach();
+
+    /* Return session: */
+    return session;
+}
+
+/**
+ * Figures out which medium formats are currently supported by VirtualBox for
+ * the given device type.
+ * Returned is a list of pairs with the form
+ *   <tt>{"Backend Name", "*.suffix1 .suffix2 ..."}</tt>.
+ */
+/* static */
+QList <QPair <QString, QString> > VBoxGlobal::MediumBackends(KDeviceType enmType)
+{
+    CSystemProperties systemProperties = vboxGlobal().virtualBox().GetSystemProperties();
+    QVector<CMediumFormat> mediumFormats = systemProperties.GetMediumFormats();
+    QList< QPair<QString, QString> > backendPropList;
+    for (int i = 0; i < mediumFormats.size(); ++ i)
+    {
+        /* File extensions */
+        QVector <QString> fileExtensions;
+        QVector <KDeviceType> deviceTypes;
+
+        mediumFormats [i].DescribeFileExtensions(fileExtensions, deviceTypes);
+
+        QStringList f;
+        for (int a = 0; a < fileExtensions.size(); ++ a)
+            if (deviceTypes [a] == enmType)
+                f << QString ("*.%1").arg (fileExtensions [a]);
+        /* Create a pair out of the backend description and all suffix's. */
+        if (!f.isEmpty())
+            backendPropList << QPair<QString, QString> (mediumFormats [i].GetName(), f.join(" "));
+    }
+    return backendPropList;
+}
+
+/**
+ * Figures out which hard disk formats are currently supported by VirtualBox.
+ * Returned is a list of pairs with the form
+ *   <tt>{"Backend Name", "*.suffix1 .suffix2 ..."}</tt>.
+ */
+/* static */
+QList <QPair <QString, QString> > VBoxGlobal::HDDBackends()
+{
+    return MediumBackends(KDeviceType_HardDisk);
+}
+
+/**
+ * Figures out which optical disk formats are currently supported by VirtualBox.
+ * Returned is a list of pairs with the form
+ *   <tt>{"Backend Name", "*.suffix1 .suffix2 ..."}</tt>.
+ */
+/* static */
+QList <QPair <QString, QString> > VBoxGlobal::DVDBackends()
+{
+    return MediumBackends(KDeviceType_DVD);
+}
+
+/**
+ * Figures out which floppy disk formats are currently supported by VirtualBox.
+ * Returned is a list of pairs with the form
+ *   <tt>{"Backend Name", "*.suffix1 .suffix2 ..."}</tt>.
+ */
+/* static */
+QList <QPair <QString, QString> > VBoxGlobal::FloppyBackends()
+{
+    return MediumBackends(KDeviceType_Floppy);
+}
+
+void VBoxGlobal::startMediumEnumeration()
+{
+    /* Make sure VBoxGlobal is already valid: */
+    AssertReturnVoid(mValid);
+
+    /* Make sure medium-enumerator is already created: */
+    if (!m_pMediumEnumerator)
+        return;
+
+    /* Make sure enumeration is not already started: */
+    if (isMediumEnumerationInProgress())
+        return;
+
+    /* Ignore the request during VBoxGlobal cleanup: */
+    if (s_fCleanupInProgress)
+        return;
+
+    /* If asked to restore snapshot, don't do this till *after* we're done
+     * restoring or the code with have a heart attack. */
+    if (shouldRestoreCurrentSnapshot())
+        return;
+
+    if (m_mediumEnumeratorDtorRwLock.tryLockForRead())
+    {
+        /* Redirect request to medium-enumerator: */
+        if (m_pMediumEnumerator)
+            m_pMediumEnumerator->enumerateMediums();
+        m_mediumEnumeratorDtorRwLock.unlock();
+    }
+}
+
+bool VBoxGlobal::isMediumEnumerationInProgress() const
+{
+    /* Redirect request to medium-enumerator: */
+    return m_pMediumEnumerator
+        && m_pMediumEnumerator->isMediumEnumerationInProgress();
+}
+
+UIMedium VBoxGlobal::medium(const QString &strMediumID) const
+{
+    if (m_mediumEnumeratorDtorRwLock.tryLockForRead())
+    {
+        /* Redirect call to medium-enumerator: */
+        UIMedium result;
+        if (m_pMediumEnumerator)
+            result = m_pMediumEnumerator->medium(strMediumID);
+        m_mediumEnumeratorDtorRwLock.unlock();
+        return result;
+    }
+    return UIMedium();
+}
+
+QList<QString> VBoxGlobal::mediumIDs() const
+{
+    if (m_mediumEnumeratorDtorRwLock.tryLockForRead())
+    {
+        /* Redirect call to medium-enumerator: */
+        QList<QString> result;
+        if (m_pMediumEnumerator)
+            result = m_pMediumEnumerator->mediumIDs();
+        m_mediumEnumeratorDtorRwLock.unlock();
+        return result;
+    }
+    return QList<QString>();
+}
+
+void VBoxGlobal::createMedium(const UIMedium &medium)
+{
+    if (m_mediumEnumeratorDtorRwLock.tryLockForRead())
+    {
+        /* Create medium in medium-enumerator: */
+        if (m_pMediumEnumerator)
+            m_pMediumEnumerator->createMedium(medium);
+        m_mediumEnumeratorDtorRwLock.unlock();
+    }
+}
+
+void VBoxGlobal::deleteMedium(const QString &strMediumID)
+{
+    if (m_mediumEnumeratorDtorRwLock.tryLockForRead())
+    {
+        /* Delete medium from medium-enumerator: */
+        if (m_pMediumEnumerator)
+            m_pMediumEnumerator->deleteMedium(strMediumID);
+        m_mediumEnumeratorDtorRwLock.unlock();
+    }
+}
+
+QString VBoxGlobal::openMedium(UIMediumType mediumType, QString strMediumLocation, QWidget *pParent /* = 0*/)
+{
+    /* Convert to native separators: */
+    strMediumLocation = QDir::toNativeSeparators(strMediumLocation);
+
+    /* Initialize variables: */
+    CVirtualBox vbox = virtualBox();
+
+    /* Remember the path of the last chosen medium: */
+    switch (mediumType)
+    {
+        case UIMediumType_HardDisk: gEDataManager->setRecentFolderForHardDrives(QFileInfo(strMediumLocation).absolutePath()); break;
+        case UIMediumType_DVD:      gEDataManager->setRecentFolderForOpticalDisks(QFileInfo(strMediumLocation).absolutePath()); break;
+        case UIMediumType_Floppy:   gEDataManager->setRecentFolderForFloppyDisks(QFileInfo(strMediumLocation).absolutePath()); break;
+        default: break;
+    }
+
+    /* Update recently used list: */
+    QStringList recentMediumList;
+    switch (mediumType)
+    {
+        case UIMediumType_HardDisk: recentMediumList = gEDataManager->recentListOfHardDrives(); break;
+        case UIMediumType_DVD:      recentMediumList = gEDataManager->recentListOfOpticalDisks(); break;
+        case UIMediumType_Floppy:   recentMediumList = gEDataManager->recentListOfFloppyDisks(); break;
+        default: break;
+    }
+    if (recentMediumList.contains(strMediumLocation))
+        recentMediumList.removeAll(strMediumLocation);
+    recentMediumList.prepend(strMediumLocation);
+    while(recentMediumList.size() > 5) recentMediumList.removeLast();
+    switch (mediumType)
+    {
+        case UIMediumType_HardDisk: gEDataManager->setRecentListOfHardDrives(recentMediumList); break;
+        case UIMediumType_DVD:      gEDataManager->setRecentListOfOpticalDisks(recentMediumList); break;
+        case UIMediumType_Floppy:   gEDataManager->setRecentListOfFloppyDisks(recentMediumList); break;
+        default: break;
+    }
+
+    /* Open corresponding medium: */
+    CMedium cmedium = vbox.OpenMedium(strMediumLocation, mediumTypeToGlobal(mediumType), KAccessMode_ReadWrite, false);
+
+    if (vbox.isOk())
+    {
+        /* Prepare vbox medium wrapper: */
+        UIMedium uimedium = medium(cmedium.GetId());
+
+        /* First of all we should test if that medium already opened: */
+        if (uimedium.isNull())
+        {
+            /* And create new otherwise: */
+            uimedium = UIMedium(cmedium, mediumType, KMediumState_Created);
+            vboxGlobal().createMedium(uimedium);
+        }
+
+        /* Return uimedium id: */
+        return uimedium.id();
+    }
+    else
+        msgCenter().cannotOpenMedium(vbox, mediumType, strMediumLocation, pParent);
+
+    return QString();
+}
+
+/* Open some external medium using file open dialog
+ * and temporary cache (enumerate) it in GUI inner mediums cache: */
+QString VBoxGlobal::openMediumWithFileOpenDialog(UIMediumType mediumType, QWidget *pParent,
+                                                 const QString &strDefaultFolder /* = QString() */,
+                                                 bool fUseLastFolder /* = false */)
+{
+    /* Initialize variables: */
+    QList < QPair <QString, QString> > filters;
+    QStringList backends;
+    QStringList prefixes;
+    QString strFilter;
+    QString strTitle;
+    QString allType;
+    QString strLastFolder;
+    switch (mediumType)
+    {
+        case UIMediumType_HardDisk:
+        {
+            filters = vboxGlobal().HDDBackends();
+            strTitle = tr("Please choose a virtual hard disk file");
+            allType = tr("All virtual hard disk files (%1)");
+            strLastFolder = gEDataManager->recentFolderForHardDrives();
+            if (strLastFolder.isEmpty())
+                strLastFolder = gEDataManager->recentFolderForOpticalDisks();
+            if (strLastFolder.isEmpty())
+                strLastFolder = gEDataManager->recentFolderForFloppyDisks();
+            break;
+        }
+        case UIMediumType_DVD:
+        {
+            filters = vboxGlobal().DVDBackends();
+            strTitle = tr("Please choose a virtual optical disk file");
+            allType = tr("All virtual optical disk files (%1)");
+            strLastFolder = gEDataManager->recentFolderForOpticalDisks();
+            if (strLastFolder.isEmpty())
+                strLastFolder = gEDataManager->recentFolderForFloppyDisks();
+            if (strLastFolder.isEmpty())
+                strLastFolder = gEDataManager->recentFolderForHardDrives();
+            break;
+        }
+        case UIMediumType_Floppy:
+        {
+            filters = vboxGlobal().FloppyBackends();
+            strTitle = tr("Please choose a virtual floppy disk file");
+            allType = tr("All virtual floppy disk files (%1)");
+            strLastFolder = gEDataManager->recentFolderForFloppyDisks();
+            if (strLastFolder.isEmpty())
+                strLastFolder = gEDataManager->recentFolderForOpticalDisks();
+            if (strLastFolder.isEmpty())
+                strLastFolder = gEDataManager->recentFolderForHardDrives();
+            break;
+        }
+        default:
+            break;
+    }
+    QString strHomeFolder = fUseLastFolder && !strLastFolder.isEmpty() ? strLastFolder :
+                            strDefaultFolder.isEmpty() ? vboxGlobal().homeFolder() : strDefaultFolder;
+
+    /* Prepare filters and backends: */
+    for (int i = 0; i < filters.count(); ++i)
+    {
+        /* Get iterated filter: */
+        QPair <QString, QString> item = filters.at(i);
+        /* Create one backend filter string: */
+        backends << QString("%1 (%2)").arg(item.first).arg(item.second);
+        /* Save the suffix's for the "All" entry: */
+        prefixes << item.second;
+    }
+    if (!prefixes.isEmpty())
+        backends.insert(0, allType.arg(prefixes.join(" ").trimmed()));
+    backends << tr("All files (*)");
+    strFilter = backends.join(";;").trimmed();
+
+    /* Create open file dialog: */
+    QStringList files = QIFileDialog::getOpenFileNames(strHomeFolder, strFilter, pParent, strTitle, 0, true, true);
+
+    /* If dialog has some result: */
+    if (!files.empty() && !files[0].isEmpty())
+        return openMedium(mediumType, files[0], pParent);
+
+    return QString();
+}
+
+/**
+ * Create a VISO using the file open dialog.
+ *
+ * Temporarily caches (enumerate) it in GUI inner mediums cache.
+ *
+ * @returns Medium ID string, empty on abort.
+ */
+QString VBoxGlobal::createVisoMediumWithFileOpenDialog(QWidget *pParent, const QString &strMachineFolder)
+{
+    AssertReturn(!strMachineFolder.isEmpty(), QString());
+
+    /* Figure out where to start browsing for content. */
+    QString strDirectory = gEDataManager->recentFolderForVISOContent();
+    if (strDirectory.isEmpty())
+        strDirectory = QDir::homePath();
+    if (strDirectory.isEmpty())
+        strDirectory = homeFolder();
+
+    /* Execute the open file dialog, getting a list of files & dirs back. */
+    /** @todo make it possible to select directories... */
+    QStringList files = QIFileDialog::getOpenFileNames(strDirectory, tr("All files (*)"), pParent,
+                                                       /// @todo tr("Please select files and directories to be on the VISO"),
+                                                       tr("Please select files to be on the VISO"),
+                                                       0, true /*aResolveSymlinks*/, false /*aSingleFile*/);
+
+    /* Return if no result. */
+    if (files.empty() || files[0].isEmpty())
+        return QString();
+
+    /* Remember folder for the next time. */
+    gEDataManager->setRecentFolderForVISOContent(QFileInfo(files[0]).absolutePath());
+
+    /* Produce the VISO. */
+    char szVisoPath[RTPATH_MAX];
+    int vrc = RTPathJoin(szVisoPath, sizeof(szVisoPath), strMachineFolder.toUtf8().constData(), "ad-hoc.viso");
+    if (RT_SUCCESS(vrc))
+    {
+        PRTSTREAM pStrmViso;
+        vrc = RTStrmOpen(szVisoPath, "w", &pStrmViso);
+        if (RT_SUCCESS(vrc))
+        {
+            RTUUID Uuid;
+            vrc = RTUuidCreate(&Uuid);
+            if (RT_SUCCESS(vrc))
+            {
+                RTStrmPrintf(pStrmViso, "--iprt-iso-maker-file-marker-bourne-sh %RTuuid\n", &Uuid);
+
+                for (int iFile = 0; iFile < files.size(); iFile++)
+                {
+                    QByteArray const utf8Name = files[iFile].toUtf8();
+                    const char *apszArgv[2] = { utf8Name.constData(), NULL };
+                    char *pszQuoted;
+                    vrc = RTGetOptArgvToString(&pszQuoted, apszArgv, RTGETOPTARGV_CNV_QUOTE_BOURNE_SH);
+                    if (RT_SUCCESS(vrc))
+                    {
+                        RTStrmPrintf(pStrmViso, "%s\n", pszQuoted);
+                        RTStrFree(pszQuoted);
+                    }
+                    else
+                        break;
+                }
+
+                RTStrmFlush(pStrmViso);
+                if (RT_SUCCESS(vrc))
+                    vrc = RTStrmError(pStrmViso);
+            }
+
+            RTStrmClose(pStrmViso);
+        }
+    }
+
+    /* Done. */
+    if (RT_SUCCESS(vrc))
+        return openMedium(UIMediumType_DVD, QString(szVisoPath), pParent);
+
+    /** @todo error message. */
+    return QString();
+}
+
+void VBoxGlobal::prepareStorageMenu(QMenu &menu,
+                                    QObject *pListener, const char *pszSlotName,
+                                    const CMachine &machine, const QString &strControllerName, const StorageSlot &storageSlot)
+{
+    /* Current attachment attributes: */
+    const CMediumAttachment currentAttachment = machine.GetMediumAttachment(strControllerName, storageSlot.port, storageSlot.device);
+    const CMedium currentMedium = currentAttachment.GetMedium();
+    const QString strCurrentID = currentMedium.isNull() ? QString() : currentMedium.GetId();
+    const QString strCurrentLocation = currentMedium.isNull() ? QString() : currentMedium.GetLocation();
+
+    /* Other medium-attachments of same machine: */
+    const CMediumAttachmentVector attachments = machine.GetMediumAttachments();
+
+    /* Determine device & medium types: */
+    const UIMediumType mediumType = mediumTypeToLocal(currentAttachment.GetType());
+    AssertMsgReturnVoid(mediumType != UIMediumType_Invalid, ("Incorrect storage medium type!\n"));
+
+
+    /* Prepare open-existing-medium action: */
+    QAction *pActionOpenExistingMedium = menu.addAction(UIIconPool::iconSet(":/select_file_16px.png"), QString(), pListener, pszSlotName);
+    pActionOpenExistingMedium->setData(QVariant::fromValue(UIMediumTarget(strControllerName, currentAttachment.GetPort(), currentAttachment.GetDevice(),
+                                                                          mediumType)));
+    pActionOpenExistingMedium->setText(QApplication::translate("UIMachineSettingsStorage", "Choose disk image...", "This is used for hard disks, optical media and floppies"));
+
+    /* Prepare ad-hoc-viso action for DVD-ROMs: */
+    if (mediumType == UIMediumType_DVD)
+    {
+        QAction *pActionAdHocViso = menu.addAction(UIIconPool::iconSet(":/select_file_16px.png"), QString(),
+                                                   pListener, pszSlotName);
+        pActionAdHocViso->setData(QVariant::fromValue(UIMediumTarget(strControllerName, currentAttachment.GetPort(),
+                                                                     currentAttachment.GetDevice(), mediumType,
+                                                                     UIMediumTarget::UIMediumTargetType_CreateAdHocVISO)));
+        pActionAdHocViso->setText(QApplication::translate("UIMachineSettingsStorage", "Create ad hoc VISO...", "This is used for optical media"));
+    }
+
+    /* Insert separator: */
+    menu.addSeparator();
+
+
+    /* Get existing-host-drive vector: */
+    CMediumVector mediums;
+    switch (mediumType)
+    {
+        case UIMediumType_DVD:    mediums = vboxGlobal().host().GetDVDDrives(); break;
+        case UIMediumType_Floppy: mediums = vboxGlobal().host().GetFloppyDrives(); break;
+        default: break;
+    }
+    /* Prepare choose-existing-host-drive actions: */
+    foreach (const CMedium &medium, mediums)
+    {
+        /* Make sure host-drive usage is unique: */
+        bool fIsHostDriveUsed = false;
+        foreach (const CMediumAttachment &otherAttachment, attachments)
+        {
+            if (otherAttachment != currentAttachment)
+            {
+                const CMedium &otherMedium = otherAttachment.GetMedium();
+                if (!otherMedium.isNull() && otherMedium.GetId() == medium.GetId())
+                {
+                    fIsHostDriveUsed = true;
+                    break;
+                }
+            }
+        }
+        /* If host-drives usage is unique: */
+        if (!fIsHostDriveUsed)
+        {
+            QAction *pActionChooseHostDrive = menu.addAction(UIMedium(medium, mediumType).name(), pListener, pszSlotName);
+            pActionChooseHostDrive->setCheckable(true);
+            pActionChooseHostDrive->setChecked(!currentMedium.isNull() && medium.GetId() == strCurrentID);
+            pActionChooseHostDrive->setData(QVariant::fromValue(UIMediumTarget(strControllerName, currentAttachment.GetPort(), currentAttachment.GetDevice(),
+                                                                               mediumType, UIMediumTarget::UIMediumTargetType_WithID, medium.GetId())));
+        }
+    }
+
+
+    /* Get recent-medium list: */
+    QStringList recentMediumList;
+    QStringList recentMediumListUsed;
+    switch (mediumType)
+    {
+        case UIMediumType_HardDisk: recentMediumList = gEDataManager->recentListOfHardDrives(); break;
+        case UIMediumType_DVD:      recentMediumList = gEDataManager->recentListOfOpticalDisks(); break;
+        case UIMediumType_Floppy:   recentMediumList = gEDataManager->recentListOfFloppyDisks(); break;
+        default: break;
+    }
+    /* Prepare choose-recent-medium actions: */
+    foreach (const QString &strRecentMediumLocationBase, recentMediumList)
+    {
+        /* Confirm medium uniqueness: */
+        if (recentMediumListUsed.contains(strRecentMediumLocationBase))
+            continue;
+        /* Mark medium as known: */
+        recentMediumListUsed << strRecentMediumLocationBase;
+        /* Convert separators to native: */
+        const QString strRecentMediumLocation = QDir::toNativeSeparators(strRecentMediumLocationBase);
+        /* Confirm medium presence: */
+        if (!QFile::exists(strRecentMediumLocation))
+            continue;
+        /* Make sure recent-medium usage is unique: */
+        bool fIsRecentMediumUsed = false;
+        foreach (const CMediumAttachment &otherAttachment, attachments)
+        {
+            if (otherAttachment != currentAttachment)
+            {
+                const CMedium &otherMedium = otherAttachment.GetMedium();
+                if (!otherMedium.isNull() && otherMedium.GetLocation() == strRecentMediumLocation)
+                {
+                    fIsRecentMediumUsed = true;
+                    break;
+                }
+            }
+        }
+        /* If recent-medium usage is unique: */
+        if (!fIsRecentMediumUsed)
+        {
+            QAction *pActionChooseRecentMedium = menu.addAction(QFileInfo(strRecentMediumLocation).fileName(), pListener, pszSlotName);
+            pActionChooseRecentMedium->setCheckable(true);
+            pActionChooseRecentMedium->setChecked(!currentMedium.isNull() && strRecentMediumLocation == strCurrentLocation);
+            pActionChooseRecentMedium->setData(QVariant::fromValue(UIMediumTarget(strControllerName, currentAttachment.GetPort(), currentAttachment.GetDevice(),
+                                                                                  mediumType, UIMediumTarget::UIMediumTargetType_WithLocation, strRecentMediumLocation)));
+            pActionChooseRecentMedium->setToolTip(strRecentMediumLocation);
+        }
+    }
+
+
+    /* Last action for optical/floppy attachments only: */
+    if (mediumType == UIMediumType_DVD || mediumType == UIMediumType_Floppy)
+    {
+        /* Insert separator: */
+        menu.addSeparator();
+
+        /* Prepare unmount-current-medium action: */
+        QAction *pActionUnmountMedium = menu.addAction(QString(), pListener, pszSlotName);
+        pActionUnmountMedium->setEnabled(!currentMedium.isNull());
+        pActionUnmountMedium->setData(QVariant::fromValue(UIMediumTarget(strControllerName, currentAttachment.GetPort(), currentAttachment.GetDevice())));
+        pActionUnmountMedium->setText(QApplication::translate("UIMachineSettingsStorage", "Remove disk from virtual drive"));
+        if (mediumType == UIMediumType_DVD)
+            pActionUnmountMedium->setIcon(UIIconPool::iconSet(":/cd_unmount_16px.png", ":/cd_unmount_disabled_16px.png"));
+        else if (mediumType == UIMediumType_Floppy)
+            pActionUnmountMedium->setIcon(UIIconPool::iconSet(":/fd_unmount_16px.png", ":/fd_unmount_disabled_16px.png"));
+    }
+}
+
+void VBoxGlobal::updateMachineStorage(const CMachine &constMachine, const UIMediumTarget &target)
+{
+    /* Mount (by default): */
+    bool fMount = true;
+    /* Null medium (by default): */
+    CMedium cmedium;
+    /* With null ID (by default): */
+    QString strActualID;
+
+    /* Current mount-target attributes: */
+    const CStorageController currentController = constMachine.GetStorageControllerByName(target.name);
+    const KStorageBus currentStorageBus = currentController.GetBus();
+    const CMediumAttachment currentAttachment = constMachine.GetMediumAttachment(target.name, target.port, target.device);
+    const CMedium currentMedium = currentAttachment.GetMedium();
+    const QString strCurrentID = currentMedium.isNull() ? QString() : currentMedium.GetId();
+    const QString strCurrentLocation = currentMedium.isNull() ? QString() : currentMedium.GetLocation();
+
+    /* Which additional info do we have? */
+    switch (target.type)
+    {
+        /* Do we have an exact ID or do we let the user open a medium? */
+        case UIMediumTarget::UIMediumTargetType_WithID:
+        case UIMediumTarget::UIMediumTargetType_CreateAdHocVISO:
+        {
+            /* New mount-target attributes: */
+            QString strNewID;
+
+            /* Invoke file-open dialog to choose medium ID: */
+            if (target.mediumType != UIMediumType_Invalid && target.data.isNull())
+            {
+                /* Keyboard can be captured by machine-view.
+                 * So we should clear machine-view focus to let file-open dialog get it.
+                 * That way the keyboard will be released too.. */
+                QWidget *pLastFocusedWidget = 0;
+                if (QApplication::focusWidget())
+                {
+                    pLastFocusedWidget = QApplication::focusWidget();
+                    pLastFocusedWidget->clearFocus();
+                }
+                /* Call for file-open dialog: */
+                const QString strMachineFolder(QFileInfo(constMachine.GetSettingsFilePath()).absolutePath());
+                const QString strMediumID = target.type != UIMediumTarget::UIMediumTargetType_CreateAdHocVISO
+                                          ? vboxGlobal().openMediumWithFileOpenDialog(target.mediumType,
+                                                                                      windowManager().mainWindowShown(),
+                                                                                      strMachineFolder)
+                                          : vboxGlobal().createVisoMediumWithFileOpenDialog(windowManager().mainWindowShown(),
+                                                                                            strMachineFolder);
+                /* Return focus back: */
+                if (pLastFocusedWidget)
+                    pLastFocusedWidget->setFocus();
+                /* Accept new medium ID: */
+                if (!strMediumID.isNull())
+                    strNewID = strMediumID;
+                /* Else just exit: */
+                else return;
+            }
+            /* Use medium ID which was passed: */
+            else if (!target.data.isNull() && target.data != strCurrentID)
+                strNewID = target.data;
+
+            /* Should we mount or unmount? */
+            fMount = !strNewID.isEmpty();
+
+            /* Prepare target medium: */
+            const UIMedium uimedium = vboxGlobal().medium(strNewID);
+            cmedium = uimedium.medium();
+            strActualID = fMount ? strNewID : strCurrentID;
+            break;
+        }
+        /* Do we have a resent location? */
+        case UIMediumTarget::UIMediumTargetType_WithLocation:
+        {
+            /* Open medium by location and get new medium ID if any: */
+            const QString strNewID = vboxGlobal().openMedium(target.mediumType, target.data);
+            /* Else just exit: */
+            if (strNewID.isEmpty())
+                return;
+
+            /* Should we mount or unmount? */
+            fMount = strNewID != strCurrentID;
+
+            /* Prepare target medium: */
+            const UIMedium uimedium = fMount ? vboxGlobal().medium(strNewID) : UIMedium();
+            cmedium = fMount ? uimedium.medium() : CMedium();
+            strActualID = fMount ? strNewID : strCurrentID;
+            break;
+        }
+    }
+
+    /* Do not unmount hard-drives: */
+    if (target.mediumType == UIMediumType_HardDisk && !fMount)
+        return;
+
+    /* Get editable machine: */
+    CSession session;
+    CMachine machine = constMachine;
+    KSessionState sessionState = machine.GetSessionState();
+    /* Session state unlocked? */
+    if (sessionState == KSessionState_Unlocked)
+    {
+        /* Open own 'write' session: */
+        session = openSession(machine.GetId());
+        AssertReturnVoid(!session.isNull());
+        machine = session.GetMachine();
+    }
+    /* Is it Selector UI call? */
+    else if (!isVMConsoleProcess())
+    {
+        /* Open existing 'shared' session: */
+        session = openExistingSession(machine.GetId());
+        AssertReturnVoid(!session.isNull());
+        machine = session.GetMachine();
+    }
+    /* Else this is Runtime UI call
+     * which has session locked for itself. */
+
+    /* Remount medium to the predefined port/device: */
+    bool fWasMounted = false;
+    /* Hard drive case: */
+    if (target.mediumType == UIMediumType_HardDisk)
+    {
+        /* Detaching: */
+        machine.DetachDevice(target.name, target.port, target.device);
+        fWasMounted = machine.isOk();
+        if (!fWasMounted)
+            msgCenter().cannotDetachDevice(machine, UIMediumType_HardDisk, strCurrentLocation,
+                                           StorageSlot(currentStorageBus, target.port, target.device));
+        else
+        {
+            /* Attaching: */
+            machine.AttachDevice(target.name, target.port, target.device, KDeviceType_HardDisk, cmedium);
+            fWasMounted = machine.isOk();
+            if (!fWasMounted)
+                msgCenter().cannotAttachDevice(machine, UIMediumType_HardDisk, strCurrentLocation,
+                                               StorageSlot(currentStorageBus, target.port, target.device));
+        }
+    }
+    /* Optical/floppy drive case: */
+    else
+    {
+        /* Remounting: */
+        machine.MountMedium(target.name, target.port, target.device, cmedium, false /* force? */);
+        fWasMounted = machine.isOk();
+        if (!fWasMounted)
+        {
+            /* Ask for force remounting: */
+            if (msgCenter().cannotRemountMedium(machine, vboxGlobal().medium(strActualID),
+                                                fMount, true /* retry? */))
+            {
+                /* Force remounting: */
+                machine.MountMedium(target.name, target.port, target.device, cmedium, true /* force? */);
+                fWasMounted = machine.isOk();
+                if (!fWasMounted)
+                    msgCenter().cannotRemountMedium(machine, vboxGlobal().medium(strActualID),
+                                                    fMount, false /* retry? */);
+            }
+        }
+        /* If mounting was successful: */
+        if (fWasMounted)
+        {
+            /* Disable First RUN Wizard: */
+            if (gEDataManager->machineFirstTimeStarted(machine.GetId()))
+                gEDataManager->setMachineFirstTimeStarted(false, machine.GetId());
+        }
+    }
+
+    /* Save settings: */
+    if (fWasMounted)
+    {
+        machine.SaveSettings();
+        if (!machine.isOk())
+            msgCenter().cannotSaveMachineSettings(machine, windowManager().mainWindowShown());
+    }
+
+    /* Close session to editable machine if necessary: */
+    if (!session.isNull())
+        session.UnlockMachine();
+}
+
+QString VBoxGlobal::details(const CMedium &cmedium, bool fPredictDiff, bool fUseHtml /* = true*/)
+{
+    /* Search for corresponding UI medium: */
+    const QString strMediumID = cmedium.isNull() ? UIMedium::nullID() : cmedium.GetId();
+    UIMedium uimedium = medium(strMediumID);
+    if (!cmedium.isNull() && uimedium.isNull())
+    {
+        /* UI medium may be new and not among our mediums, request enumeration: */
+        startMediumEnumeration();
+
+        /* Search for corresponding UI medium again: */
+
+        uimedium = medium(strMediumID);
+        if (uimedium.isNull())
+        {
+            /* Medium might be deleted already, return null string: */
+            return QString();
+        }
+    }
+
+    /* Return UI medium details: */
+    return fUseHtml ? uimedium.detailsHTML(true /* aNoDiffs */, fPredictDiff) :
+                      uimedium.details(true /* aNoDiffs */, fPredictDiff);
+}
+
+#ifdef RT_OS_LINUX
+/* static */
+void VBoxGlobal::checkForWrongUSBMounted()
+{
+    /* Make sure '/proc/mounts' exists and can be opened: */
+    QFile file("/proc/mounts");
+    if (!file.exists() || !file.open(QIODevice::ReadOnly | QIODevice::Text))
+        return;
+
+    /* Fetch contents: */
+    QStringList contents;
+    for (;;)
+    {
+        QByteArray line = file.readLine();
+        if (line.isEmpty())
+            break;
+        contents << line;
+    }
+    /* Grep contents for usbfs presence: */
+    QStringList grep1(contents.filter("/sys/bus/usb/drivers"));
+    QStringList grep2(grep1.filter("usbfs"));
+    if (grep2.isEmpty())
+        return;
+
+    /* Show corresponding warning: */
+    msgCenter().warnAboutWrongUSBMounted();
+}
+#endif /* RT_OS_LINUX */
+
+/**
+ *  Returns the details of the given USB device as a single-line string.
+ */
+QString VBoxGlobal::details (const CUSBDevice &aDevice) const
+{
+    QString sDetails;
+    if (aDevice.isNull())
+        sDetails = tr("Unknown device", "USB device details");
+    else
+    {
+        QVector<QString> devInfoVector = aDevice.GetDeviceInfo();
+        QString m;
+        QString p;
+
+        if (devInfoVector.size() >= 1)
+            m = devInfoVector[0].trimmed();
+        if (devInfoVector.size() >= 2)
+            p = devInfoVector[1].trimmed();
+
+        if (m.isEmpty() && p.isEmpty())
+        {
+            sDetails =
+                tr ("Unknown device %1:%2", "USB device details")
+                .arg (QString().sprintf ("%04hX", aDevice.GetVendorId()))
+                .arg (QString().sprintf ("%04hX", aDevice.GetProductId()));
+        }
+        else
+        {
+            if (p.toUpper().startsWith (m.toUpper()))
+                sDetails = p;
+            else
+                sDetails = m + " " + p;
+        }
+        ushort r = aDevice.GetRevision();
+        if (r != 0)
+            sDetails += QString().sprintf (" [%04hX]", r);
+    }
+
+    return sDetails.trimmed();
+}
+
+/**
+ *  Returns the multi-line description of the given USB device.
+ */
+QString VBoxGlobal::toolTip (const CUSBDevice &aDevice) const
+{
+    QString tip =
+        tr ("<nobr>Vendor ID: %1</nobr><br>"
+            "<nobr>Product ID: %2</nobr><br>"
+            "<nobr>Revision: %3</nobr>", "USB device tooltip")
+        .arg (QString().sprintf ("%04hX", aDevice.GetVendorId()))
+        .arg (QString().sprintf ("%04hX", aDevice.GetProductId()))
+        .arg (QString().sprintf ("%04hX", aDevice.GetRevision()));
+
+    QString ser = aDevice.GetSerialNumber();
+    if (!ser.isEmpty())
+        tip += QString (tr ("<br><nobr>Serial No. %1</nobr>", "USB device tooltip"))
+                        .arg (ser);
+
+    /* add the state field if it's a host USB device */
+    CHostUSBDevice hostDev (aDevice);
+    if (!hostDev.isNull())
+    {
+        tip += QString (tr ("<br><nobr>State: %1</nobr>", "USB device tooltip"))
+                        .arg (gpConverter->toString (hostDev.GetState()));
+    }
+
+    return tip;
+}
+
+/**
+ *  Returns the multi-line description of the given USB filter
+ */
+QString VBoxGlobal::toolTip (const CUSBDeviceFilter &aFilter) const
+{
+    QString tip;
+
+    QString vendorId = aFilter.GetVendorId();
+    if (!vendorId.isEmpty())
+        tip += tr ("<nobr>Vendor ID: %1</nobr>", "USB filter tooltip")
+                   .arg (vendorId);
+
+    QString productId = aFilter.GetProductId();
+    if (!productId.isEmpty())
+        tip += tip.isEmpty() ? "":"<br/>" + tr ("<nobr>Product ID: %2</nobr>", "USB filter tooltip")
+                                                .arg (productId);
+
+    QString revision = aFilter.GetRevision();
+    if (!revision.isEmpty())
+        tip += tip.isEmpty() ? "":"<br/>" + tr ("<nobr>Revision: %3</nobr>", "USB filter tooltip")
+                                                .arg (revision);
+
+    QString product = aFilter.GetProduct();
+    if (!product.isEmpty())
+        tip += tip.isEmpty() ? "":"<br/>" + tr ("<nobr>Product: %4</nobr>", "USB filter tooltip")
+                                                .arg (product);
+
+    QString manufacturer = aFilter.GetManufacturer();
+    if (!manufacturer.isEmpty())
+        tip += tip.isEmpty() ? "":"<br/>" + tr ("<nobr>Manufacturer: %5</nobr>", "USB filter tooltip")
+                                                .arg (manufacturer);
+
+    QString serial = aFilter.GetSerialNumber();
+    if (!serial.isEmpty())
+        tip += tip.isEmpty() ? "":"<br/>" + tr ("<nobr>Serial No.: %1</nobr>", "USB filter tooltip")
+                                                .arg (serial);
+
+    QString port = aFilter.GetPort();
+    if (!port.isEmpty())
+        tip += tip.isEmpty() ? "":"<br/>" + tr ("<nobr>Port: %1</nobr>", "USB filter tooltip")
+                                                .arg (port);
+
+    /* add the state field if it's a host USB device */
+    CHostUSBDevice hostDev (aFilter);
+    if (!hostDev.isNull())
+    {
+        tip += tip.isEmpty() ? "":"<br/>" + tr ("<nobr>State: %1</nobr>", "USB filter tooltip")
+                                                .arg (gpConverter->toString (hostDev.GetState()));
+    }
+
+    return tip;
+}
+
+/** Returns the multi-line description of the given CHostVideoInputDevice filter. */
+QString VBoxGlobal::toolTip(const CHostVideoInputDevice &webcam) const
+{
+    QStringList records;
+
+    QString strName = webcam.GetName();
+    if (!strName.isEmpty())
+        records << strName;
+
+    QString strPath = webcam.GetPath();
+    if (!strPath.isEmpty())
+        records << strPath;
+
+    return records.join("<br>");
+}
 
 /* static */
@@ -3545,6 +3521,288 @@
 }
 
-// Public slots
-////////////////////////////////////////////////////////////////////////////////
+/**
+ * Inner worker that for lazily querying for 3D support.
+ *
+ * Rational is that when starting a text mode guest (like DOS) that does not
+ * have 3D enabled, don't wast the developer's or user's time on launching the
+ * test application when starting the VM or editing it's settings.
+ *
+ * @returns true / false.
+ * @note If we ever end up checking this concurrently on multiple threads, use a
+ *       RTONCE construct to serialize the efforts.
+ */
+bool VBoxGlobal::is3DAvailableWorker() const
+{
+#ifdef VBOX_WITH_CROGL
+    bool fSupported = VBoxOglIs3DAccelerationSupported();
+#else
+    bool fSupported = false;
+#endif
+    unconst(this)->m3DAvailable = fSupported;
+    return fSupported;
+}
+
+#ifdef VBOX_WITH_CRHGSMI
+/* static */
+bool VBoxGlobal::isWddmCompatibleOsType(const QString &strGuestOSTypeId)
+{
+    return    strGuestOSTypeId.startsWith("WindowsVista")
+           || strGuestOSTypeId.startsWith("Windows7")
+           || strGuestOSTypeId.startsWith("Windows8")
+           || strGuestOSTypeId.startsWith("Windows81")
+           || strGuestOSTypeId.startsWith("Windows10")
+           || strGuestOSTypeId.startsWith("Windows2008")
+           || strGuestOSTypeId.startsWith("Windows2012");
+}
+#endif /* VBOX_WITH_CRHGSMI */
+
+/**
+ *  Returns the required video memory in bytes for the current desktop
+ *  resolution at maximum possible screen depth in bpp.
+ */
+/* static */
+quint64 VBoxGlobal::requiredVideoMemory(const QString &strGuestOSTypeId, int cMonitors /* = 1 */)
+{
+    /* We create a list of the size of all available host monitors. This list
+     * is sorted by value and by starting with the biggest one, we calculate
+     * the memory requirements for every guest screen. This is of course not
+     * correct, but as we can't predict on which host screens the user will
+     * open the guest windows, this is the best assumption we can do, cause it
+     * is the worst case. */
+    const int cHostScreens = gpDesktop->screenCount();
+    QVector<int> screenSize(qMax(cMonitors, cHostScreens), 0);
+    for (int i = 0; i < cHostScreens; ++i)
+    {
+        QRect r = gpDesktop->screenGeometry(i);
+        screenSize[i] = r.width() * r.height();
+    }
+    /* Now sort the vector */
+    qSort(screenSize.begin(), screenSize.end(), qGreater<int>());
+    /* For the case that there are more guest screens configured then host
+     * screens available, replace all zeros with the greatest value in the
+     * vector. */
+    for (int i = 0; i < screenSize.size(); ++i)
+        if (screenSize.at(i) == 0)
+            screenSize.replace(i, screenSize.at(0));
+
+    quint64 needBits = 0;
+    for (int i = 0; i < cMonitors; ++i)
+    {
+        /* Calculate summary required memory amount in bits */
+        needBits += (screenSize.at(i) * /* with x height */
+                     32 + /* we will take the maximum possible bpp for now */
+                     8 * _1M) + /* current cache per screen - may be changed in future */
+                    8 * 4096; /* adapter info */
+    }
+    /* Translate value into megabytes with rounding to highest side */
+    quint64 needMBytes = needBits % (8 * _1M) ? needBits / (8 * _1M) + 1 :
+                         needBits / (8 * _1M) /* convert to megabytes */;
+
+    if (strGuestOSTypeId.startsWith("Windows"))
+    {
+       /* Windows guests need offscreen VRAM too for graphics acceleration features: */
+#ifdef VBOX_WITH_CRHGSMI
+       if (isWddmCompatibleOsType(strGuestOSTypeId))
+       {
+           /* wddm mode, there are two surfaces for each screen: shadow & primary */
+           needMBytes *= 3;
+       }
+       else
+#endif /* VBOX_WITH_CRHGSMI */
+       {
+           needMBytes *= 2;
+       }
+    }
+
+    return needMBytes * _1M;
+}
+
+QIcon VBoxGlobal::vmUserIcon(const CMachine &comMachine) const
+{
+    /* Prepare fallback icon: */
+    static QIcon nullIcon;
+
+    /* Make sure general icon-pool initialized: */
+    AssertReturn(m_pIconPool, nullIcon);
+
+    /* Redirect to general icon-pool: */
+    return m_pIconPool->userMachineIcon(comMachine);
+}
+
+QPixmap VBoxGlobal::vmUserPixmap(const CMachine &comMachine, const QSize &size) const
+{
+    /* Prepare fallback pixmap: */
+    static QPixmap nullPixmap;
+
+    /* Make sure general icon-pool initialized: */
+    AssertReturn(m_pIconPool, nullPixmap);
+
+    /* Redirect to general icon-pool: */
+    return m_pIconPool->userMachinePixmap(comMachine, size);
+}
+
+QPixmap VBoxGlobal::vmUserPixmapDefault(const CMachine &comMachine, QSize *pLogicalSize /* = 0 */) const
+{
+    /* Prepare fallback pixmap: */
+    static QPixmap nullPixmap;
+
+    /* Make sure general icon-pool initialized: */
+    AssertReturn(m_pIconPool, nullPixmap);
+
+    /* Redirect to general icon-pool: */
+    return m_pIconPool->userMachinePixmapDefault(comMachine, pLogicalSize);
+}
+
+QIcon VBoxGlobal::vmGuestOSTypeIcon(const QString &strOSTypeID) const
+{
+    /* Prepare fallback icon: */
+    static QIcon nullIcon;
+
+    /* Make sure general icon-pool initialized: */
+    AssertReturn(m_pIconPool, nullIcon);
+
+    /* Redirect to general icon-pool: */
+    return m_pIconPool->guestOSTypeIcon(strOSTypeID);
+}
+
+QPixmap VBoxGlobal::vmGuestOSTypePixmap(const QString &strOSTypeID, const QSize &size) const
+{
+    /* Prepare fallback pixmap: */
+    static QPixmap nullPixmap;
+
+    /* Make sure general icon-pool initialized: */
+    AssertReturn(m_pIconPool, nullPixmap);
+
+    /* Redirect to general icon-pool: */
+    return m_pIconPool->guestOSTypePixmap(strOSTypeID, size);
+}
+
+QPixmap VBoxGlobal::vmGuestOSTypePixmapDefault(const QString &strOSTypeID, QSize *pLogicalSize /* = 0 */) const
+{
+    /* Prepare fallback pixmap: */
+    static QPixmap nullPixmap;
+
+    /* Make sure general icon-pool initialized: */
+    AssertReturn(m_pIconPool, nullPixmap);
+
+    /* Redirect to general icon-pool: */
+    return m_pIconPool->guestOSTypePixmapDefault(strOSTypeID, pLogicalSize);
+}
+
+/**
+ * Joins two pixmaps horizontally with 2px space between them and returns the
+ * result.
+ *
+ * @param aPM1 Left pixmap.
+ * @param aPM2 Right pixmap.
+ */
+/* static */
+QPixmap VBoxGlobal::joinPixmaps (const QPixmap &aPM1, const QPixmap &aPM2)
+{
+    if (aPM1.isNull())
+        return aPM2;
+    if (aPM2.isNull())
+        return aPM1;
+
+    QPixmap result (aPM1.width() + aPM2.width() + 2,
+                    qMax (aPM1.height(), aPM2.height()));
+    result.fill (Qt::transparent);
+
+    QPainter painter (&result);
+    painter.drawPixmap (0, 0, aPM1);
+    painter.drawPixmap (aPM1.width() + 2, result.height() - aPM2.height(), aPM2);
+    painter.end();
+
+    return result;
+}
+
+/**
+ *  Replacement for QToolButton::setTextLabel() that handles the shortcut
+ *  letter (if it is present in the argument string) as if it were a setText()
+ *  call: the shortcut letter is used to automatically assign an "Alt+<letter>"
+ *  accelerator key sequence to the given tool button.
+ *
+ *  @note This method preserves the icon set if it was assigned before. Only
+ *  the text label and the accelerator are changed.
+ *
+ *  @param aToolButton  Tool button to set the text label on.
+ *  @param aTextLabel   Text label to set.
+ */
+/* static */
+void VBoxGlobal::setTextLabel (QToolButton *aToolButton,
+                               const QString &aTextLabel)
+{
+    AssertReturnVoid (aToolButton != NULL);
+
+    /* remember the icon set as setText() will kill it */
+    QIcon iset = aToolButton->icon();
+    /* re-use the setText() method to detect and set the accelerator */
+    aToolButton->setText (aTextLabel);
+    QKeySequence accel = aToolButton->shortcut();
+    aToolButton->setText (aTextLabel);
+    aToolButton->setIcon (iset);
+    /* set the accel last as setIconSet() would kill it */
+    aToolButton->setShortcut (accel);
+}
+
+/**
+ * Puts soft hyphens after every path component in the given file name.
+ *
+ * @param aFileName File name (must be a full path name).
+ */
+/* static */
+QString VBoxGlobal::locationForHTML (const QString &aFileName)
+{
+/// @todo (dmik) remove?
+//    QString result = QDir::toNativeSeparators (fn);
+//#ifdef Q_OS_LINUX
+//    result.replace ('/', "/<font color=red>&shy;</font>");
+//#else
+//    result.replace ('\\', "\\<font color=red>&shy;</font>");
+//#endif
+//    return result;
+    QFileInfo fi (aFileName);
+    return fi.fileName();
+}
+
+/**
+ *  Searches for a widget that with @a aName (if it is not NULL) which inherits
+ *  @a aClassName (if it is not NULL) and among children of @a aParent. If @a
+ *  aParent is NULL, all top-level widgets are searched. If @a aRecursive is
+ *  true, child widgets are recursively searched as well.
+ */
+/* static */
+QWidget *VBoxGlobal::findWidget (QWidget *aParent, const char *aName,
+                                 const char *aClassName /* = NULL */,
+                                 bool aRecursive /* = false */)
+{
+    if (aParent == NULL)
+    {
+        QWidgetList list = QApplication::topLevelWidgets();
+        foreach(QWidget *w, list)
+        {
+            if ((!aName || strcmp (w->objectName().toLatin1().constData(), aName) == 0) &&
+                (!aClassName || strcmp (w->metaObject()->className(), aClassName) == 0))
+                return w;
+            if (aRecursive)
+            {
+                w = findWidget (w, aName, aClassName, aRecursive);
+                if (w)
+                    return w;
+            }
+        }
+        return NULL;
+    }
+
+    /* Find the first children of aParent with the appropriate properties.
+     * Please note that this call is recursively. */
+    QList<QWidget *> list = aParent->findChildren<QWidget*>(aName);
+    foreach(QWidget *child, list)
+    {
+        if (!aClassName || strcmp (child->metaObject()->className(), aClassName) == 0)
+            return child;
+    }
+    return NULL;
+}
 
 /**
@@ -3639,7 +3897,4 @@
 }
 
-// Protected members
-////////////////////////////////////////////////////////////////////////////////
-
 bool VBoxGlobal::eventFilter (QObject *aObject, QEvent *aEvent)
 {
@@ -3663,78 +3918,27 @@
 }
 
-#ifdef VBOX_WITH_DEBUGGER_GUI
-
-bool VBoxGlobal::isDebuggerEnabled() const
-{
-    return isDebuggerWorker(&m_fDbgEnabled, GUI_Dbg_Enabled);
-}
-
-bool VBoxGlobal::isDebuggerAutoShowEnabled() const
-{
-    return isDebuggerWorker(&m_fDbgAutoShow, GUI_Dbg_AutoShow);
-}
-
-bool VBoxGlobal::isDebuggerAutoShowCommandLineEnabled() const
-{
-    return isDebuggerWorker(&m_fDbgAutoShowCommandLine, GUI_Dbg_AutoShow);
-}
-
-bool VBoxGlobal::isDebuggerAutoShowStatisticsEnabled() const
-{
-    return isDebuggerWorker(&m_fDbgAutoShowStatistics, GUI_Dbg_AutoShow);
-}
-
-#endif /* VBOX_WITH_DEBUGGER_GUI */
-
-// Private members
-////////////////////////////////////////////////////////////////////////////////
-
-bool VBoxGlobal::processArgs()
-{
-    bool fResult = false;
-    QStringList args = qApp->arguments();
-    QList<QUrl> list;
-    for (int i = 1; i < args.size(); ++i)
-    {
-        /* We break out after the first parameter, cause there could be
-           parameters with arguments (e.g. --comment comment). */
-        if (args.at(i).startsWith("-"))
-            break;
-#ifdef VBOX_WS_MAC
-        QString strArg = ::darwinResolveAlias(args.at(i));
-#else /* VBOX_WS_MAC */
-        QString strArg = args.at(i);
-#endif /* !VBOX_WS_MAC */
-        if (   !strArg.isEmpty()
-            && QFile::exists(strArg))
-            list << QUrl::fromLocalFile(strArg);
-    }
-    if (!list.isEmpty())
-    {
-        for (int i = 0; i < list.size(); ++i)
-        {
-            const QString& strFile = list.at(i).toLocalFile();
-            if (VBoxGlobal::hasAllowedExtension(strFile, VBoxFileExts))
-            {
-                CVirtualBox vbox = virtualBox();
-                CMachine machine = vbox.FindMachine(strFile);
-                if (!machine.isNull())
-                {
-                    fResult = true;
-                    launchMachine(machine);
-                    /* Remove from the arg list. */
-                    list.removeAll(strFile);
-                }
-            }
-        }
-    }
-    if (!list.isEmpty())
-    {
-        /* Store the URLs: */
-        m_ArgUrlList = list;
-        /* Ask UIStarter to open them: */
-        emit sigAskToOpenURLs();
-    }
-    return fResult;
+/**
+ *  Changes the language of all global string constants according to the
+ *  currently installed translations tables.
+ */
+void VBoxGlobal::retranslateUi()
+{
+    mUserDefinedPortName = tr ("User-defined", "serial port");
+
+    mWarningIcon = UIIconPool::defaultIcon(UIIconPool::UIDefaultIconType_MessageBoxWarning).pixmap (16, 16);
+    Assert (!mWarningIcon.isNull());
+
+    mErrorIcon = UIIconPool::defaultIcon(UIIconPool::UIDefaultIconType_MessageBoxCritical).pixmap (16, 16);
+    Assert (!mErrorIcon.isNull());
+
+    /* Re-enumerate uimedium since they contain some translations too: */
+    if (mValid)
+        startMediumEnumeration();
+
+#ifdef VBOX_WS_X11
+    /* As X11 do not have functionality for providing human readable key names,
+     * we keep a table of them, which must be updated when the language is changed. */
+    UINativeHotKey::retranslateKeyNames();
+#endif /* VBOX_WS_X11 */
 }
 
@@ -4225,20 +4429,4 @@
 }
 
-#ifdef VBOX_WS_WIN
-/* static */
-BOOL VBoxGlobal::ShutdownBlockReasonCreateAPI(HWND hWnd, LPCWSTR pwszReason)
-{
-    BOOL fResult = FALSE;
-    typedef BOOL(WINAPI *PFNSHUTDOWNBLOCKREASONCREATE)(HWND hWnd, LPCWSTR pwszReason);
-
-    PFNSHUTDOWNBLOCKREASONCREATE pfn = (PFNSHUTDOWNBLOCKREASONCREATE)GetProcAddress(
-        GetModuleHandle(L"User32.dll"), "ShutdownBlockReasonCreate");
-    _ASSERTE(pfn);
-    if (pfn)
-        fResult = pfn(hWnd, pwszReason);
-    return fResult;
-}
-#endif
-
 void VBoxGlobal::sltHandleCommitDataRequest(QSessionManager &manager)
 {
@@ -4320,41 +4508,19 @@
 }
 
-void VBoxGlobal::comWrappersReinit()
-{
-    /* Re-fetch corresponding objects/values: */
-    m_host = virtualBox().GetHost();
-    m_strHomeFolder = virtualBox().GetHomeFolder();
-
-    /* Re-initialize guest OS Type list: */
-    m_guestOSFamilyIDs.clear();
-    m_guestOSTypes.clear();
-    const CGuestOSTypeVector guestOSTypes = m_vbox.GetGuestOSTypes();
-    const int cGuestOSTypeCount = guestOSTypes.size();
-    AssertMsg(cGuestOSTypeCount > 0, ("Number of OS types must not be zero"));
-    if (cGuestOSTypeCount > 0)
-    {
-        /* Here we ASSUME the 'Other' types are always the first,
-         * so we remember them and will append them to the list when finished.
-         * We do a two pass, first adding the specific types, then the two 'Other' types. */
-        for (int j = 0; j < 2; ++j)
-        {
-            int cMax = j == 0 ? cGuestOSTypeCount : RT_MIN(2, cGuestOSTypeCount);
-            for (int i = j == 0 ? 2 : 0; i < cMax; ++i)
-            {
-                const CGuestOSType os = guestOSTypes.at(i);
-                const QString strFamilyID = os.GetFamilyId();
-                if (!m_guestOSFamilyIDs.contains(strFamilyID))
-                {
-                    m_guestOSFamilyIDs << strFamilyID;
-                    m_guestOSTypes << QList<CGuestOSType>();
-                }
-                m_guestOSTypes[m_guestOSFamilyIDs.indexOf(strFamilyID)].append(os);
-            }
-        }
-    }
-
-    /* Mark wrappers valid: */
-    m_fWrappersValid = true;
-}
+#ifdef VBOX_WS_WIN
+/* static */
+BOOL VBoxGlobal::ShutdownBlockReasonCreateAPI(HWND hWnd, LPCWSTR pwszReason)
+{
+    BOOL fResult = FALSE;
+    typedef BOOL(WINAPI *PFNSHUTDOWNBLOCKREASONCREATE)(HWND hWnd, LPCWSTR pwszReason);
+
+    PFNSHUTDOWNBLOCKREASONCREATE pfn = (PFNSHUTDOWNBLOCKREASONCREATE)GetProcAddress(
+        GetModuleHandle(L"User32.dll"), "ShutdownBlockReasonCreate");
+    _ASSERTE(pfn);
+    if (pfn)
+        fResult = pfn(hWnd, pwszReason);
+    return fResult;
+}
+#endif
 
 #ifdef VBOX_WITH_DEBUGGER_GUI
@@ -4471,227 +4637,39 @@
 #endif /* VBOX_WITH_DEBUGGER_GUI */
 
-bool VBoxGlobal::switchToMachine(CMachine &machine)
-{
-#ifdef VBOX_WS_MAC
-    ULONG64 id = machine.ShowConsoleWindow();
-#else
-    WId id = (WId) machine.ShowConsoleWindow();
-#endif
-    AssertWrapperOk(machine);
-    if (!machine.isOk())
-        return false;
-
-    /* winId = 0 it means the console window has already done everything
-     * necessary to implement the "show window" semantics. */
-    if (id == 0)
-        return true;
-
-#if defined(VBOX_WS_WIN) || defined(VBOX_WS_X11)
-
-    return vboxGlobal().activateWindow(id, true);
-
-#elif defined(VBOX_WS_MAC)
-    /*
-     * This is just for the case were the other process cannot steal
-     * the focus from us. It will send us a PSN so we can try.
-     */
-    ProcessSerialNumber psn;
-    psn.highLongOfPSN = id >> 32;
-    psn.lowLongOfPSN = (UInt32)id;
-# ifdef __clang__
-#  pragma GCC diagnostic push
-#  pragma GCC diagnostic ignored "-Wdeprecated-declarations"
-    OSErr rc = ::SetFrontProcess(&psn);
-#  pragma GCC diagnostic pop
-# else
-    OSErr rc = ::SetFrontProcess(&psn);
-# endif
-    if (!rc)
-        Log(("GUI: %#RX64 couldn't do SetFrontProcess on itself, the selector (we) had to do it...\n", id));
-    else
-        Log(("GUI: Failed to bring %#RX64 to front. rc=%#x\n", id, rc));
-    return !rc;
-
-#else
-
-    return false;
-
-#endif
-
-
-    /// @todo Below is the old method of switching to the console window
-    //  based on the process ID of the console process. It should go away
-    //  after the new (callback-based) method is fully tested.
-#if 0
-
-    if (!canSwitchTo())
-        return false;
-
-#if defined (VBOX_WS_WIN)
-
-    HWND hwnd = mWinId;
-
-    /* if there are blockers (modal and modeless dialogs, etc), find the
-     * topmost one */
-    HWND hwndAbove = NULL;
-    do
-    {
-        hwndAbove = GetNextWindow(hwnd, GW_HWNDPREV);
-        HWND hwndOwner;
-        if (hwndAbove != NULL &&
-            ((hwndOwner = GetWindow(hwndAbove, GW_OWNER)) == hwnd ||
-             hwndOwner  == hwndAbove))
-            hwnd = hwndAbove;
-        else
-            break;
-    }
-    while (1);
-
-    /* first, check that the primary window is visible */
-    if (IsIconic(mWinId))
-        ShowWindow(mWinId, SW_RESTORE);
-    else if (!IsWindowVisible(mWinId))
-        ShowWindow(mWinId, SW_SHOW);
-
-#if 0
-    LogFlowFunc(("mWinId=%08X hwnd=%08X\n", mWinId, hwnd));
-#endif
-
-    /* then, activate the topmost in the group */
-    AllowSetForegroundWindow(m_pid);
-    SetForegroundWindow(hwnd);
-
-    return true;
-
-#elif defined (VBOX_WS_X11)
-
-    return false;
-
-#elif defined (VBOX_WS_MAC)
-
-    ProcessSerialNumber psn;
-    OSStatus rc = ::GetProcessForPID(m_pid, &psn);
-    if (!rc)
-    {
-        rc = ::SetFrontProcess(&psn);
-
-        if (!rc)
-        {
-            ShowHideProcess(&psn, true);
-            return true;
-        }
-    }
-    return false;
-
-#else
-
-    return false;
-
-#endif
-
-#endif
-}
-
-bool VBoxGlobal::launchMachine(CMachine &machine, LaunchMode enmLaunchMode /* = LaunchMode_Default */)
-{
-    /* Switch to machine window(s) if possible: */
-    if (   machine.GetSessionState() == KSessionState_Locked /* precondition for CanShowConsoleWindow() */
-        && machine.CanShowConsoleWindow())
-    {
-        /* For the Selector UI: */
-        if (!isVMConsoleProcess())
-        {
-            /* Just switch to existing VM window: */
-            return VBoxGlobal::switchToMachine(machine);
-        }
-        /* For the Runtime UI: */
-        else
-        {
-            /* Only separate UI process can reach that place,
-             * switch to existing VM window and exit. */
-            VBoxGlobal::switchToMachine(machine);
-            return false;
-        }
-    }
-
-    if (enmLaunchMode != LaunchMode_Separate)
-    {
-        /* Make sure machine-state is one of required: */
-        KMachineState state = machine.GetState(); NOREF(state);
-        AssertMsg(   state == KMachineState_PoweredOff
-                  || state == KMachineState_Saved
-                  || state == KMachineState_Teleported
-                  || state == KMachineState_Aborted
-                  , ("Machine must be PoweredOff/Saved/Teleported/Aborted (%d)", state));
-    }
-
-    /* Create empty session instance: */
-    CSession session;
-    session.createInstance(CLSID_Session);
-    if (session.isNull())
-    {
-        msgCenter().cannotOpenSession(session);
-        return false;
-    }
-
-    /* Configure environment: */
-    QString strEnv;
-#ifdef Q_OS_WIN
-    /* Allow started VM process to be foreground window: */
-    AllowSetForegroundWindow(ASFW_ANY);
-#endif /* Q_OS_WIN */
-#ifdef VBOX_WS_X11
-    /* Make sure VM process will start on the same display as the VM selector: */
-    const char *pDisplay = RTEnvGet("DISPLAY");
-    if (pDisplay)
-        strEnv.append(QString("DISPLAY=%1\n").arg(pDisplay));
-    const char *pXauth = RTEnvGet("XAUTHORITY");
-    if (pXauth)
-        strEnv.append(QString("XAUTHORITY=%1\n").arg(pXauth));
-#endif /* VBOX_WS_X11 */
-    QString strType;
-    switch (enmLaunchMode)
-    {
-        case LaunchMode_Default:  strType = ""; break;
-        case LaunchMode_Separate: strType = vboxGlobal().isSeparateProcess() ? "headless" : "separate"; break;
-        case LaunchMode_Headless: strType = "headless"; break;
-        default: AssertFailedReturn(false);
-    }
-
-    /* Prepare "VM spawning" progress: */
-    CProgress progress = machine.LaunchVMProcess(session, strType, strEnv);
-    if (!machine.isOk())
-    {
-        /* If the VM is started separately and the VM process is already running, then it is OK. */
-        if (enmLaunchMode == LaunchMode_Separate)
-        {
-            KMachineState state = machine.GetState();
-            if (   state >= KMachineState_FirstOnline
-                && state <= KMachineState_LastOnline)
+void VBoxGlobal::comWrappersReinit()
+{
+    /* Re-fetch corresponding objects/values: */
+    m_host = virtualBox().GetHost();
+    m_strHomeFolder = virtualBox().GetHomeFolder();
+
+    /* Re-initialize guest OS Type list: */
+    m_guestOSFamilyIDs.clear();
+    m_guestOSTypes.clear();
+    const CGuestOSTypeVector guestOSTypes = m_vbox.GetGuestOSTypes();
+    const int cGuestOSTypeCount = guestOSTypes.size();
+    AssertMsg(cGuestOSTypeCount > 0, ("Number of OS types must not be zero"));
+    if (cGuestOSTypeCount > 0)
+    {
+        /* Here we ASSUME the 'Other' types are always the first,
+         * so we remember them and will append them to the list when finished.
+         * We do a two pass, first adding the specific types, then the two 'Other' types. */
+        for (int j = 0; j < 2; ++j)
+        {
+            int cMax = j == 0 ? cGuestOSTypeCount : RT_MIN(2, cGuestOSTypeCount);
+            for (int i = j == 0 ? 2 : 0; i < cMax; ++i)
             {
-                /* Already running. */
-                return true;
+                const CGuestOSType os = guestOSTypes.at(i);
+                const QString strFamilyID = os.GetFamilyId();
+                if (!m_guestOSFamilyIDs.contains(strFamilyID))
+                {
+                    m_guestOSFamilyIDs << strFamilyID;
+                    m_guestOSTypes << QList<CGuestOSType>();
+                }
+                m_guestOSTypes[m_guestOSFamilyIDs.indexOf(strFamilyID)].append(os);
             }
         }
-
-        msgCenter().cannotOpenSession(machine);
-        return false;
-    }
-
-    /* Postpone showing "VM spawning" progress.
-     * Hope 1 minute will be enough to spawn any running VM silently,
-     * otherwise we better show the progress...
-     * If starting separately, then show the progress now. */
-    int iSpawningDuration = enmLaunchMode == LaunchMode_Separate ? 0 : 60000;
-    msgCenter().showModalProgressDialog(progress, machine.GetName(),
-                                        ":/progress_start_90px.png", 0, iSpawningDuration);
-    if (!progress.isOk() || progress.GetResultCode() != 0)
-        msgCenter().cannotOpenSession(progress, machine.GetName());
-
-    /* Unlock machine, close session: */
-    session.UnlockMachine();
-
-    /* True finally: */
-    return true;
-}
-
+    }
+
+    /* Mark wrappers valid: */
+    m_fWrappersValid = true;
+}
Index: trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.h
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.h	(revision 72411)
+++ trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.h	(revision 72413)
@@ -63,4 +63,27 @@
     Q_OBJECT
 
+signals:
+
+    /** Asks listener to commit data. */
+    void sigAskToCommitData();
+
+    /** Asks listener to open URLs. */
+    void sigAskToOpenURLs();
+
+    /** Asks listener to recreate UI. */
+    void sigAskToRestartUI();
+
+    /** Notifies listeners about the VBoxSVC availability change. */
+    void sigVBoxSVCAvailabilityChange();
+
+    /* Notifiers: Medium-processing stuff: */
+    void sigMediumCreated(const QString &strMediumID);
+    void sigMediumDeleted(const QString &strMediumID);
+
+    /* Notifiers: Medium-enumeration stuff: */
+    void sigMediumEnumerationStarted();
+    void sigMediumEnumerated(const QString &strMediumID);
+    void sigMediumEnumerationFinished();
+
 public:
 
@@ -100,5 +123,4 @@
     static void destroy();
 
-    bool isValid() { return mValid; }
     bool isCleaningUp() { return s_fCleanupInProgress; }
 
@@ -108,12 +130,11 @@
     static uint qtCTVersion();
 
+    bool isValid() { return mValid; }
+
     QString vboxVersionString() const;
     QString vboxVersionStringNormalized() const;
+    bool isBeta() const;
 
     QString versionString() const { return mVerString; }
-    bool isBeta() const;
-
-    /** Returns whether GUI is separate (from VM) process. */
-    bool isSeparateProcess() const { return m_fSeparateProcess; }
 
 #ifdef VBOX_WS_MAC
@@ -123,4 +144,200 @@
     MacOSXRelease osRelease() const { return m_osRelease; }
 #endif /* VBOX_WS_MAC */
+
+#ifdef VBOX_WS_X11
+    /** X11: Returns whether the Window Manager we are running at is composition one. */
+    bool isCompositingManagerRunning() const { return m_fCompositingManagerRunning; }
+    /** X11: Returns the type of the Window Manager we are running under. */
+    X11WMType typeOfWindowManager() const { return m_enmWindowManagerType; }
+#endif /* VBOX_WS_X11 */
+
+    /* branding */
+    bool brandingIsActive (bool aForce = false);
+    QString brandingGetKey (QString aKey);
+
+    static bool hasAllowedExtension(const QString &strExt, const QStringList &extList)
+    {
+        for (int i = 0; i < extList.size(); ++i)
+            if (strExt.endsWith(extList.at(i), Qt::CaseInsensitive))
+                return true;
+        return false;
+    }
+
+    bool processArgs();
+
+    QList<QUrl> &argUrlList() { return m_ArgUrlList; }
+
+    QString managedVMUuid() const { return vmUuid; }
+    bool isVMConsoleProcess() const { return !vmUuid.isNull(); }
+    /** Returns whether GUI is separate (from VM) process. */
+    bool isSeparateProcess() const { return m_fSeparateProcess; }
+    bool showStartVMErrors() const { return mShowStartVMErrors; }
+
+    bool agressiveCaching() const { return mAgressiveCaching; }
+
+    /** Returns whether we should restore current snapshot before VM started. */
+    bool shouldRestoreCurrentSnapshot() const { return mRestoreCurrentSnapshot; }
+    /** Defines whether we should fRestore current snapshot before VM started. */
+    void setShouldRestoreCurrentSnapshot(bool fRestore) { mRestoreCurrentSnapshot = fRestore; }
+
+    bool hasFloppyImageToMount() const    { return !m_strFloppyImage.isEmpty(); }
+    bool hasDvdImageToMount() const       { return !m_strDvdImage.isEmpty(); }
+    QString const &getFloppyImage() const { return m_strFloppyImage; }
+    QString const &getDvdImage() const    { return m_strDvdImage; }
+
+    bool isPatmDisabled() const { return mDisablePatm; }
+    bool isCsamDisabled() const { return mDisableCsam; }
+    bool isSupervisorCodeExecedRecompiled() const { return mRecompileSupervisor; }
+    bool isUserCodeExecedRecompiled()       const { return mRecompileUser; }
+    bool areWeToExecuteAllInIem()           const { return mExecuteAllInIem; }
+    bool isDefaultWarpPct() const { return mWarpPct == 100; }
+    uint32_t getWarpPct()       const { return mWarpPct; }
+
+#ifdef VBOX_WITH_DEBUGGER_GUI
+    bool isDebuggerEnabled() const;
+    bool isDebuggerAutoShowEnabled() const;
+    bool isDebuggerAutoShowCommandLineEnabled() const;
+    bool isDebuggerAutoShowStatisticsEnabled() const;
+
+    RTLDRMOD getDebuggerModule() const { return m_hVBoxDbg; }
+#endif /* VBOX_WITH_DEBUGGER_GUI */
+
+    bool shouldStartPaused() const
+    {
+#ifdef VBOX_WITH_DEBUGGER_GUI
+        return m_enmStartRunning == StartRunning_Default ? isDebuggerAutoShowEnabled() : m_enmStartRunning == StartRunning_No;
+#else
+        return false;
+#endif
+    }
+
+#ifdef VBOX_GUI_WITH_PIDFILE
+    void createPidfile();
+    void deletePidfile();
+#endif
+
+    QString languageName() const;
+    QString languageCountry() const;
+    QString languageNameEnglish() const;
+    QString languageCountryEnglish() const;
+    QString languageTranslators() const;
+
+    /** Returns VBox language sub-directory. */
+    static QString vboxLanguageSubDirectory();
+    /** Returns VBox language file-base. */
+    static QString vboxLanguageFileBase();
+    /** Returns VBox language file-extension. */
+    static QString vboxLanguageFileExtension();
+    /** Returns VBox language ID reg-exp. */
+    static QString vboxLanguageIdRegExp();
+    /** Returns built in language name. */
+    static QString vboxBuiltInLanguageName();
+
+    static QString languageId();
+    static QString systemLanguageId();
+
+    static void loadLanguage (const QString &aLangId = QString::null);
+
+    static inline QString yearsToString (uint32_t cVal)
+    {
+        return tr("%n year(s)", "", cVal);
+    }
+
+    static inline QString monthsToString (uint32_t cVal)
+    {
+        return tr("%n month(s)", "", cVal);
+    }
+
+    static inline QString daysToString (uint32_t cVal)
+    {
+        return tr("%n day(s)", "", cVal);
+    }
+
+    static inline QString hoursToString (uint32_t cVal)
+    {
+        return tr("%n hour(s)", "", cVal);
+    }
+
+    static inline QString minutesToString (uint32_t cVal)
+    {
+        return tr("%n minute(s)", "", cVal);
+    }
+
+    static inline QString secondsToString (uint32_t cVal)
+    {
+        return tr("%n second(s)", "", cVal);
+    }
+
+    static QChar decimalSep();
+    static QString sizeRegexp();
+
+    static quint64 parseSize (const QString &);
+    static QString formatSize (quint64 aSize, uint aDecimal = 2, FormatSize aMode = FormatSize_Round);
+
+    /* Returns full medium-format name for the given base medium-format name: */
+    static QString fullMediumFormatName(const QString &strBaseMediumFormatName);
+
+    QStringList COMPortNames() const;
+    QString toCOMPortName (ulong aIRQ, ulong aIOBase) const;
+    bool toCOMPortNumbers (const QString &aName, ulong &aIRQ, ulong &aIOBase) const;
+
+    QStringList LPTPortNames() const;
+    QString toLPTPortName (ulong aIRQ, ulong aIOBase) const;
+    bool toLPTPortNumbers (const QString &aName, ulong &aIRQ, ulong &aIOBase) const;
+
+    static QString highlight (const QString &aStr, bool aToolTip = false);
+    static QString emphasize (const QString &aStr);
+    static QString removeAccelMark (const QString &aText);
+    static QString insertKeyToActionText (const QString &aText, const QString &aKey);
+
+    static QString replaceHtmlEntities(QString strText);
+
+    QString helpFile() const;
+    static QString documentsPath();
+
+    static QRect normalizeGeometry (const QRect &aRectangle, const QRegion &aBoundRegion,
+                                    bool aCanResize = true);
+    static QRect getNormalized (const QRect &aRectangle, const QRegion &aBoundRegion,
+                                bool aCanResize = true);
+    static QRegion flip (const QRegion &aRegion);
+
+    static void centerWidget (QWidget *aWidget, QWidget *aRelative,
+                              bool aCanResize = true);
+
+    /** Assigns top-level @a pWidget geometry passed as QRect coordinates.
+      * @note  Take into account that this request may fail on X11. */
+    static void setTopLevelGeometry(QWidget *pWidget, int x, int y, int w, int h);
+    /** Assigns top-level @a pWidget geometry passed as @a rect.
+      * @note  Take into account that this request may fail on X11. */
+    static void setTopLevelGeometry(QWidget *pWidget, const QRect &rect);
+
+    static bool activateWindow (WId aWId, bool aSwitchDesktop = true);
+
+#ifdef VBOX_WS_X11
+    /** X11: Test whether the current window manager supports full screen mode. */
+    static bool supportsFullScreenMonitorsProtocolX11();
+    /** X11: Performs mapping of the passed @a pWidget to host-screen with passed @a uScreenId. */
+    static bool setFullScreenMonitorX11(QWidget *pWidget, ulong uScreenId);
+
+    /** X11: Returns a list of current _NET_WM_STATE flags for passed @a pWidget. */
+    static QVector<Atom> flagsNetWmState(QWidget *pWidget);
+    /** X11: Check whether _NET_WM_STATE_FULLSCREEN flag is set for passed @a pWidget. */
+    static bool isFullScreenFlagSet(QWidget *pWidget);
+    /** X11: Sets _NET_WM_STATE_FULLSCREEN flag for passed @a pWidget. */
+    static void setFullScreenFlag(QWidget *pWidget);
+    /** X11: Sets _NET_WM_STATE_SKIP_TASKBAR flag for passed @a pWidget. */
+    static void setSkipTaskBarFlag(QWidget *pWidget);
+    /** X11: Sets _NET_WM_STATE_SKIP_PAGER flag for passed @a pWidget. */
+    static void setSkipPagerFlag(QWidget *pWidget);
+
+    /** Assigns WM_CLASS property for passed @a pWidget. */
+    static void setWMClass(QWidget *pWidget, const QString &strNameString, const QString &strClassString);
+#endif /* VBOX_WS_X11 */
+
+    /* Shame on Qt it hasn't stuff for tuning
+     * widget size suitable for reflecting content of desired size.
+     * For example QLineEdit, QSpinBox and similar widgets should have a methods
+     * to strict the minimum width to reflect at least [n] symbols. */
+    static void setMinimumWidthAccordingSymbolCount(QSpinBox *pSpinBox, int cCount);
 
     /** Try to acquire COM cleanup protection token for reading. */
@@ -141,98 +358,6 @@
     bool isVBoxSVCAvailable() const { return m_fVBoxSVCAvailable; }
 
-    /** Returns the thread-pool instance. */
-    UIThreadPool* threadPool() const { return m_pThreadPool; }
-
-    bool is3DAvailableWorker() const;
-    bool is3DAvailable() const { if (m3DAvailable < 0) return is3DAvailableWorker(); return m3DAvailable != 0; }
-
-#ifdef VBOX_GUI_WITH_PIDFILE
-    void createPidfile();
-    void deletePidfile();
-#endif
-
-    /* branding */
-    bool brandingIsActive (bool aForce = false);
-    QString brandingGetKey (QString aKey);
-
-    bool processArgs();
-
-    bool switchToMachine(CMachine &machine);
-
-    bool launchMachine(CMachine &machine, LaunchMode enmLaunchMode = LaunchMode_Default);
-
-    bool isVMConsoleProcess() const { return !vmUuid.isNull(); }
-    bool showStartVMErrors() const { return mShowStartVMErrors; }
-    QString managedVMUuid() const { return vmUuid; }
-    QList<QUrl> &argUrlList() { return m_ArgUrlList; }
-
-    /** Returns whether the Extension Pack installation was requested at startup. */
-    bool isEPInstallationRequested() const { return m_fEPInstallationRequested; }
-    /** Defines whether the Extension Pack installation was @a fRequested at startup. */
-    void setEPInstallationRequested(bool fRequested) { m_fEPInstallationRequested = fRequested; }
-
-#ifdef VBOX_WS_X11
-    /** X11: Returns whether the Window Manager we are running at is composition one. */
-    bool isCompositingManagerRunning() const { return m_fCompositingManagerRunning; }
-    /** X11: Returns the type of the Window Manager we are running under. */
-    X11WMType typeOfWindowManager() const { return m_enmWindowManagerType; }
-#endif /* VBOX_WS_X11 */
-
-    /** Returns whether we should restore current snapshot before VM started. */
-    bool shouldRestoreCurrentSnapshot() const { return mRestoreCurrentSnapshot; }
-    /** Defines whether we should fRestore current snapshot before VM started. */
-    void setShouldRestoreCurrentSnapshot(bool fRestore) { mRestoreCurrentSnapshot = fRestore; }
-
-    bool hasFloppyImageToMount() const    { return !m_strFloppyImage.isEmpty(); }
-    bool hasDvdImageToMount() const       { return !m_strDvdImage.isEmpty(); }
-    QString const &getFloppyImage() const { return m_strFloppyImage; }
-    QString const &getDvdImage() const    { return m_strDvdImage; }
-
-    bool isPatmDisabled() const { return mDisablePatm; }
-    bool isCsamDisabled() const { return mDisableCsam; }
-    bool isSupervisorCodeExecedRecompiled() const { return mRecompileSupervisor; }
-    bool isUserCodeExecedRecompiled()       const { return mRecompileUser; }
-    bool areWeToExecuteAllInIem()           const { return mExecuteAllInIem; }
-    bool isDefaultWarpPct() const { return mWarpPct == 100; }
-    uint32_t getWarpPct()       const { return mWarpPct; }
-
-#ifdef VBOX_WITH_DEBUGGER_GUI
-    bool isDebuggerEnabled() const;
-    bool isDebuggerAutoShowEnabled() const;
-    bool isDebuggerAutoShowCommandLineEnabled() const;
-    bool isDebuggerAutoShowStatisticsEnabled() const;
-
-    RTLDRMOD getDebuggerModule() const { return m_hVBoxDbg; }
-#endif /* VBOX_WITH_DEBUGGER_GUI */
-
-    bool shouldStartPaused() const
-    {
-#ifdef VBOX_WITH_DEBUGGER_GUI
-        return m_enmStartRunning == StartRunning_Default ? isDebuggerAutoShowEnabled() : m_enmStartRunning == StartRunning_No;
-#else
-        return false;
-#endif
-    }
-
-    /* VBox enum to/from string/icon/color convertors */
-
     QList <CGuestOSType> vmGuestOSFamilyList() const;
     QList <CGuestOSType> vmGuestOSTypeList (const QString &aFamilyId) const;
-
-    /** Returns icon defined for a passed @a comMachine. */
-    QIcon vmUserIcon(const CMachine &comMachine) const;
-    /** Returns pixmap of a passed @a size defined for a passed @a comMachine. */
-    QPixmap vmUserPixmap(const CMachine &comMachine, const QSize &size) const;
-    /** Returns pixmap defined for a passed @a comMachine.
-      * In case if non-null @a pLogicalSize pointer provided, it will be updated properly. */
-    QPixmap vmUserPixmapDefault(const CMachine &comMachine, QSize *pLogicalSize = 0) const;
-
-    /** Returns pixmap corresponding to passed @a strOSTypeID. */
-    QIcon vmGuestOSTypeIcon(const QString &strOSTypeID) const;
-    /** Returns pixmap corresponding to passed @a strOSTypeID and @a size. */
-    QPixmap vmGuestOSTypePixmap(const QString &strOSTypeID, const QSize &size) const;
-    /** Returns pixmap corresponding to passed @a strOSTypeID.
-      * In case if non-null @a pLogicalSize pointer provided, it will be updated properly. */
-    QPixmap vmGuestOSTypePixmapDefault(const QString &strOSTypeID, QSize *pLogicalSize = 0) const;
 
     CGuestOSType vmGuestOSType (const QString &aTypeId,
@@ -240,86 +365,33 @@
     QString vmGuestOSTypeDescription (const QString &aTypeId) const;
 
-    static inline QString yearsToString (uint32_t cVal)
-    {
-        return tr("%n year(s)", "", cVal);
-    }
-
-    static inline QString monthsToString (uint32_t cVal)
-    {
-        return tr("%n month(s)", "", cVal);
-    }
-
-    static inline QString daysToString (uint32_t cVal)
-    {
-        return tr("%n day(s)", "", cVal);
-    }
-
-    static inline QString hoursToString (uint32_t cVal)
-    {
-        return tr("%n hour(s)", "", cVal);
-    }
-
-    static inline QString minutesToString (uint32_t cVal)
-    {
-        return tr("%n minute(s)", "", cVal);
-    }
-
-    static inline QString secondsToString (uint32_t cVal)
-    {
-        return tr("%n second(s)", "", cVal);
-    }
-
-    QStringList COMPortNames() const;
-    QString toCOMPortName (ulong aIRQ, ulong aIOBase) const;
-    bool toCOMPortNumbers (const QString &aName, ulong &aIRQ, ulong &aIOBase) const;
-
-    QStringList LPTPortNames() const;
-    QString toLPTPortName (ulong aIRQ, ulong aIOBase) const;
-    bool toLPTPortNumbers (const QString &aName, ulong &aIRQ, ulong &aIOBase) const;
-
-    static bool hasAllowedExtension(const QString &strExt, const QStringList &extList)
-    {
-        for (int i = 0; i < extList.size(); ++i)
-            if (strExt.endsWith(extList.at(i), Qt::CaseInsensitive))
-                return true;
-        return false;
-    }
-
-    QIcon icon(QFileIconProvider::IconType type) { return m_globalIconProvider.icon(type); }
-    QIcon icon(const QFileInfo &info) { return m_globalIconProvider.icon(info); }
-
-    QPixmap warningIcon() const { return mWarningIcon; }
-    QPixmap errorIcon() const { return mErrorIcon; }
-
-    /* details generators */
-
-    QString details(const CMedium &medium, bool fPredictDiff, bool fUseHtml = true);
-
-    QString details (const CUSBDevice &aDevice) const;
-    QString toolTip (const CUSBDevice &aDevice) const;
-    QString toolTip (const CUSBDeviceFilter &aFilter) const;
-    QString toolTip(const CHostVideoInputDevice &webcam) const;
-
-    /* VirtualBox helpers */
+    static bool isDOSType (const QString &aOSTypeId);
+
+    bool switchToMachine(CMachine &machine);
+    bool launchMachine(CMachine &machine, LaunchMode enmLaunchMode = LaunchMode_Default);
 
     CSession openSession(const QString &aId, KLockType aLockType = KLockType_Write);
-
     /** Shortcut to openSession (aId, true). */
     CSession openExistingSession(const QString &aId) { return openSession(aId, KLockType_Shared); }
 
-    /* API: Medium-processing stuff: */
-    void createMedium(const UIMedium &medium);
-    void deleteMedium(const QString &strMediumID);
-    QString createVisoMediumWithFileOpenDialog(QWidget *pParent, const QString &strMachineFolder);
-    QString openMediumWithFileOpenDialog(UIMediumType mediumType, QWidget *pParent = 0,
-                                         const QString &strDefaultFolder = QString(), bool fUseLastFolder = true);
-    QString openMedium(UIMediumType mediumType, QString strMediumLocation, QWidget *pParent = 0);
+    static QList <QPair <QString, QString> > MediumBackends(KDeviceType enmDeviceType);
+    static QList <QPair <QString, QString> > HDDBackends();
+    static QList <QPair <QString, QString> > DVDBackends();
+    static QList <QPair <QString, QString> > FloppyBackends();
 
     /* API: Medium-enumeration stuff: */
     void startMediumEnumeration();
-    bool agressiveCaching() const { return mAgressiveCaching; }
     bool isMediumEnumerationInProgress() const;
     UIMedium medium(const QString &strMediumID) const;
     QList<QString> mediumIDs() const;
+    void createMedium(const UIMedium &medium);
+    void deleteMedium(const QString &strMediumID);
+
+    /* API: Medium-processing stuff: */
+    QString openMedium(UIMediumType mediumType, QString strMediumLocation, QWidget *pParent = 0);
+
+    QString openMediumWithFileOpenDialog(UIMediumType mediumType, QWidget *pParent = 0,
+                                         const QString &strDefaultFolder = QString(), bool fUseLastFolder = true);
+
+    QString createVisoMediumWithFileOpenDialog(QWidget *pParent, const QString &strMachineFolder);
 
     /** Prepares storage menu according passed parameters.
@@ -336,104 +408,5 @@
     void updateMachineStorage(const CMachine &constMachine, const UIMediumTarget &target);
 
-    /* various helpers */
-
-    QString languageName() const;
-    QString languageCountry() const;
-    QString languageNameEnglish() const;
-    QString languageCountryEnglish() const;
-    QString languageTranslators() const;
-
-    void retranslateUi();
-
-    /* public static stuff */
-
-    static bool isDOSType (const QString &aOSTypeId);
-
-    /** Returns VBox language sub-directory. */
-    static QString vboxLanguageSubDirectory();
-    /** Returns VBox language file-base. */
-    static QString vboxLanguageFileBase();
-    /** Returns VBox language file-extension. */
-    static QString vboxLanguageFileExtension();
-    /** Returns VBox language ID reg-exp. */
-    static QString vboxLanguageIdRegExp();
-    /** Returns built in language name. */
-    static QString vboxBuiltInLanguageName();
-    static QString languageId();
-    static void loadLanguage (const QString &aLangId = QString::null);
-    QString helpFile() const;
-
-    static void setTextLabel (QToolButton *aToolButton, const QString &aTextLabel);
-
-    static QRect normalizeGeometry (const QRect &aRectangle, const QRegion &aBoundRegion,
-                                    bool aCanResize = true);
-    static QRect getNormalized (const QRect &aRectangle, const QRegion &aBoundRegion,
-                                bool aCanResize = true);
-    static QRegion flip (const QRegion &aRegion);
-
-    static void centerWidget (QWidget *aWidget, QWidget *aRelative,
-                              bool aCanResize = true);
-
-    static QChar decimalSep();
-    static QString sizeRegexp();
-
-    static quint64 parseSize (const QString &);
-    static QString formatSize (quint64 aSize, uint aDecimal = 2, FormatSize aMode = FormatSize_Round);
-
-    static quint64 requiredVideoMemory(const QString &strGuestOSTypeId, int cMonitors = 1);
-
-    static QString locationForHTML (const QString &aFileName);
-
-    static QString highlight (const QString &aStr, bool aToolTip = false);
-
-    static QString replaceHtmlEntities(QString strText);
-    static QString emphasize (const QString &aStr);
-
-    static QString systemLanguageId();
-
-    static bool activateWindow (WId aWId, bool aSwitchDesktop = true);
-
-#ifdef VBOX_WS_X11
-    /** X11: Test whether the current window manager supports full screen mode. */
-    static bool supportsFullScreenMonitorsProtocolX11();
-    /** X11: Performs mapping of the passed @a pWidget to host-screen with passed @a uScreenId. */
-    static bool setFullScreenMonitorX11(QWidget *pWidget, ulong uScreenId);
-
-    /** X11: Returns a list of current _NET_WM_STATE flags for passed @a pWidget. */
-    static QVector<Atom> flagsNetWmState(QWidget *pWidget);
-    /** X11: Check whether _NET_WM_STATE_FULLSCREEN flag is set for passed @a pWidget. */
-    static bool isFullScreenFlagSet(QWidget *pWidget);
-    /** X11: Sets _NET_WM_STATE_FULLSCREEN flag for passed @a pWidget. */
-    static void setFullScreenFlag(QWidget *pWidget);
-    /** X11: Sets _NET_WM_STATE_SKIP_TASKBAR flag for passed @a pWidget. */
-    static void setSkipTaskBarFlag(QWidget *pWidget);
-    /** X11: Sets _NET_WM_STATE_SKIP_PAGER flag for passed @a pWidget. */
-    static void setSkipPagerFlag(QWidget *pWidget);
-#endif /* VBOX_WS_X11 */
-
-    static QString removeAccelMark (const QString &aText);
-
-    static QString insertKeyToActionText (const QString &aText, const QString &aKey);
-
-    static QPixmap joinPixmaps (const QPixmap &aPM1, const QPixmap &aPM2);
-
-    static QWidget *findWidget (QWidget *aParent, const char *aName,
-                                const char *aClassName = NULL,
-                                bool aRecursive = false);
-
-    static QList <QPair <QString, QString> > MediumBackends(KDeviceType enmDeviceType);
-    static QList <QPair <QString, QString> > HDDBackends();
-    static QList <QPair <QString, QString> > DVDBackends();
-    static QList <QPair <QString, QString> > FloppyBackends();
-
-    static QString documentsPath();
-
-#ifdef VBOX_WITH_CRHGSMI
-    static bool isWddmCompatibleOsType(const QString &strGuestOSTypeId);
-#endif /* VBOX_WITH_CRHGSMI */
-
-    /* Returns full medium-format name for the given base medium-format name: */
-    static QString fullMediumFormatName(const QString &strBaseMediumFormatName);
-
+    QString details(const CMedium &medium, bool fPredictDiff, bool fUseHtml = true);
 
 #ifdef RT_OS_LINUX
@@ -441,21 +414,8 @@
 #endif /* RT_OS_LINUX */
 
-    /* Shame on Qt it hasn't stuff for tuning
-     * widget size suitable for reflecting content of desired size.
-     * For example QLineEdit, QSpinBox and similar widgets should have a methods
-     * to strict the minimum width to reflect at least [n] symbols. */
-    static void setMinimumWidthAccordingSymbolCount(QSpinBox *pSpinBox, int cCount);
-
-    /** Assigns top-level @a pWidget geometry passed as QRect coordinates.
-      * @note  Take into account that this request may fail on X11. */
-    static void setTopLevelGeometry(QWidget *pWidget, int x, int y, int w, int h);
-    /** Assigns top-level @a pWidget geometry passed as @a rect.
-      * @note  Take into account that this request may fail on X11. */
-    static void setTopLevelGeometry(QWidget *pWidget, const QRect &rect);
-
-#ifdef VBOX_WS_X11
-    /** Assigns WM_CLASS property for passed @a pWidget. */
-    static void setWMClass(QWidget *pWidget, const QString &strNameString, const QString &strClassString);
-#endif
+    QString details (const CUSBDevice &aDevice) const;
+    QString toolTip (const CUSBDevice &aDevice) const;
+    QString toolTip (const CUSBDeviceFilter &aFilter) const;
+    QString toolTip(const CHostVideoInputDevice &webcam) const;
 
     /** Initiates the extension pack installation process.
@@ -469,24 +429,52 @@
                                       QString *pstrExtPackName);
 
-signals:
-
-    /** Asks listener to recreate UI. */
-    void sigAskToRestartUI();
-    /** Asks listener to open URLs. */
-    void sigAskToOpenURLs();
-    /** Asks listener to commit data. */
-    void sigAskToCommitData();
-
-    /** Notifies listeners about the VBoxSVC availability change. */
-    void sigVBoxSVCAvailabilityChange();
-
-    /* Notifiers: Medium-processing stuff: */
-    void sigMediumCreated(const QString &strMediumID);
-    void sigMediumDeleted(const QString &strMediumID);
-
-    /* Notifiers: Medium-enumeration stuff: */
-    void sigMediumEnumerationStarted();
-    void sigMediumEnumerated(const QString &strMediumID);
-    void sigMediumEnumerationFinished();
+    /** Returns whether the Extension Pack installation was requested at startup. */
+    bool isEPInstallationRequested() const { return m_fEPInstallationRequested; }
+    /** Defines whether the Extension Pack installation was @a fRequested at startup. */
+    void setEPInstallationRequested(bool fRequested) { m_fEPInstallationRequested = fRequested; }
+
+    bool is3DAvailableWorker() const;
+    bool is3DAvailable() const { if (m3DAvailable < 0) return is3DAvailableWorker(); return m3DAvailable != 0; }
+
+#ifdef VBOX_WITH_CRHGSMI
+    static bool isWddmCompatibleOsType(const QString &strGuestOSTypeId);
+#endif /* VBOX_WITH_CRHGSMI */
+
+    static quint64 requiredVideoMemory(const QString &strGuestOSTypeId, int cMonitors = 1);
+
+    /** Returns the thread-pool instance. */
+    UIThreadPool* threadPool() const { return m_pThreadPool; }
+
+    /** Returns icon defined for a passed @a comMachine. */
+    QIcon vmUserIcon(const CMachine &comMachine) const;
+    /** Returns pixmap of a passed @a size defined for a passed @a comMachine. */
+    QPixmap vmUserPixmap(const CMachine &comMachine, const QSize &size) const;
+    /** Returns pixmap defined for a passed @a comMachine.
+      * In case if non-null @a pLogicalSize pointer provided, it will be updated properly. */
+    QPixmap vmUserPixmapDefault(const CMachine &comMachine, QSize *pLogicalSize = 0) const;
+
+    /** Returns pixmap corresponding to passed @a strOSTypeID. */
+    QIcon vmGuestOSTypeIcon(const QString &strOSTypeID) const;
+    /** Returns pixmap corresponding to passed @a strOSTypeID and @a size. */
+    QPixmap vmGuestOSTypePixmap(const QString &strOSTypeID, const QSize &size) const;
+    /** Returns pixmap corresponding to passed @a strOSTypeID.
+      * In case if non-null @a pLogicalSize pointer provided, it will be updated properly. */
+    QPixmap vmGuestOSTypePixmapDefault(const QString &strOSTypeID, QSize *pLogicalSize = 0) const;
+
+    QIcon icon(QFileIconProvider::IconType type) { return m_globalIconProvider.icon(type); }
+    QIcon icon(const QFileInfo &info) { return m_globalIconProvider.icon(info); }
+
+    QPixmap warningIcon() const { return mWarningIcon; }
+    QPixmap errorIcon() const { return mErrorIcon; }
+
+    static QPixmap joinPixmaps (const QPixmap &aPM1, const QPixmap &aPM2);
+
+    static void setTextLabel (QToolButton *aToolButton, const QString &aTextLabel);
+
+    static QString locationForHTML (const QString &aFileName);
+
+    static QWidget *findWidget (QWidget *aParent, const char *aName,
+                                const char *aClassName = NULL,
+                                bool aRecursive = false);
 
 public slots:
@@ -495,4 +483,10 @@
 
     void sltGUILanguageChange(QString strLang);
+
+protected:
+
+    bool eventFilter (QObject *, QEvent *);
+
+    void retranslateUi();
 
 protected slots:
@@ -507,8 +501,4 @@
     /** Handles the VBoxSVC availability change. */
     void sltHandleVBoxSVCAvailabilityChange(bool fAvailable);
-
-protected:
-
-    bool eventFilter (QObject *, QEvent *);
 
 private:
@@ -525,7 +515,4 @@
     virtual ~VBoxGlobal() /* override */;
 
-    /** Re-initializes COM wrappers and containers. */
-    void comWrappersReinit();
-
 #ifdef VBOX_WS_WIN
     /** Wraps WinAPI ShutdownBlockReasonCreate function. */
@@ -539,4 +526,16 @@
 #endif
 
+    /** Re-initializes COM wrappers and containers. */
+    void comWrappersReinit();
+
+    /** Holds the singleton VBoxGlobal instance. */
+    static VBoxGlobal *s_pInstance;
+
+    /** Holds the currently loaded language ID. */
+    static QString     s_strLoadedLanguageId;
+
+    /** Holds whether VBoxGlobal cleanup is in progress. */
+    static bool        s_fCleanupInProgress;
+
 #ifdef VBOX_GUI_WITH_SHARED_LIBRARY
     /** Holds the UI type. */
@@ -550,41 +549,4 @@
     MacOSXRelease m_osRelease;
 #endif /* VBOX_WS_MAC */
-
-    /** COM cleanup protection token. */
-    QReadWriteLock m_comCleanupProtectionToken;
-
-    /** Holds the instance of VirtualBox client wrapper. */
-    CVirtualBoxClient m_client;
-    /** Holds the copy of VirtualBox object wrapper. */
-    CVirtualBox m_vbox;
-    /** Holds the copy of VirtualBox host-object wrapper. */
-    CHost m_host;
-    /** Holds the symbolic VirtualBox home-folder representation. */
-    QString m_strHomeFolder;
-    /** Holds the guest OS family IDs. */
-    QList<QString> m_guestOSFamilyIDs;
-    /** Holds the guest OS types for each family ID. */
-    QList<QList<CGuestOSType> > m_guestOSTypes;
-
-    /** Holds whether acquired COM wrappers are currently valid. */
-    bool m_fWrappersValid;
-    /** Holds whether VBoxSVC is currently available. */
-    bool m_fVBoxSVCAvailable;
-
-    /** Holds whether GUI is separate (from VM) process. */
-    bool m_fSeparateProcess;
-
-    QString vmUuid;
-    QList<QUrl> m_ArgUrlList;
-
-    /** Whether to show error message boxes for VM start errors. */
-    bool mShowStartVMErrors;
-
-    /* Variable: Medium-enumeration stuff: */
-    UIMediumEnumerator *m_pMediumEnumerator;
-    mutable QReadWriteLock m_mediumEnumeratorDtorRwLock;
-
-    /** Holds whether the Extension Pack installation was requested at startup. */
-    bool m_fEPInstallationRequested;
 
 #ifdef VBOX_WS_X11
@@ -595,6 +557,18 @@
 #endif /* VBOX_WS_X11 */
 
+    QString mVerString;
+    QString mBrandingConfig;
+
+    QList<QUrl> m_ArgUrlList;
+
+    QString vmUuid;
+    /** Holds whether GUI is separate (from VM) process. */
+    bool m_fSeparateProcess;
+    /** Whether to show error message boxes for VM start errors. */
+    bool mShowStartVMErrors;
+
     /** The --aggressive-caching / --no-aggressive-caching option. */
     bool mAgressiveCaching;
+
     /** The --restore-current option. */
     bool mRestoreCurrentSnapshot;
@@ -640,18 +614,6 @@
 #endif
 
-#if defined (VBOX_WS_WIN)
-    DWORD dwHTMLHelpCookie;
-#endif
-
-    QString mVerString;
-    QString mBrandingConfig;
-
-    int m3DAvailable;
-
-    QString mUserDefinedPortName;
-
-    QPixmap mWarningIcon, mErrorIcon;
-
-    QFileIconProvider m_globalIconProvider;
+    char mSettingsPw[256];
+    bool mSettingsPwSet;
 
 #ifdef VBOX_GUI_WITH_PIDFILE
@@ -659,11 +621,46 @@
 #endif
 
-    char mSettingsPw[256];
-    bool mSettingsPwSet;
+    QString mUserDefinedPortName;
+
+    /** COM cleanup protection token. */
+    QReadWriteLock m_comCleanupProtectionToken;
+
+    /** Holds the instance of VirtualBox client wrapper. */
+    CVirtualBoxClient m_client;
+    /** Holds the copy of VirtualBox object wrapper. */
+    CVirtualBox m_vbox;
+    /** Holds the copy of VirtualBox host-object wrapper. */
+    CHost m_host;
+    /** Holds the symbolic VirtualBox home-folder representation. */
+    QString m_strHomeFolder;
+
+    /** Holds whether acquired COM wrappers are currently valid. */
+    bool m_fWrappersValid;
+    /** Holds whether VBoxSVC is currently available. */
+    bool m_fVBoxSVCAvailable;
+
+    /** Holds the guest OS family IDs. */
+    QList<QString> m_guestOSFamilyIDs;
+    /** Holds the guest OS types for each family ID. */
+    QList<QList<CGuestOSType> > m_guestOSTypes;
+
+    int m3DAvailable;
+
+    /** Holds the thread-pool instance. */
+    UIThreadPool *m_pThreadPool;
 
     /** General icon-pool. */
     UIIconPoolGeneral *m_pIconPool;
-    /** Holds the thread-pool instance. */
-    UIThreadPool *m_pThreadPool;
+
+    QFileIconProvider m_globalIconProvider;
+
+    QPixmap mWarningIcon, mErrorIcon;
+
+    /* Variable: Medium-enumeration stuff: */
+    mutable QReadWriteLock m_mediumEnumeratorDtorRwLock;
+    UIMediumEnumerator *m_pMediumEnumerator;
+
+    /** Holds whether the Extension Pack installation was requested at startup. */
+    bool m_fEPInstallationRequested;
 
 #if defined(VBOX_WS_WIN) && defined(VBOX_GUI_WITH_SHARED_LIBRARY)
@@ -673,10 +670,7 @@
 #endif
 
-    /** Holds the singleton VBoxGlobal instance. */
-    static VBoxGlobal *s_pInstance;
-    /** Holds whether VBoxGlobal cleanup is in progress. */
-    static bool        s_fCleanupInProgress;
-    /** Holds the currently loaded language ID. */
-    static QString     s_strLoadedLanguageId;
+#if defined (VBOX_WS_WIN)
+    DWORD dwHTMLHelpCookie;
+#endif
 
     /** Allows for shortcut access. */
@@ -688,3 +682,2 @@
 
 #endif /* !___VBoxGlobal_h___ */
-
