Index: /trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk	(revision 30867)
+++ /trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk	(revision 30868)
@@ -148,5 +148,5 @@
 endif
 ifdef VBOX_BLEEDING_EDGE
-VirtualBox_src/VBoxSelectorWnd.cpp_DEFS += \
+VirtualBox_src/selector/VBoxSelectorWnd.cpp_DEFS += \
     VBOX_BLEEDING_EDGE=\"$(VBOX_BLEEDING_EDGE)\"
 VirtualBox_src/runtime/UIMachineWindow.cpp_DEFS += \
@@ -174,4 +174,5 @@
 	./src/X11 \
 	./src/darwin \
+	./src/selector \
 	./src/runtime \
 	./src/runtime/normal \
@@ -246,12 +247,8 @@
 	src/VBoxGlobalSettings.h \
 	src/VBoxMediaManagerDlg.h \
-	src/VBoxSelectorWnd.h \
 	src/VBoxSnapshotDetailsDlg.h \
-	src/VBoxSnapshotsWgt.h \
 	src/VBoxTakeSnapshotDlg.h \
 	src/VBoxUpdateDlg.h \
 	src/VBoxVMInformationDlg.h \
-	src/UIVMListView.h \
-	src/UIVirtualBoxEventHandler.h \
 	src/VBoxVMLogViewer.h \
 	src/globals/VBoxGlobal.h \
@@ -310,7 +307,9 @@
 	src/wizards/exportappliance/UIExportApplianceWzd.h \
 	src/wizards/importappliance/UIImportApplianceWzd.h \
+	src/widgets/UIBar.h \
 	src/widgets/UIDownloader.h \
 	src/widgets/UIDownloaderAdditions.h \
 	src/widgets/UIDownloaderUserManual.h \
+	src/widgets/UIPopupBox.h \
 	src/widgets/UISpacerWidgets.h \
 	src/widgets/UISpecialControls.h \
@@ -327,4 +326,10 @@
 	src/widgets/VBoxProgressDialog.h \
 	src/widgets/VBoxWarningPane.h \
+	src/selector/UIVMDesktop.h \
+	src/selector/UIVMListView.h \
+	src/selector/UIVMPreviewWindow.h \
+	src/selector/UIVirtualBoxEventHandler.h \
+	src/selector/VBoxSelectorWnd.h \
+	src/selector/VBoxSnapshotsWgt.h \
 	src/runtime/UIMachine.h \
 	src/runtime/UISession.h \
@@ -361,13 +366,13 @@
 # Sources containing local definitions of classes that use the Q_OBJECT macro.
 VirtualBox_QT_MOCSRCS = \
-	src/VBoxSelectorWnd.cpp \
 	src/VBoxMediaManagerDlg.cpp \
+	src/globals/UIExtraDataEventHandler.cpp \
+	src/extensions/QISplitter.cpp \
+	src/selector/UIVMDesktop.cpp \
 	src/runtime/UIActionsPool.cpp \
-	src/runtime/UIMachineMenuBar.cpp \
 	src/runtime/UIIndicatorsPool.cpp \
 	src/runtime/UIMachine.cpp \
 	src/runtime/UIMachineLogic.cpp \
-	src/extensions/QISplitter.cpp \
-	src/globals/UIExtraDataEventHandler.cpp
+	src/runtime/UIMachineMenuBar.cpp
 
 ifdef VBOX_WITH_XPCOM
@@ -393,13 +398,8 @@
 	src/VBoxMediaManagerDlg.cpp \
 	src/VBoxMedium.cpp \
-	src/VBoxSelectorWnd.cpp \
 	src/VBoxSnapshotDetailsDlg.cpp \
-	src/VBoxSnapshotsWgt.cpp \
 	src/VBoxTakeSnapshotDlg.cpp \
 	src/VBoxUpdateDlg.cpp \
 	src/VBoxVMInformationDlg.cpp \
-	src/UIVMItem.cpp \
-	src/UIVMListView.cpp \
-	src/UIVirtualBoxEventHandler.cpp \
 	src/VBoxVMLogViewer.cpp \
 	src/globals/COMDefs.cpp \
@@ -459,7 +459,9 @@
 	src/wizards/exportappliance/UIExportApplianceWzd.cpp \
 	src/wizards/importappliance/UIImportApplianceWzd.cpp \
+	src/widgets/UIBar.cpp \
 	src/widgets/UIDownloader.cpp \
 	src/widgets/UIDownloaderAdditions.cpp \
 	src/widgets/UIDownloaderUserManual.cpp \
+	src/widgets/UIPopupBox.cpp \
 	src/widgets/UISpecialControls.cpp \
 	src/widgets/VBoxApplianceEditorWgt.cpp \
@@ -476,4 +478,11 @@
 	src/widgets/VBoxProgressDialog.cpp \
 	src/widgets/VBoxWarningPane.cpp \
+	src/selector/UIVMDesktop.cpp \
+	src/selector/UIVMItem.cpp \
+	src/selector/UIVMListView.cpp \
+	src/selector/UIVMPreviewWindow.cpp \
+	src/selector/UIVirtualBoxEventHandler.cpp \
+	src/selector/VBoxSelectorWnd.cpp \
+	src/selector/VBoxSnapshotsWgt.cpp \
 	src/runtime/UIMachine.cpp \
 	src/runtime/UISession.cpp \
Index: /trunk/src/VBox/Frontends/VirtualBox/VBoxUI.pro
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/VBoxUI.pro	(revision 30867)
+++ /trunk/src/VBox/Frontends/VirtualBox/VBoxUI.pro	(revision 30868)
@@ -26,5 +26,4 @@
     src/VBoxMediaManagerDlg.ui \
     src/VBoxSnapshotDetailsDlg.ui \
-    src/VBoxSnapshotsWgt.ui \
     src/VBoxTakeSnapshotDlg.ui \
     src/VBoxUpdateDlg.ui \
@@ -68,5 +67,6 @@
     src/wizards/importappliance/UIImportApplianceWzdPage2.ui \
     src/wizards/registration/UIRegistrationWzdPage1.ui \
-    src/widgets/VBoxApplianceEditorWgt.ui
+    src/widgets/VBoxApplianceEditorWgt.ui \
+    src/selector/VBoxSnapshotsWgt.ui
 
 TRANSLATIONS = \
Index: unk/src/VBox/Frontends/VirtualBox/src/UIVMItem.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/UIVMItem.cpp	(revision 30867)
+++ 	(revision )
@@ -1,394 +1,0 @@
-/* $Id$ */
-/** @file
- *
- * VBox frontends: Qt GUI ("VirtualBox"):
- * UIVMItem class implementation
- */
-
-/*
- * Copyright (C) 2006-2010 Oracle Corporation
- *
- * This file is part of VirtualBox Open Source Edition (OSE), as
- * available from http://www.virtualbox.org. This file is free software;
- * you can redistribute it and/or modify it under the terms of the GNU
- * General Public License (GPL) as published by the Free Software
- * Foundation, in version 2 as it comes in the "COPYING" file of the
- * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
- * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
- */
-
-#ifdef VBOX_WITH_PRECOMPILED_HEADERS
-# include "precomp.h"
-#else  /* !VBOX_WITH_PRECOMPILED_HEADERS */
-
-/* Local includes */
-#include "UIVMItem.h"
-
-/* Qt includes */
-#include <QFileInfo>
-
-#ifdef Q_WS_MAC
-//# include "VBoxUtils.h"
-# include <ApplicationServices/ApplicationServices.h>
-#endif /* Q_WS_MAC */
-
-#endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
-
-// Helpers
-////////////////////////////////////////////////////////////////////////////////
-
-/// @todo Remove. See @c todo in #switchTo() below.
-#if 0
-
-#if defined (Q_WS_WIN32)
-
-struct EnumWindowsProcData
-{
-    ULONG pid;
-    WId wid;
-};
-
-BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lParam)
-{
-    EnumWindowsProcData *d = (EnumWindowsProcData *) lParam;
-
-    DWORD pid = 0;
-    GetWindowThreadProcessId(hwnd, &pid);
-
-    if (d->pid == pid)
-    {
-        WINDOWINFO info;
-        if (!GetWindowInfo(hwnd, &info))
-            return TRUE;
-
-#if 0
-        LogFlowFunc(("pid=%d, wid=%08X\n", pid, hwnd));
-        LogFlowFunc(("  parent=%08X\n", GetParent(hwnd)));
-        LogFlowFunc(("  owner=%08X\n", GetWindow(hwnd, GW_OWNER)));
-        TCHAR buf [256];
-        LogFlowFunc(("  rcWindow=%d,%d;%d,%d\n",
-                      info.rcWindow.left, info.rcWindow.top,
-                      info.rcWindow.right, info.rcWindow.bottom));
-        LogFlowFunc(("  dwStyle=%08X\n", info.dwStyle));
-        LogFlowFunc(("  dwExStyle=%08X\n", info.dwExStyle));
-        GetClassName(hwnd, buf, 256);
-        LogFlowFunc(("  class=%ls\n", buf));
-        GetWindowText(hwnd, buf, 256);
-        LogFlowFunc(("  text=%ls\n", buf));
-#endif
-
-        /* we are interested in unowned top-level windows only */
-        if (!(info.dwStyle & (WS_CHILD | WS_POPUP)) &&
-            info.rcWindow.left < info.rcWindow.right &&
-            info.rcWindow.top < info.rcWindow.bottom &&
-            GetParent(hwnd) == NULL &&
-            GetWindow(hwnd, GW_OWNER) == NULL)
-        {
-            d->wid = hwnd;
-            /* if visible, stop the search immediately */
-            if (info.dwStyle & WS_VISIBLE)
-                return FALSE;
-            /* otherwise, give other top-level windows a chance
-             * (the last one wins) */
-        }
-    }
-
-    return TRUE;
-}
-
-#endif
-
-/**
- * Searches for a main window of the given process.
- *
- * @param aPid process ID to search for
- *
- * @return window ID on success or <tt>(WId) ~0</tt> otherwise.
- */
-static WId FindWindowIdFromPid(ULONG aPid)
-{
-#if defined (Q_WS_WIN32)
-
-    EnumWindowsProcData d = { aPid, (WId) ~0 };
-    EnumWindows(EnumWindowsProc, (LPARAM) &d);
-    LogFlowFunc(("SELECTED wid=%08X\n", d.wid));
-    return d.wid;
-
-#elif defined (Q_WS_X11)
-
-    NOREF(aPid);
-    return (WId) ~0;
-
-#elif defined (Q_WS_MAC)
-
-    /** @todo Figure out how to get access to another windows of another process...
-     * Or at least check that it's not a VBoxVRDP process. */
-    NOREF (aPid);
-    return (WId) 0;
-
-#else
-
-    return (WId) ~0;
-
-#endif
-}
-
-#endif
-
-UIVMItem::UIVMItem(const CMachine &aMachine)
-    : m_machine(aMachine)
-{
-    recache();
-}
-
-UIVMItem::~UIVMItem()
-{
-}
-
-// public members
-////////////////////////////////////////////////////////////////////////////////
-
-QString UIVMItem::sessionStateName() const
-{
-    return m_fAccessible ? vboxGlobal().toString(m_state) :
-           QApplication::translate("UIVMListView", "Inaccessible");
-}
-
-QString UIVMItem::toolTipText() const
-{
-    QString dateTime = (m_lastStateChange.date() == QDate::currentDate()) ?
-                        m_lastStateChange.time().toString(Qt::LocalDate) :
-                        m_lastStateChange.toString(Qt::LocalDate);
-
-    QString toolTip;
-
-    if (m_fAccessible)
-    {
-        toolTip = QString("<b>%1</b>").arg(m_strName);
-        if (!m_strSnapshotName.isNull())
-            toolTip += QString(" (%1)").arg(m_strSnapshotName);
-        toolTip = QApplication::translate("UIVMListView",
-            "<nobr>%1<br></nobr>"
-            "<nobr>%2 since %3</nobr><br>"
-            "<nobr>Session %4</nobr>",
-            "VM tooltip (name, last state change, session state)")
-            .arg(toolTip)
-            .arg(vboxGlobal().toString(m_state))
-            .arg(dateTime)
-            .arg(vboxGlobal().toString(m_sessionState));
-    }
-    else
-    {
-        toolTip = QApplication::translate("UIVMListView",
-            "<nobr><b>%1</b><br></nobr>"
-            "<nobr>Inaccessible since %2</nobr>",
-            "Inaccessible VM tooltip (name, last state change)")
-            .arg(m_strSettingsFile)
-            .arg(dateTime);
-    }
-
-    return toolTip;
-}
-
-bool UIVMItem::recache()
-{
-    bool needsResort = true;
-
-    m_strId = m_machine.GetId();
-    m_strSettingsFile = m_machine.GetSettingsFilePath();
-
-    m_fAccessible = m_machine.GetAccessible();
-    if (m_fAccessible)
-    {
-        QString name = m_machine.GetName();
-
-        CSnapshot snp = m_machine.GetCurrentSnapshot();
-        m_strSnapshotName = snp.isNull() ? QString::null : snp.GetName();
-        needsResort = name != m_strName;
-        m_strName = name;
-
-        m_state = m_machine.GetState();
-        m_lastStateChange.setTime_t(m_machine.GetLastStateChange() / 1000);
-        m_sessionState = m_machine.GetSessionState();
-        m_strOSTypeId = m_machine.GetOSTypeId();
-        m_cSnaphot = m_machine.GetSnapshotCount();
-
-        if (   m_state == KMachineState_PoweredOff
-            || m_state == KMachineState_Saved
-            || m_state == KMachineState_Teleported
-            || m_state == KMachineState_Aborted
-           )
-        {
-            m_pid = (ULONG) ~0;
-    /// @todo Remove. See @c todo in #switchTo() below.
-#if 0
-            mWinId = (WId) ~0;
-#endif
-        }
-        else
-        {
-            m_pid = m_machine.GetSessionPid();
-    /// @todo Remove. See @c todo in #switchTo() below.
-#if 0
-            mWinId = FindWindowIdFromPid(m_pid);
-#endif
-        }
-    }
-    else
-    {
-        m_accessError = m_machine.GetAccessError();
-
-        /* this should be in sync with
-         * VBoxProblemReporter::confirm_machineDeletion() */
-        QFileInfo fi(m_strSettingsFile);
-        QString name = fi.completeSuffix().toLower() == "xml" ?
-                       fi.completeBaseName() : fi.fileName();
-        needsResort = name != m_strName;
-        m_strName = name;
-        m_state = KMachineState_Null;
-        m_sessionState = KSessionState_Null;
-        m_lastStateChange = QDateTime::currentDateTime();
-        m_strOSTypeId = QString::null;
-        m_cSnaphot = 0;
-
-        m_pid = (ULONG) ~0;
-    /// @todo Remove. See @c todo in #switchTo() below.
-#if 0
-        mWinId = (WId) ~0;
-#endif
-    }
-
-    return needsResort;
-}
-
-/**
- * Returns @a true if we can activate and bring the VM console window to
- * foreground, and @a false otherwise.
- */
-bool UIVMItem::canSwitchTo() const
-{
-    return const_cast <CMachine &>(m_machine).CanShowConsoleWindow();
-
-    /// @todo Remove. See @c todo in #switchTo() below.
-#if 0
-    return mWinId != (WId) ~0;
-#endif
-}
-
-/**
- * Tries to switch to the main window of the VM process.
- *
- * @return true if successfully switched and false otherwise.
- */
-bool UIVMItem::switchTo()
-{
-#ifdef Q_WS_MAC
-    ULONG64 id = m_machine.ShowConsoleWindow();
-#else
-    WId id = (WId) m_machine.ShowConsoleWindow();
-#endif
-    AssertWrapperOk(m_machine);
-    if (!m_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 (Q_WS_WIN32) || defined (Q_WS_X11)
-
-    return vboxGlobal().activateWindow(id, true);
-
-#elif defined (Q_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;
-    OSErr rc = ::SetFrontProcess(&psn);
-    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;
-
-#endif
-
-    return false;
-
-    /// @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 (Q_WS_WIN32)
-
-    HWND hwnd = mWinId;
-
-    /* if there are ownees (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 (Q_WS_X11)
-
-    return false;
-
-#elif defined (Q_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
-}
-
Index: unk/src/VBox/Frontends/VirtualBox/src/UIVMItem.h
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/UIVMItem.h	(revision 30867)
+++ 	(revision )
@@ -1,87 +1,0 @@
-/** @file
- *
- * VBox frontends: Qt GUI ("VirtualBox"):
- * UIVMItem class declarations
- */
-
-/*
- * Copyright (C) 2006-2010 Oracle Corporation
- *
- * This file is part of VirtualBox Open Source Edition (OSE), as
- * available from http://www.virtualbox.org. This file is free software;
- * you can redistribute it and/or modify it under the terms of the GNU
- * General Public License (GPL) as published by the Free Software
- * Foundation, in version 2 as it comes in the "COPYING" file of the
- * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
- * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
- */
-
-#ifndef __UIVMItem_h__
-#define __UIVMItem_h__
-
-/* Local includes */
-#include "VBoxGlobal.h"
-
-/* Global includes */
-#include <QDateTime>
-
-class UIVMItem
-{
-public:
-
-    UIVMItem(const CMachine &aMachine);
-    virtual ~UIVMItem();
-
-    CMachine machine() const { return m_machine; }
-
-    QString name() const { return m_strName; }
-    QIcon osIcon() const { return m_fAccessible ? vboxGlobal().vmGuestOSTypeIcon(m_strOSTypeId) : QPixmap(":/os_other.png"); }
-    QString osTypeId() const { return m_strOSTypeId; }
-    QString id() const { return m_strId; }
-
-    QString sessionStateName() const;
-    QIcon sessionStateIcon() const { return m_fAccessible ? vboxGlobal().toIcon(m_state) : QPixmap(":/state_aborted_16px.png"); }
-
-    QString snapshotName() const { return m_strSnapshotName; }
-    ULONG snapshotCount() const { return m_cSnaphot; }
-
-    QString toolTipText() const;
-
-    bool accessible() const { return m_fAccessible; }
-    const CVirtualBoxErrorInfo &accessError() const { return m_accessError; }
-    KMachineState state() const { return m_state; }
-    KSessionState sessionState() const { return m_sessionState; }
-
-    bool recache();
-
-    bool canSwitchTo() const;
-    bool switchTo();
-
-private:
-
-    /* Private member vars */
-    CMachine m_machine;
-
-    /* Cached machine data (to minimize server requests) */
-    QString m_strId;
-    QString m_strSettingsFile;
-
-    bool m_fAccessible;
-    CVirtualBoxErrorInfo m_accessError;
-
-    QString m_strName;
-    QString m_strSnapshotName;
-    KMachineState m_state;
-    QDateTime m_lastStateChange;
-    KSessionState m_sessionState;
-    QString m_strOSTypeId;
-    ULONG m_cSnaphot;
-
-    ULONG m_pid;
-};
-
-/* Make the pointer of this class public to the QVariant framework */
-Q_DECLARE_METATYPE(UIVMItem *);
-
-#endif /* __UIVMItem_h__ */
-
Index: unk/src/VBox/Frontends/VirtualBox/src/UIVMListView.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/UIVMListView.cpp	(revision 30867)
+++ 	(revision )
@@ -1,638 +1,0 @@
-/* $Id$ */
-/** @file
- *
- * VBox frontends: Qt GUI ("VirtualBox"):
- * UIVMItemModel, UIVMListView, UIVMItemPainter class implementation
- */
-
-/*
- * Copyright (C) 2006-2010 Oracle Corporation
- *
- * This file is part of VirtualBox Open Source Edition (OSE), as
- * available from http://www.virtualbox.org. This file is free software;
- * you can redistribute it and/or modify it under the terms of the GNU
- * General Public License (GPL) as published by the Free Software
- * Foundation, in version 2 as it comes in the "COPYING" file of the
- * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
- * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
- */
-
-#ifdef VBOX_WITH_PRECOMPILED_HEADERS
-# include "precomp.h"
-#else  /* !VBOX_WITH_PRECOMPILED_HEADERS */
-
-/* Local includes */
-#include "UIVMListView.h"
-#include "VBoxProblemReporter.h"
-#include "VBoxSelectorWnd.h"
-
-/* Global includes */
-#include <QPainter>
-#include <QLinearGradient>
-#include <QPixmapCache>
-
-#endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
-
-/* UIVMItemModel class */
-
-void UIVMItemModel::addItem(UIVMItem *aItem)
-{
-    Assert(aItem);
-    int row = m_VMItemList.count();
-    emit layoutAboutToBeChanged();
-    beginInsertRows(QModelIndex(), row, row);
-    m_VMItemList << aItem;
-    endInsertRows();
-    refreshItem(aItem);
-}
-
-void UIVMItemModel::removeItem(UIVMItem *aItem)
-{
-    Assert(aItem);
-    int row = m_VMItemList.indexOf(aItem);
-    removeRows(row, 1);
-}
-
-bool UIVMItemModel::removeRows(int aRow, int aCount, const QModelIndex &aParent /* = QModelIndex() */)
-{
-    emit layoutAboutToBeChanged();
-    beginRemoveRows(aParent, aRow, aRow + aCount);
-    m_VMItemList.erase(m_VMItemList.begin() + aRow, m_VMItemList.begin() + aRow + aCount);
-    endRemoveRows();
-    emit layoutChanged();
-    return true;
-}
-
-/**
- *  Refreshes the item corresponding to the given UUID.
- */
-void UIVMItemModel::refreshItem(UIVMItem *aItem)
-{
-    Assert(aItem);
-    if (aItem->recache())
-        sort();
-    itemChanged(aItem);
-}
-
-void UIVMItemModel::itemChanged(UIVMItem *aItem)
-{
-    Assert(aItem);
-    int row = m_VMItemList.indexOf(aItem);
-    /* Emit an layout change signal for the case some dimensions of the item
-     * has changed also. */
-    emit layoutChanged();
-    /* Emit an data changed signal. */
-    emit dataChanged(index(row), index(row));
-}
-
-/**
- *  Clear the item model list. Please note that the items itself are also
- *  deleted.
- */
-void UIVMItemModel::clear()
-{
-    qDeleteAll(m_VMItemList);
-}
-
-/**
- *  Returns the list item with the given UUID.
- */
-UIVMItem *UIVMItemModel::itemById(const QString &aId) const
-{
-    foreach(UIVMItem *item, m_VMItemList)
-        if (item->id() == aId)
-            return item;
-    return NULL;
-}
-
-UIVMItem *UIVMItemModel::itemByRow(int aRow) const
-{
-    return m_VMItemList.at(aRow);
-}
-
-QModelIndex UIVMItemModel::indexById(const QString &aId) const
-{
-    int row = rowById(aId);
-    if (row >= 0)
-        return index(row);
-    else
-        return QModelIndex();
-}
-
-int UIVMItemModel::rowById(const QString &aId) const
-{
-    for (int i=0; i < m_VMItemList.count(); ++i)
-    {
-        UIVMItem *item = m_VMItemList.at(i);
-        if (item->id() == aId)
-            return i;
-    }
-    return -1;
-}
-
-void UIVMItemModel::sort(int /* aColumn */, Qt::SortOrder aOrder /* = Qt::AscendingOrder */)
-{
-    emit layoutAboutToBeChanged();
-    switch (aOrder)
-    {
-        case Qt::AscendingOrder: qSort(m_VMItemList.begin(), m_VMItemList.end(), UIVMItemNameCompareLessThan); break;
-        case Qt::DescendingOrder: qSort(m_VMItemList.begin(), m_VMItemList.end(), UIVMItemNameCompareGreaterThan); break;
-    }
-    emit layoutChanged();
-}
-
-int UIVMItemModel::rowCount(const QModelIndex & /* aParent = QModelIndex() */) const
-{
-    return m_VMItemList.count();
-}
-
-QVariant UIVMItemModel::data(const QModelIndex &aIndex, int aRole) const
-{
-    if (!aIndex.isValid())
-        return QVariant();
-
-    if (aIndex.row() >= m_VMItemList.size())
-        return QVariant();
-
-    QVariant v;
-    switch (aRole)
-    {
-        case Qt::DisplayRole:
-        {
-            v = m_VMItemList.at(aIndex.row())->name();
-            break;
-        }
-        case Qt::DecorationRole:
-        {
-            v = m_VMItemList.at(aIndex.row())->osIcon();
-            break;
-        }
-        case Qt::ToolTipRole:
-        {
-            v = m_VMItemList.at(aIndex.row())->toolTipText();
-            break;
-        }
-        case Qt::FontRole:
-        {
-            QFont f = qApp->font();
-            f.setPointSize(f.pointSize() + 1);
-            f.setWeight(QFont::Bold);
-            v = f;
-            break;
-        }
-        case Qt::AccessibleTextRole:
-        {
-            UIVMItem *item = m_VMItemList.at(aIndex.row());
-            v = QString("%1 (%2)\n%3")
-                         .arg(item->name())
-                         .arg(item->snapshotName())
-                         .arg(item->sessionStateName());
-            break;
-        }
-        case SnapShotDisplayRole:
-        {
-            v = m_VMItemList.at(aIndex.row())->snapshotName();
-            break;
-        }
-        case SnapShotFontRole:
-        {
-            QFont f = qApp->font();
-            v = f;
-            break;
-        }
-        case SessionStateDisplayRole:
-        {
-            v = m_VMItemList.at(aIndex.row())->sessionStateName();
-            break;
-        }
-        case SessionStateDecorationRole:
-        {
-            v = m_VMItemList.at(aIndex.row())->sessionStateIcon();
-            break;
-        }
-        case SessionStateFontRole:
-        {
-            QFont f = qApp->font();
-            f.setPointSize(f.pointSize());
-            if (m_VMItemList.at(aIndex.row())->sessionState() != KSessionState_Closed)
-                f.setItalic(true);
-            v = f;
-            break;
-        }
-        case OSTypeIdRole:
-        {
-            v = m_VMItemList.at(aIndex.row())->osTypeId();
-            break;
-        }
-        case UIVMItemPtrRole:
-        {
-            v = qVariantFromValue(m_VMItemList.at(aIndex.row()));
-            break;
-        }
-    }
-    return v;
-}
-
-QVariant UIVMItemModel::headerData(int /*aSection*/, Qt::Orientation /*aOrientation*/,
-                                  int /*aRole = Qt::DisplayRole */) const
-{
-    return QVariant();
-}
-
-bool UIVMItemModel::UIVMItemNameCompareLessThan(UIVMItem* aItem1, UIVMItem* aItem2)
-{
-    Assert(aItem1);
-    Assert(aItem2);
-    return aItem1->name().toLower() < aItem2->name().toLower();
-}
-
-bool UIVMItemModel::UIVMItemNameCompareGreaterThan(UIVMItem* aItem1, UIVMItem* aItem2)
-{
-    Assert(aItem1);
-    Assert(aItem2);
-    return aItem2->name().toLower() < aItem1->name().toLower();
-}
-
-/* UIVMListView class */
-
-UIVMListView::UIVMListView(QWidget *aParent /* = 0 */)
-    :QIListView(aParent)
-{
-    /* Create & set our delegation class */
-    UIVMItemPainter *delegate = new UIVMItemPainter(this);
-    setItemDelegate(delegate);
-    /* Default icon size */
-    setIconSize(QSize(32, 32));
-    /* Publish the activation of items */
-    connect(this, SIGNAL(activated(const QModelIndex &)),
-            this, SIGNAL(activated()));
-    /* Use the correct policy for the context menu */
-    setContextMenuPolicy(Qt::CustomContextMenu);
-}
-
-void UIVMListView::selectItemByRow(int row)
-{
-    setCurrentIndex(model()->index(row, 0));
-}
-
-void UIVMListView::selectItemById(const QString &aID)
-{
-    if (UIVMItemModel *m = qobject_cast <UIVMItemModel*>(model()))
-    {
-        QModelIndex i = m->indexById(aID);
-        if (i.isValid())
-            setCurrentIndex(i);
-    }
-}
-
-void UIVMListView::ensureSomeRowSelected(int aRowHint)
-{
-    UIVMItem *item = selectedItem();
-    if (!item)
-    {
-        aRowHint = qBound(0, aRowHint, model()->rowCount() - 1);
-        selectItemByRow(aRowHint);
-        item = selectedItem();
-        if (!item)
-            selectItemByRow(0);
-    }
-}
-
-UIVMItem * UIVMListView::selectedItem() const
-{
-    QModelIndexList indexes = selectedIndexes();
-    if (indexes.isEmpty())
-        return NULL;
-    return model()->data(indexes.first(), UIVMItemModel::UIVMItemPtrRole).value <UIVMItem *>();
-}
-
-void UIVMListView::ensureCurrentVisible()
-{
-    scrollTo(currentIndex(), QAbstractItemView::EnsureVisible);
-}
-
-void UIVMListView::selectionChanged(const QItemSelection &aSelected, const QItemSelection &aDeselected)
-{
-    QListView::selectionChanged(aSelected, aDeselected);
-    selectCurrent();
-    ensureCurrentVisible();
-    emit currentChanged();
-}
-
-void UIVMListView::currentChanged(const QModelIndex &aCurrent, const QModelIndex &aPrevious)
-{
-    QListView::currentChanged(aCurrent, aPrevious);
-    selectCurrent();
-    ensureCurrentVisible();
-    emit currentChanged();
-}
-
-void UIVMListView::dataChanged(const QModelIndex &aTopLeft, const QModelIndex &aBottomRight)
-{
-    QListView::dataChanged(aTopLeft, aBottomRight);
-    selectCurrent();
-//    ensureCurrentVisible();
-    emit currentChanged();
-}
-
-bool UIVMListView::selectCurrent()
-{
-    QModelIndexList indexes = selectionModel()->selectedIndexes();
-    if (indexes.isEmpty() ||
-        indexes.first() != currentIndex())
-    {
-        /* Make sure that the current is always selected */
-        selectionModel()->select(currentIndex(), QItemSelectionModel::Current | QItemSelectionModel::ClearAndSelect);
-        return true;
-    }
-    return false;
-}
-
-/* UIVMItemPainter class */
-/*
- +----------------------------------------------+
- |       marg                                   |
- |   +----------+   m                           |
- | m |          | m a  name_string___________ m |
- | a |  OSType  | a r                         a |
- | r |  icon    | r g  +--+                   r |
- | g |          | g /  |si|  state_string     g |
- |   +----------+   2  +--+                     |
- |       marg                                   |
- +----------------------------------------------+
-
- si = state icon
-
-*/
-
-/* Little helper class for layout calculation */
-class QRectList: public QList<QRect *>
-{
-public:
-    void alignVCenterTo(QRect* aWhich)
-    {
-        QRect b;
-        foreach(QRect *rect, *this)
-            if(rect != aWhich)
-                b |= *rect;
-        if (b.width() > aWhich->width())
-            aWhich->moveCenter(QPoint(aWhich->center().x(), b.center().y()));
-        else
-        {
-            foreach(QRect *rect, *this)
-                if(rect != aWhich)
-                    rect->moveCenter(QPoint(rect->center().x(), aWhich->center().y()));
-        }
-    }
-};
-
-QSize UIVMItemPainter::sizeHint(const QStyleOptionViewItem &aOption,
-                                const QModelIndex &aIndex) const
-{
-    /* Get the size of every item */
-    QRect osTypeRT = rect(aOption, aIndex, Qt::DecorationRole);
-    QRect vmNameRT = rect(aOption, aIndex, Qt::DisplayRole);
-    QRect shotRT = rect(aOption, aIndex, UIVMItemModel::SnapShotDisplayRole);
-    QRect stateIconRT = rect(aOption, aIndex, UIVMItemModel::SessionStateDecorationRole);
-    QRect stateRT = rect(aOption, aIndex, UIVMItemModel::SessionStateDisplayRole);
-    /* Calculate the position for every item */
-    calcLayout(aIndex, &osTypeRT, &vmNameRT, &shotRT, &stateIconRT, &stateRT);
-    /* Calc the bounding rect */
-    const QRect boundingRect = osTypeRT | vmNameRT | shotRT | stateIconRT | stateRT;
-    /* Return + left/top/right/bottom margin */
-    return (boundingRect.size() + QSize(2 * m_Margin, 2 * m_Margin));
-}
-
-void UIVMItemPainter::paint(QPainter *pPainter, const QStyleOptionViewItem &option,
-                            const QModelIndex &index) const
-{
-    /* Generate the key used in the pixmap cache. Needs to be composed with all
-     * values which might be changed. */
-    QString key = QString("vbox:%1:%2:%3:%4:%5:%6")
-        .arg(index.data(Qt::DisplayRole).toString())
-        .arg(index.data(UIVMItemModel::OSTypeIdRole).toString())
-        .arg(index.data(UIVMItemModel::SnapShotDisplayRole).toString())
-        .arg(index.data(UIVMItemModel::SessionStateDisplayRole).toString())
-        .arg(option.state)
-        .arg(option.rect.width());
-
-    /* Check if the pixmap already exists in the cache. */
-    QPixmap pixmap;
-    if (!QPixmapCache::find(key, pixmap))
-    {
-        /* If not, generate a new one */
-        QStyleOptionViewItem tmpOption(option);
-        /* Highlight background if an item is selected in any case.
-         * (Fix for selector in the windows style.) */
-        tmpOption.showDecorationSelected = true;
-
-        /* Create a temporary pixmap and painter to work on.*/
-        QPixmap tmpPixmap(option.rect.size());
-        tmpPixmap.fill(Qt::transparent);
-        QPainter tmpPainter(&tmpPixmap);
-
-        /* Normally we operate on a painter which is in the size of the list
-         * view widget. Here we process one item only, so shift all the stuff
-         * out of the view. It will be translated back in the following
-         * methods. */
-        tmpPainter.translate(-option.rect.x(), -option.rect.y());
-
-        /* Start drawing with the background */
-        drawBackground(&tmpPainter, tmpOption, index);
-
-        /* Blend the content */
-        blendContent(&tmpPainter, tmpOption, index);
-
-        /* Draw a focus rectangle when necessary */
-        drawFocus(&tmpPainter, tmpOption, tmpOption.rect);
-
-        /* Finish drawing */
-        tmpPainter.end();
-
-        pixmap = tmpPixmap;
-        /* Fill the  cache */
-        QPixmapCache::insert(key, tmpPixmap);
-    }
-    pPainter->drawPixmap(option.rect, pixmap);
-}
-
-void UIVMItemPainter::paintContent(QPainter *pPainter, const QStyleOptionViewItem &option,
-                                   const QModelIndex &index) const
-{
-    /* Name and decoration */
-    const QString vmName = index.data(Qt::DisplayRole).toString();
-    const QFont nameFont = index.data(Qt::FontRole).value<QFont>();
-    const QPixmap osType = index.data(Qt::DecorationRole).value<QIcon>().pixmap(option.decorationSize, iconMode(option.state), iconState(option.state));
-
-    const QString shot = index.data(UIVMItemModel::SnapShotDisplayRole).toString();
-    const QFont shotFont = index.data(UIVMItemModel::SnapShotFontRole).value<QFont>();
-
-    const QString state = index.data(UIVMItemModel::SessionStateDisplayRole).toString();
-    const QFont stateFont = index.data(UIVMItemModel::SessionStateFontRole).value<QFont>();
-    const QPixmap stateIcon = index.data(UIVMItemModel::SessionStateDecorationRole).value<QIcon>().pixmap(QSize(16, 16), iconMode(option.state), iconState(option.state));
-
-    /* Get the sizes for all items */
-    QRect osTypeRT = rect(option, index, Qt::DecorationRole);
-    QRect vmNameRT = rect(option, index, Qt::DisplayRole);
-    QRect shotRT = rect(option, index, UIVMItemModel::SnapShotDisplayRole);
-    QRect stateIconRT = rect(option, index, UIVMItemModel::SessionStateDecorationRole);
-    QRect stateRT = rect(option, index, UIVMItemModel::SessionStateDisplayRole);
-
-    /* Calculate the positions for all items */
-    calcLayout(index, &osTypeRT, &vmNameRT, &shotRT, &stateIconRT, &stateRT);
-    /* Get the appropriate pen for the current state */
-    QPalette pal = option.palette;
-    QPen pen = pal.color(QPalette::Active, QPalette::Text);
-    if (option.state & QStyle::State_Selected &&
-        (option.state & QStyle::State_HasFocus ||
-        QApplication::style()->styleHint(QStyle::SH_ItemView_ChangeHighlightOnFocus, &option) == 0))
-        pen =  pal.color(QPalette::Active, QPalette::HighlightedText);
-    /* Set the current pen */
-    pPainter->setPen(pen);
-    /* os type icon */
-    pPainter->drawPixmap(osTypeRT, osType);
-    /* vm name */
-    pPainter->setFont(nameFont);
-    pPainter->drawText(vmNameRT, vmName);
-    /* current snapshot in braces */
-    if (!shot.isEmpty())
-    {
-        pPainter->setFont(shotFont);
-        pPainter->drawText(shotRT, QString("(%1)").arg(shot));
-    }
-    /* state icon */
-    pPainter->drawPixmap(stateIconRT, stateIcon);
-    /* textual state */
-    pPainter->setFont(stateFont);
-    pPainter->drawText(stateRT, state);
-    /* For debugging */
-//    QRect boundingRect = osTypeRT | vmNameRT | shotRT | stateIconRT | stateRT;
-//    pPainter->drawRect(boundingRect);
-}
-
-void UIVMItemPainter::blendContent(QPainter *pPainter, const QStyleOptionViewItem &option,
-                                   const QModelIndex &index) const
-{
-    QRect r = option.rect;
-    QWidget *pParent = qobject_cast<QListView *>(parent())->viewport();
-    /* This is as always a big fat mess on Mac OS X. We can't use QImage for
-     * rendering text, cause this looks like shit. We can't do all the drawing
-     * on the widget, cause the composition modes are not working correctly.
-     * The same count for doing composition on a QPixmap. The work around is to
-     * draw all into a QPixmap (also the background color/gradient, otherwise
-     * the antialiasing is messed up), bliting this into a QImage to make the
-     * composition stuff and finally bliting this QImage into the QWidget.
-     * Yipi a yeah. Btw, no problem on Linux at all. */
-    QPixmap basePixmap(r.width(), r.height());//
-    /* Initialize with the base image color. */
-    basePixmap.fill(pParent->palette().base().color());
-    /* Create the painter to operate on. */
-    QPainter basePainter(&basePixmap);
-    /* Initialize the painter with the corresponding widget */
-    basePainter.initFrom(pParent);
-    basePainter.setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing, true);
-    /* The translation is necessary, cause drawBackground expect the whole drawing area. */
-    basePainter.save();
-    basePainter.translate(-option.rect.x(), -option.rect.y());
-    drawBackground(&basePainter, option, index);
-    basePainter.restore();
-    /* Now paint the content. */
-    paintContent(&basePainter, option, index);
-    /* Finished with the OS dependent part. */
-    basePainter.end();
-    /* Time for the OS independent part (That is, use the QRasterEngine) */
-    QImage baseImage(r.width(), r.height(), QImage::Format_ARGB32_Premultiplied);
-    QPainter rasterPainter(&baseImage);
-    /* Initialize the painter with the corresponding widget */
-    rasterPainter.initFrom(pParent);
-    rasterPainter.setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing, true);
-    /* Fully copy the source to the destination */
-    rasterPainter.setCompositionMode(QPainter::CompositionMode_Source);
-    rasterPainter.drawPixmap(0, 0, basePixmap);
-    /* Now use the alpha value of the source to blend the destination in. */
-    rasterPainter.setCompositionMode(QPainter::CompositionMode_DestinationIn);
-
-    const int blendWidth = qMin(70, r.width());
-    QLinearGradient lg(r.width()-blendWidth, 0, r.width(), 0);
-    lg.setColorAt(0, QColor(Qt::white));
-    lg.setColorAt(0.95, QColor(Qt::transparent));
-    lg.setColorAt(1, QColor(Qt::transparent));
-    rasterPainter.fillRect(r.width()-blendWidth, 0, blendWidth, r.height(), lg);
-    /* Finished with the OS independent part. */
-    rasterPainter.end();
-
-    /* Finally blit our hard work on the widget. */
-    pPainter->drawImage(option.rect.x(), option.rect.y(), baseImage);
-}
-
-QRect UIVMItemPainter::rect(const QStyleOptionViewItem &aOption,
-                            const QModelIndex &aIndex, int aRole) const
-{
-    switch (aRole)
-    {
-        case Qt::DisplayRole:
-            {
-                QString text = aIndex.data(Qt::DisplayRole).toString();
-                QFontMetrics fm(fontMetric(aIndex, Qt::FontRole));
-                return QRect(QPoint(0, 0), fm.size(0, text));
-                break;
-            }
-        case Qt::DecorationRole:
-            {
-                QIcon icon = aIndex.data(Qt::DecorationRole).value<QIcon>();
-                return QRect(QPoint(0, 0), icon.actualSize(aOption.decorationSize, iconMode(aOption.state), iconState(aOption.state)));
-                break;
-            }
-        case UIVMItemModel::SnapShotDisplayRole:
-            {
-                QString text = aIndex.data(UIVMItemModel::SnapShotDisplayRole).toString();
-                if (!text.isEmpty())
-                {
-                    QFontMetrics fm(fontMetric(aIndex, UIVMItemModel::SnapShotFontRole));
-                    return QRect(QPoint(0, 0), fm.size(0, QString("(%1)").arg(text)));
-                }else
-                    return QRect();
-                break;
-            }
-        case UIVMItemModel::SessionStateDisplayRole:
-            {
-                QString text = aIndex.data(UIVMItemModel::SessionStateDisplayRole).toString();
-                QFontMetrics fm(fontMetric(aIndex, UIVMItemModel::SessionStateFontRole));
-                return QRect(QPoint(0, 0), fm.size(0, text));
-                break;
-            }
-        case UIVMItemModel::SessionStateDecorationRole:
-            {
-                QIcon icon = aIndex.data(UIVMItemModel::SessionStateDecorationRole).value<QIcon>();
-                return QRect(QPoint(0, 0), icon.actualSize(QSize(16, 16), iconMode(aOption.state), iconState(aOption.state)));
-                break;
-            }
-    }
-    return QRect();
-}
-
-void UIVMItemPainter::calcLayout(const QModelIndex &aIndex,
-                                 QRect *aOSType, QRect *aVMName, QRect *aShot,
-                                 QRect *aStateIcon, QRect *aState) const
-{
-    const int nameSpaceWidth = fontMetric(aIndex, Qt::FontRole).width(' ');
-    const int stateSpaceWidth = fontMetric(aIndex, UIVMItemModel::SessionStateFontRole).width(' ');
-    /* Really basic layout managment.
-     * First layout as usual */
-    aOSType->moveTo(m_Margin, m_Margin);
-    aVMName->moveTo(m_Margin + aOSType->width() + m_Spacing, m_Margin);
-    aShot->moveTo(aVMName->right() + nameSpaceWidth, aVMName->top());
-    aStateIcon->moveTo(aVMName->left(), aVMName->bottom());
-    aState->moveTo(aStateIcon->right() + stateSpaceWidth, aStateIcon->top());
-    /* Do grouping for the automatic center routine.
-     * First the states group: */
-    QRectList statesLayout;
-    statesLayout << aStateIcon << aState;
-    /* All items in the layout: */
-    QRectList allLayout;
-    allLayout << aOSType << aVMName << aShot << statesLayout;
-    /* Now verticaly center the items based on the reference item */
-    statesLayout.alignVCenterTo(aStateIcon);
-    allLayout.alignVCenterTo(aOSType);
-}
-
Index: unk/src/VBox/Frontends/VirtualBox/src/UIVMListView.h
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/UIVMListView.h	(revision 30867)
+++ 	(revision )
@@ -1,147 +1,0 @@
-/** @file
- *
- * VBox frontends: Qt GUI ("VirtualBox"):
- * UIVMItemModel, UIVMListView, UIVMItemPainter class declarations
- */
-
-/*
- * Copyright (C) 2006-2010 Oracle Corporation
- *
- * This file is part of VirtualBox Open Source Edition (OSE), as
- * available from http://www.virtualbox.org. This file is free software;
- * you can redistribute it and/or modify it under the terms of the GNU
- * General Public License (GPL) as published by the Free Software
- * Foundation, in version 2 as it comes in the "COPYING" file of the
- * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
- * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
- */
-
-#ifndef __UIVMListView_h__
-#define __UIVMListView_h__
-
-/* Self includes */
-#include "VBoxGlobal.h"
-#include "QIListView.h"
-#include "UIVMItem.h"
-
-/* Qt includes */
-#include <QAbstractListModel>
-
-class UIVMItemModel: public QAbstractListModel
-{
-    Q_OBJECT;
-
-public:
-    enum { SnapShotDisplayRole = Qt::UserRole,
-           SnapShotFontRole,
-           SessionStateDisplayRole,
-           SessionStateDecorationRole,
-           SessionStateFontRole,
-           OSTypeIdRole,
-           UIVMItemPtrRole };
-
-    UIVMItemModel(QObject *aParent = 0)
-        :QAbstractListModel(aParent) {}
-
-    void addItem(UIVMItem *aItem);
-    void removeItem(UIVMItem *aItem);
-    void refreshItem(UIVMItem *aItem);
-
-    void itemChanged(UIVMItem *aItem);
-
-    void clear();
-
-    UIVMItem *itemById(const QString &aId) const;
-    UIVMItem *itemByRow(int aRow) const;
-    QModelIndex indexById(const QString &aId) const;
-
-    int rowById(const QString &aId) const;;
-
-    void sort(Qt::SortOrder aOrder = Qt::AscendingOrder) { sort(0, aOrder); }
-
-    /* The following are necessary model implementations */
-    void sort(int aColumn, Qt::SortOrder aOrder = Qt::AscendingOrder);
-
-    int rowCount(const QModelIndex &aParent = QModelIndex()) const;
-
-    QVariant data(const QModelIndex &aIndex, int aRole) const;
-    QVariant headerData(int aSection, Qt::Orientation aOrientation,
-                        int aRole = Qt::DisplayRole) const;
-
-    bool removeRows(int aRow, int aCount, const QModelIndex &aParent = QModelIndex());
-
-private:
-    static bool UIVMItemNameCompareLessThan(UIVMItem* aItem1, UIVMItem* aItem2);
-    static bool UIVMItemNameCompareGreaterThan(UIVMItem* aItem1, UIVMItem* aItem2);
-
-    /* Private member vars */
-    QList<UIVMItem *> m_VMItemList;
-};
-
-class UIVMListView: public QIListView
-{
-    Q_OBJECT;
-
-public:
-    UIVMListView(QWidget *aParent = 0);
-
-    void selectItemByRow(int row);
-    void selectItemById(const QString &aID);
-    void ensureSomeRowSelected(int aRowHint);
-    UIVMItem * selectedItem() const;
-
-    void ensureCurrentVisible();
-
-signals:
-    void currentChanged();
-    void activated();
-
-protected slots:
-    void selectionChanged(const QItemSelection &aSelected, const QItemSelection &aDeselected);
-    void currentChanged(const QModelIndex &aCurrent, const QModelIndex &aPrevious);
-    void dataChanged(const QModelIndex &aTopLeft, const QModelIndex &aBottomRight);
-
-protected:
-    bool selectCurrent();
-};
-
-class UIVMItemPainter: public QIItemDelegate
-{
-public:
-    UIVMItemPainter(QObject *aParent = 0)
-      : QIItemDelegate(aParent), m_Margin(8), m_Spacing(m_Margin * 3 / 2) {}
-
-    QSize sizeHint(const QStyleOptionViewItem &aOption,
-                   const QModelIndex &aIndex) const;
-
-    void paint(QPainter *aPainter, const QStyleOptionViewItem &aOption,
-               const QModelIndex &aIndex) const;
-
-private:
-    void paintContent(QPainter *pPainter, const QStyleOptionViewItem &option, const QModelIndex &index) const;
-    void blendContent(QPainter *pPainter, const QStyleOptionViewItem &option, const QModelIndex &index) const;
-    inline QFontMetrics fontMetric(const QModelIndex &aIndex, int aRole) const { return QFontMetrics(aIndex.data(aRole).value<QFont>()); }
-    inline QIcon::Mode iconMode(QStyle::State aState) const
-    {
-        if (!(aState & QStyle::State_Enabled))
-            return QIcon::Disabled;
-        if (aState & QStyle::State_Selected)
-            return QIcon::Selected;
-        return QIcon::Normal;
-    }
-    inline QIcon::State iconState(QStyle::State aState) const { return aState & QStyle::State_Open ? QIcon::On : QIcon::Off; }
-
-    QRect rect(const QStyleOptionViewItem &aOption,
-               const QModelIndex &aIndex, int aRole) const;
-
-    void calcLayout(const QModelIndex &aIndex,
-                    QRect *aOSType, QRect *aVMName, QRect *aShot,
-                    QRect *aStateIcon, QRect *aState) const;
-
-    /* Private member vars */
-    int m_Margin;
-    int m_Spacing;
-};
-
-#endif /* __UIVMListView_h__ */
-
Index: unk/src/VBox/Frontends/VirtualBox/src/UIVirtualBoxEventHandler.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/UIVirtualBoxEventHandler.cpp	(revision 30867)
+++ 	(revision )
@@ -1,93 +1,0 @@
-/* $Id$ */
-/** @file
- *
- * VBox frontends: Qt GUI ("VirtualBox"):
- * UIVirtualBoxEventHandler class implementation
- */
-
-/*
- * Copyright (C) 2010 Oracle Corporation
- *
- * This file is part of VirtualBox Open Source Edition (OSE), as
- * available from http://www.virtualbox.org. This file is free software;
- * you can redistribute it and/or modify it under the terms of the GNU
- * General Public License (GPL) as published by the Free Software
- * Foundation, in version 2 as it comes in the "COPYING" file of the
- * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
- * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
- */
-
-/* Local includes */
-#include "UIVirtualBoxEventHandler.h"
-#include "UIMainEventListener.h"
-#include "VBoxGlobal.h"
-
-/* Global includes */
-//#include <iprt/thread.h>
-//#include <iprt/stream.h>
-
-/* static */
-UIVirtualBoxEventHandler *UIVirtualBoxEventHandler::m_pInstance = 0;
-
-/* static */
-UIVirtualBoxEventHandler* UIVirtualBoxEventHandler::instance()
-{
-    if (!m_pInstance)
-        m_pInstance = new UIVirtualBoxEventHandler();
-    return m_pInstance;
-}
-
-/* static */
-void UIVirtualBoxEventHandler::destroy()
-{
-    if (m_pInstance)
-    {
-        delete m_pInstance;
-        m_pInstance = 0;
-    }
-}
-
-UIVirtualBoxEventHandler::UIVirtualBoxEventHandler()
-{
-//    RTPrintf("Self add: %RTthrd\n", RTThreadSelf());
-    const CVirtualBox &vbox = vboxGlobal().virtualBox();
-    UIMainEventListener *pListener = new UIMainEventListener(this);
-    m_mainEventListener = CEventListener(pListener);
-    QVector<KVBoxEventType> events;
-    events
-        << KVBoxEventType_OnMachineStateChange
-        << KVBoxEventType_OnMachineDataChange
-        << KVBoxEventType_OnMachineRegistered
-        << KVBoxEventType_OnSessionStateChange
-        << KVBoxEventType_OnSnapshotChange;
-
-    vbox.GetEventSource().RegisterListener(m_mainEventListener, events, TRUE);
-    AssertWrapperOk(vbox);
-
-    connect(pListener, SIGNAL(sigMachineStateChange(QString, KMachineState)),
-            this, SIGNAL(sigMachineStateChange(QString, KMachineState)),
-            Qt::QueuedConnection);
-
-    connect(pListener, SIGNAL(sigMachineDataChange(QString)),
-            this, SIGNAL(sigMachineDataChange(QString)),
-            Qt::QueuedConnection);
-
-    connect(pListener, SIGNAL(sigMachineRegistered(QString, bool)),
-            this, SIGNAL(sigMachineRegistered(QString, bool)),
-            Qt::QueuedConnection);
-
-    connect(pListener, SIGNAL(sigSessionStateChange(QString, KSessionState)),
-            this, SIGNAL(sigSessionStateChange(QString, KSessionState)),
-            Qt::QueuedConnection);
-
-    connect(pListener, SIGNAL(sigSnapshotChange(QString, QString)),
-            this, SIGNAL(sigSnapshotChange(QString, QString)),
-            Qt::QueuedConnection);
-}
-
-UIVirtualBoxEventHandler::~UIVirtualBoxEventHandler()
-{
-    const CVirtualBox &vbox = vboxGlobal().virtualBox();
-    vbox.GetEventSource().UnregisterListener(m_mainEventListener);
-}
-
Index: unk/src/VBox/Frontends/VirtualBox/src/UIVirtualBoxEventHandler.h
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/UIVirtualBoxEventHandler.h	(revision 30867)
+++ 	(revision )
@@ -1,53 +1,0 @@
-/** @file
- *
- * VBox frontends: Qt GUI ("VirtualBox"):
- * UIVirtualBoxEventHandler class declaration
- */
-
-/*
- * Copyright (C) 2010 Oracle Corporation
- *
- * This file is part of VirtualBox Open Source Edition (OSE), as
- * available from http://www.virtualbox.org. This file is free software;
- * you can redistribute it and/or modify it under the terms of the GNU
- * General Public License (GPL) as published by the Free Software
- * Foundation, in version 2 as it comes in the "COPYING" file of the
- * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
- * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
- */
-
-#ifndef __UIVirtualBoxEventHandler_h__
-#define __UIVirtualBoxEventHandler_h__
-
-/* Local includes */
-#include "COMDefs.h"
-
-class UIVirtualBoxEventHandler: public QObject
-{
-    Q_OBJECT;
-
-public:
-    static UIVirtualBoxEventHandler* instance();
-    static void destroy();
-
-signals:
-    /* VirtualBox main signals */
-    void sigMachineStateChange(QString strId, KMachineState state);
-    void sigMachineDataChange(QString strId);
-    void sigMachineRegistered(QString strId, bool fRegistered);
-    void sigSessionStateChange(QString strId, KSessionState state);
-    void sigSnapshotChange(QString strId, QString strSnapshotId);
-
-private:
-    UIVirtualBoxEventHandler();
-    ~UIVirtualBoxEventHandler();
-
-    /* Private member vars */
-    static UIVirtualBoxEventHandler *m_pInstance;
-    CEventListener m_mainEventListener;
-};
-
-#define gVBoxEvents UIVirtualBoxEventHandler::instance()
-
-#endif /* !__UIVirtualBoxEventHandler_h__ */
-
Index: unk/src/VBox/Frontends/VirtualBox/src/VBoxSelectorWnd.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/VBoxSelectorWnd.cpp	(revision 30867)
+++ 	(revision )
@@ -1,2277 +1,0 @@
-/** @file
- *
- * VBox frontends: Qt GUI ("VirtualBox"):
- * VBoxSelectorWnd class implementation
- */
-
-/*
- * Copyright (C) 2006-2010 Oracle Corporation
- *
- * This file is part of VirtualBox Open Source Edition (OSE), as
- * available from http://www.virtualbox.org. This file is free software;
- * you can redistribute it and/or modify it under the terms of the GNU
- * General Public License (GPL) as published by the Free Software
- * Foundation, in version 2 as it comes in the "COPYING" file of the
- * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
- * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
- */
-
-#ifdef VBOX_WITH_PRECOMPILED_HEADERS
-# include "precomp.h"
-#else  /* !VBOX_WITH_PRECOMPILED_HEADERS */
-#include "QISplitter.h"
-#include "QITabWidget.h"
-#include "UIExportApplianceWzd.h"
-#include "UIIconPool.h"
-#include "UIImportApplianceWzd.h"
-#include "UINewVMWzd.h"
-#include "UISpacerWidgets.h"
-#include "UISpecialControls.h"
-#include "UIVMListView.h"
-#include "VBoxGlobal.h"
-#include "VBoxMediaManagerDlg.h"
-#include "VBoxProblemReporter.h"
-#include "VBoxSelectorWnd.h"
-#include "VBoxSettingsDialogSpecific.h"
-#include "VBoxSnapshotsWgt.h"
-#include "VBoxToolBar.h"
-#include "VBoxUtils.h"
-#include "VBoxVMLogViewer.h"
-#include "UIVirtualBoxEventHandler.h"
-
-#include "UIDownloaderUserManual.h"
-
-#ifdef Q_WS_X11
-#include <iprt/env.h>
-#endif
-
-/* Qt includes */
-#include <QTextBrowser>
-#include <QMenuBar>
-#include <QMenu>
-#include <QMenuItem>
-#include <QStackedWidget>
-#include <QDesktopWidget>
-#include <QToolButton>
-
-#include <iprt/buildconfig.h>
-#include <VBox/version.h>
-#endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
-
-// VBoxVMDetailsView class
-////////////////////////////////////////////////////////////////////////////////
-
-/**
- *  Two-page widget stack to represent VM details: one page for normal details
- *  and another one for inaccessibility errors.
- */
-class VBoxVMDetailsView : public QIWithRetranslateUI<QStackedWidget>
-{
-    Q_OBJECT;
-
-public:
-
-    VBoxVMDetailsView (QWidget *aParent,
-                       QAction *aRefreshAction = NULL);
-
-    void setDetailsText (const QString &aText)
-    {
-        mDetailsText->setText (aText);
-        setCurrentIndex (0);
-    }
-
-    void setErrorText (const QString &aText)
-    {
-        createErrPage();
-        mErrText->setText (aText);
-        setCurrentIndex (1);
-    }
-
-    void setEmpty()
-    {
-        mDetailsText->setText (QString::null);
-        setCurrentIndex (0);
-    }
-
-signals:
-
-    void linkClicked (const QString &aURL);
-
-protected:
-
-    void retranslateUi();
-
-private slots:
-
-    void gotLinkClicked (const QUrl &aURL)
-    {
-        emit linkClicked (aURL.toString());
-    }
-
-private:
-
-    void createErrPage();
-
-    QRichTextBrowser *mDetailsText;
-
-    QWidget *mErrBox;
-    QLabel *mErrLabel;
-    QTextBrowser *mErrText;
-    QToolButton *mRefreshButton;
-    QAction *mRefreshAction;
-};
-
-VBoxVMDetailsView::VBoxVMDetailsView (QWidget *aParent,
-                                      QAction *aRefreshAction /* = NULL */)
-    : QIWithRetranslateUI<QStackedWidget> (aParent)
-    , mErrBox (NULL), mErrLabel (NULL), mErrText (NULL)
-    , mRefreshButton (NULL)
-    , mRefreshAction (aRefreshAction)
-{
-    Assert (mRefreshAction);
-
-    /* create normal details page */
-
-    mDetailsText = new QRichTextBrowser (mErrBox);
-    mDetailsText->setViewportMargins (10, 10, 10, 10);
-    mDetailsText->setFocusPolicy (Qt::StrongFocus);
-    mDetailsText->document()->setDefaultStyleSheet ("a { text-decoration: none; }");
-    /* make "transparent" */
-    mDetailsText->setFrameShape (QFrame::NoFrame);
-    mDetailsText->viewport()->setAutoFillBackground (false);
-    mDetailsText->setOpenLinks (false);
-
-    connect (mDetailsText, SIGNAL (anchorClicked (const QUrl &)),
-             this, SLOT (gotLinkClicked (const QUrl &)));
-
-    addWidget (mDetailsText);
-}
-
-void VBoxVMDetailsView::createErrPage()
-{
-    /* create inaccessible details page */
-
-    if (mErrBox)
-        return;
-
-    mErrBox = new QWidget();
-
-    QVBoxLayout *vLayout = new QVBoxLayout (mErrBox);
-    vLayout->setSpacing (10);
-
-    mErrLabel = new QLabel (mErrBox);
-    mErrLabel->setWordWrap (true);
-    mErrLabel->setSizePolicy (QSizePolicy::Expanding, QSizePolicy::Fixed);
-    vLayout->addWidget (mErrLabel);
-
-    mErrText = new QTextBrowser (mErrBox);
-    mErrText->setFocusPolicy (Qt::StrongFocus);
-    mErrText->document()->setDefaultStyleSheet ("a { text-decoration: none; }");
-    vLayout->addWidget (mErrText);
-
-    if (mRefreshAction)
-    {
-        mRefreshButton = new QToolButton (mErrBox);
-        mRefreshButton->setFocusPolicy (Qt::StrongFocus);
-
-        QHBoxLayout *hLayout = new QHBoxLayout ();
-        vLayout->addLayout (hLayout);
-        hLayout->addItem (new QSpacerItem (0, 0, QSizePolicy::Expanding,
-                                                 QSizePolicy::Minimum));
-        hLayout->addWidget (mRefreshButton);
-
-        connect (mRefreshButton, SIGNAL (clicked()),
-                 mRefreshAction, SIGNAL (triggered()));
-    }
-
-    vLayout->addItem (new QSpacerItem (0, 0, QSizePolicy::Minimum,
-                                             QSizePolicy::Expanding));
-
-    addWidget (mErrBox);
-
-    retranslateUi();
-}
-
-void VBoxVMDetailsView::retranslateUi()
-{
-    if (mErrLabel)
-        mErrLabel->setText (tr (
-            "The selected virtual machine is <i>inaccessible</i>. Please "
-            "inspect the error message shown below and press the "
-            "<b>Refresh</b> button if you want to repeat the accessibility "
-            "check:"));
-
-    if (mRefreshAction && mRefreshButton)
-    {
-        mRefreshButton->setText (mRefreshAction->text());
-        mRefreshButton->setIcon (mRefreshAction->icon());
-        mRefreshButton->setToolButtonStyle (Qt::ToolButtonTextBesideIcon);
-    }
-}
-
-// VBoxVMDescriptionPage class
-////////////////////////////////////////////////////////////////////////////////
-
-/**
- *  Comments page widget to represent VM comments.
- */
-class VBoxVMDescriptionPage : public QIWithRetranslateUI<QWidget>
-{
-    Q_OBJECT;
-
-public:
-
-    VBoxVMDescriptionPage (VBoxSelectorWnd *);
-    ~VBoxVMDescriptionPage() {}
-
-    void setMachineItem (UIVMItem *aItem);
-
-    void updateState();
-
-protected:
-
-    void retranslateUi();
-
-private slots:
-
-    void goToSettings();
-
-private:
-
-    UIVMItem *mItem;
-
-    VBoxSelectorWnd *mParent;
-    QToolButton *mBtnEdit;
-    QTextBrowser *mBrowser;
-    QLabel *mLabel;
-};
-
-VBoxVMDescriptionPage::VBoxVMDescriptionPage (VBoxSelectorWnd *aParent)
-    : QIWithRetranslateUI<QWidget> (aParent)
-    , mItem (NULL), mParent (aParent)
-    , mBtnEdit (0), mBrowser (0), mLabel (0)
-{
-    /* main layout */
-    QVBoxLayout *vMainLayout = new QVBoxLayout (this);
-    vMainLayout->setSpacing (10);
-    VBoxGlobal::setLayoutMargin (vMainLayout, 0);
-
-    /* mBrowser */
-    mBrowser = new QTextBrowser (this);
-    mBrowser->setSizePolicy (QSizePolicy::Expanding, QSizePolicy::Expanding);
-    mBrowser->setFocusPolicy (Qt::StrongFocus);
-    mBrowser->document()->setDefaultStyleSheet ("a { text-decoration: none; }");
-    vMainLayout->addWidget (mBrowser);
-    /* hidden by default */
-    mBrowser->setHidden (true);
-
-    mLabel = new QLabel (this);
-    mLabel->setFrameStyle (mBrowser->frameStyle());
-    mLabel->setSizePolicy (QSizePolicy::Expanding, QSizePolicy::Expanding);
-    mLabel->setAlignment (Qt::AlignCenter);
-    mLabel->setWordWrap (true);
-    vMainLayout->addWidget (mLabel);
-    /* always disabled */
-    mLabel->setEnabled (false);
-
-    /* button layout */
-    QHBoxLayout *hBtnLayout = new QHBoxLayout ();
-    vMainLayout->addLayout (hBtnLayout);
-    hBtnLayout->setSpacing (10);
-    hBtnLayout->addItem (new QSpacerItem (0, 0,
-                                          QSizePolicy::Expanding,
-                                          QSizePolicy::Minimum));
-
-    /* button */
-    mBtnEdit = new QToolButton (this);
-    mBtnEdit->setSizePolicy (QSizePolicy::Preferred, QSizePolicy::Fixed);
-    mBtnEdit->setFocusPolicy (Qt::StrongFocus);
-    mBtnEdit->setIcon(UIIconPool::iconSet(":/edit_description_16px.png",
-                                          ":/edit_description_disabled_16px.png"));
-    mBtnEdit->setToolButtonStyle (Qt::ToolButtonTextBesideIcon);
-    connect (mBtnEdit, SIGNAL (clicked()), this, SLOT (goToSettings()));
-    hBtnLayout->addWidget (mBtnEdit);
-
-    vMainLayout->addItem (new QSpacerItem (0, 0,
-                                           QSizePolicy::Expanding,
-                                           QSizePolicy::Minimum));
-
-    /* apply language settings */
-    retranslateUi();
-
-    updateState();
-}
-
-/**
- * The machine list @a aItem is used to access cached machine data w/o making
- * unnecessary RPC calls.
- */
-void VBoxVMDescriptionPage::setMachineItem (UIVMItem *aItem)
-{
-    mItem = aItem;
-
-    QString text = aItem ? aItem->machine().GetDescription() : QString::null;
-
-    if (!text.isEmpty())
-    {
-        mLabel->setHidden (true);
-        mBrowser->setText (text);
-        mBrowser->setVisible (true);
-    }
-    else
-    {
-        mBrowser->setHidden (true);
-        mBrowser->clear();
-        mLabel->setVisible (true);
-    }
-
-    /* check initial machine and session states */
-    updateState();
-}
-
-void VBoxVMDescriptionPage::retranslateUi()
-{
-    mLabel->setText (tr ("No description. Press the Edit button below to add it."));
-
-    mBtnEdit->setText (tr ("Edit"));
-    mBtnEdit->setShortcut (QKeySequence ("Ctrl+E"));
-    mBtnEdit->setToolTip (tr ("Edit (Ctrl+E)"));
-    mBtnEdit->adjustSize();
-    mBtnEdit->updateGeometry();
-}
-
-/**
- * Called by the parent from machineStateChanged() and sessionStateChanged()
- * signal handlers. We cannot connect to these signals ourselves because we
- * use the UIVMListBoxItem which needs to be properly updated by the parent
- * first.
- */
-void VBoxVMDescriptionPage::updateState()
-{
-    /// @todo disabling the edit button for a saved VM will not be necessary
-    /// when we implement the selective VM Settings dialog, where only fields
-    /// that can be changed in the saved state, can be changed.
-
-    if (mItem)
-    {
-        bool saved = mItem->state() == KMachineState_Saved;
-        bool busy = mItem->sessionState() != KSessionState_Closed;
-        mBtnEdit->setEnabled (!saved && !busy);
-    }
-    else
-        mBtnEdit->setEnabled (false);
-}
-
-void VBoxVMDescriptionPage::goToSettings()
-{
-    mParent->vmSettings ("#general", "mTeDescription");
-}
-
-// VBoxSelectorWnd class
-////////////////////////////////////////////////////////////////////////////////
-
-/** \class VBoxSelectorWnd
- *
- *  The VBoxSelectorWnd class is a VM selector window, one of two main VBox
- *  GUI windows.
- *
- *  This window appears when the user starts the VirtualBox executable.
- *  It allows to view the list of configured VMs, their settings
- *  and the current state, create, reconfigure, delete and start VMs.
- */
-
-/**
- *  Constructs the VM selector window.
- *
- *  @param aSelf pointer to a variable where to store |this| right after
- *               this object's constructor is called (necessary to avoid
- *               recursion in VBoxGlobal::selectorWnd())
- */
-VBoxSelectorWnd::
-VBoxSelectorWnd (VBoxSelectorWnd **aSelf, QWidget* aParent,
-                 Qt::WindowFlags aFlags /* = Qt::Window */)
-    : QIWithRetranslateUI2<QMainWindow> (aParent, aFlags)
-    , mDoneInaccessibleWarningOnce (false)
-{
-    VBoxGlobalSettings settings = vboxGlobal().settings();
-
-    if (aSelf)
-        *aSelf = this;
-
-    statusBar()->setContextMenuPolicy(Qt::CustomContextMenu);
-    connect(statusBar(), SIGNAL(customContextMenuRequested(const QPoint&)),
-            this, SLOT(showViewContextMenu(const QPoint&)));
-
-#if defined (Q_WS_MAC) && (QT_VERSION < 0x040402)
-    qApp->installEventFilter (this);
-#endif /* defined (Q_WS_MAC) && (QT_VERSION < 0x040402) */
-
-#if !(defined (Q_WS_WIN) || defined (Q_WS_MAC))
-    /* The application icon. On Win32, it's built-in to the executable. On Mac
-     * OS X the icon referenced in info.plist is used. */
-    setWindowIcon (QIcon (":/VirtualBox_48px.png"));
-#endif
-
-    /* actions */
-
-    mFileMediaMgrAction = new QAction (this);
-    mFileMediaMgrAction->setIcon(UIIconPool::iconSet(":/diskimage_16px.png"));
-
-    mFileApplianceImportAction = new QAction (this);
-    mFileApplianceImportAction->setIcon(UIIconPool::iconSet(":/import_16px.png"));
-
-    mFileApplianceExportAction = new QAction (this);
-    mFileApplianceExportAction->setIcon(UIIconPool::iconSet(":/export_16px.png"));
-
-    mFileSettingsAction = new QAction(this);
-    mFileSettingsAction->setMenuRole (QAction::PreferencesRole);
-    mFileSettingsAction->setIcon(UIIconPool::iconSet(":/global_settings_16px.png"));
-    mFileExitAction = new QAction (this);
-    mFileExitAction->setMenuRole (QAction::QuitRole);
-    mFileExitAction->setIcon(UIIconPool::iconSet(":/exit_16px.png"));
-
-    mVmNewAction = new QAction (this);
-    mVmNewAction->setIcon(UIIconPool::iconSetFull(
-        QSize (32, 32), QSize (16, 16),
-        ":/vm_new_32px.png", ":/new_16px.png"));
-    mVmConfigAction = new QAction (this);
-    mVmConfigAction->setIcon(UIIconPool::iconSetFull(
-        QSize (32, 32), QSize (16, 16),
-        ":/vm_settings_32px.png", ":/settings_16px.png",
-        ":/vm_settings_disabled_32px.png", ":/settings_dis_16px.png"));
-    mVmDeleteAction = new QAction (this);
-    mVmDeleteAction->setIcon(UIIconPool::iconSetFull(
-        QSize (32, 32), QSize (16, 16),
-        ":/vm_delete_32px.png", ":/delete_16px.png",
-        ":/vm_delete_disabled_32px.png", ":/delete_dis_16px.png"));
-    mVmStartAction = new QAction (this);
-    mVmStartAction->setIcon(UIIconPool::iconSetFull(
-        QSize (32, 32), QSize (16, 16),
-        ":/vm_start_32px.png", ":/start_16px.png",
-        ":/vm_start_disabled_32px.png", ":/start_dis_16px.png"));
-    mVmDiscardAction = new QAction (this);
-    mVmDiscardAction->setIcon(UIIconPool::iconSetFull(
-        QSize (32, 32), QSize (16, 16),
-        ":/vm_discard_32px.png", ":/discard_16px.png",
-        ":/vm_discard_disabled_32px.png", ":/discard_dis_16px.png"));
-    mVmPauseAction = new QAction (this);
-    mVmPauseAction->setCheckable (true);
-    mVmPauseAction->setIcon(UIIconPool::iconSetFull(
-        QSize (32, 32), QSize (16, 16),
-        ":/vm_pause_32px.png", ":/pause_16px.png",
-        ":/vm_pause_disabled_32px.png", ":/pause_disabled_16px.png"));
-    mVmRefreshAction = new QAction (this);
-    mVmRefreshAction->setIcon(UIIconPool::iconSetFull(
-        QSize (32, 32), QSize (16, 16),
-        ":/refresh_32px.png", ":/refresh_16px.png",
-        ":/refresh_disabled_32px.png", ":/refresh_disabled_16px.png"));
-    mVmShowLogsAction = new QAction (this);
-    mVmShowLogsAction->setIcon(UIIconPool::iconSetFull(
-        QSize (32, 32), QSize (16, 16),
-        ":/vm_show_logs_32px.png", ":/show_logs_16px.png",
-        ":/vm_show_logs_disabled_32px.png", ":/show_logs_disabled_16px.png"));
-
-    mHelpActions.setup (this);
-
-    QISplitter *pSplitter = new QISplitter(this);
-    pSplitter->setHandleType(QISplitter::Native);
-    /* Central widget @ horizontal layout */
-    setCentralWidget(pSplitter);
-
-    /* VM list toolbar */
-    mVMToolBar = new VBoxToolBar(this);
-    mVMToolBar->setContextMenuPolicy(Qt::CustomContextMenu);
-#ifndef Q_WS_MAC
-    connect(mVMToolBar, SIGNAL(customContextMenuRequested(const QPoint&)),
-            this, SLOT(showViewContextMenu(const QPoint&)));
-#else /* !Q_WS_MAC */
-    /* A simple connect doesn't work on the Mac, also we want receive right
-     * click notifications on the title bar. So register our own handler. */
-    ::darwinRegisterForUnifiedToolbarContextMenuEvents(this);
-#endif /* Q_WS_MAC */
-
-    /* VM list view */
-    mVMListView = new UIVMListView();
-    mVMModel = new UIVMItemModel(mVMListView);
-    mVMListView->setModel(mVMModel);
-    mVMListView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
-
-    /* Make non-possible to activate list elements by single click,
-     * this hack should disable the current possibility to do it if present */
-    if (mVMListView->style()->styleHint (QStyle::SH_ItemView_ActivateItemOnSingleClick, 0, mVMListView))
-        mVMListView->setStyleSheet ("activate-on-singleclick : 0");
-
-#if MAC_LEOPARD_STYLE
-    /* Enable unified toolbars on Mac OS X. Available on Qt >= 4.3 */
-    addToolBar (mVMToolBar);
-    mVMToolBar->setMacToolbar();
-    pSplitter->addWidget (mVMListView);
-#else /* MAC_LEOPARD_STYLE */
-    QWidget *pLeftWidget = new QWidget(this);
-    QVBoxLayout *pLeftVLayout = new QVBoxLayout(pLeftWidget);
-    pLeftVLayout->setContentsMargins(5, 5, 0, 0);
-    pLeftVLayout->addWidget(mVMToolBar);
-    pLeftVLayout->addWidget(mVMListView);
-    pSplitter->addWidget(pLeftWidget);
-#endif /* MAC_LEOPARD_STYLE */
-
-     /* VM tab widget containing details and snapshots tabs */
-    mVmTabWidget = new QITabWidget();
-    pSplitter->addWidget (mVmTabWidget);
-
-    /* Set the initial distribution. The right site is bigger. */
-    pSplitter->setStretchFactor(0, 2);
-    pSplitter->setStretchFactor(1, 3);
-
-
-    /* VM details view */
-    mVmDetailsView = new VBoxVMDetailsView (NULL, mVmRefreshAction);
-    mVmTabWidget->addTab(mVmDetailsView,
-                         UIIconPool::iconSet(":/settings_16px.png"),
-                         QString::null);
-
-    /* VM snapshots list */
-    mVmSnapshotsWgt = new VBoxSnapshotsWgt (NULL);
-    mVmTabWidget->addTab(mVmSnapshotsWgt,
-                         UIIconPool::iconSet(":/take_snapshot_16px.png",
-                                             ":/take_snapshot_dis_16px.png"),
-                         QString::null);
-    mVmSnapshotsWgt->setContentsMargins (10, 10, 10, 10);
-
-    /* VM comments page */
-    mVmDescriptionPage = new VBoxVMDescriptionPage (this);
-    mVmTabWidget->addTab(mVmDescriptionPage,
-                         UIIconPool::iconSet(":/description_16px.png",
-                                             ":/description_disabled_16px.png"),
-                         QString::null);
-    mVmDescriptionPage->setContentsMargins (10, 10, 10, 10);
-
-    /* add actions to the toolbar */
-
-    mVMToolBar->setIconSize (QSize (32, 32));
-    mVMToolBar->setToolButtonStyle (Qt::ToolButtonTextUnderIcon);
-    mVMToolBar->setSizePolicy (QSizePolicy::Fixed, QSizePolicy::Preferred);
-
-    mVMToolBar->addAction (mVmNewAction);
-    mVMToolBar->addAction (mVmConfigAction);
-#if 0 /* delete action is really rare */
-    mVMToolBar->addAction (mVmDeleteAction);
-#endif
-    mVMToolBar->addAction (mVmStartAction);
-    mVMToolBar->addAction (mVmDiscardAction);
-
-    /* Configure menubar */
-    menuBar()->setContextMenuPolicy(Qt::CustomContextMenu);
-    connect(menuBar(), SIGNAL(customContextMenuRequested(const QPoint&)),
-            this, SLOT(showViewContextMenu(const QPoint&)));
-
-    /* add actions to menubar */
-    mFileMenu = menuBar()->addMenu (QString::null);
-    mFileMenu->addAction (mFileMediaMgrAction);
-    mFileMenu->addAction (mFileApplianceImportAction);
-    mFileMenu->addAction (mFileApplianceExportAction);
-#ifndef Q_WS_MAC
-    mFileMenu->addSeparator();
-#endif /* Q_WS_MAC */
-    mFileMenu->addAction (mFileSettingsAction);
-#ifndef Q_WS_MAC
-    mFileMenu->addSeparator();
-#endif /* Q_WS_MAC */
-    mFileMenu->addAction (mFileExitAction);
-
-    mVMMenu = menuBar()->addMenu (QString::null);
-    mVMMenu->addAction (mVmNewAction);
-    mVMMenu->addAction (mVmConfigAction);
-    mVMMenu->addAction (mVmDeleteAction);
-    mVMMenu->addSeparator();
-    mVMMenu->addAction (mVmStartAction);
-    mVMMenu->addAction (mVmDiscardAction);
-    mVMMenu->addAction (mVmPauseAction);
-    mVMMenu->addSeparator();
-    mVMMenu->addAction (mVmRefreshAction);
-    mVMMenu->addAction (mVmShowLogsAction);
-
-    mVMCtxtMenu = new QMenu (this);
-    mVMCtxtMenu->addAction (mVmConfigAction);
-    mVMCtxtMenu->addAction (mVmDeleteAction);
-    mVMCtxtMenu->addSeparator();
-    mVMCtxtMenu->addAction (mVmStartAction);
-    mVMCtxtMenu->addAction (mVmDiscardAction);
-    mVMCtxtMenu->addAction (mVmPauseAction);
-    mVMCtxtMenu->addSeparator();
-    mVMCtxtMenu->addAction (mVmRefreshAction);
-    mVMCtxtMenu->addAction (mVmShowLogsAction);
-
-    /* Make sure every status bar hint from the context menu is cleared when
-     * the menu is closed. */
-    connect (mVMCtxtMenu, SIGNAL(aboutToHide()),
-             statusBar(), SLOT(clearMessage()));
-
-    mHelpMenu = menuBar()->addMenu (QString::null);
-    mHelpActions.addTo (mHelpMenu);
-
-#ifdef VBOX_GUI_WITH_SYSTRAY
-    mTrayIcon = new VBoxTrayIcon (this, mVMModel);
-    Assert (mTrayIcon);
-    connect (mTrayIcon, SIGNAL (activated (QSystemTrayIcon::ActivationReason)),
-             this, SLOT (trayIconActivated (QSystemTrayIcon::ActivationReason)));
-#endif
-
-    retranslateUi();
-
-    CVirtualBox vbox = vboxGlobal().virtualBox();
-    /* Restore the position of the window */
-    {
-        QString winPos = vbox.GetExtraData (VBoxDefs::GUI_LastWindowPosition);
-
-        bool ok = false, max = false;
-        int x = 0, y = 0, w = 0, h = 0;
-        x = winPos.section (',', 0, 0).toInt (&ok);
-        if (ok)
-            y = winPos.section (',', 1, 1).toInt (&ok);
-        if (ok)
-            w = winPos.section (',', 2, 2).toInt (&ok);
-        if (ok)
-            h = winPos.section (',', 3, 3).toInt (&ok);
-        if (ok)
-            max = winPos.section (',', 4, 4) == VBoxDefs::GUI_LastWindowState_Max;
-
-        QRect ar = ok ? QApplication::desktop()->availableGeometry (QPoint (x, y)) :
-                        QApplication::desktop()->availableGeometry (this);
-
-        if (ok /* previous parameters were read correctly */
-            && (y > 0) && (y < ar.bottom()) /* check vertical bounds */
-            && (x + w > ar.left()) && (x < ar.right()) /* & horizontal bounds */)
-        {
-            mNormalGeo.moveTo (x, y);
-            mNormalGeo.setSize (QSize (w, h).expandedTo (minimumSizeHint())
-                                            .boundedTo (ar.size()));
-            setGeometry (mNormalGeo);
-            if (max) /* maximize if needed */
-                showMaximized();
-        }
-        else
-        {
-            mNormalGeo.setSize (QSize (770, 550).expandedTo (minimumSizeHint())
-                                                .boundedTo (ar.size()));
-            mNormalGeo.moveCenter (ar.center());
-            setGeometry (mNormalGeo);
-        }
-    }
-
-    /* Update the list */
-    refreshVMList();
-
-    /* Reset to the first item */
-    mVMListView->selectItemByRow (0);
-
-    /* restore the position of vm selector */
-    {
-        QString prevVMId = vbox.GetExtraData (VBoxDefs::GUI_LastVMSelected);
-
-        mVMListView->selectItemById (prevVMId);
-    }
-
-    /* Read the splitter handle position */
-    {
-        QString sliderPos = vbox.GetExtraData(VBoxDefs::GUI_SplitterSizes);
-        QStringList strSizes = sliderPos.split(",");
-        if (strSizes.size() == 2)
-        {
-            QList<int> sizes;
-            for (int i=0; i <  strSizes.size(); ++i)
-                sizes << strSizes.at(i).toInt();
-            pSplitter->setSizes(sizes);
-        }
-    }
-
-    /* Restore toolbar and statusbar visibility */
-    {
-        QString strToolbar = vbox.GetExtraData(VBoxDefs::GUI_Toolbar);
-        QString strStatusbar = vbox.GetExtraData(VBoxDefs::GUI_Statusbar);
-
-        mVMToolBar->setVisible(strToolbar.isEmpty() || strToolbar == "true");
-        statusBar()->setVisible(strStatusbar.isEmpty() || strStatusbar == "true");
-    }
-
-    /* refresh the details et all (necessary for the case when the stored
-     * selection is still the first list item) */
-    vmListViewCurrentChanged();
-
-    /* signals and slots connections */
-    connect (mFileMediaMgrAction, SIGNAL (triggered()), this, SLOT (fileMediaMgr()));
-    connect (mFileApplianceImportAction, SIGNAL (triggered()), this, SLOT (fileImportAppliance()));
-    connect (mFileApplianceExportAction, SIGNAL (triggered()), this, SLOT (fileExportAppliance()));
-    connect (mFileSettingsAction, SIGNAL (triggered()), this, SLOT (fileSettings()));
-    connect (mFileExitAction, SIGNAL (triggered()), this, SLOT (fileExit()));
-    connect (mVmNewAction, SIGNAL (triggered()), this, SLOT (vmNew()));
-
-    connect (mVmConfigAction, SIGNAL (triggered()), this, SLOT (vmSettings()));
-    connect (mVmDeleteAction, SIGNAL (triggered()), this, SLOT (vmDelete()));
-    connect (mVmStartAction, SIGNAL (triggered()), this, SLOT (vmStart()));
-    connect (mVmDiscardAction, SIGNAL (triggered()), this, SLOT (vmDiscard()));
-    connect (mVmPauseAction, SIGNAL (toggled (bool)), this, SLOT (vmPause (bool)));
-    connect (mVmRefreshAction, SIGNAL (triggered()), this, SLOT (vmRefresh()));
-    connect (mVmShowLogsAction, SIGNAL (triggered()), this, SLOT (vmShowLogs()));
-
-    connect (mVMListView, SIGNAL (currentChanged()),
-             this, SLOT (vmListViewCurrentChanged()));
-    connect (mVMListView, SIGNAL (activated()),
-             this, SLOT (vmStart()));
-    connect (mVMListView, SIGNAL (customContextMenuRequested (const QPoint &)),
-             this, SLOT (showContextMenu (const QPoint &)));
-
-    connect (mVmDetailsView, SIGNAL (linkClicked (const QString &)),
-             this, SLOT(vmSettings(const QString &)));
-
-    /* listen to media enumeration signals */
-    connect (&vboxGlobal(), SIGNAL (mediumEnumStarted()),
-             this, SLOT (mediumEnumStarted()));
-    connect (&vboxGlobal(), SIGNAL (mediumEnumFinished (const VBoxMediaList &)),
-             this, SLOT (mediumEnumFinished (const VBoxMediaList &)));
-
-    /* connect VirtualBox events */
-    connect (gVBoxEvents, SIGNAL(sigMachineStateChange(QString, KMachineState)),
-             this, SLOT(machineStateChanged(QString, KMachineState)));
-    connect (gVBoxEvents, SIGNAL(sigMachineDataChange(QString)),
-             this, SLOT(machineDataChanged(QString)));
-    connect (gVBoxEvents, SIGNAL(sigMachineRegistered(QString, bool)),
-             this, SLOT(machineRegistered(QString, bool)));
-    connect (gVBoxEvents, SIGNAL(sigSessionStateChange(QString, KSessionState)),
-             this, SLOT(sessionStateChanged(QString, KSessionState)));
-    connect (gVBoxEvents, SIGNAL(sigSnapshotChange(QString, QString)),
-             this, SLOT(snapshotChanged(QString, QString)));
-#ifdef VBOX_GUI_WITH_SYSTRAY
-    connect (gEDataEvents, SIGNAL(sigMainWindowCountChange(int)),
-             this, SLOT(mainWindowCountChanged(int)));
-    connect (gEDataEvents, SIGNAL(sigCanShowTrayIcon(bool)),
-             this, SLOT(trayIconCanShow(bool)));
-    connect (gEDataEvents, SIGNAL(sigTrayIconChange(bool)),
-             this, SLOT(trayIconChanged(bool)));
-    connect (&vboxGlobal(), SIGNAL(sigTrayIconShow(bool)),
-             this, SLOT(trayIconShow(bool)));
-#endif
-
-    /* Listen to potential downloaders signals: */
-    connect(&vboxProblem(), SIGNAL(sigDownloaderUserManualCreated()), this, SLOT(sltDownloaderUserManualEmbed()));
-
-    /* bring the VM list to the focus */
-    mVMListView->setFocus();
-}
-
-VBoxSelectorWnd::~VBoxSelectorWnd()
-{
-    /* Destroy our event handlers */
-    UIVirtualBoxEventHandler::destroy();
-
-    CVirtualBox vbox = vboxGlobal().virtualBox();
-
-    /* Save the position of the window */
-    {
-        int y = mNormalGeo.y();
-        QString winPos = QString ("%1,%2,%3,%4")
-            .arg (mNormalGeo.x()).arg (y)
-            .arg (mNormalGeo.width()).arg (mNormalGeo.height());
-#ifdef Q_WS_MAC
-        ::darwinUnregisterForUnifiedToolbarContextMenuEvents(this);
-        if (::darwinIsWindowMaximized(this))
-#else /* Q_WS_MAC */
-        if (isMaximized())
-#endif /* !Q_WS_MAC */
-            winPos += QString (",%1").arg (VBoxDefs::GUI_LastWindowState_Max);
-
-        vbox.SetExtraData (VBoxDefs::GUI_LastWindowPosition, winPos);
-    }
-
-    /* Save VM selector position */
-    {
-        UIVMItem *item = mVMListView->selectedItem();
-        QString curVMId = item ?
-            QString (item->id()) :
-            QString::null;
-        vbox.SetExtraData (VBoxDefs::GUI_LastVMSelected, curVMId);
-    }
-
-    /* Save the splitter handle position */
-    {
-        QSplitter *pSplitter = static_cast<QSplitter*>(centralWidget());
-        QList<int> sizes = pSplitter->sizes();
-        QStringList strSizes;
-        for (int i=0; i < sizes.size(); ++i)
-            strSizes << QString::number(sizes.at(i));
-        vbox.SetExtraData(VBoxDefs::GUI_SplitterSizes, strSizes.join(","));
-    }
-
-#ifdef VBOX_GUI_WITH_SYSTRAY
-    /* Delete systray menu object */
-    delete mTrayIcon;
-    mTrayIcon = NULL;
-#endif
-
-    /* Delete the items from our model */
-    mVMModel->clear();
-}
-
-//
-// Public slots
-/////////////////////////////////////////////////////////////////////////////
-
-void VBoxSelectorWnd::fileMediaMgr()
-{
-    VBoxMediaManagerDlg::showModeless (this);
-}
-
-void VBoxSelectorWnd::fileImportAppliance()
-{
-    UIImportApplianceWzd wzd (this);
-
-    wzd.exec();
-}
-
-void VBoxSelectorWnd::fileExportAppliance()
-{
-    QString name;
-
-    UIVMItem *item = mVMListView->selectedItem();
-    if (item)
-        name = item->name();
-
-    UIExportApplianceWzd wzd (this, name);
-
-    wzd.exec();
-}
-
-void VBoxSelectorWnd::fileSettings()
-{
-    VBoxGlobalSettings settings = vboxGlobal().settings();
-    CSystemProperties props = vboxGlobal().virtualBox().GetSystemProperties();
-
-    VBoxSettingsDialog *dlg = new VBoxGLSettingsDlg (this);
-    dlg->getFrom();
-
-    if (dlg->exec() == QDialog::Accepted)
-        dlg->putBackTo();
-
-    delete dlg;
-}
-
-void VBoxSelectorWnd::fileExit()
-{
-    /* We have to check if there are any open windows beside this mainwindow
-     * (e.g. VDM) and if so close them. Note that the default behavior is
-     * different to Qt3 where a *mainWidget* exists & if this going to close
-     * all other windows are closed automatically. We do the same below. */
-    foreach (QWidget *widget, QApplication::topLevelWidgets())
-    {
-        if (widget->isVisible() &&
-            widget != this)
-            widget->close();
-    }
-    /* We close this widget last. */
-    close();
-}
-
-void VBoxSelectorWnd::vmNew()
-{
-    UINewVMWzd wzd (this);
-    if (wzd.exec() == QDialog::Accepted)
-    {
-        CMachine m = wzd.machine();
-
-        /* wait until the list is updated by OnMachineRegistered() */
-        QModelIndex index;
-        while (!index.isValid())
-        {
-            qApp->processEvents();
-            index = mVMModel->indexById (m.GetId());
-        }
-        mVMListView->setCurrentIndex (index);
-    }
-}
-
-/**
- *  Opens the VM settings dialog.
- */
-void VBoxSelectorWnd::vmSettings (const QString &aCategory, const QString &aControl,
-                                  const QString &aUuid /* = QString::null */)
-{
-    if (!aCategory.isEmpty() && aCategory [0] != '#')
-    {
-        /* Assume it's a href from the Details HTML */
-        vboxGlobal().openURL (aCategory);
-        return;
-    }
-
-    UIVMItem *item = aUuid.isNull() ? mVMListView->selectedItem() :
-                       mVMModel->itemById (aUuid);
-
-    AssertMsgReturnVoid (item, ("Item must be always selected here"));
-
-    // open a direct session to modify VM settings
-    QString id = item->id();
-    CSession session = vboxGlobal().openSession (id);
-    if (session.isNull())
-        return;
-
-    CMachine m = session.GetMachine();
-    AssertMsgReturn (!m.isNull(), ("Machine must not be null"), (void) 0);
-
-    VBoxSettingsDialog *dlg = new VBoxVMSettingsDlg (this, m, aCategory, aControl);
-    dlg->getFrom();
-
-    if (dlg->exec() == QDialog::Accepted)
-    {
-        QString oldName = m.GetName();
-        dlg->putBackTo();
-
-        m.SaveSettings();
-        if (m.isOk())
-        {
-            if (oldName.compare (m.GetName()))
-                mVMModel->sort();
-        }
-        else
-            vboxProblem().cannotSaveMachineSettings (m);
-
-        /* To check use the result in future
-         * vboxProblem().cannotApplyMachineSettings (m, res); */
-    }
-
-    delete dlg;
-
-    mVMListView->setFocus();
-
-    session.Close();
-}
-
-void VBoxSelectorWnd::vmDelete (const QString &aUuid /* = QString::null */)
-{
-    UIVMItem *item = aUuid.isNull() ? mVMListView->selectedItem() :
-                       mVMModel->itemById (aUuid);
-
-    AssertMsgReturnVoid (item, ("Item must be always selected here"));
-
-    if (vboxProblem().confirmMachineDeletion (item->machine()))
-    {
-        CVirtualBox vbox = vboxGlobal().virtualBox();
-        QString id = item->id();
-        bool ok = false;
-        if (item->accessible())
-        {
-            /* Open a direct session to modify VM settings */
-            CSession session = vboxGlobal().openSession (id);
-            if (session.isNull())
-                return;
-            CMachine machine = session.GetMachine();
-            /* Detach all attached Hard Disks */
-            CMediumAttachmentVector vec = machine.GetMediumAttachments();
-            for (int i = 0; i < vec.size(); ++ i)
-            {
-                CMediumAttachment hda = vec [i];
-                const QString ctlName = hda.GetController();
-
-                machine.DetachDevice(ctlName, hda.GetPort(), hda.GetDevice());
-                if (!machine.isOk())
-                {
-                    CStorageController ctl = machine.GetStorageControllerByName(ctlName);
-                    vboxProblem().cannotDetachDevice (this, machine, VBoxDefs::MediumType_HardDisk,
-                        vboxGlobal().getMedium (CMedium (hda.GetMedium())).location(),
-                        ctl.GetBus(), hda.GetPort(), hda.GetDevice());
-                }
-            }
-            /* Commit changes */
-            machine.SaveSettings();
-            if (!machine.isOk())
-                vboxProblem().cannotSaveMachineSettings (machine);
-            else
-                ok = true;
-            session.Close();
-        }
-        else
-            ok = true;
-
-        if (ok)
-        {
-            CMachine machine = item->machine();
-            vbox.UnregisterMachine (id);
-            if (vbox.isOk() && item->accessible())
-            {
-                /* delete machine settings */
-                machine.DeleteSettings();
-                /* remove the item shortly: cmachine it refers to is no longer valid! */
-                int row = mVMModel->rowById (item->id());
-                mVMModel->removeItem (item);
-                delete item;
-                mVMListView->ensureSomeRowSelected (row);
-            }
-            if (!vbox.isOk() || !machine.isOk())
-                vboxProblem().cannotDeleteMachine (vbox, machine);
-        }
-    }
-}
-
-void VBoxSelectorWnd::vmStart (const QString &aUuid /* = QString::null */)
-{
-    QUuid uuid (aUuid);
-    UIVMItem *item = uuid.isNull() ? mVMListView->selectedItem() :
-                       mVMModel->itemById (aUuid);
-
-    AssertMsgReturnVoid (item, ("Item must be always selected here"));
-
-    /* Are we called from the mVMListView's activated() signal? */
-    if (uuid.isNull())
-    {
-        /* We always get here when mVMListView emits the activated() signal,
-         * so we must explicitly check if the action is enabled or not. */
-        if (!mVmStartAction->isEnabled())
-            return;
-    }
-
-    AssertMsg (!vboxGlobal().isVMConsoleProcess(),
-               ("Must NOT be a VM console process"));
-
-    /* just switch to the VM window if it already exists */
-    if (item->canSwitchTo())
-    {
-        item->switchTo();
-        return;
-    }
-
-    AssertMsg (   item->state() == KMachineState_PoweredOff
-               || item->state() == KMachineState_Saved
-               || item->state() == KMachineState_Teleported
-               || item->state() == KMachineState_Aborted
-               , ("Machine must be PoweredOff/Saved/Aborted (%d)", item->state()));
-
-    QString id = item->id();
-    CVirtualBox vbox = vboxGlobal().virtualBox();
-    CSession session;
-
-    session.createInstance (CLSID_Session);
-    if (session.isNull())
-    {
-        vboxProblem().cannotOpenSession (session);
-        return;
-    }
-
-#if defined (Q_OS_WIN32)
-    /* allow the started VM process to make itself the foreground window */
-    AllowSetForegroundWindow (ASFW_ANY);
-#endif
-
-    QString env;
-#if defined (Q_WS_X11)
-    /* make sure the VM process will start on the same display as the Selector */
-    const char *display = RTEnvGet ("DISPLAY");
-    if (display)
-        env.append(QString("DISPLAY=%1\n").arg(display));
-    const char *xauth = RTEnvGet ("XAUTHORITY");
-    if (xauth)
-        env.append(QString("XAUTHORITY=%1\n").arg(xauth));
-#endif
-
-    CProgress progress = vbox.OpenRemoteSession (session, id, "GUI/Qt", env);
-    if (!vbox.isOk())
-    {
-        vboxProblem().cannotOpenSession (vbox, item->machine());
-        return;
-    }
-
-    /* Hide the "VM spawning" progress dialog */
-    /* I hope 1 minute will be enough to spawn any running VM silently, isn't it? */
-    int iSpawningDuration = 60000;
-    vboxProblem().showModalProgressDialog(progress, item->name(), this, iSpawningDuration);
-    if (progress.GetResultCode() != 0)
-        vboxProblem().cannotOpenSession(vbox, item->machine(), progress);
-
-    session.Close();
-}
-
-void VBoxSelectorWnd::vmDiscard (const QString &aUuid /* = QString::null */)
-{
-    UIVMItem *item = aUuid.isNull() ? mVMListView->selectedItem() :
-                       mVMModel->itemById (aUuid);
-
-    AssertMsgReturnVoid (item, ("Item must be always selected here"));
-
-    if (!vboxProblem().confirmDiscardSavedState (item->machine()))
-        return;
-
-    /* open a session to modify VM settings */
-    QString id = item->id();
-    CSession session;
-    CVirtualBox vbox = vboxGlobal().virtualBox();
-    session.createInstance (CLSID_Session);
-    if (session.isNull())
-    {
-        vboxProblem().cannotOpenSession (session);
-        return;
-    }
-    vbox.OpenSession (session, id);
-    if (!vbox.isOk())
-    {
-        vboxProblem().cannotOpenSession (vbox, item->machine());
-        return;
-    }
-
-    CConsole console = session.GetConsole();
-    console.ForgetSavedState(true);
-    if (!console.isOk())
-        vboxProblem().cannotDiscardSavedState (console);
-
-    session.Close();
-}
-
-void VBoxSelectorWnd::vmPause (bool aPause, const QString &aUuid /* = QString::null */)
-{
-    UIVMItem *item = aUuid.isNull() ? mVMListView->selectedItem() :
-                       mVMModel->itemById (aUuid);
-
-    AssertMsgReturnVoid (item, ("Item must be always selected here"));
-
-    CSession session = vboxGlobal().openExistingSession (item->id());
-    if (session.isNull())
-        return;
-
-    CConsole console = session.GetConsole();
-    if (console.isNull())
-        return;
-
-    if (aPause)
-        console.Pause();
-    else
-        console.Resume();
-
-    bool ok = console.isOk();
-    if (!ok)
-    {
-        if (aPause)
-            vboxProblem().cannotPauseMachine (console);
-        else
-            vboxProblem().cannotResumeMachine (console);
-    }
-
-    session.Close();
-}
-
-void VBoxSelectorWnd::vmRefresh (const QString &aUuid /* = QString::null */)
-{
-    UIVMItem *item = aUuid.isNull() ? mVMListView->selectedItem() :
-                       mVMModel->itemById (aUuid);
-
-    AssertMsgReturnVoid (item, ("Item must be always selected here"));
-
-    refreshVMItem (item->id(),
-                   true /* aDetails */,
-                   true /* aSnapshot */,
-                   true /* aDescription */);
-}
-
-void VBoxSelectorWnd::vmShowLogs (const QString &aUuid /* = QString::null */)
-{
-    UIVMItem *item = aUuid.isNull() ? mVMListView->selectedItem() :
-                       mVMModel->itemById (aUuid);
-
-    AssertMsgReturnVoid (item, ("Item must be always selected here"));
-
-    CMachine machine = item->machine();
-    VBoxVMLogViewer::createLogViewer (this, machine);
-}
-
-void VBoxSelectorWnd::refreshVMList()
-{
-    CVirtualBox vbox = vboxGlobal().virtualBox();
-    CMachineVector vec = vbox.GetMachines();
-    for (CMachineVector::ConstIterator m = vec.begin();
-         m != vec.end(); ++ m)
-        mVMModel->addItem (new UIVMItem (*m));
-    mVMModel->sort();
-
-    vmListViewCurrentChanged();
-
-#ifdef VBOX_GUI_WITH_SYSTRAY
-    if (vboxGlobal().isTrayMenu())
-        mTrayIcon->refresh();
-#endif
-}
-
-void VBoxSelectorWnd::refreshVMItem (const QString &aID, bool aDetails,
-                                                       bool aSnapshots,
-                                                       bool aDescription)
-{
-    UIVMItem *item = mVMModel->itemById (aID);
-    if (item)
-    {
-        mVMModel->refreshItem (item);
-        if (item && item->id() == aID)
-            vmListViewCurrentChanged (aDetails, aSnapshots, aDescription);
-    }
-}
-
-void VBoxSelectorWnd::showContextMenu (const QPoint &aPoint)
-{
-    /* Send a context menu request */
-    const QModelIndex &index = mVMListView->indexAt (aPoint);
-    if (index.isValid())
-        if (mVMListView->model()->data (index,
-            UIVMItemModel::UIVMItemPtrRole).value <UIVMItem*>())
-                mVMCtxtMenu->exec (mVMListView->mapToGlobal (aPoint));
-}
-
-#ifdef VBOX_GUI_WITH_SYSTRAY
-
-void VBoxSelectorWnd::trayIconActivated (QSystemTrayIcon::ActivationReason aReason)
-{
-    switch (aReason)
-    {
-        case QSystemTrayIcon::Context:
-
-            mTrayIcon->refresh();
-            break;
-
-        case QSystemTrayIcon::Trigger:
-            break;
-
-        case QSystemTrayIcon::DoubleClick:
-
-            vboxGlobal().trayIconShowSelector();
-            break;
-
-        case QSystemTrayIcon::MiddleClick:
-            break;
-
-        default:
-            break;
-    }
-}
-
-void VBoxSelectorWnd::showWindow()
-{
-    showNormal();
-    raise();
-    activateWindow();
-}
-
-#endif // VBOX_GUI_WITH_SYSTRAY
-
-// Protected members
-/////////////////////////////////////////////////////////////////////////////
-
-bool VBoxSelectorWnd::event (QEvent *e)
-{
-    switch (e->type())
-    {
-        /* By handling every Resize and Move we keep track of the normal
-         * (non-minimized and non-maximized) window geometry. Shame on Qt
-         * that it doesn't provide this geometry in its public APIs. */
-
-        case QEvent::Resize:
-        {
-            QResizeEvent *re = (QResizeEvent *) e;
-            if ((windowState() & (Qt::WindowMaximized | Qt::WindowMinimized |
-                                  Qt::WindowFullScreen)) == 0)
-                mNormalGeo.setSize (re->size());
-            break;
-        }
-        case QEvent::Move:
-        {
-            if ((windowState() & (Qt::WindowMaximized | Qt::WindowMinimized |
-                                  Qt::WindowFullScreen)) == 0)
-                mNormalGeo.moveTo (geometry().x(), geometry().y());
-            break;
-        }
-        case QEvent::WindowDeactivate:
-        {
-            /* Make sure every status bar hint is cleared when the window lost
-             * focus. */
-            statusBar()->clearMessage();
-            break;
-        }
-#ifdef Q_WS_MAC
-        case QEvent::ContextMenu:
-        {
-            /* This is the unified context menu event. Lets show the context
-             * menu. */
-            QContextMenuEvent *pCE = static_cast<QContextMenuEvent*>(e);
-            showViewContextMenu(pCE->globalPos());
-            /* Accept it to interrupt the chain. */
-            pCE->accept();
-            return false;
-            break;
-        }
-        case QEvent::ToolBarChange:
-        {
-            CVirtualBox vbox = vboxGlobal().virtualBox();
-            /* We have to invert the isVisible check one time, cause this event
-             * is sent *before* the real toggle is done. Really intuitive
-             * Trolls. */
-            vbox.SetExtraData(VBoxDefs::GUI_Toolbar, !::darwinIsToolbarVisible(mVMToolBar) ? "true" : "false");
-            break;
-        }
-#endif /* Q_WS_MAC */
-        default:
-            break;
-    }
-
-    return QMainWindow::event (e);
-}
-
-void VBoxSelectorWnd::closeEvent (QCloseEvent *aEvent)
-{
-#ifdef VBOX_GUI_WITH_SYSTRAY
-    /* Needed for breaking out of the while() loop in main(). */
-    if (vboxGlobal().isTrayMenu())
-        vboxGlobal().setTrayMenu (false);
-#endif
-
-    emit closing();
-    QMainWindow::closeEvent (aEvent);
-}
-
-#if defined (Q_WS_MAC) && (QT_VERSION < 0x040402)
-bool VBoxSelectorWnd::eventFilter (QObject *aObject, QEvent *aEvent)
-{
-    if (!isActiveWindow())
-        return QIWithRetranslateUI2<QMainWindow>::eventFilter (aObject, aEvent);
-
-    if (qobject_cast<QWidget*> (aObject) &&
-        qobject_cast<QWidget*> (aObject)->window() != this)
-        return QIWithRetranslateUI2<QMainWindow>::eventFilter (aObject, aEvent);
-
-    switch (aEvent->type())
-    {
-        case QEvent::KeyPress:
-            {
-                /* Bug in Qt below 4.4.2. The key events are send to the current
-                 * window even if a menu is shown & has the focus. See
-                 * http://trolltech.com/developer/task-tracker/index_html?method=entry&id=214681. */
-                if (::darwinIsMenuOpen())
-                    return true;
-            }
-        default:
-            break;
-    }
-    return QIWithRetranslateUI2<QMainWindow>::eventFilter (aObject, aEvent);
-}
-#endif /* defined (Q_WS_MAC) && (QT_VERSION < 0x040402) */
-
-/**
- *  Sets the strings of the subwidgets using the current
- *  language.
- */
-void VBoxSelectorWnd::retranslateUi()
-{
-#ifdef VBOX_OSE
-    QString title (tr ("VirtualBox OSE"));
-#else
-    QString title (VBOX_PRODUCT);
-#endif
-
-#ifdef VBOX_BLEEDING_EDGE
-    title += QString(" EXPERIMENTAL build ")
-          +  QString(RTBldCfgVersion())
-          +  QString(" r")
-          +  QString(RTBldCfgRevisionStr())
-          +  QString(" - "VBOX_BLEEDING_EDGE);
-#endif
-
-    setWindowTitle (title);
-
-    mVmTabWidget->setTabText (mVmTabWidget->indexOf (mVmDetailsView), tr ("&Details"));
-    /* note: Snapshots and Details tabs are changed dynamically by
-     * vmListViewCurrentChanged() */
-
-    /* ensure the details and screenshot view are updated */
-    vmListViewCurrentChanged();
-
-    mFileMediaMgrAction->setText (tr ("&Virtual Media Manager..."));
-    mFileMediaMgrAction->setShortcut (QKeySequence ("Ctrl+D"));
-    mFileMediaMgrAction->setStatusTip (tr ("Display the Virtual Media Manager dialog"));
-
-    mFileApplianceImportAction->setText (tr ("&Import Appliance..."));
-    mFileApplianceImportAction->setShortcut (QKeySequence ("Ctrl+I"));
-    mFileApplianceImportAction->setStatusTip (tr ("Import an appliance into VirtualBox"));
-
-    mFileApplianceExportAction->setText (tr ("&Export Appliance..."));
-    mFileApplianceExportAction->setShortcut (QKeySequence ("Ctrl+E"));
-    mFileApplianceExportAction->setStatusTip (tr ("Export one or more VirtualBox virtual machines as an appliance"));
-
-#ifdef Q_WS_MAC
-    /*
-     * Macification: Getting the right menu as application preference menu item.
-     *
-     * QMenuBar::isCommand() in qmenubar_mac.cpp doesn't recognize "Setting"(s)
-     * unless it's in the first position. So, we use the Mac term here to make
-     * sure we get picked instead of the VM settings.
-     *
-     * Now, since both QMenuBar and we translate these strings, it's going to
-     * be really interesting to see how this plays on non-english systems...
-     */
-    mFileSettingsAction->setText (tr ("&Preferences...", "global settings"));
-#else
-    /*
-     * ...and on other platforms we use "Preferences" as well. The #ifdef is
-     * left because of the possible localization problems on Mac we first need
-     * to figure out.
-     */
-    mFileSettingsAction->setText (tr ("&Preferences...", "global settings"));
-#endif
-    mFileSettingsAction->setShortcut (QKeySequence ("Ctrl+G"));
-    mFileSettingsAction->setStatusTip (tr ("Display the global settings dialog"));
-
-    mFileExitAction->setText (tr ("E&xit"));
-    mFileExitAction->setShortcut (QKeySequence ("Ctrl+Q"));
-    mFileExitAction->setStatusTip (tr ("Close application"));
-
-    mVmNewAction->setText (tr ("&New..."));
-    mVmNewAction->setShortcut (QKeySequence ("Ctrl+N"));
-    mVmNewAction->setStatusTip (tr ("Create a new virtual machine"));
-    mVmNewAction->setToolTip (mVmNewAction->text().remove ('&').remove ('.') +
-        QString (" (%1)").arg (mVmNewAction->shortcut().toString()));
-
-    mVmConfigAction->setText (tr ("&Settings..."));
-    mVmConfigAction->setShortcut (QKeySequence ("Ctrl+S"));
-    mVmConfigAction->setStatusTip (tr ("Configure the selected virtual machine"));
-    mVmConfigAction->setToolTip (mVmConfigAction->text().remove ('&').remove ('.') +
-        QString (" (%1)").arg (mVmConfigAction->shortcut().toString()));
-
-    mVmDeleteAction->setText (tr ("&Delete"));
-    mVmDeleteAction->setShortcut (QKeySequence ("Ctrl+R"));
-    mVmDeleteAction->setStatusTip (tr ("Delete the selected virtual machine"));
-
-    /* Note: mVmStartAction text is set up in vmListViewCurrentChanged() */
-
-    mVmDiscardAction->setText (tr ("D&iscard"));
-    mVmDiscardAction->setStatusTip (
-        tr ("Discard the saved state of the selected virtual machine"));
-
-    mVmPauseAction->setText (tr ("&Pause"));
-    mVmPauseAction->setStatusTip (
-        tr ("Suspend the execution of the virtual machine"));
-
-    mVmRefreshAction->setText (tr ("Re&fresh"));
-    mVmRefreshAction->setStatusTip (
-        tr ("Refresh the accessibility state of the selected virtual machine"));
-
-    mVmShowLogsAction->setText (tr ("Show &Log..."));
-    mVmShowLogsAction->setIconText (tr ("Log", "icon text"));
-    mVmShowLogsAction->setShortcut (QKeySequence ("Ctrl+L"));
-    mVmShowLogsAction->setStatusTip (
-        tr ("Show the log files of the selected virtual machine"));
-
-    mHelpActions.retranslateUi();
-
-#ifdef Q_WS_MAC
-    mFileMenu->setTitle (tr("&File", "Mac OS X version"));
-#else /* Q_WS_MAC */
-    mFileMenu->setTitle (tr("&File", "Non Mac OS X version"));
-#endif /* !Q_WS_MAC */
-    mVMMenu->setTitle (tr ("&Machine"));
-    mHelpMenu->setTitle (tr ("&Help"));
-
-#ifdef VBOX_GUI_WITH_SYSTRAY
-    if (vboxGlobal().isTrayMenu())
-    {
-        mTrayIcon->retranslateUi();
-        mTrayIcon->refresh();
-    }
-#endif
-
-#ifdef QT_MAC_USE_COCOA
-    /* There is a bug in Qt Cocoa which result in showing a "more arrow" when
-       the necessary size of the toolbar is increased. Also for some languages
-       the with doesn't match if the text increase. So manually adjust the size
-       after changing the text. */
-    mVMToolBar->updateLayout();
-#endif /* QT_MAC_USE_COCOA */
-}
-
-
-// Private members
-/////////////////////////////////////////////////////////////////////////////
-
-//
-// Private slots
-/////////////////////////////////////////////////////////////////////////////
-
-void VBoxSelectorWnd::vmListViewCurrentChanged (bool aRefreshDetails,
-                                                bool aRefreshSnapshots,
-                                                bool aRefreshDescription)
-{
-    UIVMItem *item = mVMListView->selectedItem();
-
-    if (item && item->accessible())
-    {
-        CMachine m = item->machine();
-
-        KMachineState state = item->state();
-        bool running = item->sessionState() != KSessionState_Closed;
-        bool modifyEnabled = !running && state != KMachineState_Saved;
-
-        if (aRefreshDetails)
-        {
-            mVmDetailsView->setDetailsText (
-                vboxGlobal().detailsReport (m, modifyEnabled /* withLinks */));
-        }
-        if (aRefreshSnapshots)
-        {
-            /* update the snapshots tab name */
-            QString name = tr ("&Snapshots");
-            ULONG count = item->snapshotCount();
-            if (count)
-                name += QString (" (%1)").arg (count);
-            mVmTabWidget->setTabText (mVmTabWidget->indexOf (mVmSnapshotsWgt), name);
-            /* refresh the snapshots widget */
-            mVmSnapshotsWgt->setMachine (m);
-            /* ensure the tab is enabled */
-            mVmTabWidget->setTabEnabled (mVmTabWidget->indexOf (mVmSnapshotsWgt), true);
-        }
-        if (aRefreshDescription)
-        {
-            /* update the description tab name */
-            QString name = m.GetDescription().isEmpty() ?
-                tr ("D&escription") : tr ("D&escription *");
-            mVmTabWidget->setTabText (mVmTabWidget->indexOf (mVmDescriptionPage), name);
-            /* refresh the description widget */
-            mVmDescriptionPage->setMachineItem (item);
-            /* ensure the tab is enabled */
-            mVmTabWidget->setTabEnabled (mVmTabWidget->indexOf (mVmDescriptionPage), true);
-        }
-
-        /* enable/disable modify actions */
-        mVmConfigAction->setEnabled (modifyEnabled);
-        mVmDeleteAction->setEnabled (modifyEnabled);
-        mVmDiscardAction->setEnabled (state == KMachineState_Saved && !running);
-        mVmPauseAction->setEnabled (   state == KMachineState_Running
-                                    || state == KMachineState_Teleporting
-                                    || state == KMachineState_LiveSnapshotting
-                                    || state == KMachineState_Paused
-                                    || state == KMachineState_TeleportingPausedVM /** @todo Live Migration: does this make sense? */
-                                   );
-
-        /* change the Start button text accordingly */
-        if (   state == KMachineState_PoweredOff
-            || state == KMachineState_Saved
-            || state == KMachineState_Teleported
-            || state == KMachineState_Aborted
-           )
-        {
-            mVmStartAction->setText (tr ("S&tart"));
-#ifdef QT_MAC_USE_COCOA
-            /* There is a bug in Qt Cocoa which result in showing a "more arrow" when
-               the necessary size of the toolbar is increased. Also for some languages
-               the with doesn't match if the text increase. So manually adjust the size
-               after changing the text. */
-            mVMToolBar->updateLayout();
-#endif /* QT_MAC_USE_COCOA */
-            mVmStartAction->setStatusTip (
-                tr ("Start the selected virtual machine"));
-
-            mVmStartAction->setEnabled (!running);
-        }
-        else
-        {
-            mVmStartAction->setText (tr ("S&how"));
-#ifdef QT_MAC_USE_COCOA
-            /* There is a bug in Qt Cocoa which result in showing a "more arrow" when
-               the necessary size of the toolbar is increased. Also for some languages
-               the with doesn't match if the text increase. So manually adjust the size
-               after changing the text. */
-            mVMToolBar->updateLayout();
-#endif /* QT_MAC_USE_COCOA */
-            mVmStartAction->setStatusTip (
-                tr ("Switch to the window of the selected virtual machine"));
-
-            mVmStartAction->setEnabled (item->canSwitchTo());
-        }
-
-        /* change the Pause/Resume button text accordingly */
-        if (   state == KMachineState_Paused
-            || state == KMachineState_TeleportingPausedVM /*?*/
-           )
-        {
-            mVmPauseAction->setText (tr ("R&esume"));
-            mVmPauseAction->setShortcut (QKeySequence ("Ctrl+P"));
-            mVmPauseAction->setStatusTip (
-                tr ("Resume the execution of the virtual machine"));
-            mVmPauseAction->blockSignals (true);
-            mVmPauseAction->setChecked (true);
-            mVmPauseAction->blockSignals (false);
-        }
-        else
-        {
-            mVmPauseAction->setText (tr ("&Pause"));
-            mVmPauseAction->setShortcut (QKeySequence ("Ctrl+P"));
-            mVmPauseAction->setStatusTip (
-                tr ("Suspend the execution of the virtual machine"));
-            mVmPauseAction->blockSignals (true);
-            mVmPauseAction->setChecked (false);
-            mVmPauseAction->blockSignals (false);
-        }
-
-        /* disable Refresh for accessible machines */
-        mVmRefreshAction->setEnabled (false);
-
-        /* enable the show log item for the selected vm */
-        mVmShowLogsAction->setEnabled (true);
-    }
-    else
-    {
-        /* Note that the machine becomes inaccessible (or if the last VM gets
-         * deleted), we have to update all fields, ignoring input
-         * arguments. */
-
-        if (item)
-        {
-            /* the VM is inaccessible */
-            mVmDetailsView->setErrorText (
-                VBoxProblemReporter::formatErrorInfo (item->accessError()));
-            mVmRefreshAction->setEnabled (true);
-        }
-        else
-        {
-            /* default HTML support in Qt is terrible so just try to get
-             * something really simple */
-            mVmDetailsView->setDetailsText
-                (tr ("<h3>"
-                     "Welcome to VirtualBox!</h3>"
-                     "<p>The left part of this window is  "
-                     "a list of all virtual machines on your computer. "
-                     "The list is empty now because you haven't created any virtual "
-                     "machines yet."
-                     "<img src=:/welcome.png align=right/></p>"
-                     "<p>In order to create a new virtual machine, press the "
-                     "<b>New</b> button in the main tool bar located "
-                     "at the top of the window.</p>"
-                     "<p>You can press the <b>%1</b> key to get instant help, "
-                     "or visit "
-                     "<a href=http://www.virtualbox.org>www.virtualbox.org</a> "
-                     "for the latest information and news.</p>").arg (QKeySequence (QKeySequence::HelpContents).toString (QKeySequence::NativeText)));
-            mVmRefreshAction->setEnabled (false);
-        }
-
-        /* empty and disable other tabs */
-
-        mVmSnapshotsWgt->setMachine (CMachine());
-        mVmTabWidget->setTabText (mVmTabWidget->indexOf (mVmSnapshotsWgt), tr ("&Snapshots"));
-        mVmTabWidget->setTabEnabled (mVmTabWidget->indexOf (mVmSnapshotsWgt), false);
-
-        mVmDescriptionPage->setMachineItem (NULL);
-        mVmTabWidget->setTabText (mVmTabWidget->indexOf (mVmDescriptionPage), tr ("D&escription"));
-        mVmTabWidget->setTabEnabled (mVmTabWidget->indexOf (mVmDescriptionPage), false);
-
-        /* disable modify actions */
-        mVmConfigAction->setEnabled (false);
-        mVmDeleteAction->setEnabled (item != NULL);
-        mVmDiscardAction->setEnabled (false);
-        mVmPauseAction->setEnabled (false);
-
-        /* change the Start button text accordingly */
-        mVmStartAction->setText (tr ("S&tart"));
-        mVmStartAction->setStatusTip (
-            tr ("Start the selected virtual machine"));
-        mVmStartAction->setEnabled (false);
-
-        /* disable the show log item for the selected vm */
-        mVmShowLogsAction->setEnabled (false);
-    }
-}
-
-void VBoxSelectorWnd::mediumEnumStarted()
-{
-    /* refresh the current details to pick up hard disk sizes */
-    vmListViewCurrentChanged (true /* aRefreshDetails */);
-}
-
-void VBoxSelectorWnd::mediumEnumFinished (const VBoxMediaList &list)
-{
-    /* refresh the current details to pick up hard disk sizes */
-    vmListViewCurrentChanged (true /* aRefreshDetails */);
-
-    /* we warn about inaccessible media only once (after media emumeration
-     * started from main() at startup), to avoid annoying the user */
-    if (   mDoneInaccessibleWarningOnce
-#ifdef VBOX_GUI_WITH_SYSTRAY
-        || vboxGlobal().isTrayMenu()
-#endif
-       )
-        return;
-
-    mDoneInaccessibleWarningOnce = true;
-
-    do
-    {
-        /* ignore the signal if a modal widget is currently active (we won't be
-         * able to properly show the modeless VDI manager window in this case) */
-        if (QApplication::activeModalWidget())
-            break;
-
-        /* ignore the signal if a VBoxMediaManagerDlg window is active */
-        if (qApp->activeWindow() &&
-            !strcmp (qApp->activeWindow()->metaObject()->className(), "VBoxMediaManagerDlg"))
-            break;
-
-        /* look for at least one inaccessible media */
-        VBoxMediaList::const_iterator it;
-        for (it = list.begin(); it != list.end(); ++ it)
-            if ((*it).state() == KMediumState_Inaccessible)
-                break;
-
-        if (it != list.end() && vboxProblem().remindAboutInaccessibleMedia())
-        {
-            /* Show the VDM dialog but don't refresh once more after a
-             * just-finished refresh */
-            VBoxMediaManagerDlg::showModeless (this, false /* aRefresh */);
-        }
-    }
-    while (0);
-}
-
-void VBoxSelectorWnd::machineStateChanged(QString strId, KMachineState /* state */)
-{
-#ifdef VBOX_GUI_WITH_SYSTRAY
-    if (vboxGlobal().isTrayMenu())
-    {
-        /* Check if there are some machines alive - else quit, since
-         * we're not needed as a systray menu anymore. */
-        if (vboxGlobal().mainWindowCount() == 0)
-        {
-            fileExit();
-            return;
-        }
-    }
-#endif
-
-    refreshVMItem (strId,
-                   false /* aDetails */,
-                   false /* aSnapshots */,
-                   false /* aDescription */);
-
-    /* simulate a state change signal */
-    mVmDescriptionPage->updateState();
-}
-
-void VBoxSelectorWnd::machineDataChanged(QString strId)
-{
-    refreshVMItem (strId,
-                   true  /* aDetails */,
-                   false /* aSnapshots */,
-                   true  /* aDescription */);
-}
-
-void VBoxSelectorWnd::machineRegistered(QString strId, bool fRegistered)
-{
-    if (fRegistered)
-    {
-        CVirtualBox vbox = vboxGlobal().virtualBox();
-        CMachine m = vbox.GetMachine (strId);
-        if (!m.isNull())
-        {
-            mVMModel->addItem (new UIVMItem (m));
-            mVMModel->sort();
-            /* Make sure the description, ... pages are properly updated.
-             * Actualy we haven't call the next method, but unfortunately Qt
-             * seems buggy if the new item is on the same position as the
-             * previous one. So go on the safe side and call this by our self. */
-            vmListViewCurrentChanged();
-        }
-        /* m.isNull() is ok (theoretically, the machine could have been
-         * already deregistered by some other client at this point) */
-    }
-    else
-    {
-        UIVMItem *item = mVMModel->itemById (strId);
-        if (item)
-        {
-            int row = mVMModel->rowById (item->id());
-            mVMModel->removeItem (item);
-            delete item;
-            mVMListView->ensureSomeRowSelected (row);
-        }
-
-        /* item = 0 is ok (if we originated this event then the item
-         * has been already removed) */
-    }
-}
-
-void VBoxSelectorWnd::sessionStateChanged(QString strId, KSessionState /* state */)
-{
-    refreshVMItem (strId,
-                   true  /* aDetails */,
-                   false /* aSnapshots */,
-                   false /* aDescription */);
-
-    /* simulate a state change signal */
-    mVmDescriptionPage->updateState();
-}
-
-void VBoxSelectorWnd::snapshotChanged(QString strId, QString /* strSnapshotId */)
-{
-    refreshVMItem (strId,
-                   false /* aDetails */,
-                   true  /* aSnapshot */,
-                   false /* aDescription */);
-}
-
-#ifdef VBOX_GUI_WITH_SYSTRAY
-
-void VBoxSelectorWnd::mainWindowCountChanged(int count)
-{
-    if (vboxGlobal().isTrayMenu() && count <= 1)
-        fileExit();
-}
-
-void VBoxSelectorWnd::trayIconCanShow(bool fEnabled)
-{
-    emit trayIconChanged(VBoxChangeTrayIconEvent (vboxGlobal().settings().trayIconEnabled()));
-}
-
-void VBoxSelectorWnd::trayIconShow(bool fEnabled)
-{
-    if (vboxGlobal().isTrayMenu() && mTrayIcon)
-        mTrayIcon->trayIconShow(fEnabled);
-}
-
-void VBoxSelectorWnd::trayIconChanged(bool fEnabled)
-{
-    /* Not used yet. */
-}
-
-VBoxTrayIcon::VBoxTrayIcon (VBoxSelectorWnd* aParent, UIVMItemModel* aVMModel)
-{
-    mParent = aParent;
-    mVMModel = aVMModel;
-
-    mShowSelectorAction = new QAction (this);
-    Assert (mShowSelectorAction);
-    mShowSelectorAction->setIcon(UIIconPool::iconSet(":/VirtualBox_16px.png"));
-
-    mHideSystrayMenuAction = new QAction (this);
-    Assert (mHideSystrayMenuAction);
-    mHideSystrayMenuAction->setIcon(UIIconPool::iconSet(":/exit_16px.png"));
-
-    /* reuse parent action data */
-
-    mVmConfigAction = new QAction (this);
-    Assert (mVmConfigAction);
-    mVmConfigAction->setIcon (mParent->vmConfigAction()->icon());
-
-    mVmDeleteAction = new QAction (this);
-    Assert (mVmDeleteAction);
-    mVmDeleteAction->setIcon (mParent->vmDeleteAction()->icon());
-
-    mVmStartAction = new QAction (this);
-    Assert (mVmStartAction);
-    mVmStartAction->setIcon (mParent->vmStartAction()->icon());
-
-    mVmDiscardAction = new QAction (this);
-    Assert (mVmDiscardAction);
-    mVmDiscardAction->setIcon (mParent->vmDiscardAction()->icon());
-
-    mVmPauseAction = new QAction (this);
-    Assert (mVmPauseAction);
-    mVmPauseAction->setCheckable (true);
-    mVmPauseAction->setIcon (mParent->vmPauseAction()->icon());
-
-    mVmRefreshAction = new QAction (this);
-    Assert (mVmRefreshAction);
-    mVmRefreshAction->setIcon (mParent->vmRefreshAction()->icon());
-
-    mVmShowLogsAction = new QAction (this);
-    Assert (mVmConfigAction);
-    mVmShowLogsAction->setIcon (mParent->vmShowLogsAction()->icon());
-
-    mTrayIconMenu = new QMenu (aParent);
-    Assert (mTrayIconMenu);
-
-    setIcon (QIcon (":/VirtualBox_16px.png"));
-    setContextMenu (mTrayIconMenu);
-
-    connect (mShowSelectorAction, SIGNAL (triggered()), mParent, SLOT (showWindow()));
-    connect (mHideSystrayMenuAction, SIGNAL (triggered()), this, SLOT (trayIconShow()));
-}
-
-VBoxTrayIcon::~VBoxTrayIcon ()
-{
-    /* Erase dialog handle in config file. */
-    if (mActive)
-    {
-        vboxGlobal().virtualBox().SetExtraData (VBoxDefs::GUI_TrayIconWinID,
-                                                QString::null);
-        hide();
-    }
-}
-
-void VBoxTrayIcon::retranslateUi ()
-{
-    if (!mActive)
-        return;
-
-    mShowSelectorAction->setText (tr ("Show Selector Window"));
-    mShowSelectorAction->setStatusTip (tr (
-        "Show the selector window assigned to this menu"));
-
-    mHideSystrayMenuAction->setText (tr ("Hide Tray Icon"));
-    mHideSystrayMenuAction->setStatusTip (tr (
-        "Remove this icon from the system tray"));
-
-    /* reuse parent action data */
-
-    mVmConfigAction->setText (mParent->vmConfigAction()->text());
-    mVmConfigAction->setStatusTip (mParent->vmConfigAction()->statusTip());
-
-    mVmDeleteAction->setText (mParent->vmDeleteAction()->text());
-    mVmDeleteAction->setStatusTip (mParent->vmDeleteAction()->statusTip());
-
-    mVmPauseAction->setText (mParent->vmPauseAction()->text());
-    mVmPauseAction->setStatusTip (mParent->vmPauseAction()->statusTip());
-
-    mVmDiscardAction->setText (mParent->vmDiscardAction()->text());
-    mVmDiscardAction->setStatusTip (mParent->vmDiscardAction()->statusTip());
-
-    mVmShowLogsAction->setText (mParent->vmShowLogsAction()->text());
-    mVmShowLogsAction->setStatusTip (mParent->vmShowLogsAction()->statusTip());
-}
-
-void VBoxTrayIcon::showSubMenu ()
-{
-    if (!mActive)
-        return;
-
-    UIVMItem* pItem = NULL;
-    QMenu *pMenu = NULL;
-    QVariant vID;
-
-    if ((pMenu = qobject_cast<QMenu*>(sender())))
-    {
-        vID = pMenu->menuAction()->data();
-        if (vID.canConvert<QString>() && mVMModel)
-            pItem = mVMModel->itemById (qvariant_cast<QString>(vID));
-    }
-
-    mVmConfigAction->setData (vID);
-    mVmDeleteAction->setData (vID);
-    mVmDiscardAction->setData (vID);
-    mVmStartAction->setData (vID);
-    mVmPauseAction->setData (vID);
-    mVmShowLogsAction->setData (vID);
-
-    if (pItem && pItem->accessible())
-    {
-        /* look at vmListViewCurrentChanged() */
-        CMachine m = pItem->machine();
-        KMachineState s = pItem->state();
-        bool running = pItem->sessionState() != KSessionState_Closed;
-        bool modifyEnabled = !running && s != KMachineState_Saved;
-
-        /* Settings */
-        mVmConfigAction->setEnabled (modifyEnabled);
-
-        /* Delete */
-        mVmDeleteAction->setEnabled (modifyEnabled);
-
-        /* Discard */
-        mVmDiscardAction->setEnabled (s == KMachineState_Saved && !running);
-
-        /* Change the Start button text accordingly */
-        if (   s == KMachineState_PoweredOff
-            || s == KMachineState_Saved
-            || s == KMachineState_Teleported
-            || s == KMachineState_Aborted
-           )
-        {
-            mVmStartAction->setText (UIVMListView::tr ("S&tart"));
-            mVmStartAction->setStatusTip (
-                  UIVMListView::tr ("Start the selected virtual machine"));
-            mVmStartAction->setEnabled (!running);
-        }
-        else
-        {
-            mVmStartAction->setText (UIVMListView::tr ("S&how"));
-            mVmStartAction->setStatusTip (
-                  UIVMListView::tr ("Switch to the window of the selected virtual machine"));
-            mVmStartAction->setEnabled (pItem->canSwitchTo());
-        }
-
-        /* Change the Pause/Resume button text accordingly */
-        mVmPauseAction->setEnabled (   s == KMachineState_Running
-                                    || s == KMachineState_Teleporting
-                                    || s == KMachineState_LiveSnapshotting
-                                    || s == KMachineState_Paused
-                                    || s == KMachineState_TeleportingPausedVM
-                                   );
-
-        if (   s == KMachineState_Paused
-            || s == KMachineState_TeleportingPausedVM /*?*/
-           )
-        {
-            mVmPauseAction->setText (UIVMListView::tr ("R&esume"));
-            mVmPauseAction->setStatusTip (
-                  UIVMListView::tr ("Resume the execution of the virtual machine"));
-            mVmPauseAction->blockSignals (true);
-            mVmPauseAction->setChecked (true);
-            mVmPauseAction->blockSignals (false);
-        }
-        else
-        {
-            mVmPauseAction->setText (UIVMListView::tr ("&Pause"));
-            mVmPauseAction->setStatusTip (
-                  UIVMListView::tr ("Suspend the execution of the virtual machine"));
-            mVmPauseAction->blockSignals (true);
-            mVmPauseAction->setChecked (false);
-            mVmPauseAction->blockSignals (false);
-        }
-
-        mVmShowLogsAction->setEnabled (true);
-
-        /* Disconnect old slot which maybe was connected from another selected sub menu. */
-        disconnect (mVmConfigAction, SIGNAL (triggered()), this, SLOT (vmSettings()));
-        disconnect (mVmDeleteAction, SIGNAL (triggered()), this, SLOT (vmDelete()));
-        disconnect (mVmDiscardAction, SIGNAL (triggered()), this, SLOT (vmDiscard()));
-        disconnect (mVmStartAction, SIGNAL (triggered()), this, SLOT (vmStart()));
-        disconnect (mVmPauseAction, SIGNAL (toggled (bool)), this, SLOT (vmPause (bool)));
-        disconnect (mVmShowLogsAction, SIGNAL (triggered()), this, SLOT (vmShowLogs()));
-
-        /* Connect new sub menu with slots. */
-        connect (mVmConfigAction, SIGNAL (triggered()), this, SLOT (vmSettings()));
-        connect (mVmDeleteAction, SIGNAL (triggered()), this, SLOT (vmDelete()));
-        connect (mVmDiscardAction, SIGNAL (triggered()), this, SLOT (vmDiscard()));
-        connect (mVmStartAction, SIGNAL (triggered()), this, SLOT (vmStart()));
-        connect (mVmPauseAction, SIGNAL (toggled (bool)), this, SLOT (vmPause (bool)));
-        connect (mVmShowLogsAction, SIGNAL (triggered()), this, SLOT (vmShowLogs()));
-    }
-    else    /* Item is not accessible. */
-    {
-        mVmConfigAction->setEnabled (false);
-        mVmDeleteAction->setEnabled (pItem != NULL);
-        mVmDiscardAction->setEnabled (false);
-        mVmPauseAction->setEnabled (false);
-
-        /* Set the Start button text accordingly. */
-        mVmStartAction->setText (UIVMListView::tr ("S&tart"));
-        mVmStartAction->setStatusTip (
-              UIVMListView::tr ("Start the selected virtual machine"));
-        mVmStartAction->setEnabled (false);
-
-        /* Disable the show log item for the selected vm. */
-        mVmShowLogsAction->setEnabled (false);
-    }
-
-    /* Build sub menu entries (add rest of sub menu entries later here). */
-    pMenu->addAction (mVmStartAction);
-    pMenu->addAction (mVmPauseAction);
-}
-
-void VBoxTrayIcon::hideSubMenu ()
-{
-    if (!mActive)
-        return;
-
-    UIVMItem* pItem = NULL;
-    QVariant vID;
-
-    if (QMenu *pMenu = qobject_cast<QMenu*>(sender()))
-    {
-        vID = pMenu->menuAction()->data();
-        if (vID.canConvert<QString>() && mVMModel)
-            pItem = mVMModel->itemById (qvariant_cast<QString>(vID));
-    }
-
-    /* Nothing to do here yet. */
-
-    Assert (pItem);
-}
-
-void VBoxTrayIcon::refresh ()
-{
-    if (!mActive)
-        return;
-
-    AssertReturnVoid (mVMModel);
-    AssertReturnVoid (mTrayIconMenu);
-
-    mTrayIconMenu->clear();
-
-    UIVMItem* pItem = NULL;
-    QMenu* pCurMenu = mTrayIconMenu;
-    QMenu* pSubMenu = NULL;
-
-    int iCurItemCount = 0;
-
-    mTrayIconMenu->addAction (mShowSelectorAction);
-    mTrayIconMenu->setDefaultAction (mShowSelectorAction);
-
-    if (mVMModel->rowCount() > 0)
-        mTrayIconMenu->addSeparator();
-
-    for (int i = 0; i < mVMModel->rowCount(); i++, iCurItemCount++)
-    {
-        pItem = mVMModel->itemByRow(i);
-        Assert(pItem);
-
-        if (iCurItemCount > 10) /* 10 machines per sub menu. */
-        {
-            pSubMenu = new QMenu (tr ("&Other Machines...", "tray menu"));
-            Assert (pSubMenu);
-            pCurMenu->addMenu (pSubMenu);
-            pCurMenu = pSubMenu;
-            iCurItemCount = 0;
-        }
-
-        pSubMenu = new QMenu (QString ("&%1. %2")
-                              .arg ((iCurItemCount + 1) % 100).arg (pItem->name()));
-        Assert (pSubMenu);
-        pSubMenu->setIcon (pItem->sessionStateIcon());
-
-        QAction *pAction = NULL;
-        QVariant vID;
-        vID.setValue (pItem->id());
-
-        pSubMenu->menuAction()->setData (vID);
-        connect (pSubMenu, SIGNAL (aboutToShow()), this, SLOT (showSubMenu()));
-        connect (pSubMenu, SIGNAL (aboutToHide()), this, SLOT (hideSubMenu()));
-        pCurMenu->addMenu (pSubMenu);
-    }
-
-    if (mVMModel->rowCount() > 0)
-        mTrayIconMenu->addSeparator();
-
-    mTrayIconMenu->addAction (mHideSystrayMenuAction);
-
-    /* We're done constructing the menu, show it */
-    setVisible (true);
-}
-
-UIVMItem* VBoxTrayIcon::GetItem (QObject* aObject)
-{
-    UIVMItem* pItem = NULL;
-    if (QAction *pAction = qobject_cast<QAction*>(sender()))
-    {
-        QVariant v = pAction->data();
-        if (v.canConvert<QString>() && mVMModel)
-            pItem = mVMModel->itemById (qvariant_cast<QString>(v));
-    }
-
-    Assert (pItem);
-    return pItem;
-}
-
-void VBoxTrayIcon::trayIconShow (bool aShow)
-{
-    if (!vboxGlobal().isTrayMenu())
-        return;
-
-    mActive = aShow;
-    if (mActive)
-    {
-        refresh();
-        retranslateUi();
-    }
-    setVisible (mActive);
-
-    if (!mActive)
-        mParent->fileExit();
-}
-
-void VBoxTrayIcon::vmSettings()
-{
-    UIVMItem* pItem = GetItem (sender());
-    mParent->vmSettings (NULL, NULL, pItem->id());
-}
-
-void VBoxTrayIcon::vmDelete()
-{
-    UIVMItem* pItem = GetItem (sender());
-    mParent->vmDelete (pItem->id());
-}
-
-void VBoxTrayIcon::vmStart()
-{
-    UIVMItem* pItem = GetItem (sender());
-    mParent->vmStart (pItem->id());
-}
-
-void VBoxTrayIcon::vmDiscard()
-{
-    UIVMItem* pItem = GetItem (sender());
-    mParent->vmDiscard (pItem->id());
-}
-
-void VBoxTrayIcon::vmPause(bool aPause)
-{
-    UIVMItem* pItem = GetItem (sender());
-    mParent->vmPause (aPause, pItem->id());
-}
-
-void VBoxTrayIcon::vmRefresh()
-{
-    UIVMItem* pItem = GetItem (sender());
-    mParent->vmRefresh (pItem->id());
-}
-
-void VBoxTrayIcon::vmShowLogs()
-{
-    UIVMItem* pItem = GetItem (sender());
-    mParent->vmShowLogs (pItem->id());
-}
-
-#endif // VBOX_GUI_WITH_SYSTRAY
-
-void VBoxSelectorWnd::sltDownloaderUserManualEmbed()
-{
-    /* If there is User Manual downloader created => show the process bar: */
-    if (UIDownloaderUserManual *pDl = UIDownloaderUserManual::current())
-        statusBar()->addWidget(pDl->processWidget(this), 0);
-}
-
-void VBoxSelectorWnd::showViewContextMenu(const QPoint &pos)
-{
-    CVirtualBox vbox = vboxGlobal().virtualBox();
-    QString strToolbar = vbox.GetExtraData(VBoxDefs::GUI_Toolbar);
-    QString strStatusbar = vbox.GetExtraData(VBoxDefs::GUI_Statusbar);
-    bool fToolbar = strToolbar.isEmpty() || strToolbar == "true";
-    bool fStatusbar = strStatusbar.isEmpty() || strStatusbar == "true";
-
-    QList<QAction*> actions;
-    QAction *pShowToolBar = new QAction(tr("Show Toolbar"), 0);
-    pShowToolBar->setCheckable(true);
-    pShowToolBar->setChecked(fToolbar);
-    actions << pShowToolBar;
-    QAction *pShowStatusBar = new QAction(tr("Show Statusbar"), 0);
-    pShowStatusBar->setCheckable(true);
-    pShowStatusBar->setChecked(fStatusbar);
-    actions << pShowStatusBar;
-
-    QPoint gpos = pos;
-    QWidget *pSender = static_cast<QWidget*>(sender());
-    if (pSender)
-        gpos = pSender->mapToGlobal(pos);
-    QAction *pResult = QMenu::exec(actions, gpos);
-    if (pResult == pShowToolBar)
-    {
-        if (pResult->isChecked())
-        {
-            mVMToolBar->show();
-            vbox.SetExtraData(VBoxDefs::GUI_Toolbar, "true");
-        }
-        else
-        {
-            mVMToolBar->hide();
-            vbox.SetExtraData(VBoxDefs::GUI_Toolbar, "false");
-        }
-    }else if (pResult == pShowStatusBar)
-    {
-        if (pResult->isChecked())
-        {
-            statusBar()->show();
-            vbox.SetExtraData(VBoxDefs::GUI_Statusbar, "true");
-        }
-        else
-        {
-            statusBar()->hide();
-            vbox.SetExtraData(VBoxDefs::GUI_Statusbar, "false");
-        }
-    }
-}
-
-#include "VBoxSelectorWnd.moc"
Index: unk/src/VBox/Frontends/VirtualBox/src/VBoxSelectorWnd.h
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/VBoxSelectorWnd.h	(revision 30867)
+++ 	(revision )
@@ -1,259 +1,0 @@
-/** @file
- *
- * VBox frontends: Qt GUI ("VirtualBox"):
- * VBoxSelectorWnd class declaration
- */
-
-/*
- * Copyright (C) 2006-2008 Oracle Corporation
- *
- * This file is part of VirtualBox Open Source Edition (OSE), as
- * available from http://www.virtualbox.org. This file is free software;
- * you can redistribute it and/or modify it under the terms of the GNU
- * General Public License (GPL) as published by the Free Software
- * Foundation, in version 2 as it comes in the "COPYING" file of the
- * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
- * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
- */
-
-#ifndef __VBoxSelectorWnd_h__
-#define __VBoxSelectorWnd_h__
-
-#include "COMDefs.h"
-
-#include "QIWithRetranslateUI.h"
-
-#include "VBoxGlobal.h"
-#include "VBoxProblemReporter.h"
-#include "VBoxHelpActions.h"
-
-/* Qt includes */
-#include <QMainWindow>
-#ifdef VBOX_GUI_WITH_SYSTRAY
-    #include <QSystemTrayIcon>
-#endif
-
-/* Local forward declarations */
-class QITabWidget;
-class UIVMItem;
-class UIVMItemModel;
-class UIVMListView;
-class VBoxSnapshotsWgt;
-class VBoxToolBar;
-class VBoxTrayIcon;
-class VBoxVMDescriptionPage;
-class VBoxVMDetailsView;
-class VBoxVMLogViewer;
-
-/* Global forward declarations */
-class QEvent;
-class QListView;
-
-class VBoxSelectorWnd : public QIWithRetranslateUI2 <QMainWindow>
-{
-    Q_OBJECT;
-
-public:
-
-    VBoxSelectorWnd (VBoxSelectorWnd **aSelf,
-                     QWidget* aParent = 0,
-                     Qt::WindowFlags aFlags = Qt::Window);
-    virtual ~VBoxSelectorWnd();
-
-signals:
-
-    void closing();
-
-public slots:
-
-    void fileMediaMgr();
-    void fileImportAppliance();
-    void fileExportAppliance();
-    void fileSettings();
-    void fileExit();
-
-    void vmNew();
-    void vmSettings (const QString &aCategory = QString::null,
-                     const QString &aControl = QString::null,
-                     const QString & = QString::null);
-    void vmDelete (const QString & = QString::null);
-    void vmStart (const QString & = QString::null);
-    void vmDiscard (const QString & = QString::null);
-    void vmPause (bool, const QString & = QString::null);
-    void vmRefresh (const QString & = QString::null);
-    void vmShowLogs (const QString & = QString::null);
-
-    void refreshVMList();
-    void refreshVMItem (const QString &aID, bool aDetails,
-                                          bool aSnapshots,
-                                          bool aDescription);
-
-    void showContextMenu (const QPoint &aPoint);
-
-#ifdef VBOX_GUI_WITH_SYSTRAY
-    void trayIconActivated (QSystemTrayIcon::ActivationReason aReason);
-    void showWindow();
-#endif
-
-    const QAction *vmNewAction() const { return mVmNewAction; }
-    const QAction *vmConfigAction() const { return mVmConfigAction; }
-    const QAction *vmDeleteAction() const { return mVmDeleteAction; }
-    const QAction *vmStartAction() const { return mVmStartAction; }
-    const QAction *vmDiscardAction() const { return mVmDiscardAction; }
-    const QAction *vmPauseAction() const { return mVmPauseAction; }
-    const QAction *vmRefreshAction() const { return mVmRefreshAction; }
-    const QAction *vmShowLogsAction() const { return mVmShowLogsAction; }
-
-protected:
-
-    /* Events */
-    bool event (QEvent *aEvent);
-    void closeEvent (QCloseEvent *aEvent);
-//#if defined (Q_WS_MAC) && (QT_VERSION < 0x040402)
-//    bool eventFilter (QObject *aObject, QEvent *aEvent);
-//#endif /* defined (Q_WS_MAC) && (QT_VERSION < 0x040402) */
-
-    void retranslateUi();
-
-private slots:
-
-    void vmListViewCurrentChanged (bool aRefreshDetails = true,
-                                   bool aRefreshSnapshots = true,
-                                   bool aRefreshDescription = true);
-
-    void mediumEnumStarted();
-    void mediumEnumFinished (const VBoxMediaList &);
-
-    /* VirtualBox callback events we're interested in */
-
-    void machineStateChanged(QString strId, KMachineState state);
-    void machineDataChanged(QString strId);
-    void machineRegistered(QString strID, bool fRegistered);
-    void sessionStateChanged(QString strId, KSessionState state);
-    void snapshotChanged(QString strId, QString strSnapshotId);
-#ifdef VBOX_GUI_WITH_SYSTRAY
-    void mainWindowCountChanged(int count);
-    void trayIconCanShow(bool fEnabled);
-    void trayIconShow(bool fEnabled);
-    void trayIconChanged(bool fEnabled);
-#endif
-
-    void sltDownloaderUserManualEmbed();
-
-    void showViewContextMenu(const QPoint &pos);
-
-private:
-
-    /* Main menus */
-    QMenu *mFileMenu;
-    QMenu *mVMMenu;
-    QMenu *mHelpMenu;
-
-    /* Main toolbar */
-    VBoxToolBar *mVMToolBar;
-
-    /* VM list context menu */
-    QMenu *mVMCtxtMenu;
-//    UIOSDMenu *mVMCtxtMenu;
-
-    /* Actions */
-    QAction *mFileMediaMgrAction;
-    QAction *mFileApplianceImportAction;
-    QAction *mFileApplianceExportAction;
-    QAction *mFileSettingsAction;
-    QAction *mFileExitAction;
-    QAction *mVmNewAction;
-    QAction *mVmConfigAction;
-    QAction *mVmDeleteAction;
-    QAction *mVmStartAction;
-    QAction *mVmDiscardAction;
-    QAction *mVmPauseAction;
-    QAction *mVmRefreshAction;
-    QAction *mVmShowLogsAction;
-
-    VBoxHelpActions mHelpActions;
-
-#ifdef VBOX_GUI_WITH_SYSTRAY
-    /* The systray icon */
-    VBoxTrayIcon *mTrayIcon;
-#endif
-
-    /* The vm list view/model */
-    UIVMListView *mVMListView;
-    UIVMItemModel *mVMModel;
-
-    /* The right information widgets */
-    QITabWidget *mVmTabWidget;
-    VBoxVMDetailsView *mVmDetailsView;
-    VBoxSnapshotsWgt *mVmSnapshotsWgt;
-    VBoxVMDescriptionPage *mVmDescriptionPage;
-
-    QRect mNormalGeo;
-
-    bool mDoneInaccessibleWarningOnce : 1;
-};
-
-#ifdef VBOX_GUI_WITH_SYSTRAY
-
-Q_DECLARE_METATYPE(QString);
-
-class VBoxTrayIcon : public QSystemTrayIcon
-{
-    Q_OBJECT;
-
-public:
-
-    VBoxTrayIcon (VBoxSelectorWnd* aParent, UIVMItemModel* aVMModel);
-    virtual ~VBoxTrayIcon ();
-
-    void refresh ();
-    void retranslateUi ();
-
-protected:
-
-    UIVMItem* GetItem (QObject* aObject);
-
-signals:
-
-public slots:
-
-    void trayIconShow (bool aShow = false);
-
-private slots:
-
-    void showSubMenu();
-    void hideSubMenu ();
-
-    void vmSettings();
-    void vmDelete();
-    void vmStart();
-    void vmDiscard();
-    void vmPause(bool aPause);
-    void vmRefresh();
-    void vmShowLogs();
-
-private:
-
-    bool mActive;           /* Is systray menu active/available? */
-
-    /* The vm list model */
-    UIVMItemModel *mVMModel;
-
-    VBoxSelectorWnd* mParent;
-    QMenu *mTrayIconMenu;
-
-    QAction *mShowSelectorAction;
-    QAction *mHideSystrayMenuAction;
-    QAction *mVmConfigAction;
-    QAction *mVmDeleteAction;
-    QAction *mVmStartAction;
-    QAction *mVmDiscardAction;
-    QAction *mVmPauseAction;
-    QAction *mVmRefreshAction;
-    QAction *mVmShowLogsAction;
-};
-
-#endif // VBOX_GUI_WITH_SYSTRAY
-
-#endif // __VBoxSelectorWnd_h__
-
Index: unk/src/VBox/Frontends/VirtualBox/src/VBoxSnapshotsWgt.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/VBoxSnapshotsWgt.cpp	(revision 30867)
+++ 	(revision )
@@ -1,875 +1,0 @@
-/* $Id$ */
-/** @file
- *
- * VBox frontends: Qt4 GUI ("VirtualBox"):
- * VBoxSnapshotsWgt class implementation
- */
-
-/*
- * Copyright (C) 2006-2010 Oracle Corporation
- *
- * This file is part of VirtualBox Open Source Edition (OSE), as
- * available from http://www.virtualbox.org. This file is free software;
- * you can redistribute it and/or modify it under the terms of the GNU
- * General Public License (GPL) as published by the Free Software
- * Foundation, in version 2 as it comes in the "COPYING" file of the
- * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
- * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
- */
-
-#ifdef VBOX_WITH_PRECOMPILED_HEADERS
-# include "precomp.h"
-#else  /* !VBOX_WITH_PRECOMPILED_HEADERS */
-/* Local includes */
-#include "UIIconPool.h"
-#include "VBoxProblemReporter.h"
-#include "VBoxSnapshotDetailsDlg.h"
-#include "VBoxSnapshotsWgt.h"
-#include "VBoxTakeSnapshotDlg.h"
-#include "VBoxToolBar.h"
-#include "UIVirtualBoxEventHandler.h"
-
-/* Global includes */
-#include <QDateTime>
-#include <QHeaderView>
-#include <QMenu>
-#include <QScrollBar>
-
-#endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
-
-/**
- *  QTreeWidgetItem subclass for snapshots items
- */
-class SnapshotWgtItem : public QTreeWidgetItem
-{
-public:
-
-    enum { ItemType = QTreeWidgetItem::UserType + 1 };
-
-    /* Normal snapshot item (child of tree-widget) */
-    SnapshotWgtItem (QTreeWidget *aTreeWidget, const CSnapshot &aSnapshot)
-        : QTreeWidgetItem (aTreeWidget, ItemType)
-        , mIsCurrentState (false)
-        , mSnapshot (aSnapshot)
-    {
-    }
-
-    /* Normal snapshot item (child of tree-widget-item) */
-    SnapshotWgtItem (QTreeWidgetItem *aRootItem, const CSnapshot &aSnapshot)
-        : QTreeWidgetItem (aRootItem, ItemType)
-        , mIsCurrentState (false)
-        , mSnapshot (aSnapshot)
-    {
-    }
-
-    /* Current state item (child of tree-widget) */
-    SnapshotWgtItem (QTreeWidget *aTreeWidget, const CMachine &aMachine)
-        : QTreeWidgetItem (aTreeWidget, ItemType)
-        , mIsCurrentState (true)
-        , mMachine (aMachine)
-    {
-        updateCurrentState (mMachine.GetState());
-    }
-
-    /* Current state item (child of tree-widget-item) */
-    SnapshotWgtItem (QTreeWidgetItem *aRootItem, const CMachine &aMachine)
-        : QTreeWidgetItem (aRootItem, ItemType)
-        , mIsCurrentState (true)
-        , mMachine (aMachine)
-    {
-        updateCurrentState (mMachine.GetState());
-    }
-
-    QVariant data (int aColumn, int aRole) const
-    {
-        switch (aRole)
-        {
-            case Qt::DisplayRole:
-                return mIsCurrentState ? QTreeWidgetItem::data (aColumn, aRole) : QVariant (QString ("%1%2")
-                                         .arg (QTreeWidgetItem::data (aColumn, Qt::DisplayRole).toString())
-                                         .arg (QTreeWidgetItem::data (aColumn, Qt::UserRole).toString()));
-            default:
-                break;
-        }
-        return QTreeWidgetItem::data (aColumn, aRole);
-    }
-
-    QString text (int aColumn) const
-    {
-        return QTreeWidgetItem::data (aColumn, Qt::DisplayRole).toString();
-    }
-
-    bool isCurrentStateItem() const
-    {
-        return mSnapshot.isNull();
-    }
-
-    int level()
-    {
-        QTreeWidgetItem *item = this;
-        int result = 0;
-        while (item->parent())
-        {
-            ++ result;
-            item = item->parent();
-        }
-        return result;
-    }
-
-    bool bold() const { return font (0).bold(); }
-    void setBold (bool aBold)
-    {
-        QFont myFont = font (0);
-        myFont.setBold (aBold);
-        setFont (0, myFont);
-        adjustText();
-    }
-
-    bool italic() const { return font (0).italic(); }
-    void setItalic (bool aItalic)
-    {
-        QFont myFont = font (0);
-        myFont.setItalic (aItalic);
-        setFont (0, myFont);
-        adjustText();
-    }
-
-    CSnapshot snapshot() const { return mSnapshot; }
-    QString snapshotId() const { return mId; }
-
-    void recache()
-    {
-        if (mIsCurrentState)
-        {
-            Assert (!mMachine.isNull());
-            mCurStateModified = mMachine.GetCurrentStateModified();
-            setText (0, mCurStateModified ?
-                        VBoxSnapshotsWgt::tr ("Current State (changed)", "Current State (Modified)") :
-                        VBoxSnapshotsWgt::tr ("Current State", "Current State (Unmodified)"));
-            mDesc = mCurStateModified ?
-                    VBoxSnapshotsWgt::tr ("The current state differs from the state stored in the current snapshot") :
-                    parent() != 0 ?
-                    VBoxSnapshotsWgt::tr ("The current state is identical to the state stored in the current snapshot") :
-                    QString::null;
-        }
-        else
-        {
-            Assert (!mSnapshot.isNull());
-            mId = mSnapshot.GetId();
-            setText (0, mSnapshot.GetName());
-            mOnline = mSnapshot.GetOnline();
-            setIcon (0, vboxGlobal().snapshotIcon (mOnline));
-            mDesc = mSnapshot.GetDescription();
-            mTimestamp.setTime_t (mSnapshot.GetTimeStamp() / 1000);
-            mCurStateModified = false;
-        }
-        adjustText();
-        recacheToolTip();
-    }
-
-    KMachineState getCurrentState()
-    {
-        if (mMachine.isNull())
-            return KMachineState_Null;
-
-        return mMachineState;
-    }
-
-    void updateCurrentState (KMachineState aState)
-    {
-        if (mMachine.isNull())
-            return;
-
-        setIcon (0, vboxGlobal().toIcon (aState));
-        mMachineState = aState;
-        mTimestamp.setTime_t (mMachine.GetLastStateChange() / 1000);
-    }
-
-    SnapshotAgeFormat updateAge()
-    {
-        QString age;
-
-        /* Age: [date time|%1d ago|%1h ago|%1min ago|%1sec ago] */
-        SnapshotAgeFormat ageFormat;
-        if (mTimestamp.daysTo (QDateTime::currentDateTime()) > 30)
-        {
-            age = VBoxSnapshotsWgt::tr (" (%1)").arg (mTimestamp.toString (Qt::LocalDate));
-            ageFormat = AgeMax;
-        }
-        else if (mTimestamp.secsTo (QDateTime::currentDateTime()) > 60 * 60 * 24)
-        {
-            age = VBoxSnapshotsWgt::tr (" (%1 ago)").arg(VBoxGlobal::daysToString(mTimestamp.secsTo (QDateTime::currentDateTime()) / 60 / 60 / 24));
-            ageFormat = AgeInDays;
-        }
-        else if (mTimestamp.secsTo (QDateTime::currentDateTime()) > 60 * 60)
-        {
-            age = VBoxSnapshotsWgt::tr (" (%1 ago)").arg(VBoxGlobal::hoursToString(mTimestamp.secsTo (QDateTime::currentDateTime()) / 60 / 60));
-            ageFormat = AgeInHours;
-        }
-        else if (mTimestamp.secsTo (QDateTime::currentDateTime()) > 60)
-        {
-            age = VBoxSnapshotsWgt::tr (" (%1 ago)").arg(VBoxGlobal::minutesToString(mTimestamp.secsTo (QDateTime::currentDateTime()) / 60));
-            ageFormat = AgeInMinutes;
-        }
-        else
-        {
-            age = VBoxSnapshotsWgt::tr (" (%1 ago)").arg(VBoxGlobal::secondsToString(mTimestamp.secsTo (QDateTime::currentDateTime())));
-            ageFormat = AgeInSeconds;
-        }
-
-        /* Update data */
-        setData (0, Qt::UserRole, age);
-
-        return ageFormat;
-    }
-
-private:
-
-    void adjustText()
-    {
-        if (!treeWidget()) return; /* only for initialised items */
-        QFontMetrics metrics (font (0));
-        int hei0 = (metrics.height() > 16 ?
-                   metrics.height() /* text */ : 16 /* icon */) +
-                   2 * 2 /* 2 pixel per margin */;
-        int wid0 = metrics.width (text (0)) /* text */ +
-                   treeWidget()->indentation() /* indent */ +
-                   16 /* icon */;
-        setSizeHint (0, QSize (wid0, hei0));
-    }
-
-    void recacheToolTip()
-    {
-        QString name = text (0);
-
-        bool dateTimeToday = mTimestamp.date() == QDate::currentDate();
-        QString dateTime = dateTimeToday ?
-                           mTimestamp.time().toString (Qt::LocalDate) :
-                           mTimestamp.toString (Qt::LocalDate);
-
-        QString details;
-
-        if (!mSnapshot.isNull())
-        {
-            /* The current snapshot is always bold */
-            if (bold())
-                details = VBoxSnapshotsWgt::tr (" (current, ", "Snapshot details");
-            else
-                details = " (";
-            details += mOnline ? VBoxSnapshotsWgt::tr ("online)", "Snapshot details")
-                               : VBoxSnapshotsWgt::tr ("offline)", "Snapshot details");
-
-            if (dateTimeToday)
-                dateTime = VBoxSnapshotsWgt::tr ("Taken at %1", "Snapshot (time)").arg (dateTime);
-            else
-                dateTime = VBoxSnapshotsWgt::tr ("Taken on %1", "Snapshot (date + time)").arg (dateTime);
-        }
-        else
-        {
-            dateTime = VBoxSnapshotsWgt::tr ("%1 since %2", "Current State (time or date + time)")
-                .arg (vboxGlobal().toString (mMachineState)).arg (dateTime);
-        }
-
-        QString toolTip = QString ("<nobr><b>%1</b>%2</nobr><br><nobr>%3</nobr>")
-            .arg (name) .arg (details).arg (dateTime);
-
-        if (!mDesc.isEmpty())
-            toolTip += "<hr>" + mDesc;
-
-        setToolTip (0, toolTip);
-    }
-
-    bool mIsCurrentState;
-
-    CSnapshot mSnapshot;
-    CMachine mMachine;
-
-    QString mId;
-    bool mOnline;
-    QString mDesc;
-    QDateTime mTimestamp;
-
-    bool mCurStateModified;
-    KMachineState mMachineState;
-};
-
-/**
- *  Simple guard block to prevent cyclic call caused by:
- *  changing tree-widget item content (rename) leads to snapshot update &
- *  snapshot update leads to changing tree-widget item content.
- */
-class SnapshotEditBlocker
-{
-public:
-
-    SnapshotEditBlocker (bool &aProtector)
-        : mProtector (aProtector)
-    {
-        mProtector = true;
-    }
-
-   ~SnapshotEditBlocker()
-    {
-        mProtector = false;
-    }
-
-private:
-
-    bool &mProtector;
-};
-
-VBoxSnapshotsWgt::VBoxSnapshotsWgt (QWidget *aParent)
-    : QIWithRetranslateUI <QWidget> (aParent)
-    , mCurSnapshotItem (0)
-    , mEditProtector (false)
-    , mSnapshotActionGroup (new QActionGroup (this))
-    , mCurStateActionGroup (new QActionGroup (this))
-    , mRestoreSnapshotAction (new QAction (mSnapshotActionGroup))
-    , mDeleteSnapshotAction (new QAction (mSnapshotActionGroup))
-    , mShowSnapshotDetailsAction (new QAction (mSnapshotActionGroup))
-    , mTakeSnapshotAction (new QAction (mCurStateActionGroup))
-{
-    /* Apply UI decorations */
-    Ui::VBoxSnapshotsWgt::setupUi (this);
-
-    mTreeWidget->header()->hide();
-
-    /* The snapshots widget is not very useful if there are a lot
-     * of snapshots in a tree and the current Qt style decides not
-     * to draw lines (branches) between the snapshot nodes; it is
-     * then often unclear which snapshot is a child of another.
-     * So on platforms whose styles do not normally draw branches,
-     * we use QWindowsStyle which is present on every platform and
-     * draws required thing like we want. */
-// #if defined(RT_OS_DARWIN) || defined(RT_OS_LINUX) || defined(RT_OS_SOLARIS)
-    QWindowsStyle *treeWidgetStyle = new QWindowsStyle;
-    mTreeWidget->setStyle (treeWidgetStyle);
-    connect (mTreeWidget, SIGNAL (destroyed (QObject *)), treeWidgetStyle, SLOT (deleteLater()));
-// #endif
-
-    /* ToolBar creation */
-    VBoxToolBar *toolBar = new VBoxToolBar (this);
-    toolBar->setUsesTextLabel (false);
-    toolBar->setIconSize (QSize (22, 22));
-    toolBar->setSizePolicy (QSizePolicy::Fixed, QSizePolicy::Fixed);
-
-    toolBar->addAction (mTakeSnapshotAction);
-    toolBar->addSeparator();
-    toolBar->addAction (mRestoreSnapshotAction);
-    toolBar->addAction (mDeleteSnapshotAction);
-    toolBar->addSeparator();
-    toolBar->addAction (mShowSnapshotDetailsAction);
-
-    ((QVBoxLayout*)layout())->insertWidget (0, toolBar);
-
-    /* Setup actions */
-    mRestoreSnapshotAction->setIcon(UIIconPool::iconSetFull(
-        QSize (22, 22), QSize (16, 16),
-        ":/discard_cur_state_22px.png", ":/discard_cur_state_16px.png", // TODO: Update Icons!
-        ":/discard_cur_state_dis_22px.png", ":/discard_cur_state_dis_16px.png")); // TODO: Update Icons!
-    mDeleteSnapshotAction->setIcon(UIIconPool::iconSetFull(
-        QSize (22, 22), QSize (16, 16),
-        ":/delete_snapshot_22px.png", ":/delete_snapshot_16px.png",
-        ":/delete_snapshot_dis_22px.png", ":/delete_snapshot_dis_16px.png"));
-    mShowSnapshotDetailsAction->setIcon(UIIconPool::iconSetFull(
-        QSize (22, 22), QSize (16, 16),
-        ":/show_snapshot_details_22px.png", ":/show_snapshot_details_16px.png",
-        ":/show_snapshot_details_dis_22px.png", ":/show_snapshot_details_dis_16px.png"));
-    mTakeSnapshotAction->setIcon(UIIconPool::iconSetFull(
-        QSize (22, 22), QSize (16, 16),
-        ":/take_snapshot_22px.png", ":/take_snapshot_16px.png",
-        ":/take_snapshot_dis_22px.png", ":/take_snapshot_dis_16px.png"));
-
-    mRestoreSnapshotAction->setShortcut (QString ("Ctrl+Shift+R"));
-    mDeleteSnapshotAction->setShortcut (QString ("Ctrl+Shift+D"));
-    mShowSnapshotDetailsAction->setShortcut (QString ("Ctrl+Space"));
-    mTakeSnapshotAction->setShortcut (QString ("Ctrl+Shift+S"));
-
-    mAgeUpdateTimer.setSingleShot (true);
-
-    /* Setup connections */
-    connect (mTreeWidget, SIGNAL (currentItemChanged (QTreeWidgetItem*, QTreeWidgetItem*)),
-             this, SLOT (onCurrentChanged (QTreeWidgetItem*)));
-    connect (mTreeWidget, SIGNAL (customContextMenuRequested (const QPoint&)),
-             this, SLOT (onContextMenuRequested (const QPoint&)));
-    connect (mTreeWidget, SIGNAL (itemChanged (QTreeWidgetItem*, int)),
-             this, SLOT (onItemChanged (QTreeWidgetItem*)));
-
-    connect (mRestoreSnapshotAction, SIGNAL (triggered()), this, SLOT (restoreSnapshot()));
-    connect (mDeleteSnapshotAction, SIGNAL (triggered()), this, SLOT (deleteSnapshot()));
-    connect (mShowSnapshotDetailsAction, SIGNAL (triggered()), this, SLOT (showSnapshotDetails()));
-    connect (mTakeSnapshotAction, SIGNAL (triggered()), this, SLOT (takeSnapshot()));
-
-    connect (gVBoxEvents, SIGNAL(sigMachineDataChange(QString)),
-             this, SLOT(machineDataChanged(QString)));
-    connect (gVBoxEvents, SIGNAL(sigMachineStateChange(QString, KMachineState)),
-             this, SLOT(machineStateChanged(QString, KMachineState)));
-    connect (gVBoxEvents, SIGNAL(sigSessionStateChange(QString, KSessionState)),
-             this, SLOT(sessionStateChanged(QString, KSessionState)));
-
-    connect (&mAgeUpdateTimer, SIGNAL (timeout()), this, SLOT (updateSnapshotsAge()));
-
-    retranslateUi();
-}
-
-void VBoxSnapshotsWgt::setMachine (const CMachine &aMachine)
-{
-    mMachine = aMachine;
-
-    if (aMachine.isNull())
-    {
-        mMachineId = QString::null;
-        mSessionState = KSessionState_Null;
-    }
-    else
-    {
-        mMachineId = aMachine.GetId();
-        mSessionState = aMachine.GetSessionState();
-    }
-
-    refreshAll();
-}
-
-
-void VBoxSnapshotsWgt::onCurrentChanged (QTreeWidgetItem *aItem)
-{
-    /* Make the selected item visible */
-    SnapshotWgtItem *item = aItem ? static_cast <SnapshotWgtItem*> (aItem) : 0;
-    if (item)
-    {
-        mTreeWidget->horizontalScrollBar()->setValue (0);
-        mTreeWidget->scrollToItem (item);
-        mTreeWidget->horizontalScrollBar()->setValue (mTreeWidget->indentation() * item->level());
-    }
-
-    /* Whether another direct session is open or not */
-    bool busy = mSessionState != KSessionState_Closed;
-
-    /* Machine state of the current state item */
-    KMachineState s = KMachineState_Null;
-    if (curStateItem())
-        s = curStateItem()->getCurrentState();
-
-    /* Whether taking or deleting snapshots is possible right now */
-    bool canTakeDeleteSnapshot =    !busy
-                                 || s == KMachineState_PoweredOff
-                                 || s == KMachineState_Saved
-                                 || s == KMachineState_Aborted
-                                 || s == KMachineState_Running
-                                 || s == KMachineState_Paused;
-
-    /* Enable/disable restoring snapshot */
-    mRestoreSnapshotAction->setEnabled (!busy && mCurSnapshotItem && item && !item->isCurrentStateItem());
-
-    /* Enable/disable deleting snapshot */
-    mDeleteSnapshotAction->setEnabled (   canTakeDeleteSnapshot
-                                       && mCurSnapshotItem && item && !item->isCurrentStateItem());
-
-    /* Enable/disable the details action regardles of the session state */
-    mShowSnapshotDetailsAction->setEnabled (mCurSnapshotItem && item && !item->isCurrentStateItem());
-
-    /* Enable/disable taking snapshots */
-    mTakeSnapshotAction->setEnabled (   (   canTakeDeleteSnapshot
-                                         && mCurSnapshotItem && item && item->isCurrentStateItem())
-                                     || (item && !mCurSnapshotItem));
-}
-
-void VBoxSnapshotsWgt::onContextMenuRequested (const QPoint &aPoint)
-{
-    QTreeWidgetItem *item = mTreeWidget->itemAt (aPoint);
-    SnapshotWgtItem *snapshotItem = item ? static_cast <SnapshotWgtItem*> (item) : 0;
-    if (!snapshotItem)
-        return;
-
-    QMenu menu;
-
-    if (mCurSnapshotItem && !snapshotItem->isCurrentStateItem())
-    {
-        menu.addAction (mRestoreSnapshotAction);
-        menu.addAction (mDeleteSnapshotAction);
-        menu.addSeparator();
-        menu.addAction (mShowSnapshotDetailsAction);
-    }
-    else
-        menu.addAction (mTakeSnapshotAction);
-
-    menu.exec (mTreeWidget->viewport()->mapToGlobal (aPoint));
-}
-
-void VBoxSnapshotsWgt::onItemChanged (QTreeWidgetItem *aItem)
-{
-    if (mEditProtector)
-        return;
-
-    SnapshotWgtItem *item = aItem ? static_cast <SnapshotWgtItem*> (aItem) : 0;
-
-    if (item)
-    {
-        CSnapshot snap = item->snapshotId().isNull() ? CSnapshot() : mMachine.GetSnapshot (item->snapshotId());
-        if (!snap.isNull() && snap.isOk() && snap.GetName() != item->text (0))
-            snap.SetName (item->text (0));
-    }
-}
-
-void VBoxSnapshotsWgt::restoreSnapshot()
-{
-    SnapshotWgtItem *item = !mTreeWidget->currentItem() ? 0 :
-        static_cast <SnapshotWgtItem*> (mTreeWidget->currentItem());
-    AssertReturn (item, (void) 0);
-
-    QString snapId = item->snapshotId();
-    AssertReturn (!snapId.isNull(), (void) 0);
-    CSnapshot snapshot = mMachine.GetSnapshot (snapId);
-
-    if (!vboxProblem().askAboutSnapshotRestoring (snapshot.GetName()))
-        return;
-
-    /* Open a direct session (this call will handle all errors) */
-    CSession session = vboxGlobal().openSession (mMachineId);
-    if (session.isNull())
-        return;
-
-    CConsole console = session.GetConsole();
-    CProgress progress = console.RestoreSnapshot (snapshot);
-    if (console.isOk())
-    {
-        /* Show the progress dialog */
-        vboxProblem().showModalProgressDialog (progress, mMachine.GetName(),
-                                               vboxProblem().mainWindowShown());
-
-        if (progress.GetResultCode() != 0)
-            vboxProblem().cannotRestoreSnapshot (progress, snapshot.GetName());
-    }
-    else
-        vboxProblem().cannotRestoreSnapshot (progress, snapshot.GetName());
-
-    session.Close();
-}
-
-void VBoxSnapshotsWgt::deleteSnapshot()
-{
-    SnapshotWgtItem *item = !mTreeWidget->currentItem() ? 0 :
-        static_cast <SnapshotWgtItem*> (mTreeWidget->currentItem());
-    AssertReturn (item, (void) 0);
-
-    QString snapId = item->snapshotId();
-    AssertReturn (!snapId.isNull(), (void) 0);
-    CSnapshot snapshot = mMachine.GetSnapshot (snapId);
-
-    if (!vboxProblem().askAboutSnapshotDeleting (snapshot.GetName()))
-        return;
-
-    /** @todo check available space on the target filesystem etc etc. */
-#if 0
-    if (!vboxProblem().askAboutSnapshotDeletingFreeSpace (snapshot.GetName(),
-                                                          "/home/juser/.VirtualBox/Machines/SampleVM/Snapshots/{01020304-0102-0102-0102-010203040506}.vdi",
-                                                          "59 GiB",
-                                                          "15 GiB"))
-        return;
-#endif
-
-
-    /* Open a direct session (this call will handle all errors) */
-    bool busy = mSessionState != KSessionState_Closed;
-    CSession session = vboxGlobal().openSession (mMachineId, busy /* aExisting */);
-    if (session.isNull())
-        return;
-
-    CConsole console = session.GetConsole();
-    CProgress progress = console.DeleteSnapshot (snapId);
-    if (console.isOk())
-    {
-        /* Show the progress dialog */
-        vboxProblem().showModalProgressDialog (progress, mMachine.GetName(),
-                                               vboxProblem().mainWindowShown());
-
-        if (progress.GetResultCode() != 0)
-            vboxProblem().cannotDeleteSnapshot (progress,  snapshot.GetName());
-    }
-    else
-        vboxProblem().cannotDeleteSnapshot (console,  snapshot.GetName());
-
-    session.Close();
-}
-
-void VBoxSnapshotsWgt::showSnapshotDetails()
-{
-    SnapshotWgtItem *item = !mTreeWidget->currentItem() ? 0 :
-        static_cast <SnapshotWgtItem*> (mTreeWidget->currentItem());
-    AssertReturn (item, (void) 0);
-
-    CSnapshot snap = item->snapshot();
-    AssertReturn (!snap.isNull(), (void) 0);
-
-    CMachine snapMachine = snap.GetMachine();
-
-    VBoxSnapshotDetailsDlg dlg (this);
-    dlg.getFromSnapshot (snap);
-
-    if (dlg.exec() == QDialog::Accepted)
-        dlg.putBackToSnapshot();
-}
-
-void VBoxSnapshotsWgt::takeSnapshot()
-{
-    SnapshotWgtItem *item = !mTreeWidget->currentItem() ? 0 :
-        static_cast <SnapshotWgtItem*> (mTreeWidget->currentItem());
-    AssertReturn (item, (void) 0);
-
-    VBoxTakeSnapshotDlg dlg (this, mMachine);
-
-    QString typeId = mMachine.GetOSTypeId();
-    dlg.mLbIcon->setPixmap (vboxGlobal().vmGuestOSTypeIcon (typeId));
-
-    /* Search for the max available filter index */
-    int maxSnapShotIndex = 0;
-    QString snapShotName = tr ("Snapshot %1");
-    QRegExp regExp (QString ("^") + snapShotName.arg ("([0-9]+)") + QString ("$"));
-    QTreeWidgetItemIterator iterator (mTreeWidget);
-    while (*iterator)
-    {
-        QString snapShot = static_cast <SnapshotWgtItem*> (*iterator)->text (0);
-        int pos = regExp.indexIn (snapShot);
-        if (pos != -1)
-            maxSnapShotIndex = regExp.cap (1).toInt() > maxSnapShotIndex ?
-                               regExp.cap (1).toInt() : maxSnapShotIndex;
-        ++ iterator;
-    }
-    dlg.mLeName->setText (snapShotName.arg (maxSnapShotIndex + 1));
-
-    if (dlg.exec() == QDialog::Accepted)
-    {
-        /* Open a direct session (this call will handle all errors) */
-        bool busy = mSessionState != KSessionState_Closed;
-        CSession session = vboxGlobal().openSession (mMachineId, busy /* aExisting */);
-        if (session.isNull())
-            return;
-
-        CConsole console = session.GetConsole();
-        CProgress progress = console.TakeSnapshot (dlg.mLeName->text().trimmed(),
-                                                   dlg.mTeDescription->toPlainText());
-        if (console.isOk())
-        {
-            /* Show the progress dialog */
-            vboxProblem().showModalProgressDialog (progress, mMachine.GetName(),
-                                                   vboxProblem().mainWindowShown());
-
-            if (progress.GetResultCode() != 0)
-                vboxProblem().cannotTakeSnapshot (progress);
-        }
-        else
-            vboxProblem().cannotTakeSnapshot (console);
-
-        session.Close();
-    }
-}
-
-
-void VBoxSnapshotsWgt::machineDataChanged(QString strId)
-{
-    SnapshotEditBlocker guardBlock (mEditProtector);
-
-    if (strId != mMachineId)
-        return;
-
-    curStateItem()->recache();
-}
-
-void VBoxSnapshotsWgt::machineStateChanged(QString strId, KMachineState state)
-{
-    SnapshotEditBlocker guardBlock (mEditProtector);
-
-    if (strId != mMachineId)
-        return;
-
-    curStateItem()->recache();
-    curStateItem()->updateCurrentState(state);
-}
-
-void VBoxSnapshotsWgt::sessionStateChanged(QString strId, KSessionState state)
-{
-    SnapshotEditBlocker guardBlock (mEditProtector);
-
-    if (strId != mMachineId)
-        return;
-
-    mSessionState = state;
-    onCurrentChanged (mTreeWidget->currentItem());
-}
-
-void VBoxSnapshotsWgt::updateSnapshotsAge()
-{
-    if (mAgeUpdateTimer.isActive())
-        mAgeUpdateTimer.stop();
-
-    SnapshotAgeFormat age = traverseSnapshotAge (mTreeWidget->invisibleRootItem());
-
-    switch (age)
-    {
-        case AgeInSeconds:
-            mAgeUpdateTimer.setInterval (5 * 1000);
-            break;
-        case AgeInMinutes:
-            mAgeUpdateTimer.setInterval (60 * 1000);
-            break;
-        case AgeInHours:
-            mAgeUpdateTimer.setInterval (60 * 60 * 1000);
-            break;
-        case AgeInDays:
-            mAgeUpdateTimer.setInterval (24 * 60 * 60 * 1000);
-            break;
-        default:
-            mAgeUpdateTimer.setInterval (0);
-            break;
-    }
-
-    if (mAgeUpdateTimer.interval() > 0)
-        mAgeUpdateTimer.start();
-}
-
-void VBoxSnapshotsWgt::retranslateUi()
-{
-    /* Translate uic generated strings */
-    Ui::VBoxSnapshotsWgt::retranslateUi (this);
-
-    mRestoreSnapshotAction->setText (tr ("&Restore Snapshot"));
-    mDeleteSnapshotAction->setText (tr ("&Delete Snapshot"));
-    mShowSnapshotDetailsAction->setText (tr ("S&how Details"));
-    mTakeSnapshotAction->setText (tr ("Take &Snapshot"));
-
-    mRestoreSnapshotAction->setStatusTip (tr ("Restore the selected snapshot of the virtual machine"));
-    mDeleteSnapshotAction->setStatusTip (tr ("Delete the selected snapshot of the virtual machine"));
-    mShowSnapshotDetailsAction->setStatusTip (tr ("Show the details of the selected snapshot"));
-    mTakeSnapshotAction->setStatusTip (tr ("Take a snapshot of the current virtual machine state"));
-
-    mRestoreSnapshotAction->setToolTip (mRestoreSnapshotAction->text().remove ('&').remove ('.') +
-        QString (" (%1)").arg (mRestoreSnapshotAction->shortcut().toString()));
-    mDeleteSnapshotAction->setToolTip (mDeleteSnapshotAction->text().remove ('&').remove ('.') +
-        QString (" (%1)").arg (mDeleteSnapshotAction->shortcut().toString()));
-    mShowSnapshotDetailsAction->setToolTip (mShowSnapshotDetailsAction->text().remove ('&').remove ('.') +
-        QString (" (%1)").arg (mShowSnapshotDetailsAction->shortcut().toString()));
-    mTakeSnapshotAction->setToolTip (mTakeSnapshotAction->text().remove ('&').remove ('.') +
-        QString (" (%1)").arg (mTakeSnapshotAction->shortcut().toString()));
-}
-
-void VBoxSnapshotsWgt::refreshAll()
-{
-    SnapshotEditBlocker guardBlock (mEditProtector);
-
-    if (mMachine.isNull())
-    {
-        onCurrentChanged();
-        return;
-    }
-
-    QString selectedItem, firstChildOfSelectedItem;
-    SnapshotWgtItem *cur = !mTreeWidget->currentItem() ? 0 :
-        static_cast <SnapshotWgtItem*> (mTreeWidget->currentItem());
-    if (cur)
-    {
-        selectedItem = cur->snapshotId();
-        if (cur->child (0))
-            firstChildOfSelectedItem = static_cast <SnapshotWgtItem*> (cur->child (0))->snapshotId();
-    }
-
-    mTreeWidget->clear();
-
-    /* Get the first snapshot */
-    if (mMachine.GetSnapshotCount() > 0)
-    {
-        CSnapshot snapshot = mMachine.GetSnapshot (QString::null);
-
-        populateSnapshots (snapshot, 0);
-        Assert (mCurSnapshotItem);
-
-        /* Add the "current state" item */
-        SnapshotWgtItem *csi = new SnapshotWgtItem (mCurSnapshotItem, mMachine);
-        csi->setBold (true);
-        csi->recache();
-
-        SnapshotWgtItem *cur = findItem (selectedItem);
-        if (cur == 0)
-            cur = findItem (firstChildOfSelectedItem);
-        if (cur == 0)
-            cur = curStateItem();
-
-        mTreeWidget->scrollToItem (cur);
-        mTreeWidget->setCurrentItem (cur);
-        onCurrentChanged (cur);
-    }
-    else
-    {
-        mCurSnapshotItem = 0;
-
-        /* Add the "current state" item */
-        SnapshotWgtItem *csi = new SnapshotWgtItem (mTreeWidget, mMachine);
-        csi->setBold (true);
-        csi->recache();
-
-        mTreeWidget->setCurrentItem (csi);
-        onCurrentChanged (csi);
-    }
-
-    /* Updating age */
-    updateSnapshotsAge();
-
-    mTreeWidget->resizeColumnToContents (0);
-}
-
-SnapshotWgtItem* VBoxSnapshotsWgt::findItem (const QString &aSnapshotId)
-{
-    QTreeWidgetItemIterator it (mTreeWidget);
-    while (*it)
-    {
-        SnapshotWgtItem *lvi = static_cast <SnapshotWgtItem*> (*it);
-        if (lvi->snapshotId() == aSnapshotId)
-            return lvi;
-        ++ it;
-    }
-
-    return 0;
-}
-
-SnapshotWgtItem *VBoxSnapshotsWgt::curStateItem()
-{
-    QTreeWidgetItem *csi = mCurSnapshotItem ?
-                           mCurSnapshotItem->child (mCurSnapshotItem->childCount() - 1) :
-                           mTreeWidget->invisibleRootItem()->child (0);
-    return static_cast <SnapshotWgtItem*> (csi);
-}
-
-void VBoxSnapshotsWgt::populateSnapshots (const CSnapshot &aSnapshot, QTreeWidgetItem *aItem)
-{
-    SnapshotWgtItem *item = aItem ? new SnapshotWgtItem (aItem, aSnapshot) :
-                                    new SnapshotWgtItem (mTreeWidget, aSnapshot);
-    item->recache();
-
-    if (mMachine.GetCurrentSnapshot().GetId() == aSnapshot.GetId())
-    {
-        item->setBold (true);
-        mCurSnapshotItem = item;
-    }
-
-    CSnapshotVector snapshots = aSnapshot.GetChildren();
-    foreach (const CSnapshot &snapshot, snapshots)
-        populateSnapshots (snapshot, item);
-
-    item->setExpanded (true);
-    item->setFlags (item->flags() | Qt::ItemIsEditable);
-}
-
-SnapshotAgeFormat VBoxSnapshotsWgt::traverseSnapshotAge (QTreeWidgetItem *aParentItem)
-{
-    SnapshotWgtItem *parentItem = aParentItem->type() == SnapshotWgtItem::ItemType ?
-                                  static_cast <SnapshotWgtItem*> (aParentItem) : 0;
-
-    SnapshotAgeFormat age = parentItem ? parentItem->updateAge() : AgeMax;
-    for (int i = 0; i < aParentItem->childCount(); ++ i)
-    {
-        SnapshotAgeFormat newAge = traverseSnapshotAge (aParentItem->child (i));
-        age = newAge < age ? newAge : age;
-    }
-
-    return age;
-}
-
Index: unk/src/VBox/Frontends/VirtualBox/src/VBoxSnapshotsWgt.h
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/VBoxSnapshotsWgt.h	(revision 30867)
+++ 	(revision )
@@ -1,100 +1,0 @@
-/** @file
- *
- * VBox frontends: Qt4 GUI ("VirtualBox"):
- * VBoxSnapshotsWgt class declaration
- */
-
-/*
- * Copyright (C) 2006-2009 Oracle Corporation
- *
- * This file is part of VirtualBox Open Source Edition (OSE), as
- * available from http://www.virtualbox.org. This file is free software;
- * you can redistribute it and/or modify it under the terms of the GNU
- * General Public License (GPL) as published by the Free Software
- * Foundation, in version 2 as it comes in the "COPYING" file of the
- * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
- * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
- */
-
-#ifndef __VBoxSnapshotsWgt_h__
-#define __VBoxSnapshotsWgt_h__
-
-/* Global includes */
-#include <QTimer>
-
-/* Local includes */
-#include "VBoxSnapshotsWgt.gen.h"
-#include "VBoxGlobal.h"
-#include "QIWithRetranslateUI.h"
-
-/* Local forwards */
-class SnapshotWgtItem;
-
-/* Snapshot age format */
-enum SnapshotAgeFormat
-{
-    AgeInSeconds,
-    AgeInMinutes,
-    AgeInHours,
-    AgeInDays,
-    AgeMax
-};
-
-class VBoxSnapshotsWgt : public QIWithRetranslateUI <QWidget>, public Ui::VBoxSnapshotsWgt
-{
-    Q_OBJECT;
-
-public:
-
-    VBoxSnapshotsWgt (QWidget *aParent);
-
-    void setMachine (const CMachine &aMachine);
-
-protected:
-
-    void retranslateUi();
-
-private slots:
-
-    void onCurrentChanged (QTreeWidgetItem *aItem = 0);
-    void onContextMenuRequested (const QPoint &aPoint);
-    void onItemChanged (QTreeWidgetItem *aItem);
-
-    void restoreSnapshot();
-    void deleteSnapshot();
-    void showSnapshotDetails();
-    void takeSnapshot();
-
-    void machineDataChanged(QString strId);
-    void machineStateChanged(QString strId, KMachineState state);
-    void sessionStateChanged(QString strId, KSessionState state);
-
-    void updateSnapshotsAge();
-
-private:
-
-    void refreshAll();
-    SnapshotWgtItem* findItem (const QString &aSnapshotId);
-    SnapshotWgtItem* curStateItem();
-    void populateSnapshots (const CSnapshot &aSnapshot, QTreeWidgetItem *aItem);
-    SnapshotAgeFormat traverseSnapshotAge (QTreeWidgetItem *aParentItem);
-
-    CMachine         mMachine;
-    QString          mMachineId;
-    KSessionState    mSessionState;
-    SnapshotWgtItem *mCurSnapshotItem;
-    bool             mEditProtector;
-
-    QActionGroup    *mSnapshotActionGroup;
-    QActionGroup    *mCurStateActionGroup;
-
-    QAction         *mRestoreSnapshotAction;
-    QAction         *mDeleteSnapshotAction;
-    QAction         *mShowSnapshotDetailsAction;
-    QAction         *mTakeSnapshotAction;
-
-    QTimer          mAgeUpdateTimer;
-};
-
-#endif // __VBoxSnapshotsWgt_h__
-
Index: unk/src/VBox/Frontends/VirtualBox/src/VBoxSnapshotsWgt.ui
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/VBoxSnapshotsWgt.ui	(revision 30867)
+++ 	(revision )
@@ -1,55 +1,0 @@
-<ui version="4.0" >
- <class>VBoxSnapshotsWgt</class>
- <comment>
- VBox frontends: Qt4 GUI ("VirtualBox"):
-
-     Copyright (C) 2008 Oracle Corporation
-
-     This file is part of VirtualBox Open Source Edition (OSE), as
-     available from http://www.virtualbox.org. This file is free software;
-     you can redistribute it and/or modify it under the terms of the GNU
-     General Public License (GPL) as published by the Free Software
-     Foundation, in version 2 as it comes in the "COPYING" file of the
-     VirtualBox OSE distribution. VirtualBox OSE is distributed in the
-     hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
- </comment>
- <widget class="QWidget" name="VBoxSnapshotsWgt" >
-  <property name="geometry" >
-   <rect>
-    <x>0</x>
-    <y>0</y>
-    <width>400</width>
-    <height>300</height>
-   </rect>
-  </property>
-  <property name="windowTitle" >
-   <string>VBoxSnapshotsWgt</string>
-  </property>
-  <layout class="QVBoxLayout" >
-   <property name="leftMargin" >
-    <number>0</number>
-   </property>
-   <property name="topMargin" >
-    <number>0</number>
-   </property>
-   <property name="rightMargin" >
-    <number>0</number>
-   </property>
-   <property name="bottomMargin" >
-    <number>0</number>
-   </property>
-   <item>
-    <widget class="QTreeWidget" name="mTreeWidget" >
-     <property name="contextMenuPolicy" >
-      <enum>Qt::CustomContextMenu</enum>
-     </property>
-     <property name="allColumnsShowFocus" >
-      <bool>true</bool>
-     </property>
-    </widget>
-   </item>
-  </layout>
- </widget>
- <resources/>
- <connections/>
-</ui>
Index: /trunk/src/VBox/Frontends/VirtualBox/src/extensions/QILabel.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/extensions/QILabel.cpp	(revision 30867)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/extensions/QILabel.cpp	(revision 30868)
@@ -237,4 +237,10 @@
         style()->drawPrimitive (QStyle::PE_FrameFocusRect, &option, &painter, this);
     }
+}
+
+void QILabel::showEvent(QShowEvent *pEvent)
+{
+    QLabel::showEvent(pEvent);
+    emit shown();
 }
 
Index: /trunk/src/VBox/Frontends/VirtualBox/src/extensions/QILabel.h
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/extensions/QILabel.h	(revision 30867)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/extensions/QILabel.h	(revision 30868)
@@ -6,5 +6,5 @@
 
 /*
- * Copyright (C) 2006-2009 Oracle Corporation
+ * Copyright (C) 2006-2010 Oracle Corporation
  *
  * This file is part of VirtualBox Open Source Edition (OSE), as
@@ -48,4 +48,7 @@
     QString text() const;
 
+signals:
+    void shown();
+
 public slots:
 
@@ -64,4 +67,5 @@
     void focusOutEvent (QFocusEvent *aEvent);
     void paintEvent (QPaintEvent *aEvent);
+    void showEvent(QShowEvent *pEvent);
 
 private:
Index: /trunk/src/VBox/Frontends/VirtualBox/src/extensions/QISplitter.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/extensions/QISplitter.cpp	(revision 30867)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/extensions/QISplitter.cpp	(revision 30868)
@@ -18,4 +18,7 @@
  */
 
+/* Local includes */
+#include "QISplitter.h"
+
 /* Global includes */
 #include <QApplication>
@@ -23,7 +26,4 @@
 #include <QPainter>
 #include <QPaintEvent>
-
-/* Local includes */
-#include "QISplitter.h"
 
 /* A simple shaded line. */
@@ -121,5 +121,5 @@
 }
 
-QISplitter::QISplitter(Qt::Orientation orientation /* = Qt::Horizontal */, QWidget *pParent /* = 0 */)
+QISplitter::QISplitter(Qt::Orientation orientation, QWidget *pParent /* = 0 */)
     : QSplitter(orientation, pParent)
     , m_fPolished(false)
Index: /trunk/src/VBox/Frontends/VirtualBox/src/extensions/QISplitter.h
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/extensions/QISplitter.h	(revision 30867)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/extensions/QISplitter.h	(revision 30868)
@@ -32,5 +32,5 @@
 
     QISplitter(QWidget *pParent = 0);
-    QISplitter(Qt::Orientation orientation = Qt::Horizontal, QWidget *pParent = 0);
+    QISplitter(Qt::Orientation orientation, QWidget *pParent = 0);
 
     void setHandleType(Type type) { m_type = type; }
Index: /trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxDefs.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxDefs.cpp	(revision 30867)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxDefs.cpp	(revision 30868)
@@ -44,4 +44,6 @@
 const char* VBoxDefs::GUI_PermanentSharedFoldersAtRuntime = "GUI/PermanentSharedFoldersAtRuntime";
 const char* VBoxDefs::GUI_LanguageId = "GUI/LanguageID";
+const char* VBoxDefs::GUI_PreviewUpdate = "GUI/PreviewUpdate";
+const char* VBoxDefs::GUI_DetailsPageBoxes = "GUI/DetailsPageBoxes";
 #ifdef Q_WS_X11
 const char* VBoxDefs::GUI_LicenseKey = "GUI/LicenseAgreed";
Index: /trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxDefs.h
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxDefs.h	(revision 30867)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxDefs.h	(revision 30868)
@@ -122,4 +122,6 @@
     static const char* GUI_PermanentSharedFoldersAtRuntime;
     static const char* GUI_LanguageId;
+    static const char* GUI_PreviewUpdate;
+    static const char* GUI_DetailsPageBoxes;
 #ifdef Q_WS_X11
     static const char* GUI_LicenseKey;
Index: /trunk/src/VBox/Frontends/VirtualBox/src/selector/UIVMDesktop.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/selector/UIVMDesktop.cpp	(revision 30868)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/selector/UIVMDesktop.cpp	(revision 30868)
@@ -0,0 +1,1410 @@
+/* $Id$ */
+/** @file
+ *
+ * VBox frontends: Qt GUI ("VirtualBox"):
+ * UIVMDesktop class implementation
+ */
+
+/*
+ * Copyright (C) 2010 Oracle Corporation
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ */
+
+/* Local includes */
+#include "QILabel.h"
+#include "UIBar.h"
+#include "UIIconPool.h"
+#include "UIImageTools.h"
+#include "UIPopupBox.h"
+#include "UISpacerWidgets.h"
+#include "UISpecialControls.h"
+#include "UIVMDesktop.h"
+#include "UIVMItem.h"
+#include "UIVMPreviewWindow.h"
+#include "UIVirtualBoxEventHandler.h"
+#include "VBoxSnapshotsWgt.h"
+#include "VBoxToolBar.h"
+
+#include "VBoxUtils.h"
+
+/* Global includes */
+#include <QDir>
+#include <QLabel>
+#include <QScrollArea>
+#include <QStackedLayout>
+#include <QStackedWidget>
+#include <QToolButton>
+#include <QUrl>
+
+#include <iprt/assert.h>
+
+/*
+ * Todo:
+ * - dynamically change size of preview window!
+ */
+
+//#ifdef Q_WS_MAC
+# define DARWIN_USE_TOOLBAR
+//#endif /* Q_WS_MAC */
+
+static const QString sTableTpl =
+"<table border=0 cellspacing=1 cellpadding=0>%1</table>";
+static const QString sSectionItemTpl1 =
+"<tr><td width=40%><nobr><i>%1</i></nobr></td><td/><td/></tr>";
+static const QString sSectionItemTpl2 =
+"<tr><td><nobr>%1:</nobr></td><td/><td>%2</td></tr>";
+//        "<tr><td width=40%><nobr>%1:</nobr></td><td/><td>%2</td></tr>";
+static const QString sSectionItemTpl3 =
+"<tr><td width=40%><nobr>%1</nobr></td><td/><td/></tr>";
+
+#ifdef Q_WS_MAC
+static const int gsLeftMargin = 5;
+static const int gsTopMargin = 5;
+static const int gsRightMargin = 5;
+static const int gsBottomMargin = 5;
+#else /* Q_WS_MAC */
+static const int gsLeftMargin = 0;
+static const int gsTopMargin = 5;
+static const int gsRightMargin = 5;
+static const int gsBottomMargin = 5;
+#endif /* !Q_WS_MAC */
+
+/**
+ *  UIDescriptionPagePrivate
+ */
+class UIDetailsPagePrivate : public QIWithRetranslateUI<QStackedWidget>
+{
+    Q_OBJECT;
+
+    enum Section
+    {
+        GeneralSec,
+        SystemSec,
+        PreviewSec,
+        DisplaySec,
+        StorageSec,
+        AudioSec,
+        NetworkSec,
+        SerialPortsSec,
+#ifdef VBOX_WITH_PARALLEL_PORTS
+        ParallelPortsSec,
+#endif /* VBOX_WITH_PARALLEL_PORTS */
+        USBSec,
+        SharedFoldersSec,
+        EndSec
+    };
+
+public:
+
+    UIDetailsPagePrivate(QWidget *aParent, QAction *aRefreshAction = 0);
+    ~UIDetailsPagePrivate();
+
+    void setMachine(const CMachine& machine);
+
+    void setText(const QString &aText)
+    {
+        m_machine = CMachine();
+        createTextPage();
+        m_pText->setText(aText);
+        setCurrentIndex(indexOf(m_pText));
+    }
+
+    void setErrorText(const QString &aText)
+    {
+        m_machine = CMachine();
+        createErrPage();
+        m_pErrText->setText(aText);
+        setCurrentIndex(indexOf(m_pErrBox));
+    }
+signals:
+
+    void linkClicked(const QString &aURL);
+
+protected:
+
+    void retranslateUi();
+
+private slots:
+
+    void sltUpdateGeneral();
+    void sltUpdatePreview();
+    void sltUpdateSystem();
+    void sltUpdateDisplay();
+    void sltUpdateStorage();
+    void sltUpdateAudio();
+    void sltUpdateNetwork();
+    void sltUpdateSerialPorts();
+#ifdef VBOX_WITH_PARALLEL_PORTS
+    void sltUpdateParallelPorts();
+#endif /* VBOX_WITH_PARALLEL_PORTS */
+    void sltUpdateUSB();
+    void sltUpdateSharedFolders();
+
+    void sltContextMenuRequested(const QPoint &pos);
+
+    void gotLinkClicked(const QUrl &aURL)
+    {
+        emit linkClicked(aURL.toString());
+    }
+
+private:
+
+    void createTextPage();
+    void createErrPage();
+
+    /* Private member vars */
+    CVirtualBox m_vbox;
+    CMachine m_machine;
+
+    /* Details view */
+    QWidget *m_pDetails;
+    QHash<Section, QString> m_EDStrs;
+    QHash<Section, QAction*> m_actions;
+    QHash<Section, UIPopupBox*> m_secBoxes;
+    bool m_fChangeable;
+    bool m_fUSBAvailable;
+
+    /* Free text */
+    QRichTextBrowser *m_pText;
+
+    /* Error text */
+    QWidget *m_pErrBox;
+    QLabel *m_pErrLabel;
+    QTextBrowser *m_pErrText;
+    QToolButton *mRefreshButton;
+    QAction *mRefreshAction;
+};
+
+UIDetailsPagePrivate::UIDetailsPagePrivate(QWidget *aParent,
+                                           QAction *aRefreshAction /* = 0 */)
+    : QIWithRetranslateUI<QStackedWidget>(aParent)
+    , m_vbox(vboxGlobal().virtualBox())
+    , m_fChangeable(false)
+    , m_fUSBAvailable(true)
+    , m_pText(0)
+    , m_pErrBox(0), m_pErrLabel(0), m_pErrText(0)
+    , mRefreshButton(0)
+    , mRefreshAction(aRefreshAction)
+{
+    Assert(mRefreshAction);
+
+    /* The names for the extra data list */
+    m_EDStrs[GeneralSec]       = "general";
+    m_EDStrs[SystemSec]        = "system";
+    m_EDStrs[PreviewSec]       = "preview";
+    m_EDStrs[DisplaySec]       = "display";
+    m_EDStrs[StorageSec]       = "storage";
+    m_EDStrs[AudioSec]         = "audio";
+    m_EDStrs[NetworkSec]       = "network";
+    m_EDStrs[SerialPortsSec]   = "serialPorts";
+#ifdef VBOX_WITH_PARALLEL_PORTS
+    m_EDStrs[ParallelPortsSec] = "parallelPorts";
+#endif /* VBOX_WITH_PARALLEL_PORTS */
+    m_EDStrs[USBSec]           = "usb";
+    m_EDStrs[SharedFoldersSec] = "sharedFolders";
+
+    QScrollArea *pSArea = new QScrollArea(this);
+    pSArea->setFrameStyle(QFrame::NoFrame);
+    m_pDetails = new QWidget(this);
+    QVBoxLayout *pMainLayout = new QVBoxLayout(m_pDetails);
+    pMainLayout->setContentsMargins(gsLeftMargin, gsTopMargin, gsRightMargin, gsBottomMargin);
+
+    /* Create the context menu, which allows showing/hiding of the boxes */
+    m_pDetails->setContextMenuPolicy(Qt::CustomContextMenu);
+    connect(m_pDetails, SIGNAL(customContextMenuRequested(const QPoint&)),
+            this, SLOT(sltContextMenuRequested(const QPoint&)));
+    for(int i = 0; i < EndSec; ++i)
+    {
+        /* Create the context menu actions */
+        QAction *pAction = new QAction(this);
+        pAction->setData(i);
+        pAction->setCheckable(true);
+        m_actions[static_cast<Section>(i)] = pAction;
+
+        /* Create the popup boxes */
+        UIPopupBox *pPopup = new UIPopupBox(this);
+        connect(pPopup, SIGNAL(titleClicked(const QString)),
+                this, SIGNAL(linkClicked(const QString)));
+        pPopup->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
+        m_secBoxes[static_cast<Section>(i)] = pPopup;
+    }
+
+    /* General */
+    {
+        QILabel *pLabel= new QILabel(m_secBoxes.value(GeneralSec));
+        connect(pLabel, SIGNAL(shown()),
+                this, SLOT(sltUpdateGeneral()));
+        m_secBoxes.value(GeneralSec)->setTitleIcon(UIIconPool::iconSet(":/machine_16px.png"));
+        m_secBoxes.value(GeneralSec)->setTitleLink("#general");
+        m_secBoxes.value(GeneralSec)->setContentWidget(pLabel);
+        m_secBoxes.value(GeneralSec)->hide();
+    }
+
+    /* System */
+    {
+        QILabel *pLabel= new QILabel(this);
+        connect(pLabel, SIGNAL(shown()),
+                this, SLOT(sltUpdateSystem()));
+        m_secBoxes.value(SystemSec)->setTitleIcon(UIIconPool::iconSet(":/chipset_16px.png"));
+        m_secBoxes.value(SystemSec)->setTitleLink("#system");
+        m_secBoxes.value(SystemSec)->setContentWidget(pLabel);
+        m_secBoxes.value(SystemSec)->hide();
+    }
+
+    /* Preview */
+    {
+        UIVMPreviewWindow *pWidget = new UIVMPreviewWindow(this);
+        m_secBoxes.value(PreviewSec)->setTitleIcon(UIIconPool::iconSet(":/machine_16px.png"));
+        m_secBoxes.value(PreviewSec)->setContentWidget(pWidget);
+        m_secBoxes.value(PreviewSec)->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
+        /* Make sure the width is always the same, regardless if the preview is
+         * shown or not. */
+        m_secBoxes.value(PreviewSec)->setFixedWidth(m_secBoxes.value(PreviewSec)->sizeHint().width());
+        m_secBoxes.value(PreviewSec)->hide();
+    }
+
+    QHBoxLayout *tt1 = new QHBoxLayout();
+    QVBoxLayout *tt2 = new QVBoxLayout();
+    tt2->addWidget(m_secBoxes.value(GeneralSec));
+    tt2->addWidget(m_secBoxes.value(SystemSec));
+    tt2->addStretch(1);
+    tt1->addLayout(tt2);
+    QVBoxLayout *tt3 = new QVBoxLayout();
+    tt3->addWidget(m_secBoxes.value(PreviewSec));
+    tt3->addStretch(1);
+    tt1->addLayout(tt3);
+    pMainLayout->addLayout(tt1);
+
+    /* Display */
+    {
+        QILabel *pLabel= new QILabel(this);
+        connect(pLabel, SIGNAL(shown()),
+                this, SLOT(sltUpdateDisplay()));
+        m_secBoxes.value(DisplaySec)->setTitleIcon(UIIconPool::iconSet(":/vrdp_16px.png"));
+        m_secBoxes.value(DisplaySec)->setTitleLink("#display");
+        m_secBoxes.value(DisplaySec)->setContentWidget(pLabel);
+        m_secBoxes.value(DisplaySec)->hide();
+        pMainLayout->addWidget(m_secBoxes.value(DisplaySec));
+    }
+
+    /* Storage */
+    {
+        QILabel *pLabel= new QILabel(this);
+        connect(pLabel, SIGNAL(shown()),
+                this, SLOT(sltUpdateStorage()));
+        m_secBoxes.value(StorageSec)->setTitleIcon(UIIconPool::iconSet(":/attachment_16px.png"));
+        m_secBoxes.value(StorageSec)->setTitleLink("#storage");
+        m_secBoxes.value(StorageSec)->setContentWidget(pLabel);
+        m_secBoxes.value(StorageSec)->hide();
+        pMainLayout->addWidget(m_secBoxes.value(StorageSec));
+    }
+
+    /* Audio */
+    {
+        QILabel *pLabel= new QILabel(this);
+        connect(pLabel, SIGNAL(shown()),
+                this, SLOT(sltUpdateAudio()));
+        m_secBoxes.value(AudioSec)->setTitleIcon(UIIconPool::iconSet(":/sound_16px.png"));
+        m_secBoxes.value(AudioSec)->setTitleLink("#audio");
+        m_secBoxes.value(AudioSec)->setContentWidget(pLabel);
+        m_secBoxes.value(AudioSec)->hide();
+        pMainLayout->addWidget(m_secBoxes.value(AudioSec));
+    }
+
+    /* Network */
+    {
+        QILabel *pLabel= new QILabel(this);
+        connect(pLabel, SIGNAL(shown()),
+                this, SLOT(sltUpdateNetwork()));
+        m_secBoxes.value(NetworkSec)->setTitleIcon(UIIconPool::iconSet(":/nw_16px.png"));
+        m_secBoxes.value(NetworkSec)->setTitleLink("#network");
+        m_secBoxes.value(NetworkSec)->setContentWidget(pLabel);
+        m_secBoxes.value(NetworkSec)->hide();
+        pMainLayout->addWidget(m_secBoxes.value(NetworkSec));
+    }
+
+    /* Serial Ports */
+    {
+        QILabel *pLabel= new QILabel(this);
+        connect(pLabel, SIGNAL(shown()),
+                this, SLOT(sltUpdateSerialPorts()));
+        m_secBoxes.value(SerialPortsSec)->setTitleIcon(UIIconPool::iconSet(":/serial_port_16px.png"));
+        m_secBoxes.value(SerialPortsSec)->setTitleLink("#serialPorts");
+        m_secBoxes.value(SerialPortsSec)->setContentWidget(pLabel);
+        m_secBoxes.value(SerialPortsSec)->hide();
+        pMainLayout->addWidget(m_secBoxes.value(SerialPortsSec));
+    }
+
+#ifdef VBOX_WITH_PARALLEL_PORTS
+    /* Parallel Ports */
+    {
+        QILabel *pLabel= new QILabel(this);
+        connect(pLabel, SIGNAL(shown()),
+                this, SLOT(sltUpdateParallelPorts()));
+        m_secBoxes.value(ParallelPortsSec)->setTitleIcon(UIIconPool::iconSet(":/parallel_port_16px.png"));
+        m_secBoxes.value(ParallelPortsSec)->setTitleLink("#parallelPorts");
+        m_secBoxes.value(ParallelPortsSec)->setContentWidget(pLabel);
+        m_secBoxes.value(ParallelPortsSec)->hide();
+        pMainLayout->addWidget(m_secBoxes.value(ParallelPortsSec));
+    }
+#endif /* VBOX_WITH_PARALLEL_PORTS */
+
+    /* USB */
+    {
+        QILabel *pLabel= new QILabel(this);
+        connect(pLabel, SIGNAL(shown()),
+                this, SLOT(sltUpdateUSB()));
+        m_secBoxes.value(USBSec)->setTitleIcon(UIIconPool::iconSet(":/usb_16px.png"));
+        m_secBoxes.value(USBSec)->setTitleLink("#usb");
+        m_secBoxes.value(USBSec)->setContentWidget(pLabel);
+        m_secBoxes.value(USBSec)->hide();
+        pMainLayout->addWidget(m_secBoxes.value(USBSec));
+    }
+
+    /* Shared Folders */
+    {
+        QILabel *pLabel= new QILabel(this);
+        connect(pLabel, SIGNAL(shown()),
+                this, SLOT(sltUpdateSharedFolders()));
+        m_secBoxes.value(SharedFoldersSec)->setTitleIcon(UIIconPool::iconSet(":/shared_folder_16px.png"));
+        m_secBoxes.value(SharedFoldersSec)->setTitleLink("#sfolders");
+        m_secBoxes.value(SharedFoldersSec)->setContentWidget(pLabel);
+        m_secBoxes.value(SharedFoldersSec)->hide();
+        pMainLayout->addWidget(m_secBoxes.value(SharedFoldersSec));
+    }
+
+    pMainLayout->addStretch(1);
+
+    pSArea->setWidget(m_pDetails);
+    pSArea->setWidgetResizable(true);
+    addWidget(pSArea);
+
+    /* Read the configuration from extra data. Defaults are provided in place. */
+    QStringList boxes = vboxGlobal().virtualBox().GetExtraDataStringList(VBoxDefs::GUI_DetailsPageBoxes,
+                                                                         /* Defaults */
+                                                                         QStringList()
+                                                                         << m_EDStrs.value(GeneralSec)
+                                                                         << m_EDStrs.value(SystemSec)
+                                                                         << m_EDStrs.value(PreviewSec)
+                                                                         << m_EDStrs.value(DisplaySec)
+                                                                         << m_EDStrs.value(StorageSec)
+                                                                         << m_EDStrs.value(AudioSec)
+                                                                         << m_EDStrs.value(NetworkSec)
+                                                                         << m_EDStrs.value(USBSec)
+                                                                         << m_EDStrs.value(SharedFoldersSec));
+    for (int i = 0; i < boxes.size(); ++i)
+    {
+        QString strED = boxes.value(i);
+        bool fOpen = !strED.endsWith("Closed");
+        Section sec = m_EDStrs.key(fOpen ? strED : strED.remove("Closed"), EndSec);
+        if (sec != EndSec)
+        {
+            m_actions[sec]->setChecked(true);
+            m_secBoxes.value(sec)->setOpen(fOpen);
+            m_secBoxes.value(sec)->show();
+        }
+    }
+
+    retranslateUi();
+}
+
+UIDetailsPagePrivate::~UIDetailsPagePrivate()
+{
+    /* Save the configuration to extra data at destruction */
+    QStringList boxes;
+    for (int i = 0; i < EndSec; ++i)
+    {
+        if (m_actions[static_cast<Section>(i)]->isChecked())
+        {
+            QString strED = m_EDStrs.value(static_cast<Section>(i));
+            if (!m_secBoxes.value(static_cast<Section>(i))->isOpen())
+                strED += "Closed";
+            boxes << strED;
+        }
+    }
+    vboxGlobal().virtualBox().SetExtraDataStringList(VBoxDefs::GUI_DetailsPageBoxes,
+                                                     boxes);
+}
+
+void UIDetailsPagePrivate::sltUpdateGeneral()
+{
+    m_secBoxes.value(GeneralSec)->setTitleLinkEnabled(m_fChangeable);
+    QILabel *pLabel = qobject_cast<QILabel*>(m_secBoxes.value(GeneralSec)->contentWidget());
+    if (pLabel->isVisible())
+    {
+        if (!m_machine.isNull())
+        {
+            QString item = sSectionItemTpl2.arg(tr("Name", "details report"),
+                                                m_machine.GetName())
+                + sSectionItemTpl2.arg(tr("OS Type", "details report"),
+                                       vboxGlobal().vmGuestOSTypeDescription(m_machine.GetOSTypeId()));
+
+            QString table = sTableTpl.arg(item);
+            pLabel->setText(table);
+
+        }else
+            pLabel->setText("");
+    }
+}
+
+void UIDetailsPagePrivate::sltUpdateSystem()
+{
+    m_secBoxes.value(SystemSec)->setTitleLinkEnabled(m_fChangeable);
+    QILabel *pLabel = qobject_cast<QILabel*>(m_secBoxes.value(SystemSec)->contentWidget());
+    if (pLabel->isVisible())
+    {
+        if (!m_machine.isNull())
+        {
+            QString item = sSectionItemTpl2.arg(tr("Base Memory", "details report"),
+                                                tr("<nobr>%1 MB</nobr>", "details report"))
+                .arg(m_machine.GetMemorySize());
+
+            int cCPU = m_machine.GetCPUCount();
+            if (cCPU > 1)
+                item += sSectionItemTpl2.arg(tr("Processors", "details report"),
+                                             tr("<nobr>%1</nobr>", "details report"))
+                    .arg(cCPU);
+
+            /* Boot order */
+            QStringList bootOrder;
+            for (ulong i = 1; i <= m_vbox.GetSystemProperties().GetMaxBootPosition(); ++i)
+            {
+                KDeviceType device = m_machine.GetBootOrder(i);
+                if (device == KDeviceType_Null)
+                    continue;
+                bootOrder << vboxGlobal().toString(device);
+            }
+            if (bootOrder.isEmpty())
+                bootOrder << vboxGlobal().toString(KDeviceType_Null);
+
+            item += sSectionItemTpl2.arg(tr("Boot Order", "details report"), bootOrder.join(", "));
+
+#ifdef VBOX_WITH_FULL_DETAILS_REPORT
+            /* BIOS Settings holder */
+            const CBIOSSettings &biosSettings = m_machine.GetBIOSSettings();
+            QStringList bios;
+            /* ACPI */
+            if (biosSettings.GetACPIEnabled())
+                bios << tr("ACPI", "details report");
+
+            /* IO APIC */
+            if (biosSettings.GetIOAPICEnabled())
+                bios << tr("IO APIC", "details report");
+
+            if (!bios.isEmpty())
+                item += sSectionItemTpl2.arg(tr("BIOS", "details report"), bios.join(", "));
+#endif /* VBOX_WITH_FULL_DETAILS_REPORT */
+
+            QStringList accel;
+            if (m_vbox.GetHost().GetProcessorFeature(KProcessorFeature_HWVirtEx))
+            {
+
+                /* VT-x/AMD-V */
+                if (m_machine.GetHWVirtExProperty(KHWVirtExPropertyType_Enabled))
+                    accel << tr("VT-x/AMD-V", "details report");
+
+                /* Nested Paging */
+                if (m_machine.GetHWVirtExProperty(KHWVirtExPropertyType_NestedPaging))
+                    accel << tr("Nested Paging", "details report");
+
+            }
+            /* PAE/NX */
+            if (m_machine.GetCPUProperty(KCPUPropertyType_PAE))
+                accel << tr("PAE/NX", "details report");
+
+            if (!accel.isEmpty())
+                item += sSectionItemTpl2.arg(tr("Acceleration", "details report"), accel.join(", "));
+
+            QString table = sTableTpl.arg(item);
+            pLabel->setText(table);
+        } else
+            pLabel->setText("");
+    }
+}
+
+void UIDetailsPagePrivate::sltUpdatePreview()
+{
+    qobject_cast<UIVMPreviewWindow*>(m_secBoxes.value(PreviewSec)->contentWidget())->setMachine(m_machine);
+}
+
+void UIDetailsPagePrivate::sltUpdateDisplay()
+{
+    m_secBoxes.value(DisplaySec)->setTitleLinkEnabled(m_fChangeable);
+    QILabel *pLabel = qobject_cast<QILabel*>(m_secBoxes.value(DisplaySec)->contentWidget());
+    if (pLabel->isVisible())
+    {
+        if (!m_machine.isNull())
+        {
+            /* Video tab */
+            QString item = QString(sSectionItemTpl2)
+                .arg(tr("Video Memory", "details report"),
+                     tr("<nobr>%1 MB</nobr>", "details report"))
+                .arg(m_machine.GetVRAMSize());
+
+            int cGuestScreens = m_machine.GetMonitorCount();
+            if (cGuestScreens > 1)
+            {
+                item += QString(sSectionItemTpl2)
+                    .arg(tr("Screens", "details report"))
+                    .arg(cGuestScreens);
+            }
+
+            QStringList accel;
+#ifdef VBOX_WITH_VIDEOHWACCEL
+            if (m_machine.GetAccelerate2DVideoEnabled())
+                accel << tr("2D Video", "details report");
+#endif /* VBOX_WITH_VIDEOHWACCEL */
+            if (m_machine.GetAccelerate3DEnabled())
+                accel << tr("3D", "details report");
+
+            if (!accel.isEmpty())
+                item += sSectionItemTpl2.arg(tr("Acceleration", "details report"), accel.join(", "));
+
+            /* VRDP tab */
+            const CVRDPServer &srv = m_machine.GetVRDPServer();
+            if (!srv.isNull())
+            {
+                if (srv.GetEnabled())
+                    item += QString(sSectionItemTpl2)
+                        .arg(tr("Remote Display Server Port", "details report (VRDP Server)"))
+                        .arg(srv.GetPorts());
+                else
+                    item += QString(sSectionItemTpl2)
+                        .arg(tr("Remote Display Server", "details report (VRDP Server)"))
+                        .arg(tr("Disabled", "details report (VRDP Server)"));
+            }
+
+            QString table = sTableTpl.arg(item);
+            pLabel->setText(table);
+        } else
+            pLabel->setText("");
+    }
+}
+
+void UIDetailsPagePrivate::sltUpdateStorage()
+{
+    m_secBoxes.value(StorageSec)->setTitleLinkEnabled(m_fChangeable);
+    QILabel *pLabel = qobject_cast<QILabel*>(m_secBoxes.value(StorageSec)->contentWidget());
+    if (pLabel->isVisible())
+    {
+        if (!m_machine.isNull())
+        {
+            QString item;
+            /* Iterate over the all machine controllers: */
+            const CStorageControllerVector &controllers = m_machine.GetStorageControllers();
+            for (int i = 0; i < controllers.size(); ++i)
+            {
+                /* Get current controller: */
+                const CStorageController &controller = controllers[i];
+                /* Add controller information: */
+                item += QString(sSectionItemTpl3).arg(controller.GetName());
+
+                /* Populate sorted map with attachments information: */
+                QMap<StorageSlot,QString> attachmentsMap;
+                const CMediumAttachmentVector &attachments = m_machine.GetMediumAttachmentsOfController(controller.GetName());
+                for (int j = 0; j < attachments.size(); ++j)
+                {
+                    /* Get current attachment: */
+                    const CMediumAttachment &attachment = attachments[j];
+                    /* Prepare current storage slot: */
+                    StorageSlot attachmentSlot(controller.GetBus(), attachment.GetPort(), attachment.GetDevice());
+                    /* Append 'device slot name' with 'device type name' for CD/DVD devices only: */
+                    QString strDeviceType = attachment.GetType() == KDeviceType_DVD ? tr("(CD/DVD)") : QString();
+                    if (!strDeviceType.isNull())
+                        strDeviceType.prepend(' ');
+                    /* Prepare current medium object: */
+                    const CMedium &medium = attachment.GetMedium();
+                    /* Prepare information about current medium & attachment: */
+                    QString strAttachmentInfo = !attachment.isOk() ? QString() :
+                        QString(sSectionItemTpl2)
+                        .arg(QString("&nbsp;&nbsp;") +
+                             vboxGlobal().toString(StorageSlot(controller.GetBus(),
+                                                               attachment.GetPort(),
+                                                               attachment.GetDevice())) + strDeviceType)
+                        .arg(vboxGlobal().details(medium, false));
+                    /* Insert that attachment into map: */
+                    if (!strAttachmentInfo.isNull())
+                        attachmentsMap.insert(attachmentSlot, strAttachmentInfo);
+                }
+
+                /* Iterate over the sorted map with attachments information: */
+                QMapIterator<StorageSlot,QString> it(attachmentsMap);
+                while (it.hasNext())
+                {
+                    /* Add controller information: */
+                    it.next();
+                    item += it.value();
+                }
+            }
+
+            if (item.isNull())
+            {
+                item = QString(sSectionItemTpl1)
+                    .arg(tr("Not Attached", "details report (Storage)"));
+            }
+
+            QString table = sTableTpl.arg(item);
+            pLabel->setText(table);
+        } else
+            pLabel->setText("");
+    }
+}
+
+void UIDetailsPagePrivate::sltUpdateAudio()
+{
+    m_secBoxes.value(AudioSec)->setTitleLinkEnabled(m_fChangeable);
+    QILabel *pLabel = qobject_cast<QILabel*>(m_secBoxes.value(AudioSec)->contentWidget());
+    if (pLabel->isVisible())
+    {
+        if (!m_machine.isNull())
+        {
+            QString item;
+
+            const CAudioAdapter &audio = m_machine.GetAudioAdapter();
+            if (audio.GetEnabled())
+                item = QString(sSectionItemTpl2)
+                    .arg(tr("Host Driver", "details report (audio)"),
+                         vboxGlobal().toString(audio.GetAudioDriver())) +
+                    QString(sSectionItemTpl2)
+                    .arg(tr("Controller", "details report (audio)"),
+                         vboxGlobal().toString(audio.GetAudioController()));
+            else
+                item = QString(sSectionItemTpl1)
+                    .arg(tr("Disabled", "details report (audio)"));
+
+            QString table = sTableTpl.arg(item);
+            pLabel->setText(table);
+        } else
+            pLabel->setText("");
+    }
+}
+
+void UIDetailsPagePrivate::sltUpdateNetwork()
+{
+    m_secBoxes.value(NetworkSec)->setTitleLinkEnabled(m_fChangeable);
+    QILabel *pLabel = qobject_cast<QILabel*>(m_secBoxes.value(NetworkSec)->contentWidget());
+    if (pLabel->isVisible())
+    {
+        if (!m_machine.isNull())
+        {
+            QString item;
+
+            ulong count = m_vbox.GetSystemProperties().GetNetworkAdapterCount();
+            for (ulong slot = 0; slot < count; slot ++)
+            {
+                const CNetworkAdapter &adapter = m_machine.GetNetworkAdapter(slot);
+                if (adapter.GetEnabled())
+                {
+                    KNetworkAttachmentType type = adapter.GetAttachmentType();
+                    QString attType = vboxGlobal().toString(adapter.GetAdapterType())
+                        .replace(QRegExp("\\s\\(.+\\)"), " (%1)");
+                    /* don't use the adapter type string for types that have
+                     * an additional symbolic network/interface name field, use
+                     * this name instead */
+                    if (type == KNetworkAttachmentType_Bridged)
+                        attType = attType.arg(tr("Bridged adapter, %1",
+                                                 "details report (network)").arg(adapter.GetHostInterface()));
+                    else if (type == KNetworkAttachmentType_Internal)
+                        attType = attType.arg(tr("Internal network, '%1'",
+                                                 "details report (network)").arg(adapter.GetInternalNetwork()));
+                    else if (type == KNetworkAttachmentType_HostOnly)
+                        attType = attType.arg(tr("Host-only adapter, '%1'",
+                                                 "details report (network)").arg(adapter.GetHostInterface()));
+#ifdef VBOX_WITH_VDE
+                    else if (type == KNetworkAttachmentType_VDE)
+                        attType = attType.arg(tr("VDE network, '%1'",
+                                                 "details report (network)").arg(adapter.GetVDENetwork()));
+#endif
+                    else
+                        attType = attType.arg(vboxGlobal().toString(type));
+
+                    item += QString(sSectionItemTpl2)
+                        .arg(tr("Adapter %1", "details report (network)")
+                             .arg(adapter.GetSlot() + 1))
+                        .arg(attType);
+                }
+            }
+            if (item.isNull())
+            {
+                item = QString(sSectionItemTpl1)
+                    .arg(tr("Disabled", "details report (network)"));
+            }
+
+            QString table = sTableTpl.arg(item);
+            pLabel->setText(table);
+        } else
+            pLabel->setText("");
+    }
+}
+
+void UIDetailsPagePrivate::sltUpdateSerialPorts()
+{
+    m_secBoxes.value(SerialPortsSec)->setTitleLinkEnabled(m_fChangeable);
+    QILabel *pLabel = qobject_cast<QILabel*>(m_secBoxes.value(SerialPortsSec)->contentWidget());
+    if (pLabel->isVisible())
+    {
+        if (!m_machine.isNull())
+        {
+            QString item;
+
+            ulong count = m_vbox.GetSystemProperties().GetSerialPortCount();
+            for (ulong slot = 0; slot < count; slot ++)
+            {
+                const CSerialPort &port = m_machine.GetSerialPort(slot);
+                if (port.GetEnabled())
+                {
+                    KPortMode mode = port.GetHostMode();
+                    QString data =
+                        vboxGlobal().toCOMPortName(port.GetIRQ(), port.GetIOBase()) + ", ";
+                    if (mode == KPortMode_HostPipe ||
+                        mode == KPortMode_HostDevice ||
+                        mode == KPortMode_RawFile)
+                        data += QString("%1 (<nobr>%2</nobr>)")
+                            .arg(vboxGlobal().toString(mode))
+                            .arg(QDir::toNativeSeparators(port.GetPath()));
+                    else
+                        data += vboxGlobal().toString(mode);
+
+                    item += QString(sSectionItemTpl2)
+                        .arg(tr("Port %1", "details report (serial ports)")
+                             .arg(port.GetSlot() + 1))
+                        .arg(data);
+                }
+            }
+            if (item.isNull())
+            {
+                item = QString(sSectionItemTpl1)
+                    .arg(tr("Disabled", "details report (serial ports)"));
+            }
+
+            QString table = sTableTpl.arg(item);
+            pLabel->setText(table);
+        } else
+            pLabel->setText("");
+    }
+}
+
+#ifdef VBOX_WITH_PARALLEL_PORTS
+void UIDetailsPagePrivate::sltUpdateParallelPorts()
+{
+    m_secBoxes.value(ParallelPortsSec)->setTitleLinkEnabled(m_fChangeable);
+    QILabel *pLabel = qobject_cast<QILabel*>(m_secBoxes.value(ParallelPortsSec)->contentWidget());
+    if (pLabel->isVisible())
+    {
+        if (!m_machine.isNull())
+        {
+            QString item;
+
+            ulong count = m_vbox.GetSystemProperties().GetParallelPortCount();
+            for (ulong slot = 0; slot < count; slot ++)
+            {
+                const CParallelPort &port = m_machine.GetParallelPort(slot);
+                if (port.GetEnabled())
+                {
+                    QString data =
+                        vboxGlobal().toLPTPortName(port.GetIRQ(), port.GetIOBase()) +
+                        QString(" (<nobr>%1</nobr>)")
+                        .arg(QDir::toNativeSeparators(port.GetPath()));
+
+                    item += QString(sSectionItemTpl2)
+                        .arg(tr("Port %1", "details report (parallel ports)")
+                             .arg(port.GetSlot() + 1))
+                        .arg(data);
+                }
+            }
+            if (item.isNull())
+            {
+                item = QString(sSectionItemTpl1)
+                    .arg(tr("Disabled", "details report (parallel ports)"));
+            }
+
+            /* Currently disabled */
+            QString table = sTableTpl.arg(item);
+            pLabel->setText(table);
+        } else
+            pLabel->setText("");
+    }
+}
+#endif /* VBOX_WITH_PARALLEL_PORTS */
+
+void UIDetailsPagePrivate::sltUpdateUSB()
+{
+    m_secBoxes.value(USBSec)->setTitleLinkEnabled(m_fChangeable);
+    QILabel *pLabel = qobject_cast<QILabel*>(m_secBoxes.value(USBSec)->contentWidget());
+    if (pLabel->isVisible())
+    {
+        if (!m_machine.isNull())
+        {
+            QString item;
+
+            const CUSBController &ctl = m_machine.GetUSBController();
+            if (   !ctl.isNull()
+                && ctl.GetProxyAvailable())
+            {
+                m_fUSBAvailable = true;
+                /* the USB controller may be unavailable (i.e. in VirtualBox OSE) */
+                if (ctl.GetEnabled())
+                {
+                    const CUSBDeviceFilterVector &coll = ctl.GetDeviceFilters();
+                    uint active = 0;
+                    for (int i = 0; i < coll.size(); ++i)
+                        if (coll[i].GetActive())
+                            active ++;
+
+                    item = QString(sSectionItemTpl2)
+                        .arg(tr("Device Filters", "details report (USB)"),
+                             tr("%1 (%2 active)", "details report (USB)")
+                             .arg(coll.size()).arg(active));
+                }
+                else
+                    item = QString(sSectionItemTpl1)
+                        .arg(tr("Disabled", "details report (USB)"));
+
+                QString table = sTableTpl.arg(item);
+                pLabel->setText(table);
+            } else
+            {
+                m_fUSBAvailable = false;
+                /* Fully hide when USB is not available */
+                m_secBoxes.value(USBSec)->hide();
+            }
+        } else
+            pLabel->setText("");
+    }
+}
+
+void UIDetailsPagePrivate::sltUpdateSharedFolders()
+{
+    m_secBoxes.value(SharedFoldersSec)->setTitleLinkEnabled(m_fChangeable);
+    QILabel *pLabel = qobject_cast<QILabel*>(m_secBoxes.value(SharedFoldersSec)->contentWidget());
+    if (pLabel->isVisible())
+    {
+        if (!m_machine.isNull())
+        {
+            QString item;
+
+            ulong count = m_machine.GetSharedFolders().size();
+            if (count > 0)
+            {
+                item = QString(sSectionItemTpl2)
+                    .arg(tr("Shared Folders", "details report (shared folders)"))
+                    .arg(count);
+            }
+            else
+                item = QString(sSectionItemTpl1)
+                    .arg(tr("None", "details report (shared folders)"));
+
+            QString table = sTableTpl.arg(item);
+            pLabel->setText(table);
+        } else
+            pLabel->setText("");
+    }
+}
+
+void UIDetailsPagePrivate::sltContextMenuRequested(const QPoint &pos)
+{
+    QList<QAction*> actions = m_actions.values();
+    if (!m_fUSBAvailable)
+        actions.removeOne(m_actions.value(USBSec));
+    QAction *pReturn = QMenu::exec(actions, m_pDetails->mapToGlobal(pos), 0, this);
+    if (pReturn)
+    {
+        UIPopupBox *pBox = m_secBoxes.value(static_cast<Section>(pReturn->data().toInt()));
+        if (pReturn->isChecked())
+            pBox->show();
+        else
+            pBox->hide();
+    }
+}
+
+void UIDetailsPagePrivate::setMachine(const CMachine& machine)
+{
+    m_machine = machine;
+    if (m_machine.isNull())
+        m_fChangeable = false;
+    else
+    {
+        KMachineState state = m_machine.GetState();
+        bool running = m_machine.GetSessionState() != KSessionState_Closed;
+        m_fChangeable = !running && state != KMachineState_Saved;
+    }
+
+    sltUpdateGeneral();
+    sltUpdateSystem();
+    sltUpdatePreview();
+    sltUpdateDisplay();
+    sltUpdateStorage();
+    sltUpdateAudio();
+    sltUpdateNetwork();
+    sltUpdateSerialPorts();
+#ifdef VBOX_WITH_PARALLEL_PORTS
+    sltUpdateParallelPorts();
+#endif /* VBOX_WITH_PARALLEL_PORTS */
+    sltUpdateUSB();
+    sltUpdateSharedFolders();
+
+    setCurrentIndex(0);
+}
+
+void UIDetailsPagePrivate::createTextPage()
+{
+    if (m_pText)
+        return;
+
+    /* Create normal text page */
+    m_pText = new QRichTextBrowser(this);
+    m_pText->setFocusPolicy(Qt::StrongFocus);
+    m_pText->document()->setDefaultStyleSheet("a { text-decoration: none; }");
+    /* Make "transparent" */
+    m_pText->setFrameShape(QFrame::NoFrame);
+    m_pText->viewport()->setAutoFillBackground(false);
+    m_pText->setOpenLinks(false);
+
+    connect(m_pText, SIGNAL(anchorClicked(const QUrl &)),
+            this, SLOT(gotLinkClicked(const QUrl &)));
+
+    addWidget(m_pText);
+}
+
+void UIDetailsPagePrivate::createErrPage()
+{
+    if (m_pErrBox)
+        return;
+
+    /* Create inaccessible details page */
+    m_pErrBox = new QWidget();
+
+    QVBoxLayout *vLayout = new QVBoxLayout(m_pErrBox);
+    vLayout->setSpacing(10);
+    vLayout->setContentsMargins(gsLeftMargin, gsTopMargin, gsRightMargin, gsBottomMargin);
+
+    m_pErrLabel = new QLabel(m_pErrBox);
+    m_pErrLabel->setWordWrap(true);
+    m_pErrLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
+    vLayout->addWidget(m_pErrLabel);
+
+    m_pErrText = new QTextBrowser(m_pErrBox);
+    m_pErrText->setFocusPolicy(Qt::StrongFocus);
+    m_pErrText->document()->setDefaultStyleSheet("a { text-decoration: none; }");
+    vLayout->addWidget(m_pErrText);
+
+    if (mRefreshAction)
+    {
+        mRefreshButton = new QToolButton(m_pErrBox);
+        mRefreshButton->setFocusPolicy(Qt::StrongFocus);
+
+        QHBoxLayout *hLayout = new QHBoxLayout();
+        vLayout->addLayout(hLayout);
+        hLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding,
+                                                 QSizePolicy::Minimum));
+        hLayout->addWidget(mRefreshButton);
+
+        connect(mRefreshButton, SIGNAL(clicked()),
+                mRefreshAction, SIGNAL(triggered()));
+    }
+
+    vLayout->addItem(new QSpacerItem(0, 0,
+                                     QSizePolicy::Minimum,
+                                     QSizePolicy::Expanding));
+
+    addWidget(m_pErrBox);
+
+    retranslateUi();
+}
+
+void UIDetailsPagePrivate::retranslateUi()
+{
+    if (m_pErrLabel)
+        m_pErrLabel->setText(tr(
+            "The selected virtual machine is <i>inaccessible</i>. Please "
+            "inspect the error message shown below and press the "
+            "<b>Refresh</b> button if you want to repeat the accessibility "
+            "check:"));
+
+    if (mRefreshAction && mRefreshButton)
+    {
+        mRefreshButton->setText(mRefreshAction->text());
+        mRefreshButton->setIcon(mRefreshAction->icon());
+        mRefreshButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
+    }
+
+    /* General */
+    {
+        m_secBoxes.value(GeneralSec)->setTitle(tr("General", "details report"));
+        m_actions.value(GeneralSec)->setText(m_secBoxes.value(GeneralSec)->title());
+    }
+
+    /* System */
+    {
+        m_secBoxes.value(SystemSec)->setTitle(tr("System", "details report"));
+        m_actions.value(SystemSec)->setText(m_secBoxes.value(SystemSec)->title());
+    }
+
+    /* Preview */
+    {
+        m_secBoxes.value(PreviewSec)->setTitle(tr("Preview", "details report"));
+        m_actions.value(PreviewSec)->setText(m_secBoxes.value(PreviewSec)->title());
+    }
+
+    /* Display */
+    {
+        m_secBoxes.value(DisplaySec)->setTitle(tr("Display", "details report"));
+        m_actions.value(DisplaySec)->setText(m_secBoxes.value(DisplaySec)->title());
+    }
+
+    /* Storage */
+    {
+        m_secBoxes.value(StorageSec)->setTitle(tr("Storage", "details report"));
+        m_actions.value(StorageSec)->setText(m_secBoxes.value(StorageSec)->title());
+    }
+
+    /* Audio */
+    {
+        m_secBoxes.value(AudioSec)->setTitle(tr("Audio", "details report"));
+        m_actions.value(AudioSec)->setText(m_secBoxes.value(AudioSec)->title());
+    }
+
+    /* Network */
+    {
+        m_secBoxes.value(NetworkSec)->setTitle(tr("Network", "details report"));
+        m_actions.value(NetworkSec)->setText(m_secBoxes.value(NetworkSec)->title());
+    }
+
+    /* Serial Ports */
+    {
+        m_secBoxes.value(SerialPortsSec)->setTitle(tr("Serial Ports", "details report"));
+        m_actions.value(SerialPortsSec)->setText(m_secBoxes.value(SerialPortsSec)->title());
+    }
+
+#ifdef VBOX_WITH_PARALLEL_PORTS
+    /* Parallel Ports */
+    {
+        m_secBoxes.value(ParallelPortsSec)->setTitle(tr("Parallel Ports", "details report"));
+        m_actions.value(ParallelPortsSec)->setText(m_secBoxes.value(ParallelPortsSec)->title());
+    }
+#endif /* VBOX_WITH_PARALLEL_PORTS */
+
+    /* USB */
+    {
+        m_secBoxes.value(USBSec)->setTitle(tr("USB", "details report"));
+        m_actions.value(USBSec)->setText(m_secBoxes.value(USBSec)->title());
+    }
+
+    /* Shared Folders */
+    {
+        m_secBoxes.value(SharedFoldersSec)->setTitle(tr("Shared Folders", "details report"));
+        m_actions.value(SharedFoldersSec)->setText(m_secBoxes.value(SharedFoldersSec)->title());
+    }
+}
+
+/**
+ *  UIDescriptionPagePrivate
+ */
+class UIDescriptionPagePrivate : public QIWithRetranslateUI<QWidget>
+{
+    Q_OBJECT;
+
+public:
+
+    UIDescriptionPagePrivate(QWidget *pParent = 0);
+    ~UIDescriptionPagePrivate() {}
+
+    void setMachineItem(UIVMItem *pVMItem);
+
+    void updateState();
+
+signals:
+
+    void linkClicked(const QString &aURL);
+
+protected:
+
+    void retranslateUi();
+
+private slots:
+
+    void goToSettings();
+
+private:
+
+    UIVMItem *m_pVMItem;
+
+    QToolButton *m_pEditBtn;
+    QTextBrowser *m_pBrowser;
+    QLabel *m_pLabel;
+};
+
+UIDescriptionPagePrivate::UIDescriptionPagePrivate(QWidget *pParent /* = 0 */)
+    : QIWithRetranslateUI<QWidget>(pParent)
+    , m_pVMItem(0)
+    , m_pEditBtn(0)
+    , m_pBrowser(0)
+    , m_pLabel(0)
+{
+    /* Main layout */
+    QVBoxLayout *pMainLayout = new QVBoxLayout(this);
+    pMainLayout->setSpacing(10);
+    VBoxGlobal::setLayoutMargin(pMainLayout, 0);
+
+    /* m_pBrowser */
+    m_pBrowser = new QTextBrowser(this);
+    m_pBrowser->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
+    m_pBrowser->setFocusPolicy(Qt::StrongFocus);
+    m_pBrowser->document()->setDefaultStyleSheet("a { text-decoration: none; }");
+    pMainLayout->addWidget(m_pBrowser);
+    /* hidden by default */
+    m_pBrowser->setHidden(true);
+
+    m_pLabel = new QLabel(this);
+    m_pLabel->setFrameStyle(m_pBrowser->frameStyle());
+    m_pLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
+    m_pLabel->setAlignment(Qt::AlignCenter);
+    m_pLabel->setWordWrap(true);
+    pMainLayout->addWidget(m_pLabel);
+    /* always disabled */
+    m_pLabel->setEnabled(false);
+
+    /* button layout */
+    QHBoxLayout *hBtnLayout = new QHBoxLayout();
+    pMainLayout->addLayout(hBtnLayout);
+    hBtnLayout->setSpacing(10);
+    hBtnLayout->addItem(new QSpacerItem(0, 0,
+                                        QSizePolicy::Expanding,
+                                        QSizePolicy::Minimum));
+
+    /* button */
+    m_pEditBtn = new QToolButton(this);
+    m_pEditBtn->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
+    m_pEditBtn->setFocusPolicy(Qt::StrongFocus);
+    m_pEditBtn->setIcon(UIIconPool::iconSet(":/edit_description_16px.png",
+                                            ":/edit_description_disabled_16px.png"));
+    m_pEditBtn->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
+    connect(m_pEditBtn, SIGNAL(clicked()), this, SLOT(goToSettings()));
+    hBtnLayout->addWidget(m_pEditBtn);
+
+    pMainLayout->addItem(new QSpacerItem(0, 0,
+                                         QSizePolicy::Expanding,
+                                         QSizePolicy::Minimum));
+
+    /* apply language settings */
+    retranslateUi();
+
+    updateState();
+}
+
+/**
+ * The machine list @a pVMItem is used to access cached machine data w/o making
+ * unnecessary RPC calls.
+ */
+void UIDescriptionPagePrivate::setMachineItem(UIVMItem *pVMItem)
+{
+    m_pVMItem = pVMItem;
+
+    QString text = pVMItem ? pVMItem->machine().GetDescription() : QString::null;
+
+    if (!text.isEmpty())
+    {
+        m_pLabel->setHidden(true);
+        m_pBrowser->setText(text);
+        m_pBrowser->setVisible(true);
+    }
+    else
+    {
+        m_pBrowser->setHidden(true);
+        m_pBrowser->clear();
+        m_pLabel->setVisible(true);
+    }
+
+    /* check initial machine and session states */
+    updateState();
+}
+
+void UIDescriptionPagePrivate::retranslateUi()
+{
+    m_pLabel->setText(tr("No description. Press the Edit button below to add it."));
+
+    m_pEditBtn->setText(tr("Edit"));
+    m_pEditBtn->setShortcut(QKeySequence("Ctrl+E"));
+    m_pEditBtn->setToolTip(tr("Edit (Ctrl+E)"));
+    m_pEditBtn->adjustSize();
+    m_pEditBtn->updateGeometry();
+}
+
+/**
+ * Called by the parent from machineStateChanged() and sessionStateChanged()
+ * signal handlers. We cannot connect to these signals ourselves because we
+ * use the UIVMListBoxItem which needs to be properly updated by the parent
+ * first.
+ */
+void UIDescriptionPagePrivate::updateState()
+{
+    /// @todo disabling the edit button for a saved VM will not be necessary
+    /// when we implement the selective VM Settings dialog, where only fields
+    /// that can be changed in the saved state, can be changed.
+
+    if (m_pVMItem)
+    {
+        bool saved = m_pVMItem->state() == KMachineState_Saved;
+        bool busy = m_pVMItem->sessionState() != KSessionState_Closed;
+        m_pEditBtn->setEnabled(!saved && !busy);
+    }
+    else
+        m_pEditBtn->setEnabled(false);
+}
+
+void UIDescriptionPagePrivate::goToSettings()
+{
+    emit linkClicked("#general%%mTeDescription");
+}
+
+/**
+ *  UIVMDesktop
+ */
+enum
+{
+    Dtls = 0,
+    Snap,
+    Desc
+};
+
+UIVMDesktop::UIVMDesktop(VBoxToolBar *pToolBar, QAction *pRefreshAction, QWidget *pParent /* = 0 */)
+  : QIWithRetranslateUI<QWidget>(pParent)
+{
+    m_pHeaderBtn = new UITexturedSegmentedButton(3);
+    m_pHeaderBtn->setIcon(Dtls, UIIconPool::iconSet(":/settings_16px.png"));
+    m_pHeaderBtn->setIcon(Snap, UIIconPool::iconSet(":/take_snapshot_16px.png",
+                                                    ":/take_snapshot_dis_16px.png"));
+    m_pHeaderBtn->setIcon(Desc, UIIconPool::iconSet(":/description_16px.png",
+                                                    ":/description_disabled_16px.png"));
+    m_pHeaderBtn->animateClick(0);
+
+    QVBoxLayout *pMainLayout = new QVBoxLayout(this);
+    pMainLayout->setContentsMargins(0, 0, 0, 0);
+
+    /* The header to select the different pages. Has different styles on the
+     * different platforms. */
+#ifdef DARWIN_USE_TOOLBAR
+    if (pToolBar)
+    {
+        pToolBar->addWidget(new UIHorizontalSpacerWidget(this));
+        pToolBar->addWidget(m_pHeaderBtn);
+        pToolBar->addWidget(new UIHorizontalSpacerWidget(this));
+        pToolBar->updateLayout();
+    } else
+#else /* DARWIN_USE_TOOLBAR */
+        NOREF(pToolBar);
+#endif /* !DARWIN_USE_TOOLBAR */
+    {
+        UIBar *pBar = new UIBar(this);
+#ifndef Q_WS_MAC
+//        pBar->setFixedHeight(65);
+#endif /* !Q_WS_MAC */
+        pBar->setContentWidget(m_pHeaderBtn);
+        pMainLayout->addWidget(pBar);
+    }
+
+    /* Add the pages */
+    QStackedLayout *pStack = new QStackedLayout(pMainLayout);
+
+    m_pDetails = new UIDetailsPagePrivate(this, pRefreshAction);
+    connect(m_pDetails, SIGNAL(linkClicked(const QString&)),
+            this, SIGNAL(linkClicked(const QString&)));
+    pStack->addWidget(m_pDetails);
+    m_pSnapshotsPage = new VBoxSnapshotsWgt(this);
+    m_pSnapshotsPage->setContentsMargins(gsLeftMargin, gsTopMargin, gsRightMargin, gsBottomMargin);
+    pStack->addWidget(m_pSnapshotsPage);
+    m_pDescription = new UIDescriptionPagePrivate(this);
+    connect(m_pDescription, SIGNAL(linkClicked(const QString&)),
+            this, SIGNAL(linkClicked(const QString&)));
+    m_pDescription->setContentsMargins(gsLeftMargin, gsTopMargin, gsRightMargin, gsBottomMargin);
+    pStack->addWidget(m_pDescription);
+
+    /* Connect the header buttons with the stack layout. */
+    connect(m_pHeaderBtn, SIGNAL(clicked(int)),
+            pStack, SLOT(setCurrentIndex(int)));
+
+    retranslateUi();
+}
+
+void UIVMDesktop::retranslateUi()
+{
+    m_pHeaderBtn->setTitle(Dtls, tr("&Details"));
+}
+
+void UIVMDesktop::updateDetails(UIVMItem * /* pVMItem */, const CMachine& machine)
+{
+//    KMachineState state = pVMItem->state();
+//    bool fRunning = pVMItem->sessionState() != KSessionState_Closed;
+//    bool fModifyEnabled = !fRunning && state != KMachineState_Saved;
+    m_pDetails->setMachine(machine);
+}
+
+void UIVMDesktop::updateDetailsText(const QString &strText)
+{
+    m_pDetails->setText(strText);
+}
+
+void UIVMDesktop::updateDetailsErrorText(const QString &strText)
+{
+    m_pDetails->setErrorText(strText);
+}
+
+void UIVMDesktop::updateSnapshots(UIVMItem *pVMItem, const CMachine& machine)
+{
+    /* Update the snapshots header name */
+    QString name = tr("&Snapshots");
+    if (pVMItem)
+    {
+        ULONG count = pVMItem->snapshotCount();
+        if (count)
+            name += QString(" (%1)").arg(count);
+    }
+    m_pHeaderBtn->setTitle(Snap, name);
+    /* Refresh the snapshots widget */
+    if (!machine.isNull())
+    {
+        m_pHeaderBtn->setEnabled(Snap, true);
+        m_pSnapshotsPage->setMachine(machine);
+    } else
+    {
+        m_pHeaderBtn->animateClick(Dtls);
+        m_pHeaderBtn->setEnabled(Snap, false);
+    }
+}
+
+void UIVMDesktop::updateDescription(UIVMItem *pVMItem, const CMachine& machine)
+{
+    /* Update the description header name */
+    QString name = tr("D&escription");
+    if (pVMItem)
+    {
+         if(!machine.GetDescription().isEmpty())
+             name += " *";
+    }
+    m_pHeaderBtn->setTitle(Desc, name);
+    /* refresh the description widget */
+    if (!machine.isNull())
+    {
+        m_pHeaderBtn->setEnabled(Desc, true);
+        m_pDescription->setMachineItem(pVMItem);
+    } else
+    {
+        m_pHeaderBtn->animateClick(Dtls);
+        m_pHeaderBtn->setEnabled(Desc, false);
+    }
+}
+
+void UIVMDesktop::updateDescriptionState()
+{
+    m_pDescription->updateState();
+}
+
+#include "UIVMDesktop.moc"
+
Index: /trunk/src/VBox/Frontends/VirtualBox/src/selector/UIVMDesktop.h
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/selector/UIVMDesktop.h	(revision 30868)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/selector/UIVMDesktop.h	(revision 30868)
@@ -0,0 +1,71 @@
+/** @file
+ *
+ * VBox frontends: Qt GUI ("VirtualBox"):
+ * UIVMDesktop class declarations
+ */
+
+/*
+ * Copyright (C) 2010 Oracle Corporation
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ */
+
+#ifndef __UIVMDesktop_h__
+#define __UIVMDesktop_h__
+
+/* Local includes */
+#include "QIWithRetranslateUI.h"
+
+/* Global includes */
+#include <QWidget>
+
+/* Local forward declarations */
+class CMachine;
+class UIDescriptionPagePrivate;
+class UIDetailsPagePrivate;
+class UITexturedSegmentedButton;
+class UIVMItem;
+class VBoxSnapshotsWgt;
+class VBoxToolBar;
+
+class UIVMDesktop: public QIWithRetranslateUI<QWidget>
+{
+    Q_OBJECT;
+
+public:
+
+    UIVMDesktop(VBoxToolBar *pToolBar, QAction *pRefreshAction, QWidget *pParent = 0);
+
+    void updateDetails(UIVMItem *pVMItem, const CMachine& machine);
+    void updateDetailsText(const QString &strText);
+    void updateDetailsErrorText(const QString &strText);
+
+    void updateSnapshots(UIVMItem *pVMItem, const CMachine& machine);
+    void updateDescription(UIVMItem *pVMItem, const CMachine& machine);
+    void updateDescriptionState();
+
+signals:
+
+    void linkClicked(const QString &strURL);
+
+protected:
+
+    void retranslateUi();
+
+private:
+
+    /* Private member vars */
+    UITexturedSegmentedButton *m_pHeaderBtn;
+    UIDetailsPagePrivate *m_pDetails;
+    VBoxSnapshotsWgt *m_pSnapshotsPage;
+    UIDescriptionPagePrivate *m_pDescription;
+};
+
+#endif /* !__UIVMDesktop_h__ */
+
Index: /trunk/src/VBox/Frontends/VirtualBox/src/selector/UIVMItem.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/selector/UIVMItem.cpp	(revision 30868)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/selector/UIVMItem.cpp	(revision 30868)
@@ -0,0 +1,394 @@
+/* $Id$ */
+/** @file
+ *
+ * VBox frontends: Qt GUI ("VirtualBox"):
+ * UIVMItem class implementation
+ */
+
+/*
+ * Copyright (C) 2006-2010 Oracle Corporation
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ */
+
+#ifdef VBOX_WITH_PRECOMPILED_HEADERS
+# include "precomp.h"
+#else  /* !VBOX_WITH_PRECOMPILED_HEADERS */
+
+/* Local includes */
+#include "UIVMItem.h"
+
+/* Qt includes */
+#include <QFileInfo>
+
+#ifdef Q_WS_MAC
+//# include "VBoxUtils.h"
+# include <ApplicationServices/ApplicationServices.h>
+#endif /* Q_WS_MAC */
+
+#endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
+
+// Helpers
+////////////////////////////////////////////////////////////////////////////////
+
+/// @todo Remove. See @c todo in #switchTo() below.
+#if 0
+
+#if defined (Q_WS_WIN32)
+
+struct EnumWindowsProcData
+{
+    ULONG pid;
+    WId wid;
+};
+
+BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lParam)
+{
+    EnumWindowsProcData *d = (EnumWindowsProcData *) lParam;
+
+    DWORD pid = 0;
+    GetWindowThreadProcessId(hwnd, &pid);
+
+    if (d->pid == pid)
+    {
+        WINDOWINFO info;
+        if (!GetWindowInfo(hwnd, &info))
+            return TRUE;
+
+#if 0
+        LogFlowFunc(("pid=%d, wid=%08X\n", pid, hwnd));
+        LogFlowFunc(("  parent=%08X\n", GetParent(hwnd)));
+        LogFlowFunc(("  owner=%08X\n", GetWindow(hwnd, GW_OWNER)));
+        TCHAR buf [256];
+        LogFlowFunc(("  rcWindow=%d,%d;%d,%d\n",
+                      info.rcWindow.left, info.rcWindow.top,
+                      info.rcWindow.right, info.rcWindow.bottom));
+        LogFlowFunc(("  dwStyle=%08X\n", info.dwStyle));
+        LogFlowFunc(("  dwExStyle=%08X\n", info.dwExStyle));
+        GetClassName(hwnd, buf, 256);
+        LogFlowFunc(("  class=%ls\n", buf));
+        GetWindowText(hwnd, buf, 256);
+        LogFlowFunc(("  text=%ls\n", buf));
+#endif
+
+        /* we are interested in unowned top-level windows only */
+        if (!(info.dwStyle & (WS_CHILD | WS_POPUP)) &&
+            info.rcWindow.left < info.rcWindow.right &&
+            info.rcWindow.top < info.rcWindow.bottom &&
+            GetParent(hwnd) == NULL &&
+            GetWindow(hwnd, GW_OWNER) == NULL)
+        {
+            d->wid = hwnd;
+            /* if visible, stop the search immediately */
+            if (info.dwStyle & WS_VISIBLE)
+                return FALSE;
+            /* otherwise, give other top-level windows a chance
+             * (the last one wins) */
+        }
+    }
+
+    return TRUE;
+}
+
+#endif
+
+/**
+ * Searches for a main window of the given process.
+ *
+ * @param aPid process ID to search for
+ *
+ * @return window ID on success or <tt>(WId) ~0</tt> otherwise.
+ */
+static WId FindWindowIdFromPid(ULONG aPid)
+{
+#if defined (Q_WS_WIN32)
+
+    EnumWindowsProcData d = { aPid, (WId) ~0 };
+    EnumWindows(EnumWindowsProc, (LPARAM) &d);
+    LogFlowFunc(("SELECTED wid=%08X\n", d.wid));
+    return d.wid;
+
+#elif defined (Q_WS_X11)
+
+    NOREF(aPid);
+    return (WId) ~0;
+
+#elif defined (Q_WS_MAC)
+
+    /** @todo Figure out how to get access to another windows of another process...
+     * Or at least check that it's not a VBoxVRDP process. */
+    NOREF (aPid);
+    return (WId) 0;
+
+#else
+
+    return (WId) ~0;
+
+#endif
+}
+
+#endif
+
+UIVMItem::UIVMItem(const CMachine &aMachine)
+    : m_machine(aMachine)
+{
+    recache();
+}
+
+UIVMItem::~UIVMItem()
+{
+}
+
+// public members
+////////////////////////////////////////////////////////////////////////////////
+
+QString UIVMItem::sessionStateName() const
+{
+    return m_fAccessible ? vboxGlobal().toString(m_state) :
+           QApplication::translate("UIVMListView", "Inaccessible");
+}
+
+QString UIVMItem::toolTipText() const
+{
+    QString dateTime = (m_lastStateChange.date() == QDate::currentDate()) ?
+                        m_lastStateChange.time().toString(Qt::LocalDate) :
+                        m_lastStateChange.toString(Qt::LocalDate);
+
+    QString toolTip;
+
+    if (m_fAccessible)
+    {
+        toolTip = QString("<b>%1</b>").arg(m_strName);
+        if (!m_strSnapshotName.isNull())
+            toolTip += QString(" (%1)").arg(m_strSnapshotName);
+        toolTip = QApplication::translate("UIVMListView",
+            "<nobr>%1<br></nobr>"
+            "<nobr>%2 since %3</nobr><br>"
+            "<nobr>Session %4</nobr>",
+            "VM tooltip (name, last state change, session state)")
+            .arg(toolTip)
+            .arg(vboxGlobal().toString(m_state))
+            .arg(dateTime)
+            .arg(vboxGlobal().toString(m_sessionState));
+    }
+    else
+    {
+        toolTip = QApplication::translate("UIVMListView",
+            "<nobr><b>%1</b><br></nobr>"
+            "<nobr>Inaccessible since %2</nobr>",
+            "Inaccessible VM tooltip (name, last state change)")
+            .arg(m_strSettingsFile)
+            .arg(dateTime);
+    }
+
+    return toolTip;
+}
+
+bool UIVMItem::recache()
+{
+    bool needsResort = true;
+
+    m_strId = m_machine.GetId();
+    m_strSettingsFile = m_machine.GetSettingsFilePath();
+
+    m_fAccessible = m_machine.GetAccessible();
+    if (m_fAccessible)
+    {
+        QString name = m_machine.GetName();
+
+        CSnapshot snp = m_machine.GetCurrentSnapshot();
+        m_strSnapshotName = snp.isNull() ? QString::null : snp.GetName();
+        needsResort = name != m_strName;
+        m_strName = name;
+
+        m_state = m_machine.GetState();
+        m_lastStateChange.setTime_t(m_machine.GetLastStateChange() / 1000);
+        m_sessionState = m_machine.GetSessionState();
+        m_strOSTypeId = m_machine.GetOSTypeId();
+        m_cSnaphot = m_machine.GetSnapshotCount();
+
+        if (   m_state == KMachineState_PoweredOff
+            || m_state == KMachineState_Saved
+            || m_state == KMachineState_Teleported
+            || m_state == KMachineState_Aborted
+           )
+        {
+            m_pid = (ULONG) ~0;
+    /// @todo Remove. See @c todo in #switchTo() below.
+#if 0
+            mWinId = (WId) ~0;
+#endif
+        }
+        else
+        {
+            m_pid = m_machine.GetSessionPid();
+    /// @todo Remove. See @c todo in #switchTo() below.
+#if 0
+            mWinId = FindWindowIdFromPid(m_pid);
+#endif
+        }
+    }
+    else
+    {
+        m_accessError = m_machine.GetAccessError();
+
+        /* this should be in sync with
+         * VBoxProblemReporter::confirm_machineDeletion() */
+        QFileInfo fi(m_strSettingsFile);
+        QString name = fi.completeSuffix().toLower() == "xml" ?
+                       fi.completeBaseName() : fi.fileName();
+        needsResort = name != m_strName;
+        m_strName = name;
+        m_state = KMachineState_Null;
+        m_sessionState = KSessionState_Null;
+        m_lastStateChange = QDateTime::currentDateTime();
+        m_strOSTypeId = QString::null;
+        m_cSnaphot = 0;
+
+        m_pid = (ULONG) ~0;
+    /// @todo Remove. See @c todo in #switchTo() below.
+#if 0
+        mWinId = (WId) ~0;
+#endif
+    }
+
+    return needsResort;
+}
+
+/**
+ * Returns @a true if we can activate and bring the VM console window to
+ * foreground, and @a false otherwise.
+ */
+bool UIVMItem::canSwitchTo() const
+{
+    return const_cast <CMachine &>(m_machine).CanShowConsoleWindow();
+
+    /// @todo Remove. See @c todo in #switchTo() below.
+#if 0
+    return mWinId != (WId) ~0;
+#endif
+}
+
+/**
+ * Tries to switch to the main window of the VM process.
+ *
+ * @return true if successfully switched and false otherwise.
+ */
+bool UIVMItem::switchTo()
+{
+#ifdef Q_WS_MAC
+    ULONG64 id = m_machine.ShowConsoleWindow();
+#else
+    WId id = (WId) m_machine.ShowConsoleWindow();
+#endif
+    AssertWrapperOk(m_machine);
+    if (!m_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 (Q_WS_WIN32) || defined (Q_WS_X11)
+
+    return vboxGlobal().activateWindow(id, true);
+
+#elif defined (Q_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;
+    OSErr rc = ::SetFrontProcess(&psn);
+    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;
+
+#endif
+
+    return false;
+
+    /// @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 (Q_WS_WIN32)
+
+    HWND hwnd = mWinId;
+
+    /* if there are ownees (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 (Q_WS_X11)
+
+    return false;
+
+#elif defined (Q_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
+}
+
Index: /trunk/src/VBox/Frontends/VirtualBox/src/selector/UIVMItem.h
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/selector/UIVMItem.h	(revision 30868)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/selector/UIVMItem.h	(revision 30868)
@@ -0,0 +1,87 @@
+/** @file
+ *
+ * VBox frontends: Qt GUI ("VirtualBox"):
+ * UIVMItem class declarations
+ */
+
+/*
+ * Copyright (C) 2006-2010 Oracle Corporation
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ */
+
+#ifndef __UIVMItem_h__
+#define __UIVMItem_h__
+
+/* Local includes */
+#include "VBoxGlobal.h"
+
+/* Global includes */
+#include <QDateTime>
+
+class UIVMItem
+{
+public:
+
+    UIVMItem(const CMachine &aMachine);
+    virtual ~UIVMItem();
+
+    CMachine machine() const { return m_machine; }
+
+    QString name() const { return m_strName; }
+    QIcon osIcon() const { return m_fAccessible ? vboxGlobal().vmGuestOSTypeIcon(m_strOSTypeId) : QPixmap(":/os_other.png"); }
+    QString osTypeId() const { return m_strOSTypeId; }
+    QString id() const { return m_strId; }
+
+    QString sessionStateName() const;
+    QIcon sessionStateIcon() const { return m_fAccessible ? vboxGlobal().toIcon(m_state) : QPixmap(":/state_aborted_16px.png"); }
+
+    QString snapshotName() const { return m_strSnapshotName; }
+    ULONG snapshotCount() const { return m_cSnaphot; }
+
+    QString toolTipText() const;
+
+    bool accessible() const { return m_fAccessible; }
+    const CVirtualBoxErrorInfo &accessError() const { return m_accessError; }
+    KMachineState state() const { return m_state; }
+    KSessionState sessionState() const { return m_sessionState; }
+
+    bool recache();
+
+    bool canSwitchTo() const;
+    bool switchTo();
+
+private:
+
+    /* Private member vars */
+    CMachine m_machine;
+
+    /* Cached machine data (to minimize server requests) */
+    QString m_strId;
+    QString m_strSettingsFile;
+
+    bool m_fAccessible;
+    CVirtualBoxErrorInfo m_accessError;
+
+    QString m_strName;
+    QString m_strSnapshotName;
+    KMachineState m_state;
+    QDateTime m_lastStateChange;
+    KSessionState m_sessionState;
+    QString m_strOSTypeId;
+    ULONG m_cSnaphot;
+
+    ULONG m_pid;
+};
+
+/* Make the pointer of this class public to the QVariant framework */
+Q_DECLARE_METATYPE(UIVMItem *);
+
+#endif /* __UIVMItem_h__ */
+
Index: /trunk/src/VBox/Frontends/VirtualBox/src/selector/UIVMListView.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/selector/UIVMListView.cpp	(revision 30868)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/selector/UIVMListView.cpp	(revision 30868)
@@ -0,0 +1,638 @@
+/* $Id$ */
+/** @file
+ *
+ * VBox frontends: Qt GUI ("VirtualBox"):
+ * UIVMItemModel, UIVMListView, UIVMItemPainter class implementation
+ */
+
+/*
+ * Copyright (C) 2006-2010 Oracle Corporation
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ */
+
+#ifdef VBOX_WITH_PRECOMPILED_HEADERS
+# include "precomp.h"
+#else  /* !VBOX_WITH_PRECOMPILED_HEADERS */
+
+/* Local includes */
+#include "UIVMListView.h"
+#include "VBoxProblemReporter.h"
+#include "VBoxSelectorWnd.h"
+
+/* Global includes */
+#include <QPainter>
+#include <QLinearGradient>
+#include <QPixmapCache>
+
+#endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
+
+/* UIVMItemModel class */
+
+void UIVMItemModel::addItem(UIVMItem *aItem)
+{
+    Assert(aItem);
+    int row = m_VMItemList.count();
+    emit layoutAboutToBeChanged();
+    beginInsertRows(QModelIndex(), row, row);
+    m_VMItemList << aItem;
+    endInsertRows();
+    refreshItem(aItem);
+}
+
+void UIVMItemModel::removeItem(UIVMItem *aItem)
+{
+    Assert(aItem);
+    int row = m_VMItemList.indexOf(aItem);
+    removeRows(row, 1);
+}
+
+bool UIVMItemModel::removeRows(int aRow, int aCount, const QModelIndex &aParent /* = QModelIndex() */)
+{
+    emit layoutAboutToBeChanged();
+    beginRemoveRows(aParent, aRow, aRow + aCount);
+    m_VMItemList.erase(m_VMItemList.begin() + aRow, m_VMItemList.begin() + aRow + aCount);
+    endRemoveRows();
+    emit layoutChanged();
+    return true;
+}
+
+/**
+ *  Refreshes the item corresponding to the given UUID.
+ */
+void UIVMItemModel::refreshItem(UIVMItem *aItem)
+{
+    Assert(aItem);
+    if (aItem->recache())
+        sort();
+    itemChanged(aItem);
+}
+
+void UIVMItemModel::itemChanged(UIVMItem *aItem)
+{
+    Assert(aItem);
+    int row = m_VMItemList.indexOf(aItem);
+    /* Emit an layout change signal for the case some dimensions of the item
+     * has changed also. */
+    emit layoutChanged();
+    /* Emit an data changed signal. */
+    emit dataChanged(index(row), index(row));
+}
+
+/**
+ *  Clear the item model list. Please note that the items itself are also
+ *  deleted.
+ */
+void UIVMItemModel::clear()
+{
+    qDeleteAll(m_VMItemList);
+}
+
+/**
+ *  Returns the list item with the given UUID.
+ */
+UIVMItem *UIVMItemModel::itemById(const QString &aId) const
+{
+    foreach(UIVMItem *item, m_VMItemList)
+        if (item->id() == aId)
+            return item;
+    return NULL;
+}
+
+UIVMItem *UIVMItemModel::itemByRow(int aRow) const
+{
+    return m_VMItemList.at(aRow);
+}
+
+QModelIndex UIVMItemModel::indexById(const QString &aId) const
+{
+    int row = rowById(aId);
+    if (row >= 0)
+        return index(row);
+    else
+        return QModelIndex();
+}
+
+int UIVMItemModel::rowById(const QString &aId) const
+{
+    for (int i=0; i < m_VMItemList.count(); ++i)
+    {
+        UIVMItem *item = m_VMItemList.at(i);
+        if (item->id() == aId)
+            return i;
+    }
+    return -1;
+}
+
+void UIVMItemModel::sort(int /* aColumn */, Qt::SortOrder aOrder /* = Qt::AscendingOrder */)
+{
+    emit layoutAboutToBeChanged();
+    switch (aOrder)
+    {
+        case Qt::AscendingOrder: qSort(m_VMItemList.begin(), m_VMItemList.end(), UIVMItemNameCompareLessThan); break;
+        case Qt::DescendingOrder: qSort(m_VMItemList.begin(), m_VMItemList.end(), UIVMItemNameCompareGreaterThan); break;
+    }
+    emit layoutChanged();
+}
+
+int UIVMItemModel::rowCount(const QModelIndex & /* aParent = QModelIndex() */) const
+{
+    return m_VMItemList.count();
+}
+
+QVariant UIVMItemModel::data(const QModelIndex &aIndex, int aRole) const
+{
+    if (!aIndex.isValid())
+        return QVariant();
+
+    if (aIndex.row() >= m_VMItemList.size())
+        return QVariant();
+
+    QVariant v;
+    switch (aRole)
+    {
+        case Qt::DisplayRole:
+        {
+            v = m_VMItemList.at(aIndex.row())->name();
+            break;
+        }
+        case Qt::DecorationRole:
+        {
+            v = m_VMItemList.at(aIndex.row())->osIcon();
+            break;
+        }
+        case Qt::ToolTipRole:
+        {
+            v = m_VMItemList.at(aIndex.row())->toolTipText();
+            break;
+        }
+        case Qt::FontRole:
+        {
+            QFont f = qApp->font();
+            f.setPointSize(f.pointSize() + 1);
+            f.setWeight(QFont::Bold);
+            v = f;
+            break;
+        }
+        case Qt::AccessibleTextRole:
+        {
+            UIVMItem *item = m_VMItemList.at(aIndex.row());
+            v = QString("%1 (%2)\n%3")
+                         .arg(item->name())
+                         .arg(item->snapshotName())
+                         .arg(item->sessionStateName());
+            break;
+        }
+        case SnapShotDisplayRole:
+        {
+            v = m_VMItemList.at(aIndex.row())->snapshotName();
+            break;
+        }
+        case SnapShotFontRole:
+        {
+            QFont f = qApp->font();
+            v = f;
+            break;
+        }
+        case SessionStateDisplayRole:
+        {
+            v = m_VMItemList.at(aIndex.row())->sessionStateName();
+            break;
+        }
+        case SessionStateDecorationRole:
+        {
+            v = m_VMItemList.at(aIndex.row())->sessionStateIcon();
+            break;
+        }
+        case SessionStateFontRole:
+        {
+            QFont f = qApp->font();
+            f.setPointSize(f.pointSize());
+            if (m_VMItemList.at(aIndex.row())->sessionState() != KSessionState_Closed)
+                f.setItalic(true);
+            v = f;
+            break;
+        }
+        case OSTypeIdRole:
+        {
+            v = m_VMItemList.at(aIndex.row())->osTypeId();
+            break;
+        }
+        case UIVMItemPtrRole:
+        {
+            v = qVariantFromValue(m_VMItemList.at(aIndex.row()));
+            break;
+        }
+    }
+    return v;
+}
+
+QVariant UIVMItemModel::headerData(int /*aSection*/, Qt::Orientation /*aOrientation*/,
+                                  int /*aRole = Qt::DisplayRole */) const
+{
+    return QVariant();
+}
+
+bool UIVMItemModel::UIVMItemNameCompareLessThan(UIVMItem* aItem1, UIVMItem* aItem2)
+{
+    Assert(aItem1);
+    Assert(aItem2);
+    return aItem1->name().toLower() < aItem2->name().toLower();
+}
+
+bool UIVMItemModel::UIVMItemNameCompareGreaterThan(UIVMItem* aItem1, UIVMItem* aItem2)
+{
+    Assert(aItem1);
+    Assert(aItem2);
+    return aItem2->name().toLower() < aItem1->name().toLower();
+}
+
+/* UIVMListView class */
+
+UIVMListView::UIVMListView(QWidget *aParent /* = 0 */)
+    :QIListView(aParent)
+{
+    /* Create & set our delegation class */
+    UIVMItemPainter *delegate = new UIVMItemPainter(this);
+    setItemDelegate(delegate);
+    /* Default icon size */
+    setIconSize(QSize(32, 32));
+    /* Publish the activation of items */
+    connect(this, SIGNAL(activated(const QModelIndex &)),
+            this, SIGNAL(activated()));
+    /* Use the correct policy for the context menu */
+    setContextMenuPolicy(Qt::CustomContextMenu);
+}
+
+void UIVMListView::selectItemByRow(int row)
+{
+    setCurrentIndex(model()->index(row, 0));
+}
+
+void UIVMListView::selectItemById(const QString &aID)
+{
+    if (UIVMItemModel *m = qobject_cast <UIVMItemModel*>(model()))
+    {
+        QModelIndex i = m->indexById(aID);
+        if (i.isValid())
+            setCurrentIndex(i);
+    }
+}
+
+void UIVMListView::ensureSomeRowSelected(int aRowHint)
+{
+    UIVMItem *item = selectedItem();
+    if (!item)
+    {
+        aRowHint = qBound(0, aRowHint, model()->rowCount() - 1);
+        selectItemByRow(aRowHint);
+        item = selectedItem();
+        if (!item)
+            selectItemByRow(0);
+    }
+}
+
+UIVMItem * UIVMListView::selectedItem() const
+{
+    QModelIndexList indexes = selectedIndexes();
+    if (indexes.isEmpty())
+        return NULL;
+    return model()->data(indexes.first(), UIVMItemModel::UIVMItemPtrRole).value <UIVMItem *>();
+}
+
+void UIVMListView::ensureCurrentVisible()
+{
+    scrollTo(currentIndex(), QAbstractItemView::EnsureVisible);
+}
+
+void UIVMListView::selectionChanged(const QItemSelection &aSelected, const QItemSelection &aDeselected)
+{
+    QListView::selectionChanged(aSelected, aDeselected);
+    selectCurrent();
+    ensureCurrentVisible();
+    emit currentChanged();
+}
+
+void UIVMListView::currentChanged(const QModelIndex &aCurrent, const QModelIndex &aPrevious)
+{
+    QListView::currentChanged(aCurrent, aPrevious);
+    selectCurrent();
+    ensureCurrentVisible();
+    emit currentChanged();
+}
+
+void UIVMListView::dataChanged(const QModelIndex &aTopLeft, const QModelIndex &aBottomRight)
+{
+    QListView::dataChanged(aTopLeft, aBottomRight);
+    selectCurrent();
+//    ensureCurrentVisible();
+    emit currentChanged();
+}
+
+bool UIVMListView::selectCurrent()
+{
+    QModelIndexList indexes = selectionModel()->selectedIndexes();
+    if (indexes.isEmpty() ||
+        indexes.first() != currentIndex())
+    {
+        /* Make sure that the current is always selected */
+        selectionModel()->select(currentIndex(), QItemSelectionModel::Current | QItemSelectionModel::ClearAndSelect);
+        return true;
+    }
+    return false;
+}
+
+/* UIVMItemPainter class */
+/*
+ +----------------------------------------------+
+ |       marg                                   |
+ |   +----------+   m                           |
+ | m |          | m a  name_string___________ m |
+ | a |  OSType  | a r                         a |
+ | r |  icon    | r g  +--+                   r |
+ | g |          | g /  |si|  state_string     g |
+ |   +----------+   2  +--+                     |
+ |       marg                                   |
+ +----------------------------------------------+
+
+ si = state icon
+
+*/
+
+/* Little helper class for layout calculation */
+class QRectList: public QList<QRect *>
+{
+public:
+    void alignVCenterTo(QRect* aWhich)
+    {
+        QRect b;
+        foreach(QRect *rect, *this)
+            if(rect != aWhich)
+                b |= *rect;
+        if (b.width() > aWhich->width())
+            aWhich->moveCenter(QPoint(aWhich->center().x(), b.center().y()));
+        else
+        {
+            foreach(QRect *rect, *this)
+                if(rect != aWhich)
+                    rect->moveCenter(QPoint(rect->center().x(), aWhich->center().y()));
+        }
+    }
+};
+
+QSize UIVMItemPainter::sizeHint(const QStyleOptionViewItem &aOption,
+                                const QModelIndex &aIndex) const
+{
+    /* Get the size of every item */
+    QRect osTypeRT = rect(aOption, aIndex, Qt::DecorationRole);
+    QRect vmNameRT = rect(aOption, aIndex, Qt::DisplayRole);
+    QRect shotRT = rect(aOption, aIndex, UIVMItemModel::SnapShotDisplayRole);
+    QRect stateIconRT = rect(aOption, aIndex, UIVMItemModel::SessionStateDecorationRole);
+    QRect stateRT = rect(aOption, aIndex, UIVMItemModel::SessionStateDisplayRole);
+    /* Calculate the position for every item */
+    calcLayout(aIndex, &osTypeRT, &vmNameRT, &shotRT, &stateIconRT, &stateRT);
+    /* Calc the bounding rect */
+    const QRect boundingRect = osTypeRT | vmNameRT | shotRT | stateIconRT | stateRT;
+    /* Return + left/top/right/bottom margin */
+    return (boundingRect.size() + QSize(2 * m_Margin, 2 * m_Margin));
+}
+
+void UIVMItemPainter::paint(QPainter *pPainter, const QStyleOptionViewItem &option,
+                            const QModelIndex &index) const
+{
+    /* Generate the key used in the pixmap cache. Needs to be composed with all
+     * values which might be changed. */
+    QString key = QString("vbox:%1:%2:%3:%4:%5:%6")
+        .arg(index.data(Qt::DisplayRole).toString())
+        .arg(index.data(UIVMItemModel::OSTypeIdRole).toString())
+        .arg(index.data(UIVMItemModel::SnapShotDisplayRole).toString())
+        .arg(index.data(UIVMItemModel::SessionStateDisplayRole).toString())
+        .arg(option.state)
+        .arg(option.rect.width());
+
+    /* Check if the pixmap already exists in the cache. */
+    QPixmap pixmap;
+    if (!QPixmapCache::find(key, pixmap))
+    {
+        /* If not, generate a new one */
+        QStyleOptionViewItem tmpOption(option);
+        /* Highlight background if an item is selected in any case.
+         * (Fix for selector in the windows style.) */
+        tmpOption.showDecorationSelected = true;
+
+        /* Create a temporary pixmap and painter to work on.*/
+        QPixmap tmpPixmap(option.rect.size());
+        tmpPixmap.fill(Qt::transparent);
+        QPainter tmpPainter(&tmpPixmap);
+
+        /* Normally we operate on a painter which is in the size of the list
+         * view widget. Here we process one item only, so shift all the stuff
+         * out of the view. It will be translated back in the following
+         * methods. */
+        tmpPainter.translate(-option.rect.x(), -option.rect.y());
+
+        /* Start drawing with the background */
+        drawBackground(&tmpPainter, tmpOption, index);
+
+        /* Blend the content */
+        blendContent(&tmpPainter, tmpOption, index);
+
+        /* Draw a focus rectangle when necessary */
+        drawFocus(&tmpPainter, tmpOption, tmpOption.rect);
+
+        /* Finish drawing */
+        tmpPainter.end();
+
+        pixmap = tmpPixmap;
+        /* Fill the  cache */
+        QPixmapCache::insert(key, tmpPixmap);
+    }
+    pPainter->drawPixmap(option.rect, pixmap);
+}
+
+void UIVMItemPainter::paintContent(QPainter *pPainter, const QStyleOptionViewItem &option,
+                                   const QModelIndex &index) const
+{
+    /* Name and decoration */
+    const QString vmName = index.data(Qt::DisplayRole).toString();
+    const QFont nameFont = index.data(Qt::FontRole).value<QFont>();
+    const QPixmap osType = index.data(Qt::DecorationRole).value<QIcon>().pixmap(option.decorationSize, iconMode(option.state), iconState(option.state));
+
+    const QString shot = index.data(UIVMItemModel::SnapShotDisplayRole).toString();
+    const QFont shotFont = index.data(UIVMItemModel::SnapShotFontRole).value<QFont>();
+
+    const QString state = index.data(UIVMItemModel::SessionStateDisplayRole).toString();
+    const QFont stateFont = index.data(UIVMItemModel::SessionStateFontRole).value<QFont>();
+    const QPixmap stateIcon = index.data(UIVMItemModel::SessionStateDecorationRole).value<QIcon>().pixmap(QSize(16, 16), iconMode(option.state), iconState(option.state));
+
+    /* Get the sizes for all items */
+    QRect osTypeRT = rect(option, index, Qt::DecorationRole);
+    QRect vmNameRT = rect(option, index, Qt::DisplayRole);
+    QRect shotRT = rect(option, index, UIVMItemModel::SnapShotDisplayRole);
+    QRect stateIconRT = rect(option, index, UIVMItemModel::SessionStateDecorationRole);
+    QRect stateRT = rect(option, index, UIVMItemModel::SessionStateDisplayRole);
+
+    /* Calculate the positions for all items */
+    calcLayout(index, &osTypeRT, &vmNameRT, &shotRT, &stateIconRT, &stateRT);
+    /* Get the appropriate pen for the current state */
+    QPalette pal = option.palette;
+    QPen pen = pal.color(QPalette::Active, QPalette::Text);
+    if (option.state & QStyle::State_Selected &&
+        (option.state & QStyle::State_HasFocus ||
+        QApplication::style()->styleHint(QStyle::SH_ItemView_ChangeHighlightOnFocus, &option) == 0))
+        pen =  pal.color(QPalette::Active, QPalette::HighlightedText);
+    /* Set the current pen */
+    pPainter->setPen(pen);
+    /* os type icon */
+    pPainter->drawPixmap(osTypeRT, osType);
+    /* vm name */
+    pPainter->setFont(nameFont);
+    pPainter->drawText(vmNameRT, vmName);
+    /* current snapshot in braces */
+    if (!shot.isEmpty())
+    {
+        pPainter->setFont(shotFont);
+        pPainter->drawText(shotRT, QString("(%1)").arg(shot));
+    }
+    /* state icon */
+    pPainter->drawPixmap(stateIconRT, stateIcon);
+    /* textual state */
+    pPainter->setFont(stateFont);
+    pPainter->drawText(stateRT, state);
+    /* For debugging */
+//    QRect boundingRect = osTypeRT | vmNameRT | shotRT | stateIconRT | stateRT;
+//    pPainter->drawRect(boundingRect);
+}
+
+void UIVMItemPainter::blendContent(QPainter *pPainter, const QStyleOptionViewItem &option,
+                                   const QModelIndex &index) const
+{
+    QRect r = option.rect;
+    QWidget *pParent = qobject_cast<QListView *>(parent())->viewport();
+    /* This is as always a big fat mess on Mac OS X. We can't use QImage for
+     * rendering text, cause this looks like shit. We can't do all the drawing
+     * on the widget, cause the composition modes are not working correctly.
+     * The same count for doing composition on a QPixmap. The work around is to
+     * draw all into a QPixmap (also the background color/gradient, otherwise
+     * the antialiasing is messed up), bliting this into a QImage to make the
+     * composition stuff and finally bliting this QImage into the QWidget.
+     * Yipi a yeah. Btw, no problem on Linux at all. */
+    QPixmap basePixmap(r.width(), r.height());//
+    /* Initialize with the base image color. */
+    basePixmap.fill(pParent->palette().base().color());
+    /* Create the painter to operate on. */
+    QPainter basePainter(&basePixmap);
+    /* Initialize the painter with the corresponding widget */
+    basePainter.initFrom(pParent);
+    basePainter.setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing, true);
+    /* The translation is necessary, cause drawBackground expect the whole drawing area. */
+    basePainter.save();
+    basePainter.translate(-option.rect.x(), -option.rect.y());
+    drawBackground(&basePainter, option, index);
+    basePainter.restore();
+    /* Now paint the content. */
+    paintContent(&basePainter, option, index);
+    /* Finished with the OS dependent part. */
+    basePainter.end();
+    /* Time for the OS independent part (That is, use the QRasterEngine) */
+    QImage baseImage(r.width(), r.height(), QImage::Format_ARGB32_Premultiplied);
+    QPainter rasterPainter(&baseImage);
+    /* Initialize the painter with the corresponding widget */
+    rasterPainter.initFrom(pParent);
+    rasterPainter.setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing, true);
+    /* Fully copy the source to the destination */
+    rasterPainter.setCompositionMode(QPainter::CompositionMode_Source);
+    rasterPainter.drawPixmap(0, 0, basePixmap);
+    /* Now use the alpha value of the source to blend the destination in. */
+    rasterPainter.setCompositionMode(QPainter::CompositionMode_DestinationIn);
+
+    const int blendWidth = qMin(70, r.width());
+    QLinearGradient lg(r.width()-blendWidth, 0, r.width(), 0);
+    lg.setColorAt(0, QColor(Qt::white));
+    lg.setColorAt(0.95, QColor(Qt::transparent));
+    lg.setColorAt(1, QColor(Qt::transparent));
+    rasterPainter.fillRect(r.width()-blendWidth, 0, blendWidth, r.height(), lg);
+    /* Finished with the OS independent part. */
+    rasterPainter.end();
+
+    /* Finally blit our hard work on the widget. */
+    pPainter->drawImage(option.rect.x(), option.rect.y(), baseImage);
+}
+
+QRect UIVMItemPainter::rect(const QStyleOptionViewItem &aOption,
+                            const QModelIndex &aIndex, int aRole) const
+{
+    switch (aRole)
+    {
+        case Qt::DisplayRole:
+            {
+                QString text = aIndex.data(Qt::DisplayRole).toString();
+                QFontMetrics fm(fontMetric(aIndex, Qt::FontRole));
+                return QRect(QPoint(0, 0), fm.size(0, text));
+                break;
+            }
+        case Qt::DecorationRole:
+            {
+                QIcon icon = aIndex.data(Qt::DecorationRole).value<QIcon>();
+                return QRect(QPoint(0, 0), icon.actualSize(aOption.decorationSize, iconMode(aOption.state), iconState(aOption.state)));
+                break;
+            }
+        case UIVMItemModel::SnapShotDisplayRole:
+            {
+                QString text = aIndex.data(UIVMItemModel::SnapShotDisplayRole).toString();
+                if (!text.isEmpty())
+                {
+                    QFontMetrics fm(fontMetric(aIndex, UIVMItemModel::SnapShotFontRole));
+                    return QRect(QPoint(0, 0), fm.size(0, QString("(%1)").arg(text)));
+                }else
+                    return QRect();
+                break;
+            }
+        case UIVMItemModel::SessionStateDisplayRole:
+            {
+                QString text = aIndex.data(UIVMItemModel::SessionStateDisplayRole).toString();
+                QFontMetrics fm(fontMetric(aIndex, UIVMItemModel::SessionStateFontRole));
+                return QRect(QPoint(0, 0), fm.size(0, text));
+                break;
+            }
+        case UIVMItemModel::SessionStateDecorationRole:
+            {
+                QIcon icon = aIndex.data(UIVMItemModel::SessionStateDecorationRole).value<QIcon>();
+                return QRect(QPoint(0, 0), icon.actualSize(QSize(16, 16), iconMode(aOption.state), iconState(aOption.state)));
+                break;
+            }
+    }
+    return QRect();
+}
+
+void UIVMItemPainter::calcLayout(const QModelIndex &aIndex,
+                                 QRect *aOSType, QRect *aVMName, QRect *aShot,
+                                 QRect *aStateIcon, QRect *aState) const
+{
+    const int nameSpaceWidth = fontMetric(aIndex, Qt::FontRole).width(' ');
+    const int stateSpaceWidth = fontMetric(aIndex, UIVMItemModel::SessionStateFontRole).width(' ');
+    /* Really basic layout managment.
+     * First layout as usual */
+    aOSType->moveTo(m_Margin, m_Margin);
+    aVMName->moveTo(m_Margin + aOSType->width() + m_Spacing, m_Margin);
+    aShot->moveTo(aVMName->right() + nameSpaceWidth, aVMName->top());
+    aStateIcon->moveTo(aVMName->left(), aVMName->bottom());
+    aState->moveTo(aStateIcon->right() + stateSpaceWidth, aStateIcon->top());
+    /* Do grouping for the automatic center routine.
+     * First the states group: */
+    QRectList statesLayout;
+    statesLayout << aStateIcon << aState;
+    /* All items in the layout: */
+    QRectList allLayout;
+    allLayout << aOSType << aVMName << aShot << statesLayout;
+    /* Now verticaly center the items based on the reference item */
+    statesLayout.alignVCenterTo(aStateIcon);
+    allLayout.alignVCenterTo(aOSType);
+}
+
Index: /trunk/src/VBox/Frontends/VirtualBox/src/selector/UIVMListView.h
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/selector/UIVMListView.h	(revision 30868)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/selector/UIVMListView.h	(revision 30868)
@@ -0,0 +1,147 @@
+/** @file
+ *
+ * VBox frontends: Qt GUI ("VirtualBox"):
+ * UIVMItemModel, UIVMListView, UIVMItemPainter class declarations
+ */
+
+/*
+ * Copyright (C) 2006-2010 Oracle Corporation
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ */
+
+#ifndef __UIVMListView_h__
+#define __UIVMListView_h__
+
+/* Self includes */
+#include "VBoxGlobal.h"
+#include "QIListView.h"
+#include "UIVMItem.h"
+
+/* Qt includes */
+#include <QAbstractListModel>
+
+class UIVMItemModel: public QAbstractListModel
+{
+    Q_OBJECT;
+
+public:
+    enum { SnapShotDisplayRole = Qt::UserRole,
+           SnapShotFontRole,
+           SessionStateDisplayRole,
+           SessionStateDecorationRole,
+           SessionStateFontRole,
+           OSTypeIdRole,
+           UIVMItemPtrRole };
+
+    UIVMItemModel(QObject *aParent = 0)
+        :QAbstractListModel(aParent) {}
+
+    void addItem(UIVMItem *aItem);
+    void removeItem(UIVMItem *aItem);
+    void refreshItem(UIVMItem *aItem);
+
+    void itemChanged(UIVMItem *aItem);
+
+    void clear();
+
+    UIVMItem *itemById(const QString &aId) const;
+    UIVMItem *itemByRow(int aRow) const;
+    QModelIndex indexById(const QString &aId) const;
+
+    int rowById(const QString &aId) const;;
+
+    void sort(Qt::SortOrder aOrder = Qt::AscendingOrder) { sort(0, aOrder); }
+
+    /* The following are necessary model implementations */
+    void sort(int aColumn, Qt::SortOrder aOrder = Qt::AscendingOrder);
+
+    int rowCount(const QModelIndex &aParent = QModelIndex()) const;
+
+    QVariant data(const QModelIndex &aIndex, int aRole) const;
+    QVariant headerData(int aSection, Qt::Orientation aOrientation,
+                        int aRole = Qt::DisplayRole) const;
+
+    bool removeRows(int aRow, int aCount, const QModelIndex &aParent = QModelIndex());
+
+private:
+    static bool UIVMItemNameCompareLessThan(UIVMItem* aItem1, UIVMItem* aItem2);
+    static bool UIVMItemNameCompareGreaterThan(UIVMItem* aItem1, UIVMItem* aItem2);
+
+    /* Private member vars */
+    QList<UIVMItem *> m_VMItemList;
+};
+
+class UIVMListView: public QIListView
+{
+    Q_OBJECT;
+
+public:
+    UIVMListView(QWidget *aParent = 0);
+
+    void selectItemByRow(int row);
+    void selectItemById(const QString &aID);
+    void ensureSomeRowSelected(int aRowHint);
+    UIVMItem * selectedItem() const;
+
+    void ensureCurrentVisible();
+
+signals:
+    void currentChanged();
+    void activated();
+
+protected slots:
+    void selectionChanged(const QItemSelection &aSelected, const QItemSelection &aDeselected);
+    void currentChanged(const QModelIndex &aCurrent, const QModelIndex &aPrevious);
+    void dataChanged(const QModelIndex &aTopLeft, const QModelIndex &aBottomRight);
+
+protected:
+    bool selectCurrent();
+};
+
+class UIVMItemPainter: public QIItemDelegate
+{
+public:
+    UIVMItemPainter(QObject *aParent = 0)
+      : QIItemDelegate(aParent), m_Margin(8), m_Spacing(m_Margin * 3 / 2) {}
+
+    QSize sizeHint(const QStyleOptionViewItem &aOption,
+                   const QModelIndex &aIndex) const;
+
+    void paint(QPainter *aPainter, const QStyleOptionViewItem &aOption,
+               const QModelIndex &aIndex) const;
+
+private:
+    void paintContent(QPainter *pPainter, const QStyleOptionViewItem &option, const QModelIndex &index) const;
+    void blendContent(QPainter *pPainter, const QStyleOptionViewItem &option, const QModelIndex &index) const;
+    inline QFontMetrics fontMetric(const QModelIndex &aIndex, int aRole) const { return QFontMetrics(aIndex.data(aRole).value<QFont>()); }
+    inline QIcon::Mode iconMode(QStyle::State aState) const
+    {
+        if (!(aState & QStyle::State_Enabled))
+            return QIcon::Disabled;
+        if (aState & QStyle::State_Selected)
+            return QIcon::Selected;
+        return QIcon::Normal;
+    }
+    inline QIcon::State iconState(QStyle::State aState) const { return aState & QStyle::State_Open ? QIcon::On : QIcon::Off; }
+
+    QRect rect(const QStyleOptionViewItem &aOption,
+               const QModelIndex &aIndex, int aRole) const;
+
+    void calcLayout(const QModelIndex &aIndex,
+                    QRect *aOSType, QRect *aVMName, QRect *aShot,
+                    QRect *aStateIcon, QRect *aState) const;
+
+    /* Private member vars */
+    int m_Margin;
+    int m_Spacing;
+};
+
+#endif /* __UIVMListView_h__ */
+
Index: /trunk/src/VBox/Frontends/VirtualBox/src/selector/UIVMPreviewWindow.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/selector/UIVMPreviewWindow.cpp	(revision 30868)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/selector/UIVMPreviewWindow.cpp	(revision 30868)
@@ -0,0 +1,426 @@
+/* $Id$ */
+/** @file
+ *
+ * VBox frontends: Qt GUI ("VirtualBox"):
+ * UIPreviewWindow class implementation
+ */
+
+/*
+ * Copyright (C) 2010 Oracle Corporation
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ */
+
+/* Local includes */
+#include "UIVMPreviewWindow.h"
+#include "UIVirtualBoxEventHandler.h"
+#include "UIImageTools.h"
+#include "VBoxGlobal.h"
+
+/* Global includes */
+#include <QContextMenuEvent>
+#include <QMenu>
+#include <QPainter>
+#include <QTimer>
+
+UIVMPreviewWindow::UIVMPreviewWindow(QWidget *pParent)
+  : QIWithRetranslateUI<QWidget>(pParent)
+  , m_machineState(KMachineState_Null)
+  , m_pUpdateTimer(new QTimer(this))
+  , m_vMargin(10)
+  , m_pbgImage(0)
+  , m_pPreviewImg(0)
+  , m_pGlossyImg(0)
+{
+    setContentsMargins(0, 5, 0, 5);
+    setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
+    /* Connect the update timer */
+    connect(m_pUpdateTimer, SIGNAL(timeout()),
+            this, SLOT(sltRecreatePreview()));
+    /* Connect the machine state event */
+    connect(gVBoxEvents, SIGNAL(sigMachineStateChange(QString, KMachineState)),
+            this, SLOT(sltMachineStateChange(QString, KMachineState)));
+    /* Create the context menu */
+    setContextMenuPolicy(Qt::DefaultContextMenu);
+    m_pUpdateTimerMenu = new QMenu(this);
+    QActionGroup *pUpdateTimeG = new QActionGroup(this);
+    pUpdateTimeG->setExclusive(true);
+    for(int i = 0; i < UpdateEnd; ++i)
+    {
+        QAction *pUpdateTime = new QAction(pUpdateTimeG);
+        pUpdateTime->setData(i);
+        pUpdateTime->setCheckable(true);
+        pUpdateTimeG->addAction(pUpdateTime);
+        m_pUpdateTimerMenu->addAction(pUpdateTime);
+        m_actions[static_cast<UpdateInterval>(i)] = pUpdateTime;
+    }
+    m_pUpdateTimerMenu->insertSeparator(m_actions[static_cast<UpdateInterval>(Update1Sec)]);
+    /* Default value */
+    UpdateInterval interval = Update5Sec;
+    QString strInterval = vboxGlobal().virtualBox().GetExtraData(VBoxDefs::GUI_PreviewUpdate);
+    if (strInterval == "disabled")
+        interval = UpdateDisabled;
+    else if (strInterval == "1")
+        interval = Update1Sec;
+    else if (strInterval == "2")
+        interval = Update2Sec;
+    else if (strInterval == "5")
+        interval = Update5Sec;
+    else if (strInterval == "10")
+        interval = Update10Sec;
+    /* Initialize with the new update interval */
+    setUpdateInterval(interval, false);
+
+    /* Retranslate the UI */
+    retranslateUi();
+}
+
+void UIVMPreviewWindow::setMachine(const CMachine& machine)
+{
+    m_pUpdateTimer->stop();
+    m_machine = machine;
+    restart();
+}
+
+CMachine UIVMPreviewWindow::machine() const
+{
+    return m_machine;
+}
+
+QSize UIVMPreviewWindow::sizeHint() const
+{
+    return QSize(220, 220 * 3.0/4.0);
+}
+
+void UIVMPreviewWindow::retranslateUi()
+{
+    m_actions.value(UpdateDisabled)->setText(tr("Update Disabled"));
+    m_actions.value(Update1Sec)->setText(tr("Every 1 s"));
+    m_actions.value(Update2Sec)->setText(tr("Every 2 s"));
+    m_actions.value(Update5Sec)->setText(tr("Every 5 s"));
+    m_actions.value(Update10Sec)->setText(tr("Every 10 s"));
+}
+
+void UIVMPreviewWindow::resizeEvent(QResizeEvent *pEvent)
+{
+    repaintBGImages();
+    QWidget::resizeEvent(pEvent);
+}
+
+void UIVMPreviewWindow::showEvent(QShowEvent *pEvent)
+{
+    /* Make sure there is some valid preview image when shown. */
+    restart();
+    QWidget::showEvent(pEvent);
+}
+
+void UIVMPreviewWindow::hideEvent(QHideEvent *pEvent)
+{
+    /* Stop the update time when we aren't visible */
+    m_pUpdateTimer->stop();
+    QWidget::hideEvent(pEvent);
+}
+
+void UIVMPreviewWindow::paintEvent(QPaintEvent *pEvent)
+{
+    QPainter painter(this);
+    /* Enable clipping */
+    painter.setClipRect(pEvent->rect());
+    /* Where should the content go */
+    QRect cr = contentsRect();
+    /* Draw the background with the monitor and the shadow */
+    painter.drawImage(cr.x(), cr.y(), *m_pbgImage);
+//    painter.setPen(Qt::red);
+//    painter.drawRect(cr.adjusted(0, 0, -1, -1));
+//    return;
+    /* If there is a preview image available, use it. */
+    if (m_pPreviewImg)
+        painter.drawImage(0, 0, *m_pPreviewImg);
+    else
+    {
+        QString strName = tr("No Preview");
+        if (!m_machine.isNull())
+            strName = m_machine.GetName();
+
+        /* Paint the name in the center of the monitor */
+        painter.fillRect(m_vRect, Qt::black);
+		QFont font = painter.font();
+        font.setBold(true);
+        int fFlags = Qt::AlignCenter | Qt::TextWordWrap;
+        float h = m_vRect.size().height() * .2;
+        QRect r;
+        /* Make a little magic to find out if the given text fits into
+         * our rectangle. Decrease the font pixel size as long as it
+         * doesn't fit. */
+        do
+        {
+            h = h * .8;
+            font.setPixelSize(h);
+            painter.setFont(font);
+            r = painter.boundingRect(m_vRect, fFlags, strName);
+        }while (   r.height() > m_vRect.height()
+                || r.width() > m_vRect.width());
+        painter.setPen(Qt::white);
+        painter.drawText(m_vRect, fFlags, strName);
+    }
+    /* Draw the glossy overlay last */
+    painter.drawImage(m_vRect.x(), m_vRect.y(), *m_pGlossyImg);
+}
+
+void UIVMPreviewWindow::contextMenuEvent(QContextMenuEvent *pEvent)
+{
+    QAction *pReturn = m_pUpdateTimerMenu->exec(pEvent->globalPos(), 0);
+    if (pReturn)
+    {
+        UpdateInterval interval = static_cast<UpdateInterval>(pReturn->data().toInt());
+        setUpdateInterval(interval, true);
+        restart();
+    }
+}
+
+void UIVMPreviewWindow::sltMachineStateChange(QString strId, KMachineState state)
+{
+    if (   !m_machine.isNull()
+        && m_machine.GetId() == strId)
+    {
+        /* Cache the machine state */
+        m_machineState = state;
+        restart();
+    }
+}
+
+void UIVMPreviewWindow::sltRecreatePreview()
+{
+    /* Only do this if we are visible */
+    if (!isVisible())
+        return;
+
+    if (m_pPreviewImg)
+    {
+        delete m_pPreviewImg;
+        m_pPreviewImg = 0;
+    }
+
+    if (!m_machine.isNull())
+    {
+        Assert(m_machineState != KMachineState_Null);
+        QImage image(size(), QImage::Format_ARGB32);
+        image.fill(Qt::transparent);
+        QPainter painter(&image);
+        bool fDone = false;
+
+        /* Preview enabled? */
+        if (m_pUpdateTimer->interval() > 0)
+        {
+            /* Use the image which may be included in the save state. */
+            if (   m_machineState == KMachineState_Saved
+                || m_machineState == KMachineState_Restoring)
+            {
+                ULONG width = 0, height = 0;
+                QVector<BYTE> screenData = m_machine.ReadSavedScreenshotPNGToArray(0, width, height);
+                if (screenData.size() != 0)
+                {
+                    QImage shot = QImage::fromData(screenData.data(), screenData.size(), "PNG").scaled(m_vRect.size());
+                    dimImage(shot);
+                    painter.drawImage(m_vRect.x(), m_vRect.y(), shot);
+                    fDone = true;
+                }
+            }
+            /* Use the current VM output. */
+            else if (   m_machineState == KMachineState_Running
+//                      || m_machineState == KMachineState_Saving /* Not sure if this is valid */
+                     || m_machineState == KMachineState_Paused)
+            {
+                CSession session;
+                session.createInstance(CLSID_Session);
+                if (!session.isNull())
+                {
+                    CVirtualBox vbox = vboxGlobal().virtualBox();
+                    vbox.OpenExistingSession(session, m_machine.GetId());
+                    if (vbox.isOk())
+                    {
+                        CDisplay display = session.GetConsole().GetDisplay();
+                        /* Todo: correct aspect radio */
+//                        ULONG w, h, bpp;
+//                        display.GetScreenResolution(0, w, h, bpp);
+//                        QImage shot = QImage(w, h, QImage::Format_RGB32);
+//                        shot.fill(Qt::black);
+//                        display.TakeScreenShot(0, shot.bits(), shot.width(), shot.height());
+                        QVector<BYTE> screenData = display.TakeScreenShotToArray(0, m_vRect.width(), m_vRect.height());
+                        if (   display.isOk()
+                               && screenData.size() != 0)
+                        {
+                            /* Unfortunately we have to reorder the pixel
+                             * data, cause the VBox API returns RGBA data,
+                             * which is not a format QImage understand.
+                             * Todo: check for 32bit alignment, for both
+                             * the data and the scanlines. Maybe we need to
+                             * copy the data in any case. */
+                            uint32_t *d = (uint32_t*)screenData.data();
+                            for (int i = 0; i < screenData.size() / 4; ++i)
+                            {
+                                uint32_t e = d[i];
+                                d[i] = RT_MAKE_U32_FROM_U8(RT_BYTE3(e), RT_BYTE2(e), RT_BYTE1(e), RT_BYTE4(e));
+                            }
+
+                            QImage shot = QImage((uchar*)d, m_vRect.width(), m_vRect.height(), QImage::Format_RGB32);
+
+                            if (m_machineState == KMachineState_Paused)
+                                dimImage(shot);
+                            painter.drawImage(m_vRect.x(), m_vRect.y(), shot);
+                            fDone = true;
+                        }
+                    }
+                }
+            }
+        }
+        if (fDone)
+            m_pPreviewImg = new QImage(image);
+    }
+    update();
+}
+
+void UIVMPreviewWindow::setUpdateInterval(UpdateInterval interval, bool fSave)
+{
+    switch (interval)
+    {
+        case UpdateDisabled:
+        {
+            if (fSave)
+                vboxGlobal().virtualBox().SetExtraData(VBoxDefs::GUI_PreviewUpdate, "disabled");
+            m_pUpdateTimer->setInterval(0);
+            m_pUpdateTimer->stop();
+            m_actions[interval]->setChecked(true);
+            break;
+        }
+        case Update1Sec:
+        {
+            if (fSave)
+                vboxGlobal().virtualBox().SetExtraData(VBoxDefs::GUI_PreviewUpdate, "1");
+            m_pUpdateTimer->setInterval(1000);
+            m_actions[interval]->setChecked(true);
+            break;
+        }
+        case Update2Sec:
+        {
+            if (fSave)
+                vboxGlobal().virtualBox().SetExtraData(VBoxDefs::GUI_PreviewUpdate, "2");
+            m_pUpdateTimer->setInterval(2000);
+            m_actions[interval]->setChecked(true);
+            break;
+        }
+        case Update5Sec:
+        {
+            if (fSave)
+                vboxGlobal().virtualBox().SetExtraData(VBoxDefs::GUI_PreviewUpdate, "5");
+            m_pUpdateTimer->setInterval(5000);
+            m_actions[interval]->setChecked(true);
+            break;
+        }
+        case Update10Sec:
+        {
+            if (fSave)
+                vboxGlobal().virtualBox().SetExtraData(VBoxDefs::GUI_PreviewUpdate, "10");
+            m_pUpdateTimer->setInterval(10000);
+            m_actions[interval]->setChecked(true);
+            break;
+        }
+        case UpdateEnd: break;
+    }
+}
+
+void UIVMPreviewWindow::restart()
+{
+    /* Fetch the latest machine state */
+    if (!m_machine.isNull())
+        m_machineState = m_machine.GetState();
+    /* Recreate the preview image */
+    sltRecreatePreview();
+    /* Start the timer */
+    if (!m_machine.isNull())
+    {
+        if (   m_pUpdateTimer->interval() > 0
+            && m_machineState == KMachineState_Running)
+            m_pUpdateTimer->start();
+    }
+}
+
+void UIVMPreviewWindow::repaintBGImages()
+{
+    QPalette pal = palette();
+    QRect cr = contentsRect();
+    m_wRect = cr.adjusted(10, 10, -10, -10);
+    m_vRect = m_wRect.adjusted(m_vMargin, m_vMargin, -m_vMargin, -m_vMargin).adjusted(-3, -3, 3, 3);
+
+    /* First draw the shadow. Its a rounded rectangle which get blured. */
+    QImage imageW(cr.size(), QImage::Format_ARGB32);
+    QColor bg = pal.color(QPalette::Base);
+    bg.setAlpha(0); /* We want blur to transparent _and_ whatever the base color is. */
+    imageW.fill(bg.rgba());
+    QPainter pW(&imageW);
+    pW.setBrush(QColor(30, 30, 30)); /* Dark gray */
+    pW.setPen(Qt::NoPen);
+    pW.drawRoundedRect(QRect(QPoint(0, 0), cr.size()).adjusted(10, 10, -10, -10), m_vMargin, m_vMargin);
+    pW.end();
+    /* Blur the rectangle */
+    QImage imageO(cr.size(), QImage::Format_ARGB32);
+    blurImage(imageW, imageO, 10);
+    QPainter pO(&imageO);
+
+#if 1
+    /* Now paint the border with a gradient to get a look of a monitor. */
+    QRect rr = QRect(QPoint(0, 0), cr.size()).adjusted(10, 10, -10, -10);
+    QLinearGradient lg(0, rr.y(), 0, rr.height());
+    QColor base(200, 200, 200); /* light variant */
+    //        QColor base(80, 80, 80); /* Dark variant */
+    lg.setColorAt(0, base);
+    lg.setColorAt(0.4, base.darker(300));
+    lg.setColorAt(0.5, base.darker(400));
+    lg.setColorAt(0.7, base.darker(300));
+    lg.setColorAt(1, base);
+    pO.setBrush(lg);
+    pO.setPen(QPen(base.darker(150), 1));
+    pO.drawRoundedRect(rr, m_vMargin, m_vMargin);
+    pO.end();
+#endif
+    /* Make a copy of the new bg image */
+    if (m_pbgImage)
+        delete m_pbgImage;
+    m_pbgImage = new QImage(imageO);
+
+    /* Now the glossy overlay has to be created. Start with defining a nice
+     * looking painter path. */
+    QRect gRect = QRect(QPoint(0, 0), m_vRect.size());
+    QPainterPath glossyPath(QPointF(gRect.x(), gRect.y()));
+    glossyPath.lineTo(gRect.x() + gRect.width(), gRect.y());
+    glossyPath.lineTo(gRect.x() + gRect.width(), gRect.y() + gRect.height() * 1.0/3.0);
+    glossyPath.cubicTo(gRect.x() + gRect.width() / 2.0, gRect.y() + gRect.height() * 1.0/3.0,
+                       gRect.x() + gRect.width() / 2.0, gRect.y() + gRect.height() * 2.0/3.0,
+                       gRect.x(), gRect.y() + gRect.height() * 2.0/3.0);
+    glossyPath.closeSubpath();
+
+    /* Paint the glossy path on a QImage */
+    if (m_pGlossyImg)
+        delete m_pGlossyImg;
+    QImage image(m_vRect.size(), QImage::Format_ARGB32);
+    QColor bg1(Qt::white); /* We want blur to transparent _and_ white. */
+    bg1.setAlpha(0);
+    image.fill(bg1.rgba());
+    QPainter painter(&image);
+    painter.fillPath(glossyPath, QColor(255, 255, 255, 80));
+    painter.end();
+    /* Blur the image to get a much more smooth feeling */
+    QImage image1(m_vRect.size(), QImage::Format_ARGB32);
+    blurImage(image, image1, 7);
+    m_pGlossyImg = new QImage(image1);
+
+    /* Repaint */
+    update();
+}
+
Index: /trunk/src/VBox/Frontends/VirtualBox/src/selector/UIVMPreviewWindow.h
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/selector/UIVMPreviewWindow.h	(revision 30868)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/selector/UIVMPreviewWindow.h	(revision 30868)
@@ -0,0 +1,95 @@
+/** @file
+ *
+ * VBox frontends: Qt GUI ("VirtualBox"):
+ * UIVMPreviewWindow class declaration
+ */
+
+/*
+ * Copyright (C) 2010 Oracle Corporation
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ */
+
+#ifndef __UIVMPreviewWindow_h__
+#define __UIVMPreviewWindow_h__
+
+/* Local includes */
+#include "QIWithRetranslateUI.h"
+#include "COMDefs.h"
+
+/* Global includes */
+#include <QWidget>
+#include <QHash>
+
+/* Global forward declarations */
+class QAction;
+class QImage;
+class QMenu;
+class QTimer;
+
+class UIVMPreviewWindow : public QIWithRetranslateUI<QWidget>
+{
+    Q_OBJECT;
+
+    enum UpdateInterval
+    {
+        UpdateDisabled,
+        Update1Sec,
+        Update2Sec,
+        Update5Sec,
+        Update10Sec,
+        UpdateEnd
+    };
+
+public:
+
+    UIVMPreviewWindow(QWidget *pParent);
+
+    void setMachine(const CMachine& machine);
+    CMachine machine() const;
+
+    QSize sizeHint() const;
+
+protected:
+
+    void retranslateUi();
+
+    void resizeEvent(QResizeEvent *pEvent);
+    void showEvent(QShowEvent *pEvent);
+    void hideEvent(QHideEvent *pEvent);
+    void paintEvent(QPaintEvent *pEvent);
+    void contextMenuEvent(QContextMenuEvent *pEvent);
+
+private slots:
+
+    void sltMachineStateChange(QString strId, KMachineState state);
+    void sltRecreatePreview();
+
+private:
+
+    void setUpdateInterval(UpdateInterval interval, bool fSave);
+    void restart();
+    void repaintBGImages();
+
+    /* Private member vars */
+    CMachine m_machine;
+    KMachineState m_machineState;
+    QTimer *m_pUpdateTimer;
+    QMenu *m_pUpdateTimerMenu;
+    QHash<UpdateInterval, QAction*> m_actions;
+    const int m_vMargin;
+    QRect m_wRect;
+    QRect m_vRect;
+    QImage *m_pbgImage;
+    QImage *m_pPreviewImg;
+    QImage *m_pGlossyImg;
+};
+
+#endif /* !__UIVMPreviewWindow_h__ */
+
Index: /trunk/src/VBox/Frontends/VirtualBox/src/selector/UIVirtualBoxEventHandler.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/selector/UIVirtualBoxEventHandler.cpp	(revision 30868)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/selector/UIVirtualBoxEventHandler.cpp	(revision 30868)
@@ -0,0 +1,93 @@
+/* $Id$ */
+/** @file
+ *
+ * VBox frontends: Qt GUI ("VirtualBox"):
+ * UIVirtualBoxEventHandler class implementation
+ */
+
+/*
+ * Copyright (C) 2010 Oracle Corporation
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ */
+
+/* Local includes */
+#include "UIVirtualBoxEventHandler.h"
+#include "UIMainEventListener.h"
+#include "VBoxGlobal.h"
+
+/* Global includes */
+//#include <iprt/thread.h>
+//#include <iprt/stream.h>
+
+/* static */
+UIVirtualBoxEventHandler *UIVirtualBoxEventHandler::m_pInstance = 0;
+
+/* static */
+UIVirtualBoxEventHandler* UIVirtualBoxEventHandler::instance()
+{
+    if (!m_pInstance)
+        m_pInstance = new UIVirtualBoxEventHandler();
+    return m_pInstance;
+}
+
+/* static */
+void UIVirtualBoxEventHandler::destroy()
+{
+    if (m_pInstance)
+    {
+        delete m_pInstance;
+        m_pInstance = 0;
+    }
+}
+
+UIVirtualBoxEventHandler::UIVirtualBoxEventHandler()
+{
+//    RTPrintf("Self add: %RTthrd\n", RTThreadSelf());
+    const CVirtualBox &vbox = vboxGlobal().virtualBox();
+    UIMainEventListener *pListener = new UIMainEventListener(this);
+    m_mainEventListener = CEventListener(pListener);
+    QVector<KVBoxEventType> events;
+    events
+        << KVBoxEventType_OnMachineStateChange
+        << KVBoxEventType_OnMachineDataChange
+        << KVBoxEventType_OnMachineRegistered
+        << KVBoxEventType_OnSessionStateChange
+        << KVBoxEventType_OnSnapshotChange;
+
+    vbox.GetEventSource().RegisterListener(m_mainEventListener, events, TRUE);
+    AssertWrapperOk(vbox);
+
+    connect(pListener, SIGNAL(sigMachineStateChange(QString, KMachineState)),
+            this, SIGNAL(sigMachineStateChange(QString, KMachineState)),
+            Qt::QueuedConnection);
+
+    connect(pListener, SIGNAL(sigMachineDataChange(QString)),
+            this, SIGNAL(sigMachineDataChange(QString)),
+            Qt::QueuedConnection);
+
+    connect(pListener, SIGNAL(sigMachineRegistered(QString, bool)),
+            this, SIGNAL(sigMachineRegistered(QString, bool)),
+            Qt::QueuedConnection);
+
+    connect(pListener, SIGNAL(sigSessionStateChange(QString, KSessionState)),
+            this, SIGNAL(sigSessionStateChange(QString, KSessionState)),
+            Qt::QueuedConnection);
+
+    connect(pListener, SIGNAL(sigSnapshotChange(QString, QString)),
+            this, SIGNAL(sigSnapshotChange(QString, QString)),
+            Qt::QueuedConnection);
+}
+
+UIVirtualBoxEventHandler::~UIVirtualBoxEventHandler()
+{
+    const CVirtualBox &vbox = vboxGlobal().virtualBox();
+    vbox.GetEventSource().UnregisterListener(m_mainEventListener);
+}
+
Index: /trunk/src/VBox/Frontends/VirtualBox/src/selector/UIVirtualBoxEventHandler.h
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/selector/UIVirtualBoxEventHandler.h	(revision 30868)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/selector/UIVirtualBoxEventHandler.h	(revision 30868)
@@ -0,0 +1,53 @@
+/** @file
+ *
+ * VBox frontends: Qt GUI ("VirtualBox"):
+ * UIVirtualBoxEventHandler class declaration
+ */
+
+/*
+ * Copyright (C) 2010 Oracle Corporation
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ */
+
+#ifndef __UIVirtualBoxEventHandler_h__
+#define __UIVirtualBoxEventHandler_h__
+
+/* Local includes */
+#include "COMDefs.h"
+
+class UIVirtualBoxEventHandler: public QObject
+{
+    Q_OBJECT;
+
+public:
+    static UIVirtualBoxEventHandler* instance();
+    static void destroy();
+
+signals:
+    /* VirtualBox main signals */
+    void sigMachineStateChange(QString strId, KMachineState state);
+    void sigMachineDataChange(QString strId);
+    void sigMachineRegistered(QString strId, bool fRegistered);
+    void sigSessionStateChange(QString strId, KSessionState state);
+    void sigSnapshotChange(QString strId, QString strSnapshotId);
+
+private:
+    UIVirtualBoxEventHandler();
+    ~UIVirtualBoxEventHandler();
+
+    /* Private member vars */
+    static UIVirtualBoxEventHandler *m_pInstance;
+    CEventListener m_mainEventListener;
+};
+
+#define gVBoxEvents UIVirtualBoxEventHandler::instance()
+
+#endif /* !__UIVirtualBoxEventHandler_h__ */
+
Index: /trunk/src/VBox/Frontends/VirtualBox/src/selector/VBoxSelectorWnd.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/selector/VBoxSelectorWnd.cpp	(revision 30868)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/selector/VBoxSelectorWnd.cpp	(revision 30868)
@@ -0,0 +1,1937 @@
+/** @file
+ *
+ * VBox frontends: Qt GUI ("VirtualBox"):
+ * VBoxSelectorWnd class implementation
+ */
+
+/*
+ * Copyright (C) 2006-2010 Oracle Corporation
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ */
+
+#ifdef VBOX_WITH_PRECOMPILED_HEADERS
+# include "precomp.h"
+#else  /* !VBOX_WITH_PRECOMPILED_HEADERS */
+#include "QISplitter.h"
+#include "UIBar.h"
+#include "UIDownloaderUserManual.h"
+#include "UIExportApplianceWzd.h"
+#include "UIIconPool.h"
+#include "UIImportApplianceWzd.h"
+#include "UINewVMWzd.h"
+#include "UIVMDesktop.h"
+#include "UIVMListView.h"
+#include "UIVirtualBoxEventHandler.h"
+#include "VBoxGlobal.h"
+#include "VBoxMediaManagerDlg.h"
+#include "VBoxProblemReporter.h"
+#include "VBoxSelectorWnd.h"
+#include "VBoxSettingsDialogSpecific.h"
+#include "VBoxToolBar.h"
+#include "VBoxVMLogViewer.h"
+
+/* Global includes */
+#include <QDesktopWidget>
+#include <QMenuBar>
+#include <QResizeEvent>
+
+#include <iprt/buildconfig.h>
+#include <VBox/version.h>
+#ifdef Q_WS_X11
+# include <iprt/env.h>
+#endif
+#endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
+
+// VBoxSelectorWnd class
+////////////////////////////////////////////////////////////////////////////////
+
+/** \class VBoxSelectorWnd
+ *
+ *  The VBoxSelectorWnd class is a VM selector window, one of two main VBox
+ *  GUI windows.
+ *
+ *  This window appears when the user starts the VirtualBox executable.
+ *  It allows to view the list of configured VMs, their settings
+ *  and the current state, create, reconfigure, delete and start VMs.
+ */
+
+/**
+ *  Constructs the VM selector window.
+ *
+ *  @param aSelf pointer to a variable where to store |this| right after
+ *               this object's constructor is called (necessary to avoid
+ *               recursion in VBoxGlobal::selectorWnd())
+ */
+VBoxSelectorWnd::
+VBoxSelectorWnd (VBoxSelectorWnd **aSelf, QWidget* aParent,
+                 Qt::WindowFlags aFlags /* = Qt::Window */)
+    : QIWithRetranslateUI2<QMainWindow> (aParent, aFlags)
+    , mDoneInaccessibleWarningOnce (false)
+{
+    VBoxGlobalSettings settings = vboxGlobal().settings();
+
+    if (aSelf)
+        *aSelf = this;
+
+    statusBar()->setContextMenuPolicy(Qt::CustomContextMenu);
+    connect(statusBar(), SIGNAL(customContextMenuRequested(const QPoint&)),
+            this, SLOT(showViewContextMenu(const QPoint&)));
+
+#if defined (Q_WS_MAC) && (QT_VERSION < 0x040402)
+    qApp->installEventFilter (this);
+#endif /* defined (Q_WS_MAC) && (QT_VERSION < 0x040402) */
+
+#if !(defined (Q_WS_WIN) || defined (Q_WS_MAC))
+    /* The application icon. On Win32, it's built-in to the executable. On Mac
+     * OS X the icon referenced in info.plist is used. */
+    setWindowIcon (QIcon (":/VirtualBox_48px.png"));
+#endif
+
+    /* actions */
+
+    mFileMediaMgrAction = new QAction (this);
+    mFileMediaMgrAction->setIcon(UIIconPool::iconSet(":/diskimage_16px.png"));
+
+    mFileApplianceImportAction = new QAction (this);
+    mFileApplianceImportAction->setIcon(UIIconPool::iconSet(":/import_16px.png"));
+
+    mFileApplianceExportAction = new QAction (this);
+    mFileApplianceExportAction->setIcon(UIIconPool::iconSet(":/export_16px.png"));
+
+    mFileSettingsAction = new QAction(this);
+    mFileSettingsAction->setMenuRole (QAction::PreferencesRole);
+    mFileSettingsAction->setIcon(UIIconPool::iconSet(":/global_settings_16px.png"));
+    mFileExitAction = new QAction (this);
+    mFileExitAction->setMenuRole (QAction::QuitRole);
+    mFileExitAction->setIcon(UIIconPool::iconSet(":/exit_16px.png"));
+
+    mVmNewAction = new QAction (this);
+    mVmNewAction->setIcon(UIIconPool::iconSetFull(
+        QSize (32, 32), QSize (16, 16),
+        ":/vm_new_32px.png", ":/new_16px.png"));
+    mVmConfigAction = new QAction (this);
+    mVmConfigAction->setIcon(UIIconPool::iconSetFull(
+        QSize (32, 32), QSize (16, 16),
+        ":/vm_settings_32px.png", ":/settings_16px.png",
+        ":/vm_settings_disabled_32px.png", ":/settings_dis_16px.png"));
+    mVmDeleteAction = new QAction (this);
+    mVmDeleteAction->setIcon(UIIconPool::iconSetFull(
+        QSize (32, 32), QSize (16, 16),
+        ":/vm_delete_32px.png", ":/delete_16px.png",
+        ":/vm_delete_disabled_32px.png", ":/delete_dis_16px.png"));
+    mVmStartAction = new QAction (this);
+    mVmStartAction->setIcon(UIIconPool::iconSetFull(
+        QSize (32, 32), QSize (16, 16),
+        ":/vm_start_32px.png", ":/start_16px.png",
+        ":/vm_start_disabled_32px.png", ":/start_dis_16px.png"));
+    mVmDiscardAction = new QAction (this);
+    mVmDiscardAction->setIcon(UIIconPool::iconSetFull(
+        QSize (32, 32), QSize (16, 16),
+        ":/vm_discard_32px.png", ":/discard_16px.png",
+        ":/vm_discard_disabled_32px.png", ":/discard_dis_16px.png"));
+    mVmPauseAction = new QAction (this);
+    mVmPauseAction->setCheckable (true);
+    mVmPauseAction->setIcon(UIIconPool::iconSetFull(
+        QSize (32, 32), QSize (16, 16),
+        ":/vm_pause_32px.png", ":/pause_16px.png",
+        ":/vm_pause_disabled_32px.png", ":/pause_disabled_16px.png"));
+    mVmRefreshAction = new QAction (this);
+    mVmRefreshAction->setIcon(UIIconPool::iconSetFull(
+        QSize (32, 32), QSize (16, 16),
+        ":/refresh_32px.png", ":/refresh_16px.png",
+        ":/refresh_disabled_32px.png", ":/refresh_disabled_16px.png"));
+    mVmShowLogsAction = new QAction (this);
+    mVmShowLogsAction->setIcon(UIIconPool::iconSetFull(
+        QSize (32, 32), QSize (16, 16),
+        ":/vm_show_logs_32px.png", ":/show_logs_16px.png",
+        ":/vm_show_logs_disabled_32px.png", ":/show_logs_disabled_16px.png"));
+
+    mHelpActions.setup (this);
+
+    /* VM list toolbar */
+    mVMToolBar = new VBoxToolBar(this);
+    mVMToolBar->setContextMenuPolicy(Qt::CustomContextMenu);
+#ifndef Q_WS_MAC
+    connect(mVMToolBar, SIGNAL(customContextMenuRequested(const QPoint&)),
+            this, SLOT(showViewContextMenu(const QPoint&)));
+#else /* !Q_WS_MAC */
+    /* A simple connect doesn't work on the Mac, also we want receive right
+     * click notifications on the title bar. So register our own handler. */
+    ::darwinRegisterForUnifiedToolbarContextMenuEvents(this);
+#endif /* Q_WS_MAC */
+
+    /* VM list view */
+    mVMListView = new UIVMListView();
+    mVMModel = new UIVMItemModel(mVMListView);
+    mVMListView->setModel(mVMModel);
+    mVMListView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+
+    /* Make non-possible to activate list elements by single click,
+     * this hack should disable the current possibility to do it if present */
+    if (mVMListView->style()->styleHint (QStyle::SH_ItemView_ActivateItemOnSingleClick, 0, mVMListView))
+        mVMListView->setStyleSheet ("activate-on-singleclick : 0");
+
+    m_pSplitter = new QISplitter(this);
+    m_pSplitter->setHandleType(QISplitter::Native);
+
+#define BIG_TOOLBAR
+#if MAC_LEOPARD_STYLE
+    /* Enable unified toolbars on Mac OS X. Available on Qt >= 4.3 */
+    addToolBar (mVMToolBar);
+    mVMToolBar->setMacToolbar();
+    /* Central widget @ horizontal layout */
+    setCentralWidget(m_pSplitter);
+    m_pSplitter->addWidget (mVMListView);
+#else /* MAC_LEOPARD_STYLE */
+//    mVMToolBar->setContentsMargins(5, 5, 0, 0);
+//    addToolBar (mVMToolBar);
+//    m_pSplitter->addWidget (mVMListView);
+    QWidget *pLeftWidget = new QWidget(this);
+    QVBoxLayout *pLeftVLayout = new QVBoxLayout(pLeftWidget);
+    pLeftVLayout->setContentsMargins(0, 0, 0, 0);
+    pLeftVLayout->setSpacing(0);
+# ifdef BIG_TOOLBAR
+    m_pBar = new UIBar(this);
+    m_pBar->setContentWidget(mVMToolBar);
+    pLeftVLayout->addWidget(m_pBar);
+    pLeftVLayout->addWidget(m_pSplitter);
+    setCentralWidget(pLeftWidget);
+    m_pSplitter->addWidget(mVMListView);
+# else /* BIG_TOOLBAR */
+    pLeftVLayout->addWidget(mVMToolBar);
+    pLeftVLayout->addWidget(mVMListView);
+    setCentralWidget(m_pSplitter);
+    m_pSplitter->addWidget(pLeftWidget);
+# endif /* BIG_TOOLBAR */
+#endif /* MAC_LEOPARD_STYLE */
+
+    /* add actions to the toolbar */
+
+    mVMToolBar->setIconSize (QSize (32, 32));
+    mVMToolBar->setToolButtonStyle (Qt::ToolButtonTextUnderIcon);
+//    mVMToolBar->setSizePolicy (QSizePolicy::Fixed, QSizePolicy::Preferred);
+
+    mVMToolBar->addAction (mVmNewAction);
+    mVMToolBar->addAction (mVmConfigAction);
+#if 0 /* delete action is really rare */
+    mVMToolBar->addAction (mVmDeleteAction);
+#endif
+    mVMToolBar->addAction (mVmStartAction);
+    mVMToolBar->addAction (mVmDiscardAction);
+
+    /* VM tab widget containing details and snapshots tabs */
+    QWidget *w = new QWidget();
+    QVBoxLayout *pVBox = new QVBoxLayout(w);
+    pVBox->setContentsMargins(0, 0, 0, 0);
+
+    m_pVMDesktop = new UIVMDesktop(mVMToolBar, mVmRefreshAction, this);
+    pVBox->addWidget(m_pVMDesktop);
+
+    m_pSplitter->addWidget (w);
+
+    /* Set the initial distribution. The right site is bigger. */
+    m_pSplitter->setStretchFactor(0, 2);
+    m_pSplitter->setStretchFactor(1, 3);
+
+    /* Configure menubar */
+    menuBar()->setContextMenuPolicy(Qt::CustomContextMenu);
+    connect(menuBar(), SIGNAL(customContextMenuRequested(const QPoint&)),
+            this, SLOT(showViewContextMenu(const QPoint&)));
+
+    /* add actions to menubar */
+    mFileMenu = menuBar()->addMenu (QString::null);
+    mFileMenu->addAction (mFileMediaMgrAction);
+    mFileMenu->addAction (mFileApplianceImportAction);
+    mFileMenu->addAction (mFileApplianceExportAction);
+#ifndef Q_WS_MAC
+    mFileMenu->addSeparator();
+#endif /* Q_WS_MAC */
+    mFileMenu->addAction (mFileSettingsAction);
+#ifndef Q_WS_MAC
+    mFileMenu->addSeparator();
+#endif /* Q_WS_MAC */
+    mFileMenu->addAction (mFileExitAction);
+
+    mVMMenu = menuBar()->addMenu (QString::null);
+    mVMMenu->addAction (mVmNewAction);
+    mVMMenu->addAction (mVmConfigAction);
+    mVMMenu->addAction (mVmDeleteAction);
+    mVMMenu->addSeparator();
+    mVMMenu->addAction (mVmStartAction);
+    mVMMenu->addAction (mVmDiscardAction);
+    mVMMenu->addAction (mVmPauseAction);
+    mVMMenu->addSeparator();
+    mVMMenu->addAction (mVmRefreshAction);
+    mVMMenu->addAction (mVmShowLogsAction);
+
+    mVMCtxtMenu = new QMenu (this);
+    mVMCtxtMenu->addAction (mVmConfigAction);
+    mVMCtxtMenu->addAction (mVmDeleteAction);
+    mVMCtxtMenu->addSeparator();
+    mVMCtxtMenu->addAction (mVmStartAction);
+    mVMCtxtMenu->addAction (mVmDiscardAction);
+    mVMCtxtMenu->addAction (mVmPauseAction);
+    mVMCtxtMenu->addSeparator();
+    mVMCtxtMenu->addAction (mVmRefreshAction);
+    mVMCtxtMenu->addAction (mVmShowLogsAction);
+
+    /* Make sure every status bar hint from the context menu is cleared when
+     * the menu is closed. */
+    connect (mVMCtxtMenu, SIGNAL(aboutToHide()),
+             statusBar(), SLOT(clearMessage()));
+
+    mHelpMenu = menuBar()->addMenu (QString::null);
+    mHelpActions.addTo (mHelpMenu);
+
+#ifdef VBOX_GUI_WITH_SYSTRAY
+    mTrayIcon = new VBoxTrayIcon (this, mVMModel);
+    Assert (mTrayIcon);
+    connect (mTrayIcon, SIGNAL (activated (QSystemTrayIcon::ActivationReason)),
+             this, SLOT (trayIconActivated (QSystemTrayIcon::ActivationReason)));
+#endif
+
+    retranslateUi();
+
+    CVirtualBox vbox = vboxGlobal().virtualBox();
+    /* Restore the position of the window */
+    {
+        QString winPos = vbox.GetExtraData (VBoxDefs::GUI_LastWindowPosition);
+
+        bool ok = false, max = false;
+        int x = 0, y = 0, w = 0, h = 0;
+        x = winPos.section (',', 0, 0).toInt (&ok);
+        if (ok)
+            y = winPos.section (',', 1, 1).toInt (&ok);
+        if (ok)
+            w = winPos.section (',', 2, 2).toInt (&ok);
+        if (ok)
+            h = winPos.section (',', 3, 3).toInt (&ok);
+        if (ok)
+            max = winPos.section (',', 4, 4) == VBoxDefs::GUI_LastWindowState_Max;
+
+        QRect ar = ok ? QApplication::desktop()->availableGeometry (QPoint (x, y)) :
+                        QApplication::desktop()->availableGeometry (this);
+
+        if (ok /* previous parameters were read correctly */
+            && (y > 0) && (y < ar.bottom()) /* check vertical bounds */
+            && (x + w > ar.left()) && (x < ar.right()) /* & horizontal bounds */)
+        {
+            mNormalGeo.moveTo (x, y);
+            mNormalGeo.setSize (QSize (w, h).expandedTo (minimumSizeHint())
+                                            .boundedTo (ar.size()));
+            setGeometry (mNormalGeo);
+            if (max) /* maximize if needed */
+                showMaximized();
+        }
+        else
+        {
+            mNormalGeo.setSize (QSize (770, 550).expandedTo (minimumSizeHint())
+                                                .boundedTo (ar.size()));
+            mNormalGeo.moveCenter (ar.center());
+            setGeometry (mNormalGeo);
+        }
+    }
+
+    /* Update the list */
+    refreshVMList();
+
+    /* Reset to the first item */
+    mVMListView->selectItemByRow (0);
+
+    /* restore the position of vm selector */
+    {
+        QString prevVMId = vbox.GetExtraData (VBoxDefs::GUI_LastVMSelected);
+
+        mVMListView->selectItemById (prevVMId);
+    }
+
+    /* Read the splitter handle position */
+    {
+        QList<int> sizes = vbox.GetExtraDataIntList(VBoxDefs::GUI_SplitterSizes);
+        if (sizes.size() == 2)
+            m_pSplitter->setSizes(sizes);
+    }
+
+    /* Restore toolbar and statusbar visibility */
+    {
+        QString strToolbar = vbox.GetExtraData(VBoxDefs::GUI_Toolbar);
+        QString strStatusbar = vbox.GetExtraData(VBoxDefs::GUI_Statusbar);
+
+#ifdef Q_WS_MAC
+        mVMToolBar->setVisible(strToolbar.isEmpty() || strToolbar == "true");
+#else /* Q_WS_MAC */
+        m_pBar->setVisible(strToolbar.isEmpty() || strToolbar == "true");
+#endif /* !Q_WS_MAC */
+        statusBar()->setVisible(strStatusbar.isEmpty() || strStatusbar == "true");
+    }
+
+    /* refresh the details et all (necessary for the case when the stored
+     * selection is still the first list item) */
+    vmListViewCurrentChanged();
+
+    /* signals and slots connections */
+    connect (mFileMediaMgrAction, SIGNAL (triggered()), this, SLOT (fileMediaMgr()));
+    connect (mFileApplianceImportAction, SIGNAL (triggered()), this, SLOT (fileImportAppliance()));
+    connect (mFileApplianceExportAction, SIGNAL (triggered()), this, SLOT (fileExportAppliance()));
+    connect (mFileSettingsAction, SIGNAL (triggered()), this, SLOT (fileSettings()));
+    connect (mFileExitAction, SIGNAL (triggered()), this, SLOT (fileExit()));
+    connect (mVmNewAction, SIGNAL (triggered()), this, SLOT (vmNew()));
+
+    connect (mVmConfigAction, SIGNAL (triggered()), this, SLOT (vmSettings()));
+    connect (mVmDeleteAction, SIGNAL (triggered()), this, SLOT (vmDelete()));
+    connect (mVmStartAction, SIGNAL (triggered()), this, SLOT (vmStart()));
+    connect (mVmDiscardAction, SIGNAL (triggered()), this, SLOT (vmDiscard()));
+    connect (mVmPauseAction, SIGNAL (toggled (bool)), this, SLOT (vmPause (bool)));
+    connect (mVmRefreshAction, SIGNAL (triggered()), this, SLOT (vmRefresh()));
+    connect (mVmShowLogsAction, SIGNAL (triggered()), this, SLOT (vmShowLogs()));
+
+    connect (mVMListView, SIGNAL (currentChanged()),
+             this, SLOT (vmListViewCurrentChanged()));
+    connect (mVMListView, SIGNAL (activated()),
+             this, SLOT (vmStart()));
+    connect (mVMListView, SIGNAL (customContextMenuRequested (const QPoint &)),
+             this, SLOT (showContextMenu (const QPoint &)));
+
+    connect (m_pVMDesktop, SIGNAL(linkClicked(const QString &)),
+             this, SLOT(vmSettings(const QString &)));
+
+    /* listen to media enumeration signals */
+    connect (&vboxGlobal(), SIGNAL (mediumEnumStarted()),
+             this, SLOT (mediumEnumStarted()));
+    connect (&vboxGlobal(), SIGNAL (mediumEnumFinished (const VBoxMediaList &)),
+             this, SLOT (mediumEnumFinished (const VBoxMediaList &)));
+
+    /* connect VirtualBox events */
+    connect (gVBoxEvents, SIGNAL(sigMachineStateChange(QString, KMachineState)),
+             this, SLOT(machineStateChanged(QString, KMachineState)));
+    connect (gVBoxEvents, SIGNAL(sigMachineDataChange(QString)),
+             this, SLOT(machineDataChanged(QString)));
+    connect (gVBoxEvents, SIGNAL(sigMachineRegistered(QString, bool)),
+             this, SLOT(machineRegistered(QString, bool)));
+    connect (gVBoxEvents, SIGNAL(sigSessionStateChange(QString, KSessionState)),
+             this, SLOT(sessionStateChanged(QString, KSessionState)));
+    connect (gVBoxEvents, SIGNAL(sigSnapshotChange(QString, QString)),
+             this, SLOT(snapshotChanged(QString, QString)));
+#ifdef VBOX_GUI_WITH_SYSTRAY
+    connect (gEDataEvents, SIGNAL(sigMainWindowCountChange(int)),
+             this, SLOT(mainWindowCountChanged(int)));
+    connect (gEDataEvents, SIGNAL(sigCanShowTrayIcon(bool)),
+             this, SLOT(trayIconCanShow(bool)));
+    connect (gEDataEvents, SIGNAL(sigTrayIconChange(bool)),
+             this, SLOT(trayIconChanged(bool)));
+    connect (&vboxGlobal(), SIGNAL(sigTrayIconShow(bool)),
+             this, SLOT(trayIconShow(bool)));
+#endif
+
+    /* Listen to potential downloaders signals: */
+    connect(&vboxProblem(), SIGNAL(sigDownloaderUserManualCreated()), this, SLOT(sltDownloaderUserManualEmbed()));
+
+    /* bring the VM list to the focus */
+    mVMListView->setFocus();
+}
+
+VBoxSelectorWnd::~VBoxSelectorWnd()
+{
+    CVirtualBox vbox = vboxGlobal().virtualBox();
+
+    /* Destroy our event handlers */
+    UIVirtualBoxEventHandler::destroy();
+
+    /* Save the position of the window */
+    {
+        int y = mNormalGeo.y();
+        QString winPos = QString ("%1,%2,%3,%4")
+            .arg (mNormalGeo.x()).arg (y)
+            .arg (mNormalGeo.width()).arg (mNormalGeo.height());
+#ifdef Q_WS_MAC
+        ::darwinUnregisterForUnifiedToolbarContextMenuEvents(this);
+        if (::darwinIsWindowMaximized(this))
+#else /* Q_WS_MAC */
+        if (isMaximized())
+#endif /* !Q_WS_MAC */
+            winPos += QString (",%1").arg (VBoxDefs::GUI_LastWindowState_Max);
+
+        vbox.SetExtraData (VBoxDefs::GUI_LastWindowPosition, winPos);
+    }
+
+    /* Save VM selector position */
+    {
+        UIVMItem *item = mVMListView->selectedItem();
+        QString curVMId = item ?
+            QString (item->id()) :
+            QString::null;
+        vbox.SetExtraData (VBoxDefs::GUI_LastVMSelected, curVMId);
+    }
+
+    /* Save the splitter handle position */
+    {
+        vbox.SetExtraDataIntList(VBoxDefs::GUI_SplitterSizes, m_pSplitter->sizes());
+    }
+
+#ifdef VBOX_GUI_WITH_SYSTRAY
+    /* Delete systray menu object */
+    delete mTrayIcon;
+    mTrayIcon = NULL;
+#endif
+
+    /* Delete the items from our model */
+    mVMModel->clear();
+}
+
+//
+// Public slots
+/////////////////////////////////////////////////////////////////////////////
+
+void VBoxSelectorWnd::fileMediaMgr()
+{
+    VBoxMediaManagerDlg::showModeless (this);
+}
+
+void VBoxSelectorWnd::fileImportAppliance()
+{
+    UIImportApplianceWzd wzd (this);
+
+    wzd.exec();
+}
+
+void VBoxSelectorWnd::fileExportAppliance()
+{
+    QString name;
+
+    UIVMItem *item = mVMListView->selectedItem();
+    if (item)
+        name = item->name();
+
+    UIExportApplianceWzd wzd (this, name);
+
+    wzd.exec();
+}
+
+void VBoxSelectorWnd::fileSettings()
+{
+    VBoxGlobalSettings settings = vboxGlobal().settings();
+    CSystemProperties props = vboxGlobal().virtualBox().GetSystemProperties();
+
+    VBoxSettingsDialog *dlg = new VBoxGLSettingsDlg (this);
+    dlg->getFrom();
+
+    if (dlg->exec() == QDialog::Accepted)
+        dlg->putBackTo();
+
+    delete dlg;
+}
+
+void VBoxSelectorWnd::fileExit()
+{
+    /* We have to check if there are any open windows beside this mainwindow
+     * (e.g. VDM) and if so close them. Note that the default behavior is
+     * different to Qt3 where a *mainWidget* exists & if this going to close
+     * all other windows are closed automatically. We do the same below. */
+    foreach (QWidget *widget, QApplication::topLevelWidgets())
+    {
+        if (widget->isVisible() &&
+            widget != this)
+            widget->close();
+    }
+    /* We close this widget last. */
+    close();
+}
+
+void VBoxSelectorWnd::vmNew()
+{
+    UINewVMWzd wzd (this);
+    if (wzd.exec() == QDialog::Accepted)
+    {
+        CMachine m = wzd.machine();
+
+        /* wait until the list is updated by OnMachineRegistered() */
+        QModelIndex index;
+        while (!index.isValid())
+        {
+            qApp->processEvents();
+            index = mVMModel->indexById (m.GetId());
+        }
+        mVMListView->setCurrentIndex (index);
+    }
+}
+
+/**
+ *  Opens the VM settings dialog.
+ */
+void VBoxSelectorWnd::vmSettings (const QString &aCategory /* = QString::null */,
+                                  const QString &aControl /* = QString::null */,
+                                  const QString &aUuid /* = QString::null */)
+{
+    if (!aCategory.isEmpty() && aCategory [0] != '#')
+    {
+        /* Assume it's a href from the Details HTML */
+        vboxGlobal().openURL (aCategory);
+        return;
+    }
+    QString strCategory = aCategory;
+    QString strControl = aControl;
+    /* Maybe the control is coded into the URL by %% */
+    if (aControl == QString::null)
+    {
+        QStringList parts = aCategory.split("%%");
+        if (parts.size() == 2)
+        {
+            strCategory = parts.at(0);
+            strControl = parts.at(1);
+        }
+    }
+
+    UIVMItem *item = aUuid.isNull() ? mVMListView->selectedItem() :
+                       mVMModel->itemById (aUuid);
+
+    AssertMsgReturnVoid (item, ("Item must be always selected here"));
+
+    // open a direct session to modify VM settings
+    QString id = item->id();
+    CSession session = vboxGlobal().openSession (id);
+    if (session.isNull())
+        return;
+
+    CMachine m = session.GetMachine();
+    AssertMsgReturn (!m.isNull(), ("Machine must not be null"), (void) 0);
+
+    VBoxSettingsDialog *dlg = new VBoxVMSettingsDlg (this, m, strCategory, strControl);
+    dlg->getFrom();
+
+    if (dlg->exec() == QDialog::Accepted)
+    {
+        QString oldName = m.GetName();
+        dlg->putBackTo();
+
+        m.SaveSettings();
+        if (m.isOk())
+        {
+            if (oldName.compare (m.GetName()))
+                mVMModel->sort();
+        }
+        else
+            vboxProblem().cannotSaveMachineSettings (m);
+
+        /* To check use the result in future
+         * vboxProblem().cannotApplyMachineSettings (m, res); */
+    }
+
+    delete dlg;
+
+    mVMListView->setFocus();
+
+    session.Close();
+}
+
+void VBoxSelectorWnd::vmDelete (const QString &aUuid /* = QString::null */)
+{
+    UIVMItem *item = aUuid.isNull() ? mVMListView->selectedItem() :
+                       mVMModel->itemById (aUuid);
+
+    AssertMsgReturnVoid (item, ("Item must be always selected here"));
+
+    if (vboxProblem().confirmMachineDeletion (item->machine()))
+    {
+        CVirtualBox vbox = vboxGlobal().virtualBox();
+        QString id = item->id();
+        bool ok = false;
+        if (item->accessible())
+        {
+            /* Open a direct session to modify VM settings */
+            CSession session = vboxGlobal().openSession (id);
+            if (session.isNull())
+                return;
+            CMachine machine = session.GetMachine();
+            /* Detach all attached Hard Disks */
+            CMediumAttachmentVector vec = machine.GetMediumAttachments();
+            for (int i = 0; i < vec.size(); ++ i)
+            {
+                CMediumAttachment hda = vec [i];
+                const QString ctlName = hda.GetController();
+
+                machine.DetachDevice(ctlName, hda.GetPort(), hda.GetDevice());
+                if (!machine.isOk())
+                {
+                    CStorageController ctl = machine.GetStorageControllerByName(ctlName);
+                    vboxProblem().cannotDetachDevice (this, machine, VBoxDefs::MediumType_HardDisk,
+                        vboxGlobal().getMedium (CMedium (hda.GetMedium())).location(),
+                        ctl.GetBus(), hda.GetPort(), hda.GetDevice());
+                }
+            }
+            /* Commit changes */
+            machine.SaveSettings();
+            if (!machine.isOk())
+                vboxProblem().cannotSaveMachineSettings (machine);
+            else
+                ok = true;
+            session.Close();
+        }
+        else
+            ok = true;
+
+        if (ok)
+        {
+            CMachine machine = item->machine();
+            vbox.UnregisterMachine (id);
+            if (vbox.isOk() && item->accessible())
+            {
+                /* delete machine settings */
+                machine.DeleteSettings();
+                /* remove the item shortly: cmachine it refers to is no longer valid! */
+                int row = mVMModel->rowById (item->id());
+                mVMModel->removeItem (item);
+                delete item;
+                mVMListView->ensureSomeRowSelected (row);
+            }
+            if (!vbox.isOk() || !machine.isOk())
+                vboxProblem().cannotDeleteMachine (vbox, machine);
+        }
+    }
+}
+
+void VBoxSelectorWnd::vmStart (const QString &aUuid /* = QString::null */)
+{
+    QUuid uuid (aUuid);
+    UIVMItem *item = uuid.isNull() ? mVMListView->selectedItem() :
+                       mVMModel->itemById (aUuid);
+
+    AssertMsgReturnVoid (item, ("Item must be always selected here"));
+
+    /* Are we called from the mVMListView's activated() signal? */
+    if (uuid.isNull())
+    {
+        /* We always get here when mVMListView emits the activated() signal,
+         * so we must explicitly check if the action is enabled or not. */
+        if (!mVmStartAction->isEnabled())
+            return;
+    }
+
+    AssertMsg (!vboxGlobal().isVMConsoleProcess(),
+               ("Must NOT be a VM console process"));
+
+    /* just switch to the VM window if it already exists */
+    if (item->canSwitchTo())
+    {
+        item->switchTo();
+        return;
+    }
+
+    AssertMsg (   item->state() == KMachineState_PoweredOff
+               || item->state() == KMachineState_Saved
+               || item->state() == KMachineState_Teleported
+               || item->state() == KMachineState_Aborted
+               , ("Machine must be PoweredOff/Saved/Aborted (%d)", item->state()));
+
+    QString id = item->id();
+    CVirtualBox vbox = vboxGlobal().virtualBox();
+    CSession session;
+
+    session.createInstance (CLSID_Session);
+    if (session.isNull())
+    {
+        vboxProblem().cannotOpenSession (session);
+        return;
+    }
+
+#if defined (Q_OS_WIN32)
+    /* allow the started VM process to make itself the foreground window */
+    AllowSetForegroundWindow (ASFW_ANY);
+#endif
+
+    QString env;
+#if defined (Q_WS_X11)
+    /* make sure the VM process will start on the same display as the Selector */
+    const char *display = RTEnvGet ("DISPLAY");
+    if (display)
+        env.append(QString("DISPLAY=%1\n").arg(display));
+    const char *xauth = RTEnvGet ("XAUTHORITY");
+    if (xauth)
+        env.append(QString("XAUTHORITY=%1\n").arg(xauth));
+#endif
+
+    CProgress progress = vbox.OpenRemoteSession (session, id, "GUI/Qt", env);
+    if (!vbox.isOk())
+    {
+        vboxProblem().cannotOpenSession (vbox, item->machine());
+        return;
+    }
+
+    /* Hide the "VM spawning" progress dialog */
+    /* I hope 1 minute will be enough to spawn any running VM silently, isn't it? */
+    int iSpawningDuration = 60000;
+    vboxProblem().showModalProgressDialog(progress, item->name(), this, iSpawningDuration);
+    if (progress.GetResultCode() != 0)
+        vboxProblem().cannotOpenSession(vbox, item->machine(), progress);
+
+    session.Close();
+}
+
+void VBoxSelectorWnd::vmDiscard (const QString &aUuid /* = QString::null */)
+{
+    UIVMItem *item = aUuid.isNull() ? mVMListView->selectedItem() :
+                       mVMModel->itemById (aUuid);
+
+    AssertMsgReturnVoid (item, ("Item must be always selected here"));
+
+    if (!vboxProblem().confirmDiscardSavedState (item->machine()))
+        return;
+
+    /* open a session to modify VM settings */
+    QString id = item->id();
+    CSession session;
+    CVirtualBox vbox = vboxGlobal().virtualBox();
+    session.createInstance (CLSID_Session);
+    if (session.isNull())
+    {
+        vboxProblem().cannotOpenSession (session);
+        return;
+    }
+    vbox.OpenSession (session, id);
+    if (!vbox.isOk())
+    {
+        vboxProblem().cannotOpenSession (vbox, item->machine());
+        return;
+    }
+
+    CConsole console = session.GetConsole();
+    console.ForgetSavedState(true);
+    if (!console.isOk())
+        vboxProblem().cannotDiscardSavedState (console);
+
+    session.Close();
+}
+
+void VBoxSelectorWnd::vmPause (bool aPause, const QString &aUuid /* = QString::null */)
+{
+    UIVMItem *item = aUuid.isNull() ? mVMListView->selectedItem() :
+                       mVMModel->itemById (aUuid);
+
+    AssertMsgReturnVoid (item, ("Item must be always selected here"));
+
+    CSession session = vboxGlobal().openExistingSession (item->id());
+    if (session.isNull())
+        return;
+
+    CConsole console = session.GetConsole();
+    if (console.isNull())
+        return;
+
+    if (aPause)
+        console.Pause();
+    else
+        console.Resume();
+
+    bool ok = console.isOk();
+    if (!ok)
+    {
+        if (aPause)
+            vboxProblem().cannotPauseMachine (console);
+        else
+            vboxProblem().cannotResumeMachine (console);
+    }
+
+    session.Close();
+}
+
+void VBoxSelectorWnd::vmRefresh (const QString &aUuid /* = QString::null */)
+{
+    UIVMItem *item = aUuid.isNull() ? mVMListView->selectedItem() :
+                       mVMModel->itemById (aUuid);
+
+    AssertMsgReturnVoid (item, ("Item must be always selected here"));
+
+    refreshVMItem (item->id(),
+                   true /* aDetails */,
+                   true /* aSnapshot */,
+                   true /* aDescription */);
+}
+
+void VBoxSelectorWnd::vmShowLogs (const QString &aUuid /* = QString::null */)
+{
+    UIVMItem *item = aUuid.isNull() ? mVMListView->selectedItem() :
+                       mVMModel->itemById (aUuid);
+
+    AssertMsgReturnVoid (item, ("Item must be always selected here"));
+
+    CMachine machine = item->machine();
+    VBoxVMLogViewer::createLogViewer (this, machine);
+}
+
+void VBoxSelectorWnd::refreshVMList()
+{
+    CVirtualBox vbox = vboxGlobal().virtualBox();
+    CMachineVector vec = vbox.GetMachines();
+    for (CMachineVector::ConstIterator m = vec.begin();
+         m != vec.end(); ++ m)
+        mVMModel->addItem (new UIVMItem (*m));
+    mVMModel->sort();
+
+    vmListViewCurrentChanged();
+
+#ifdef VBOX_GUI_WITH_SYSTRAY
+    if (vboxGlobal().isTrayMenu())
+        mTrayIcon->refresh();
+#endif
+}
+
+void VBoxSelectorWnd::refreshVMItem (const QString &aID, bool aDetails,
+                                                       bool aSnapshots,
+                                                       bool aDescription)
+{
+    UIVMItem *item = mVMModel->itemById (aID);
+    if (item)
+    {
+        mVMModel->refreshItem (item);
+        if (item && item->id() == aID)
+            vmListViewCurrentChanged (aDetails, aSnapshots, aDescription);
+    }
+}
+
+void VBoxSelectorWnd::showContextMenu (const QPoint &aPoint)
+{
+    /* Send a context menu request */
+    const QModelIndex &index = mVMListView->indexAt (aPoint);
+    if (index.isValid())
+        if (mVMListView->model()->data (index,
+            UIVMItemModel::UIVMItemPtrRole).value <UIVMItem*>())
+                mVMCtxtMenu->exec (mVMListView->mapToGlobal (aPoint));
+}
+
+#ifdef VBOX_GUI_WITH_SYSTRAY
+
+void VBoxSelectorWnd::trayIconActivated (QSystemTrayIcon::ActivationReason aReason)
+{
+    switch (aReason)
+    {
+        case QSystemTrayIcon::Context:
+
+            mTrayIcon->refresh();
+            break;
+
+        case QSystemTrayIcon::Trigger:
+            break;
+
+        case QSystemTrayIcon::DoubleClick:
+
+            vboxGlobal().trayIconShowSelector();
+            break;
+
+        case QSystemTrayIcon::MiddleClick:
+            break;
+
+        default:
+            break;
+    }
+}
+
+void VBoxSelectorWnd::showWindow()
+{
+    showNormal();
+    raise();
+    activateWindow();
+}
+
+#endif // VBOX_GUI_WITH_SYSTRAY
+
+// Protected members
+/////////////////////////////////////////////////////////////////////////////
+
+bool VBoxSelectorWnd::event (QEvent *e)
+{
+    switch (e->type())
+    {
+        /* By handling every Resize and Move we keep track of the normal
+         * (non-minimized and non-maximized) window geometry. Shame on Qt
+         * that it doesn't provide this geometry in its public APIs. */
+
+        case QEvent::Resize:
+        {
+            QResizeEvent *re = (QResizeEvent *) e;
+            if ((windowState() & (Qt::WindowMaximized | Qt::WindowMinimized |
+                                  Qt::WindowFullScreen)) == 0)
+                mNormalGeo.setSize (re->size());
+            break;
+        }
+        case QEvent::Move:
+        {
+            if ((windowState() & (Qt::WindowMaximized | Qt::WindowMinimized |
+                                  Qt::WindowFullScreen)) == 0)
+                mNormalGeo.moveTo (geometry().x(), geometry().y());
+            break;
+        }
+        case QEvent::WindowDeactivate:
+        {
+            /* Make sure every status bar hint is cleared when the window lost
+             * focus. */
+            statusBar()->clearMessage();
+            break;
+        }
+#ifdef Q_WS_MAC
+        case QEvent::ContextMenu:
+        {
+            /* This is the unified context menu event. Lets show the context
+             * menu. */
+            QContextMenuEvent *pCE = static_cast<QContextMenuEvent*>(e);
+            showViewContextMenu(pCE->globalPos());
+            /* Accept it to interrupt the chain. */
+            pCE->accept();
+            return false;
+            break;
+        }
+        case QEvent::ToolBarChange:
+        {
+            CVirtualBox vbox = vboxGlobal().virtualBox();
+            /* We have to invert the isVisible check one time, cause this event
+             * is sent *before* the real toggle is done. Really intuitive
+             * Trolls. */
+            vbox.SetExtraData(VBoxDefs::GUI_Toolbar, !::darwinIsToolbarVisible(mVMToolBar) ? "true" : "false");
+            break;
+        }
+#endif /* Q_WS_MAC */
+        default:
+            break;
+    }
+
+    return QMainWindow::event (e);
+}
+
+void VBoxSelectorWnd::closeEvent (QCloseEvent *aEvent)
+{
+#ifdef VBOX_GUI_WITH_SYSTRAY
+    /* Needed for breaking out of the while() loop in main(). */
+    if (vboxGlobal().isTrayMenu())
+        vboxGlobal().setTrayMenu (false);
+#endif
+
+    emit closing();
+    QMainWindow::closeEvent (aEvent);
+}
+
+#if defined (Q_WS_MAC) && (QT_VERSION < 0x040402)
+bool VBoxSelectorWnd::eventFilter (QObject *aObject, QEvent *aEvent)
+{
+    if (!isActiveWindow())
+        return QIWithRetranslateUI2<QMainWindow>::eventFilter (aObject, aEvent);
+
+    if (qobject_cast<QWidget*> (aObject) &&
+        qobject_cast<QWidget*> (aObject)->window() != this)
+        return QIWithRetranslateUI2<QMainWindow>::eventFilter (aObject, aEvent);
+
+    switch (aEvent->type())
+    {
+        case QEvent::KeyPress:
+            {
+                /* Bug in Qt below 4.4.2. The key events are send to the current
+                 * window even if a menu is shown & has the focus. See
+                 * http://trolltech.com/developer/task-tracker/index_html?method=entry&id=214681. */
+                if (::darwinIsMenuOpen())
+                    return true;
+            }
+        default:
+            break;
+    }
+    return QIWithRetranslateUI2<QMainWindow>::eventFilter (aObject, aEvent);
+}
+#endif /* defined (Q_WS_MAC) && (QT_VERSION < 0x040402) */
+
+/**
+ *  Sets the strings of the subwidgets using the current
+ *  language.
+ */
+void VBoxSelectorWnd::retranslateUi()
+{
+#ifdef VBOX_OSE
+    QString title (tr ("VirtualBox OSE"));
+#else
+    QString title (VBOX_PRODUCT);
+#endif
+
+#ifdef VBOX_BLEEDING_EDGE
+    title += QString(" EXPERIMENTAL build ")
+          +  QString(RTBldCfgVersion())
+          +  QString(" r")
+          +  QString(RTBldCfgRevisionStr())
+          +  QString(" - "VBOX_BLEEDING_EDGE);
+#endif
+
+    setWindowTitle (title);
+
+    /* ensure the details and screenshot view are updated */
+    vmListViewCurrentChanged();
+
+    mFileMediaMgrAction->setText (tr ("&Virtual Media Manager..."));
+    mFileMediaMgrAction->setShortcut (QKeySequence ("Ctrl+D"));
+    mFileMediaMgrAction->setStatusTip (tr ("Display the Virtual Media Manager dialog"));
+
+    mFileApplianceImportAction->setText (tr ("&Import Appliance..."));
+    mFileApplianceImportAction->setShortcut (QKeySequence ("Ctrl+I"));
+    mFileApplianceImportAction->setStatusTip (tr ("Import an appliance into VirtualBox"));
+
+    mFileApplianceExportAction->setText (tr ("&Export Appliance..."));
+    mFileApplianceExportAction->setShortcut (QKeySequence ("Ctrl+E"));
+    mFileApplianceExportAction->setStatusTip (tr ("Export one or more VirtualBox virtual machines as an appliance"));
+
+#ifdef Q_WS_MAC
+    /*
+     * Macification: Getting the right menu as application preference menu item.
+     *
+     * QMenuBar::isCommand() in qmenubar_mac.cpp doesn't recognize "Setting"(s)
+     * unless it's in the first position. So, we use the Mac term here to make
+     * sure we get picked instead of the VM settings.
+     *
+     * Now, since both QMenuBar and we translate these strings, it's going to
+     * be really interesting to see how this plays on non-english systems...
+     */
+    mFileSettingsAction->setText (tr ("&Preferences...", "global settings"));
+#else
+    /*
+     * ...and on other platforms we use "Preferences" as well. The #ifdef is
+     * left because of the possible localization problems on Mac we first need
+     * to figure out.
+     */
+    mFileSettingsAction->setText (tr ("&Preferences...", "global settings"));
+#endif
+    mFileSettingsAction->setShortcut (QKeySequence ("Ctrl+G"));
+    mFileSettingsAction->setStatusTip (tr ("Display the global settings dialog"));
+
+    mFileExitAction->setText (tr ("E&xit"));
+    mFileExitAction->setShortcut (QKeySequence ("Ctrl+Q"));
+    mFileExitAction->setStatusTip (tr ("Close application"));
+
+    mVmNewAction->setText (tr ("&New..."));
+    mVmNewAction->setShortcut (QKeySequence ("Ctrl+N"));
+    mVmNewAction->setStatusTip (tr ("Create a new virtual machine"));
+    mVmNewAction->setToolTip (mVmNewAction->text().remove ('&').remove ('.') +
+        QString (" (%1)").arg (mVmNewAction->shortcut().toString()));
+
+    mVmConfigAction->setText (tr ("&Settings..."));
+    mVmConfigAction->setShortcut (QKeySequence ("Ctrl+S"));
+    mVmConfigAction->setStatusTip (tr ("Configure the selected virtual machine"));
+    mVmConfigAction->setToolTip (mVmConfigAction->text().remove ('&').remove ('.') +
+        QString (" (%1)").arg (mVmConfigAction->shortcut().toString()));
+
+    mVmDeleteAction->setText (tr ("&Delete"));
+    mVmDeleteAction->setShortcut (QKeySequence ("Ctrl+R"));
+    mVmDeleteAction->setStatusTip (tr ("Delete the selected virtual machine"));
+
+    /* Note: mVmStartAction text is set up in vmListViewCurrentChanged() */
+
+    mVmDiscardAction->setText (tr ("D&iscard"));
+    mVmDiscardAction->setStatusTip (
+        tr ("Discard the saved state of the selected virtual machine"));
+
+    mVmPauseAction->setText (tr ("&Pause"));
+    mVmPauseAction->setStatusTip (
+        tr ("Suspend the execution of the virtual machine"));
+
+    mVmRefreshAction->setText (tr ("Re&fresh"));
+    mVmRefreshAction->setStatusTip (
+        tr ("Refresh the accessibility state of the selected virtual machine"));
+
+    mVmShowLogsAction->setText (tr ("Show &Log..."));
+    mVmShowLogsAction->setIconText (tr ("Log", "icon text"));
+    mVmShowLogsAction->setShortcut (QKeySequence ("Ctrl+L"));
+    mVmShowLogsAction->setStatusTip (
+        tr ("Show the log files of the selected virtual machine"));
+
+    mHelpActions.retranslateUi();
+
+#ifdef Q_WS_MAC
+    mFileMenu->setTitle (tr("&File", "Mac OS X version"));
+#else /* Q_WS_MAC */
+    mFileMenu->setTitle (tr("&File", "Non Mac OS X version"));
+#endif /* !Q_WS_MAC */
+    mVMMenu->setTitle (tr ("&Machine"));
+    mHelpMenu->setTitle (tr ("&Help"));
+
+#ifdef VBOX_GUI_WITH_SYSTRAY
+    if (vboxGlobal().isTrayMenu())
+    {
+        mTrayIcon->retranslateUi();
+        mTrayIcon->refresh();
+    }
+#endif
+
+#ifdef QT_MAC_USE_COCOA
+    /* There is a bug in Qt Cocoa which result in showing a "more arrow" when
+       the necessary size of the toolbar is increased. Also for some languages
+       the with doesn't match if the text increase. So manually adjust the size
+       after changing the text. */
+    mVMToolBar->updateLayout();
+#endif /* QT_MAC_USE_COCOA */
+}
+
+
+// Private members
+/////////////////////////////////////////////////////////////////////////////
+
+//
+// Private slots
+/////////////////////////////////////////////////////////////////////////////
+
+void VBoxSelectorWnd::vmListViewCurrentChanged (bool aRefreshDetails,
+                                                bool aRefreshSnapshots,
+                                                bool aRefreshDescription)
+{
+    UIVMItem *item = mVMListView->selectedItem();
+
+    if (item && item->accessible())
+    {
+        CMachine m = item->machine();
+
+        KMachineState state = item->state();
+        bool running = item->sessionState() != KSessionState_Closed;
+        bool modifyEnabled = !running && state != KMachineState_Saved;
+
+        if (aRefreshDetails)
+            m_pVMDesktop->updateDetails(item, m);
+        if (aRefreshSnapshots)
+            m_pVMDesktop->updateSnapshots(item, m);
+        if (aRefreshDescription)
+            m_pVMDesktop->updateDescription(item, m);
+
+        /* enable/disable modify actions */
+        mVmConfigAction->setEnabled (modifyEnabled);
+        mVmDeleteAction->setEnabled (modifyEnabled);
+        mVmDiscardAction->setEnabled (state == KMachineState_Saved && !running);
+        mVmPauseAction->setEnabled (   state == KMachineState_Running
+                                    || state == KMachineState_Teleporting
+                                    || state == KMachineState_LiveSnapshotting
+                                    || state == KMachineState_Paused
+                                    || state == KMachineState_TeleportingPausedVM /** @todo Live Migration: does this make sense? */
+                                   );
+
+        /* change the Start button text accordingly */
+        if (   state == KMachineState_PoweredOff
+            || state == KMachineState_Saved
+            || state == KMachineState_Teleported
+            || state == KMachineState_Aborted
+           )
+        {
+            mVmStartAction->setText (tr ("S&tart"));
+#ifdef QT_MAC_USE_COCOA
+            /* There is a bug in Qt Cocoa which result in showing a "more arrow" when
+               the necessary size of the toolbar is increased. Also for some languages
+               the with doesn't match if the text increase. So manually adjust the size
+               after changing the text. */
+            mVMToolBar->updateLayout();
+#endif /* QT_MAC_USE_COCOA */
+            mVmStartAction->setStatusTip (
+                tr ("Start the selected virtual machine"));
+
+            mVmStartAction->setEnabled (!running);
+        }
+        else
+        {
+            mVmStartAction->setText (tr ("S&how"));
+#ifdef QT_MAC_USE_COCOA
+            /* There is a bug in Qt Cocoa which result in showing a "more arrow" when
+               the necessary size of the toolbar is increased. Also for some languages
+               the with doesn't match if the text increase. So manually adjust the size
+               after changing the text. */
+            mVMToolBar->updateLayout();
+#endif /* QT_MAC_USE_COCOA */
+            mVmStartAction->setStatusTip (
+                tr ("Switch to the window of the selected virtual machine"));
+
+            mVmStartAction->setEnabled (item->canSwitchTo());
+        }
+
+        /* change the Pause/Resume button text accordingly */
+        if (   state == KMachineState_Paused
+            || state == KMachineState_TeleportingPausedVM /*?*/
+           )
+        {
+            mVmPauseAction->setText (tr ("R&esume"));
+            mVmPauseAction->setShortcut (QKeySequence ("Ctrl+P"));
+            mVmPauseAction->setStatusTip (
+                tr ("Resume the execution of the virtual machine"));
+            mVmPauseAction->blockSignals (true);
+            mVmPauseAction->setChecked (true);
+            mVmPauseAction->blockSignals (false);
+        }
+        else
+        {
+            mVmPauseAction->setText (tr ("&Pause"));
+            mVmPauseAction->setShortcut (QKeySequence ("Ctrl+P"));
+            mVmPauseAction->setStatusTip (
+                tr ("Suspend the execution of the virtual machine"));
+            mVmPauseAction->blockSignals (true);
+            mVmPauseAction->setChecked (false);
+            mVmPauseAction->blockSignals (false);
+        }
+
+        /* disable Refresh for accessible machines */
+        mVmRefreshAction->setEnabled (false);
+
+        /* enable the show log item for the selected vm */
+        mVmShowLogsAction->setEnabled (true);
+    }
+    else
+    {
+        /* Note that the machine becomes inaccessible (or if the last VM gets
+         * deleted), we have to update all fields, ignoring input
+         * arguments. */
+
+        if (item)
+        {
+            /* the VM is inaccessible */
+            m_pVMDesktop->updateDetailsErrorText(
+                VBoxProblemReporter::formatErrorInfo(item->accessError()));
+            mVmRefreshAction->setEnabled(true);
+        }
+        else
+        {
+            /* default HTML support in Qt is terrible so just try to get
+             * something really simple */
+            m_pVMDesktop->updateDetailsText(
+                tr("<h3>"
+                   "Welcome to VirtualBox!</h3>"
+                   "<p>The left part of this window is  "
+                   "a list of all virtual machines on your computer. "
+                   "The list is empty now because you haven't created any virtual "
+                   "machines yet."
+                   "<img src=:/welcome.png align=right/></p>"
+                   "<p>In order to create a new virtual machine, press the "
+                   "<b>New</b> button in the main tool bar located "
+                   "at the top of the window.</p>"
+                   "<p>You can press the <b>%1</b> key to get instant help, "
+                   "or visit "
+                   "<a href=http://www.virtualbox.org>www.virtualbox.org</a> "
+                   "for the latest information and news.</p>").arg (QKeySequence (QKeySequence::HelpContents).toString (QKeySequence::NativeText)));
+            mVmRefreshAction->setEnabled(false);
+        }
+
+        /* empty and disable other tabs */
+        m_pVMDesktop->updateSnapshots(0, CMachine());
+        m_pVMDesktop->updateDescription(0, CMachine());
+
+        /* disable modify actions */
+        mVmConfigAction->setEnabled (false);
+        mVmDeleteAction->setEnabled (item != NULL);
+        mVmDiscardAction->setEnabled (false);
+        mVmPauseAction->setEnabled (false);
+
+        /* change the Start button text accordingly */
+        mVmStartAction->setText (tr ("S&tart"));
+        mVmStartAction->setStatusTip (
+            tr ("Start the selected virtual machine"));
+        mVmStartAction->setEnabled (false);
+
+        /* disable the show log item for the selected vm */
+        mVmShowLogsAction->setEnabled (false);
+    }
+}
+
+void VBoxSelectorWnd::mediumEnumStarted()
+{
+    /* refresh the current details to pick up hard disk sizes */
+    vmListViewCurrentChanged (true /* aRefreshDetails */);
+}
+
+void VBoxSelectorWnd::mediumEnumFinished (const VBoxMediaList &list)
+{
+    /* refresh the current details to pick up hard disk sizes */
+    vmListViewCurrentChanged (true /* aRefreshDetails */);
+
+    /* we warn about inaccessible media only once (after media emumeration
+     * started from main() at startup), to avoid annoying the user */
+    if (   mDoneInaccessibleWarningOnce
+#ifdef VBOX_GUI_WITH_SYSTRAY
+        || vboxGlobal().isTrayMenu()
+#endif
+       )
+        return;
+
+    mDoneInaccessibleWarningOnce = true;
+
+    do
+    {
+        /* ignore the signal if a modal widget is currently active (we won't be
+         * able to properly show the modeless VDI manager window in this case) */
+        if (QApplication::activeModalWidget())
+            break;
+
+        /* ignore the signal if a VBoxMediaManagerDlg window is active */
+        if (qApp->activeWindow() &&
+            !strcmp (qApp->activeWindow()->metaObject()->className(), "VBoxMediaManagerDlg"))
+            break;
+
+        /* look for at least one inaccessible media */
+        VBoxMediaList::const_iterator it;
+        for (it = list.begin(); it != list.end(); ++ it)
+            if ((*it).state() == KMediumState_Inaccessible)
+                break;
+
+        if (it != list.end() && vboxProblem().remindAboutInaccessibleMedia())
+        {
+            /* Show the VDM dialog but don't refresh once more after a
+             * just-finished refresh */
+            VBoxMediaManagerDlg::showModeless (this, false /* aRefresh */);
+        }
+    }
+    while (0);
+}
+
+void VBoxSelectorWnd::machineStateChanged(QString strId, KMachineState /* state */)
+{
+#ifdef VBOX_GUI_WITH_SYSTRAY
+    if (vboxGlobal().isTrayMenu())
+    {
+        /* Check if there are some machines alive - else quit, since
+         * we're not needed as a systray menu anymore. */
+        if (vboxGlobal().mainWindowCount() == 0)
+        {
+            fileExit();
+            return;
+        }
+    }
+#endif
+
+    refreshVMItem (strId,
+                   false /* aDetails */,
+                   false /* aSnapshots */,
+                   false /* aDescription */);
+
+    /* simulate a state change signal */
+    m_pVMDesktop->updateDescriptionState();
+}
+
+void VBoxSelectorWnd::machineDataChanged(QString strId)
+{
+    refreshVMItem (strId,
+                   true  /* aDetails */,
+                   false /* aSnapshots */,
+                   true  /* aDescription */);
+}
+
+void VBoxSelectorWnd::machineRegistered(QString strId, bool fRegistered)
+{
+    if (fRegistered)
+    {
+        CVirtualBox vbox = vboxGlobal().virtualBox();
+        CMachine m = vbox.GetMachine (strId);
+        if (!m.isNull())
+        {
+            mVMModel->addItem (new UIVMItem (m));
+            mVMModel->sort();
+            /* Make sure the description, ... pages are properly updated.
+             * Actualy we haven't call the next method, but unfortunately Qt
+             * seems buggy if the new item is on the same position as the
+             * previous one. So go on the safe side and call this by our self. */
+            vmListViewCurrentChanged();
+        }
+        /* m.isNull() is ok (theoretically, the machine could have been
+         * already deregistered by some other client at this point) */
+    }
+    else
+    {
+        UIVMItem *item = mVMModel->itemById (strId);
+        if (item)
+        {
+            int row = mVMModel->rowById (item->id());
+            mVMModel->removeItem (item);
+            delete item;
+            mVMListView->ensureSomeRowSelected (row);
+        }
+
+        /* item = 0 is ok (if we originated this event then the item
+         * has been already removed) */
+    }
+}
+
+void VBoxSelectorWnd::sessionStateChanged(QString strId, KSessionState /* state */)
+{
+    refreshVMItem (strId,
+                   true  /* aDetails */,
+                   false /* aSnapshots */,
+                   false /* aDescription */);
+
+    /* simulate a state change signal */
+    m_pVMDesktop->updateDescriptionState();
+}
+
+void VBoxSelectorWnd::snapshotChanged(QString strId, QString /* strSnapshotId */)
+{
+    refreshVMItem (strId,
+                   false /* aDetails */,
+                   true  /* aSnapshot */,
+                   false /* aDescription */);
+}
+
+#ifdef VBOX_GUI_WITH_SYSTRAY
+
+void VBoxSelectorWnd::mainWindowCountChanged(int count)
+{
+    if (vboxGlobal().isTrayMenu() && count <= 1)
+        fileExit();
+}
+
+void VBoxSelectorWnd::trayIconCanShow(bool fEnabled)
+{
+    emit trayIconChanged(VBoxChangeTrayIconEvent (vboxGlobal().settings().trayIconEnabled()));
+}
+
+void VBoxSelectorWnd::trayIconShow(bool fEnabled)
+{
+    if (vboxGlobal().isTrayMenu() && mTrayIcon)
+        mTrayIcon->trayIconShow(fEnabled);
+}
+
+void VBoxSelectorWnd::trayIconChanged(bool fEnabled)
+{
+    /* Not used yet. */
+}
+
+VBoxTrayIcon::VBoxTrayIcon (VBoxSelectorWnd* aParent, UIVMItemModel* aVMModel)
+{
+    mParent = aParent;
+    mVMModel = aVMModel;
+
+    mShowSelectorAction = new QAction (this);
+    Assert (mShowSelectorAction);
+    mShowSelectorAction->setIcon(UIIconPool::iconSet(":/VirtualBox_16px.png"));
+
+    mHideSystrayMenuAction = new QAction (this);
+    Assert (mHideSystrayMenuAction);
+    mHideSystrayMenuAction->setIcon(UIIconPool::iconSet(":/exit_16px.png"));
+
+    /* reuse parent action data */
+
+    mVmConfigAction = new QAction (this);
+    Assert (mVmConfigAction);
+    mVmConfigAction->setIcon (mParent->vmConfigAction()->icon());
+
+    mVmDeleteAction = new QAction (this);
+    Assert (mVmDeleteAction);
+    mVmDeleteAction->setIcon (mParent->vmDeleteAction()->icon());
+
+    mVmStartAction = new QAction (this);
+    Assert (mVmStartAction);
+    mVmStartAction->setIcon (mParent->vmStartAction()->icon());
+
+    mVmDiscardAction = new QAction (this);
+    Assert (mVmDiscardAction);
+    mVmDiscardAction->setIcon (mParent->vmDiscardAction()->icon());
+
+    mVmPauseAction = new QAction (this);
+    Assert (mVmPauseAction);
+    mVmPauseAction->setCheckable (true);
+    mVmPauseAction->setIcon (mParent->vmPauseAction()->icon());
+
+    mVmRefreshAction = new QAction (this);
+    Assert (mVmRefreshAction);
+    mVmRefreshAction->setIcon (mParent->vmRefreshAction()->icon());
+
+    mVmShowLogsAction = new QAction (this);
+    Assert (mVmConfigAction);
+    mVmShowLogsAction->setIcon (mParent->vmShowLogsAction()->icon());
+
+    mTrayIconMenu = new QMenu (aParent);
+    Assert (mTrayIconMenu);
+
+    setIcon (QIcon (":/VirtualBox_16px.png"));
+    setContextMenu (mTrayIconMenu);
+
+    connect (mShowSelectorAction, SIGNAL (triggered()), mParent, SLOT (showWindow()));
+    connect (mHideSystrayMenuAction, SIGNAL (triggered()), this, SLOT (trayIconShow()));
+}
+
+VBoxTrayIcon::~VBoxTrayIcon ()
+{
+    /* Erase dialog handle in config file. */
+    if (mActive)
+    {
+        vboxGlobal().virtualBox().SetExtraData (VBoxDefs::GUI_TrayIconWinID,
+                                                QString::null);
+        hide();
+    }
+}
+
+void VBoxTrayIcon::retranslateUi ()
+{
+    if (!mActive)
+        return;
+
+    mShowSelectorAction->setText (tr ("Show Selector Window"));
+    mShowSelectorAction->setStatusTip (tr (
+        "Show the selector window assigned to this menu"));
+
+    mHideSystrayMenuAction->setText (tr ("Hide Tray Icon"));
+    mHideSystrayMenuAction->setStatusTip (tr (
+        "Remove this icon from the system tray"));
+
+    /* reuse parent action data */
+
+    mVmConfigAction->setText (mParent->vmConfigAction()->text());
+    mVmConfigAction->setStatusTip (mParent->vmConfigAction()->statusTip());
+
+    mVmDeleteAction->setText (mParent->vmDeleteAction()->text());
+    mVmDeleteAction->setStatusTip (mParent->vmDeleteAction()->statusTip());
+
+    mVmPauseAction->setText (mParent->vmPauseAction()->text());
+    mVmPauseAction->setStatusTip (mParent->vmPauseAction()->statusTip());
+
+    mVmDiscardAction->setText (mParent->vmDiscardAction()->text());
+    mVmDiscardAction->setStatusTip (mParent->vmDiscardAction()->statusTip());
+
+    mVmShowLogsAction->setText (mParent->vmShowLogsAction()->text());
+    mVmShowLogsAction->setStatusTip (mParent->vmShowLogsAction()->statusTip());
+}
+
+void VBoxTrayIcon::showSubMenu ()
+{
+    if (!mActive)
+        return;
+
+    UIVMItem* pItem = NULL;
+    QMenu *pMenu = NULL;
+    QVariant vID;
+
+    if ((pMenu = qobject_cast<QMenu*>(sender())))
+    {
+        vID = pMenu->menuAction()->data();
+        if (vID.canConvert<QString>() && mVMModel)
+            pItem = mVMModel->itemById (qvariant_cast<QString>(vID));
+    }
+
+    mVmConfigAction->setData (vID);
+    mVmDeleteAction->setData (vID);
+    mVmDiscardAction->setData (vID);
+    mVmStartAction->setData (vID);
+    mVmPauseAction->setData (vID);
+    mVmShowLogsAction->setData (vID);
+
+    if (pItem && pItem->accessible())
+    {
+        /* look at vmListViewCurrentChanged() */
+        CMachine m = pItem->machine();
+        KMachineState s = pItem->state();
+        bool running = pItem->sessionState() != KSessionState_Closed;
+        bool modifyEnabled = !running && s != KMachineState_Saved;
+
+        /* Settings */
+        mVmConfigAction->setEnabled (modifyEnabled);
+
+        /* Delete */
+        mVmDeleteAction->setEnabled (modifyEnabled);
+
+        /* Discard */
+        mVmDiscardAction->setEnabled (s == KMachineState_Saved && !running);
+
+        /* Change the Start button text accordingly */
+        if (   s == KMachineState_PoweredOff
+            || s == KMachineState_Saved
+            || s == KMachineState_Teleported
+            || s == KMachineState_Aborted
+           )
+        {
+            mVmStartAction->setText (UIVMListView::tr ("S&tart"));
+            mVmStartAction->setStatusTip (
+                  UIVMListView::tr ("Start the selected virtual machine"));
+            mVmStartAction->setEnabled (!running);
+        }
+        else
+        {
+            mVmStartAction->setText (UIVMListView::tr ("S&how"));
+            mVmStartAction->setStatusTip (
+                  UIVMListView::tr ("Switch to the window of the selected virtual machine"));
+            mVmStartAction->setEnabled (pItem->canSwitchTo());
+        }
+
+        /* Change the Pause/Resume button text accordingly */
+        mVmPauseAction->setEnabled (   s == KMachineState_Running
+                                    || s == KMachineState_Teleporting
+                                    || s == KMachineState_LiveSnapshotting
+                                    || s == KMachineState_Paused
+                                    || s == KMachineState_TeleportingPausedVM
+                                   );
+
+        if (   s == KMachineState_Paused
+            || s == KMachineState_TeleportingPausedVM /*?*/
+           )
+        {
+            mVmPauseAction->setText (UIVMListView::tr ("R&esume"));
+            mVmPauseAction->setStatusTip (
+                  UIVMListView::tr ("Resume the execution of the virtual machine"));
+            mVmPauseAction->blockSignals (true);
+            mVmPauseAction->setChecked (true);
+            mVmPauseAction->blockSignals (false);
+        }
+        else
+        {
+            mVmPauseAction->setText (UIVMListView::tr ("&Pause"));
+            mVmPauseAction->setStatusTip (
+                  UIVMListView::tr ("Suspend the execution of the virtual machine"));
+            mVmPauseAction->blockSignals (true);
+            mVmPauseAction->setChecked (false);
+            mVmPauseAction->blockSignals (false);
+        }
+
+        mVmShowLogsAction->setEnabled (true);
+
+        /* Disconnect old slot which maybe was connected from another selected sub menu. */
+        disconnect (mVmConfigAction, SIGNAL (triggered()), this, SLOT (vmSettings()));
+        disconnect (mVmDeleteAction, SIGNAL (triggered()), this, SLOT (vmDelete()));
+        disconnect (mVmDiscardAction, SIGNAL (triggered()), this, SLOT (vmDiscard()));
+        disconnect (mVmStartAction, SIGNAL (triggered()), this, SLOT (vmStart()));
+        disconnect (mVmPauseAction, SIGNAL (toggled (bool)), this, SLOT (vmPause (bool)));
+        disconnect (mVmShowLogsAction, SIGNAL (triggered()), this, SLOT (vmShowLogs()));
+
+        /* Connect new sub menu with slots. */
+        connect (mVmConfigAction, SIGNAL (triggered()), this, SLOT (vmSettings()));
+        connect (mVmDeleteAction, SIGNAL (triggered()), this, SLOT (vmDelete()));
+        connect (mVmDiscardAction, SIGNAL (triggered()), this, SLOT (vmDiscard()));
+        connect (mVmStartAction, SIGNAL (triggered()), this, SLOT (vmStart()));
+        connect (mVmPauseAction, SIGNAL (toggled (bool)), this, SLOT (vmPause (bool)));
+        connect (mVmShowLogsAction, SIGNAL (triggered()), this, SLOT (vmShowLogs()));
+    }
+    else    /* Item is not accessible. */
+    {
+        mVmConfigAction->setEnabled (false);
+        mVmDeleteAction->setEnabled (pItem != NULL);
+        mVmDiscardAction->setEnabled (false);
+        mVmPauseAction->setEnabled (false);
+
+        /* Set the Start button text accordingly. */
+        mVmStartAction->setText (UIVMListView::tr ("S&tart"));
+        mVmStartAction->setStatusTip (
+              UIVMListView::tr ("Start the selected virtual machine"));
+        mVmStartAction->setEnabled (false);
+
+        /* Disable the show log item for the selected vm. */
+        mVmShowLogsAction->setEnabled (false);
+    }
+
+    /* Build sub menu entries (add rest of sub menu entries later here). */
+    pMenu->addAction (mVmStartAction);
+    pMenu->addAction (mVmPauseAction);
+}
+
+void VBoxTrayIcon::hideSubMenu ()
+{
+    if (!mActive)
+        return;
+
+    UIVMItem* pItem = NULL;
+    QVariant vID;
+
+    if (QMenu *pMenu = qobject_cast<QMenu*>(sender()))
+    {
+        vID = pMenu->menuAction()->data();
+        if (vID.canConvert<QString>() && mVMModel)
+            pItem = mVMModel->itemById (qvariant_cast<QString>(vID));
+    }
+
+    /* Nothing to do here yet. */
+
+    Assert (pItem);
+}
+
+void VBoxTrayIcon::refresh ()
+{
+    if (!mActive)
+        return;
+
+    AssertReturnVoid (mVMModel);
+    AssertReturnVoid (mTrayIconMenu);
+
+    mTrayIconMenu->clear();
+
+    UIVMItem* pItem = NULL;
+    QMenu* pCurMenu = mTrayIconMenu;
+    QMenu* pSubMenu = NULL;
+
+    int iCurItemCount = 0;
+
+    mTrayIconMenu->addAction (mShowSelectorAction);
+    mTrayIconMenu->setDefaultAction (mShowSelectorAction);
+
+    if (mVMModel->rowCount() > 0)
+        mTrayIconMenu->addSeparator();
+
+    for (int i = 0; i < mVMModel->rowCount(); i++, iCurItemCount++)
+    {
+        pItem = mVMModel->itemByRow(i);
+        Assert(pItem);
+
+        if (iCurItemCount > 10) /* 10 machines per sub menu. */
+        {
+            pSubMenu = new QMenu (tr ("&Other Machines...", "tray menu"));
+            Assert (pSubMenu);
+            pCurMenu->addMenu (pSubMenu);
+            pCurMenu = pSubMenu;
+            iCurItemCount = 0;
+        }
+
+        pSubMenu = new QMenu (QString ("&%1. %2")
+                              .arg ((iCurItemCount + 1) % 100).arg (pItem->name()));
+        Assert (pSubMenu);
+        pSubMenu->setIcon (pItem->sessionStateIcon());
+
+        QAction *pAction = NULL;
+        QVariant vID;
+        vID.setValue (pItem->id());
+
+        pSubMenu->menuAction()->setData (vID);
+        connect (pSubMenu, SIGNAL (aboutToShow()), this, SLOT (showSubMenu()));
+        connect (pSubMenu, SIGNAL (aboutToHide()), this, SLOT (hideSubMenu()));
+        pCurMenu->addMenu (pSubMenu);
+    }
+
+    if (mVMModel->rowCount() > 0)
+        mTrayIconMenu->addSeparator();
+
+    mTrayIconMenu->addAction (mHideSystrayMenuAction);
+
+    /* We're done constructing the menu, show it */
+    setVisible (true);
+}
+
+UIVMItem* VBoxTrayIcon::GetItem (QObject* aObject)
+{
+    UIVMItem* pItem = NULL;
+    if (QAction *pAction = qobject_cast<QAction*>(sender()))
+    {
+        QVariant v = pAction->data();
+        if (v.canConvert<QString>() && mVMModel)
+            pItem = mVMModel->itemById (qvariant_cast<QString>(v));
+    }
+
+    Assert (pItem);
+    return pItem;
+}
+
+void VBoxTrayIcon::trayIconShow (bool aShow)
+{
+    if (!vboxGlobal().isTrayMenu())
+        return;
+
+    mActive = aShow;
+    if (mActive)
+    {
+        refresh();
+        retranslateUi();
+    }
+    setVisible (mActive);
+
+    if (!mActive)
+        mParent->fileExit();
+}
+
+void VBoxTrayIcon::vmSettings()
+{
+    UIVMItem* pItem = GetItem (sender());
+    mParent->vmSettings (NULL, NULL, pItem->id());
+}
+
+void VBoxTrayIcon::vmDelete()
+{
+    UIVMItem* pItem = GetItem (sender());
+    mParent->vmDelete (pItem->id());
+}
+
+void VBoxTrayIcon::vmStart()
+{
+    UIVMItem* pItem = GetItem (sender());
+    mParent->vmStart (pItem->id());
+}
+
+void VBoxTrayIcon::vmDiscard()
+{
+    UIVMItem* pItem = GetItem (sender());
+    mParent->vmDiscard (pItem->id());
+}
+
+void VBoxTrayIcon::vmPause(bool aPause)
+{
+    UIVMItem* pItem = GetItem (sender());
+    mParent->vmPause (aPause, pItem->id());
+}
+
+void VBoxTrayIcon::vmRefresh()
+{
+    UIVMItem* pItem = GetItem (sender());
+    mParent->vmRefresh (pItem->id());
+}
+
+void VBoxTrayIcon::vmShowLogs()
+{
+    UIVMItem* pItem = GetItem (sender());
+    mParent->vmShowLogs (pItem->id());
+}
+
+#endif // VBOX_GUI_WITH_SYSTRAY
+
+void VBoxSelectorWnd::sltDownloaderUserManualEmbed()
+{
+    /* If there is User Manual downloader created => show the process bar: */
+    if (UIDownloaderUserManual *pDl = UIDownloaderUserManual::current())
+        statusBar()->addWidget(pDl->processWidget(this), 0);
+}
+
+void VBoxSelectorWnd::showViewContextMenu(const QPoint &pos)
+{
+    CVirtualBox vbox = vboxGlobal().virtualBox();
+    QString strToolbar = vbox.GetExtraData(VBoxDefs::GUI_Toolbar);
+    QString strStatusbar = vbox.GetExtraData(VBoxDefs::GUI_Statusbar);
+    bool fToolbar = strToolbar.isEmpty() || strToolbar == "true";
+    bool fStatusbar = strStatusbar.isEmpty() || strStatusbar == "true";
+
+    QList<QAction*> actions;
+    QAction *pShowToolBar = new QAction(tr("Show Toolbar"), 0);
+    pShowToolBar->setCheckable(true);
+    pShowToolBar->setChecked(fToolbar);
+    actions << pShowToolBar;
+    QAction *pShowStatusBar = new QAction(tr("Show Statusbar"), 0);
+    pShowStatusBar->setCheckable(true);
+    pShowStatusBar->setChecked(fStatusbar);
+    actions << pShowStatusBar;
+
+    QPoint gpos = pos;
+    QWidget *pSender = static_cast<QWidget*>(sender());
+    if (pSender)
+        gpos = pSender->mapToGlobal(pos);
+    QAction *pResult = QMenu::exec(actions, gpos);
+    if (pResult == pShowToolBar)
+    {
+        if (pResult->isChecked())
+        {
+#ifdef Q_WS_MAC
+            mVMToolBar->show();
+#else /* Q_WS_MAC */
+            m_pBar->show();
+#endif /* !Q_WS_MAC */
+            vbox.SetExtraData(VBoxDefs::GUI_Toolbar, "true");
+        }
+        else
+        {
+#ifdef Q_WS_MAC
+            mVMToolBar->hide();
+#else /* Q_WS_MAC */
+            m_pBar->hide();
+#endif /* !Q_WS_MAC */
+            vbox.SetExtraData(VBoxDefs::GUI_Toolbar, "false");
+        }
+    }else if (pResult == pShowStatusBar)
+    {
+        if (pResult->isChecked())
+        {
+            statusBar()->show();
+            vbox.SetExtraData(VBoxDefs::GUI_Statusbar, "true");
+        }
+        else
+        {
+            statusBar()->hide();
+            vbox.SetExtraData(VBoxDefs::GUI_Statusbar, "false");
+        }
+    }
+}
+
Index: /trunk/src/VBox/Frontends/VirtualBox/src/selector/VBoxSelectorWnd.h
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/selector/VBoxSelectorWnd.h	(revision 30868)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/selector/VBoxSelectorWnd.h	(revision 30868)
@@ -0,0 +1,255 @@
+/** @file
+ *
+ * VBox frontends: Qt GUI ("VirtualBox"):
+ * VBoxSelectorWnd class declaration
+ */
+
+/*
+ * Copyright (C) 2006-2008 Oracle Corporation
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ */
+
+#ifndef __VBoxSelectorWnd_h__
+#define __VBoxSelectorWnd_h__
+
+/* Local includes */
+#include "COMDefs.h"
+#include "QIWithRetranslateUI.h"
+#include "VBoxGlobal.h"
+#include "VBoxHelpActions.h"
+#include "VBoxProblemReporter.h"
+
+/* Global includes */
+#include <QMainWindow>
+#ifdef VBOX_GUI_WITH_SYSTRAY
+# include <QSystemTrayIcon>
+#endif
+
+/* Local forward declarations */
+class QISplitter;
+class UIBar;
+class UIVMDesktop;
+class UIVMItem;
+class UIVMItemModel;
+class UIVMListView;
+class VBoxToolBar;
+class VBoxTrayIcon;
+class VBoxVMLogViewer;
+
+class VBoxSelectorWnd : public QIWithRetranslateUI2<QMainWindow>
+{
+    Q_OBJECT;
+
+public:
+
+    VBoxSelectorWnd (VBoxSelectorWnd **aSelf,
+                     QWidget* aParent = 0,
+                     Qt::WindowFlags aFlags = Qt::Window);
+    virtual ~VBoxSelectorWnd();
+
+signals:
+
+    void closing();
+
+public slots:
+
+    void fileMediaMgr();
+    void fileImportAppliance();
+    void fileExportAppliance();
+    void fileSettings();
+    void fileExit();
+
+    void vmNew();
+    void vmSettings (const QString &aCategory = QString::null,
+                     const QString &aControl = QString::null,
+                     const QString & = QString::null);
+    void vmDelete (const QString & = QString::null);
+    void vmStart (const QString & = QString::null);
+    void vmDiscard (const QString & = QString::null);
+    void vmPause (bool, const QString & = QString::null);
+    void vmRefresh (const QString & = QString::null);
+    void vmShowLogs (const QString & = QString::null);
+
+    void refreshVMList();
+    void refreshVMItem (const QString &aID, bool aDetails,
+                                          bool aSnapshots,
+                                          bool aDescription);
+
+    void showContextMenu (const QPoint &aPoint);
+
+#ifdef VBOX_GUI_WITH_SYSTRAY
+    void trayIconActivated (QSystemTrayIcon::ActivationReason aReason);
+    void showWindow();
+#endif
+
+    const QAction *vmNewAction() const { return mVmNewAction; }
+    const QAction *vmConfigAction() const { return mVmConfigAction; }
+    const QAction *vmDeleteAction() const { return mVmDeleteAction; }
+    const QAction *vmStartAction() const { return mVmStartAction; }
+    const QAction *vmDiscardAction() const { return mVmDiscardAction; }
+    const QAction *vmPauseAction() const { return mVmPauseAction; }
+    const QAction *vmRefreshAction() const { return mVmRefreshAction; }
+    const QAction *vmShowLogsAction() const { return mVmShowLogsAction; }
+
+protected:
+
+    /* Events */
+    bool event (QEvent *aEvent);
+    void closeEvent (QCloseEvent *aEvent);
+//#if defined (Q_WS_MAC) && (QT_VERSION < 0x040402)
+//    bool eventFilter (QObject *aObject, QEvent *aEvent);
+//#endif /* defined (Q_WS_MAC) && (QT_VERSION < 0x040402) */
+
+    void retranslateUi();
+
+private slots:
+
+    void vmListViewCurrentChanged (bool aRefreshDetails = true,
+                                   bool aRefreshSnapshots = true,
+                                   bool aRefreshDescription = true);
+
+    void mediumEnumStarted();
+    void mediumEnumFinished (const VBoxMediaList &);
+
+    /* VirtualBox callback events we're interested in */
+
+    void machineStateChanged(QString strId, KMachineState state);
+    void machineDataChanged(QString strId);
+    void machineRegistered(QString strID, bool fRegistered);
+    void sessionStateChanged(QString strId, KSessionState state);
+    void snapshotChanged(QString strId, QString strSnapshotId);
+#ifdef VBOX_GUI_WITH_SYSTRAY
+    void mainWindowCountChanged(int count);
+    void trayIconCanShow(bool fEnabled);
+    void trayIconShow(bool fEnabled);
+    void trayIconChanged(bool fEnabled);
+#endif
+
+    void sltDownloaderUserManualEmbed();
+
+    void showViewContextMenu(const QPoint &pos);
+
+private:
+
+    /* Main menus */
+    QMenu *mFileMenu;
+    QMenu *mVMMenu;
+    QMenu *mHelpMenu;
+
+    /* Central splitter window */
+    QISplitter *m_pSplitter;
+
+    /* Main toolbar */
+#ifndef Q_WS_MAC
+    UIBar *m_pBar;
+#endif /* !Q_WS_MAC */
+    VBoxToolBar *mVMToolBar;
+
+    /* VM list context menu */
+    QMenu *mVMCtxtMenu;
+
+    /* Actions */
+    QAction *mFileMediaMgrAction;
+    QAction *mFileApplianceImportAction;
+    QAction *mFileApplianceExportAction;
+    QAction *mFileSettingsAction;
+    QAction *mFileExitAction;
+    QAction *mVmNewAction;
+    QAction *mVmConfigAction;
+    QAction *mVmDeleteAction;
+    QAction *mVmStartAction;
+    QAction *mVmDiscardAction;
+    QAction *mVmPauseAction;
+    QAction *mVmRefreshAction;
+    QAction *mVmShowLogsAction;
+
+    VBoxHelpActions mHelpActions;
+
+#ifdef VBOX_GUI_WITH_SYSTRAY
+    /* The systray icon */
+    VBoxTrayIcon *mTrayIcon;
+#endif
+
+    /* The vm list view/model */
+    UIVMListView *mVMListView;
+    UIVMItemModel *mVMModel;
+
+    /* The right information widgets */
+    UIVMDesktop *m_pVMDesktop;
+
+    QRect mNormalGeo;
+
+    bool mDoneInaccessibleWarningOnce : 1;
+};
+
+#ifdef VBOX_GUI_WITH_SYSTRAY
+
+Q_DECLARE_METATYPE(QString);
+
+class VBoxTrayIcon : public QSystemTrayIcon
+{
+    Q_OBJECT;
+
+public:
+
+    VBoxTrayIcon (VBoxSelectorWnd* aParent, UIVMItemModel* aVMModel);
+    virtual ~VBoxTrayIcon ();
+
+    void refresh ();
+    void retranslateUi ();
+
+protected:
+
+    UIVMItem* GetItem (QObject* aObject);
+
+signals:
+
+public slots:
+
+    void trayIconShow (bool aShow = false);
+
+private slots:
+
+    void showSubMenu();
+    void hideSubMenu ();
+
+    void vmSettings();
+    void vmDelete();
+    void vmStart();
+    void vmDiscard();
+    void vmPause(bool aPause);
+    void vmRefresh();
+    void vmShowLogs();
+
+private:
+
+    bool mActive;           /* Is systray menu active/available? */
+
+    /* The vm list model */
+    UIVMItemModel *mVMModel;
+
+    VBoxSelectorWnd* mParent;
+    QMenu *mTrayIconMenu;
+
+    QAction *mShowSelectorAction;
+    QAction *mHideSystrayMenuAction;
+    QAction *mVmConfigAction;
+    QAction *mVmDeleteAction;
+    QAction *mVmStartAction;
+    QAction *mVmDiscardAction;
+    QAction *mVmPauseAction;
+    QAction *mVmRefreshAction;
+    QAction *mVmShowLogsAction;
+};
+
+#endif // VBOX_GUI_WITH_SYSTRAY
+
+#endif // __VBoxSelectorWnd_h__
+
Index: /trunk/src/VBox/Frontends/VirtualBox/src/selector/VBoxSnapshotsWgt.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/selector/VBoxSnapshotsWgt.cpp	(revision 30868)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/selector/VBoxSnapshotsWgt.cpp	(revision 30868)
@@ -0,0 +1,875 @@
+/* $Id$ */
+/** @file
+ *
+ * VBox frontends: Qt4 GUI ("VirtualBox"):
+ * VBoxSnapshotsWgt class implementation
+ */
+
+/*
+ * Copyright (C) 2006-2010 Oracle Corporation
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ */
+
+#ifdef VBOX_WITH_PRECOMPILED_HEADERS
+# include "precomp.h"
+#else  /* !VBOX_WITH_PRECOMPILED_HEADERS */
+/* Local includes */
+#include "UIIconPool.h"
+#include "VBoxProblemReporter.h"
+#include "VBoxSnapshotDetailsDlg.h"
+#include "VBoxSnapshotsWgt.h"
+#include "VBoxTakeSnapshotDlg.h"
+#include "VBoxToolBar.h"
+#include "UIVirtualBoxEventHandler.h"
+
+/* Global includes */
+#include <QDateTime>
+#include <QHeaderView>
+#include <QMenu>
+#include <QScrollBar>
+
+#endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
+
+/**
+ *  QTreeWidgetItem subclass for snapshots items
+ */
+class SnapshotWgtItem : public QTreeWidgetItem
+{
+public:
+
+    enum { ItemType = QTreeWidgetItem::UserType + 1 };
+
+    /* Normal snapshot item (child of tree-widget) */
+    SnapshotWgtItem (QTreeWidget *aTreeWidget, const CSnapshot &aSnapshot)
+        : QTreeWidgetItem (aTreeWidget, ItemType)
+        , mIsCurrentState (false)
+        , mSnapshot (aSnapshot)
+    {
+    }
+
+    /* Normal snapshot item (child of tree-widget-item) */
+    SnapshotWgtItem (QTreeWidgetItem *aRootItem, const CSnapshot &aSnapshot)
+        : QTreeWidgetItem (aRootItem, ItemType)
+        , mIsCurrentState (false)
+        , mSnapshot (aSnapshot)
+    {
+    }
+
+    /* Current state item (child of tree-widget) */
+    SnapshotWgtItem (QTreeWidget *aTreeWidget, const CMachine &aMachine)
+        : QTreeWidgetItem (aTreeWidget, ItemType)
+        , mIsCurrentState (true)
+        , mMachine (aMachine)
+    {
+        updateCurrentState (mMachine.GetState());
+    }
+
+    /* Current state item (child of tree-widget-item) */
+    SnapshotWgtItem (QTreeWidgetItem *aRootItem, const CMachine &aMachine)
+        : QTreeWidgetItem (aRootItem, ItemType)
+        , mIsCurrentState (true)
+        , mMachine (aMachine)
+    {
+        updateCurrentState (mMachine.GetState());
+    }
+
+    QVariant data (int aColumn, int aRole) const
+    {
+        switch (aRole)
+        {
+            case Qt::DisplayRole:
+                return mIsCurrentState ? QTreeWidgetItem::data (aColumn, aRole) : QVariant (QString ("%1%2")
+                                         .arg (QTreeWidgetItem::data (aColumn, Qt::DisplayRole).toString())
+                                         .arg (QTreeWidgetItem::data (aColumn, Qt::UserRole).toString()));
+            default:
+                break;
+        }
+        return QTreeWidgetItem::data (aColumn, aRole);
+    }
+
+    QString text (int aColumn) const
+    {
+        return QTreeWidgetItem::data (aColumn, Qt::DisplayRole).toString();
+    }
+
+    bool isCurrentStateItem() const
+    {
+        return mSnapshot.isNull();
+    }
+
+    int level()
+    {
+        QTreeWidgetItem *item = this;
+        int result = 0;
+        while (item->parent())
+        {
+            ++ result;
+            item = item->parent();
+        }
+        return result;
+    }
+
+    bool bold() const { return font (0).bold(); }
+    void setBold (bool aBold)
+    {
+        QFont myFont = font (0);
+        myFont.setBold (aBold);
+        setFont (0, myFont);
+        adjustText();
+    }
+
+    bool italic() const { return font (0).italic(); }
+    void setItalic (bool aItalic)
+    {
+        QFont myFont = font (0);
+        myFont.setItalic (aItalic);
+        setFont (0, myFont);
+        adjustText();
+    }
+
+    CSnapshot snapshot() const { return mSnapshot; }
+    QString snapshotId() const { return mId; }
+
+    void recache()
+    {
+        if (mIsCurrentState)
+        {
+            Assert (!mMachine.isNull());
+            mCurStateModified = mMachine.GetCurrentStateModified();
+            setText (0, mCurStateModified ?
+                        VBoxSnapshotsWgt::tr ("Current State (changed)", "Current State (Modified)") :
+                        VBoxSnapshotsWgt::tr ("Current State", "Current State (Unmodified)"));
+            mDesc = mCurStateModified ?
+                    VBoxSnapshotsWgt::tr ("The current state differs from the state stored in the current snapshot") :
+                    parent() != 0 ?
+                    VBoxSnapshotsWgt::tr ("The current state is identical to the state stored in the current snapshot") :
+                    QString::null;
+        }
+        else
+        {
+            Assert (!mSnapshot.isNull());
+            mId = mSnapshot.GetId();
+            setText (0, mSnapshot.GetName());
+            mOnline = mSnapshot.GetOnline();
+            setIcon (0, vboxGlobal().snapshotIcon (mOnline));
+            mDesc = mSnapshot.GetDescription();
+            mTimestamp.setTime_t (mSnapshot.GetTimeStamp() / 1000);
+            mCurStateModified = false;
+        }
+        adjustText();
+        recacheToolTip();
+    }
+
+    KMachineState getCurrentState()
+    {
+        if (mMachine.isNull())
+            return KMachineState_Null;
+
+        return mMachineState;
+    }
+
+    void updateCurrentState (KMachineState aState)
+    {
+        if (mMachine.isNull())
+            return;
+
+        setIcon (0, vboxGlobal().toIcon (aState));
+        mMachineState = aState;
+        mTimestamp.setTime_t (mMachine.GetLastStateChange() / 1000);
+    }
+
+    SnapshotAgeFormat updateAge()
+    {
+        QString age;
+
+        /* Age: [date time|%1d ago|%1h ago|%1min ago|%1sec ago] */
+        SnapshotAgeFormat ageFormat;
+        if (mTimestamp.daysTo (QDateTime::currentDateTime()) > 30)
+        {
+            age = VBoxSnapshotsWgt::tr (" (%1)").arg (mTimestamp.toString (Qt::LocalDate));
+            ageFormat = AgeMax;
+        }
+        else if (mTimestamp.secsTo (QDateTime::currentDateTime()) > 60 * 60 * 24)
+        {
+            age = VBoxSnapshotsWgt::tr (" (%1 ago)").arg(VBoxGlobal::daysToString(mTimestamp.secsTo (QDateTime::currentDateTime()) / 60 / 60 / 24));
+            ageFormat = AgeInDays;
+        }
+        else if (mTimestamp.secsTo (QDateTime::currentDateTime()) > 60 * 60)
+        {
+            age = VBoxSnapshotsWgt::tr (" (%1 ago)").arg(VBoxGlobal::hoursToString(mTimestamp.secsTo (QDateTime::currentDateTime()) / 60 / 60));
+            ageFormat = AgeInHours;
+        }
+        else if (mTimestamp.secsTo (QDateTime::currentDateTime()) > 60)
+        {
+            age = VBoxSnapshotsWgt::tr (" (%1 ago)").arg(VBoxGlobal::minutesToString(mTimestamp.secsTo (QDateTime::currentDateTime()) / 60));
+            ageFormat = AgeInMinutes;
+        }
+        else
+        {
+            age = VBoxSnapshotsWgt::tr (" (%1 ago)").arg(VBoxGlobal::secondsToString(mTimestamp.secsTo (QDateTime::currentDateTime())));
+            ageFormat = AgeInSeconds;
+        }
+
+        /* Update data */
+        setData (0, Qt::UserRole, age);
+
+        return ageFormat;
+    }
+
+private:
+
+    void adjustText()
+    {
+        if (!treeWidget()) return; /* only for initialised items */
+        QFontMetrics metrics (font (0));
+        int hei0 = (metrics.height() > 16 ?
+                   metrics.height() /* text */ : 16 /* icon */) +
+                   2 * 2 /* 2 pixel per margin */;
+        int wid0 = metrics.width (text (0)) /* text */ +
+                   treeWidget()->indentation() /* indent */ +
+                   16 /* icon */;
+        setSizeHint (0, QSize (wid0, hei0));
+    }
+
+    void recacheToolTip()
+    {
+        QString name = text (0);
+
+        bool dateTimeToday = mTimestamp.date() == QDate::currentDate();
+        QString dateTime = dateTimeToday ?
+                           mTimestamp.time().toString (Qt::LocalDate) :
+                           mTimestamp.toString (Qt::LocalDate);
+
+        QString details;
+
+        if (!mSnapshot.isNull())
+        {
+            /* The current snapshot is always bold */
+            if (bold())
+                details = VBoxSnapshotsWgt::tr (" (current, ", "Snapshot details");
+            else
+                details = " (";
+            details += mOnline ? VBoxSnapshotsWgt::tr ("online)", "Snapshot details")
+                               : VBoxSnapshotsWgt::tr ("offline)", "Snapshot details");
+
+            if (dateTimeToday)
+                dateTime = VBoxSnapshotsWgt::tr ("Taken at %1", "Snapshot (time)").arg (dateTime);
+            else
+                dateTime = VBoxSnapshotsWgt::tr ("Taken on %1", "Snapshot (date + time)").arg (dateTime);
+        }
+        else
+        {
+            dateTime = VBoxSnapshotsWgt::tr ("%1 since %2", "Current State (time or date + time)")
+                .arg (vboxGlobal().toString (mMachineState)).arg (dateTime);
+        }
+
+        QString toolTip = QString ("<nobr><b>%1</b>%2</nobr><br><nobr>%3</nobr>")
+            .arg (name) .arg (details).arg (dateTime);
+
+        if (!mDesc.isEmpty())
+            toolTip += "<hr>" + mDesc;
+
+        setToolTip (0, toolTip);
+    }
+
+    bool mIsCurrentState;
+
+    CSnapshot mSnapshot;
+    CMachine mMachine;
+
+    QString mId;
+    bool mOnline;
+    QString mDesc;
+    QDateTime mTimestamp;
+
+    bool mCurStateModified;
+    KMachineState mMachineState;
+};
+
+/**
+ *  Simple guard block to prevent cyclic call caused by:
+ *  changing tree-widget item content (rename) leads to snapshot update &
+ *  snapshot update leads to changing tree-widget item content.
+ */
+class SnapshotEditBlocker
+{
+public:
+
+    SnapshotEditBlocker (bool &aProtector)
+        : mProtector (aProtector)
+    {
+        mProtector = true;
+    }
+
+   ~SnapshotEditBlocker()
+    {
+        mProtector = false;
+    }
+
+private:
+
+    bool &mProtector;
+};
+
+VBoxSnapshotsWgt::VBoxSnapshotsWgt (QWidget *aParent)
+    : QIWithRetranslateUI <QWidget> (aParent)
+    , mCurSnapshotItem (0)
+    , mEditProtector (false)
+    , mSnapshotActionGroup (new QActionGroup (this))
+    , mCurStateActionGroup (new QActionGroup (this))
+    , mRestoreSnapshotAction (new QAction (mSnapshotActionGroup))
+    , mDeleteSnapshotAction (new QAction (mSnapshotActionGroup))
+    , mShowSnapshotDetailsAction (new QAction (mSnapshotActionGroup))
+    , mTakeSnapshotAction (new QAction (mCurStateActionGroup))
+{
+    /* Apply UI decorations */
+    Ui::VBoxSnapshotsWgt::setupUi (this);
+
+    mTreeWidget->header()->hide();
+
+    /* The snapshots widget is not very useful if there are a lot
+     * of snapshots in a tree and the current Qt style decides not
+     * to draw lines (branches) between the snapshot nodes; it is
+     * then often unclear which snapshot is a child of another.
+     * So on platforms whose styles do not normally draw branches,
+     * we use QWindowsStyle which is present on every platform and
+     * draws required thing like we want. */
+// #if defined(RT_OS_DARWIN) || defined(RT_OS_LINUX) || defined(RT_OS_SOLARIS)
+    QWindowsStyle *treeWidgetStyle = new QWindowsStyle;
+    mTreeWidget->setStyle (treeWidgetStyle);
+    connect (mTreeWidget, SIGNAL (destroyed (QObject *)), treeWidgetStyle, SLOT (deleteLater()));
+// #endif
+
+    /* ToolBar creation */
+    VBoxToolBar *toolBar = new VBoxToolBar (this);
+    toolBar->setUsesTextLabel (false);
+    toolBar->setIconSize (QSize (22, 22));
+    toolBar->setSizePolicy (QSizePolicy::Fixed, QSizePolicy::Fixed);
+
+    toolBar->addAction (mTakeSnapshotAction);
+    toolBar->addSeparator();
+    toolBar->addAction (mRestoreSnapshotAction);
+    toolBar->addAction (mDeleteSnapshotAction);
+    toolBar->addSeparator();
+    toolBar->addAction (mShowSnapshotDetailsAction);
+
+    ((QVBoxLayout*)layout())->insertWidget (0, toolBar);
+
+    /* Setup actions */
+    mRestoreSnapshotAction->setIcon(UIIconPool::iconSetFull(
+        QSize (22, 22), QSize (16, 16),
+        ":/discard_cur_state_22px.png", ":/discard_cur_state_16px.png", // TODO: Update Icons!
+        ":/discard_cur_state_dis_22px.png", ":/discard_cur_state_dis_16px.png")); // TODO: Update Icons!
+    mDeleteSnapshotAction->setIcon(UIIconPool::iconSetFull(
+        QSize (22, 22), QSize (16, 16),
+        ":/delete_snapshot_22px.png", ":/delete_snapshot_16px.png",
+        ":/delete_snapshot_dis_22px.png", ":/delete_snapshot_dis_16px.png"));
+    mShowSnapshotDetailsAction->setIcon(UIIconPool::iconSetFull(
+        QSize (22, 22), QSize (16, 16),
+        ":/show_snapshot_details_22px.png", ":/show_snapshot_details_16px.png",
+        ":/show_snapshot_details_dis_22px.png", ":/show_snapshot_details_dis_16px.png"));
+    mTakeSnapshotAction->setIcon(UIIconPool::iconSetFull(
+        QSize (22, 22), QSize (16, 16),
+        ":/take_snapshot_22px.png", ":/take_snapshot_16px.png",
+        ":/take_snapshot_dis_22px.png", ":/take_snapshot_dis_16px.png"));
+
+    mRestoreSnapshotAction->setShortcut (QString ("Ctrl+Shift+R"));
+    mDeleteSnapshotAction->setShortcut (QString ("Ctrl+Shift+D"));
+    mShowSnapshotDetailsAction->setShortcut (QString ("Ctrl+Space"));
+    mTakeSnapshotAction->setShortcut (QString ("Ctrl+Shift+S"));
+
+    mAgeUpdateTimer.setSingleShot (true);
+
+    /* Setup connections */
+    connect (mTreeWidget, SIGNAL (currentItemChanged (QTreeWidgetItem*, QTreeWidgetItem*)),
+             this, SLOT (onCurrentChanged (QTreeWidgetItem*)));
+    connect (mTreeWidget, SIGNAL (customContextMenuRequested (const QPoint&)),
+             this, SLOT (onContextMenuRequested (const QPoint&)));
+    connect (mTreeWidget, SIGNAL (itemChanged (QTreeWidgetItem*, int)),
+             this, SLOT (onItemChanged (QTreeWidgetItem*)));
+
+    connect (mRestoreSnapshotAction, SIGNAL (triggered()), this, SLOT (restoreSnapshot()));
+    connect (mDeleteSnapshotAction, SIGNAL (triggered()), this, SLOT (deleteSnapshot()));
+    connect (mShowSnapshotDetailsAction, SIGNAL (triggered()), this, SLOT (showSnapshotDetails()));
+    connect (mTakeSnapshotAction, SIGNAL (triggered()), this, SLOT (takeSnapshot()));
+
+    connect (gVBoxEvents, SIGNAL(sigMachineDataChange(QString)),
+             this, SLOT(machineDataChanged(QString)));
+    connect (gVBoxEvents, SIGNAL(sigMachineStateChange(QString, KMachineState)),
+             this, SLOT(machineStateChanged(QString, KMachineState)));
+    connect (gVBoxEvents, SIGNAL(sigSessionStateChange(QString, KSessionState)),
+             this, SLOT(sessionStateChanged(QString, KSessionState)));
+
+    connect (&mAgeUpdateTimer, SIGNAL (timeout()), this, SLOT (updateSnapshotsAge()));
+
+    retranslateUi();
+}
+
+void VBoxSnapshotsWgt::setMachine (const CMachine &aMachine)
+{
+    mMachine = aMachine;
+
+    if (aMachine.isNull())
+    {
+        mMachineId = QString::null;
+        mSessionState = KSessionState_Null;
+    }
+    else
+    {
+        mMachineId = aMachine.GetId();
+        mSessionState = aMachine.GetSessionState();
+    }
+
+    refreshAll();
+}
+
+
+void VBoxSnapshotsWgt::onCurrentChanged (QTreeWidgetItem *aItem)
+{
+    /* Make the selected item visible */
+    SnapshotWgtItem *item = aItem ? static_cast <SnapshotWgtItem*> (aItem) : 0;
+    if (item)
+    {
+        mTreeWidget->horizontalScrollBar()->setValue (0);
+        mTreeWidget->scrollToItem (item);
+        mTreeWidget->horizontalScrollBar()->setValue (mTreeWidget->indentation() * item->level());
+    }
+
+    /* Whether another direct session is open or not */
+    bool busy = mSessionState != KSessionState_Closed;
+
+    /* Machine state of the current state item */
+    KMachineState s = KMachineState_Null;
+    if (curStateItem())
+        s = curStateItem()->getCurrentState();
+
+    /* Whether taking or deleting snapshots is possible right now */
+    bool canTakeDeleteSnapshot =    !busy
+                                 || s == KMachineState_PoweredOff
+                                 || s == KMachineState_Saved
+                                 || s == KMachineState_Aborted
+                                 || s == KMachineState_Running
+                                 || s == KMachineState_Paused;
+
+    /* Enable/disable restoring snapshot */
+    mRestoreSnapshotAction->setEnabled (!busy && mCurSnapshotItem && item && !item->isCurrentStateItem());
+
+    /* Enable/disable deleting snapshot */
+    mDeleteSnapshotAction->setEnabled (   canTakeDeleteSnapshot
+                                       && mCurSnapshotItem && item && !item->isCurrentStateItem());
+
+    /* Enable/disable the details action regardles of the session state */
+    mShowSnapshotDetailsAction->setEnabled (mCurSnapshotItem && item && !item->isCurrentStateItem());
+
+    /* Enable/disable taking snapshots */
+    mTakeSnapshotAction->setEnabled (   (   canTakeDeleteSnapshot
+                                         && mCurSnapshotItem && item && item->isCurrentStateItem())
+                                     || (item && !mCurSnapshotItem));
+}
+
+void VBoxSnapshotsWgt::onContextMenuRequested (const QPoint &aPoint)
+{
+    QTreeWidgetItem *item = mTreeWidget->itemAt (aPoint);
+    SnapshotWgtItem *snapshotItem = item ? static_cast <SnapshotWgtItem*> (item) : 0;
+    if (!snapshotItem)
+        return;
+
+    QMenu menu;
+
+    if (mCurSnapshotItem && !snapshotItem->isCurrentStateItem())
+    {
+        menu.addAction (mRestoreSnapshotAction);
+        menu.addAction (mDeleteSnapshotAction);
+        menu.addSeparator();
+        menu.addAction (mShowSnapshotDetailsAction);
+    }
+    else
+        menu.addAction (mTakeSnapshotAction);
+
+    menu.exec (mTreeWidget->viewport()->mapToGlobal (aPoint));
+}
+
+void VBoxSnapshotsWgt::onItemChanged (QTreeWidgetItem *aItem)
+{
+    if (mEditProtector)
+        return;
+
+    SnapshotWgtItem *item = aItem ? static_cast <SnapshotWgtItem*> (aItem) : 0;
+
+    if (item)
+    {
+        CSnapshot snap = item->snapshotId().isNull() ? CSnapshot() : mMachine.GetSnapshot (item->snapshotId());
+        if (!snap.isNull() && snap.isOk() && snap.GetName() != item->text (0))
+            snap.SetName (item->text (0));
+    }
+}
+
+void VBoxSnapshotsWgt::restoreSnapshot()
+{
+    SnapshotWgtItem *item = !mTreeWidget->currentItem() ? 0 :
+        static_cast <SnapshotWgtItem*> (mTreeWidget->currentItem());
+    AssertReturn (item, (void) 0);
+
+    QString snapId = item->snapshotId();
+    AssertReturn (!snapId.isNull(), (void) 0);
+    CSnapshot snapshot = mMachine.GetSnapshot (snapId);
+
+    if (!vboxProblem().askAboutSnapshotRestoring (snapshot.GetName()))
+        return;
+
+    /* Open a direct session (this call will handle all errors) */
+    CSession session = vboxGlobal().openSession (mMachineId);
+    if (session.isNull())
+        return;
+
+    CConsole console = session.GetConsole();
+    CProgress progress = console.RestoreSnapshot (snapshot);
+    if (console.isOk())
+    {
+        /* Show the progress dialog */
+        vboxProblem().showModalProgressDialog (progress, mMachine.GetName(),
+                                               vboxProblem().mainWindowShown());
+
+        if (progress.GetResultCode() != 0)
+            vboxProblem().cannotRestoreSnapshot (progress, snapshot.GetName());
+    }
+    else
+        vboxProblem().cannotRestoreSnapshot (progress, snapshot.GetName());
+
+    session.Close();
+}
+
+void VBoxSnapshotsWgt::deleteSnapshot()
+{
+    SnapshotWgtItem *item = !mTreeWidget->currentItem() ? 0 :
+        static_cast <SnapshotWgtItem*> (mTreeWidget->currentItem());
+    AssertReturn (item, (void) 0);
+
+    QString snapId = item->snapshotId();
+    AssertReturn (!snapId.isNull(), (void) 0);
+    CSnapshot snapshot = mMachine.GetSnapshot (snapId);
+
+    if (!vboxProblem().askAboutSnapshotDeleting (snapshot.GetName()))
+        return;
+
+    /** @todo check available space on the target filesystem etc etc. */
+#if 0
+    if (!vboxProblem().askAboutSnapshotDeletingFreeSpace (snapshot.GetName(),
+                                                          "/home/juser/.VirtualBox/Machines/SampleVM/Snapshots/{01020304-0102-0102-0102-010203040506}.vdi",
+                                                          "59 GiB",
+                                                          "15 GiB"))
+        return;
+#endif
+
+
+    /* Open a direct session (this call will handle all errors) */
+    bool busy = mSessionState != KSessionState_Closed;
+    CSession session = vboxGlobal().openSession (mMachineId, busy /* aExisting */);
+    if (session.isNull())
+        return;
+
+    CConsole console = session.GetConsole();
+    CProgress progress = console.DeleteSnapshot (snapId);
+    if (console.isOk())
+    {
+        /* Show the progress dialog */
+        vboxProblem().showModalProgressDialog (progress, mMachine.GetName(),
+                                               vboxProblem().mainWindowShown());
+
+        if (progress.GetResultCode() != 0)
+            vboxProblem().cannotDeleteSnapshot (progress,  snapshot.GetName());
+    }
+    else
+        vboxProblem().cannotDeleteSnapshot (console,  snapshot.GetName());
+
+    session.Close();
+}
+
+void VBoxSnapshotsWgt::showSnapshotDetails()
+{
+    SnapshotWgtItem *item = !mTreeWidget->currentItem() ? 0 :
+        static_cast <SnapshotWgtItem*> (mTreeWidget->currentItem());
+    AssertReturn (item, (void) 0);
+
+    CSnapshot snap = item->snapshot();
+    AssertReturn (!snap.isNull(), (void) 0);
+
+    CMachine snapMachine = snap.GetMachine();
+
+    VBoxSnapshotDetailsDlg dlg (this);
+    dlg.getFromSnapshot (snap);
+
+    if (dlg.exec() == QDialog::Accepted)
+        dlg.putBackToSnapshot();
+}
+
+void VBoxSnapshotsWgt::takeSnapshot()
+{
+    SnapshotWgtItem *item = !mTreeWidget->currentItem() ? 0 :
+        static_cast <SnapshotWgtItem*> (mTreeWidget->currentItem());
+    AssertReturn (item, (void) 0);
+
+    VBoxTakeSnapshotDlg dlg (this, mMachine);
+
+    QString typeId = mMachine.GetOSTypeId();
+    dlg.mLbIcon->setPixmap (vboxGlobal().vmGuestOSTypeIcon (typeId));
+
+    /* Search for the max available filter index */
+    int maxSnapShotIndex = 0;
+    QString snapShotName = tr ("Snapshot %1");
+    QRegExp regExp (QString ("^") + snapShotName.arg ("([0-9]+)") + QString ("$"));
+    QTreeWidgetItemIterator iterator (mTreeWidget);
+    while (*iterator)
+    {
+        QString snapShot = static_cast <SnapshotWgtItem*> (*iterator)->text (0);
+        int pos = regExp.indexIn (snapShot);
+        if (pos != -1)
+            maxSnapShotIndex = regExp.cap (1).toInt() > maxSnapShotIndex ?
+                               regExp.cap (1).toInt() : maxSnapShotIndex;
+        ++ iterator;
+    }
+    dlg.mLeName->setText (snapShotName.arg (maxSnapShotIndex + 1));
+
+    if (dlg.exec() == QDialog::Accepted)
+    {
+        /* Open a direct session (this call will handle all errors) */
+        bool busy = mSessionState != KSessionState_Closed;
+        CSession session = vboxGlobal().openSession (mMachineId, busy /* aExisting */);
+        if (session.isNull())
+            return;
+
+        CConsole console = session.GetConsole();
+        CProgress progress = console.TakeSnapshot (dlg.mLeName->text().trimmed(),
+                                                   dlg.mTeDescription->toPlainText());
+        if (console.isOk())
+        {
+            /* Show the progress dialog */
+            vboxProblem().showModalProgressDialog (progress, mMachine.GetName(),
+                                                   vboxProblem().mainWindowShown());
+
+            if (progress.GetResultCode() != 0)
+                vboxProblem().cannotTakeSnapshot (progress);
+        }
+        else
+            vboxProblem().cannotTakeSnapshot (console);
+
+        session.Close();
+    }
+}
+
+
+void VBoxSnapshotsWgt::machineDataChanged(QString strId)
+{
+    SnapshotEditBlocker guardBlock (mEditProtector);
+
+    if (strId != mMachineId)
+        return;
+
+    curStateItem()->recache();
+}
+
+void VBoxSnapshotsWgt::machineStateChanged(QString strId, KMachineState state)
+{
+    SnapshotEditBlocker guardBlock (mEditProtector);
+
+    if (strId != mMachineId)
+        return;
+
+    curStateItem()->recache();
+    curStateItem()->updateCurrentState(state);
+}
+
+void VBoxSnapshotsWgt::sessionStateChanged(QString strId, KSessionState state)
+{
+    SnapshotEditBlocker guardBlock (mEditProtector);
+
+    if (strId != mMachineId)
+        return;
+
+    mSessionState = state;
+    onCurrentChanged (mTreeWidget->currentItem());
+}
+
+void VBoxSnapshotsWgt::updateSnapshotsAge()
+{
+    if (mAgeUpdateTimer.isActive())
+        mAgeUpdateTimer.stop();
+
+    SnapshotAgeFormat age = traverseSnapshotAge (mTreeWidget->invisibleRootItem());
+
+    switch (age)
+    {
+        case AgeInSeconds:
+            mAgeUpdateTimer.setInterval (5 * 1000);
+            break;
+        case AgeInMinutes:
+            mAgeUpdateTimer.setInterval (60 * 1000);
+            break;
+        case AgeInHours:
+            mAgeUpdateTimer.setInterval (60 * 60 * 1000);
+            break;
+        case AgeInDays:
+            mAgeUpdateTimer.setInterval (24 * 60 * 60 * 1000);
+            break;
+        default:
+            mAgeUpdateTimer.setInterval (0);
+            break;
+    }
+
+    if (mAgeUpdateTimer.interval() > 0)
+        mAgeUpdateTimer.start();
+}
+
+void VBoxSnapshotsWgt::retranslateUi()
+{
+    /* Translate uic generated strings */
+    Ui::VBoxSnapshotsWgt::retranslateUi (this);
+
+    mRestoreSnapshotAction->setText (tr ("&Restore Snapshot"));
+    mDeleteSnapshotAction->setText (tr ("&Delete Snapshot"));
+    mShowSnapshotDetailsAction->setText (tr ("S&how Details"));
+    mTakeSnapshotAction->setText (tr ("Take &Snapshot"));
+
+    mRestoreSnapshotAction->setStatusTip (tr ("Restore the selected snapshot of the virtual machine"));
+    mDeleteSnapshotAction->setStatusTip (tr ("Delete the selected snapshot of the virtual machine"));
+    mShowSnapshotDetailsAction->setStatusTip (tr ("Show the details of the selected snapshot"));
+    mTakeSnapshotAction->setStatusTip (tr ("Take a snapshot of the current virtual machine state"));
+
+    mRestoreSnapshotAction->setToolTip (mRestoreSnapshotAction->text().remove ('&').remove ('.') +
+        QString (" (%1)").arg (mRestoreSnapshotAction->shortcut().toString()));
+    mDeleteSnapshotAction->setToolTip (mDeleteSnapshotAction->text().remove ('&').remove ('.') +
+        QString (" (%1)").arg (mDeleteSnapshotAction->shortcut().toString()));
+    mShowSnapshotDetailsAction->setToolTip (mShowSnapshotDetailsAction->text().remove ('&').remove ('.') +
+        QString (" (%1)").arg (mShowSnapshotDetailsAction->shortcut().toString()));
+    mTakeSnapshotAction->setToolTip (mTakeSnapshotAction->text().remove ('&').remove ('.') +
+        QString (" (%1)").arg (mTakeSnapshotAction->shortcut().toString()));
+}
+
+void VBoxSnapshotsWgt::refreshAll()
+{
+    SnapshotEditBlocker guardBlock (mEditProtector);
+
+    if (mMachine.isNull())
+    {
+        onCurrentChanged();
+        return;
+    }
+
+    QString selectedItem, firstChildOfSelectedItem;
+    SnapshotWgtItem *cur = !mTreeWidget->currentItem() ? 0 :
+        static_cast <SnapshotWgtItem*> (mTreeWidget->currentItem());
+    if (cur)
+    {
+        selectedItem = cur->snapshotId();
+        if (cur->child (0))
+            firstChildOfSelectedItem = static_cast <SnapshotWgtItem*> (cur->child (0))->snapshotId();
+    }
+
+    mTreeWidget->clear();
+
+    /* Get the first snapshot */
+    if (mMachine.GetSnapshotCount() > 0)
+    {
+        CSnapshot snapshot = mMachine.GetSnapshot (QString::null);
+
+        populateSnapshots (snapshot, 0);
+        Assert (mCurSnapshotItem);
+
+        /* Add the "current state" item */
+        SnapshotWgtItem *csi = new SnapshotWgtItem (mCurSnapshotItem, mMachine);
+        csi->setBold (true);
+        csi->recache();
+
+        SnapshotWgtItem *cur = findItem (selectedItem);
+        if (cur == 0)
+            cur = findItem (firstChildOfSelectedItem);
+        if (cur == 0)
+            cur = curStateItem();
+
+        mTreeWidget->scrollToItem (cur);
+        mTreeWidget->setCurrentItem (cur);
+        onCurrentChanged (cur);
+    }
+    else
+    {
+        mCurSnapshotItem = 0;
+
+        /* Add the "current state" item */
+        SnapshotWgtItem *csi = new SnapshotWgtItem (mTreeWidget, mMachine);
+        csi->setBold (true);
+        csi->recache();
+
+        mTreeWidget->setCurrentItem (csi);
+        onCurrentChanged (csi);
+    }
+
+    /* Updating age */
+    updateSnapshotsAge();
+
+    mTreeWidget->resizeColumnToContents (0);
+}
+
+SnapshotWgtItem* VBoxSnapshotsWgt::findItem (const QString &aSnapshotId)
+{
+    QTreeWidgetItemIterator it (mTreeWidget);
+    while (*it)
+    {
+        SnapshotWgtItem *lvi = static_cast <SnapshotWgtItem*> (*it);
+        if (lvi->snapshotId() == aSnapshotId)
+            return lvi;
+        ++ it;
+    }
+
+    return 0;
+}
+
+SnapshotWgtItem *VBoxSnapshotsWgt::curStateItem()
+{
+    QTreeWidgetItem *csi = mCurSnapshotItem ?
+                           mCurSnapshotItem->child (mCurSnapshotItem->childCount() - 1) :
+                           mTreeWidget->invisibleRootItem()->child (0);
+    return static_cast <SnapshotWgtItem*> (csi);
+}
+
+void VBoxSnapshotsWgt::populateSnapshots (const CSnapshot &aSnapshot, QTreeWidgetItem *aItem)
+{
+    SnapshotWgtItem *item = aItem ? new SnapshotWgtItem (aItem, aSnapshot) :
+                                    new SnapshotWgtItem (mTreeWidget, aSnapshot);
+    item->recache();
+
+    if (mMachine.GetCurrentSnapshot().GetId() == aSnapshot.GetId())
+    {
+        item->setBold (true);
+        mCurSnapshotItem = item;
+    }
+
+    CSnapshotVector snapshots = aSnapshot.GetChildren();
+    foreach (const CSnapshot &snapshot, snapshots)
+        populateSnapshots (snapshot, item);
+
+    item->setExpanded (true);
+    item->setFlags (item->flags() | Qt::ItemIsEditable);
+}
+
+SnapshotAgeFormat VBoxSnapshotsWgt::traverseSnapshotAge (QTreeWidgetItem *aParentItem)
+{
+    SnapshotWgtItem *parentItem = aParentItem->type() == SnapshotWgtItem::ItemType ?
+                                  static_cast <SnapshotWgtItem*> (aParentItem) : 0;
+
+    SnapshotAgeFormat age = parentItem ? parentItem->updateAge() : AgeMax;
+    for (int i = 0; i < aParentItem->childCount(); ++ i)
+    {
+        SnapshotAgeFormat newAge = traverseSnapshotAge (aParentItem->child (i));
+        age = newAge < age ? newAge : age;
+    }
+
+    return age;
+}
+
Index: /trunk/src/VBox/Frontends/VirtualBox/src/selector/VBoxSnapshotsWgt.h
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/selector/VBoxSnapshotsWgt.h	(revision 30868)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/selector/VBoxSnapshotsWgt.h	(revision 30868)
@@ -0,0 +1,100 @@
+/** @file
+ *
+ * VBox frontends: Qt4 GUI ("VirtualBox"):
+ * VBoxSnapshotsWgt class declaration
+ */
+
+/*
+ * Copyright (C) 2006-2009 Oracle Corporation
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ */
+
+#ifndef __VBoxSnapshotsWgt_h__
+#define __VBoxSnapshotsWgt_h__
+
+/* Global includes */
+#include <QTimer>
+
+/* Local includes */
+#include "VBoxSnapshotsWgt.gen.h"
+#include "VBoxGlobal.h"
+#include "QIWithRetranslateUI.h"
+
+/* Local forwards */
+class SnapshotWgtItem;
+
+/* Snapshot age format */
+enum SnapshotAgeFormat
+{
+    AgeInSeconds,
+    AgeInMinutes,
+    AgeInHours,
+    AgeInDays,
+    AgeMax
+};
+
+class VBoxSnapshotsWgt : public QIWithRetranslateUI <QWidget>, public Ui::VBoxSnapshotsWgt
+{
+    Q_OBJECT;
+
+public:
+
+    VBoxSnapshotsWgt (QWidget *aParent);
+
+    void setMachine (const CMachine &aMachine);
+
+protected:
+
+    void retranslateUi();
+
+private slots:
+
+    void onCurrentChanged (QTreeWidgetItem *aItem = 0);
+    void onContextMenuRequested (const QPoint &aPoint);
+    void onItemChanged (QTreeWidgetItem *aItem);
+
+    void restoreSnapshot();
+    void deleteSnapshot();
+    void showSnapshotDetails();
+    void takeSnapshot();
+
+    void machineDataChanged(QString strId);
+    void machineStateChanged(QString strId, KMachineState state);
+    void sessionStateChanged(QString strId, KSessionState state);
+
+    void updateSnapshotsAge();
+
+private:
+
+    void refreshAll();
+    SnapshotWgtItem* findItem (const QString &aSnapshotId);
+    SnapshotWgtItem* curStateItem();
+    void populateSnapshots (const CSnapshot &aSnapshot, QTreeWidgetItem *aItem);
+    SnapshotAgeFormat traverseSnapshotAge (QTreeWidgetItem *aParentItem);
+
+    CMachine         mMachine;
+    QString          mMachineId;
+    KSessionState    mSessionState;
+    SnapshotWgtItem *mCurSnapshotItem;
+    bool             mEditProtector;
+
+    QActionGroup    *mSnapshotActionGroup;
+    QActionGroup    *mCurStateActionGroup;
+
+    QAction         *mRestoreSnapshotAction;
+    QAction         *mDeleteSnapshotAction;
+    QAction         *mShowSnapshotDetailsAction;
+    QAction         *mTakeSnapshotAction;
+
+    QTimer          mAgeUpdateTimer;
+};
+
+#endif // __VBoxSnapshotsWgt_h__
+
Index: /trunk/src/VBox/Frontends/VirtualBox/src/selector/VBoxSnapshotsWgt.ui
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/selector/VBoxSnapshotsWgt.ui	(revision 30868)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/selector/VBoxSnapshotsWgt.ui	(revision 30868)
@@ -0,0 +1,55 @@
+<ui version="4.0" >
+ <class>VBoxSnapshotsWgt</class>
+ <comment>
+ VBox frontends: Qt4 GUI ("VirtualBox"):
+
+     Copyright (C) 2008 Oracle Corporation
+
+     This file is part of VirtualBox Open Source Edition (OSE), as
+     available from http://www.virtualbox.org. This file is free software;
+     you can redistribute it and/or modify it under the terms of the GNU
+     General Public License (GPL) as published by the Free Software
+     Foundation, in version 2 as it comes in the "COPYING" file of the
+     VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+     hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ </comment>
+ <widget class="QWidget" name="VBoxSnapshotsWgt" >
+  <property name="geometry" >
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>400</width>
+    <height>300</height>
+   </rect>
+  </property>
+  <property name="windowTitle" >
+   <string>VBoxSnapshotsWgt</string>
+  </property>
+  <layout class="QVBoxLayout" >
+   <property name="leftMargin" >
+    <number>0</number>
+   </property>
+   <property name="topMargin" >
+    <number>0</number>
+   </property>
+   <property name="rightMargin" >
+    <number>0</number>
+   </property>
+   <property name="bottomMargin" >
+    <number>0</number>
+   </property>
+   <item>
+    <widget class="QTreeWidget" name="mTreeWidget" >
+     <property name="contextMenuPolicy" >
+      <enum>Qt::CustomContextMenu</enum>
+     </property>
+     <property name="allColumnsShowFocus" >
+      <bool>true</bool>
+     </property>
+    </widget>
+   </item>
+  </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
Index: /trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIBar.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIBar.cpp	(revision 30868)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIBar.cpp	(revision 30868)
@@ -0,0 +1,108 @@
+/* $Id$ */
+/** @file
+ *
+ * VBox frontends: Qt GUI ("VirtualBox"):
+ * UIBar class implementation
+ */
+
+/*
+ * Copyright (C) 2010 Oracle Corporation
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ */
+
+/* Local includes */
+#include "UIBar.h"
+
+/* Global includes */
+#include <QPaintEvent>
+#include <QPainter>
+#include <QVBoxLayout>
+
+UIBar::UIBar(QWidget *pParent /* = 0 */)
+  : QWidget(pParent)
+  , m_pContentWidget(0)
+{
+    setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
+    QVBoxLayout *pMainLayout = new QVBoxLayout(this);
+    pMainLayout->setContentsMargins(0, 2, 0, 2);
+}
+
+void UIBar::setContentWidget(QWidget *pWidget)
+{
+    QLayout *pLayout = layout();
+    if (m_pContentWidget)
+        pLayout->removeWidget(m_pContentWidget);
+    pLayout->addWidget(pWidget);
+//    pLayout->setAlignment(pWidget, Qt::AlignCenter);
+    m_pContentWidget = pWidget;
+}
+
+QWidget* UIBar::contentWidget() const
+{
+    return m_pContentWidget;
+}
+
+QSize UIBar::sizeHint() const
+{
+    return QSize(0, 0);
+}
+
+void UIBar::paintEvent(QPaintEvent *pEvent)
+{
+    QPainter painter(this);
+    painter.setClipRect(pEvent->rect());
+
+#ifdef Q_WS_MAC
+    paintContentDarwin(&painter);
+#else /* Q_WS_MAC */
+    paintContent(&painter);
+#endif /* !Q_WS_MAC */
+}
+
+#ifdef Q_WS_MAC
+
+void UIBar::paintContentDarwin(QPainter *pPainter)
+{
+    QSize s = size();
+    QLinearGradient lg(0, 1, 0, s.height() - 2);
+    lg.setColorAt(0, QColor(233, 233, 233));
+    lg.setColorAt(1, QColor(208, 208, 208));
+//    pPainter->setPen(QColor(64, 64, 64));
+//    pPainter->drawLine(0, 0, s.width(), 0);
+    pPainter->setPen(QColor(147, 147, 147));
+    pPainter->drawLine(0, s.height()-1, s.width(), s.height()-1);
+    pPainter->setPen(Qt::NoPen);
+    pPainter->setBrush(lg);
+    pPainter->drawRect(0, 1, s.width(), s.height()- 2);
+}
+
+#else /* Q_WS_MAC */
+
+void UIBar::paintContent(QPainter *pPainter)
+{
+    QSize s = size();
+    QPalette pal = palette();
+    QColor base = pal.color(QPalette::Active, QPalette::Window);
+    QLinearGradient lg(0, 1, 0, s.height() - 2);
+    lg.setColorAt(0, base);
+    lg.setColorAt(.49, base.darker(102));
+    lg.setColorAt(.50, base.darker(104));
+    lg.setColorAt(1., base.darker(106));
+    pPainter->setPen(base.darker(60));
+    pPainter->drawLine(0, 0, s.width(), 0);
+    pPainter->setPen(base.darker(125));
+    pPainter->drawLine(0, s.height()-1, s.width(), s.height()-1);
+    pPainter->setPen(Qt::NoPen);
+    pPainter->setBrush(lg);
+    pPainter->drawRect(0, 1, s.width(), s.height()-2);
+}
+
+#endif /* !Q_WS_MAC */
+
Index: /trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIBar.h
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIBar.h	(revision 30868)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIBar.h	(revision 30868)
@@ -0,0 +1,54 @@
+/** @file
+ *
+ * VBox frontends: Qt GUI ("VirtualBox"):
+ * UIBar class declaration
+ */
+
+/*
+ * Copyright (C) 2010 Oracle Corporation
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ */
+
+#ifndef __UIBar_h__
+#define __UIBar_h__
+
+/* Global includes */
+#include <QWidget>
+
+class UIBar : public QWidget
+{
+    Q_OBJECT;
+
+public:
+
+    UIBar(QWidget *pParent = 0);
+    QSize sizeHint() const;
+
+    void setContentWidget(QWidget *pWidget);
+    QWidget* contentWidget() const;
+
+protected:
+
+    void paintEvent(QPaintEvent *pEvent);
+
+#ifdef Q_WS_MAC
+    void paintContentDarwin(QPainter *pPainter);
+#else /* Q_WS_MAC */
+    void paintContent(QPainter *pPainter);
+#endif /* !Q_WS_MAC */
+
+private:
+
+    /* Private member vars */
+    QWidget *m_pContentWidget;
+};
+
+#endif /* !__UIBar_h__ */
+
Index: /trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIPopupBox.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIPopupBox.cpp	(revision 30868)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIPopupBox.cpp	(revision 30868)
@@ -0,0 +1,289 @@
+/* $Id$ */
+/** @file
+ *
+ * VBox frontends: Qt GUI ("VirtualBox"):
+ * UIPopupBox class implementation
+ */
+
+/*
+ * Copyright (C) 2010 Oracle Corporation
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ */
+
+/* Local includes */
+#include "UIPopupBox.h"
+#ifdef Q_WS_MAC
+# include "UIImageTools.h"
+#endif /* Q_WS_MAC */
+
+/* Global includes */
+#include <QApplication>
+#include <QLabel>
+#include <QPaintEvent>
+#include <QPainter>
+#include <QVBoxLayout>
+
+UIPopupBox::UIPopupBox(QWidget *pParent)
+  : QWidget(pParent)
+  , m_fLinkEnabled(false)
+  , m_pContentWidget(0)
+  , m_fOpen(true)
+  , m_pLabelPath(0)
+  , m_aw(9)
+  , m_fHeaderHover(false)
+{
+    QVBoxLayout *pMainLayout = new QVBoxLayout(this);
+    pMainLayout->setContentsMargins(10, 5, 5, 5);
+    QHBoxLayout *pTitleLayout = new QHBoxLayout();
+    m_pTitleIcon = new QLabel(this);
+    m_pTitleLabel = new QLabel(this);
+    connect(m_pTitleLabel, SIGNAL(linkActivated(const QString)),
+            this, SIGNAL(titleClicked(const QString)));
+    pTitleLayout->addWidget(m_pTitleIcon);
+    pTitleLayout->addWidget(m_pTitleLabel, Qt::AlignLeft);
+    pMainLayout->addLayout(pTitleLayout);
+
+    m_arrowPath.lineTo(m_aw / 2.0, m_aw / 2.0);
+    m_arrowPath.lineTo(m_aw, 0);
+
+//    setMouseTracking(true);
+    qApp->installEventFilter(this);
+}
+
+UIPopupBox::~UIPopupBox()
+{
+    if (m_pLabelPath)
+        delete m_pLabelPath;
+}
+
+void UIPopupBox::setTitle(const QString& strTitle)
+{
+    m_strTitle = strTitle;
+    updateHover(true);
+    recalc();
+}
+
+QString UIPopupBox::title() const
+{
+    return m_strTitle;
+}
+
+void UIPopupBox::setTitleIcon(const QIcon& icon)
+{
+    m_icon = icon;
+    updateHover(true);
+    recalc();
+}
+
+QIcon UIPopupBox::titleIcon() const
+{
+    return m_icon;
+}
+
+void UIPopupBox::setTitleLink(const QString& strLink)
+{
+    m_strLink = strLink;
+}
+
+QString UIPopupBox::titleLink() const
+{
+    return m_strLink;
+}
+
+void UIPopupBox::setTitleLinkEnabled(bool fEnabled)
+{
+    m_fLinkEnabled = fEnabled;
+}
+
+bool UIPopupBox::isTitleLinkEnabled() const
+{
+    return m_fLinkEnabled;
+}
+
+void UIPopupBox::setContentWidget(QWidget *pWidget)
+{
+    if (m_pContentWidget)
+    {
+        layout()->removeWidget(m_pContentWidget);
+//        m_pContentWidget->removeEventFilter(this);
+    }
+    m_pContentWidget = pWidget;
+//    m_pContentWidget->installEventFilter(this);
+//    m_pContentWidget->setMouseTracking(true);
+    layout()->addWidget(pWidget);
+    recalc();
+}
+
+QWidget* UIPopupBox::contentWidget() const
+{
+    return m_pContentWidget;
+}
+
+void UIPopupBox::setOpen(bool fOpen)
+{
+    m_fOpen = fOpen;
+    if (m_pContentWidget)
+        m_pContentWidget->setVisible(m_fOpen);
+    else
+        update();
+}
+
+void UIPopupBox::toggleOpen()
+{
+    setOpen(!m_fOpen);
+}
+
+bool UIPopupBox::isOpen() const
+{
+    return m_fOpen;
+}
+
+bool UIPopupBox::eventFilter(QObject * /* pWatched */, QEvent *pEvent)
+{
+    QEvent::Type type = pEvent->type();
+    if (   type == QEvent::MouseMove
+        || type == QEvent::Wheel
+        || type == QEvent::Resize
+        || type == QEvent::Enter
+        || type == QEvent::Leave)
+        updateHover();
+    return false;
+}
+
+void UIPopupBox::resizeEvent(QResizeEvent *pEvent)
+{
+    updateHover();
+    recalc();
+    QWidget::resizeEvent(pEvent);
+}
+
+void UIPopupBox::mouseDoubleClickEvent(QMouseEvent * /* pEvent */)
+{
+    toggleOpen();
+}
+
+void UIPopupBox::mouseMoveEvent(QMouseEvent *pEvent)
+{
+    updateHover();
+    QWidget::mouseMoveEvent(pEvent);
+}
+
+void UIPopupBox::wheelEvent(QWheelEvent *pEvent)
+{
+    updateHover();
+    QWidget::wheelEvent(pEvent);
+}
+
+void UIPopupBox::enterEvent(QEvent *pEvent)
+{
+    updateHover();
+    QWidget::enterEvent(pEvent);
+}
+
+void UIPopupBox::leaveEvent(QEvent *pEvent)
+{
+    updateHover();
+    QWidget::leaveEvent(pEvent);
+}
+
+void UIPopupBox::paintEvent(QPaintEvent *pEvent)
+{
+    QPainter painter(this);
+    painter.setClipRect(pEvent->rect());
+
+    QPalette pal = palette();
+    painter.setClipPath(*m_pLabelPath);
+    QColor base = pal.color(QPalette::Active, QPalette::Window);
+    QRect rect = QRect(QPoint(0, 0), size()).adjusted(0, 0, -1, -1);
+    /* Base background */
+    painter.fillRect(QRect(QPoint(0, 0), size()), pal.brush(QPalette::Active, QPalette::Base));
+    /* Top header background */
+    QLinearGradient lg(rect.x(), rect.y(), rect.x(), rect.y() + 2 * 5 + m_pTitleLabel->sizeHint().height());
+    lg.setColorAt(0, base.darker(95));
+    lg.setColorAt(1, base.darker(110));
+    int theight = rect.height();
+    if (m_fOpen)
+        theight = 2 * 5 + m_pTitleLabel->sizeHint().height();
+    painter.fillRect(QRect(rect.x(), rect.y(), rect.width(), theight), lg);
+    /* Outer round rectangle line */
+    painter.setClipping(false);
+    painter.strokePath(*m_pLabelPath, base.darker(110));
+    /* Arrow */
+    if (m_fHeaderHover)
+    {
+        painter.setBrush(base.darker(106));
+        painter.setPen(QPen(base.darker(128), 3, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
+        QSizeF s = m_arrowPath.boundingRect().size();
+        if (m_fOpen)
+        {
+            painter.translate(rect.x() + rect.width() - s.width() - 10, rect.y() + theight / 2 + s.height() / 2);
+            /* Flip */
+            painter.scale(1, -1);
+        }
+        else
+            painter.translate(rect.x() + rect.width() - s.width() - 10, rect.y() + theight / 2 - s.height() / 2 + 1);
+
+        painter.setRenderHint(QPainter::Antialiasing);
+        painter.drawPath(m_arrowPath);
+    }
+}
+
+void UIPopupBox::updateHover(bool fForce /* = false */)
+{
+    bool fOld = m_fHeaderHover;
+    QPoint bl = mapFromGlobal(QCursor::pos());
+//    printf("%d %d\n", bl.x(), bl.y());
+    if (   m_pLabelPath
+        && m_pLabelPath->contains(mapFromGlobal(QCursor::pos())))
+//        if (underMouse())
+        m_fHeaderHover = true;
+    else
+        m_fHeaderHover = false;
+
+    if (   !m_fLinkEnabled
+        || m_strLink.isEmpty())
+    {
+        m_pTitleLabel->setText(QString("<b>%1</b>").arg(m_strTitle));
+    }
+    if (   fForce
+        || fOld != m_fHeaderHover)
+    {
+        QPalette pal = m_pTitleLabel->palette();
+        m_pTitleLabel->setText(QString("<b><a style=\"text-decoration: none; color: %1\" href=\"%2\">%3</a></b>")
+                               .arg(m_fHeaderHover ? pal.color(QPalette::Link).name() : pal.color(QPalette::WindowText).name())
+                               .arg(m_strLink)
+                               .arg(m_strTitle));
+
+        QPixmap i = m_icon.pixmap(16, 16);
+#ifdef Q_WS_MAC
+        /* todo: fix this */
+        if (!m_fHeaderHover)
+            i = QPixmap::fromImage(toGray(i.toImage()));
+#endif /* Q_WS_MAC */
+        m_pTitleIcon->setPixmap(i);
+        update();
+    }
+}
+
+void UIPopupBox::recalc()
+{
+    if (m_pLabelPath)
+        delete m_pLabelPath;
+    QRect rect = QRect(QPoint(0, 0), size()).adjusted(0, 0, -1, -1);
+    int d = 18; // 22
+    m_pLabelPath = new QPainterPath(QPointF(rect.x() + rect.width() - d, rect.y()));
+    m_pLabelPath->arcTo(QRectF(rect.x(), rect.y(), d, d), 90, 90);
+    m_pLabelPath->arcTo(QRectF(rect.x(), rect.y() + rect.height() - d, d, d), 180, 90);
+    m_pLabelPath->arcTo(QRectF(rect.x() + rect.width() - d, rect.y() + rect.height() - d, d, d), 270, 90);
+    m_pLabelPath->arcTo(QRectF(rect.x() + rect.width() - d, rect.y(), d, d), 0, 90);
+    m_pLabelPath->closeSubpath();
+    update();
+}
+
Index: /trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIPopupBox.h
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIPopupBox.h	(revision 30868)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIPopupBox.h	(revision 30868)
@@ -0,0 +1,94 @@
+/** @file
+ *
+ * VBox frontends: Qt GUI ("VirtualBox"):
+ * UIPopupBox class declaration
+ */
+
+/*
+ * Copyright (C) 2010 Oracle Corporation
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ */
+
+#ifndef __UIPopupBox_h__
+#define __UIPopupBox_h__
+
+/* Global includes */
+#include <QIcon>
+#include <QWidget>
+
+/* Global forward declarations */
+class QLabel;
+
+class UIPopupBox : public QWidget
+{
+    Q_OBJECT;
+
+public:
+
+    UIPopupBox(QWidget *pParent);
+    ~UIPopupBox();
+
+    void setTitle(const QString& strTitle);
+    QString title() const;
+
+    void setTitleIcon(const QIcon& icon);
+    QIcon titleIcon() const;
+
+    void setTitleLink(const QString& strLink);
+    QString titleLink() const;
+
+    void setTitleLinkEnabled(bool fEnabled);
+    bool isTitleLinkEnabled() const;
+
+    void setContentWidget(QWidget *pWidget);
+    QWidget* contentWidget() const;
+
+    void setOpen(bool fOpen);
+    void toggleOpen();
+    bool isOpen() const;
+
+signals:
+    void titleClicked(const QString);
+
+protected:
+
+    bool eventFilter(QObject *pWatched, QEvent *pEvent);
+
+    void resizeEvent(QResizeEvent *pEvent);
+    void mouseDoubleClickEvent(QMouseEvent *pEvent);
+    void mouseMoveEvent(QMouseEvent *pEvent);
+    void wheelEvent(QWheelEvent *pEvent);
+    void enterEvent(QEvent *pEvent);
+    void leaveEvent(QEvent *pEvent);
+    void paintEvent(QPaintEvent *pEvent);
+
+private:
+
+    void updateHover(bool fForce = false);
+    void recalc();
+
+    /* Private member vars */
+    QLabel *m_pTitleLabel;
+    QString m_strTitle;
+    QLabel *m_pTitleIcon;
+    QIcon m_icon;
+    QString m_strLink;
+    bool m_fLinkEnabled;
+    QWidget *m_pContentWidget;
+    bool m_fOpen;
+
+    QPainterPath *m_pLabelPath;
+    const int m_aw;
+    QPainterPath m_arrowPath;
+    bool m_fHeaderHover;
+};
+
+#endif /* !__UIPopupBox_h__ */
+
Index: /trunk/src/VBox/Frontends/VirtualBox/src/widgets/UISpacerWidgets.h
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/widgets/UISpacerWidgets.h	(revision 30867)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/widgets/UISpacerWidgets.h	(revision 30868)
@@ -32,4 +32,5 @@
       : QWidget(pParent)
     {
+        setContentsMargins(0, 0, 0, 0);
         setOrientation(Qt::Horizontal);
     }
@@ -45,5 +46,5 @@
     Qt::Orientation orientation() const { return m_orientation; }
 
-    QSize sizeHint() const { return QSize(1, 1); }
+    QSize sizeHint() const { return QSize(0, 0); }
 
 private:
