VBoxVMInformationDlg.cpp revision e64031e20c39650a7bc902a3e1aba613b9415dee
/* $Id$ */
/** @file
*
* VBox frontends: Qt4 GUI ("VirtualBox"):
* VBoxVMInformationDlg class implementation
*/
/*
* Copyright (C) 2006-2009 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* 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 <QTimer>
/* Local Includes */
#include <VBoxVMInformationDlg.h>
#include <VBoxGlobal.h>
#include <VBoxConsoleView.h>
#endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
#ifdef VBOX_WITH_NEW_RUNTIME_CORE
#include "UIMachineLogic.h"
#include "UIMachineWindow.h"
#include "UIMachineView.h"
#include "UISession.h"
#endif /* VBOX_WITH_NEW_RUNTIME_CORE */
#ifdef VBOX_WITH_NEW_RUNTIME_CORE
{
{
/* Creating new information dialog if there is no one existing */
// TODO_NEW_CORE: this seems not necessary, cause we set WA_DeleteOnClose.
}
info->activateWindow();
}
VBoxVMInformationDlg::VBoxVMInformationDlg (UIMachineWindow *pMachineWindow, Qt::WindowFlags aFlags)
# ifdef Q_WS_MAC
# else /* Q_WS_MAC */
# endif /* Q_WS_MAC */
, mIsPolished (false)
, mStatTimer (new QTimer (this))
{
/* Apply UI decorations */
#ifdef Q_WS_MAC
/* No icon for this window on the mac, cause this would act as proxy icon which isn't necessary here. */
setWindowIcon (QIcon());
#else
/* Apply window icons */
":/session_info_32px.png", ":/session_info_16px.png"));
#endif
/* Enable size grip without using a status bar. */
setSizeGripEnabled (true);
/* Setup focus-proxy for pages */
/* Setup browsers */
/* Setup margins */
/* Setup handlers */
connect (pMachineWindow->uisession(), SIGNAL (sigMediumChange(const CMediumAttachment&)), this, SLOT (updateDetails()));
connect (pMachineWindow->uisession(), SIGNAL (sigSharedFolderChange()), this, SLOT (updateDetails()));
/* TODO_NEW_CORE: this is ofc not really right in the mm sense. There are
* more than one screens. */
connect (pMachineWindow->machineView(), SIGNAL (resizeHintDone()), this, SLOT (processStatistics()));
connect (&vboxGlobal(), SIGNAL (mediumEnumFinished (const VBoxMediaList &)), this, SLOT (updateDetails()));
/* Loading language constants */
/* Details page update */
/* Statistics page update */
/* Preload dialog attributes for this vm */
{
mWidth = 400;
mHeight = 450;
mMax = false;
}
else
{
}
/* Make statistics page the default one */
}
#endif /* VBOX_WITH_NEW_RUNTIME_CORE */
void VBoxVMInformationDlg::createInformationDlg (const CSession &aSession, VBoxConsoleView *aConsole)
{
{
/* Creating new information dialog if there is no one existing */
}
info->activateWindow();
}
VBoxVMInformationDlg::VBoxVMInformationDlg (VBoxConsoleView *aConsole, const CSession &aSession, Qt::WindowFlags aFlags)
# ifdef Q_WS_MAC
# else /* Q_WS_MAC */
# endif /* Q_WS_MAC */
, mIsPolished (false)
, mStatTimer (new QTimer (this))
{
/* Apply UI decorations */
#ifdef Q_WS_MAC
/* No icon for this window on the mac, cause this would act as proxy icon which isn't necessary here. */
setWindowIcon (QIcon());
#else
/* Apply window icons */
":/session_info_32px.png", ":/session_info_16px.png"));
#endif
/* Enable size grip without using a status bar. */
setSizeGripEnabled (true);
/* Setup focus-proxy for pages */
/* Setup browsers */
/* Setup margins */
/* Setup handlers */
/* Setup handlers */
connect (mConsole, SIGNAL (mediaDriveChanged (VBoxDefs::MediumType)), this, SLOT (updateDetails()));
connect (&vboxGlobal(), SIGNAL (mediumEnumFinished (const VBoxMediaList &)), this, SLOT (updateDetails()));
/* Loading language constants */
/* Details page update */
/* Statistics page update */
/* Preload dialog attributes for this vm */
{
mWidth = 400;
mHeight = 450;
mMax = false;
}
else
{
}
/* Make statistics page the default one */
}
{
/* Save dialog attributes for this vm */
}
void VBoxVMInformationDlg::retranslateUi()
{
/* Translate uic generated strings */
/* Setup a dialog caption */
/* Setup a tabwidget page names */
/* Clear counter names initially */
/* Storage statistics */
{
switch (controller.GetBus())
{
case KStorageBus_IDE:
{
{
{
/* Names */
/* Units */
/* Belongs to */
}
}
++ ideCount;
break;
}
case KStorageBus_SATA:
{
{
{
/* Names */
= tr ("DMA Transfers");
= tr ("Data Read");
= tr ("Data Written");
/* Units */
/* Belongs to */
}
}
++ sataCount;
break;
}
case KStorageBus_SCSI:
{
{
{
/* Names */
= tr ("Data Read");
= tr ("Data Written");
/* Units */
/* Belongs to */
}
}
++ scsiCount;
break;
}
default:
break;
}
}
/* Network statistics: */
{
const char *name;
switch (ty)
{
name = "E1k";
break;
name = "VNet";
break;
default:
name = "PCNet";
break;
}
/* Names */
/* Units */
/* Belongs to */
}
/* Statistics page update. */
}
{
{
case QEvent::WindowStateChange:
{
if (mIsPolished)
mMax = isMaximized();
else if (mMax == isMaximized())
mIsPolished = true;
break;
}
default:
break;
}
return result;
}
{
/* Store dialog size for this vm */
if (mIsPolished && !isMaximized())
{
}
}
{
/* One may think that QWidget::polish() is the right place to do things
* below, but apparently, by the time when QWidget::polish() is called,
* the widget style & layout are not fully done, at least the minimum
* size hint is not properly calculated. Since this is sometimes necessary,
* we provide our own "polish" implementation */
if (!mIsPolished)
{
/* Load window size and state */
if (mMax)
else
mIsPolished = true;
}
}
void VBoxVMInformationDlg::updateDetails()
{
/* Details page update */
}
{
/* Process selected statistics: */
{
}
/* Statistics page update */
}
{
/* Focusing the browser on shown page */
}
{
/* Filters the statistic counters body */
{
/* Parse incoming counter and fill the counter-element values. */
{
}
/* Fill the output with the necessary counter's value.
* Currently we are using "c" field of simple counter only. */
}
}
{
return;
"<td colspan=2><nobr><b>%2</b></nobr></td></tr>";
/* Runtime Information */
{
if (bpp)
{
+ " r"
}
else
else
/* Searching for longest string */
int maxLength = 0;
result += formatValue (VBoxGlobal::tr ("Remote Display Server Port", "details report (VRDP Server)"), vrdpInfo, maxLength);
}
/* Storage statistics */
{
{
CMediumAttachmentVector attachments = mSession.GetMachine().GetMediumAttachmentsOfController (ctrName);
{
int scsiIndex = 0;
{
switch (busType)
{
case KStorageBus_IDE:
{
break;
}
case KStorageBus_SATA:
{
break;
}
case KStorageBus_SCSI:
{
++ scsiIndex;
break;
}
default:
break;
}
storageStat += paragraph;
}
}
switch (busType)
{
case KStorageBus_IDE:
{
++ ideCount;
break;
}
case KStorageBus_SATA:
{
++ sataCount;
break;
}
case KStorageBus_SCSI:
{
++ scsiCount;
break;
}
default:
break;
}
}
/* If there are no Hard Disks */
if (storageStat.isNull())
{
storageStat += paragraph;
}
result += storageStat;
}
/* Network Adapters Statistics */
{
/* Network Adapters list */
{
{
networkStat += paragraph;
}
}
/* If there are no Network Adapters */
if (networkStat.isNull())
{
networkStat += paragraph;
}
result += networkStat;
}
}
/**
* Allows left-aligned values formatting in right column.
*
* aValueName - the name of value in the left column.
* aValue - left-aligned value itself in the right column.
* aMaxSize - maximum width (in pixels) of value in right column.
*/
{
"<td align=right><nobr>%2"
"<img src=:/tpixel.png width=%3 height=1></nobr></td></tr>";
}
const QString &aBelongsTo)
{
}
const QString &aBelongsTo)
{
}
{
"<td align=right><nobr>%3%4</nobr></td></tr>";
for (int i = 0; i < aSpacesCount; ++ i)
indent += " ";
{
{
{
}
}
}
else
return result;
}