UISelectorWindow.cpp revision 8d8dfc00d014a62894327907a04f148b00a08529
/** @file
*
* VBox frontends: Qt GUI ("VirtualBox"):
* UISelectorWindow class implementation
*/
/*
* Copyright (C) 2006-2011 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*/
# include "precomp.h"
#else /* !VBOX_WITH_PRECOMPILED_HEADERS */
/* Global includes */
#include <QDesktopWidget>
#include <QMenuBar>
#include <QResizeEvent>
#include <QDesktopServices>
/* Local includes: */
#include "QISplitter.h"
#include "UIBar.h"
#include "UINetworkManager.h"
#include "UIUpdateManager.h"
#include "UIDownloaderUserManual.h"
#include "UIDownloaderExtensionPack.h"
#include "UIIconPool.h"
#include "UIWizardNewVM.h"
#include "UIWizardCloneVM.h"
#include "UIWizardExportApp.h"
#include "UIWizardImportApp.h"
#include "UIVMDesktop.h"
#include "UIVMListView.h"
#include "UIVirtualBoxEventHandler.h"
#include "VBoxGlobal.h"
#include "VBoxMediaManagerDlg.h"
#include "UIMessageCenter.h"
#include "UISelectorWindow.h"
#include "UISettingsDialogSpecific.h"
#include "UIToolBar.h"
#include "UIVMLogViewer.h"
#include "QIFileDialog.h"
#include "UISelectorShortcuts.h"
#include "UIDesktopServices.h"
#include "UIGlobalSettingsExtension.h"
#include "UIActionPoolSelector.h"
#ifdef VBOX_GUI_WITH_SYSTRAY
# include "VBoxTrayIcon.h"
# include "UIExtraDataEventHandler.h"
#endif /* VBOX_GUI_WITH_SYSTRAY */
#ifdef Q_WS_MAC
# include "VBoxUtils.h"
# include "UIWindowMenuManager.h"
# include "UIImageTools.h"
#endif /* Q_WS_MAC */
#ifdef Q_WS_X11
#endif /* Q_WS_X11 */
#include <iprt/buildconfig.h>
#endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
, m_pSplitter(0)
#ifndef Q_WS_MAC
, m_pBar(0)
#endif /* !Q_WS_MAC */
, mVMToolBar(0)
, m_pVMListView(0)
, m_pVMModel(0)
, m_pVMDesktop(0)
, m_fDoneInaccessibleWarningOnce(false)
{
/* Remember self: */
if (ppSelf)
*ppSelf = this;
/* Prepare everything: */
prepareIcon();
/* Load all settings: */
loadSettings();
/* Translate UI: */
#ifdef Q_WS_MAC
# if MAC_LEOPARD_STYLE
/* Enable unified toolbars on Mac OS X. Available on Qt >= 4.3.
* includes the toolbar height in the content height. */
# endif /* MAC_LEOPARD_STYLE */
/* Beta label? */
if (vboxGlobal().isBeta())
{
::darwinLabelWindow(this, &betaLabel, false);
}
/* General event filter: */
qApp->installEventFilter(this);
#endif /* Q_WS_MAC */
}
{
/* Destroy our event handlers: */
/* Save all settings: */
saveSettings();
#ifdef VBOX_GUI_WITH_SYSTRAY
/* Delete systray menu object: */
delete m_pTrayIcon;
m_pTrayIcon = NULL;
#endif /* VBOX_GUI_WITH_SYSTRAY */
}
{
pShowToolBar->setCheckable(true);
actions << pShowToolBar;
pShowStatusBar->setCheckable(true);
if (pSender)
if (pResult == pShowToolBar)
{
{
#ifdef Q_WS_MAC
mVMToolBar->show();
#else /* Q_WS_MAC */
#endif /* !Q_WS_MAC */
}
else
{
#ifdef Q_WS_MAC
mVMToolBar->hide();
#else /* Q_WS_MAC */
#endif /* !Q_WS_MAC */
}
}
else if (pResult == pShowStatusBar)
{
{
}
else
{
}
}
}
void UISelectorWindow::sltShowMediumManager()
{
/* Show modeless Virtual Medium Manager: */
VBoxMediaManagerDlg::showModeless(this);
}
{
/* Show Import Appliance wizard: */
#ifdef Q_WS_MAC
#else /* Q_WS_MAC */
#endif /* !Q_WS_MAC */
}
{
/* Get selected items: */
/* Populate the list of VM names: */
/* Show Export Appliance wizard: */
}
{
/* Check that we do NOT handling that already: */
return;
/* Remember that we handling that already: */
m_pPreferencesDialogAction->setData(true);
/* Create and execute global settings dialog: */
UISettingsDialogGlobal dialog(this);
/* Remember that we do NOT handling that already: */
m_pPreferencesDialogAction->setData(false);
}
void UISelectorWindow::sltPerformExit()
{
/* We have to check if there are any open windows beside this mainwindow
* (e.g. VDM) and if so close them. Note that the default behavior is
* different to Qt3 where a *mainWidget* exists & if this going to close
* all other windows are closed automatically. We do the same below. */
{
}
/* We close this pWidget last: */
close();
}
{
/* Show New VM wizard: */
UIWizardNewVM wizard(this);
}
{
/* Initialize variables: */
#ifdef Q_WS_MAC
#else /* Q_WS_MAC */
#endif /* !Q_WS_MAC */
if (strTmpFile.isEmpty())
{
/* Create open file dialog: */
QStringList fileNames = QIFileDialog::getOpenFileNames(strBaseFolder, strFilter, this, strTitle, 0, true, true);
}
/* Open corresponding machine: */
if (!strTmpFile.isEmpty())
{
/* First we should test what machine was opened: */
{
/* Second we should check what such machine was NOT already registered.
* Actually current Main implementation will even prevent such machine opening
* but we will perform such a check anyway: */
if (oldMachine.isNull())
{
/* Register that machine: */
}
else
}
else
}
}
void UISelectorWindow::sltShowMachineSettingsDialog(const QString &strCategoryRef /* = QString() */,
{
/* Check that we do NOT handling that already: */
return;
/* Remember that we handling that already: */
m_pSettingsDialogAction->setData(true);
/* Process href from VM details / description: */
{
return;
}
/* Get category and control: */
/* Check if control is coded into the URL by %%: */
if (strControl.isEmpty())
{
{
}
}
/* Don't show the inaccessible warning if the user tries to open VM settings: */
m_fDoneInaccessibleWarningOnce = true;
/* Get corresponding VM item: */
UIVMItem *pItem = strMachineId.isNull() ? m_pVMListView->currentItem() : m_pVMModel->itemById(strMachineId);
/* Create and execute corresponding VM settings dialog: */
/* Remember that we do NOT handling that already: */
m_pSettingsDialogAction->setData(false);
}
{
/* Get current item: */
/* Show Clone VM wizard: */
}
{
/* Get selected items: */
/* Populate machine list: */
/* Show machine remove dialog: */
{
/* For every selected item: */
{
/* Check if current item could be removed: */
continue;
/* Get iterated VM: */
{
/* Unregister and cleanup machine's data & hard-disks: */
{
/* Delete machine hard-disks: */
{
msgCenter().showModalProgressDialog(progress, machine.GetName(), ":/progress_delete_90px.png", 0, true);
if (progress.GetResultCode() != 0)
}
}
}
else
{
/* Just unregister machine: */
}
}
}
}
{
/* We always get here when m_pVMListView emits the activated() signal,
* so we must explicitly check if the action is enabled or not. */
if (!m_pStartOrShowAction->isEnabled())
return;
/* Get selected items: */
/* For every selected item: */
{
continue;
/* Get iterated VM: */
}
}
{
/* Get current item: */
/* Confirm discarding current VM saved state: */
return;
/* Open a session to modify VM: */
{
return;
}
/* Get session console: */
/* Unlock machine finally: */
}
{
/* Get selected items: */
/* For every selected item: */
{
/* Get iterated item: */
/* Get item state: */
continue;
/* Check if current item already paused: */
if (fPause &&
continue;
/* Check if current item already resumed: */
if (!fPause &&
(state == KMachineState_Running || state == KMachineState_Teleporting || state == KMachineState_LiveSnapshotting))
continue;
/* Open a session to modify VM state: */
{
return;
}
/* Get session console: */
if (fPause)
else
if (!ok)
{
if (fPause)
else
}
/* Unlock machine finally: */
}
}
{
/* Confirm reseting VM: */
if (!msgCenter().confirmVMReset(this))
return;
/* Get selected items: */
/* For each selected item: */
{
/* Get iterated item: */
/* Check if current item could be reseted: */
continue;
/* Open a session to modify VM state: */
{
return;
}
/* Get session console: */
/* Reset VM: */
/* Unlock machine finally: */
}
}
{
/* Confirm ACPI shutdown current VM: */
if (!msgCenter().confirmVMACPIShutdown(this))
return;
/* Get selected items: */
/* For each selected item: */
{
/* Get iterated item: */
/* Check if current item could be shutdowned: */
continue;
/* Open a session to modify VM state: */
{
return;
}
/* Get session console: */
/* ACPI Shutdown: */
/* Unlock machine finally: */
}
}
{
/* Confirm Power Off current VM: */
if (!msgCenter().confirmVMPowerOff(this))
return;
/* Get selected items: */
/* For each selected item: */
{
/* Get iterated item: */
/* Check if current item could be powered off: */
continue;
/* Open a session to modify VM state: */
{
return;
}
/* Get session console: */
/* Power Off: */
/* Unlock machine finally: */
}
}
{
/* Get selected items: */
/* For each selected item: */
{
/* Get iterated item: */
/* Check if current item could be refreshed: */
continue;
/* Refresh currently selected VM item: */
}
}
void UISelectorWindow::sltShowLogDialog()
{
/* Get selected items: */
/* For each selected item: */
{
/* Get iterated item: */
/* Check if log could be show for the current item: */
continue;
/* Show VM Log Viewer: */
}
}
{
/* Get selected items: */
/* For each selected item: */
{
/* Get iterated item: */
/* Check if that item could be shown in file-browser: */
continue;
/* Show VM in filebrowser: */
}
}
{
/* Get selected items: */
/* For each selected item: */
{
/* Get iterated item: */
/* Check if shortcuts could be created for this item: */
continue;
/* Create shortcut for this VM: */
}
}
void UISelectorWindow::sltPerformSortAction()
{
/* Get current item: */
/* Sort VM list: */
m_pVMModel->sortByIdList(QStringList(), qApp->keyboardModifiers() == Qt::ShiftModifier ? Qt::DescendingOrder : Qt::AscendingOrder);
/* Select the VM which was selected before */
}
{
/* Get current item: */
/* Get selected items: */
m_pMachineCloseMenuAction->setEnabled(isActionEnabled(UIActionIndexSelector_Menu_Machine_Close, pItem, items));
}
{
/* Get current item: */
/* Get selected items: */
m_pACPIShutdownAction->setEnabled(isActionEnabled(UIActionIndexSelector_Simple_Machine_Close_ACPIShutdown, pItem, items));
}
{
/* Update statusbar with howered action status text: */
}
void UISelectorWindow::sltRefreshVMList()
{
/* Refresh VM list: */
m_pVMModel->addItem(*m);
/* Apply the saved sort order. */
/* Update details page. */
#ifdef VBOX_GUI_WITH_SYSTRAY
if (vboxGlobal().isTrayMenu())
m_pTrayIcon->refresh();
#endif /* VBOX_GUI_WITH_SYSTRAY */
}
void UISelectorWindow::sltRefreshVMItem(const QString &strMachineId, bool fDetails, bool fSnapshots, bool fDescription)
{
/* Refresh VM item: */
if (pItem)
{
}
}
{
/* Show VM list context menu: */
if (index.isValid() && m_pVMListView->model()->data(index, UIVMItemModel::UIVMItemPtrRole).value<UIVMItem*>())
{
/* Make sure every status bar hint from the context menu is cleared when the menu is closed: */
statusBar()->clearMessage();
}
}
void UISelectorWindow::sltCurrentVMItemChanged(bool fRefreshDetails, bool fRefreshSnapshots, bool fRefreshDescription)
{
/* Get current item: */
m_pSettingsDialogAction->setEnabled(isActionEnabled(UIActionIndexSelector_Simple_Machine_SettingsDialog, pItem, items));
m_pCloneWizardAction->setEnabled(isActionEnabled(UIActionIndexSelector_Simple_Machine_CloneWizard, pItem, items));
m_pRemoveDialogAction->setEnabled(isActionEnabled(UIActionIndexSelector_Simple_Machine_RemoveDialog, pItem, items));
m_pStartOrShowAction->setEnabled(isActionEnabled(UIActionIndexSelector_State_Machine_StartOrShow, pItem, items));
m_pDiscardAction->setEnabled(isActionEnabled(UIActionIndexSelector_Simple_Machine_Discard, pItem, items));
m_pPauseAndResumeAction->setEnabled(isActionEnabled(UIActionIndexSelector_Toggle_Machine_PauseAndResume, pItem, items));
m_pResetAction->setEnabled(isActionEnabled(UIActionIndexSelector_Simple_Machine_Reset, pItem, items));
m_pACPIShutdownAction->setEnabled(isActionEnabled(UIActionIndexSelector_Simple_Machine_Close_ACPIShutdown, pItem, items));
m_pPowerOffAction->setEnabled(isActionEnabled(UIActionIndexSelector_Simple_Machine_Close_PowerOff, pItem, items));
m_pRefreshAction->setEnabled(isActionEnabled(UIActionIndexSelector_Simple_Machine_Refresh, pItem, items));
m_pLogDialogAction->setEnabled(isActionEnabled(UIActionIndexSelector_Simple_Machine_LogDialog, pItem, items));
m_pShowInFileManagerAction->setEnabled(isActionEnabled(UIActionIndexSelector_Simple_Machine_ShowInFileManager, pItem, items));
m_pCreateShortcutAction->setEnabled(isActionEnabled(UIActionIndexSelector_Simple_Machine_CreateShortcut, pItem, items));
m_pSortAction->setEnabled(isActionEnabled(UIActionIndexSelector_Simple_Machine_Sort, pItem, items));
/* If currently selected VM item is accessible: */
{
if (fRefreshDetails || fRefreshDescription)
if (fRefreshSnapshots)
/* Update the Start button action appearance: */
if (state == KMachineState_PoweredOff ||
state == KMachineState_Saved ||
{
#ifdef QT_MAC_USE_COCOA
/* There is a bug in Qt Cocoa which result in showing a "more arrow" when
the necessary size of the toolbar is increased. Also for some languages
the with doesn't match if the text increase. So manually adjust the size
after changing the text. */
#endif /* QT_MAC_USE_COCOA */
}
else
{
#ifdef QT_MAC_USE_COCOA
/* There is a bug in Qt Cocoa which result in showing a "more arrow" when
the necessary size of the toolbar is increased. Also for some languages
the with doesn't match if the text increase. So manually adjust the size
after changing the text. */
#endif /* QT_MAC_USE_COCOA */
}
if (state == KMachineState_Paused ||
{
m_pPauseAndResumeAction->blockSignals(true);
m_pPauseAndResumeAction->setChecked(true);
m_pPauseAndResumeAction->blockSignals(false);
}
else
{
m_pPauseAndResumeAction->blockSignals(true);
m_pPauseAndResumeAction->setChecked(false);
m_pPauseAndResumeAction->blockSignals(false);
}
}
/* If currently selected VM item is NOT accessible: */
else
{
/* Note that the machine becomes inaccessible (or if the last VM gets
* deleted), we have to update all fields, ignoring input arguments. */
if (pItem)
{
/* The VM is inaccessible: */
}
else
{
/* Default HTML support in Qt is terrible so just try to get something really simple: */
tr("<h3>Welcome to VirtualBox!</h3>"
"<p>The left part of this window is "
"a list of all virtual machines on your computer. "
"The list is empty now because you haven't created any virtual "
"machines yet."
"<img src=:/welcome.png align=right/></p>"
"<p>In order to create a new virtual machine, press the "
"<b>New</b> button in the main tool bar located "
"at the top of the window.</p>"
"<p>You can press the <b>%1</b> key to get instant help, "
"or visit "
"<a href=http://www.virtualbox.org>www.virtualbox.org</a> "
"for the latest information and news.</p>")
}
/* Empty and disable other tabs: */
/* Change the Start button text accordingly: */
}
}
{
/* Make sure any pending D&D events are consumed. */
qApp->processEvents();
{
}
/* Check if we are can handle the dropped urls. */
{
#ifdef Q_WS_MAC
#else /* Q_WS_MAC */
#endif /* !Q_WS_MAC */
{
{
/* VBox config files. */
{
}
else
}
{
break;
}
{
}
}
}
}
{
if (fRegistered)
{
if (!m.isNull())
{
m_pVMModel->addItem(m);
}
/* m.isNull() is ok (theoretically, the machine could have been
* already deregistered by some other client at this point) */
}
else
{
if (pItem)
{
}
/* item = 0 is ok (if we originated this event then the item
* has been already removed) */
}
/* Make sure all updated: */
}
{
#ifdef VBOX_GUI_WITH_SYSTRAY
if (vboxGlobal().isTrayMenu())
{
/* Check if there are some machines alive - else quit, since
* we're not needed as a systray menu anymore. */
if (vboxGlobal().mainWindowCount() == 0)
{
return;
}
}
#endif /* VBOX_GUI_WITH_SYSTRAY */
sltRefreshVMItem(strMachineId, false /* aDetails */, true /* aSnapshots */, false /* aDescription */);
/* Simulate a state change signal: */
// m_pVMDesktop->updateDescriptionState();
}
{
}
{
// /* Simulate a state change signal: */
// m_pVMDesktop->updateDescriptionState();
}
{
}
#ifdef VBOX_GUI_WITH_SYSTRAY
{
}
{
}
{
}
{
/* Not used yet. */
}
{
switch (reason)
{
case QSystemTrayIcon::Context:
m_pTrayIcon->refresh();
break;
case QSystemTrayIcon::Trigger:
break;
case QSystemTrayIcon::DoubleClick:
break;
case QSystemTrayIcon::MiddleClick:
break;
default:
break;
}
}
void UISelectorWindow::sltShowWindow()
{
showNormal();
raise();
}
#endif // VBOX_GUI_WITH_SYSTRAY
{
/* Refresh the current details to pick up hard disk sizes: */
sltCurrentVMItemChanged(true /* fRefreshDetails */);
}
{
/* Refresh the current details to pick up hard disk sizes */
sltCurrentVMItemChanged(true /* fRefreshDetails */);
/* We warn about inaccessible media only once (after media emumeration
* started from main() at startup), to avoid annoying the user */
#ifdef VBOX_GUI_WITH_SYSTRAY
|| vboxGlobal().isTrayMenu()
#endif /* VBOX_GUI_WITH_SYSTRAY */
)
return;
m_fDoneInaccessibleWarningOnce = true;
do
{
/* Ignore the signal if a modal widget is currently active (we won't be
* able to properly show the modeless VDI manager window in this case): */
if (QApplication::activeModalWidget())
break;
/* Ignore the signal if a VBoxMediaManagerDlg window is active: */
if (qApp->activeWindow() &&
break;
/* Look for at least one inaccessible media: */
break;
{
/* Show the VDM dialog but don't refresh once more after a just-finished refresh: */
}
}
while (0);
}
#if 0
{
switch (downloaderType)
{
{
break;
}
{
break;
}
default:
break;
}
}
#endif
void UISelectorWindow::retranslateUi()
{
/* Set window title: */
#ifdef VBOX_BLEEDING_EDGE
+ QString(RTBldCfgVersion())
+ QString(" r")
#endif /* VBOX_BLEEDING_EDGE */
/* Ensure the details and screenshot view are updated: */
#ifdef VBOX_GUI_WITH_SYSTRAY
if (vboxGlobal().isTrayMenu())
{
m_pTrayIcon->refresh();
}
#endif /* VBOX_GUI_WITH_SYSTRAY */
#ifdef QT_MAC_USE_COCOA
/* There is a bug in Qt Cocoa which result in showing a "more arrow" when
the necessary size of the toolbar is increased. Also for some languages
the with doesn't match if the text increase. So manually adjust the size
after changing the text. */
#endif /* QT_MAC_USE_COCOA */
}
{
{
/* By handling every Resize and Move we keep track of the normal
* (non-minimized and non-maximized) window geometry. Shame on Qt
* that it doesn't provide this geometry in its public APIs. */
{
break;
}
{
break;
}
case QEvent::WindowDeactivate:
{
/* Make sure every status bar hint is cleared when the window lost focus. */
statusBar()->clearMessage();
break;
}
#ifdef Q_WS_MAC
case QEvent::ContextMenu:
{
/* This is the unified context menu event. Lets show the context menu. */
/* Accept it to interrupt the chain. */
return false;
break;
}
case QEvent::ToolBarChange:
{
/* We have to invert the isVisible check one time, cause this event
* is sent *before* the real toggle is done. Really intuitive Trolls. */
break;
}
#endif /* Q_WS_MAC */
default:
break;
}
}
{
#ifdef VBOX_GUI_WITH_SYSTRAY
/* Needed for breaking out of the while() loop in main(). */
if (vboxGlobal().isTrayMenu())
vboxGlobal().setTrayMenu(false);
#endif /* VBOX_GUI_WITH_SYSTRAY */
}
#ifdef Q_WS_MAC
{
if (!isActiveWindow())
{
{
return true;
break;
}
# if (QT_VERSION < 0x040402)
{
/* Bug in Qt below 4.4.2. The key events are send to the current
* window even if a menu is shown & has the focus. See
if (::darwinIsMenuOpen())
return true;
break;
}
# endif
default:
break;
}
}
#endif /* Q_WS_MAC */
void UISelectorWindow::prepareIcon()
{
/* Prepare application icon: */
/* On Win32, it's built-in to the executable.
* On Mac OS X the icon referenced in info.plist is used. */
#endif
}
void UISelectorWindow::prepareMenuBar()
{
/* Prepare 'File' menu: */
/* Prepare 'Machine' menu: */
#ifdef Q_WS_MAC
#endif /* Q_WS_MAC */
/* Prepare 'Help' menu: */
/* Setup menubar policy: */
}
{
/* Do not touch if filled already: */
return;
/* Populate 'File' menu: */
m_pMediumManagerDialogAction = gActionPool->action(UIActionIndexSelector_Simple_File_MediumManagerDialog);
m_pImportApplianceWizardAction = gActionPool->action(UIActionIndexSelector_Simple_File_ImportApplianceWizard);
m_pExportApplianceWizardAction = gActionPool->action(UIActionIndexSelector_Simple_File_ExportApplianceWizard);
#ifndef Q_WS_MAC
pMenu->addSeparator();
#endif /* Q_WS_MAC */
m_pPreferencesDialogAction = gActionPool->action(UIActionIndexSelector_Simple_File_PreferencesDialog);
#ifndef Q_WS_MAC
pMenu->addSeparator();
#endif /* Q_WS_MAC */
}
{
/* Do not touch if filled already: */
return;
/* Populate 'Machine' menu: */
pMenu->addSeparator();
pMenu->addSeparator();
pMenu->addSeparator();
m_pShowInFileManagerAction = gActionPool->action(UIActionIndexSelector_Simple_Machine_ShowInFileManager);
pMenu->addSeparator();
}
{
/* Do not touch if filled already: */
return;
m_pACPIShutdownAction = gActionPool->action(UIActionIndexSelector_Simple_Machine_Close_ACPIShutdown);
}
{
/* Do not touch if filled already: */
return;
/* Populate 'Help' menu: */
pMenu->addSeparator();
pMenu->addSeparator();
#ifdef VBOX_WITH_REGISTRATION
#endif /* VBOX_WITH_REGISTRATION */
#ifndef Q_WS_MAC
pMenu->addSeparator();
#endif /* !Q_WS_MAC */
}
void UISelectorWindow::prepareContextMenu()
{
m_pMachineContextMenu = new QMenu(this);
}
void UISelectorWindow::prepareStatusBar()
{
/* Setup statusbar policy: */
}
void UISelectorWindow::prepareWidgets()
{
/* Prepare splitter: */
m_pSplitter = new QISplitter(this);
/* Prepare tool-bar: */
mVMToolBar = new UIToolBar(this);
/* Prepare VM list: */
m_pVMModel = new UIVMItemModel(this);
/* Make non-possible to activate list elements by single click,
* this hack should disable the current possibility to do it if present: */
if (m_pVMListView->style()->styleHint(QStyle::SH_ItemView_ActivateItemOnSingleClick, 0, m_pVMListView))
/* Prepare details and snapshots tabs: */
/* Layout all the widgets: */
#define BIG_TOOLBAR
/* Central widget @ horizontal layout: */
#else /* MAC_LEOPARD_STYLE */
pLeftVLayout->setContentsMargins(0, 0, 0, 0);
pLeftVLayout->setSpacing(0);
# ifdef BIG_TOOLBAR
# else /* BIG_TOOLBAR */
# endif /* !BIG_TOOLBAR */
#endif /* !MAC_LEOPARD_STYLE */
/* Set the initial distribution. The right site is bigger. */
/* Refresh VM list: */
/* Reset to the first item: */
/* Bring the VM list to the focus: */
#ifdef VBOX_GUI_WITH_SYSTRAY
#endif /* VBOX_GUI_WITH_SYSTRAY */
}
void UISelectorWindow::prepareConnections()
{
/* VirtualBox event connections: */
connect(gVBoxEvents, SIGNAL(sigMachineStateChange(QString, KMachineState)), this, SLOT(sltMachineStateChanged(QString, KMachineState)));
connect(gVBoxEvents, SIGNAL(sigMachineDataChange(QString)), this, SLOT(sltMachineDataChanged(QString)));
connect(gVBoxEvents, SIGNAL(sigMachineRegistered(QString, bool)), this, SLOT(sltMachineRegistered(QString, bool)));
connect(gVBoxEvents, SIGNAL(sigSessionStateChange(QString, KSessionState)), this, SLOT(sltSessionStateChanged(QString, KSessionState)));
connect(gVBoxEvents, SIGNAL(sigSnapshotChange(QString, QString)), this, SLOT(sltSnapshotChanged(QString, QString)));
/* Medium enumeration connections: */
connect(&vboxGlobal(), SIGNAL(mediumEnumFinished(const VBoxMediaList &)), this, SLOT(sltMediumEnumFinished(const VBoxMediaList &)));
#if 0
/* Network manager connections: */
connect(gNetworkManager, SIGNAL(sigDownloaderCreated(UIDownloadType)), this, SLOT(sltEmbedDownloader(UIDownloadType)));
#endif
/* Menu-bar connections: */
connect(menuBar(), SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(sltShowSelectorContextMenu(const QPoint&)));
/* 'File' menu connections: */
connect(m_pImportApplianceWizardAction, SIGNAL(triggered()), this, SLOT(sltShowImportApplianceWizard()));
connect(m_pExportApplianceWizardAction, SIGNAL(triggered()), this, SLOT(sltShowExportApplianceWizard()));
/* 'Machine' menu connections: */
connect(m_pPauseAndResumeAction, SIGNAL(toggled(bool)), this, SLOT(sltPerformPauseResumeAction(bool)));
connect(m_pShowInFileManagerAction, SIGNAL(triggered()), this, SLOT(sltShowMachineInFileManager()));
connect(m_pCreateShortcutAction, SIGNAL(triggered()), this, SLOT(sltPerformCreateShortcutAction()));
/* 'Help' menu connections: */
connect(m_pResetWarningsAction, SIGNAL(triggered()), &msgCenter(), SLOT(sltResetSuppressedMessages()));
#ifdef VBOX_WITH_REGISTRATION
connect(gEDataEvents, SIGNAL(sigCanShowRegistrationDlg(bool)), m_pRegisterAction, SLOT(setEnabled(bool)));
#endif /* VBOX_WITH_REGISTRATION */
/* 'Machine' context menu connections: */
connect(m_pMachineContextMenu, SIGNAL(hovered(QAction*)), this, SLOT(sltMachineContextMenuHovered(QAction*)));
/* Status-bar connections: */
/* VM list-view connections: */
connect(m_pVMListView, SIGNAL(sigUrlsDropped(QList<QUrl>)), this, SLOT(sltOpenUrls(QList<QUrl>)), Qt::QueuedConnection);
connect(m_pVMListView, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(sltShowContextMenu(const QPoint &)));
/* Tool-bar connections: */
#ifndef Q_WS_MAC
connect(mVMToolBar, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(sltShowSelectorContextMenu(const QPoint&)));
#else /* !Q_WS_MAC */
/* A simple connect doesn't work on the Mac, also we want receive right
* click notifications on the title bar. So register our own handler. */
#endif /* Q_WS_MAC */
/* VM desktop connections: */
connect(m_pVMDesktop, SIGNAL(linkClicked(const QString &)), this, SLOT(sltShowMachineSettingsDialog(const QString &)));
#ifdef VBOX_GUI_WITH_SYSTRAY
/* Tray icon connections: */
connect(gEDataEvents, SIGNAL(sigMainWindowCountChange(int)), this, SLOT(sltMainWindowCountChanged(int)));
#endif /* VBOX_GUI_WITH_SYSTRAY */
}
void UISelectorWindow::loadSettings()
{
/* Get VBox object: */
/* Restore window position: */
{
int x = 0, y = 0, w = 0, h = 0;
if (ok)
if (ok)
if (ok)
if (ok)
if (ok /* previous parameters were read correctly */
{
m_normalGeo.moveTo(x, y);
#else /* defined(Q_WS_MAC) && (QT_VERSION >= 0x040700) */
#endif /* !(defined(Q_WS_MAC) && (QT_VERSION >= 0x040700)) */
if (max) /* maximize if needed */
}
else
{
}
}
/* Restore selected VM(s): */
{
}
/* Restore splitter handle position: */
{
}
/* Restore toolbar and statusbar visibility: */
{
#ifdef Q_WS_MAC
#else /* Q_WS_MAC */
#endif /* !Q_WS_MAC */
}
}
void UISelectorWindow::saveSettings()
{
/* Get VBox object: */
/* Save window position: */
{
#else /* defined(Q_WS_MAC) && (QT_VERSION >= 0x040700) */
#endif /* !(defined(Q_WS_MAC) && (QT_VERSION >= 0x040700)) */
QString strWinPos = QString("%1,%2,%3,%4").arg(save.x()).arg(save.y()).arg(save.width()).arg(save.height());
#ifdef Q_WS_MAC
if (::darwinIsWindowMaximized(this))
#else /* Q_WS_MAC */
if (isMaximized())
#endif /* !Q_WS_MAC */
}
/* Save selected VM(s): */
{
}
/* Save splitter handle position: */
{
}
}
bool UISelectorWindow::isActionEnabled(int iActionIndex, UIVMItem *pItem, const QList<UIVMItem*> &items)
{
if (pItem)
{
switch (iActionIndex)
{
{
/* Check that there is only one item, its accessible
* and machine is not in 'stuck' or 'saved' state.
* Modifying VM settings in 'saved' state will be available later. */
}
{
/* Check that there is only one item, its accessible
* and session state is unlocked. */
}
{
/* Check that item is present and
* machine is not accessible or session state is unlocked. */
return pItem &&
}
{
/* Check that item present and accessible: */
return false;
/* Check if we are in powered off mode which unifies next possible states.
* Then if session state is unlocked we can allow to start VM. */
/* Otherwise we are in running mode and
* should allow to switch to VM if its possible: */
return pItem->canSwitchTo();
}
{
/* Check that there is only one item, its accessible
* and machine is in 'saved' state and session state is unlocked. */
}
{
/* Check that item present and accessible
* and machine is in 'running' or 'paused' mode which unifies next possible states. */
}
{
/* Check that item present and accessible
* and machine is in 'running' mode which unifies next possible states. */
}
{
/* Check that item present and accessible
* and machine is in 'running' or 'paused' state. */
}
{
return false;
/* Check if we are entered ACPI mode already.
* Only then it make sense to send the ACPI shutdown sequence: */
bool fEnteredACPIMode = false;
{
}
else
return fEnteredACPIMode;
}
{
}
{
/* Check if item present and NOT accessible: */
}
{
/* Check if item present and accessible: */
}
{
#ifdef Q_WS_MAC
/* On Mac OS X this are real alias files, which don't work with the old
* legacy xml files. On the other OS's some kind of start up script is used. */
#else /* Q_WS_MAC */
#endif /* Q_WS_MAC */
}
default:
break;
}
}
return false;
}