VirtualBox

Changeset 38977 in vbox for trunk/src/VBox/Frontends


Ignore:
Timestamp:
Oct 12, 2011 11:44:56 AM (13 years ago)
Author:
vboxsync
Message:

FE/Qt: GUI Maintenance: VM Selector Window overall update & coding-style rework.

Location:
trunk/src/VBox/Frontends/VirtualBox
Files:
14 edited
2 moved

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk

    r38973 r38977  
    131131endif
    132132ifdef VBOX_BLEEDING_EDGE
    133 VirtualBox_src/selector/VBoxSelectorWnd.cpp_DEFS += \
     133VirtualBox_src/selector/UISelectorWindow.cpp_DEFS += \
    134134    VBOX_BLEEDING_EDGE=\"$(VBOX_BLEEDING_EDGE)\"
    135135VirtualBox_src/runtime/UIMachineWindow.cpp_DEFS += \
     
    305305        src/selector/UIVMPreviewWindow.h \
    306306        src/selector/UIVirtualBoxEventHandler.h \
    307         src/selector/VBoxSelectorWnd.h \
     307        src/selector/UISelectorWindow.h \
    308308        src/selector/VBoxSnapshotsWgt.h \
    309309        src/settings/UISettingsDialog.h \
     
    478478        src/selector/UIVMPreviewWindow.cpp \
    479479        src/selector/UIVirtualBoxEventHandler.cpp \
    480         src/selector/VBoxSelectorWnd.cpp \
     480        src/selector/UISelectorWindow.cpp \
    481481        src/selector/VBoxSnapshotsWgt.cpp \
    482482        src/settings/UISettingsDefs.cpp \
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxMediaManagerDlg.cpp

    r38311 r38977  
    550550        mModelessDialog->setup (VBoxDefs::MediumType_All, false /* aDoSelect */, aRefresh);
    551551
    552         /* Setup 'closing' connection if main window is VBoxSelectorWnd: */
    553         if (vboxGlobal().mainWindow() && vboxGlobal().mainWindow()->inherits("VBoxSelectorWnd"))
     552        /* Setup 'closing' connection if main window is UISelectorWindow: */
     553        if (vboxGlobal().mainWindow() && vboxGlobal().mainWindow()->inherits("UISelectorWindow"))
    554554            connect(vboxGlobal().mainWindow(), SIGNAL(closing()), mModelessDialog, SLOT(close()));
    555555
  • trunk/src/VBox/Frontends/VirtualBox/src/extensions/QIMessageBox.cpp

    r38373 r38977  
    2626#include "QIDialogButtonBox.h"
    2727#include "UIIconPool.h"
    28 #ifdef Q_WS_MAC
    29 # include "VBoxSelectorWnd.h"
    30 #endif /* Q_WS_MAC */
    3128
    3229/* Qt includes */
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.cpp

    r38582 r38977  
    3535#include "UIMessageCenter.h"
    3636#include "VBoxGlobal.h"
    37 #include "VBoxSelectorWnd.h"
     37#include "UISelectorWindow.h"
    3838#include "UIProgressDialog.h"
    3939#include "UIDownloaderUserManual.h"
     
    22262226}
    22272227
     2228bool UIMessageCenter::confirmVMACPIShutdown(QWidget *pParent /* = 0 */)
     2229{
     2230    return messageOkCancel(pParent ? pParent : mainMachineWindowShown(), Question,
     2231        tr("<p>Do you really want to send an ACPI shutdown signal to the virtual machine?</p>"),
     2232        "confirmVMACPIShutdown" /* pcszAutoConfirmId */,
     2233        tr("ACPI Shutdown", "machine"));
     2234}
     2235
    22282236bool UIMessageCenter::confirmVMPowerOff(QWidget *pParent /* = 0 */)
    22292237{
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.h

    r38582 r38977  
    346346
    347347    bool confirmVMReset(QWidget *pParent = 0);
     348    bool confirmVMACPIShutdown(QWidget *pParent = 0);
    348349    bool confirmVMPowerOff(QWidget *pParent = 0);
    349350
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp

    r38774 r38977  
    2424#include "VBoxUtils.h"
    2525#include "VBoxDefs.h"
    26 #include "VBoxSelectorWnd.h"
     26#include "UISelectorWindow.h"
    2727#include "UIMessageCenter.h"
    2828#include "QIMessageBox.h"
     
    417417 *  There is only one such a window per VirtualBox application.
    418418 */
    419 VBoxSelectorWnd &VBoxGlobal::selectorWnd()
     419UISelectorWindow &VBoxGlobal::selectorWnd()
    420420{
    421421    AssertMsg (!vboxGlobal().isVMConsoleProcess(),
     
    431431         *  from the below constructor or from constructors/methods it calls.
    432432         */
    433         VBoxSelectorWnd *w = new VBoxSelectorWnd (&mSelectorWnd, 0);
     433        UISelectorWindow *w = new UISelectorWindow (&mSelectorWnd, 0);
    434434        Assert (w == mSelectorWnd);
    435435        NOREF(w);
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.h

    r38568 r38977  
    106106////////////////////////////////////////////////////////////////////////////////
    107107
    108 class VBoxSelectorWnd;
     108class UISelectorWindow;
    109109class UIRegistrationWzd;
    110110class VBoxUpdateDlg;
     
    139139    bool setSettings (VBoxGlobalSettings &gs);
    140140
    141     VBoxSelectorWnd &selectorWnd();
     141    UISelectorWindow &selectorWnd();
    142142
    143143    QWidget *vmWindow();
     
    800800    VBoxGlobalSettings gset;
    801801
    802     VBoxSelectorWnd *mSelectorWnd;
     802    UISelectorWindow *mSelectorWnd;
    803803    UIMachine *m_pVirtualMachine;
    804804    QWidget* mMainWindow;
  • trunk/src/VBox/Frontends/VirtualBox/src/main.cpp

    r38636 r38977  
    2626#include "VBoxGlobal.h"
    2727#include "UIMessageCenter.h"
    28 #include "VBoxSelectorWnd.h"
     28#include "UISelectorWindow.h"
    2929#include "VBoxUtils.h"
    3030#ifdef Q_WS_MAC
  • trunk/src/VBox/Frontends/VirtualBox/src/precomp.h

    r38973 r38977  
    232232#include "UIMessageCenter.h"
    233233#include "VBoxProgressDialog.h"
    234 #include "VBoxSelectorWnd.h"
     234#include "UISelectorWindow.h"
    235235#include "UISettingsDialog.h"
    236236#include "UISettingsDialogSpecific.h"
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UISelectorWindow.cpp

    r38973 r38977  
    22 *
    33 * VBox frontends: Qt GUI ("VirtualBox"):
    4  * VBoxSelectorWnd class implementation
     4 * UISelectorWindow class implementation
    55 */
    66
     
    2020# include "precomp.h"
    2121#else  /* !VBOX_WITH_PRECOMPILED_HEADERS */
     22/* Global includes */
     23#include <QDesktopWidget>
     24#include <QMenuBar>
     25#include <QResizeEvent>
     26#include <QDesktopServices>
     27
     28/* Local includes: */
    2229#include "QISplitter.h"
    2330#include "UIBar.h"
     
    3643#include "VBoxMediaManagerDlg.h"
    3744#include "UIMessageCenter.h"
    38 #include "VBoxSelectorWnd.h"
     45#include "UISelectorWindow.h"
    3946#include "UISettingsDialogSpecific.h"
    4047#include "UIToolBar.h"
     
    4350#include "UISelectorShortcuts.h"
    4451#include "UIDesktopServices.h"
    45 #include "UIGlobalSettingsExtension.h" /* extension pack installation */
     52#include "UIGlobalSettingsExtension.h"
    4653#include "UIActionPoolSelector.h"
    4754
     
    5562# include "UIWindowMenuManager.h"
    5663# include "UIImageTools.h"
    57 #endif
    58 
    59 /* Global includes */
    60 #include <QDesktopWidget>
    61 #include <QMenuBar>
    62 #include <QResizeEvent>
    63 #include <QDesktopServices>
     64#endif /* Q_WS_MAC */
     65
     66#ifdef Q_WS_X11
     67# include <iprt/env.h>
     68#endif /* Q_WS_X11 */
    6469
    6570#include <iprt/buildconfig.h>
    6671#include <VBox/version.h>
    67 #ifdef Q_WS_X11
    68 # include <iprt/env.h>
    69 #endif
    7072#endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
    7173
    72 // VBoxSelectorWnd class
    73 ////////////////////////////////////////////////////////////////////////////////
    74 
    75 /** \class VBoxSelectorWnd
    76  *
    77  *  The VBoxSelectorWnd class is a VM selector window, one of two main VBox
    78  *  GUI windows.
    79  *
    80  *  This window appears when the user starts the VirtualBox executable.
    81  *  It allows to view the list of configured VMs, their settings
    82  *  and the current state, create, reconfigure, delete and start VMs.
    83  */
    84 
    85 /**
    86  *  Constructs the VM selector window.
    87  *
    88  *  @param aSelf pointer to a variable where to store |this| right after
    89  *               this object's constructor is called (necessary to avoid
    90  *               recursion in VBoxGlobal::selectorWnd())
    91  */
    92 VBoxSelectorWnd::
    93 VBoxSelectorWnd(VBoxSelectorWnd **aSelf, QWidget* aParent,
    94                 Qt::WindowFlags aFlags /* = Qt::Window */)
    95     : QIWithRetranslateUI2<QMainWindow>(aParent, aFlags)
    96     , mDoneInaccessibleWarningOnce(false)
     74UISelectorWindow::UISelectorWindow(UISelectorWindow **ppSelf, QWidget *pParent,
     75                                   Qt::WindowFlags flags /* = Qt::Window */)
     76    : QIWithRetranslateUI2<QMainWindow>(pParent, flags)
     77    , m_pSplitter(0)
     78#ifndef Q_WS_MAC
     79    , m_pBar(0)
     80#endif /* !Q_WS_MAC */
     81    , mVMToolBar(0)
     82    , m_pVMListView(0)
     83    , m_pVMModel(0)
     84    , m_pMachineContextMenu(0)
     85    , m_pVMDesktop(0)
     86    , m_fDoneInaccessibleWarningOnce(false)
    9787{
    9888    /* Remember self: */
    99     if (aSelf)
    100         *aSelf = this;
    101 
    102     /* The application icon: */
    103 #if !(defined (Q_WS_WIN) || defined (Q_WS_MAC))
    104     /* On Win32, it's built-in to the executable.
    105      * On Mac OS X the icon referenced in info.plist is used. */
    106     setWindowIcon(QIcon(":/VirtualBox_48px.png"));
    107 #endif
    108 
    109     /* Prepare menu: */
     89    if (ppSelf)
     90        *ppSelf = this;
     91
     92    /* Prepare everything: */
     93    prepareIcon();
    11094    prepareMenuBar();
    11195    prepareContextMenu();
    112 
    113     /* Prepare status bar: */
    11496    prepareStatusBar();
    115 
    116     /* Prepare tool bar: */
    11797    prepareWidgets();
    118 
    119     /* Prepare connections: */
    12098    prepareConnections();
    12199
    122 #ifdef VBOX_GUI_WITH_SYSTRAY
    123     mTrayIcon = new VBoxTrayIcon(this, mVMModel);
    124     Assert(mTrayIcon);
    125 #endif
    126 
     100    /* Load all settings: */
     101    loadSettings();
     102
     103    /* Translate UI: */
    127104    retranslateUi();
    128105
    129     CVirtualBox vbox = vboxGlobal().virtualBox();
    130     /* Restore the position of the window */
    131     {
    132         QString winPos = vbox.GetExtraData(VBoxDefs::GUI_LastWindowPosition);
    133 
    134         bool ok = false, max = false;
    135         int x = 0, y = 0, w = 0, h = 0;
    136         x = winPos.section(',', 0, 0).toInt(&ok);
    137         if (ok)
    138             y = winPos.section(',', 1, 1).toInt(&ok);
    139         if (ok)
    140             w = winPos.section(',', 2, 2).toInt(&ok);
    141         if (ok)
    142             h = winPos.section(',', 3, 3).toInt(&ok);
    143         if (ok)
    144             max = winPos.section(',', 4, 4) == VBoxDefs::GUI_LastWindowState_Max;
    145 
    146         QRect ar = ok ? QApplication::desktop()->availableGeometry(QPoint(x, y)) :
    147                         QApplication::desktop()->availableGeometry(this);
    148 
    149         if (ok /* previous parameters were read correctly */
    150             && (y > 0) && (y < ar.bottom()) /* check vertical bounds */
    151             && (x + w > ar.left()) && (x < ar.right()) /* & horizontal bounds */)
    152         {
    153             mNormalGeo.moveTo(x, y);
    154             mNormalGeo.setSize(QSize(w, h)
    155                                .expandedTo(minimumSizeHint())
    156                                .boundedTo(ar.size()));
    157 #if defined(Q_WS_MAC) && (QT_VERSION >= 0x040700)
    158             move(mNormalGeo.topLeft());
    159             resize(mNormalGeo.size());
    160             mNormalGeo = normalGeometry();
    161 #else /* defined(Q_WS_MAC) && (QT_VERSION >= 0x040700) */
    162             setGeometry(mNormalGeo);
    163 #endif /* !(defined(Q_WS_MAC) && (QT_VERSION >= 0x040700)) */
    164             if (max) /* maximize if needed */
    165                 showMaximized();
    166         }
    167         else
    168         {
    169             mNormalGeo.setSize(QSize(770, 550).expandedTo(minimumSizeHint())
    170                                               .boundedTo(ar.size()));
    171             mNormalGeo.moveCenter(ar.center());
    172             setGeometry(mNormalGeo);
    173         }
    174     }
    175 #if MAC_LEOPARD_STYLE
    176     /* Enable unified toolbars on Mac OS X. Available on Qt >= 4.3. We do this
    177      * after setting the window pos/size, cause Qt sometime includes the
    178      * toolbar height in the content height. */
     106#ifdef Q_WS_MAC
     107# if MAC_LEOPARD_STYLE
     108    /* Enable unified toolbars on Mac OS X. Available on Qt >= 4.3.
     109     * We do this after setting the window pos/size, cause Qt sometimes
     110     * includes the toolbar height in the content height. */
    179111    mVMToolBar->setMacToolbar();
    180 #endif /* MAC_LEOPARD_STYLE */
    181 
    182     /* Update the list */
    183     refreshVMList();
    184 
    185     /* Reset to the first item */
    186     mVMListView->selectItemByRow(0);
    187 
    188     /* restore the position of vm selector */
    189     {
    190         QString prevVMId = vbox.GetExtraData(VBoxDefs::GUI_LastVMSelected);
    191 
    192         mVMListView->selectItemById(prevVMId);
    193     }
    194 
    195     /* Read the splitter handle position */
    196     {
    197         QList<int> sizes = vbox.GetExtraDataIntList(VBoxDefs::GUI_SplitterSizes);
    198         if (sizes.size() == 2)
    199             m_pSplitter->setSizes(sizes);
    200     }
    201 
    202     /* Restore toolbar and statusbar visibility */
    203     {
    204         QString strToolbar = vbox.GetExtraData(VBoxDefs::GUI_Toolbar);
    205         QString strStatusbar = vbox.GetExtraData(VBoxDefs::GUI_Statusbar);
    206 
    207 #ifdef Q_WS_MAC
    208         mVMToolBar->setVisible(strToolbar.isEmpty() || strToolbar == "true");
    209 #else /* Q_WS_MAC */
    210         m_pBar->setVisible(strToolbar.isEmpty() || strToolbar == "true");
    211 #endif /* !Q_WS_MAC */
    212         statusBar()->setVisible(strStatusbar.isEmpty() || strStatusbar == "true");
    213     }
    214 
    215     /* refresh the details et all (necessary for the case when the stored
    216      * selection is still the first list item) */
    217     vmListViewCurrentChanged();
    218 
    219     /* bring the VM list to the focus */
    220     mVMListView->setFocus();
    221 
    222 #ifdef Q_WS_MAC
     112# endif /* MAC_LEOPARD_STYLE */
     113
    223114    UIWindowMenuManager::instance()->addWindow(this);
    224115    /* Beta label? */
     
    228119        ::darwinLabelWindow(this, &betaLabel, false);
    229120    }
    230 #endif /* Q_WS_MAC */
    231 
    232 #ifdef Q_WS_MAC
     121
    233122    /* General event filter: */
    234123    qApp->installEventFilter(this);
     
    236125}
    237126
    238 VBoxSelectorWnd::~VBoxSelectorWnd()
    239 {
     127UISelectorWindow::~UISelectorWindow()
     128{
     129    /* Destroy our event handlers: */
     130    UIVirtualBoxEventHandler::destroy();
     131
     132    /* Save all settings: */
     133    saveSettings();
     134
     135#ifdef VBOX_GUI_WITH_SYSTRAY
     136    /* Delete systray menu object: */
     137    delete m_pTrayIcon;
     138    m_pTrayIcon = NULL;
     139#endif /* VBOX_GUI_WITH_SYSTRAY */
     140}
     141
     142void UISelectorWindow::sltShowSelectorContextMenu(const QPoint &pos)
     143{
     144    /* Load toolbar/statusbar availability settings: */
    240145    CVirtualBox vbox = vboxGlobal().virtualBox();
    241 
    242     /* Destroy our event handlers */
    243     UIVirtualBoxEventHandler::destroy();
    244 
    245     /* Save the position of the window */
    246     {
    247 #if defined(Q_WS_MAC) && (QT_VERSION >= 0x040700)
    248         QRect frameGeo = frameGeometry();
    249         QRect save(frameGeo.x(), frameGeo.y(), mNormalGeo.width(), mNormalGeo.height());
    250 #else /* defined(Q_WS_MAC) && (QT_VERSION >= 0x040700) */
    251         QRect save(mNormalGeo);
    252 #endif /* !(defined(Q_WS_MAC) && (QT_VERSION >= 0x040700)) */
    253         QString winPos = QString("%1,%2,%3,%4")
    254             .arg(save.x()).arg(save.y())
    255             .arg(save.width()).arg(save.height());
     146    QString strToolbar = vbox.GetExtraData(VBoxDefs::GUI_Toolbar);
     147    QString strStatusbar = vbox.GetExtraData(VBoxDefs::GUI_Statusbar);
     148    bool fToolbar = strToolbar.isEmpty() || strToolbar == "true";
     149    bool fStatusbar = strStatusbar.isEmpty() || strStatusbar == "true";
     150
     151    /* Populate toolbar/statusbar acctions: */
     152    QList<QAction*> actions;
     153    QAction *pShowToolBar = new QAction(tr("Show Toolbar"), 0);
     154    pShowToolBar->setCheckable(true);
     155    pShowToolBar->setChecked(fToolbar);
     156    actions << pShowToolBar;
     157    QAction *pShowStatusBar = new QAction(tr("Show Statusbar"), 0);
     158    pShowStatusBar->setCheckable(true);
     159    pShowStatusBar->setChecked(fStatusbar);
     160    actions << pShowStatusBar;
     161
     162    QPoint gpos = pos;
     163    QWidget *pSender = static_cast<QWidget*>(sender());
     164    if (pSender)
     165        gpos = pSender->mapToGlobal(pos);
     166    QAction *pResult = QMenu::exec(actions, gpos);
     167    if (pResult == pShowToolBar)
     168    {
     169        if (pResult->isChecked())
     170        {
    256171#ifdef Q_WS_MAC
    257         UIWindowMenuManager::destroy();
    258         ::darwinUnregisterForUnifiedToolbarContextMenuEvents(this);
    259         if (::darwinIsWindowMaximized(this))
     172            mVMToolBar->show();
    260173#else /* Q_WS_MAC */
    261         if (isMaximized())
     174            m_pBar->show();
    262175#endif /* !Q_WS_MAC */
    263             winPos += QString(",%1").arg(VBoxDefs::GUI_LastWindowState_Max);
    264 
    265         vbox.SetExtraData(VBoxDefs::GUI_LastWindowPosition, winPos);
    266     }
    267 
    268     /* Save VM selector position */
    269     {
    270         UIVMItem *item = mVMListView->selectedItem();
    271         QString curVMId = item ?
    272             QString(item->id()) :
    273             QString::null;
    274         vbox.SetExtraData(VBoxDefs::GUI_LastVMSelected, curVMId);
    275         vbox.SetExtraDataStringList(VBoxDefs::GUI_SelectorVMPositions, mVMModel->idList());
    276     }
    277 
    278     /* Save the splitter handle position */
    279     {
    280         vbox.SetExtraDataIntList(VBoxDefs::GUI_SplitterSizes, m_pSplitter->sizes());
    281     }
    282 
    283 #ifdef VBOX_GUI_WITH_SYSTRAY
    284     /* Delete systray menu object */
    285     delete mTrayIcon;
    286     mTrayIcon = NULL;
    287 #endif
    288 
    289     /* Delete the items from our model */
    290     mVMModel->clear();
    291 }
    292 
    293 //
    294 // Public slots
    295 /////////////////////////////////////////////////////////////////////////////
    296 
    297 void VBoxSelectorWnd::sltShowMediumManager()
    298 {
     176            vbox.SetExtraData(VBoxDefs::GUI_Toolbar, "true");
     177        }
     178        else
     179        {
     180#ifdef Q_WS_MAC
     181            mVMToolBar->hide();
     182#else /* Q_WS_MAC */
     183            m_pBar->hide();
     184#endif /* !Q_WS_MAC */
     185            vbox.SetExtraData(VBoxDefs::GUI_Toolbar, "false");
     186        }
     187    }
     188    else if (pResult == pShowStatusBar)
     189    {
     190        if (pResult->isChecked())
     191        {
     192            statusBar()->show();
     193            vbox.SetExtraData(VBoxDefs::GUI_Statusbar, "true");
     194        }
     195        else
     196        {
     197            statusBar()->hide();
     198            vbox.SetExtraData(VBoxDefs::GUI_Statusbar, "false");
     199        }
     200    }
     201}
     202
     203void UISelectorWindow::sltShowMediumManager()
     204{
     205    /* Show modeless Virtual Medium Manager: */
    299206    VBoxMediaManagerDlg::showModeless(this);
    300207}
    301208
    302 void VBoxSelectorWnd::sltShowImportApplianceWizard(const QString &strFile /* = "" */)
    303 {
     209void UISelectorWindow::sltShowImportApplianceWizard(const QString &strFileName /* = QString() */)
     210{
     211    /* Show Import Appliance wizard: */
    304212#ifdef Q_WS_MAC
    305     QString strTmpFile = ::darwinResolveAlias(strFile);
     213    QString strTmpFile = ::darwinResolveAlias(strFileName);
    306214#else /* Q_WS_MAC */
    307     QString strTmpFile = strFile;
     215    QString strTmpFile = strFileName;
    308216#endif /* !Q_WS_MAC */
    309     UIImportApplianceWzd wzd(strTmpFile, this);
    310 
    311     if (   strFile.isEmpty()
    312         || wzd.isValid())
    313         wzd.exec();
    314 }
    315 
    316 void VBoxSelectorWnd::sltShowExportApplianceWizard()
    317 {
    318     QString name;
    319 
    320     UIVMItem *item = mVMListView->selectedItem();
    321     if (item)
    322         name = item->name();
    323 
    324     UIExportApplianceWzd wzd(this, name);
    325 
    326     wzd.exec();
    327 }
    328 
    329 void VBoxSelectorWnd::sltShowPreferencesDialog()
     217    UIImportApplianceWzd wizard(strTmpFile, this);
     218    if (strFileName.isEmpty() || wizard.isValid())
     219        wizard.exec();
     220}
     221
     222void UISelectorWindow::sltShowExportApplianceWizard()
     223{
     224    /* Show Export Appliance wizard: */
     225    QString strName;
     226    if (UIVMItem *pItem = m_pVMListView->selectedItem())
     227        strName = pItem->name();
     228    UIExportApplianceWzd wizard(this, strName);
     229    wizard.exec();
     230}
     231
     232void UISelectorWindow::sltShowPreferencesDialog()
    330233{
    331234    /* Get corresponding action: */
    332235    QAction *pShowPreferencesDialogAction = gActionPool->action(UIActionIndexSelector_Simple_File_PreferencesDialog);
    333 
    334236    /* Check that we do NOT handling that already: */
    335237    if (pShowPreferencesDialogAction->data().toBool())
     
    339241
    340242    /* Create and execute global settings dialog: */
    341     UISettingsDialogGlobal dlg(this);
    342     dlg.execute();
     243    UISettingsDialogGlobal dialog(this);
     244    dialog.execute();
    343245
    344246    /* Remember that we do NOT handling that already: */
     
    346248}
    347249
    348 void VBoxSelectorWnd::sltPerformExit()
     250void UISelectorWindow::sltPerformExit()
    349251{
    350252    /* We have to check if there are any open windows beside this mainwindow
     
    352254     * different to Qt3 where a *mainWidget* exists & if this going to close
    353255     * all other windows are closed automatically. We do the same below. */
    354     foreach(QWidget *widget, QApplication::topLevelWidgets())
    355     {
    356         if (widget->isVisible() &&
    357             widget != this)
    358             widget->close();
    359     }
    360     /* We close this widget last. */
     256    QWidgetList widgets = QApplication::topLevelWidgets();
     257    for(int i = 0; i < widgets.size(); ++i)
     258    {
     259        QWidget *pWidget = widgets[i];
     260        if (pWidget && pWidget->isVisible() && pWidget != this)
     261            pWidget->close();
     262    }
     263    /* We close this pWidget last: */
    361264    close();
    362265}
    363266
    364 void VBoxSelectorWnd::sltShowNewMachineWizard()
    365 {
    366     UINewVMWzd wzd(this);
    367     if (wzd.exec() == QDialog::Accepted)
    368     {
    369         CMachine m = wzd.machine();
    370 
    371         /* wait until the list is updated by OnMachineRegistered() */
     267void UISelectorWindow::sltShowNewMachineWizard()
     268{
     269    /* Show New Machine wizard: */
     270    UINewVMWzd wizard(this);
     271    if (wizard.exec() == QDialog::Accepted)
     272    {
     273        /* Wait until the list is updated by OnMachineRegistered(): */
     274        const CMachine &machine = wizard.machine();
    372275        QModelIndex index;
    373276        while(!index.isValid())
    374277        {
    375278            qApp->processEvents();
    376             index = mVMModel->indexById(m.GetId());
    377         }
    378         mVMListView->setCurrentIndex(index);
    379     }
    380 }
    381 
    382 void VBoxSelectorWnd::sltShowAddMachineDialog(const QString &strFile /* = "" */)
    383 {
     279            index = m_pVMModel->indexById(machine.GetId());
     280        }
     281        /* Choose newly created item: */
     282        m_pVMListView->setCurrentIndex(index);
     283    }
     284}
     285
     286void UISelectorWindow::sltShowAddMachineDialog(const QString &strFileName /* = QString() */)
     287{
     288    /* Initialize variables: */
    384289#ifdef Q_WS_MAC
    385     QString strTmpFile = ::darwinResolveAlias(strFile);
     290    QString strTmpFile = ::darwinResolveAlias(strFileName);
    386291#else /* Q_WS_MAC */
    387     QString strTmpFile = strFile;
     292    QString strTmpFile = strFileName;
    388293#endif /* !Q_WS_MAC */
    389     /* Initialize variables: */
    390294    CVirtualBox vbox = vboxGlobal().virtualBox();
    391295    if (strTmpFile.isEmpty())
     
    402306            strTmpFile = fileNames.at(0);
    403307    }
     308
     309    /* Open corresponding machine: */
    404310    if (!strTmpFile.isEmpty())
    405311    {
    406         /* Open corresponding machine: */
    407312        CMachine newMachine = vbox.OpenMachine(strTmpFile);
    408313        /* First we should test what machine was opened: */
     
    417322                /* Register that machine: */
    418323                vbox.RegisterMachine(newMachine);
    419 
    420324                /* Wait until the list is updated by OnMachineRegistered(): */
    421325                QModelIndex index;
     
    423327                {
    424328                    qApp->processEvents();
    425                     index = mVMModel->indexById(newMachine.GetId());
     329                    index = m_pVMModel->indexById(newMachine.GetId());
    426330                }
    427                 /* And choose the new machine item: */
    428                 mVMListView->setCurrentIndex(index);
     331                /* And choose added item: */
     332                m_pVMListView->setCurrentIndex(index);
    429333            }
    430334            else
     
    436340}
    437341
    438 /**
    439  *  Opens the VM settings dialog.
    440  */
    441 void VBoxSelectorWnd::sltShowMachineSettingsDialog(const QString &strCategoryRef /* = QString::null */,
    442                                                    const QString &strControlRef /* = QString::null */,
    443                                                    const QString &strMachineId /* = QString::null */)
     342void UISelectorWindow::sltShowMachineSettingsDialog(const QString &strCategoryRef /* = QString() */,
     343                                                    const QString &strControlRef /* = QString() */,
     344                                                    const QString &strMachineId /* = QString() */)
    444345{
    445346    /* Get corresponding action: */
    446347    QAction *pShowSettingsDialogAction = gActionPool->action(UIActionIndexSelector_Simple_Machine_SettingsDialog);
    447 
    448348    /* Check that we do NOT handling that already: */
    449349    if (pShowSettingsDialogAction->data().toBool())
     
    474374
    475375    /* Don't show the inaccessible warning if the user tries to open VM settings: */
    476     mDoneInaccessibleWarningOnce = true;
     376    m_fDoneInaccessibleWarningOnce = true;
    477377
    478378    /* Get corresponding VM item: */
    479     UIVMItem *pItem = strMachineId.isNull() ? mVMListView->selectedItem() : mVMModel->itemById(strMachineId);
     379    UIVMItem *pItem = strMachineId.isNull() ? m_pVMListView->selectedItem() : m_pVMModel->itemById(strMachineId);
    480380    AssertMsgReturnVoid(pItem, ("Item must be always selected here!\n"));
    481381
    482382    /* Create and execute corresponding VM settings dialog: */
    483     UISettingsDialogMachine dlg(this, pItem->id(), strCategory, strControl);
    484     dlg.execute();
     383    UISettingsDialogMachine dialog(this, pItem->id(), strCategory, strControl);
     384    dialog.execute();
    485385
    486386    /* Remember that we do NOT handling that already: */
     
    488388}
    489389
    490 void VBoxSelectorWnd::sltShowCloneMachineDialog(const QString &aUuid /* = QString::null */)
    491 {
    492     UIVMItem *item = aUuid.isNull() ? mVMListView->selectedItem() : mVMModel->itemById(aUuid);
    493 
    494     AssertMsgReturnVoid(item, ("Item must be always selected here"));
    495 
    496     CMachine machine = item->machine();
    497 
    498     UICloneVMWizard wzd(this, machine);
    499     wzd.exec();
    500 }
    501 
    502 void VBoxSelectorWnd::sltShowRemoveMachineDialog(const QString &aUuid /* = QString::null */)
    503 {
    504     UIVMItem *item = aUuid.isNull() ? mVMListView->selectedItem() : mVMModel->itemById(aUuid);
    505 
    506     AssertMsgReturnVoid(item, ("Item must be always selected here"));
    507 
    508     CMachine machine = item->machine();
     390void UISelectorWindow::sltShowCloneMachineWizard(const QString &strMachineId /* = QString() */)
     391{
     392    UIVMItem *pItem = strMachineId.isNull() ? m_pVMListView->selectedItem() : m_pVMModel->itemById(strMachineId);
     393    AssertMsgReturnVoid(pItem, ("Item must be always selected here"));
     394
     395    /* Show clone VM wizard: */
     396    CMachine machine = pItem->machine();
     397    UICloneVMWizard wizard(this, machine);
     398    wizard.exec();
     399}
     400
     401void UISelectorWindow::sltShowRemoveMachineDialog(const QString &strMachineId /* = QString() */)
     402{
     403    UIVMItem *pItem = strMachineId.isNull() ? m_pVMListView->selectedItem() : m_pVMModel->itemById(strMachineId);
     404    AssertMsgReturnVoid(pItem, ("Item must be always selected here"));
     405
     406    /* Show Remove Machine dialog: */
     407    CMachine machine = pItem->machine();
    509408    int rc = msgCenter().confirmMachineDeletion(machine);
    510409    if (rc != QIMessageBox::Cancel)
     
    520419                if (machine.isOk())
    521420                {
    522                     msgCenter().showModalProgressDialog(progress, item->name(), ":/progress_delete_90px.png", 0, true);
     421                    msgCenter().showModalProgressDialog(progress, pItem->name(), ":/progress_delete_90px.png", 0, true);
    523422                    if (progress.GetResultCode() != 0)
    524423                        msgCenter().cannotDeleteMachine(machine, progress);
     
    538437}
    539438
    540 void VBoxSelectorWnd::sltPerformStartOrShowAction(const QString &aUuid /* = QString::null */)
    541 {
    542     QUuid uuid(aUuid);
    543     UIVMItem *item = uuid.isNull() ? mVMListView->selectedItem() :
    544                        mVMModel->itemById(aUuid);
    545 
    546     AssertMsgReturnVoid(item, ("Item must be always selected here"));
    547 
    548     /* Are we called from the mVMListView's activated() signal? */
     439void UISelectorWindow::sltPerformStartOrShowAction(const QString &strMachineId /* = QString() */)
     440{
     441    QUuid uuid(strMachineId);
     442    UIVMItem *pItem = uuid.isNull() ? m_pVMListView->selectedItem() : m_pVMModel->itemById(strMachineId);
     443    AssertMsgReturnVoid(pItem, ("Item must be always selected here"));
     444
     445    /* Are we called from the m_pVMListView's activated() signal? */
    549446    if (uuid.isNull())
    550447    {
    551         /* We always get here when mVMListView emits the activated() signal,
     448        /* We always get here when m_pVMListView emits the activated() signal,
    552449         * so we must explicitly check if the action is enabled or not. */
    553450        if (!gActionPool->action(UIActionIndexSelector_State_Machine_StartOrShow)->isEnabled())
     
    555452    }
    556453
    557     AssertMsg(!vboxGlobal().isVMConsoleProcess(),
    558               ("Must NOT be a VM console process"));
    559 
    560     CMachine machine = item->machine();
     454    /* Start/show machine: */
     455    CMachine machine = pItem->machine();
    561456    vboxGlobal().launchMachine(machine, qApp->keyboardModifiers() == Qt::ShiftModifier);
    562457}
    563458
    564 void VBoxSelectorWnd::sltPerformDiscardAction(const QString &aUuid /* = QString::null */)
    565 {
    566     UIVMItem *item = aUuid.isNull() ? mVMListView->selectedItem() :
    567                        mVMModel->itemById(aUuid);
    568 
    569     AssertMsgReturnVoid(item, ("Item must be always selected here"));
    570 
    571     if (!msgCenter().confirmDiscardSavedState(item->machine()))
    572         return;
    573 
    574     /* open a session to modify VM settings */
    575     QString id = item->id();
     459void UISelectorWindow::sltPerformDiscardAction(const QString &strMachineId /* = QString() */)
     460{
     461    UIVMItem *pItem = strMachineId.isNull() ? m_pVMListView->selectedItem() : m_pVMModel->itemById(strMachineId);
     462    AssertMsgReturnVoid(pItem, ("Item must be always selected here"));
     463
     464    /* Confirm discarding current VM saved state: */
     465    if (!msgCenter().confirmDiscardSavedState(pItem->machine()))
     466        return;
     467
     468    /* Open a session to modify VM settings: */
     469    QString strMachinId = pItem->id();
    576470    CSession session;
    577471    CVirtualBox vbox = vboxGlobal().virtualBox();
     
    583477    }
    584478
    585     CMachine foundMachine = vbox.FindMachine(id);
    586     if (!foundMachine.isNull())
    587         foundMachine.LockMachine(session, KLockType_Write);
     479    /* Search for the correspoding machine: */
     480    CMachine machine = vbox.FindMachine(strMachinId);
     481    if (!machine.isNull())
     482        machine.LockMachine(session, KLockType_Write);
    588483    if (!vbox.isOk())
    589484    {
    590         msgCenter().cannotOpenSession(vbox, item->machine());
    591         return;
    592     }
    593 
     485        msgCenter().cannotOpenSession(vbox, pItem->machine());
     486        return;
     487    }
     488
     489    /* Get session console: */
    594490    CConsole console = session.GetConsole();
    595491    console.DiscardSavedState(true /* fDeleteFile */);
     
    597493        msgCenter().cannotDiscardSavedState(console);
    598494
     495    /* Unlock machine finally: */
    599496    session.UnlockMachine();
    600497}
    601498
    602 void VBoxSelectorWnd::sltPerformPauseResumeAction(bool aPause, const QString &aUuid /* = QString::null */)
    603 {
    604     UIVMItem *item = aUuid.isNull() ? mVMListView->selectedItem() :
    605                        mVMModel->itemById(aUuid);
    606 
    607     AssertMsgReturnVoid(item, ("Item must be always selected here"));
    608 
    609     CSession session = vboxGlobal().openExistingSession(item->id());
     499void UISelectorWindow::sltPerformPauseResumeAction(bool fPause, const QString &strMachineId /* = QString() */)
     500{
     501    UIVMItem *pItem = strMachineId.isNull() ? m_pVMListView->selectedItem() : m_pVMModel->itemById(strMachineId);
     502    AssertMsgReturnVoid(pItem, ("Item must be always selected here"));
     503
     504    /* Open a session to modify VM state: */
     505    CSession session = vboxGlobal().openExistingSession(pItem->id());
    610506    if (session.isNull())
    611507        return;
    612508
     509    /* Get session console: */
    613510    CConsole console = session.GetConsole();
    614511    if (console.isNull())
    615512        return;
    616513
    617     if (aPause)
     514    /* Pause/resume VM: */
     515    if (fPause)
    618516        console.Pause();
    619517    else
     
    623521    if (!ok)
    624522    {
    625         if (aPause)
     523        if (fPause)
    626524            msgCenter().cannotPauseMachine(console);
    627525        else
     
    629527    }
    630528
     529    /* Unlock machine finally: */
    631530    session.UnlockMachine();
    632531}
    633532
    634 void VBoxSelectorWnd::sltPerformResetAction(const QString &aUuid /* = QString::null */)
    635 {
    636     UIVMItem *item = aUuid.isNull() ? mVMListView->selectedItem() :
    637                        mVMModel->itemById(aUuid);
    638 
    639     AssertMsgReturnVoid(item, ("Item must be always selected here"));
    640 
    641     /* Confirm/Reset current console: */
    642     if (msgCenter().confirmVMReset(this))
    643     {
    644         CSession session = vboxGlobal().openExistingSession(item->id());
    645         if (session.isNull())
    646             return;
    647 
    648         CConsole console = session.GetConsole();
    649         if (console.isNull())
    650             return;
    651 
    652         console.Reset();
    653     }
    654 }
    655 
    656 void VBoxSelectorWnd::sltPerformACPIShutdownAction(const QString &aUuid /* = QString::null */)
    657 {
    658     UIVMItem *item = aUuid.isNull() ? mVMListView->selectedItem() :
    659                        mVMModel->itemById(aUuid);
    660 
    661     AssertMsgReturnVoid(item, ("Item must be always selected here"));
    662 
    663     /* Confirm/Reset current console: */
    664     if (msgCenter().confirmVMReset(this))
    665     {
    666         CSession session = vboxGlobal().openExistingSession(item->id());
    667         if (session.isNull())
    668             return;
    669 
    670         CConsole console = session.GetConsole();
    671         if (console.isNull())
    672             return;
    673 
    674         console.PowerButton();
    675 
    676         session.UnlockMachine();
    677     }
    678 }
    679 
    680 void VBoxSelectorWnd::sltPerformPowerOffAction(const QString &aUuid /* = QString::null */)
    681 {
    682     UIVMItem *item = aUuid.isNull() ? mVMListView->selectedItem() :
    683                        mVMModel->itemById(aUuid);
    684 
    685     AssertMsgReturnVoid(item, ("Item must be always selected here"));
    686 
    687     /* Confirm/Reset current console: */
    688     if (msgCenter().confirmVMPowerOff(this))
    689     {
    690         CSession session = vboxGlobal().openExistingSession(item->id());
    691         if (session.isNull())
    692             return;
    693 
    694         CConsole console = session.GetConsole();
    695         if (console.isNull())
    696             return;
    697 
    698         console.PowerDown();
    699 
    700         session.UnlockMachine();
    701     }
    702 }
    703 
    704 void VBoxSelectorWnd::sltPerformRefreshAction(const QString &aUuid /* = QString::null */)
    705 {
    706     UIVMItem *item = aUuid.isNull() ? mVMListView->selectedItem() :
    707                        mVMModel->itemById(aUuid);
    708 
    709     AssertMsgReturnVoid(item, ("Item must be always selected here"));
    710 
    711     refreshVMItem(item->id(),
    712                    true /* aDetails */,
    713                    true /* aSnapshot */,
    714                    true /* aDescription */);
    715 }
    716 
    717 void VBoxSelectorWnd::sltShowLogDialog(const QString &aUuid /* = QString::null */)
    718 {
    719     UIVMItem *item = aUuid.isNull() ? mVMListView->selectedItem() :
    720                        mVMModel->itemById(aUuid);
    721 
    722     AssertMsgReturnVoid(item, ("Item must be always selected here"));
    723 
    724     CMachine machine = item->machine();
     533void UISelectorWindow::sltPerformResetAction(const QString &strMachineId /* = QString() */)
     534{
     535    UIVMItem *pItem = strMachineId.isNull() ? m_pVMListView->selectedItem() : m_pVMModel->itemById(strMachineId);
     536    AssertMsgReturnVoid(pItem, ("Item must be always selected here"));
     537
     538    /* Confirm reseting current VM: */
     539    if (!msgCenter().confirmVMReset(this))
     540        return;
     541
     542    /* Open a session to modify VM state: */
     543    CSession session = vboxGlobal().openExistingSession(pItem->id());
     544    if (session.isNull())
     545        return;
     546
     547    /* Get session console: */
     548    CConsole console = session.GetConsole();
     549    if (console.isNull())
     550        return;
     551
     552    /* Reset VM: */
     553    console.Reset();
     554
     555    /* Unlock machine finally: */
     556    session.UnlockMachine();
     557}
     558
     559void UISelectorWindow::sltPerformACPIShutdownAction(const QString &strMachineId /* = QString() */)
     560{
     561    UIVMItem *pItem = strMachineId.isNull() ? m_pVMListView->selectedItem() : m_pVMModel->itemById(strMachineId);
     562    AssertMsgReturnVoid(pItem, ("Item must be always selected here"));
     563
     564    /* Confirm ACPI shutdown current VM: */
     565    if (!msgCenter().confirmVMACPIShutdown(this))
     566        return;
     567
     568    /* Open a session to modify VM state: */
     569    CSession session = vboxGlobal().openExistingSession(pItem->id());
     570    if (session.isNull())
     571        return;
     572
     573    /* Get session console: */
     574    CConsole console = session.GetConsole();
     575    if (console.isNull())
     576        return;
     577
     578    /* ACPI Shutdown: */
     579    console.PowerButton();
     580
     581    /* Unlock machine finally: */
     582    session.UnlockMachine();
     583}
     584
     585void UISelectorWindow::sltPerformPowerOffAction(const QString &strMachineId /* = QString() */)
     586{
     587    UIVMItem *pItem = strMachineId.isNull() ? m_pVMListView->selectedItem() : m_pVMModel->itemById(strMachineId);
     588    AssertMsgReturnVoid(pItem, ("Item must be always selected here"));
     589
     590    /* Confirm Power Off current VM: */
     591    if (!msgCenter().confirmVMPowerOff(this))
     592        return;
     593
     594    /* Open a session to modify VM state: */
     595    CSession session = vboxGlobal().openExistingSession(pItem->id());
     596    if (session.isNull())
     597        return;
     598
     599    /* Get session console: */
     600    CConsole console = session.GetConsole();
     601    if (console.isNull())
     602        return;
     603
     604    /* Power Off: */
     605    console.PowerDown();
     606
     607    /* Unlock machine finally: */
     608    session.UnlockMachine();
     609}
     610
     611void UISelectorWindow::sltPerformRefreshAction(const QString &strMachineId /* = QString() */)
     612{
     613    UIVMItem *pItem = strMachineId.isNull() ? m_pVMListView->selectedItem() : m_pVMModel->itemById(strMachineId);
     614    AssertMsgReturnVoid(pItem, ("Item must be always selected here"));
     615
     616    /* Refresh currently selected VM item: */
     617    sltRefreshVMItem(pItem->id(), true /* details */, true /* snapshot */, true /* description */);
     618}
     619
     620void UISelectorWindow::sltShowLogDialog(const QString &strMachineId /* = QString() */)
     621{
     622    UIVMItem *pItem = strMachineId.isNull() ? m_pVMListView->selectedItem() : m_pVMModel->itemById(strMachineId);
     623    AssertMsgReturnVoid(pItem, ("Item must be always selected here"));
     624
     625    /* Show VM Log Viewer: */
     626    const CMachine &machine = pItem->machine();
    725627    UIVMLogViewer::showLogViewerFor(this, machine);
    726628}
    727629
    728 void VBoxSelectorWnd::sltShowMachineInFileManager(const QString &aUuid /* = QString::null */)
    729 {
    730     UIVMItem *item = aUuid.isNull() ? mVMListView->selectedItem() :
    731                        mVMModel->itemById(aUuid);
    732 
    733     AssertMsgReturnVoid(item, ("Item must be always selected here"));
    734 
    735     CMachine machine = item->machine();
     630void UISelectorWindow::sltShowMachineInFileManager(const QString &strMachineId /* = QString() */)
     631{
     632    UIVMItem *pItem = strMachineId.isNull() ? m_pVMListView->selectedItem() : m_pVMModel->itemById(strMachineId);
     633    AssertMsgReturnVoid(pItem, ("Item must be always selected here"));
     634
     635    /* Show VM in filebrowser: */
     636    const CMachine &machine = pItem->machine();
    736637    UIDesktopServices::openInFileManager(machine.GetSettingsFilePath());
    737638}
    738639
    739 void VBoxSelectorWnd::sltPerformCreateShortcutAction(const QString &aUuid /* = QString::null */)
    740 {
    741     UIVMItem *item = aUuid.isNull() ? mVMListView->selectedItem() :
    742                        mVMModel->itemById(aUuid);
    743 
    744     AssertMsgReturnVoid(item, ("Item must be always selected here"));
    745 
    746     CMachine machine = item->machine();
    747     UIDesktopServices::createMachineShortcut(machine.GetSettingsFilePath(), QDesktopServices::storageLocation(QDesktopServices::DesktopLocation), machine.GetName(), machine.GetId());
    748 }
    749 
    750 void VBoxSelectorWnd::sltPerformSortAction(const QString &aUuid /* = QString::null */)
    751 {
    752     UIVMItem *item = aUuid.isNull() ? mVMListView->selectedItem() :
    753                        mVMModel->itemById(aUuid);
    754     const QString oldId = item->id();
    755 
    756     AssertMsgReturnVoid(item, ("Item must be always selected here"));
    757 
    758     mVMModel->sortByIdList(QStringList(),
    759                            qApp->keyboardModifiers() == Qt::ShiftModifier ? Qt::DescendingOrder : Qt::AscendingOrder);
     640void UISelectorWindow::sltPerformCreateShortcutAction(const QString &strMachineId /* = QString() */)
     641{
     642    UIVMItem *pItem = strMachineId.isNull() ? m_pVMListView->selectedItem() : m_pVMModel->itemById(strMachineId);
     643    AssertMsgReturnVoid(pItem, ("Item must be always selected here"));
     644
     645    /* Create shortcut for this VM: */
     646    const CMachine &machine = pItem->machine();
     647    UIDesktopServices::createMachineShortcut(machine.GetSettingsFilePath(),
     648                                             QDesktopServices::storageLocation(QDesktopServices::DesktopLocation),
     649                                             machine.GetName(), machine.GetId());
     650}
     651
     652void UISelectorWindow::sltPerformSortAction(const QString &strMachineId /* = QString() */)
     653{
     654    UIVMItem *pItem = strMachineId.isNull() ? m_pVMListView->selectedItem() : m_pVMModel->itemById(strMachineId);
     655    AssertMsgReturnVoid(pItem, ("Item must be always selected here"));
     656
     657    /* Sort VM list: */
     658    const QString strOldId = pItem->id();
     659    m_pVMModel->sortByIdList(QStringList(), qApp->keyboardModifiers() == Qt::ShiftModifier ? Qt::DescendingOrder : Qt::AscendingOrder);
    760660    /* Select the VM which was selected before */
    761     mVMListView->selectItemById(oldId);
    762 }
    763 
    764 void VBoxSelectorWnd::sltMachineMenuAboutToShow()
    765 {
    766     UIVMItem *pItem = mVMListView->selectedItem();
     661    m_pVMListView->selectItemById(strOldId);
     662}
     663
     664void UISelectorWindow::sltMachineMenuAboutToShow()
     665{
     666    UIVMItem *pItem = m_pVMListView->selectedItem();
    767667    AssertMsgReturnVoid(pItem, ("Item must be always selected here"));
    768668
     
    774674}
    775675
    776 void VBoxSelectorWnd::sltMachineCloseMenuAboutToShow()
    777 {
    778     UIVMItem *pItem = mVMListView->selectedItem();
     676void UISelectorWindow::sltMachineCloseMenuAboutToShow()
     677{
     678    UIVMItem *pItem = m_pVMListView->selectedItem();
    779679    AssertMsgReturnVoid(pItem, ("Item must be always selected here"));
    780680
     
    795695}
    796696
    797 void VBoxSelectorWnd::sltMachineContextMenuHovered(QAction *pAction)
    798 {
     697void UISelectorWindow::sltMachineContextMenuHovered(QAction *pAction)
     698{
     699    /* Update statusbar with howered action status text: */
    799700    statusBar()->showMessage(pAction->statusTip());
    800701}
    801702
    802 void VBoxSelectorWnd::refreshVMList()
    803 {
     703void UISelectorWindow::sltRefreshVMList()
     704{
     705    /* Refresh VM list: */
    804706    CVirtualBox vbox = vboxGlobal().virtualBox();
    805     CMachineVector vec = vbox.GetMachines();
    806     for (CMachineVector::ConstIterator m = vec.begin();
    807          m != vec.end(); ++m)
    808         mVMModel->addItem(*m);
     707    CMachineVector machines = vbox.GetMachines();
     708    for (CMachineVector::ConstIterator m = machines.begin(); m != machines.end(); ++m)
     709        m_pVMModel->addItem(*m);
    809710    /* Apply the saved sort order. */
    810     mVMModel->sortByIdList(vbox.GetExtraDataStringList(VBoxDefs::GUI_SelectorVMPositions));
     711    m_pVMModel->sortByIdList(vbox.GetExtraDataStringList(VBoxDefs::GUI_SelectorVMPositions));
    811712    /* Update details page. */
    812     vmListViewCurrentChanged();
    813 
     713    sltCurrentVMItemChanged();
    814714#ifdef VBOX_GUI_WITH_SYSTRAY
    815715    if (vboxGlobal().isTrayMenu())
    816         mTrayIcon->refresh();
    817 #endif
    818 }
    819 
    820 void VBoxSelectorWnd::refreshVMItem(const QString &aID,
    821                                     bool aDetails,
    822                                     bool aSnapshots,
    823                                     bool aDescription)
    824 {
    825     UIVMItem *item = mVMModel->itemById(aID);
    826     if (item)
    827     {
    828         mVMModel->refreshItem(item);
    829         if (item && item->id() == aID)
    830             vmListViewCurrentChanged(aDetails, aSnapshots, aDescription);
    831     }
    832 }
    833 
    834 void VBoxSelectorWnd::showContextMenu(const QPoint &aPoint)
    835 {
    836     const QModelIndex &index = mVMListView->indexAt(aPoint);
    837     if (index.isValid() && mVMListView->model()->data(index, UIVMItemModel::UIVMItemPtrRole).value<UIVMItem*>())
    838     {
    839         /* Show 'Machine' menu as context one: */
    840         m_pMachineContextMenu->exec(mVMListView->mapToGlobal(aPoint));
     716        m_pTrayIcon->refresh();
     717#endif /* VBOX_GUI_WITH_SYSTRAY */
     718}
     719
     720void UISelectorWindow::sltRefreshVMItem(const QString &strMachineId, bool fDetails, bool fSnapshots, bool fDescription)
     721{
     722    /* Refresh VM item: */
     723    UIVMItem *pItem = m_pVMModel->itemById(strMachineId);
     724    if (pItem)
     725    {
     726        m_pVMModel->refreshItem(pItem);
     727        if (pItem && pItem->id() == strMachineId)
     728            sltCurrentVMItemChanged(fDetails, fSnapshots, fDescription);
     729    }
     730}
     731
     732void UISelectorWindow::sltShowContextMenu(const QPoint &point)
     733{
     734    /* Show VM list context menu: */
     735    const QModelIndex &index = m_pVMListView->indexAt(point);
     736    if (index.isValid() && m_pVMListView->model()->data(index, UIVMItemModel::UIVMItemPtrRole).value<UIVMItem*>())
     737    {
     738        m_pMachineContextMenu->exec(m_pVMListView->mapToGlobal(point));
    841739        /* Make sure every status bar hint from the context menu is cleared when the menu is closed: */
    842740        statusBar()->clearMessage();
     
    844742}
    845743
    846 void VBoxSelectorWnd::sltOpenUrls(QList<QUrl> list /* = QList<QUrl>() */)
    847 {
    848     /* Make sure any pending D&D events are consumed. */
    849     qApp->processEvents();
    850     if (list.isEmpty())
    851     {
    852         list = vboxGlobal().argUrlList();
    853         vboxGlobal().argUrlList().clear();
    854     }
    855     /* Check if we are can handle the dropped urls. */
    856     for (int i = 0; i < list.size(); ++i)
    857     {
    858 #ifdef Q_WS_MAC
    859         QString strFile = ::darwinResolveAlias(list.at(i).toLocalFile());
    860 #else /* Q_WS_MAC */
    861         QString strFile = list.at(i).toLocalFile();
    862 #endif /* !Q_WS_MAC */
    863         if (   !strFile.isEmpty()
    864             && QFile::exists(strFile))
    865         {
    866             if (VBoxGlobal::hasAllowedExtension(strFile, VBoxDefs::VBoxFileExts))
    867             {
    868                 /* VBox config files. */
    869                 CVirtualBox vbox = vboxGlobal().virtualBox();
    870                 CMachine machine = vbox.FindMachine(strFile);
    871                 if (!machine.isNull())
    872                 {
    873                     CVirtualBox vbox = vboxGlobal().virtualBox();
    874                     CMachine machine = vbox.FindMachine(strFile);
    875                     if (!machine.isNull())
    876                         vboxGlobal().launchMachine(machine);
    877                 }else
    878                     sltShowAddMachineDialog(strFile);
    879             }
    880             else if (VBoxGlobal::hasAllowedExtension(strFile, VBoxDefs::OVFFileExts))
    881             {
    882                 /* OVF/OVA. Only one file at the time. */
    883                 sltShowImportApplianceWizard(strFile);
    884                 break;
    885             }
    886             else if (VBoxGlobal::hasAllowedExtension(strFile, VBoxDefs::VBoxExtPackFileExts))
    887             {
    888                 UIGlobalSettingsExtension::doInstallation(strFile, this, NULL);
    889             }
    890         }
    891     }
    892 }
    893 
    894 #ifdef VBOX_GUI_WITH_SYSTRAY
    895 
    896 void VBoxSelectorWnd::trayIconActivated(QSystemTrayIcon::ActivationReason aReason)
    897 {
    898     switch (aReason)
    899     {
    900         case QSystemTrayIcon::Context:
    901 
    902             mTrayIcon->refresh();
    903             break;
    904 
    905         case QSystemTrayIcon::Trigger:
    906             break;
    907 
    908         case QSystemTrayIcon::DoubleClick:
    909 
    910             vboxGlobal().trayIconShowSelector();
    911             break;
    912 
    913         case QSystemTrayIcon::MiddleClick:
    914             break;
    915 
    916         default:
    917             break;
    918     }
    919 }
    920 
    921 void VBoxSelectorWnd::showWindow()
    922 {
    923     showNormal();
    924     raise();
    925     activateWindow();
    926 }
    927 
    928 #endif // VBOX_GUI_WITH_SYSTRAY
    929 
    930 // Protected members
    931 /////////////////////////////////////////////////////////////////////////////
    932 
    933 bool VBoxSelectorWnd::event(QEvent *e)
    934 {
    935     switch (e->type())
    936     {
    937         /* By handling every Resize and Move we keep track of the normal
    938          * (non-minimized and non-maximized) window geometry. Shame on Qt
    939          * that it doesn't provide this geometry in its public APIs. */
    940 
    941         case QEvent::Resize:
    942         {
    943             QResizeEvent *re = (QResizeEvent *) e;
    944             if ((windowState() & (Qt::WindowMaximized | Qt::WindowMinimized |
    945                                   Qt::WindowFullScreen)) == 0)
    946                 mNormalGeo.setSize(re->size());
    947             break;
    948         }
    949         case QEvent::Move:
    950         {
    951             if ((windowState() & (Qt::WindowMaximized | Qt::WindowMinimized |
    952                                   Qt::WindowFullScreen)) == 0)
    953                 mNormalGeo.moveTo(geometry().x(), geometry().y());
    954             break;
    955         }
    956         case QEvent::WindowDeactivate:
    957         {
    958             /* Make sure every status bar hint is cleared when the window lost
    959              * focus. */
    960             statusBar()->clearMessage();
    961             break;
    962         }
    963 #ifdef Q_WS_MAC
    964         case QEvent::ContextMenu:
    965         {
    966             /* This is the unified context menu event. Lets show the context
    967              * menu. */
    968             QContextMenuEvent *pCE = static_cast<QContextMenuEvent*>(e);
    969             showViewContextMenu(pCE->globalPos());
    970             /* Accept it to interrupt the chain. */
    971             pCE->accept();
    972             return false;
    973             break;
    974         }
    975         case QEvent::ToolBarChange:
    976         {
    977             CVirtualBox vbox = vboxGlobal().virtualBox();
    978             /* We have to invert the isVisible check one time, cause this event
    979              * is sent *before* the real toggle is done. Really intuitive
    980              * Trolls. */
    981             vbox.SetExtraData(VBoxDefs::GUI_Toolbar, !::darwinIsToolbarVisible(mVMToolBar) ? "true" : "false");
    982             break;
    983         }
    984 #endif /* Q_WS_MAC */
    985         default:
    986             break;
    987     }
    988 
    989     return QMainWindow::event(e);
    990 }
    991 
    992 void VBoxSelectorWnd::closeEvent(QCloseEvent *aEvent)
    993 {
    994 #ifdef VBOX_GUI_WITH_SYSTRAY
    995     /* Needed for breaking out of the while() loop in main(). */
    996     if (vboxGlobal().isTrayMenu())
    997         vboxGlobal().setTrayMenu(false);
    998 #endif
    999 
    1000     emit closing();
    1001     QMainWindow::closeEvent(aEvent);
    1002 }
    1003 
    1004 #ifdef Q_WS_MAC
    1005 bool VBoxSelectorWnd::eventFilter(QObject *pObject, QEvent *pEvent)
    1006 {
    1007     if (!isActiveWindow())
    1008         return QIWithRetranslateUI2<QMainWindow>::eventFilter(pObject, pEvent);
    1009 
    1010     if (qobject_cast<QWidget*>(pObject) &&
    1011         qobject_cast<QWidget*>(pObject)->window() != this)
    1012         return QIWithRetranslateUI2<QMainWindow>::eventFilter(pObject, pEvent);
    1013 
    1014     switch (pEvent->type())
    1015     {
    1016         case QEvent::FileOpen:
    1017         {
    1018             sltOpenUrls(QList<QUrl>() << static_cast<QFileOpenEvent*>(pEvent)->file());
    1019             pEvent->accept();
    1020             return true;
    1021             break;
    1022         }
    1023 # if (QT_VERSION < 0x040402)
    1024         case QEvent::KeyPress:
    1025         {
    1026             /* Bug in Qt below 4.4.2. The key events are send to the current
    1027              * window even if a menu is shown & has the focus. See
    1028              * http://trolltech.com/developer/task-tracker/index_html?method=entry&id=214681. */
    1029             if (::darwinIsMenuOpen())
    1030                 return true;
    1031             break;
    1032         }
    1033 # endif
    1034         default:
    1035             break;
    1036     }
    1037     return QIWithRetranslateUI2<QMainWindow>::eventFilter(pObject, pEvent);
    1038 }
    1039 #endif /* Q_WS_MAC */
    1040 
    1041 /**
    1042  *  Sets the strings of the subwidgets using the current
    1043  *  language.
    1044  */
    1045 void VBoxSelectorWnd::retranslateUi()
    1046 {
    1047     QString title(VBOX_PRODUCT);
    1048     title += " " + tr("Manager", "Note: main window title which is pretended by the product name.");
    1049 
    1050 #ifdef VBOX_BLEEDING_EDGE
    1051     title += QString(" EXPERIMENTAL build ")
    1052           +  QString(RTBldCfgVersion())
    1053           +  QString(" r")
    1054           +  QString(RTBldCfgRevisionStr())
    1055           +  QString(" - "VBOX_BLEEDING_EDGE);
    1056 #endif
    1057 
    1058     setWindowTitle(title);
    1059 
    1060     /* ensure the details and screenshot view are updated */
    1061     vmListViewCurrentChanged();
    1062 
    1063 #ifdef VBOX_GUI_WITH_SYSTRAY
    1064     if (vboxGlobal().isTrayMenu())
    1065     {
    1066         mTrayIcon->retranslateUi();
    1067         mTrayIcon->refresh();
    1068     }
    1069 #endif
    1070 
    1071 #ifdef QT_MAC_USE_COCOA
    1072     /* There is a bug in Qt Cocoa which result in showing a "more arrow" when
    1073        the necessary size of the toolbar is increased. Also for some languages
    1074        the with doesn't match if the text increase. So manually adjust the size
    1075        after changing the text. */
    1076     mVMToolBar->updateLayout();
    1077 #endif /* QT_MAC_USE_COCOA */
    1078 }
    1079 
    1080 
    1081 // Private members
    1082 /////////////////////////////////////////////////////////////////////////////
    1083 
    1084 //
    1085 // Private slots
    1086 /////////////////////////////////////////////////////////////////////////////
    1087 
    1088 void VBoxSelectorWnd::vmListViewCurrentChanged(bool aRefreshDetails,
    1089                                                bool aRefreshSnapshots,
    1090                                                bool aRefreshDescription)
    1091 {
    1092     UIVMItem *item = mVMListView->selectedItem();
     744void UISelectorWindow::sltCurrentVMItemChanged(bool fRefreshDetails, bool fRefreshSnapshots, bool fRefreshDescription)
     745{
     746    UIVMItem *pItem = m_pVMListView->selectedItem();
    1093747    UIActionInterface *pStartOrShowAction = gActionPool->action(UIActionIndexSelector_State_Machine_StartOrShow);
    1094748
    1095     if (item && item->accessible())
    1096     {
    1097         CMachine m = item->machine();
    1098 
    1099         KMachineState state = item->machineState();
    1100         bool fSessionLocked = item->sessionState() != KSessionState_Unlocked;
     749    /* If currently selected VM item is accessible: */
     750    if (pItem && pItem->accessible())
     751    {
     752        CMachine m = pItem->machine();
     753
     754        KMachineState state = pItem->machineState();
     755        bool fSessionLocked = pItem->sessionState() != KSessionState_Unlocked;
    1101756        bool fModifyEnabled = state != KMachineState_Stuck &&
    1102757                              state != KMachineState_Saved /* for now! */;
     
    1105760                              state == KMachineState_LiveSnapshotting;
    1106761        bool fPaused        = state == KMachineState_Paused ||
    1107                               state == KMachineState_TeleportingPausedVM; /** @todo Live Migration: does this make sense? */
    1108 
    1109         if (   aRefreshDetails
    1110             || aRefreshDescription)
    1111             m_pVMDesktop->updateDetails(item, m);
    1112         if (aRefreshSnapshots)
    1113             m_pVMDesktop->updateSnapshots(item, m);
    1114 //        if (aRefreshDescription)
    1115 //            m_pVMDesktop->updateDescription(item, m);
    1116 
    1117         /* enable/disable modify actions */
     762                              state == KMachineState_TeleportingPausedVM;
     763
     764        if (fRefreshDetails || fRefreshDescription)
     765            m_pVMDesktop->updateDetails(pItem, m);
     766        if (fRefreshSnapshots)
     767            m_pVMDesktop->updateSnapshots(pItem, m);
     768//        if (fRefreshDescription)
     769//            m_pVMDesktop->updateDescription(pItem, m);
     770
     771        /* Enable/disable actions: */
    1118772        gActionPool->action(UIActionIndexSelector_Simple_Machine_SettingsDialog)->setEnabled(fModifyEnabled);
    1119773        gActionPool->action(UIActionIndexSelector_Simple_Machine_CloneWizard)->setEnabled(!fSessionLocked);
     
    1125779        gActionPool->action(UIActionIndexSelector_Simple_Machine_Close_PowerOff)->setEnabled(fRunning || fPaused);
    1126780
    1127         /* change the Start button text accordingly */
    1128         if (   state == KMachineState_PoweredOff
    1129             || state == KMachineState_Saved
    1130             || state == KMachineState_Teleported
    1131             || state == KMachineState_Aborted
    1132            )
     781        /* Change the Start button text accordingly: */
     782        if (state == KMachineState_PoweredOff ||
     783            state == KMachineState_Saved ||
     784            state == KMachineState_Teleported ||
     785            state == KMachineState_Aborted)
    1133786        {
    1134787            pStartOrShowAction->setState(1);
     
    1145798        {
    1146799            pStartOrShowAction->setState(2);
    1147             pStartOrShowAction->setEnabled(item->canSwitchTo());
     800            pStartOrShowAction->setEnabled(pItem->canSwitchTo());
    1148801#ifdef QT_MAC_USE_COCOA
    1149802            /* There is a bug in Qt Cocoa which result in showing a "more arrow" when
     
    1170823        gActionPool->action(UIActionIndexSelector_Toggle_Machine_PauseAndResume)->updateAppearance();
    1171824
    1172         /* disable Refresh for accessible machines */
     825        /* Disable Refresh for accessible machines: */
    1173826        gActionPool->action(UIActionIndexSelector_Simple_Machine_Refresh)->setEnabled(false);
    1174827
    1175         /* enable the show log item for the selected vm */
     828        /* Enable the show log item for the selected vm: */
    1176829        gActionPool->action(UIActionIndexSelector_Simple_Machine_LogDialog)->setEnabled(true);
    1177         /* Enable the shell interaction features. */
     830        /* Enable the shell interaction features: */
    1178831        gActionPool->action(UIActionIndexSelector_Simple_Machine_ShowInFileManager)->setEnabled(true);
    1179832#ifdef Q_WS_MAC
    1180833        /* On Mac OS X this are real alias files, which don't work with the old
    1181          * legacy xml files. On the other OS's some kind of start up script is
    1182          * used. */
    1183         gActionPool->action(UIActionIndexSelector_Simple_Machine_CreateShortcut)->setEnabled(item->settingsFile().endsWith(".vbox", Qt::CaseInsensitive));
     834         * legacy xml files. On the other OS's some kind of start up script is used. */
     835        gActionPool->action(UIActionIndexSelector_Simple_Machine_CreateShortcut)->setEnabled(pItem->settingsFile().endsWith(".vbox", Qt::CaseInsensitive));
    1184836#else /* Q_WS_MAC */
    1185837        gActionPool->action(UIActionIndexSelector_Simple_Machine_CreateShortcut)->setEnabled(true);
     
    1187839        gActionPool->action(UIActionIndexSelector_Simple_Machine_Sort)->setEnabled(true);
    1188840    }
     841    /* If currently selected VM item is NOT accessible: */
    1189842    else
    1190843    {
    1191844        /* Note that the machine becomes inaccessible (or if the last VM gets
    1192          * deleted), we have to update all fields, ignoring input
    1193          * arguments. */
    1194 
    1195         if (item)
    1196         {
    1197             /* the VM is inaccessible */
    1198             m_pVMDesktop->updateDetailsErrorText(UIMessageCenter::formatErrorInfo(item->accessError()));
     845         * deleted), we have to update all fields, ignoring input arguments. */
     846        if (pItem)
     847        {
     848            /* The VM is inaccessible */
     849            m_pVMDesktop->updateDetailsErrorText(UIMessageCenter::formatErrorInfo(pItem->accessError()));
    1199850            gActionPool->action(UIActionIndexSelector_Simple_Machine_Refresh)->setEnabled(true);
    1200851        }
    1201852        else
    1202853        {
    1203             /* default HTML support in Qt is terrible so just try to get
    1204              * something really simple */
     854            /* default HTML support in Qt is terrible so just try to get something really simple: */
    1205855            m_pVMDesktop->updateDetailsText(
    1206856                tr("<h3>"
     
    1221871        }
    1222872
    1223         /* empty and disable other tabs */
     873        /* Empty and disable other tabs: */
    1224874        m_pVMDesktop->updateSnapshots(0, CMachine());
    1225875//        m_pVMDesktop->updateDescription(0, CMachine());
     
    1228878        gActionPool->action(UIActionIndexSelector_Simple_Machine_SettingsDialog)->setEnabled(false);
    1229879        gActionPool->action(UIActionIndexSelector_Simple_Machine_CloneWizard)->setEnabled(false);
    1230         gActionPool->action(UIActionIndexSelector_Simple_Machine_RemoveDialog)->setEnabled(item != NULL);
     880        gActionPool->action(UIActionIndexSelector_Simple_Machine_RemoveDialog)->setEnabled(pItem != NULL);
    1231881        gActionPool->action(UIActionIndexSelector_Simple_Machine_Discard)->setEnabled(false);
    1232882        gActionPool->action(UIActionIndexSelector_Toggle_Machine_PauseAndResume)->setEnabled(false);
     
    1249899}
    1250900
    1251 void VBoxSelectorWnd::mediumEnumStarted()
    1252 {
    1253     /* refresh the current details to pick up hard disk sizes */
    1254     vmListViewCurrentChanged(true /* aRefreshDetails */);
    1255 }
    1256 
    1257 void VBoxSelectorWnd::mediumEnumFinished(const VBoxMediaList &list)
    1258 {
    1259     /* refresh the current details to pick up hard disk sizes */
    1260     vmListViewCurrentChanged(true /* aRefreshDetails */);
    1261 
    1262     /* we warn about inaccessible media only once (after media emumeration
     901void UISelectorWindow::sltOpenUrls(QList<QUrl> list /* = QList<QUrl>() */)
     902{
     903    /* Make sure any pending D&D events are consumed. */
     904    qApp->processEvents();
     905    if (list.isEmpty())
     906    {
     907        list = vboxGlobal().argUrlList();
     908        vboxGlobal().argUrlList().clear();
     909    }
     910    /* Check if we are can handle the dropped urls. */
     911    for (int i = 0; i < list.size(); ++i)
     912    {
     913#ifdef Q_WS_MAC
     914        QString strFile = ::darwinResolveAlias(list.at(i).toLocalFile());
     915#else /* Q_WS_MAC */
     916        QString strFile = list.at(i).toLocalFile();
     917#endif /* !Q_WS_MAC */
     918        if (!strFile.isEmpty() && QFile::exists(strFile))
     919        {
     920            if (VBoxGlobal::hasAllowedExtension(strFile, VBoxDefs::VBoxFileExts))
     921            {
     922                /* VBox config files. */
     923                CVirtualBox vbox = vboxGlobal().virtualBox();
     924                CMachine machine = vbox.FindMachine(strFile);
     925                if (!machine.isNull())
     926                {
     927                    CVirtualBox vbox = vboxGlobal().virtualBox();
     928                    CMachine machine = vbox.FindMachine(strFile);
     929                    if (!machine.isNull())
     930                        vboxGlobal().launchMachine(machine);
     931                }
     932                else
     933                    sltShowAddMachineDialog(strFile);
     934            }
     935            else if (VBoxGlobal::hasAllowedExtension(strFile, VBoxDefs::OVFFileExts))
     936            {
     937                /* OVF/OVA. Only one file at the time. */
     938                sltShowImportApplianceWizard(strFile);
     939                break;
     940            }
     941            else if (VBoxGlobal::hasAllowedExtension(strFile, VBoxDefs::VBoxExtPackFileExts))
     942            {
     943                UIGlobalSettingsExtension::doInstallation(strFile, this, NULL);
     944            }
     945        }
     946    }
     947}
     948
     949void UISelectorWindow::sltMachineRegistered(QString strMachineId, bool fRegistered)
     950{
     951    if (fRegistered)
     952    {
     953        CVirtualBox vbox = vboxGlobal().virtualBox();
     954        CMachine m = vbox.FindMachine(strMachineId);
     955        if (!m.isNull())
     956        {
     957            m_pVMModel->addItem(m);
     958            /* Make sure the description, ... pages are properly updated.
     959             * Actually we haven't call the next method, but unfortunately Qt
     960             * seems buggy if the new item is on the same position as the
     961             * previous one. So go on the safe side and call this by our self. */
     962            sltCurrentVMItemChanged();
     963        }
     964        /* m.isNull() is ok (theoretically, the machine could have been
     965         * already deregistered by some other client at this point) */
     966    }
     967    else
     968    {
     969        UIVMItem *pItem = m_pVMModel->itemById(strMachineId);
     970        if (pItem)
     971        {
     972            int iRow = m_pVMModel->rowById(pItem->id());
     973            m_pVMModel->removeItem(pItem);
     974            m_pVMListView->ensureSomeRowSelected(iRow);
     975        }
     976        /* item = 0 is ok (if we originated this event then the item
     977         * has been already removed) */
     978    }
     979}
     980
     981void UISelectorWindow::sltMachineStateChanged(QString strMachineId, KMachineState /* state */)
     982{
     983#ifdef VBOX_GUI_WITH_SYSTRAY
     984    if (vboxGlobal().isTrayMenu())
     985    {
     986        /* Check if there are some machines alive - else quit, since
     987         * we're not needed as a systray menu anymore. */
     988        if (vboxGlobal().mainWindowCount() == 0)
     989        {
     990            sltPerformExit();
     991            return;
     992        }
     993    }
     994#endif /* VBOX_GUI_WITH_SYSTRAY */
     995
     996    sltRefreshVMItem(strMachineId, false /* aDetails */, false /* aSnapshots */, false /* aDescription */);
     997
     998    /* Simulate a state change signal: */
     999//    m_pVMDesktop->updateDescriptionState();
     1000}
     1001
     1002void UISelectorWindow::sltMachineDataChanged(QString strMachineId)
     1003{
     1004    sltRefreshVMItem(strMachineId, true  /* details */, false /* snapshots */, true  /* description */);
     1005}
     1006
     1007void UISelectorWindow::sltSessionStateChanged(QString strMachineId, KSessionState /* state */)
     1008{
     1009    sltRefreshVMItem(strMachineId, true  /* details */, false /* snapshots */, false /* description */);
     1010
     1011//    /* Simulate a state change signal: */
     1012//    m_pVMDesktop->updateDescriptionState();
     1013}
     1014
     1015void UISelectorWindow::sltSnapshotChanged(QString strMachineId, QString /* strSnapshotId */)
     1016{
     1017    sltRefreshVMItem(strMachineId, false /* details */, true  /* snapshot */, false /* description */);
     1018}
     1019
     1020#ifdef VBOX_GUI_WITH_SYSTRAY
     1021void UISelectorWindow::sltMainWindowCountChanged(int iCount)
     1022{
     1023    if (vboxGlobal().isTrayMenu() && count <= 1)
     1024        sltPerformExit();
     1025}
     1026
     1027void UISelectorWindow::sltTrayIconCanShow(bool fEnabled)
     1028{
     1029    emit sltTrayIconChanged(VBoxChangeTrayIconEvent(vboxGlobal().settings().trayIconEnabled()));
     1030}
     1031
     1032void UISelectorWindow::sltTrayIconShow(bool fEnabled)
     1033{
     1034    if (vboxGlobal().isTrayMenu() && m_pTrayIcon)
     1035        m_pTrayIcon->sltTrayIconShow(fEnabled);
     1036}
     1037
     1038void UISelectorWindow::sltTrayIconChanged(bool fEnabled)
     1039{
     1040    /* Not used yet. */
     1041}
     1042
     1043void UISelectorWindow::sltTrayIconActivated(QSystemTrayIcon::ActivationReason reason)
     1044{
     1045    switch (reason)
     1046    {
     1047        case QSystemTrayIcon::Context:
     1048            m_pTrayIcon->refresh();
     1049            break;
     1050
     1051        case QSystemTrayIcon::Trigger:
     1052            break;
     1053
     1054        case QSystemTrayIcon::DoubleClick:
     1055            vboxGlobal().trayIconShowSelector();
     1056            break;
     1057
     1058        case QSystemTrayIcon::MiddleClick:
     1059            break;
     1060
     1061        default:
     1062            break;
     1063    }
     1064}
     1065
     1066void UISelectorWindow::sltShowWindow()
     1067{
     1068    showNormal();
     1069    raise();
     1070    activateWindow();
     1071}
     1072#endif // VBOX_GUI_WITH_SYSTRAY
     1073
     1074void UISelectorWindow::sltMediumEnumerationStarted()
     1075{
     1076    /* Refresh the current details to pick up hard disk sizes: */
     1077    sltCurrentVMItemChanged(true /* fRefreshDetails */);
     1078}
     1079
     1080void UISelectorWindow::sltMediumEnumFinished(const VBoxMediaList &list)
     1081{
     1082    /* Refresh the current details to pick up hard disk sizes */
     1083    sltCurrentVMItemChanged(true /* fRefreshDetails */);
     1084
     1085    /* We warn about inaccessible media only once (after media emumeration
    12631086     * started from main() at startup), to avoid annoying the user */
    1264     if (   mDoneInaccessibleWarningOnce
     1087    if (m_fDoneInaccessibleWarningOnce
    12651088#ifdef VBOX_GUI_WITH_SYSTRAY
    12661089        || vboxGlobal().isTrayMenu()
    1267 #endif
     1090#endif /* VBOX_GUI_WITH_SYSTRAY */
    12681091       )
    12691092        return;
    12701093
    1271     mDoneInaccessibleWarningOnce = true;
     1094    m_fDoneInaccessibleWarningOnce = true;
    12721095
    12731096    do
    12741097    {
    1275         /* ignore the signal if a modal widget is currently active (we won't be
    1276          * able to properly show the modeless VDI manager window in this case) */
     1098        /* Ignore the signal if a modal widget is currently active (we won't be
     1099         * able to properly show the modeless VDI manager window in this case): */
    12771100        if (QApplication::activeModalWidget())
    12781101            break;
    12791102
    1280         /* ignore the signal if a VBoxMediaManagerDlg window is active */
     1103        /* Ignore the signal if a VBoxMediaManagerDlg window is active: */
    12811104        if (qApp->activeWindow() &&
    12821105            !strcmp(qApp->activeWindow()->metaObject()->className(), "VBoxMediaManagerDlg"))
    12831106            break;
    12841107
    1285         /* look for at least one inaccessible media */
     1108        /* Look for at least one inaccessible media: */
    12861109        VBoxMediaList::const_iterator it;
    12871110        for (it = list.begin(); it != list.end(); ++ it)
     
    12911114        if (it != list.end() && msgCenter().remindAboutInaccessibleMedia())
    12921115        {
    1293             /* Show the VDM dialog but don't refresh once more after a
    1294              * just-finished refresh */
     1116            /* Show the VDM dialog but don't refresh once more after a just-finished refresh: */
    12951117            VBoxMediaManagerDlg::showModeless(this, false /* aRefresh */);
    12961118        }
     
    12991121}
    13001122
    1301 void VBoxSelectorWnd::machineStateChanged(QString strId, KMachineState /* state */)
    1302 {
    1303 #ifdef VBOX_GUI_WITH_SYSTRAY
    1304     if (vboxGlobal().isTrayMenu())
    1305     {
    1306         /* Check if there are some machines alive - else quit, since
    1307          * we're not needed as a systray menu anymore. */
    1308         if (vboxGlobal().mainWindowCount() == 0)
    1309         {
    1310             sltPerformExit();
    1311             return;
    1312         }
    1313     }
    1314 #endif
    1315 
    1316     refreshVMItem(strId,
    1317                   false /* aDetails */,
    1318                   false /* aSnapshots */,
    1319                   false /* aDescription */);
    1320 
    1321     /* simulate a state change signal */
    1322 //    m_pVMDesktop->updateDescriptionState();
    1323 }
    1324 
    1325 void VBoxSelectorWnd::machineDataChanged(QString strId)
    1326 {
    1327     refreshVMItem(strId,
    1328                   true  /* aDetails */,
    1329                   false /* aSnapshots */,
    1330                   true  /* aDescription */);
    1331 }
    1332 
    1333 void VBoxSelectorWnd::machineRegistered(QString strId, bool fRegistered)
    1334 {
    1335     if (fRegistered)
    1336     {
    1337         CVirtualBox vbox = vboxGlobal().virtualBox();
    1338         CMachine m = vbox.FindMachine(strId);
    1339         if (!m.isNull())
    1340         {
    1341             mVMModel->addItem(m);
    1342             /* Make sure the description, ... pages are properly updated.
    1343              * Actually we haven't call the next method, but unfortunately Qt
    1344              * seems buggy if the new item is on the same position as the
    1345              * previous one. So go on the safe side and call this by our self. */
    1346             vmListViewCurrentChanged();
    1347         }
    1348         /* m.isNull() is ok (theoretically, the machine could have been
    1349          * already deregistered by some other client at this point) */
    1350     }
    1351     else
    1352     {
    1353         UIVMItem *item = mVMModel->itemById(strId);
    1354         if (item)
    1355         {
    1356             int row = mVMModel->rowById(item->id());
    1357             mVMModel->removeItem(item);
    1358             mVMListView->ensureSomeRowSelected(row);
    1359         }
    1360 
    1361         /* item = 0 is ok (if we originated this event then the item
    1362          * has been already removed) */
    1363     }
    1364 }
    1365 
    1366 void VBoxSelectorWnd::sessionStateChanged(QString strId, KSessionState /* state */)
    1367 {
    1368     refreshVMItem(strId,
    1369                   true  /* aDetails */,
    1370                   false /* aSnapshots */,
    1371                   false /* aDescription */);
    1372 
    1373     /* simulate a state change signal */
    1374 //    m_pVMDesktop->updateDescriptionState();
    1375 }
    1376 
    1377 void VBoxSelectorWnd::snapshotChanged(QString strId, QString /* strSnapshotId */)
    1378 {
    1379     refreshVMItem(strId,
    1380                   false /* aDetails */,
    1381                   true  /* aSnapshot */,
    1382                   false /* aDescription */);
    1383 }
    1384 
    1385 #ifdef VBOX_GUI_WITH_SYSTRAY
    1386 
    1387 void VBoxSelectorWnd::mainWindowCountChanged(int count)
    1388 {
    1389     if (vboxGlobal().isTrayMenu() && count <= 1)
    1390         sltPerformExit();
    1391 }
    1392 
    1393 void VBoxSelectorWnd::trayIconCanShow(bool fEnabled)
    1394 {
    1395     emit trayIconChanged(VBoxChangeTrayIconEvent(vboxGlobal().settings().trayIconEnabled()));
    1396 }
    1397 
    1398 void VBoxSelectorWnd::trayIconShow(bool fEnabled)
    1399 {
    1400     if (vboxGlobal().isTrayMenu() && mTrayIcon)
    1401         mTrayIcon->trayIconShow(fEnabled);
    1402 }
    1403 
    1404 void VBoxSelectorWnd::trayIconChanged(bool fEnabled)
    1405 {
    1406     /* Not used yet. */
    1407 }
    1408 
    1409 #endif /* VBOX_GUI_WITH_SYSTRAY */
    1410 
    1411 void VBoxSelectorWnd::sltEmbedDownloaderForUserManual()
     1123void UISelectorWindow::sltEmbedDownloaderForUserManual()
    14121124{
    14131125    /* If there is User Manual downloader created => show the process bar: */
     
    14161128}
    14171129
    1418 void VBoxSelectorWnd::sltEmbedDownloaderForExtensionPack()
     1130void UISelectorWindow::sltEmbedDownloaderForExtensionPack()
    14191131{
    14201132    /* If there is Extension Pack downloader created => show the process bar: */
     
    14231135}
    14241136
    1425 void VBoxSelectorWnd::showViewContextMenu(const QPoint &pos)
    1426 {
    1427     CVirtualBox vbox = vboxGlobal().virtualBox();
    1428     QString strToolbar = vbox.GetExtraData(VBoxDefs::GUI_Toolbar);
    1429     QString strStatusbar = vbox.GetExtraData(VBoxDefs::GUI_Statusbar);
    1430     bool fToolbar = strToolbar.isEmpty() || strToolbar == "true";
    1431     bool fStatusbar = strStatusbar.isEmpty() || strStatusbar == "true";
    1432 
    1433     QList<QAction*> actions;
    1434     QAction *pShowToolBar = new QAction(tr("Show Toolbar"), 0);
    1435     pShowToolBar->setCheckable(true);
    1436     pShowToolBar->setChecked(fToolbar);
    1437     actions << pShowToolBar;
    1438     QAction *pShowStatusBar = new QAction(tr("Show Statusbar"), 0);
    1439     pShowStatusBar->setCheckable(true);
    1440     pShowStatusBar->setChecked(fStatusbar);
    1441     actions << pShowStatusBar;
    1442 
    1443     QPoint gpos = pos;
    1444     QWidget *pSender = static_cast<QWidget*>(sender());
    1445     if (pSender)
    1446         gpos = pSender->mapToGlobal(pos);
    1447     QAction *pResult = QMenu::exec(actions, gpos);
    1448     if (pResult == pShowToolBar)
    1449     {
    1450         if (pResult->isChecked())
    1451         {
     1137void UISelectorWindow::retranslateUi()
     1138{
     1139    /* Set window title: */
     1140    QString strTitle(VBOX_PRODUCT);
     1141    strTitle += " " + tr("Manager", "Note: main window title which is pretended by the product name.");
     1142#ifdef VBOX_BLEEDING_EDGE
     1143    strTitle += QString(" EXPERIMENTAL build ")
     1144             +  QString(RTBldCfgVersion())
     1145             +  QString(" r")
     1146             +  QString(RTBldCfgRevisionStr())
     1147             +  QString(" - "VBOX_BLEEDING_EDGE);
     1148#endif /* VBOX_BLEEDING_EDGE */
     1149    setWindowTitle(strTitle);
     1150
     1151    /* Ensure the details and screenshot view are updated: */
     1152    sltCurrentVMItemChanged();
     1153
     1154#ifdef VBOX_GUI_WITH_SYSTRAY
     1155    if (vboxGlobal().isTrayMenu())
     1156    {
     1157        m_pTrayIcon->retranslateUi();
     1158        m_pTrayIcon->refresh();
     1159    }
     1160#endif /* VBOX_GUI_WITH_SYSTRAY */
     1161
     1162#ifdef QT_MAC_USE_COCOA
     1163    /* There is a bug in Qt Cocoa which result in showing a "more arrow" when
     1164       the necessary size of the toolbar is increased. Also for some languages
     1165       the with doesn't match if the text increase. So manually adjust the size
     1166       after changing the text. */
     1167    mVMToolBar->updateLayout();
     1168#endif /* QT_MAC_USE_COCOA */
     1169}
     1170
     1171bool UISelectorWindow::event(QEvent *pEvent)
     1172{
     1173    switch (pEvent->type())
     1174    {
     1175        /* By handling every Resize and Move we keep track of the normal
     1176         * (non-minimized and non-maximized) window geometry. Shame on Qt
     1177         * that it doesn't provide this geometry in its public APIs. */
     1178        case QEvent::Resize:
     1179        {
     1180            QResizeEvent *pResizeEvent = (QResizeEvent*) pEvent;
     1181            if ((windowState() & (Qt::WindowMaximized | Qt::WindowMinimized | Qt::WindowFullScreen)) == 0)
     1182                m_normalGeo.setSize(pResizeEvent->size());
     1183            break;
     1184        }
     1185        case QEvent::Move:
     1186        {
     1187            if ((windowState() & (Qt::WindowMaximized | Qt::WindowMinimized | Qt::WindowFullScreen)) == 0)
     1188                m_normalGeo.moveTo(geometry().x(), geometry().y());
     1189            break;
     1190        }
     1191        case QEvent::WindowDeactivate:
     1192        {
     1193            /* Make sure every status bar hint is cleared when the window lost focus. */
     1194            statusBar()->clearMessage();
     1195            break;
     1196        }
    14521197#ifdef Q_WS_MAC
    1453             mVMToolBar->show();
    1454 #else /* Q_WS_MAC */
    1455             m_pBar->show();
    1456 #endif /* !Q_WS_MAC */
    1457             vbox.SetExtraData(VBoxDefs::GUI_Toolbar, "true");
    1458         }
    1459         else
    1460         {
     1198        case QEvent::ContextMenu:
     1199        {
     1200            /* This is the unified context menu event. Lets show the context menu. */
     1201            QContextMenuEvent *pContextMenuEvent = static_cast<QContextMenuEvent*>(pEvent);
     1202            sltShowSelectorContextMenu(pContextMenuEvent->globalPos());
     1203            /* Accept it to interrupt the chain. */
     1204            pContextMenuEvent->accept();
     1205            return false;
     1206            break;
     1207        }
     1208        case QEvent::ToolBarChange:
     1209        {
     1210            CVirtualBox vbox = vboxGlobal().virtualBox();
     1211            /* We have to invert the isVisible check one time, cause this event
     1212             * is sent *before* the real toggle is done. Really intuitive Trolls. */
     1213            vbox.SetExtraData(VBoxDefs::GUI_Toolbar, !::darwinIsToolbarVisible(mVMToolBar) ? "true" : "false");
     1214            break;
     1215        }
     1216#endif /* Q_WS_MAC */
     1217        default:
     1218            break;
     1219    }
     1220
     1221    return QMainWindow::event(pEvent);
     1222}
     1223
     1224void UISelectorWindow::closeEvent(QCloseEvent *pEvent)
     1225{
     1226#ifdef VBOX_GUI_WITH_SYSTRAY
     1227    /* Needed for breaking out of the while() loop in main(). */
     1228    if (vboxGlobal().isTrayMenu())
     1229        vboxGlobal().setTrayMenu(false);
     1230#endif /* VBOX_GUI_WITH_SYSTRAY */
     1231
     1232    emit closing();
     1233    QMainWindow::closeEvent(pEvent);
     1234}
     1235
    14611236#ifdef Q_WS_MAC
    1462             mVMToolBar->hide();
    1463 #else /* Q_WS_MAC */
    1464             m_pBar->hide();
    1465 #endif /* !Q_WS_MAC */
    1466             vbox.SetExtraData(VBoxDefs::GUI_Toolbar, "false");
    1467         }
    1468     }else if (pResult == pShowStatusBar)
    1469     {
    1470         if (pResult->isChecked())
    1471         {
    1472             statusBar()->show();
    1473             vbox.SetExtraData(VBoxDefs::GUI_Statusbar, "true");
    1474         }
    1475         else
    1476         {
    1477             statusBar()->hide();
    1478             vbox.SetExtraData(VBoxDefs::GUI_Statusbar, "false");
    1479         }
    1480     }
    1481 }
    1482 
    1483 void VBoxSelectorWnd::prepareMenuBar()
    1484 {
    1485     /* Prepare 'file' menu: */
     1237bool UISelectorWindow::eventFilter(QObject *pObject, QEvent *pEvent)
     1238{
     1239    if (!isActiveWindow())
     1240        return QIWithRetranslateUI2<QMainWindow>::eventFilter(pObject, pEvent);
     1241
     1242    if (qobject_cast<QWidget*>(pObject) &&
     1243        qobject_cast<QWidget*>(pObject)->window() != this)
     1244        return QIWithRetranslateUI2<QMainWindow>::eventFilter(pObject, pEvent);
     1245
     1246    switch (pEvent->type())
     1247    {
     1248        case QEvent::FileOpen:
     1249        {
     1250            sltOpenUrls(QList<QUrl>() << static_cast<QFileOpenEvent*>(pEvent)->file());
     1251            pEvent->accept();
     1252            return true;
     1253            break;
     1254        }
     1255# if (QT_VERSION < 0x040402)
     1256        case QEvent::KeyPress:
     1257        {
     1258            /* Bug in Qt below 4.4.2. The key events are send to the current
     1259             * window even if a menu is shown & has the focus. See
     1260             * http://trolltech.com/developer/task-tracker/index_html?method=entry&id=214681. */
     1261            if (::darwinIsMenuOpen())
     1262                return true;
     1263            break;
     1264        }
     1265# endif
     1266        default:
     1267            break;
     1268    }
     1269    return QIWithRetranslateUI2<QMainWindow>::eventFilter(pObject, pEvent);
     1270}
     1271#endif /* Q_WS_MAC */
     1272
     1273void UISelectorWindow::prepareIcon()
     1274{
     1275    /* Prepare application icon: */
     1276#if !(defined (Q_WS_WIN) || defined (Q_WS_MAC))
     1277    /* On Win32, it's built-in to the executable.
     1278     * On Mac OS X the icon referenced in info.plist is used. */
     1279    setWindowIcon(QIcon(":/VirtualBox_48px.png"));
     1280#endif
     1281}
     1282
     1283void UISelectorWindow::prepareMenuBar()
     1284{
     1285    /* Prepare 'File' menu: */
    14861286    QMenu *pFileMenu = gActionPool->action(UIActionIndexSelector_Menu_File)->menu();
    14871287    prepareMenuFile(pFileMenu);
    14881288    menuBar()->addMenu(pFileMenu);
    14891289
    1490     /* Prepare 'machine' menu: */
     1290    /* Prepare 'Machine' menu: */
    14911291    QMenu *pMachineMenu = gActionPool->action(UIActionIndexSelector_Menu_Machine)->menu();
    14921292    prepareMenuMachine(pMachineMenu);
     
    14971297#endif /* Q_WS_MAC */
    14981298
    1499     /* Prepare help menu: */
     1299    /* Prepare 'Help' menu: */
    15001300    QMenu *pHelpMenu = gActionPool->action(UIActionIndex_Menu_Help)->menu();
    15011301    prepareMenuHelp(pHelpMenu);
    15021302    menuBar()->addMenu(pHelpMenu);
    15031303
     1304    /* Setup menubar policy: */
    15041305    menuBar()->setContextMenuPolicy(Qt::CustomContextMenu);
    15051306}
    15061307
    1507 void VBoxSelectorWnd::prepareMenuFile(QMenu *pMenu)
     1308void UISelectorWindow::prepareMenuFile(QMenu *pMenu)
    15081309{
    15091310    /* Do not touch if filled already: */
     
    15111312        return;
    15121313
    1513     /* Populate 'file' menu: */
     1314    /* Populate 'File' menu: */
    15141315    pMenu->addAction(gActionPool->action(UIActionIndexSelector_Simple_File_MediumManagerDialog));
    15151316    pMenu->addAction(gActionPool->action(UIActionIndexSelector_Simple_File_ImportApplianceWizard));
     
    15251326}
    15261327
    1527 void VBoxSelectorWnd::prepareMenuMachine(QMenu *pMenu)
     1328void UISelectorWindow::prepareMenuMachine(QMenu *pMenu)
    15281329{
    15291330    /* Do not touch if filled already: */
     
    15311332        return;
    15321333
    1533     /* Populate 'machine' menu: */
     1334    /* Populate 'Machine' menu: */
    15341335    pMenu->addAction(gActionPool->action(UIActionIndexSelector_Simple_Machine_NewWizard));
    15351336    pMenu->addAction(gActionPool->action(UIActionIndexSelector_Simple_Machine_AddDialog));
     
    15561357}
    15571358
    1558 void VBoxSelectorWnd::prepareMenuMachineClose(QMenu *pMenu)
     1359void UISelectorWindow::prepareMenuMachineClose(QMenu *pMenu)
    15591360{
    15601361    /* Do not touch if filled already: */
     
    15621363        return;
    15631364
    1564     /* Populate 'machine/close' menu: */
     1365    /* Populate 'Machine/Close' menu: */
    15651366    pMenu->addAction(gActionPool->action(UIActionIndexSelector_Simple_Machine_Close_ACPIShutdown));
    15661367    pMenu->addAction(gActionPool->action(UIActionIndexSelector_Simple_Machine_Close_PowerOff));
    15671368}
    15681369
    1569 void VBoxSelectorWnd::prepareMenuHelp(QMenu *pMenu)
     1370void UISelectorWindow::prepareMenuHelp(QMenu *pMenu)
    15701371{
    15711372    /* Do not touch if filled already: */
     
    15731374        return;
    15741375
    1575     /* Help submenu: */
     1376    /* Populate 'Help' menu: */
    15761377    pMenu->addAction(gActionPool->action(UIActionIndex_Simple_Help));
    15771378    pMenu->addAction(gActionPool->action(UIActionIndex_Simple_Web));
     
    15961397}
    15971398
    1598 void VBoxSelectorWnd::prepareContextMenu()
     1399void UISelectorWindow::prepareContextMenu()
    15991400{
    16001401    m_pMachineContextMenu = new QMenu(this);
     
    16181419}
    16191420
    1620 void VBoxSelectorWnd::prepareStatusBar()
    1621 {
     1421void UISelectorWindow::prepareStatusBar()
     1422{
     1423    /* Setup statusbar policy: */
    16221424    statusBar()->setContextMenuPolicy(Qt::CustomContextMenu);
    16231425}
    16241426
    1625 void VBoxSelectorWnd::prepareWidgets()
     1427void UISelectorWindow::prepareWidgets()
    16261428{
    16271429    /* Prepare splitter: */
     
    16401442
    16411443    /* Prepare VM list: */
    1642     mVMModel = new UIVMItemModel(this);
    1643     mVMListView = new UIVMListView(mVMModel);
    1644     mVMListView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
     1444    m_pVMModel = new UIVMItemModel(this);
     1445    m_pVMListView = new UIVMListView(m_pVMModel);
     1446    m_pVMListView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    16451447    /* Make non-possible to activate list elements by single click,
    16461448     * this hack should disable the current possibility to do it if present: */
    1647     if (mVMListView->style()->styleHint(QStyle::SH_ItemView_ActivateItemOnSingleClick, 0, mVMListView))
    1648         mVMListView->setStyleSheet("activate-on-singleclick : 0");
     1449    if (m_pVMListView->style()->styleHint(QStyle::SH_ItemView_ActivateItemOnSingleClick, 0, m_pVMListView))
     1450        m_pVMListView->setStyleSheet("activate-on-singleclick : 0");
    16491451
    16501452    /* Prepare details and snapshots tabs: */
     
    16571459    /* Central widget @ horizontal layout: */
    16581460    setCentralWidget(m_pSplitter);
    1659     m_pSplitter->addWidget(mVMListView);
     1461    m_pSplitter->addWidget(m_pVMListView);
    16601462#else /* MAC_LEOPARD_STYLE */
    16611463    QWidget *pLeftWidget = new QWidget(this);
     
    16691471    pLeftVLayout->addWidget(m_pSplitter);
    16701472    setCentralWidget(pLeftWidget);
    1671     m_pSplitter->addWidget(mVMListView);
     1473    m_pSplitter->addWidget(m_pVMListView);
    16721474# else /* BIG_TOOLBAR */
    16731475    pLeftVLayout->addWidget(mVMToolBar);
    1674     pLeftVLayout->addWidget(mVMListView);
     1476    pLeftVLayout->addWidget(m_pVMListView);
    16751477    setCentralWidget(m_pSplitter);
    16761478    m_pSplitter->addWidget(pLeftWidget);
     
    16821484    m_pSplitter->setStretchFactor(0, 2);
    16831485    m_pSplitter->setStretchFactor(1, 3);
    1684 }
    1685 
    1686 void VBoxSelectorWnd::prepareConnections()
     1486
     1487    /* Refresh VM list: */
     1488    sltRefreshVMList();
     1489    /* Reset to the first item: */
     1490    m_pVMListView->selectItemByRow(0);
     1491    /* Bring the VM list to the focus: */
     1492    m_pVMListView->setFocus();
     1493
     1494#ifdef VBOX_GUI_WITH_SYSTRAY
     1495    m_pTrayIcon = new VBoxTrayIcon(this, m_pVMModel);
     1496    Assert(m_pTrayIcon);
     1497#endif /* VBOX_GUI_WITH_SYSTRAY */
     1498}
     1499
     1500void UISelectorWindow::prepareConnections()
    16871501{
    16881502    /* VirtualBox event connections: */
    1689     connect(gVBoxEvents, SIGNAL(sigMachineStateChange(QString, KMachineState)), this, SLOT(machineStateChanged(QString, KMachineState)));
    1690     connect(gVBoxEvents, SIGNAL(sigMachineDataChange(QString)), this, SLOT(machineDataChanged(QString)));
    1691     connect(gVBoxEvents, SIGNAL(sigMachineRegistered(QString, bool)), this, SLOT(machineRegistered(QString, bool)));
    1692     connect(gVBoxEvents, SIGNAL(sigSessionStateChange(QString, KSessionState)), this, SLOT(sessionStateChanged(QString, KSessionState)));
    1693     connect(gVBoxEvents, SIGNAL(sigSnapshotChange(QString, QString)), this, SLOT(snapshotChanged(QString, QString)));
     1503    connect(gVBoxEvents, SIGNAL(sigMachineStateChange(QString, KMachineState)), this, SLOT(sltMachineStateChanged(QString, KMachineState)));
     1504    connect(gVBoxEvents, SIGNAL(sigMachineDataChange(QString)), this, SLOT(sltMachineDataChanged(QString)));
     1505    connect(gVBoxEvents, SIGNAL(sigMachineRegistered(QString, bool)), this, SLOT(sltMachineRegistered(QString, bool)));
     1506    connect(gVBoxEvents, SIGNAL(sigSessionStateChange(QString, KSessionState)), this, SLOT(sltSessionStateChanged(QString, KSessionState)));
     1507    connect(gVBoxEvents, SIGNAL(sigSnapshotChange(QString, QString)), this, SLOT(sltSnapshotChanged(QString, QString)));
    16941508
    16951509    /* Medium enumeration connections: */
    1696     connect(&vboxGlobal(), SIGNAL(mediumEnumStarted()), this, SLOT(mediumEnumStarted()));
    1697     connect(&vboxGlobal(), SIGNAL(mediumEnumFinished(const VBoxMediaList &)), this, SLOT(mediumEnumFinished(const VBoxMediaList &)));
     1510    connect(&vboxGlobal(), SIGNAL(mediumEnumStarted()), this, SLOT(sltMediumEnumerationStarted()));
     1511    connect(&vboxGlobal(), SIGNAL(mediumEnumFinished(const VBoxMediaList &)), this, SLOT(sltMediumEnumFinished(const VBoxMediaList &)));
    16981512
    16991513    /* Downloader connections: */
     
    17021516
    17031517    /* Menu-bar connections: */
    1704     connect(menuBar(), SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(showViewContextMenu(const QPoint&)));
     1518    connect(menuBar(), SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(sltShowSelectorContextMenu(const QPoint&)));
    17051519
    17061520    /* 'File' menu connections: */
     
    17261540            SIGNAL(triggered()), this, SLOT(sltShowMachineSettingsDialog()));
    17271541    connect(gActionPool->action(UIActionIndexSelector_Simple_Machine_CloneWizard),
    1728             SIGNAL(triggered()), this, SLOT(sltShowCloneMachineDialog()));
     1542            SIGNAL(triggered()), this, SLOT(sltShowCloneMachineWizard()));
    17291543    connect(gActionPool->action(UIActionIndexSelector_Simple_Machine_RemoveDialog),
    17301544            SIGNAL(triggered()), this, SLOT(sltShowRemoveMachineDialog()));
     
    17801594    /* Status-bar connections: */
    17811595    connect(statusBar(), SIGNAL(customContextMenuRequested(const QPoint&)),
    1782             this, SLOT(showViewContextMenu(const QPoint&)));
     1596            this, SLOT(sltShowSelectorContextMenu(const QPoint&)));
    17831597
    17841598    /* VM list-view connections: */
    1785     connect(mVMListView, SIGNAL(sigUrlsDropped(QList<QUrl>)), this, SLOT(sltOpenUrls(QList<QUrl>)), Qt::QueuedConnection);
    1786     connect(mVMListView, SIGNAL(currentChanged()), this, SLOT(vmListViewCurrentChanged()));
    1787     connect(mVMListView, SIGNAL(activated()), this, SLOT(sltPerformStartOrShowAction()));
    1788     connect(mVMListView, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(showContextMenu(const QPoint &)));
     1599    connect(m_pVMListView, SIGNAL(sigUrlsDropped(QList<QUrl>)), this, SLOT(sltOpenUrls(QList<QUrl>)), Qt::QueuedConnection);
     1600    connect(m_pVMListView, SIGNAL(currentChanged()), this, SLOT(sltCurrentVMItemChanged()));
     1601    connect(m_pVMListView, SIGNAL(activated()), this, SLOT(sltPerformStartOrShowAction()));
     1602    connect(m_pVMListView, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(sltShowContextMenu(const QPoint &)));
    17891603
    17901604    /* Tool-bar connections: */
    17911605#ifndef Q_WS_MAC
    1792     connect(mVMToolBar, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(showViewContextMenu(const QPoint&)));
     1606    connect(mVMToolBar, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(sltShowSelectorContextMenu(const QPoint&)));
    17931607#else /* !Q_WS_MAC */
    17941608    /* A simple connect doesn't work on the Mac, also we want receive right
     
    18021616#ifdef VBOX_GUI_WITH_SYSTRAY
    18031617    /* Tray icon connections: */
    1804     connect(mTrayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
    1805             this, SLOT(trayIconActivated(QSystemTrayIcon::ActivationReason)));
    1806     connect(gEDataEvents, SIGNAL(sigMainWindowCountChange(int)), this, SLOT(mainWindowCountChanged(int)));
    1807     connect(gEDataEvents, SIGNAL(sigCanShowTrayIcon(bool)), this, SLOT(trayIconCanShow(bool)));
    1808     connect(gEDataEvents, SIGNAL(sigTrayIconChange(bool)), this, SLOT(trayIconChanged(bool)));
    1809     connect(&vboxGlobal(), SIGNAL(sigTrayIconShow(bool)), this, SLOT(trayIconShow(bool)));
     1618    connect(m_pTrayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
     1619            this, SLOT(sltTrayIconActivated(QSystemTrayIcon::ActivationReason)));
     1620    connect(gEDataEvents, SIGNAL(sigMainWindowCountChange(int)), this, SLOT(sltMainWindowCountChanged(int)));
     1621    connect(gEDataEvents, SIGNAL(sigCanShowTrayIcon(bool)), this, SLOT(sltTrayIconCanShow(bool)));
     1622    connect(gEDataEvents, SIGNAL(sigTrayIconChange(bool)), this, SLOT(sltTrayIconChanged(bool)));
     1623    connect(&vboxGlobal(), SIGNAL(sigTrayIconShow(bool)), this, SLOT(sltTrayIconShow(bool)));
    18101624#endif /* VBOX_GUI_WITH_SYSTRAY */
    18111625}
    18121626
     1627void UISelectorWindow::loadSettings()
     1628{
     1629    /* Get VBox object: */
     1630    CVirtualBox vbox = vboxGlobal().virtualBox();
     1631
     1632    /* Restore window position: */
     1633    {
     1634        QString strWinPos = vbox.GetExtraData(VBoxDefs::GUI_LastWindowPosition);
     1635
     1636        bool ok = false, max = false;
     1637        int x = 0, y = 0, w = 0, h = 0;
     1638        x = strWinPos.section(',', 0, 0).toInt(&ok);
     1639        if (ok)
     1640            y = strWinPos.section(',', 1, 1).toInt(&ok);
     1641        if (ok)
     1642            w = strWinPos.section(',', 2, 2).toInt(&ok);
     1643        if (ok)
     1644            h = strWinPos.section(',', 3, 3).toInt(&ok);
     1645        if (ok)
     1646            max = strWinPos.section(',', 4, 4) == VBoxDefs::GUI_LastWindowState_Max;
     1647
     1648        QRect ar = ok ? QApplication::desktop()->availableGeometry(QPoint(x, y)) :
     1649                        QApplication::desktop()->availableGeometry(this);
     1650
     1651        if (ok /* previous parameters were read correctly */
     1652            && (y > 0) && (y < ar.bottom()) /* check vertical bounds */
     1653            && (x + w > ar.left()) && (x < ar.right()) /* & horizontal bounds */)
     1654        {
     1655            m_normalGeo.moveTo(x, y);
     1656            m_normalGeo.setSize(QSize(w, h).expandedTo(minimumSizeHint()).boundedTo(ar.size()));
     1657#if defined(Q_WS_MAC) && (QT_VERSION >= 0x040700)
     1658            move(m_normalGeo.topLeft());
     1659            resize(m_normalGeo.size());
     1660            m_normalGeo = normalGeometry();
     1661#else /* defined(Q_WS_MAC) && (QT_VERSION >= 0x040700) */
     1662            setGeometry(m_normalGeo);
     1663#endif /* !(defined(Q_WS_MAC) && (QT_VERSION >= 0x040700)) */
     1664            if (max) /* maximize if needed */
     1665                showMaximized();
     1666        }
     1667        else
     1668        {
     1669            m_normalGeo.setSize(QSize(770, 550).expandedTo(minimumSizeHint()).boundedTo(ar.size()));
     1670            m_normalGeo.moveCenter(ar.center());
     1671            setGeometry(m_normalGeo);
     1672        }
     1673    }
     1674
     1675    /* Restore selected VM(s): */
     1676    {
     1677        QString strPrevVMId = vbox.GetExtraData(VBoxDefs::GUI_LastVMSelected);
     1678
     1679        m_pVMListView->selectItemById(strPrevVMId);
     1680    }
     1681
     1682    /* Restore splitter handle position: */
     1683    {
     1684        QList<int> sizes = vbox.GetExtraDataIntList(VBoxDefs::GUI_SplitterSizes);
     1685
     1686        if (sizes.size() == 2)
     1687            m_pSplitter->setSizes(sizes);
     1688    }
     1689
     1690    /* Restore toolbar and statusbar visibility: */
     1691    {
     1692        QString strToolbar = vbox.GetExtraData(VBoxDefs::GUI_Toolbar);
     1693        QString strStatusbar = vbox.GetExtraData(VBoxDefs::GUI_Statusbar);
     1694
     1695#ifdef Q_WS_MAC
     1696        mVMToolBar->setVisible(strToolbar.isEmpty() || strToolbar == "true");
     1697#else /* Q_WS_MAC */
     1698        m_pBar->setVisible(strToolbar.isEmpty() || strToolbar == "true");
     1699#endif /* !Q_WS_MAC */
     1700        statusBar()->setVisible(strStatusbar.isEmpty() || strStatusbar == "true");
     1701    }
     1702}
     1703
     1704void UISelectorWindow::saveSettings()
     1705{
     1706    /* Get VBox object: */
     1707    CVirtualBox vbox = vboxGlobal().virtualBox();
     1708
     1709    /* Save window position: */
     1710    {
     1711#if defined(Q_WS_MAC) && (QT_VERSION >= 0x040700)
     1712        QRect frameGeo = frameGeometry();
     1713        QRect save(frameGeo.x(), frameGeo.y(), m_normalGeo.width(), m_normalGeo.height());
     1714#else /* defined(Q_WS_MAC) && (QT_VERSION >= 0x040700) */
     1715        QRect save(m_normalGeo);
     1716#endif /* !(defined(Q_WS_MAC) && (QT_VERSION >= 0x040700)) */
     1717        QString strWinPos = QString("%1,%2,%3,%4").arg(save.x()).arg(save.y()).arg(save.width()).arg(save.height());
     1718#ifdef Q_WS_MAC
     1719        UIWindowMenuManager::destroy();
     1720        ::darwinUnregisterForUnifiedToolbarContextMenuEvents(this);
     1721        if (::darwinIsWindowMaximized(this))
     1722#else /* Q_WS_MAC */
     1723        if (isMaximized())
     1724#endif /* !Q_WS_MAC */
     1725            strWinPos += QString(",%1").arg(VBoxDefs::GUI_LastWindowState_Max);
     1726
     1727        vbox.SetExtraData(VBoxDefs::GUI_LastWindowPosition, strWinPos);
     1728    }
     1729
     1730    /* Save selected VM(s): */
     1731    {
     1732        UIVMItem *pItem = m_pVMListView->selectedItem();
     1733        QString strCurrentVMId = pItem ? QString(pItem->id()) : QString();
     1734        vbox.SetExtraData(VBoxDefs::GUI_LastVMSelected, strCurrentVMId);
     1735        vbox.SetExtraDataStringList(VBoxDefs::GUI_SelectorVMPositions, m_pVMModel->idList());
     1736    }
     1737
     1738    /* Save splitter handle position: */
     1739    {
     1740        vbox.SetExtraDataIntList(VBoxDefs::GUI_SplitterSizes, m_pSplitter->sizes());
     1741    }
     1742}
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UISelectorWindow.h

    r38973 r38977  
    22 *
    33 * VBox frontends: Qt GUI ("VirtualBox"):
    4  * VBoxSelectorWnd class declaration
     4 * UISelectorWindow class declaration
    55 */
    66
    77/*
    8  * Copyright (C) 2006-2010 Oracle Corporation
     8 * Copyright (C) 2006-2011 Oracle Corporation
    99 *
    1010 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    1717 */
    1818
    19 #ifndef __VBoxSelectorWnd_h__
    20 #define __VBoxSelectorWnd_h__
     19#ifndef __UISelectorWindow_h__
     20#define __UISelectorWindow_h__
    2121
    22 /* Local includes */
    23 #include "COMDefs.h"
    24 #include "QIWithRetranslateUI.h"
    25 #include "VBoxGlobal.h"
    26 #include "UIMessageCenter.h"
    27 
    28 /* Global includes */
     22/* Global includes: */
    2923#include <QMainWindow>
    3024#include <QUrl>
     
    3327#endif /* VBOX_GUI_WITH_SYSTRAY */
    3428
    35 /* Local forward declarations */
     29/* Local includes: */
     30#include "QIWithRetranslateUI.h"
     31#include "VBoxMedium.h"
     32#include "COMDefs.h"
     33
     34/* Forward declarations: */
    3635class QISplitter;
    3736class UIMainBar;
     37class UIToolBar;
    3838class UIVMDesktop;
    39 class UIVMItem;
    4039class UIVMItemModel;
    4140class UIVMListView;
    42 class UIToolBar;
     41#ifdef VBOX_GUI_WITH_SYSTRAY
    4342class VBoxTrayIcon;
     43#endif /* VBOX_GUI_WITH_SYSTRAY */
    4444
    45 class VBoxSelectorWnd : public QIWithRetranslateUI2<QMainWindow>
     45/* VM selector window class: */
     46class UISelectorWindow : public QIWithRetranslateUI2<QMainWindow>
    4647{
    4748    Q_OBJECT;
     
    4950public:
    5051
    51     VBoxSelectorWnd(VBoxSelectorWnd **aSelf,
    52                     QWidget* aParent = 0,
    53                     Qt::WindowFlags aFlags = Qt::Window);
    54     virtual ~VBoxSelectorWnd();
     52    /* Constructor/destructor: */
     53    UISelectorWindow(UISelectorWindow **ppSelf,
     54                     QWidget* pParent = 0,
     55                     Qt::WindowFlags flags = Qt::Window);
     56    virtual ~UISelectorWindow();
    5557
    5658signals:
    5759
     60    /* Signal to notify listeners about this dialog closed: */
    5861    void closing();
    5962
    60 public slots:
     63private slots:
    6164
     65    /* Menubar/status bar slots: */
     66    void sltShowSelectorContextMenu(const QPoint &pos);
     67
     68    /* 'File' menu slots: */
    6269    void sltShowMediumManager();
    63     void sltShowImportApplianceWizard(const QString &strFile = "");
     70    void sltShowImportApplianceWizard(const QString &strFileName = QString());
    6471    void sltShowExportApplianceWizard();
    6572    void sltShowPreferencesDialog();
    6673    void sltPerformExit();
    6774
     75    /* 'Machine' menu slots: */
    6876    void sltShowNewMachineWizard();
    69     void sltShowAddMachineDialog(const QString &strFile = "");
    70     void sltShowMachineSettingsDialog(const QString &aCategory = QString::null, const QString &aControl = QString::null, const QString & = QString::null);
    71     void sltShowCloneMachineDialog(const QString & = QString::null);
    72     void sltShowRemoveMachineDialog(const QString & = QString::null);
    73     void sltPerformStartOrShowAction(const QString & = QString::null);
    74     void sltPerformDiscardAction(const QString & = QString::null);
    75     void sltPerformPauseResumeAction(bool, const QString & = QString::null);
    76     void sltPerformResetAction(const QString & = QString::null);
    77     void sltPerformACPIShutdownAction(const QString &aUuid = QString::null);
    78     void sltPerformPowerOffAction(const QString &aUuid = QString::null);
    79     void sltPerformRefreshAction(const QString & = QString::null);
    80     void sltShowLogDialog(const QString & = QString::null);
    81     void sltShowMachineInFileManager(const QString &aUuid = QString::null);
    82     void sltPerformCreateShortcutAction(const QString &aUuid = QString::null);
    83     void sltPerformSortAction(const QString &aUuid = QString::null);
     77    void sltShowAddMachineDialog(const QString &strFileName = QString());
     78    void sltShowMachineSettingsDialog(const QString &strCategory = QString(),
     79                                      const QString &strControl = QString(),
     80                                      const QString &strMachineId = QString());
     81    void sltShowCloneMachineWizard(const QString &strMachineId = QString());
     82    void sltShowRemoveMachineDialog(const QString &strMachineId = QString());
     83    void sltPerformStartOrShowAction(const QString &strMachineId = QString());
     84    void sltPerformDiscardAction(const QString &strMachineId = QString());
     85    void sltPerformPauseResumeAction(bool fPause, const QString &strMachineId = QString());
     86    void sltPerformResetAction(const QString &strMachineId = QString());
     87    void sltPerformACPIShutdownAction(const QString &strMachineId = QString());
     88    void sltPerformPowerOffAction(const QString &strMachineId = QString());
     89    void sltPerformRefreshAction(const QString &strMachineId = QString());
     90    void sltShowLogDialog(const QString &strMachineId = QString());
     91    void sltShowMachineInFileManager(const QString &strMachineId = QString());
     92    void sltPerformCreateShortcutAction(const QString &strMachineId = QString());
     93    void sltPerformSortAction(const QString &strMachineId = QString());
    8494    void sltMachineMenuAboutToShow();
    8595    void sltMachineCloseMenuAboutToShow();
    8696    void sltMachineContextMenuHovered(QAction *pAction);
    8797
    88     void refreshVMList();
    89     void refreshVMItem(const QString &aID, bool aDetails, bool aSnapshots, bool aDescription);
    90 
    91     void showContextMenu(const QPoint &aPoint);
    92 
     98    /* VM list slots: */
     99    void sltRefreshVMList();
     100    void sltRefreshVMItem(const QString &strMachineId, bool fDetails, bool fSnapshots, bool fDescription);
     101    void sltShowContextMenu(const QPoint &point);
     102    void sltCurrentVMItemChanged(bool fRefreshDetails = true, bool fRefreshSnapshots = true, bool fRefreshDescription = true);
    93103    void sltOpenUrls(QList<QUrl> list = QList<QUrl>());
    94104
     105    /* VirtualBox callback events we're interested in: */
     106    void sltMachineRegistered(QString strID, bool fRegistered);
     107    void sltMachineStateChanged(QString strId, KMachineState state);
     108    void sltMachineDataChanged(QString strId);
     109    void sltSessionStateChanged(QString strId, KSessionState state);
     110    void sltSnapshotChanged(QString strId, QString strSnapshotId);
    95111#ifdef VBOX_GUI_WITH_SYSTRAY
    96     void trayIconActivated(QSystemTrayIcon::ActivationReason aReason);
    97     void showWindow();
    98 #endif
     112    /* Sys tray related event handlers: */
     113    void sltMainWindowCountChanged(int count);
     114    void sltTrayIconCanShow(bool fEnabled);
     115    void sltTrayIconShow(bool fEnabled);
     116    void sltTrayIconChanged(bool fEnabled);
     117    /* Sys tray related slots: */
     118    void sltTrayIconActivated(QSystemTrayIcon::ActivationReason aReason);
     119    void sltShowWindow();
     120#endif /* VBOX_GUI_WITH_SYSTRAY */
    99121
    100 protected:
     122    /* Medium enumeration related slots: */
     123    void sltMediumEnumerationStarted();
     124    void sltMediumEnumFinished(const VBoxMediaList &mediumList);
    101125
    102     /* Events */
    103     bool event(QEvent *aEvent);
    104     void closeEvent(QCloseEvent *aEvent);
     126    /* Downloader related slots: */
     127    void sltEmbedDownloaderForUserManual();
     128    void sltEmbedDownloaderForExtensionPack();
     129
     130private:
     131
     132    /* Translation stuff: */
     133    void retranslateUi();
     134
     135    /* Event handlers: */
     136    bool event(QEvent *pEvent);
     137    void closeEvent(QCloseEvent *pEvent);
    105138#ifdef Q_WS_MAC
    106139    bool eventFilter(QObject *pObject, QEvent *pEvent);
    107140#endif /* Q_WS_MAC */
    108141
    109     void retranslateUi();
    110 
    111 private slots:
    112 
    113     void vmListViewCurrentChanged(bool aRefreshDetails = true, bool aRefreshSnapshots = true, bool aRefreshDescription = true);
    114     void mediumEnumStarted();
    115     void mediumEnumFinished(const VBoxMediaList &);
    116 
    117     /* VirtualBox callback events we're interested in */
    118 
    119     void machineStateChanged(QString strId, KMachineState state);
    120     void machineDataChanged(QString strId);
    121     void machineRegistered(QString strID, bool fRegistered);
    122     void sessionStateChanged(QString strId, KSessionState state);
    123     void snapshotChanged(QString strId, QString strSnapshotId);
    124 #ifdef VBOX_GUI_WITH_SYSTRAY
    125     void mainWindowCountChanged(int count);
    126     void trayIconCanShow(bool fEnabled);
    127     void trayIconShow(bool fEnabled);
    128     void trayIconChanged(bool fEnabled);
    129 #endif
    130 
    131     void sltEmbedDownloaderForUserManual();
    132     void sltEmbedDownloaderForExtensionPack();
    133 
    134     void showViewContextMenu(const QPoint &pos);
    135 
    136 private:
    137 
    138142    /* Helping stuff: */
     143    void prepareIcon();
    139144    void prepareMenuBar();
    140145    void prepareMenuFile(QMenu *pMenu);
     
    146151    void prepareWidgets();
    147152    void prepareConnections();
     153    void loadSettings();
     154    void saveSettings();
    148155
    149     /* Central splitter window */
     156    /* Central splitter window: */
    150157    QISplitter *m_pSplitter;
    151158
    152     /* Main toolbar */
     159    /* Main toolbar: */
    153160#ifndef Q_WS_MAC
    154161    UIMainBar *m_pBar;
     
    156163    UIToolBar *mVMToolBar;
    157164
    158     /* VM list context menu */
     165    /* VM list view: */
     166    UIVMListView *m_pVMListView;
     167    /* VM list model: */
     168    UIVMItemModel *m_pVMModel;
     169    /* VM list context menu: */
    159170    QMenu *m_pMachineContextMenu;
    160171
    161 #ifdef VBOX_GUI_WITH_SYSTRAY
    162     /* The systray icon */
    163     VBoxTrayIcon *mTrayIcon;
    164 #endif
    165 
    166     /* The vm list view/model */
    167     UIVMListView *mVMListView;
    168     UIVMItemModel *mVMModel;
    169 
    170     /* The right information widgets */
     172    /* VM details widget: */
    171173    UIVMDesktop *m_pVMDesktop;
    172174
    173     QRect mNormalGeo;
    174 
    175     bool mDoneInaccessibleWarningOnce : 1;
     175    /* Other variables: */
     176    QRect m_normalGeo;
     177    bool m_fDoneInaccessibleWarningOnce : 1;
     178#ifdef VBOX_GUI_WITH_SYSTRAY
     179    /* The systray icon: */
     180    VBoxTrayIcon *m_pTrayIcon;
     181#endif /* VBOX_GUI_WITH_SYSTRAY */
    176182};
    177183
    178 #endif // __VBoxSelectorWnd_h__
     184#endif // __UISelectorWindow_h__
    179185
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UIVMListView.cpp

    r38800 r38977  
    2525#include "UIVMListView.h"
    2626#include "UIMessageCenter.h"
    27 #include "VBoxSelectorWnd.h"
    2827
    2928/* Global includes */
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UIVMListView.h

    r38800 r38977  
    4545    UIVMItemModel(QObject *aParent = 0)
    4646        :QAbstractListModel(aParent) {}
     47    ~UIVMItemModel() { clear(); }
    4748
    4849    void addItem(const CMachine &machine);
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/VBoxTrayIcon.cpp

    r32758 r38977  
    1919/* Local includes */
    2020#include "VBoxTrayIcon.h"
    21 #include "VBoxSelectorWnd.h"
     21#include "UISelectorWindow.h"
    2222#include "UIIconPool.h"
    2323#include "UIVMItem.h"
     
    2828#include <QAction>
    2929
    30 VBoxTrayIcon::VBoxTrayIcon (VBoxSelectorWnd* aParent, UIVMItemModel* aVMModel)
     30VBoxTrayIcon::VBoxTrayIcon (UISelectorWindow* aParent, UIVMItemModel* aVMModel)
    3131{
    3232    mParent = aParent;
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/VBoxTrayIcon.h

    r32758 r38977  
    2626
    2727/* Local forward declarations */
    28 class VBoxSelectorWnd;
     28class UISelectorWindow;
    2929class UIVMItem;
    3030class UIVMItemModel;
     
    4040public:
    4141
    42     VBoxTrayIcon (VBoxSelectorWnd* aParent, UIVMItemModel* aVMModel);
     42    VBoxTrayIcon (UISelectorWindow* aParent, UIVMItemModel* aVMModel);
    4343    virtual ~VBoxTrayIcon ();
    4444
     
    7474    UIVMItemModel *mVMModel;
    7575
    76     VBoxSelectorWnd* mParent;
     76    UISelectorWindow* mParent;
    7777    QMenu *mTrayIconMenu;
    7878
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsExtension.cpp

    r38311 r38977  
    108108 * Attempt the actual installation.
    109109 *
    110  * This code is shared by UIGlobalSettingsExtension::sltInstallPackage and
    111  * VBoxSelectorWnd::sltOpenUrls.
     110 * This code is shared by UIGlobalSettingsExtension::sltInstallPackage and UISelectorWindow::sltOpenUrls.
    112111 *
    113112 * @param   strFilePath     The path to the tarball.
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette