UIMachineSettingsDisplay.cpp revision 889c22e84e245c1117b3aa25dbe66065955bf20c
/* $Id$ */
/** @file
*
* VBox frontends: Qt4 GUI ("VirtualBox"):
* UIMachineSettingsDisplay class implementation
*/
/*
* Copyright (C) 2008-2013 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.
*/
/* Qt includes: */
#include <QDesktopWidget>
/* GUI includes: */
#include "QIWidgetValidator.h"
#include "UIMachineSettingsDisplay.h"
#include "VBoxGlobal.h"
#include "UIMessageCenter.h"
#include "UIConverter.h"
/* COM includes: */
#include "CVRDEServer.h"
: m_iMinVRAM(0)
, m_iMaxVRAM(0)
, m_iMaxVRAMVisible(0)
, m_iInitialVRAM(0)
#ifdef VBOX_WITH_VIDEOHWACCEL
, m_f2DVideoAccelerationSupported(false)
#endif /* VBOX_WITH_VIDEOHWACCEL */
#ifdef VBOX_WITH_CRHGSMI
, m_fWddmModeSupported(false)
#endif /* VBOX_WITH_CRHGSMI */
{
/* Prepare: */
prepare();
}
{
/* Check if guest os type changed: */
if (m_guestOSType == guestOSType)
return;
/* Remember new guest os type: */
#ifdef VBOX_WITH_VIDEOHWACCEL
/* Check if 2D video acceleration supported by the guest OS type: */
#endif /* VBOX_WITH_VIDEOHWACCEL */
#ifdef VBOX_WITH_CRHGSMI
/* Check if WDDM mode supported by the guest OS type: */
#endif /* VBOX_WITH_CRHGSMI */
/* Recheck video RAM requirement: */
/* Revalidate: */
revalidate();
}
#ifdef VBOX_WITH_VIDEOHWACCEL
bool UIMachineSettingsDisplay::isAcceleration2DVideoSelected() const
{
return m_pCheckbox2DVideo->isChecked();
}
#endif /* VBOX_WITH_VIDEOHWACCEL */
/* Load data to cache from corresponding external object(s),
* this task COULD be performed in other than GUI thread: */
{
/* Fetch data to machine: */
/* Clear cache initially: */
/* Prepare display data: */
/* Cache Video data: */
#ifdef VBOX_WITH_VIDEOHWACCEL
#endif /* VBOX_WITH_VIDEOHWACCEL */
/* Check if Remote Display server is valid: */
if (!remoteDisplayServer.isNull())
{
/* Cache Remote Display data: */
}
/* Cache Video Capture data: */
/* Initialize other variables: */
/* Cache display data: */
/* Upload machine to data: */
}
/* Load data to corresponding widgets from cache,
* this task SHOULD be performed in GUI thread only: */
void UIMachineSettingsDisplay::getFromCache()
{
/* Get display data from cache: */
/* Load Video data to page: */
#ifdef VBOX_WITH_VIDEOHWACCEL
#endif /* VBOX_WITH_VIDEOHWACCEL */
/* Should be the last one from this tab: */
/* If Remote Display server is supported: */
{
/* Load Remote Display data to page: */
m_pComboRemoteDisplayAuthMethod->setCurrentIndex(m_pComboRemoteDisplayAuthMethod->findText(gpConverter->toString(displayData.m_remoteDisplayAuthType)));
}
/* Load Video Capture data to page: */
/* Polish page finally: */
polishPage();
/* Revalidate: */
revalidate();
}
/* Save data from corresponding widgets to cache,
* this task SHOULD be performed in GUI thread only: */
void UIMachineSettingsDisplay::putToCache()
{
/* Prepare audio data: */
/* Gather Video data from page: */
#ifdef VBOX_WITH_VIDEOHWACCEL
#endif /* VBOX_WITH_VIDEOHWACCEL */
/* If Remote Display server is supported: */
{
/* Gather Remote Display data from page: */
displayData.m_remoteDisplayAuthType = gpConverter->fromString<KAuthType>(m_pComboRemoteDisplayAuthMethod->currentText());
}
/* Gather Video Capture data from page: */
/* Cache display data: */
}
/* Save data from cache to corresponding external object(s),
* this task COULD be performed in other than GUI thread: */
{
/* Fetch data to machine: */
/* Make sure machine is in valid mode & display data was changed: */
{
/* Get display data from cache: */
/* Make sure machine is 'offline': */
if (isMachineOffline())
{
/* Store Video data: */
#ifdef VBOX_WITH_VIDEOHWACCEL
#endif /* VBOX_WITH_VIDEOHWACCEL */
}
/* Check if Remote Display server still valid: */
if (!remoteDisplayServer.isNull())
{
/* Store Remote Display data: */
/* Make sure machine is 'offline' or 'saved': */
if (isMachineOffline() || isMachineSaved())
}
/* Store Video Capture data: */
if (isMachineOnline())
{
/* If Video Capture is *enabled* now: */
{
/* We can still save the *screens* option: */
/* Finally we should *disable* Video Capture if necessary: */
}
/* If Video Capture is *disabled* now: */
else
{
/* We should save all the options *before* Video Capture activation: */
/* Finally we should *enable* Video Capture if necessary: */
}
}
else
{
/* For 'offline' and 'saved' states the order is irrelevant: */
}
}
/* Upload machine to data: */
}
{
/* Check if video RAM requirement changed first: */
/* Pass by default: */
bool fPass = true;
/* Video tab: */
{
/* Prepare message: */
/* 3D acceleration test: */
{
"However the host system does not currently provide this, "
"so you will not be able to start the machine.");
}
/* Video RAM amount test: */
{
quint64 uNeedBytes = VBoxGlobal::requiredVideoMemory(m_guestOSType.GetId(), m_pEditorVideoScreenCount->value());
/* Basic video RAM amount test: */
{
message.second << tr("The virtual machine is currently assigned less than <b>%1</b> of video memory "
"which is the minimum amount required to switch to fullscreen or seamless mode.")
}
#ifdef VBOX_WITH_VIDEOHWACCEL
/* 2D acceleration video RAM amount test: */
{
{
message.second << tr("The virtual machine is currently assigned less than <b>%1</b> of video memory "
"which is the minimum amount required for High Definition Video to be played efficiently.")
}
}
#endif /* VBOX_WITH_VIDEOHWACCEL */
#if 0
# ifdef VBOX_WITH_CRHGSMI
/* 3D acceleration video RAM amount test: */
{
uNeedBytes += VBoxGlobal::required3DWddmOffscreenVideoMemory(m_guestOSType.GetId(), cGuestScreenCount);
{
"and the operating system hint is set to Windows Vista or later. "
"For best performance you should set the machine's video memory to at least b>%1</b>.")
}
}
# endif /* VBOX_WITH_CRHGSMI */
#endif /* 0 */
}
#ifdef VBOX_WITH_VIDEOHWACCEL
/* 2D video acceleration is available for Windows guests only: */
{
"As this feature only works with Windows guest systems it will be disabled.");
}
#endif /* VBOX_WITH_VIDEOHWACCEL */
/* Serialize message: */
}
/* Remote Display tab: */
{
/* Prepare message: */
/* Check VRDE server port: */
{
fPass = false;
}
/* Check VRDE server timeout: */
{
fPass = false;
}
/* Serialize message: */
}
/* Return result: */
return fPass;
}
{
/* Video tab-order */
#ifdef VBOX_WITH_VIDEOHWACCEL
#else /* VBOX_WITH_VIDEOHWACCEL */
#endif /* !VBOX_WITH_VIDEOHWACCEL */
/* Remote Display tab-order: */
/* Video Capture tab-order: */
}
{
/* Translate uic generated strings */
/* Video stuff: */
m_pLabelVideoScreenCountMax->setText(tr("<qt>%1</qt>").arg(qMin(sys.GetMaxGuestMonitors(), (ULONG)8)));
/* Remote Display stuff: */
/* Video Capture stuff: */
m_pLabelVideoCaptureFrameRateMin->setText(tr("%1 fps").arg(m_pSliderVideoCaptureFrameRate->minimum()));
m_pLabelVideoCaptureFrameRateMax->setText(tr("%1 fps").arg(m_pSliderVideoCaptureFrameRate->maximum()));
}
void UIMachineSettingsDisplay::polishPage()
{
/* Get system data from cache: */
/* Video tab: */
#ifdef VBOX_WITH_VIDEOHWACCEL
#endif /* VBOX_WITH_VIDEOHWACCEL */
/* Remote Display tab: */
/* Video Capture tab: */
}
{
/* Apply proposed memory-size: */
m_pEditorVideoMemorySize->blockSignals(true);
m_pEditorVideoMemorySize->blockSignals(false);
/* Revalidate: */
revalidate();
}
{
/* Apply proposed memory-size: */
m_pSliderVideoMemorySize->blockSignals(true);
m_pSliderVideoMemorySize->blockSignals(false);
/* Revalidate: */
revalidate();
}
{
/* Apply proposed screen-count: */
m_pEditorVideoScreenCount->blockSignals(false);
/* Update Video RAM requirements: */
/* Update Video Capture tab screen count: */
/* Revalidate: */
revalidate();
}
{
/* Apply proposed screen-count: */
m_pSliderVideoScreenCount->blockSignals(false);
/* Update Video RAM requirements: */
/* Update Video Capture tab screen count: */
/* Revalidate: */
revalidate();
}
{
/* Video Capture options should be enabled only if:
* 1. Machine is in 'offline' or 'saved' state and check-box is checked,
* 2. Machine is in 'online' state, check-box is checked, and video recording is *disabled* currently. */
bool fIsVideoCaptureOptionsEnabled = ((isMachineOffline() || isMachineSaved()) && m_pCheckboxVideoCapture->isChecked()) ||
(isMachineOnline() && !m_cache.base().m_fVideoCaptureEnabled && m_pCheckboxVideoCapture->isChecked());
/* Video Capture Screens option should be enabled only if:
* Machine is in *any* valid state and check-box is checked. */
bool fIsVideoCaptureScreenOptionEnabled = isMachineInValidMode() && m_pCheckboxVideoCapture->isChecked();
}
{
/* Get the proposed size: */
/* Make sure its valid: */
if (!videoCaptureSize.isValid())
return;
/* Apply proposed size: */
}
{
/* Look for preset: */
/* Update quality and bit-rate: */
}
{
/* Look for preset: */
/* Update quality and bit-rate: */
}
{
/* Apply proposed frame-rate: */
/* Update quality and bit-rate: */
}
{
/* Apply proposed frame-rate: */
/* Update quality and bit-rate: */
}
{
m_pEditorVideoCaptureBitRate->blockSignals(false);
}
{
m_pSliderVideoCaptureQuality->blockSignals(false);
}
void UIMachineSettingsDisplay::prepare()
{
/* Apply UI decorations: */
/* Prepare tabs: */
/* Prepare validation: */
/* Translate finally: */
}
{
/* Prepare memory-size slider: */
connect(m_pSliderVideoMemorySize, SIGNAL(valueChanged(int)), this, SLOT(sltHandleVideoMemorySizeSliderChange()));
/* Prepare memory-size editor: */
connect(m_pEditorVideoMemorySize, SIGNAL(valueChanged(int)), this, SLOT(sltHandleVideoMemorySizeEditorChange()));
/* Prepare screen-count slider: */
connect(m_pSliderVideoScreenCount, SIGNAL(valueChanged(int)), this, SLOT(sltHandleVideoScreenCountSliderChange()));
/* Prepare screen-count editor: */
connect(m_pEditorVideoScreenCount, SIGNAL(valueChanged(int)), this, SLOT(sltHandleVideoScreenCountEditorChange()));
#ifndef VBOX_WITH_VIDEOHWACCEL
/* Hide check-box if not supported: */
m_pCheckbox2DVideo->setVisible(false);
#endif /* VBOX_WITH_VIDEOHWACCEL */
}
{
/* Setup validators: */
m_pEditorRemoteDisplayPort->setValidator(new QRegExpValidator(QRegExp("(([0-9]{1,5}(\\-[0-9]{1,5}){0,1}),)*([0-9]{1,5}(\\-[0-9]{1,5}){0,1})"), this));
/* Prepare auth-method combo: */
}
{
/* Prepare Video Capture checkbox: */
connect(m_pCheckboxVideoCapture, SIGNAL(toggled(bool)), this, SLOT(sltHandleVideoCaptureCheckboxToggle()));
/* Prepare filepath selector: */
m_pEditorVideoCapturePath->setEditable(false);
/* Prepare frame-size combo-box: */
connect(m_pComboVideoCaptureSize, SIGNAL(currentIndexChanged(int)), this, SLOT(sltHandleVideoCaptureFrameSizeComboboxChange()));
/* Prepare frame-width/height editors: */
connect(m_pEditorVideoCaptureWidth, SIGNAL(valueChanged(int)), this, SLOT(sltHandleVideoCaptureFrameWidthEditorChange()));
connect(m_pEditorVideoCaptureHeight, SIGNAL(valueChanged(int)), this, SLOT(sltHandleVideoCaptureFrameHeightEditorChange()));
/* Prepare frame-rate slider: */
connect(m_pSliderVideoCaptureFrameRate, SIGNAL(valueChanged(int)), this, SLOT(sltHandleVideoCaptureFrameRateSliderChange()));
/* Prepare frame-rate editor: */
connect(m_pEditorVideoCaptureFrameRate, SIGNAL(valueChanged(int)), this, SLOT(sltHandleVideoCaptureFrameRateEditorChange()));
/* Prepare quality combo-box: */
connect(m_pSliderVideoCaptureQuality, SIGNAL(valueChanged(int)), this, SLOT(sltHandleVideoCaptureQualitySliderChange()));
/* Prepare bit-rate editor: */
connect(m_pEditorVideoCaptureBitRate, SIGNAL(valueChanged(int)), this, SLOT(sltHandleVideoCaptureBitRateEditorChange()));
}
{
/* Configure validation: */
#ifdef VBOX_WITH_VIDEOHWACCEL
#endif /* VBOX_WITH_VIDEOHWACCEL */
connect(m_pEditorRemoteDisplayTimeout, SIGNAL(textChanged(const QString&)), this, SLOT(revalidate()));
}
{
/* Make sure guest OS type is set: */
if (m_guestOSType.isNull())
return;
/* Get monitors count and base video memory requirements: */
quint64 uNeedMBytes = VBoxGlobal::requiredVideoMemory(m_guestOSType.GetId(), cGuestScreenCount) / _1M;
/* Initial value: */
/* No more than m_iMaxVRAM: */
if (m_iMaxVRAMVisible > m_iMaxVRAM)
/* No less than 128MB (if possible): */
m_iMaxVRAMVisible = 128;
/* No less than initial VRAM size (wtf?): */
if (m_iMaxVRAMVisible < m_iInitialVRAM)
#ifdef VBOX_WITH_VIDEOHWACCEL
{
}
#endif /* VBOX_WITH_VIDEOHWACCEL */
#ifdef VBOX_WITH_CRHGSMI
{
# if 0
uNeedMBytes += VBoxGlobal::required3DWddmOffscreenVideoMemory(m_guestOSType.GetId(), cGuestScreenCount) / _1M;
# endif
/* No less than 256MB (if possible): */
m_iMaxVRAMVisible = 256;
}
#endif /* VBOX_WITH_CRHGSMI */
m_pSliderVideoMemorySize->setOptimalHint(qMin((int)uNeedMBytes, m_iMaxVRAMVisible), m_iMaxVRAMVisible);
}
{
bool fResult = true;
<< "Other" << "DOS" << "Netware" << "L4" << "QNX" << "JRockitVE";
fResult = false;
return fResult;
}
/* static */
{
/* Reasonable max. number of page steps is 32. */
/* Make it a power of 2: */
while ((p >>= 1))
p2 <<= 1;
p2 <<= 1;
if (p2 < 4)
p2 = 4;
return (int)p2;
}
{
/* Look for video-capture size preset: */
}
{
/* Update copy of the cached item to get the desired result: */
}
/* static */
void UIMachineSettingsDisplay::lookForCorrespondingPreset(QComboBox *pWhere, const QVariant &whichData)
{
/* Use passed iterator to look for corresponding preset of passed combo-box: */
pWhere->setCurrentIndex(0);
}
/* static */
int UIMachineSettingsDisplay::calculateBitRate(int iFrameWidth, int iFrameHeight, int iFrameRate, int iQuality)
{
/* Linear quality<=>bit-rate scale-factor: */
/ (double)10 /* translate quality to [%] */
/ (double)1024 /* translate bit-rate to [kbps] */
/ (double)18.75 /* linear scale factor */;
return (int)dResult;
}
/* static */
int UIMachineSettingsDisplay::calculateQuality(int iFrameWidth, int iFrameHeight, int iFrameRate, int iBitRate)
{
/* Linear bit-rate<=>quality scale-factor: */
* (double)10 /* translate quality to [%] */
* (double)1024 /* translate bit-rate to [kbps] */
* (double)18.75 /* linear scale factor */;
return (int)dResult;
}