Index: /trunk/src/VBox/Frontends/VirtualBox4/include/VBoxDefs.h
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox4/include/VBoxDefs.h	(revision 14045)
+++ /trunk/src/VBox/Frontends/VirtualBox4/include/VBoxDefs.h	(revision 14046)
@@ -24,5 +24,7 @@
 #define __VBoxDefs_h__
 
+/* Qt includes */
 #include <qevent.h>
+#include <QUuid>
 
 #define LOG_GROUP LOG_GROUP_GUI
@@ -65,8 +67,8 @@
 #if defined (VBOX_GUI_DEBUG)
 
+#include <QThread>
+#include <QDateTime>
+
 #include <VBox/types.h> // for uint64_t type
-
-#include <qthread.h>
-#include <qdatetime.h>
 
 /**
@@ -104,5 +106,8 @@
 #endif // VBOX_GUI_DEBUG
 
-/* A common namespace for all enums */
+/** Null UUID constant to be used as a default value for reference parameters */
+extern const QUuid QUuid_null;
+
+/** Common namespace for all enums */
 struct VBoxDefs
 {
Index: /trunk/src/VBox/Frontends/VirtualBox4/include/VBoxSelectorWnd.h
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox4/include/VBoxSelectorWnd.h	(revision 14045)
+++ /trunk/src/VBox/Frontends/VirtualBox4/include/VBoxSelectorWnd.h	(revision 14046)
@@ -36,5 +36,4 @@
     #include <QSystemTrayIcon>
 #endif
-#include <QUuid>
 
 class VBoxSnapshotsWgt;
@@ -70,9 +69,4 @@
 
     void fileMediaMgr();
-    VBoxVMItem* getSelectedItem();
-#ifdef VBOX_GUI_WITH_SYSTRAY
-    void iconActivated (QSystemTrayIcon::ActivationReason aReason);
-    void showWindow();
-#endif
     void fileSettings();
     void fileExit();
@@ -81,15 +75,16 @@
     void vmSettings (const QString &aCategory = QString::null,
                      const QString &aControl = QString::null,
-                     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());
+                     const QUuid & = QUuid_null);
+    void vmDelete (const QUuid & = QUuid_null);
+    void vmStart (const QUuid & = QUuid_null);
+    void vmDiscard (const QUuid & = QUuid_null);
+    void vmPause (bool, const QUuid & = QUuid_null);
+    void vmRefresh (const QUuid & = QUuid_null);
+    void vmShowLogs (const QUuid & = QUuid_null);
 
 #ifdef VBOX_GUI_WITH_SYSTRAY
-    void refreshSysTray(bool a_bRetranslate = false);
+    void refreshSysTray (bool aRetranslate = false);
 #endif
+
     void refreshVMList();
     void refreshVMItem (const QUuid &aID, bool aDetails,
@@ -98,4 +93,9 @@
 
     void showContextMenu (const QPoint &aPoint);
+
+#ifdef VBOX_GUI_WITH_SYSTRAY
+    void trayIconActivated (QSystemTrayIcon::ActivationReason aReason);
+    void showWindow();
+#endif
 
 protected:
@@ -142,8 +142,4 @@
     QAction *fileExitAction;
     QAction *vmNewAction;
-#ifdef VBOX_GUI_WITH_SYSTRAY
-    QAction *trayShowWindowAction;
-    QAction *trayExitAction;
-#endif
     QAction *vmConfigAction;
     QAction *vmDeleteAction;
@@ -154,10 +150,15 @@
     QAction *vmShowLogsAction;
 
+#ifdef VBOX_GUI_WITH_SYSTRAY
+    QAction *mTrayShowWindowAction;
+    QAction *mTrayExitAction;
+#endif
+
     VBoxHelpActions mHelpActions;
 
 #ifdef VBOX_GUI_WITH_SYSTRAY
     /* The systray icon */
-    QSystemTrayIcon *trayIcon;
-    QMenu *trayIconMenu;
+    QSystemTrayIcon *mTrayIcon;
+    QMenu *mTrayIconMenu;
 #endif
 
Index: /trunk/src/VBox/Frontends/VirtualBox4/src/VBoxDefs.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox4/src/VBoxDefs.cpp	(revision 14045)
+++ /trunk/src/VBox/Frontends/VirtualBox4/src/VBoxDefs.cpp	(revision 14046)
@@ -23,4 +23,6 @@
 #include <VBoxDefs.h>
 
+const QUuid QUuid_null;
+
 const char* VBoxDefs::GUI_LastWindowPosition = "GUI/LastWindowPostion";
 const char* VBoxDefs::GUI_LastWindowPosition_Max = "max";
Index: /trunk/src/VBox/Frontends/VirtualBox4/src/VBoxSelectorWnd.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox4/src/VBoxSelectorWnd.cpp	(revision 14045)
+++ /trunk/src/VBox/Frontends/VirtualBox4/src/VBoxSelectorWnd.cpp	(revision 14046)
@@ -408,14 +408,4 @@
     fileExitAction->setMenuRole (QAction::QuitRole);
     fileExitAction->setIcon (VBoxGlobal::iconSet (":/exit_16px.png"));
-
-#ifdef VBOX_GUI_WITH_SYSTRAY
-    trayShowWindowAction = new QAction (this);
-    trayShowWindowAction->setIcon (VBoxGlobal::iconSet (":/VirtualBox_16px.png"));
-    trayShowWindowAction->setText (tr ("Sun xVM VirtualBox"));
-
-    trayExitAction = new QAction (this);
-    trayExitAction->setMenuRole (QAction::QuitRole);
-    trayExitAction->setIcon (VBoxGlobal::iconSet (":/exit_16px.png"));
-#endif
 
     vmNewAction = new QAction (this);
@@ -460,4 +450,14 @@
         ":/vm_show_logs_disabled_32px.png", ":/show_logs_disabled_16px.png"));
 
+#ifdef VBOX_GUI_WITH_SYSTRAY
+    mTrayShowWindowAction = new QAction (this);
+    mTrayShowWindowAction->setIcon (VBoxGlobal::iconSet (":/VirtualBox_16px.png"));
+    mTrayShowWindowAction->setText (tr ("Sun xVM VirtualBox"));
+
+    mTrayExitAction = new QAction (this);
+    mTrayExitAction->setMenuRole (QAction::QuitRole);
+    mTrayExitAction->setIcon (VBoxGlobal::iconSet (":/exit_16px.png"));
+#endif
+
     mHelpActions.setup (this);
 
@@ -466,13 +466,13 @@
     {
         /* tray menu */
-        trayIconMenu = new QMenu(this);
+        mTrayIconMenu = new QMenu (this);
 
         /* tray icon */
-        trayIcon = new QSystemTrayIcon  (this);
-        trayIcon->setIcon(QIcon (":/VirtualBox_16px.png"));
-        trayIcon->setContextMenu (trayIconMenu);
-
-        connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
-                this, SLOT(iconActivated(QSystemTrayIcon::ActivationReason)));
+        mTrayIcon = new QSystemTrayIcon (this);
+        mTrayIcon->setIcon (QIcon (":/VirtualBox_16px.png"));
+        mTrayIcon->setContextMenu (mTrayIconMenu);
+
+        connect (mTrayIcon, SIGNAL (activated (QSystemTrayIcon::ActivationReason)),
+                this, SLOT (trayIconActivated (QSystemTrayIcon::ActivationReason)));
     }
 #endif
@@ -665,5 +665,5 @@
 
 #ifdef VBOX_GUI_WITH_SYSTRAY
-    connect (trayShowWindowAction, SIGNAL (triggered()), this, SLOT(showWindow()));
+    connect (mTrayShowWindowAction, SIGNAL (triggered()), this, SLOT (showWindow()));
 #endif
 
@@ -719,5 +719,5 @@
     /* Save vm selector position */
     {
-        VBoxVMItem *item = getSelectedItem();
+        VBoxVMItem *item = mVMListView->selectedItem();
         QString curVMId = item ?
             QString (item->id()) :
@@ -732,51 +732,4 @@
 // Public slots
 /////////////////////////////////////////////////////////////////////////////
-
-#ifdef VBOX_GUI_WITH_SYSTRAY
-void VBoxSelectorWnd::iconActivated(QSystemTrayIcon::ActivationReason aReason)
-{
-    switch (aReason)
-    {
-
-    case QSystemTrayIcon::Context:
-
-        refreshSysTray();
-        break;
-
-    case QSystemTrayIcon::Trigger:
-        break;
-
-    case QSystemTrayIcon::DoubleClick:
-
-        showWindow();
-        break;
-
-    case QSystemTrayIcon::MiddleClick:
-        break;
-
-    default:
-        break;
-    }
-}
-#endif
-
-VBoxVMItem* VBoxSelectorWnd::getSelectedItem()
-{
-    VBoxVMItem* pItem = NULL;
-
-    if (NULL == pItem)
-        pItem = mVMListView->selectedItem();
-
-    /* pItem can be NULL here, so don't assert. */
-    return pItem;
-}
-
-#ifdef VBOX_GUI_WITH_SYSTRAY
-void VBoxSelectorWnd::showWindow()
-{
-    showNormal();
-    setFocus();
-}
-#endif
 
 void VBoxSelectorWnd::fileMediaMgr()
@@ -836,5 +789,6 @@
  *  Opens the VM settings dialog.
  */
-void VBoxSelectorWnd::vmSettings (const QString &aCategory, const QString &aControl, const QUuid& aUuid)
+void VBoxSelectorWnd::vmSettings (const QString &aCategory, const QString &aControl,
+                                  const QUuid &aUuid /*= QUuid_null*/)
 {
     if (!aCategory.isEmpty() && aCategory [0] != '#')
@@ -845,7 +799,6 @@
     }
 
-    VBoxVMItem *item = mVMModel->itemById (aUuid);
-    if (NULL == item)
-        item = getSelectedItem();
+    VBoxVMItem *item = aUuid.isNull() ? mVMListView->selectedItem() :
+                       mVMModel->itemById (aUuid);
 
     AssertMsgReturnVoid (item, ("Item must be always selected here"));
@@ -888,9 +841,8 @@
 }
 
-void VBoxSelectorWnd::vmDelete (const QUuid& aUuid)
-{
-    VBoxVMItem *item = mVMModel->itemById (aUuid);
-    if (NULL == item)
-        item = getSelectedItem();
+void VBoxSelectorWnd::vmDelete (const QUuid &aUuid /*= QUuid_null*/)
+{
+    VBoxVMItem *item = aUuid.isNull() ? mVMListView->selectedItem() :
+                       mVMModel->itemById (aUuid);
 
     AssertMsgReturnVoid (item, ("Item must be always selected here"));
@@ -950,11 +902,10 @@
 }
 
-void VBoxSelectorWnd::vmStart (const QUuid& aUuid)
-{
-    VBoxVMItem *item = mVMModel->itemById (aUuid);
-    if (NULL == item)
-        item = getSelectedItem();
-
-    AssertMsgReturn (item, ("Item must be always selected here"), (void) 0);
+void VBoxSelectorWnd::vmStart (const QUuid &aUuid /*= QUuid_null*/)
+{
+    VBoxVMItem *item = aUuid.isNull() ? mVMListView->selectedItem() :
+                       mVMModel->itemById (aUuid);
+
+    AssertMsgReturnVoid (item, ("Item must be always selected here"));
 
     /* we always get here when mVMListView emits the activated() signal,
@@ -1029,11 +980,10 @@
 }
 
-void VBoxSelectorWnd::vmDiscard (const QUuid& aUuid)
-{
-    VBoxVMItem *item = mVMModel->itemById (aUuid);
-    if (NULL == item)
-        item = getSelectedItem();
-
-    AssertMsgReturn (item, ("Item must be always selected here"), (void) 0);
+void VBoxSelectorWnd::vmDiscard (const QUuid &aUuid /*= QUuid_null*/)
+{
+    VBoxVMItem *item = aUuid.isNull() ? mVMListView->selectedItem() :
+                       mVMModel->itemById (aUuid);
+
+    AssertMsgReturnVoid (item, ("Item must be always selected here"));
 
     if (!vboxProblem().confirmDiscardSavedState (item->machine()))
@@ -1065,11 +1015,10 @@
 }
 
-void VBoxSelectorWnd::vmPause (bool aPause, const QUuid& aUuid)
-{
-    VBoxVMItem *item = mVMModel->itemById (aUuid);
-    if (NULL == item)
-        item = getSelectedItem();
-
-    AssertMsgReturn (item, ("Item must be always selected here"), (void) 0);
+void VBoxSelectorWnd::vmPause (bool aPause, const QUuid &aUuid /*= QUuid_null*/)
+{
+    VBoxVMItem *item = aUuid.isNull() ? mVMListView->selectedItem() :
+                       mVMModel->itemById (aUuid);
+
+    AssertMsgReturnVoid (item, ("Item must be always selected here"));
 
     CSession session = vboxGlobal().openExistingSession (item->id());
@@ -1098,11 +1047,10 @@
 }
 
-void VBoxSelectorWnd::vmRefresh (const QUuid& aUuid)
-{
-    VBoxVMItem *item = mVMModel->itemById (aUuid);
-    if (NULL == item)
-        item = getSelectedItem();
-
-    AssertMsgReturn (item, ("Item must be always selected here"), (void) 0);
+void VBoxSelectorWnd::vmRefresh (const QUuid &aUuid /*= QUuid_null*/)
+{
+    VBoxVMItem *item = aUuid.isNull() ? mVMListView->selectedItem() :
+                       mVMModel->itemById (aUuid);
+
+    AssertMsgReturnVoid (item, ("Item must be always selected here"));
 
     refreshVMItem (item->id(),
@@ -1112,9 +1060,10 @@
 }
 
-void VBoxSelectorWnd::vmShowLogs (const QUuid& aUuid)
-{
-    VBoxVMItem *item = mVMModel->itemById (aUuid);
-    if (NULL == item)
-        item = getSelectedItem();
+void VBoxSelectorWnd::vmShowLogs (const QUuid &aUuid /*= QUuid_null*/)
+{
+    VBoxVMItem *item = aUuid.isNull() ? mVMListView->selectedItem() :
+                       mVMModel->itemById (aUuid);
+
+    AssertMsgReturnVoid (item, ("Item must be always selected here"));
 
     CMachine machine = item->machine();
@@ -1123,24 +1072,24 @@
 
 #ifdef VBOX_GUI_WITH_SYSTRAY
-void VBoxSelectorWnd::refreshSysTray(bool a_bRetranslate)
+
+void VBoxSelectorWnd::refreshSysTray (bool aRetranslate)
 {
     if (false == QSystemTrayIcon::isSystemTrayAvailable())
         return;
 
-    Assert(trayIcon);
-    Assert(trayIconMenu);
-
-    if (!a_bRetranslate)
-    {
-        trayIcon->setVisible (true);
-        trayIconMenu->clear();
-        trayIconMenu->addAction (trayExitAction);
-        trayIconMenu->addSeparator();
+    AssertReturnVoid (mTrayIcon);
+    AssertReturnVoid (mTrayIconMenu);
+
+    if (!aRetranslate)
+    {
+        mTrayIcon->setVisible (true);
+        mTrayIconMenu->clear();
+        mTrayIconMenu->addAction (mTrayExitAction);
+        mTrayIconMenu->addSeparator();
     }
 
     VBoxVMItem* pItem = NULL;
-    QMenu* pCurMenu = trayIconMenu;
+    QMenu* pCurMenu = mTrayIconMenu;
     QMenu* pSubMenu = NULL;
-    Assert(pCurMenu);
 
     int iCurItemCount = 0;
@@ -1151,5 +1100,5 @@
         Assert(pItem);
 
-        if (a_bRetranslate)
+        if (aRetranslate)
         {
             pItem->retranslateUi();
@@ -1158,7 +1107,7 @@
         else
         {
-            if (iCurItemCount > 14)     /* 15 machines per sub menu. */
+            if (iCurItemCount > 10) /* 10 machines per sub menu. */
             {
-                pSubMenu = new QMenu (tr("Next 15 machines ..."));
+                pSubMenu = new QMenu (tr ("&Other Machines...", "tray menu"));
                 Assert(pSubMenu);
                 pCurMenu->addMenu (pSubMenu);
@@ -1195,12 +1144,12 @@
     }
 
-    if (!a_bRetranslate)
-    {
-        trayIconMenu->addSeparator();
-        trayIconMenu->addAction (fileExitAction);
-    }
-
-}
-#endif
+    if (!aRetranslate)
+    {
+        mTrayIconMenu->addSeparator();
+        mTrayIconMenu->addAction (fileExitAction);
+    }
+}
+
+#endif /* #ifdef VBOX_GUI_WITH_SYSTRAY */
 
 void VBoxSelectorWnd::refreshVMList()
@@ -1242,4 +1191,39 @@
                 mVMCtxtMenu->exec (mVMListView->mapToGlobal (aPoint));
 }
+
+#ifdef VBOX_GUI_WITH_SYSTRAY
+
+void VBoxSelectorWnd::trayIconActivated (QSystemTrayIcon::ActivationReason aReason)
+{
+    switch (aReason)
+    {
+        case QSystemTrayIcon::Context:
+
+            refreshSysTray();
+            break;
+
+        case QSystemTrayIcon::Trigger:
+            break;
+
+        case QSystemTrayIcon::DoubleClick:
+
+            showWindow();
+            break;
+
+        case QSystemTrayIcon::MiddleClick:
+            break;
+
+        default:
+            break;
+    }
+}
+
+void VBoxSelectorWnd::showWindow()
+{
+    showNormal();
+    setFocus();
+}
+
+#endif /* #ifdef VBOX_GUI_WITH_SYSTRAY */
 
 // Protected members
@@ -1426,5 +1410,5 @@
                                                 bool aRefreshDescription)
 {
-    VBoxVMItem *item = getSelectedItem();
+    VBoxVMItem *item = mVMListView->selectedItem();
 
     if (item && item->accessible())
