Index: /trunk/src/VBox/Frontends/VirtualBox4/include/VBoxSelectorWnd.h
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox4/include/VBoxSelectorWnd.h	(revision 14018)
+++ /trunk/src/VBox/Frontends/VirtualBox4/include/VBoxSelectorWnd.h	(revision 14019)
@@ -50,5 +50,5 @@
 class QEvent;
 
-class VBoxSelectorWnd: public QIWithRetranslateUI2<QMainWindow>
+class VBoxSelectorWnd: public QIWithRetranslateUI2 <QMainWindow>
 {
     Q_OBJECT;
@@ -72,5 +72,5 @@
     VBoxVMItem* getSelectedItem();
 #ifdef VBOX_GUI_WITH_SYSTRAY
-    void iconActivated(QSystemTrayIcon::ActivationReason aReason);
+    void iconActivated (QSystemTrayIcon::ActivationReason aReason);
     void showWindow();
 #endif
@@ -81,11 +81,11 @@
     void vmSettings (const QString &aCategory = QString::null,
                      const QString &aControl = QString::null,
-                     const QUuid& = "");
-    void vmDelete(const QUuid& = "");
-    void vmStart (const QUuid& = "");
-    void vmDiscard(const QUuid& = "");
-    void vmPause (bool, const QUuid& = "");
-    void vmRefresh(const QUuid& = "");
-    void vmShowLogs(const QUuid& = "");
+                     const QUuid &aMachineId = QUuid());
+    void vmDelete (const QUuid &aMachineId = QUuid());
+    void vmStart (const QUuid &aMachineId = QUuid());
+    void vmDiscard (const QUuid &aMachineId = QUuid());
+    void vmPause (bool, const QUuid &aMachineId = QUuid());
+    void vmRefresh (const QUuid &aMachineId = QUuid());
+    void vmShowLogs (const QUuid &aMachineId = QUuid());
 
 #ifdef VBOX_GUI_WITH_SYSTRAY
@@ -97,5 +97,5 @@
                                           bool aDescription);
 
-    void showContextMenu (VBoxVMItem *aItem, const QPoint &aPoint);
+    void showContextMenu (const QPoint &aPoint);
 
 protected:
Index: /trunk/src/VBox/Frontends/VirtualBox4/include/VBoxVMListView.h
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox4/include/VBoxVMListView.h	(revision 14018)
+++ /trunk/src/VBox/Frontends/VirtualBox4/include/VBoxVMListView.h	(revision 14019)
@@ -31,4 +31,6 @@
 #include <QDateTime>
 
+class VBoxSelectorWnd;
+
 class VBoxVMItem : public QObject
 {
@@ -50,5 +52,5 @@
 public:
 
-    VBoxVMItem (const CMachine &aM, QObject* pParent);
+    VBoxVMItem (const CMachine &aMachine, VBoxSelectorWnd *pParent);
     virtual ~VBoxVMItem();
 
@@ -85,5 +87,5 @@
     bool canSwitchTo() const;
     bool switchTo();
-    
+
     void updateActions();
 
@@ -91,5 +93,5 @@
 
     /* Private member vars */
-    QObject* mParent;
+    VBoxSelectorWnd *mParent;
     CMachine mMachine;
 
@@ -200,5 +202,4 @@
     void currentChanged();
     void activated();
-    void contextMenuRequested (VBoxVMItem *aItem, const QPoint &aPoint);
 
 protected slots:
@@ -208,5 +209,4 @@
 
 protected:
-    void mousePressEvent (QMouseEvent *aEvent);
     bool selectCurrent();
 };
Index: /trunk/src/VBox/Frontends/VirtualBox4/src/VBoxSelectorWnd.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox4/src/VBoxSelectorWnd.cpp	(revision 14018)
+++ /trunk/src/VBox/Frontends/VirtualBox4/src/VBoxSelectorWnd.cpp	(revision 14019)
@@ -670,8 +670,8 @@
     connect (mVMListView, SIGNAL (currentChanged()),
              this, SLOT (vmListViewCurrentChanged()));
-    connect (mVMListView, SIGNAL (activated ()),
+    connect (mVMListView, SIGNAL (activated()),
              this, SLOT (vmStart()));
-    connect (mVMListView, SIGNAL (contextMenuRequested (VBoxVMItem *, const QPoint &)),
-             this, SLOT (showContextMenu (VBoxVMItem *, const QPoint &)));
+    connect (mVMListView, SIGNAL (customContextMenuRequested (const QPoint &)),
+             this, SLOT (showContextMenu (const QPoint &)));
 
     connect (vmDetailsView, SIGNAL (linkClicked (const QString &)),
@@ -836,5 +836,5 @@
  *  Opens the VM settings dialog.
  */
-void VBoxSelectorWnd::vmSettings (const QString &aCategory, const QString &aControl, const QUuid& a_Uuid)
+void VBoxSelectorWnd::vmSettings (const QString &aCategory, const QString &aControl, const QUuid& aUuid)
 {
     if (!aCategory.isEmpty() && aCategory [0] != '#')
@@ -845,5 +845,5 @@
     }
 
-    VBoxVMItem *item = mVMModel->itemById (a_Uuid);
+    VBoxVMItem *item = mVMModel->itemById (aUuid);
     if (NULL == item)
         item = getSelectedItem();
@@ -888,7 +888,7 @@
 }
 
-void VBoxSelectorWnd::vmDelete(const QUuid& a_Uuid)
-{
-    VBoxVMItem *item = mVMModel->itemById (a_Uuid);
+void VBoxSelectorWnd::vmDelete (const QUuid& aUuid)
+{
+    VBoxVMItem *item = mVMModel->itemById (aUuid);
     if (NULL == item)
         item = getSelectedItem();
@@ -950,7 +950,7 @@
 }
 
-void VBoxSelectorWnd::vmStart(const QUuid& a_Uuid)
-{
-    VBoxVMItem *item = mVMModel->itemById (a_Uuid);
+void VBoxSelectorWnd::vmStart (const QUuid& aUuid)
+{
+    VBoxVMItem *item = mVMModel->itemById (aUuid);
     if (NULL == item)
         item = getSelectedItem();
@@ -1029,7 +1029,7 @@
 }
 
-void VBoxSelectorWnd::vmDiscard(const QUuid& a_Uuid)
-{
-    VBoxVMItem *item = mVMModel->itemById (a_Uuid);
+void VBoxSelectorWnd::vmDiscard (const QUuid& aUuid)
+{
+    VBoxVMItem *item = mVMModel->itemById (aUuid);
     if (NULL == item)
         item = getSelectedItem();
@@ -1065,7 +1065,7 @@
 }
 
-void VBoxSelectorWnd::vmPause (bool aPause, const QUuid& a_Uuid)
-{
-    VBoxVMItem *item = mVMModel->itemById (a_Uuid);
+void VBoxSelectorWnd::vmPause (bool aPause, const QUuid& aUuid)
+{
+    VBoxVMItem *item = mVMModel->itemById (aUuid);
     if (NULL == item)
         item = getSelectedItem();
@@ -1098,7 +1098,7 @@
 }
 
-void VBoxSelectorWnd::vmRefresh(const QUuid& a_Uuid)
-{
-    VBoxVMItem *item = mVMModel->itemById (a_Uuid);
+void VBoxSelectorWnd::vmRefresh (const QUuid& aUuid)
+{
+    VBoxVMItem *item = mVMModel->itemById (aUuid);
     if (NULL == item)
         item = getSelectedItem();
@@ -1112,7 +1112,7 @@
 }
 
-void VBoxSelectorWnd::vmShowLogs(const QUuid& a_Uuid)
-{
-    VBoxVMItem *item = mVMModel->itemById (a_Uuid);
+void VBoxSelectorWnd::vmShowLogs (const QUuid& aUuid)
+{
+    VBoxVMItem *item = mVMModel->itemById (aUuid);
     if (NULL == item)
         item = getSelectedItem();
@@ -1220,8 +1220,12 @@
 }
 
-void VBoxSelectorWnd::showContextMenu (VBoxVMItem *aItem, const QPoint &aPoint)
-{
-    if (aItem)
-        mVMCtxtMenu->exec (aPoint);
+void VBoxSelectorWnd::showContextMenu (const QPoint &aPoint)
+{
+    /* Send a context menu request */
+    const QModelIndex &index = mVMListView->indexAt (aPoint);
+    if (index.isValid())
+        if (VBoxVMItem *item = mVMListView->model()->data (index,
+            VBoxVMModel::VBoxVMItemPtrRole).value <VBoxVMItem*>())
+                mVMCtxtMenu->exec (mVMListView->mapToGlobal (aPoint));
 }
 
Index: /trunk/src/VBox/Frontends/VirtualBox4/src/VBoxVMListView.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox4/src/VBoxVMListView.cpp	(revision 14018)
+++ /trunk/src/VBox/Frontends/VirtualBox4/src/VBoxVMListView.cpp	(revision 14019)
@@ -135,43 +135,43 @@
 #endif
 
-VBoxVMItem::VBoxVMItem (const CMachine &aM, QObject* pParent)
-    : mParent(pParent), mMachine (aM)
+VBoxVMItem::VBoxVMItem (const CMachine &aMachine, VBoxSelectorWnd *pParent)
+    : mParent (pParent), mMachine (aMachine)
 {
     vmConfigAction = new QAction (this);
     vmConfigAction->setIcon (VBoxGlobal::iconSetFull (
-          QSize (32, 32), QSize (16, 16),
-          ":/vm_settings_32px.png", ":/settings_16px.png",
-          ":/vm_settings_disabled_32px.png", ":/settings_dis_16px.png"));
+        QSize (32, 32), QSize (16, 16),
+        ":/vm_settings_32px.png", ":/settings_16px.png",
+        ":/vm_settings_disabled_32px.png", ":/settings_dis_16px.png"));
     vmDeleteAction = new QAction (this);
     vmDeleteAction->setIcon (VBoxGlobal::iconSetFull (
-          QSize (32, 32), QSize (16, 16),
-          ":/vm_delete_32px.png", ":/delete_16px.png",
-          ":/vm_delete_disabled_32px.png", ":/delete_dis_16px.png"));
-     vmStartAction = new QAction (this);
-     vmStartAction->setIcon (VBoxGlobal::iconSetFull (
-          QSize (32, 32), QSize (16, 16),
-          ":/vm_start_32px.png", ":/start_16px.png",
-          ":/vm_start_disabled_32px.png", ":/start_dis_16px.png"));
+        QSize (32, 32), QSize (16, 16),
+        ":/vm_delete_32px.png", ":/delete_16px.png",
+        ":/vm_delete_disabled_32px.png", ":/delete_dis_16px.png"));
+    vmStartAction = new QAction (this);
+    vmStartAction->setIcon (VBoxGlobal::iconSetFull (
+        QSize (32, 32), QSize (16, 16),
+        ":/vm_start_32px.png", ":/start_16px.png",
+        ":/vm_start_disabled_32px.png", ":/start_dis_16px.png"));
     vmDiscardAction = new QAction (this);
     vmDiscardAction->setIcon (VBoxGlobal::iconSetFull (
-          QSize (32, 32), QSize (16, 16),
-          ":/vm_discard_32px.png", ":/discard_16px.png",
-          ":/vm_discard_disabled_32px.png", ":/discard_dis_16px.png"));
+        QSize (32, 32), QSize (16, 16),
+        ":/vm_discard_32px.png", ":/discard_16px.png",
+        ":/vm_discard_disabled_32px.png", ":/discard_dis_16px.png"));
     vmPauseAction = new QAction (this);
     vmPauseAction->setCheckable (true);
     vmPauseAction->setIcon (VBoxGlobal::iconSetFull (
-          QSize (32, 32), QSize (16, 16),
-          ":/vm_pause_32px.png", ":/pause_16px.png",
-          ":/vm_pause_disabled_32px.png", ":/pause_disabled_16px.png"));
+        QSize (32, 32), QSize (16, 16),
+        ":/vm_pause_32px.png", ":/pause_16px.png",
+        ":/vm_pause_disabled_32px.png", ":/pause_disabled_16px.png"));
     vmRefreshAction = new QAction (this);
     vmRefreshAction->setIcon (VBoxGlobal::iconSetFull (
-          QSize (32, 32), QSize (16, 16),
-          ":/refresh_32px.png", ":/refresh_16px.png",
-          ":/refresh_disabled_32px.png", ":/refresh_disabled_16px.png"));
+        QSize (32, 32), QSize (16, 16),
+        ":/refresh_32px.png", ":/refresh_16px.png",
+        ":/refresh_disabled_32px.png", ":/refresh_disabled_16px.png"));
     vmShowLogsAction = new QAction (this);
     vmShowLogsAction->setIcon (VBoxGlobal::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"));
+        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"));
 
     recache();
@@ -184,5 +184,5 @@
     connect (vmRefreshAction, SIGNAL (triggered()), this, SLOT (vmRefresh()));
     connect (vmShowLogsAction, SIGNAL (triggered()), this, SLOT (vmShowLogs()));
-    
+
     updateActions();
 }
@@ -197,54 +197,41 @@
 QString VBoxVMItem::sessionStateName() const
 {
-    return mAccessible ? vboxGlobal().toString (mState) : VBoxVMListView::tr ("Inaccessible");
+    return mAccessible ? vboxGlobal().toString (mState) :
+           VBoxVMListView::tr ("Inaccessible");
 }
 
 void VBoxVMItem::vmSettings()
 {
-    VBoxSelectorWnd* pWnd = qobject_cast<VBoxSelectorWnd*>(mParent);
-    Assert (pWnd);
-    emit pWnd->vmSettings(NULL, NULL, mId);
+    mParent->vmSettings (NULL, NULL, mId);
 }
 
 void VBoxVMItem::vmDelete()
 {
-    VBoxSelectorWnd* pWnd = qobject_cast<VBoxSelectorWnd*>(mParent);
-    Assert (pWnd);
-    emit pWnd->vmDelete(mId);
+    mParent->vmDelete (mId);
 }
 
 void VBoxVMItem::vmStart()
 {
-    VBoxSelectorWnd* pWnd = qobject_cast<VBoxSelectorWnd*>(mParent);
-    Assert (pWnd);
-    emit pWnd->vmStart(mId);
+    mParent->vmStart (mId);
 }
 
 void VBoxVMItem::vmDiscard()
 {
-    VBoxSelectorWnd* pWnd = qobject_cast<VBoxSelectorWnd*>(mParent);
-    Assert (pWnd);
-    emit pWnd->vmDiscard(mId);
-}
-
-void VBoxVMItem::vmPause(bool aPause)
-{
-    VBoxSelectorWnd* pWnd = qobject_cast<VBoxSelectorWnd*>(mParent);
-    Assert (pWnd);
-    emit pWnd->vmPause(aPause, mId);
+    mParent->vmDiscard (mId);
+}
+
+void VBoxVMItem::vmPause (bool aPause)
+{
+    mParent->vmPause (aPause, mId);
 }
 
 void VBoxVMItem::vmRefresh()
 {
-    VBoxSelectorWnd* pWnd = qobject_cast<VBoxSelectorWnd*>(mParent);
-    Assert (pWnd);
-    emit pWnd->vmRefresh(mId);
+    mParent->vmRefresh (mId);
 }
 
 void VBoxVMItem::vmShowLogs()
 {
-    VBoxSelectorWnd* pWnd = qobject_cast<VBoxSelectorWnd*>(mParent);
-    Assert (pWnd);
-    emit pWnd->vmShowLogs(mId);
+    mParent->vmShowLogs (mId);
 }
 
@@ -296,5 +283,5 @@
     {
         QString name = mMachine.GetName();
-        setObjectName(name);
+        setObjectName (name);
         CSnapshot snp = mMachine.GetCurrentSnapshot();
         mSnapshotName = snp.isNull() ? QString::null : snp.GetName();
@@ -545,6 +532,6 @@
     }
     else
-    {    
-        vmRefreshAction->setEnabled (true);    
+    {
+        vmRefreshAction->setEnabled (true);
 
         /* disable modify actions */
@@ -563,19 +550,19 @@
         vmShowLogsAction->setEnabled (false);
     }
-      
+
     vmConfigAction->setText (tr ("&Settings..."));
     vmConfigAction->setStatusTip (tr ("Configure the selected virtual machine"));
-    
+
     vmDeleteAction->setText (tr ("&Delete"));
     vmDeleteAction->setStatusTip (tr ("Delete the selected virtual machine"));
-    
+
     vmDiscardAction->setText (tr ("D&iscard"));
     vmDiscardAction->setStatusTip (
         tr ("Discard the saved state of the selected virtual machine"));
-    
+
     vmRefreshAction->setText (tr ("&Refresh"));
     vmRefreshAction->setStatusTip (
         tr ("Refresh the accessibility state of the selected virtual machine"));
-    
+
     vmShowLogsAction->setText (tr ("Show &Log..."));
     vmShowLogsAction->setIconText (tr ("Log", "icon text"));
@@ -693,10 +680,10 @@
 }
 
-int VBoxVMModel::rowCount(const QModelIndex & /* aParent = QModelIndex() */) const
+int VBoxVMModel::rowCount (const QModelIndex & /* aParent = QModelIndex() */) const
 {
     return mVMItemList.count();
 }
 
-QVariant VBoxVMModel::data(const QModelIndex &aIndex, int aRole) const
+QVariant VBoxVMModel::data (const QModelIndex &aIndex, int aRole) const
 {
     if (!aIndex.isValid())
@@ -710,75 +697,75 @@
     {
         case Qt::DisplayRole:
-            {
-                v = mVMItemList.at (aIndex.row())->name();
-                break;
-            }
+        {
+            v = mVMItemList.at (aIndex.row())->name();
+            break;
+        }
         case Qt::DecorationRole:
-            {
-                v = mVMItemList.at (aIndex.row())->osIcon();
-                break;
-            }
+        {
+            v = mVMItemList.at (aIndex.row())->osIcon();
+            break;
+        }
         case Qt::ToolTipRole:
-            {
-                v = mVMItemList.at (aIndex.row())->toolTipText();
-                break;
-            }
+        {
+            v = mVMItemList.at (aIndex.row())->toolTipText();
+            break;
+        }
         case Qt::FontRole:
-            {
-                QFont f = qApp->font();
-                f.setPointSize (f.pointSize() + 1);
-                f.setWeight (QFont::Bold);
-                v = f;
-                break;
-            }
+        {
+            QFont f = qApp->font();
+            f.setPointSize (f.pointSize() + 1);
+            f.setWeight (QFont::Bold);
+            v = f;
+            break;
+        }
         case Qt::AccessibleTextRole:
-            {
-                VBoxVMItem *item = mVMItemList.at (aIndex.row());
-                v = QString ("%1 (%2)\n%3")
-                             .arg (item->name())
-                             .arg (item->snapshotName())
-                             .arg (item->sessionStateName());
-                break;
-            }
+        {
+            VBoxVMItem *item = mVMItemList.at (aIndex.row());
+            v = QString ("%1 (%2)\n%3")
+                         .arg (item->name())
+                         .arg (item->snapshotName())
+                         .arg (item->sessionStateName());
+            break;
+        }
         case SnapShotDisplayRole:
-            {
-                v = mVMItemList.at (aIndex.row())->snapshotName();
-                break;
-            }
+        {
+            v = mVMItemList.at (aIndex.row())->snapshotName();
+            break;
+        }
         case SnapShotFontRole:
-            {
-                QFont f = qApp->font();
-                v = f;
-                break;
-            }
+        {
+            QFont f = qApp->font();
+            v = f;
+            break;
+        }
         case SessionStateDisplayRole:
-            {
-                v = mVMItemList.at (aIndex.row())->sessionStateName();
-                break;
-            }
+        {
+            v = mVMItemList.at (aIndex.row())->sessionStateName();
+            break;
+        }
         case SessionStateDecorationRole:
-            {
-                v = mVMItemList.at (aIndex.row())->sessionStateIcon();
-                break;
-            }
+        {
+            v = mVMItemList.at (aIndex.row())->sessionStateIcon();
+            break;
+        }
         case SessionStateFontRole:
-            {
-                QFont f = qApp->font();
-                f.setPointSize (f.pointSize());
-                if (mVMItemList.at (aIndex.row())->sessionState() != KSessionState_Closed)
-                    f.setItalic (true);
-                v = f;
-                break;
-            }
+        {
+            QFont f = qApp->font();
+            f.setPointSize (f.pointSize());
+            if (mVMItemList.at (aIndex.row())->sessionState() != KSessionState_Closed)
+                f.setItalic (true);
+            v = f;
+            break;
+        }
         case VBoxVMItemPtrRole:
-            {
-                v = qVariantFromValue (mVMItemList.at (aIndex.row()));
-            }
+        {
+            v = qVariantFromValue (mVMItemList.at (aIndex.row()));
+        }
     }
     return v;
 }
 
-QVariant VBoxVMModel::headerData(int /*aSection*/, Qt::Orientation /*aOrientation*/,
-                                 int /*aRole = Qt::DisplayRole */) const
+QVariant VBoxVMModel::headerData (int /*aSection*/, Qt::Orientation /*aOrientation*/,
+                                  int /*aRole = Qt::DisplayRole */) const
 {
     return QVariant();
@@ -805,11 +792,13 @@
 {
     /* Create & set our delegation class */
-    VBoxVMItemPainter *delegate = new VBoxVMItemPainter(this);
-    setItemDelegate(delegate);
+    VBoxVMItemPainter *delegate = new VBoxVMItemPainter (this);
+    setItemDelegate (delegate);
     /* Default icon size */
     setIconSize (QSize (32, 32));
     /* Publish the activation of items */
     connect (this, SIGNAL (activated (const QModelIndex &)),
-             this, SIGNAL (activated ()));
+             this, SIGNAL (activated()));
+    /* Use the correct policy for the context menu */
+    setContextMenuPolicy (Qt::CustomContextMenu);
 }
 
@@ -821,5 +810,5 @@
 void VBoxVMListView::selectItemById (const QUuid &aID)
 {
-    if (VBoxVMModel *m = qobject_cast<VBoxVMModel*> (model()))
+    if (VBoxVMModel *m = qobject_cast <VBoxVMModel*> (model()))
     {
         QModelIndex i = m->indexById (aID);
@@ -832,5 +821,5 @@
 {
     VBoxVMItem *item = selectedItem();
-    if(!item)
+    if (!item)
     {
         aRowHint = qBound (0, aRowHint, model()->rowCount() - 1);
@@ -847,5 +836,5 @@
     if (indexes.isEmpty())
         return NULL;
-    return model()->data (indexes.first(), VBoxVMModel::VBoxVMItemPtrRole).value<VBoxVMItem *>();
+    return model()->data (indexes.first(), VBoxVMModel::VBoxVMItemPtrRole).value <VBoxVMItem *>();
 }
 
@@ -877,20 +866,4 @@
     ensureCurrentVisible();
     emit currentChanged();
-}
-
-void VBoxVMListView::mousePressEvent (QMouseEvent *aEvent)
-{
-    /* First process event, in the case the user select a new item */
-    QListView::mousePressEvent (aEvent);
-    if (aEvent->button() == Qt::RightButton)
-    {
-        /* Send a context menu request if necessary */
-        const QModelIndex &index = indexAt (aEvent->pos());
-        if (index.isValid())
-        {
-            VBoxVMItem *item = model()->data (index, VBoxVMModel::VBoxVMItemPtrRole).value<VBoxVMItem *>();
-            emit contextMenuRequested (item, aEvent->globalPos());
-        }
-    }
 }
 
