VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/globals/UIDetailsGenerator.cpp@ 101064

Last change on this file since 101064 was 101064, checked in by vboxsync, 18 months ago

FE/Qt: More code for running ARM VMs needed -- Don't try to access and use x86-specifics when architecture is set to ARM. bugref:10384

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
  • Property svn:mergeinfo set to (toggle deleted branches)
    /branches/VBox-3.0/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserItemMachine.cpp58652,​70973
    /branches/VBox-3.2/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserItemMachine.cpp66309,​66318
    /branches/VBox-4.0/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserItemMachine.cpp70873
    /branches/VBox-4.1/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserItemMachine.cpp74233
    /branches/VBox-4.2/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsElement.cpp91503-91504,​91506-91508,​91510,​91514-91515,​91521
    /branches/VBox-4.3/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsElement.cpp91223
    /branches/VBox-4.3/trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsElement.cpp91223
    /branches/dsen/gui/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserItemMachine.cpp79076-79078,​79089,​79109-79110,​79112-79113,​79127-79130,​79134,​79141,​79151,​79155,​79157-79159,​79193,​79197
    /branches/dsen/gui2/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsElement.cpp79562-79569,​79572-79573,​79578,​79581-79582,​79590-79591,​79598-79599,​79602-79603,​79605-79606,​79632,​79635,​79637,​79644
    /branches/dsen/gui3/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsElement.cpp79645-79692
    /trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserItemMachine.cpp79225,​79271
File size: 71.7 KB
Line 
1/* $Id: UIDetailsGenerator.cpp 101064 2023-09-08 12:44:47Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - UIDetailsGenerator implementation.
4 */
5
6/*
7 * Copyright (C) 2012-2023 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * SPDX-License-Identifier: GPL-3.0-only
26 */
27
28/* Qt includes: */
29#include <QApplication>
30#include <QDir>
31#include <QRegularExpression>
32
33/* GUI includes: */
34#include "UIBootOrderEditor.h"
35#include "UICommon.h"
36#include "UIConverter.h"
37#include "UIDetailsGenerator.h"
38#include "UIErrorString.h"
39#include "UIMedium.h"
40#include "UITranslator.h"
41
42/* COM includes: */
43#include "COMEnums.h"
44#include "CAudioAdapter.h"
45#include "CAudioSettings.h"
46#include "CBooleanFormValue.h"
47#include "CChoiceFormValue.h"
48#include "CCloudMachine.h"
49#include "CConsole.h"
50#include "CFirmwareSettings.h"
51#include "CForm.h"
52#include "CFormValue.h"
53#include "CGraphicsAdapter.h"
54#include "CGuest.h"
55#include "CMachine.h"
56#include "CMediumAttachment.h"
57#include "CNetworkAdapter.h"
58#include "CNvramStore.h"
59#include "CPlatform.h"
60#include "CPlatformX86.h"
61#include "CPlatformProperties.h"
62#include "CProgress.h"
63#include "CRangedIntegerFormValue.h"
64#include "CRecordingScreenSettings.h"
65#include "CRecordingSettings.h"
66#include "CSerialPort.h"
67#include "CSharedFolder.h"
68#include "CStorageController.h"
69#include "CStringFormValue.h"
70#include "CTrustedPlatformModule.h"
71#include "CUefiVariableStore.h"
72#include "CUSBController.h"
73#include "CUSBDevice.h"
74#include "CUSBDeviceFilter.h"
75#include "CUSBDeviceFilters.h"
76#include "CVRDEServer.h"
77
78/* VirtualBox interface declarations: */
79#include <iprt/time.h>
80#include <VBox/com/VirtualBox.h>
81
82
83const QString UIDetailsGenerator::e_strTableRow1 = QString("<tr><td colspan='2'><nobr><b>%1</b></nobr></td></tr>");
84const QString UIDetailsGenerator::e_strTableRow2 = QString("<tr><td><nobr>%1:</nobr></td><td><nobr>%2</nobr></td></tr>");
85const QString UIDetailsGenerator::e_strTableRow3 = QString("<tr><td><nobr>&nbsp;%1:</nobr></td><td><nobr>%2</nobr></td></tr>");
86
87
88UITextTable UIDetailsGenerator::generateMachineInformationGeneral(CMachine &comMachine,
89 const UIExtraDataMetaDefs::DetailsElementOptionTypeGeneral &fOptions)
90{
91 UITextTable table;
92
93 if (comMachine.isNull())
94 return table;
95
96 if (!comMachine.GetAccessible())
97 {
98 table << UITextTableLine(QApplication::translate("UIDetails", "Information Inaccessible", "details"), QString());
99 return table;
100 }
101
102 /* Name: */
103 if (fOptions & UIExtraDataMetaDefs::DetailsElementOptionTypeGeneral_Name)
104 {
105 /* Configure hovering anchor: */
106 const QString strAnchorType = QString("machine_name");
107 const QString strName = comMachine.GetName();
108 table << UITextTableLine(QApplication::translate("UIDetails", "Name", "details (general)"),
109 QString("<a href=#%1,%2>%2</a>")
110 .arg(strAnchorType,
111 strName));
112 }
113
114 /* Operating system: */
115 if (fOptions & UIExtraDataMetaDefs::DetailsElementOptionTypeGeneral_OS)
116 {
117 /* Configure hovering anchor: */
118 const QString strAnchorType = QString("os_type");
119 const QString strOsTypeId = comMachine.GetOSTypeId();
120 table << UITextTableLine(QApplication::translate("UIDetails", "Operating System", "details (general)"),
121 QString("<a href=#%1,%2>%3</a>")
122 .arg(strAnchorType,
123 strOsTypeId,
124 uiCommon().vmGuestOSTypeDescription(strOsTypeId)));
125 }
126
127 /* Settings file location: */
128 if (fOptions & UIExtraDataMetaDefs::DetailsElementOptionTypeGeneral_Location)
129 {
130 /* Configure hovering anchor: */
131 const QString strAnchorType = QString("machine_location");
132 const QString strMachineLocation = comMachine.GetSettingsFilePath();
133 table << UITextTableLine(QApplication::translate("UIDetails", "Settings File Location", "details (general)"),
134 QString("<a href=#%1,%2>%3</a>")
135 .arg(strAnchorType,
136 strMachineLocation,
137 QDir::toNativeSeparators(QFileInfo(strMachineLocation).absolutePath())));
138 }
139
140 /* Groups: */
141 if (fOptions & UIExtraDataMetaDefs::DetailsElementOptionTypeGeneral_Groups)
142 {
143 QStringList groups = comMachine.GetGroups().toList();
144 /* Do not show groups for machine which is in root group only: */
145 if (groups.size() == 1)
146 groups.removeAll("/");
147 /* If group list still not empty: */
148 if (!groups.isEmpty())
149 {
150 /* For every group: */
151 for (int i = 0; i < groups.size(); ++i)
152 {
153 /* Trim first '/' symbol: */
154 QString &strGroup = groups[i];
155 if (strGroup.startsWith("/") && strGroup != "/")
156 strGroup.remove(0, 1);
157 }
158 table << UITextTableLine(QApplication::translate("UIDetails", "Groups", "details (general)"), groups.join(", "));
159 }
160 }
161
162 return table;
163}
164
165UITextTable UIDetailsGenerator::generateMachineInformationGeneral(CCloudMachine &comCloudMachine,
166 const UIExtraDataMetaDefs::DetailsElementOptionTypeGeneral &)
167{
168 UITextTable table;
169
170 if (comCloudMachine.isNull())
171 return table;
172
173 if (!comCloudMachine.GetAccessible())
174 {
175 table << UITextTableLine(QApplication::translate("UIDetails", "Information Inaccessible", "details"), QString());
176 return table;
177 }
178
179 /* Acquire details form: */
180 CForm comForm = comCloudMachine.GetDetailsForm();
181 /* Ignore cloud machine errors: */
182 if (comCloudMachine.isOk())
183 {
184 /* Common anchor for all fields: */
185 const QString strAnchorType = "cloud";
186
187 /* For each form value: */
188 const QVector<CFormValue> values = comForm.GetValues();
189 foreach (const CFormValue &comIteratedValue, values)
190 {
191 /* Ignore invisible values: */
192 if (!comIteratedValue.GetVisible())
193 continue;
194
195 /* Acquire label: */
196 const QString strLabel = comIteratedValue.GetLabel();
197 /* Generate value: */
198 const QString strValue = generateFormValueInformation(comIteratedValue);
199
200 /* Generate table string: */
201 table << UITextTableLine(strLabel, QString("<a href=#%1,%2>%3</a>").arg(strAnchorType, strLabel, strValue));
202 }
203 }
204
205 return table;
206}
207
208QString UIDetailsGenerator::generateFormValueInformation(const CFormValue &comFormValue, bool fFull /* = false */)
209{
210 /* Handle possible form value types: */
211 QString strResult;
212 switch (comFormValue.GetType())
213 {
214 case KFormValueType_Boolean:
215 {
216 CBooleanFormValue comValue(comFormValue);
217 const bool fBool = comValue.GetSelected();
218 strResult = fBool ? QApplication::translate("UIDetails", "Enabled", "details (cloud value)")
219 : QApplication::translate("UIDetails", "Disabled", "details (cloud value)");
220 break;
221 }
222 case KFormValueType_String:
223 {
224 CStringFormValue comValue(comFormValue);
225 const QString strValue = comValue.GetString();
226 const QString strClipboardValue = comValue.GetClipboardString();
227 strResult = fFull && !strClipboardValue.isEmpty() ? strClipboardValue : strValue;
228 break;
229 }
230 case KFormValueType_Choice:
231 {
232 AssertMsgFailed(("Aren't we decided to convert all choices to strings?\n"));
233 CChoiceFormValue comValue(comFormValue);
234 const QVector<QString> possibleValues = comValue.GetValues();
235 const int iCurrentIndex = comValue.GetSelectedIndex();
236 strResult = possibleValues.value(iCurrentIndex);
237 break;
238 }
239 case KFormValueType_RangedInteger:
240 {
241 CRangedIntegerFormValue comValue(comFormValue);
242 strResult = QString("%1 %2")
243 .arg(comValue.GetInteger())
244 .arg(QApplication::translate("UICommon", comValue.GetSuffix().toUtf8().constData()));
245 break;
246 }
247 default:
248 break;
249 }
250 /* Return result: */
251 return strResult;
252}
253
254UITextTable UIDetailsGenerator::generateMachineInformationSystem(CMachine &comMachine,
255 const UIExtraDataMetaDefs::DetailsElementOptionTypeSystem &fOptions)
256{
257 UITextTable table;
258
259 if (comMachine.isNull())
260 return table;
261
262 if (!comMachine.GetAccessible())
263 {
264 table << UITextTableLine(QApplication::translate("UIDetails", "Information Inaccessible", "details"), QString());
265 return table;
266 }
267
268 /* Base memory: */
269 if (fOptions & UIExtraDataMetaDefs::DetailsElementOptionTypeSystem_RAM)
270 {
271 /* Configure hovering anchor: */
272 const QString strAnchorType = QString("base_memory");
273 const int iBaseMemory = comMachine.GetMemorySize();
274 table << UITextTableLine(QApplication::translate("UIDetails", "Base Memory", "details (system)"),
275 QString("<a href=#%1,%2>%3</a>")
276 .arg(strAnchorType)
277 .arg(iBaseMemory)
278 .arg(QApplication::translate("UIDetails", "%1 MB").arg(iBaseMemory)));
279 }
280
281 /* Processors: */
282 if (fOptions & UIExtraDataMetaDefs::DetailsElementOptionTypeSystem_CPUCount)
283 {
284 const int cCPU = comMachine.GetCPUCount();
285 if (cCPU > 1)
286 table << UITextTableLine(QApplication::translate("UIDetails", "Processors", "details (system)"),
287 QString::number(cCPU));
288 }
289
290 /* Execution cap: */
291 if (fOptions & UIExtraDataMetaDefs::DetailsElementOptionTypeSystem_CPUExecutionCap)
292 {
293 const int iCPUExecutionCap = comMachine.GetCPUExecutionCap();
294 if (iCPUExecutionCap < 100)
295 table << UITextTableLine(QApplication::translate("UIDetails", "Execution Cap", "details (system)"),
296 QApplication::translate("UIDetails", "%1%", "details").arg(iCPUExecutionCap));
297 }
298
299 /* Boot order: */
300 if (fOptions & UIExtraDataMetaDefs::DetailsElementOptionTypeSystem_BootOrder)
301 {
302 /* Configure hovering anchor: */
303 const QString strAnchorType = QString("boot_order");
304 const UIBootItemDataList bootItems = loadBootItems(comMachine);
305 table << UITextTableLine(QApplication::translate("UIDetails", "Boot Order", "details (system)"),
306 QString("<a href=#%1,%2>%3</a>")
307 .arg(strAnchorType,
308 bootItemsToSerializedString(bootItems),
309 bootItemsToReadableString(bootItems)));
310 }
311
312 /* Chipset type: */
313 if (fOptions & UIExtraDataMetaDefs::DetailsElementOptionTypeSystem_ChipsetType)
314 {
315 CPlatform comPlatform = comMachine.GetPlatform();
316 const KChipsetType enmChipsetType = comPlatform.GetChipsetType();
317 if (enmChipsetType == KChipsetType_ICH9)
318 table << UITextTableLine(QApplication::translate("UIDetails", "Chipset Type", "details (system)"),
319 gpConverter->toString(enmChipsetType));
320 }
321
322 /* TPM type: */
323 if (fOptions & UIExtraDataMetaDefs::DetailsElementOptionTypeSystem_TpmType)
324 {
325 CTrustedPlatformModule comModule = comMachine.GetTrustedPlatformModule();
326 const KTpmType enmTpmType = comModule.GetType();
327 if (enmTpmType != KTpmType_None)
328 table << UITextTableLine(QApplication::translate("UIDetails", "TPM Type", "details (system)"),
329 gpConverter->toString(enmTpmType));
330 }
331
332 /* EFI: */
333 if (fOptions & UIExtraDataMetaDefs::DetailsElementOptionTypeSystem_Firmware)
334 {
335 CFirmwareSettings comFirmwareSettings = comMachine.GetFirmwareSettings();
336 switch (comFirmwareSettings.GetFirmwareType())
337 {
338 case KFirmwareType_EFI:
339 case KFirmwareType_EFI32:
340 case KFirmwareType_EFI64:
341 case KFirmwareType_EFIDUAL:
342 {
343 table << UITextTableLine(QApplication::translate("UIDetails", "EFI", "details (system)"),
344 QApplication::translate("UIDetails", "Enabled", "details (system/EFI)"));
345 break;
346 }
347 default:
348 {
349 // For NLS purpose:
350 QApplication::translate("UIDetails", "Disabled", "details (system/EFI)");
351 break;
352 }
353 }
354 }
355
356 /* Secure Boot: */
357 if (fOptions & UIExtraDataMetaDefs::DetailsElementOptionTypeSystem_SecureBoot)
358 {
359 CNvramStore comStoreLvl1 = comMachine.GetNonVolatileStore();
360 if (comStoreLvl1.isNotNull())
361 {
362 CUefiVariableStore comStoreLvl2 = comStoreLvl1.GetUefiVariableStore();
363 /// @todo this comStoreLvl2.isNotNull() will never work for
364 /// now since VM reference is immutable in Details pane
365 if ( comStoreLvl2.isNotNull()
366 && comStoreLvl2.GetSecureBootEnabled())
367 {
368 table << UITextTableLine(QApplication::translate("UIDetails", "Secure Boot", "details (system)"),
369 QApplication::translate("UIDetails", "Enabled", "details (system/secure boot)"));
370 }
371 }
372 }
373
374 /* Acceleration: */
375 if (fOptions & UIExtraDataMetaDefs::DetailsElementOptionTypeSystem_Acceleration)
376 {
377 CPlatform comPlatform = comMachine.GetPlatform();
378 KPlatformArchitecture const platformArch = comPlatform.GetArchitecture();
379 switch (platformArch)
380 {
381 case KPlatformArchitecture_x86:
382 {
383 CPlatformX86 comPlatformX86 = comPlatform.GetX86();
384 QStringList acceleration;
385 if (uiCommon().virtualBox().GetHost().GetProcessorFeature(KProcessorFeature_HWVirtEx))
386 {
387 /* Nested Paging: */
388 if (comPlatformX86.GetHWVirtExProperty(KHWVirtExPropertyType_NestedPaging))
389 acceleration << QApplication::translate("UIDetails", "Nested Paging", "details (system)");
390 }
391 /* Nested VT-x/AMD-V: */
392 if (comPlatformX86.GetCPUProperty(KCPUPropertyTypeX86_HWVirt))
393 acceleration << QApplication::translate("UIDetails", "Nested VT-x/AMD-V", "details (system)");
394 /* PAE/NX: */
395 if (comPlatformX86.GetCPUProperty(KCPUPropertyTypeX86_PAE))
396 acceleration << QApplication::translate("UIDetails", "PAE/NX", "details (system)");
397
398 /* Paravirtualization provider: */
399 switch (comMachine.GetEffectiveParavirtProvider())
400 {
401 case KParavirtProvider_Minimal: acceleration << QApplication::translate("UIDetails", "Minimal Paravirtualization", "details (system)"); break;
402 case KParavirtProvider_HyperV: acceleration << QApplication::translate("UIDetails", "Hyper-V Paravirtualization", "details (system)"); break;
403 case KParavirtProvider_KVM: acceleration << QApplication::translate("UIDetails", "KVM Paravirtualization", "details (system)"); break;
404 default: break;
405 }
406 if (!acceleration.isEmpty())
407 table << UITextTableLine(QApplication::translate("UIDetails", "Acceleration", "details (system)"),
408 acceleration.join(", "));
409 break;
410 }
411
412#ifdef VBOX_WITH_VIRT_ARMV8
413 case KPlatformArchitecture_ARM:
414 {
415 /** @todo BUGBUG ARM stuff goes here. */
416 break;
417 }
418#endif
419 default:
420 break;
421 }
422 }
423
424 return table;
425}
426
427UITextTable UIDetailsGenerator::generateMachineInformationDisplay(CMachine &comMachine,
428 const UIExtraDataMetaDefs::DetailsElementOptionTypeDisplay &fOptions)
429{
430 UITextTable table;
431
432 if (comMachine.isNull())
433 return table;
434
435 if (!comMachine.GetAccessible())
436 {
437 table << UITextTableLine(QApplication::translate("UIDetails", "Information Inaccessible", "details"), QString());
438 return table;
439 }
440
441 const CGraphicsAdapter comGraphics = comMachine.GetGraphicsAdapter();
442
443 /* Video memory: */
444 if (fOptions & UIExtraDataMetaDefs::DetailsElementOptionTypeDisplay_VRAM)
445 {
446 /* Configure hovering anchor: */
447 const QString strAnchorType = QString("video_memory");
448 const int iVideoMemory = comGraphics.GetVRAMSize();
449 table << UITextTableLine(QApplication::translate("UIDetails", "Video Memory", "details (display)"),
450 QString("<a href=#%1,%2>%3</a>")
451 .arg(strAnchorType)
452 .arg(iVideoMemory)
453 .arg(QApplication::translate("UIDetails", "%1 MB").arg(iVideoMemory)));
454 }
455
456 /* Screens: */
457 if (fOptions & UIExtraDataMetaDefs::DetailsElementOptionTypeDisplay_ScreenCount)
458 {
459 const int cGuestScreens = comGraphics.GetMonitorCount();
460 if (cGuestScreens > 1)
461 table << UITextTableLine(QApplication::translate("UIDetails", "Screens", "details (display)"),
462 QString::number(cGuestScreens));
463 }
464
465 /* Scale-factor: */
466 if (fOptions & UIExtraDataMetaDefs::DetailsElementOptionTypeDisplay_ScaleFactor)
467 {
468 const QString strScaleFactor = comMachine.GetExtraData(UIExtraDataDefs::GUI_ScaleFactor);
469 {
470 /* Try to convert loaded data to double: */
471 bool fOk = false;
472 double dValue = strScaleFactor.toDouble(&fOk);
473 /* Invent the default value: */
474 if (!fOk || !dValue)
475 dValue = 1.0;
476 /* Append information: */
477 if (dValue != 1.0)
478 table << UITextTableLine(QApplication::translate("UIDetails", "Scale-factor", "details (display)"),
479 QString::number(dValue, 'f', 2));
480 }
481 }
482
483 /* Graphics Controller: */
484 if (fOptions & UIExtraDataMetaDefs::DetailsElementOptionTypeDisplay_GraphicsController)
485 {
486 const QString strAnchorType = QString("graphics_controller_type");
487 const KGraphicsControllerType enmType = comGraphics.GetGraphicsControllerType();
488 table << UITextTableLine(QApplication::translate("UIDetails", "Graphics Controller", "details (display)"),
489 QString("<a href=#%1,%2>%3</a>")
490 .arg(strAnchorType)
491 .arg((int)enmType)
492 .arg(gpConverter->toString(enmType)));
493 }
494
495 /* Acceleration: */
496 if (fOptions & UIExtraDataMetaDefs::DetailsElementOptionTypeDisplay_Acceleration)
497 {
498 QStringList acceleration;
499 /* 3D acceleration: */
500 if (comGraphics.GetAccelerate3DEnabled())
501 acceleration << QApplication::translate("UIDetails", "3D", "details (display)");
502 if (!acceleration.isEmpty())
503 table << UITextTableLine(QApplication::translate("UIDetails", "Acceleration", "details (display)"),
504 acceleration.join(", "));
505 }
506
507 /* Remote desktop server: */
508 if (fOptions & UIExtraDataMetaDefs::DetailsElementOptionTypeDisplay_VRDE)
509 {
510 const CVRDEServer comServer = comMachine.GetVRDEServer();
511 if (!comServer.isNull())
512 {
513 if (comServer.GetEnabled())
514 table << UITextTableLine(QApplication::translate("UIDetails", "Remote Desktop Server Port", "details (display/vrde)"),
515 comServer.GetVRDEProperty("TCP/Ports"));
516 else
517 table << UITextTableLine(QApplication::translate("UIDetails", "Remote Desktop Server", "details (display/vrde)"),
518 QApplication::translate("UIDetails", "Disabled", "details (display/vrde/VRDE server)"));
519 }
520 }
521
522 /* Recording: */
523 if (fOptions & UIExtraDataMetaDefs::DetailsElementOptionTypeDisplay_Recording)
524 {
525 CRecordingSettings comRecordingSettings = comMachine.GetRecordingSettings();
526 if (comRecordingSettings.GetEnabled())
527 {
528 /* For now all screens have the same config: */
529 const CRecordingScreenSettings comRecordingScreen0Settings = comRecordingSettings.GetScreenSettings(0);
530
531 /** @todo r=andy Refine these texts (wrt audio and/or video). */
532 table << UITextTableLine(QApplication::translate("UIDetails", "Recording File", "details (display/recording)"),
533 comRecordingScreen0Settings.GetFilename());
534 table << UITextTableLine(QApplication::translate("UIDetails", "Recording Attributes", "details (display/recording)"),
535 QApplication::translate("UIDetails", "Frame Size: %1x%2, Frame Rate: %3fps, Bit Rate: %4kbps")
536 .arg(comRecordingScreen0Settings.GetVideoWidth()).arg(comRecordingScreen0Settings.GetVideoHeight())
537 .arg(comRecordingScreen0Settings.GetVideoFPS()).arg(comRecordingScreen0Settings.GetVideoRate()));
538 }
539 else
540 {
541 table << UITextTableLine(QApplication::translate("UIDetails", "Recording", "details (display/recording)"),
542 QApplication::translate("UIDetails", "Disabled", "details (display/recording)"));
543 }
544 }
545
546 return table;
547}
548
549UITextTable UIDetailsGenerator::generateMachineInformationStorage(CMachine &comMachine,
550 const UIExtraDataMetaDefs::DetailsElementOptionTypeStorage &fOptions,
551 bool fLink /* = true */)
552{
553 UITextTable table;
554
555 if (comMachine.isNull())
556 return table;
557
558 if (!comMachine.GetAccessible())
559 {
560 table << UITextTableLine(QApplication::translate("UIDetails", "Information Inaccessible", "details"), QString());
561 return table;
562 }
563
564 /* Iterate over all the machine controllers: */
565 foreach (const CStorageController &comController, comMachine.GetStorageControllers())
566 {
567 /* Add controller information: */
568 const QString strControllerName = QApplication::translate("UIMachineSettingsStorage", "Controller: %1");
569 table << UITextTableLine(strControllerName.arg(comController.GetName()), QString());
570 /* Populate map (its sorted!): */
571 QMap<StorageSlot, QString> attachmentsMap;
572 foreach (const CMediumAttachment &attachment, comMachine.GetMediumAttachmentsOfController(comController.GetName()))
573 {
574 /* Acquire device type first of all: */
575 const KDeviceType enmDeviceType = attachment.GetType();
576
577 /* Ignore restricted device types: */
578 if ( ( !(fOptions & UIExtraDataMetaDefs::DetailsElementOptionTypeStorage_HardDisks)
579 && enmDeviceType == KDeviceType_HardDisk)
580 || ( !(fOptions & UIExtraDataMetaDefs::DetailsElementOptionTypeStorage_OpticalDevices)
581 && enmDeviceType == KDeviceType_DVD)
582 || ( !(fOptions & UIExtraDataMetaDefs::DetailsElementOptionTypeStorage_FloppyDevices)
583 && enmDeviceType == KDeviceType_Floppy))
584 continue;
585
586 /* Prepare current storage slot: */
587 const StorageSlot attachmentSlot(comController.GetBus(), attachment.GetPort(), attachment.GetDevice());
588 AssertMsg(comController.isOk(),
589 ("Unable to acquire controller data: %s\n",
590 UIErrorString::formatRC(comController.lastRC()).toUtf8().constData()));
591 if (!comController.isOk())
592 continue;
593
594 /* Prepare attachment information: */
595 QString strAttachmentInfo = uiCommon().storageDetails(attachment.GetMedium(), false, false);
596 /* That hack makes sure 'Inaccessible' word is always bold: */
597 { // hack
598 const QString strInaccessibleString(UICommon::tr("Inaccessible", "medium"));
599 const QString strBoldInaccessibleString(QString("<b>%1</b>").arg(strInaccessibleString));
600 strAttachmentInfo.replace(strInaccessibleString, strBoldInaccessibleString);
601 } // hack
602
603 /* Append 'device slot name' with 'device type name' for optical devices only: */
604 QString strDeviceType = enmDeviceType == KDeviceType_DVD
605 ? QApplication::translate("UIDetails", "[Optical Drive]", "details (storage)")
606 : QString();
607 if (!strDeviceType.isNull())
608 strDeviceType.append(' ');
609
610 /* Insert that attachment information into the map: */
611 if (!strAttachmentInfo.isNull())
612 {
613 /* Configure hovering anchors: */
614 const QString strAnchorType = enmDeviceType == KDeviceType_DVD || enmDeviceType == KDeviceType_Floppy ? QString("mount") :
615 enmDeviceType == KDeviceType_HardDisk ? QString("attach") : QString();
616 const CMedium medium = attachment.GetMedium();
617 const QString strMediumLocation = medium.isNull() ? QString() : medium.GetLocation();
618 if (fLink)
619 attachmentsMap.insert(attachmentSlot,
620 QString("<a href=#%1,%2,%3,%4>%5</a>")
621 .arg(strAnchorType,
622 comController.GetName(),
623 gpConverter->toString(attachmentSlot),
624 strMediumLocation,
625 strDeviceType + strAttachmentInfo));
626 else
627 attachmentsMap.insert(attachmentSlot,
628 QString("%1")
629 .arg(strDeviceType + strAttachmentInfo));
630 }
631 }
632
633 /* Iterate over the sorted map: */
634 const QList<StorageSlot> storageSlots = attachmentsMap.keys();
635 const QList<QString> storageInfo = attachmentsMap.values();
636 for (int i = 0; i < storageSlots.size(); ++i)
637 table << UITextTableLine(QString(" ") + gpConverter->toString(storageSlots[i]), storageInfo[i]);
638 }
639 if (table.isEmpty())
640 table << UITextTableLine(QApplication::translate("UIDetails", "Not Attached", "details (storage)"), QString());
641
642 return table;
643}
644
645UITextTable UIDetailsGenerator::generateMachineInformationAudio(CMachine &comMachine,
646 const UIExtraDataMetaDefs::DetailsElementOptionTypeAudio &fOptions)
647{
648 UITextTable table;
649
650 if (comMachine.isNull())
651 return table;
652
653 if (!comMachine.GetAccessible())
654 {
655 table << UITextTableLine(QApplication::translate("UIDetails", "Information Inaccessible", "details"), QString());
656 return table;
657 }
658
659 const CAudioSettings comAudioSettings = comMachine.GetAudioSettings();
660 const CAudioAdapter comAdapter = comAudioSettings.GetAdapter();
661 if (comAdapter.GetEnabled())
662 {
663 /* Host driver: */
664 if (fOptions & UIExtraDataMetaDefs::DetailsElementOptionTypeAudio_Driver)
665 {
666 const QString strAnchorType = QString("audio_host_driver_type");
667 const KAudioDriverType enmType = comAdapter.GetAudioDriver();
668 table << UITextTableLine(QApplication::translate("UIDetails", "Host Driver", "details (audio)"),
669 QString("<a href=#%1,%2>%3</a>")
670 .arg(strAnchorType)
671 .arg((int)enmType)
672 .arg(gpConverter->toString(enmType)));
673 }
674
675 /* Controller: */
676 if (fOptions & UIExtraDataMetaDefs::DetailsElementOptionTypeAudio_Controller)
677 {
678 const QString strAnchorType = QString("audio_controller_type");
679 const KAudioControllerType enmType = comAdapter.GetAudioController();
680 table << UITextTableLine(QApplication::translate("UIDetails", "Controller", "details (audio)"),
681 QString("<a href=#%1,%2>%3</a>")
682 .arg(strAnchorType)
683 .arg((int)enmType)
684 .arg(gpConverter->toString(enmType)));
685 }
686
687#ifdef VBOX_WITH_AUDIO_INOUT_INFO
688 /* Audio I/O: */
689 if (fOptions & UIExtraDataMetaDefs::DetailsElementOptionTypeAudio_IO)
690 {
691 table << UITextTableLine(QApplication::translate("UIDetails", "Audio Input", "details (audio)"),
692 comAdapter.GetEnabledIn() ?
693 QApplication::translate("UIDetails", "Enabled", "details (audio/input)") :
694 QApplication::translate("UIDetails", "Disabled", "details (audio/input)"));
695 table << UITextTableLine(QApplication::translate("UIDetails", "Audio Output", "details (audio)"),
696 comAdapter.GetEnabledOut() ?
697 QApplication::translate("UIDetails", "Enabled", "details (audio/output)") :
698 QApplication::translate("UIDetails", "Disabled", "details (audio/output)"));
699 }
700#endif /* VBOX_WITH_AUDIO_INOUT_INFO */
701 }
702 else
703 table << UITextTableLine(QApplication::translate("UIDetails", "Disabled", "details (audio)"),
704 QString());
705
706 return table;
707}
708
709QString summarizeGenericProperties(const CNetworkAdapter &comAdapter)
710{
711 QVector<QString> names;
712 QVector<QString> props;
713 props = comAdapter.GetProperties(QString(), names);
714 QString strResult;
715 for (int i = 0; i < names.size(); ++i)
716 {
717 strResult += names[i] + "=" + props[i];
718 if (i < names.size() - 1)
719 strResult += ", ";
720 }
721 return strResult;
722}
723
724UITextTable UIDetailsGenerator::generateMachineInformationNetwork(CMachine &comMachine,
725 const UIExtraDataMetaDefs::DetailsElementOptionTypeNetwork &fOptions)
726{
727 UITextTable table;
728
729 if (comMachine.isNull())
730 return table;
731
732 if (!comMachine.GetAccessible())
733 {
734 table << UITextTableLine(QApplication::translate("UIDetails", "Information Inaccessible", "details"), QString());
735 return table;
736 }
737
738 /* Iterate over all the adapters: */
739 CPlatformProperties comProperties = uiCommon().virtualBox().GetPlatformProperties(KPlatformArchitecture_x86);
740 CPlatform comPlatform = comMachine.GetPlatform();
741 const ulong uCount = comProperties.GetMaxNetworkAdapters(comPlatform.GetChipsetType());
742 for (ulong uSlot = 0; uSlot < uCount; ++uSlot)
743 {
744 const QString strAnchorType = QString("network_attachment_type");
745 const CNetworkAdapter comAdapter = comMachine.GetNetworkAdapter(uSlot);
746
747 /* Skip disabled adapters: */
748 if (!comAdapter.GetEnabled())
749 continue;
750
751 /* Gather adapter information: */
752 const KNetworkAttachmentType enmAttachmentType = comAdapter.GetAttachmentType();
753 const QString strAttachmentTemplate = gpConverter->toString(comAdapter.GetAdapterType()).replace(QRegularExpression("\\s\\(.+\\)"),
754 " (<a href=#%1,%2;%3;%4>%5</a>)");
755 QString strAttachmentType;
756 switch (enmAttachmentType)
757 {
758 case KNetworkAttachmentType_NAT:
759 {
760 if (fOptions & UIExtraDataMetaDefs::DetailsElementOptionTypeNetwork_NAT)
761 strAttachmentType = strAttachmentTemplate
762 .arg(strAnchorType)
763 .arg(uSlot)
764 .arg((int)KNetworkAttachmentType_NAT)
765 .arg(QString())
766 .arg(gpConverter->toString(KNetworkAttachmentType_NAT));
767 break;
768 }
769 case KNetworkAttachmentType_Bridged:
770 {
771 if (fOptions & UIExtraDataMetaDefs::DetailsElementOptionTypeNetwork_BridgedAdapter)
772 {
773 const QString strName = comAdapter.GetBridgedInterface();
774 strAttachmentType = strAttachmentTemplate
775 .arg(strAnchorType)
776 .arg(uSlot)
777 .arg((int)KNetworkAttachmentType_Bridged)
778 .arg(strName)
779 .arg(QApplication::translate("UIDetails", "Bridged Adapter, %1", "details (network)")
780 .arg(strName));
781 }
782 break;
783 }
784 case KNetworkAttachmentType_Internal:
785 {
786 if (fOptions & UIExtraDataMetaDefs::DetailsElementOptionTypeNetwork_InternalNetwork)
787 {
788 const QString strName = comAdapter.GetInternalNetwork();
789 strAttachmentType = strAttachmentTemplate
790 .arg(strAnchorType)
791 .arg(uSlot)
792 .arg((int)KNetworkAttachmentType_Internal)
793 .arg(strName)
794 .arg(QApplication::translate("UIDetails", "Internal Network, '%1'", "details (network)")
795 .arg(strName));
796 }
797 break;
798 }
799 case KNetworkAttachmentType_HostOnly:
800 {
801 if (fOptions & UIExtraDataMetaDefs::DetailsElementOptionTypeNetwork_HostOnlyAdapter)
802 {
803 const QString strName = comAdapter.GetHostOnlyInterface();
804 strAttachmentType = strAttachmentTemplate
805 .arg(strAnchorType)
806 .arg(uSlot)
807 .arg((int)KNetworkAttachmentType_HostOnly)
808 .arg(strName)
809 .arg(QApplication::translate("UIDetails", "Host-only Adapter, '%1'", "details (network)")
810 .arg(strName));
811 }
812 break;
813 }
814#ifdef VBOX_WITH_VMNET
815 case KNetworkAttachmentType_HostOnlyNetwork:
816 {
817 if (fOptions & UIExtraDataMetaDefs::DetailsElementOptionTypeNetwork_HostOnlyNetwork)
818 {
819 const QString strName = comAdapter.GetHostOnlyNetwork();
820 strAttachmentType = strAttachmentTemplate
821 .arg(strAnchorType)
822 .arg(uSlot)
823 .arg((int)KNetworkAttachmentType_HostOnly)
824 .arg(strName)
825 .arg(QApplication::translate("UIDetails", "Host-only Network, '%1'", "details (network)")
826 .arg(strName));
827 }
828 break;
829 }
830#endif /* VBOX_WITH_VMNET */
831 case KNetworkAttachmentType_Generic:
832 {
833 if (fOptions & UIExtraDataMetaDefs::DetailsElementOptionTypeNetwork_GenericDriver)
834 {
835 const QString strName = comAdapter.GetGenericDriver();
836 const QString strGenericDriverProperties(summarizeGenericProperties(comAdapter));
837 strAttachmentType = strGenericDriverProperties.isNull()
838 ? strAttachmentTemplate
839 .arg(strAnchorType)
840 .arg(uSlot)
841 .arg((int)KNetworkAttachmentType_Generic)
842 .arg(strName)
843 .arg(QApplication::translate("UIDetails", "Generic Driver, '%1'", "details (network)")
844 .arg(strName))
845 : strAttachmentTemplate
846 .arg(strAnchorType)
847 .arg(uSlot)
848 .arg((int)KNetworkAttachmentType_Generic)
849 .arg(strName)
850 .arg(QApplication::translate("UIDetails", "Generic Driver, '%1' { %2 }", "details (network)")
851 .arg(strName, strGenericDriverProperties));
852 }
853 break;
854 }
855 case KNetworkAttachmentType_NATNetwork:
856 {
857 if (fOptions & UIExtraDataMetaDefs::DetailsElementOptionTypeNetwork_NATNetwork)
858 {
859 const QString strName = comAdapter.GetNATNetwork();
860 strAttachmentType = strAttachmentTemplate
861 .arg(strAnchorType)
862 .arg(uSlot)
863 .arg((int)KNetworkAttachmentType_NATNetwork)
864 .arg(strName)
865 .arg(QApplication::translate("UIDetails", "NAT Network, '%1'", "details (network)")
866 .arg(strName));
867 }
868 break;
869 }
870 default:
871 {
872 if (fOptions & UIExtraDataMetaDefs::DetailsElementOptionTypeNetwork_NotAttached)
873 strAttachmentType = strAttachmentTemplate
874 .arg(strAnchorType)
875 .arg(uSlot)
876 .arg((int)enmAttachmentType)
877 .arg(QString())
878 .arg(gpConverter->toString(enmAttachmentType));
879 break;
880 }
881 }
882 if (!strAttachmentType.isNull())
883 table << UITextTableLine(QApplication::translate("UIDetails", "Adapter %1", "details (network)").arg(comAdapter.GetSlot() + 1), strAttachmentType);
884 }
885 if (table.isEmpty())
886 table << UITextTableLine(QApplication::translate("UIDetails", "Disabled", "details (network/adapter)"), QString());
887
888 return table;
889}
890
891UITextTable UIDetailsGenerator::generateMachineInformationSerial(CMachine &comMachine,
892 const UIExtraDataMetaDefs::DetailsElementOptionTypeSerial &fOptions)
893{
894 UITextTable table;
895
896 if (comMachine.isNull())
897 return table;
898
899 if (!comMachine.GetAccessible())
900 {
901 table << UITextTableLine(QApplication::translate("UIDetails", "Information Inaccessible", "details"), QString());
902 return table;
903 }
904
905 /* Iterate over all the ports: */
906 CPlatformProperties comProperties = uiCommon().virtualBox().GetPlatformProperties(KPlatformArchitecture_x86);
907 const ulong uCount = comProperties.GetSerialPortCount();
908 for (ulong uSlot = 0; uSlot < uCount; ++uSlot)
909 {
910 const CSerialPort comPort = comMachine.GetSerialPort(uSlot);
911
912 /* Skip disabled adapters: */
913 if (!comPort.GetEnabled())
914 continue;
915
916 /* Gather port information: */
917 const KPortMode enmMode = comPort.GetHostMode();
918 const QString strModeTemplate = UITranslator::toCOMPortName(comPort.GetIRQ(), comPort.GetIOAddress()) + ", ";
919 QString strModeType;
920 switch (enmMode)
921 {
922 case KPortMode_HostPipe:
923 {
924 if (fOptions & UIExtraDataMetaDefs::DetailsElementOptionTypeSerial_HostPipe)
925 strModeType = strModeTemplate + QString("%1 (%2)").arg(gpConverter->toString(enmMode)).arg(QDir::toNativeSeparators(comPort.GetPath()));
926 break;
927 }
928 case KPortMode_HostDevice:
929 {
930 if (fOptions & UIExtraDataMetaDefs::DetailsElementOptionTypeSerial_HostDevice)
931 strModeType = strModeTemplate + QString("%1 (%2)").arg(gpConverter->toString(enmMode)).arg(QDir::toNativeSeparators(comPort.GetPath()));
932 break;
933 }
934 case KPortMode_RawFile:
935 {
936 if (fOptions & UIExtraDataMetaDefs::DetailsElementOptionTypeSerial_RawFile)
937 strModeType = strModeTemplate + QString("%1 (%2)").arg(gpConverter->toString(enmMode)).arg(QDir::toNativeSeparators(comPort.GetPath()));
938 break;
939 }
940 case KPortMode_TCP:
941 {
942 if (fOptions & UIExtraDataMetaDefs::DetailsElementOptionTypeSerial_TCP)
943 strModeType = strModeTemplate + QString("%1 (%2)").arg(gpConverter->toString(enmMode)).arg(QDir::toNativeSeparators(comPort.GetPath()));
944 break;
945 }
946 default:
947 {
948 if (fOptions & UIExtraDataMetaDefs::DetailsElementOptionTypeSerial_Disconnected)
949 strModeType = strModeTemplate + gpConverter->toString(enmMode);
950 break;
951 }
952 }
953 if (!strModeType.isNull())
954 table << UITextTableLine(QApplication::translate("UIDetails", "Port %1", "details (serial)").arg(comPort.GetSlot() + 1), strModeType);
955 }
956 if (table.isEmpty())
957 table << UITextTableLine(QApplication::translate("UIDetails", "Disabled", "details (serial)"), QString());
958
959 return table;
960}
961
962UITextTable UIDetailsGenerator::generateMachineInformationUSB(CMachine &comMachine,
963 const UIExtraDataMetaDefs::DetailsElementOptionTypeUsb &fOptions)
964{
965 UITextTable table;
966
967 if (comMachine.isNull())
968 return table;
969
970 if (!comMachine.GetAccessible())
971 {
972 table << UITextTableLine(QApplication::translate("UIDetails", "Information Inaccessible", "details"), QString());
973 return table;
974 }
975
976 /* Iterate over all the USB filters: */
977 const CUSBDeviceFilters comFilterObject = comMachine.GetUSBDeviceFilters();
978 if (!comFilterObject.isNull() && comMachine.GetUSBProxyAvailable())
979 {
980 const QString strAnchorType = QString("usb_controller_type");
981 const CUSBControllerVector controllers = comMachine.GetUSBControllers();
982 if (!controllers.isEmpty())
983 {
984 /* USB controllers: */
985 if (fOptions & UIExtraDataMetaDefs::DetailsElementOptionTypeUsb_Controller)
986 {
987 QStringList controllerInternal;
988 QStringList controllersReadable;
989 foreach (const CUSBController &comController, controllers)
990 {
991 const KUSBControllerType enmType = comController.GetType();
992 controllerInternal << QString::number((int)enmType);
993 controllersReadable << gpConverter->toString(enmType);
994 }
995 table << UITextTableLine(QApplication::translate("UIDetails", "USB Controller", "details (usb)"),
996 QString("<a href=#%1,%2>%3</a>")
997 .arg(strAnchorType)
998 .arg(controllerInternal.join(';'))
999 .arg(controllersReadable.join(", ")));
1000 }
1001
1002 /* Device filters: */
1003 if (fOptions & UIExtraDataMetaDefs::DetailsElementOptionTypeUsb_DeviceFilters)
1004 {
1005 const CUSBDeviceFilterVector filters = comFilterObject.GetDeviceFilters();
1006 uint uActive = 0;
1007 for (int i = 0; i < filters.size(); ++i)
1008 if (filters.at(i).GetActive())
1009 ++uActive;
1010 table << UITextTableLine(QApplication::translate("UIDetails", "Device Filters", "details (usb)"),
1011 QApplication::translate("UIDetails", "%1 (%2 active)", "details (usb)").arg(filters.size()).arg(uActive));
1012 }
1013 }
1014 else
1015 table << UITextTableLine(QString("<a href=#%1,%2>%3</a>")
1016 .arg(strAnchorType)
1017 .arg(QString::number((int)KUSBControllerType_Null))
1018 .arg(QApplication::translate("UIDetails", "Disabled", "details (usb)")),
1019 QString());
1020 }
1021 else
1022 table << UITextTableLine(QApplication::translate("UIDetails", "USB Controller Inaccessible", "details (usb)"), QString());
1023
1024 return table;
1025}
1026
1027UITextTable UIDetailsGenerator::generateMachineInformationSharedFolders(CMachine &comMachine,
1028 const UIExtraDataMetaDefs::DetailsElementOptionTypeSharedFolders &fOptions)
1029{
1030 Q_UNUSED(fOptions);
1031
1032 UITextTable table;
1033
1034 if (comMachine.isNull())
1035 return table;
1036
1037 if (!comMachine.GetAccessible())
1038 {
1039 table << UITextTableLine(QApplication::translate("UIDetails", "Information Inaccessible", "details"), QString());
1040 return table;
1041 }
1042
1043 /* Summary: */
1044 const ulong uCount = comMachine.GetSharedFolders().size();
1045 if (uCount > 0)
1046 table << UITextTableLine(QApplication::translate("UIDetails", "Shared Folders", "details (shared folders)"), QString::number(uCount));
1047 else
1048 table << UITextTableLine(QApplication::translate("UIDetails", "None", "details (shared folders)"), QString());
1049
1050 return table;
1051}
1052
1053UITextTable UIDetailsGenerator::generateMachineInformationUI(CMachine &comMachine,
1054 const UIExtraDataMetaDefs::DetailsElementOptionTypeUserInterface &fOptions)
1055{
1056 UITextTable table;
1057
1058 if (comMachine.isNull())
1059 return table;
1060
1061 if (!comMachine.GetAccessible())
1062 {
1063 table << UITextTableLine(QApplication::translate("UIDetails", "Information Inaccessible", "details"), QString());
1064 return table;
1065 }
1066
1067 /* Visual state: */
1068 if (fOptions & UIExtraDataMetaDefs::DetailsElementOptionTypeUserInterface_VisualState)
1069 {
1070 const QString strAnchorType = QString("visual_state");
1071 const QString strEnabledFullscreen = comMachine.GetExtraData(UIExtraDataDefs::GUI_Fullscreen);
1072 const QString strEnabledSeamless = comMachine.GetExtraData(UIExtraDataDefs::GUI_Seamless);
1073 const QString strEnabledScale = comMachine.GetExtraData(UIExtraDataDefs::GUI_Scale);
1074 UIVisualStateType enmType = UIVisualStateType_Normal;
1075 if ( strEnabledFullscreen.compare("true", Qt::CaseInsensitive) == 0
1076 || strEnabledFullscreen.compare("yes", Qt::CaseInsensitive) == 0
1077 || strEnabledFullscreen.compare("on", Qt::CaseInsensitive) == 0
1078 || strEnabledFullscreen == "1")
1079 enmType = UIVisualStateType_Fullscreen;
1080 else
1081 if ( strEnabledSeamless.compare("true", Qt::CaseInsensitive) == 0
1082 || strEnabledSeamless.compare("yes", Qt::CaseInsensitive) == 0
1083 || strEnabledSeamless.compare("on", Qt::CaseInsensitive) == 0
1084 || strEnabledSeamless == "1")
1085 enmType = UIVisualStateType_Seamless;
1086 else
1087 if ( strEnabledScale.compare("true", Qt::CaseInsensitive) == 0
1088 || strEnabledScale.compare("yes", Qt::CaseInsensitive) == 0
1089 || strEnabledScale.compare("on", Qt::CaseInsensitive) == 0
1090 || strEnabledScale == "1")
1091 enmType = UIVisualStateType_Scale;
1092 const QString strVisualState = gpConverter->toString(enmType);
1093 table << UITextTableLine(QApplication::translate("UIDetails", "Visual State", "details (user interface)"),
1094 QString("<a href=#%1,%2>%3</a>")
1095 .arg(strAnchorType)
1096 .arg(enmType)
1097 .arg(strVisualState));
1098 }
1099
1100#ifndef VBOX_WS_MAC
1101 /* Menu-bar: */
1102 if (fOptions & UIExtraDataMetaDefs::DetailsElementOptionTypeUserInterface_MenuBar)
1103 {
1104 const QString strAnchorType = QString("menu_bar");
1105 const QString strMenubarEnabled = comMachine.GetExtraData(UIExtraDataDefs::GUI_MenuBar_Enabled);
1106 const bool fEnabled = !( strMenubarEnabled.compare("false", Qt::CaseInsensitive) == 0
1107 || strMenubarEnabled.compare("no", Qt::CaseInsensitive) == 0
1108 || strMenubarEnabled.compare("off", Qt::CaseInsensitive) == 0
1109 || strMenubarEnabled == "0");
1110 table << UITextTableLine(QApplication::translate("UIDetails", "Menu-bar", "details (user interface)"),
1111 QString("<a href=#%1,%2>%3</a>")
1112 .arg(strAnchorType)
1113 .arg((int)fEnabled)
1114 .arg(fEnabled ? QApplication::translate("UIDetails", "Enabled", "details (user interface/menu-bar)")
1115 : QApplication::translate("UIDetails", "Disabled", "details (user interface/menu-bar)")));
1116 }
1117#endif /* !VBOX_WS_MAC */
1118
1119 /* Status-bar: */
1120 if (fOptions & UIExtraDataMetaDefs::DetailsElementOptionTypeUserInterface_StatusBar)
1121 {
1122 const QString strAnchorType = QString("status_bar");
1123 const QString strStatusbarEnabled = comMachine.GetExtraData(UIExtraDataDefs::GUI_StatusBar_Enabled);
1124 const bool fEnabled = !( strStatusbarEnabled.compare("false", Qt::CaseInsensitive) == 0
1125 || strStatusbarEnabled.compare("no", Qt::CaseInsensitive) == 0
1126 || strStatusbarEnabled.compare("off", Qt::CaseInsensitive) == 0
1127 || strStatusbarEnabled == "0");
1128 table << UITextTableLine(QApplication::translate("UIDetails", "Status-bar", "details (user interface)"),
1129 QString("<a href=#%1,%2>%3</a>")
1130 .arg(strAnchorType)
1131 .arg((int)fEnabled)
1132 .arg(fEnabled ? QApplication::translate("UIDetails", "Enabled", "details (user interface/status-bar)")
1133 : QApplication::translate("UIDetails", "Disabled", "details (user interface/status-bar)")));
1134 }
1135
1136#ifndef VBOX_WS_MAC
1137 /* Mini-toolbar: */
1138 if (fOptions & UIExtraDataMetaDefs::DetailsElementOptionTypeUserInterface_MiniToolbar)
1139 {
1140 const QString strAnchorType = QString("mini_toolbar");
1141 const QString strMiniToolbarEnabled = comMachine.GetExtraData(UIExtraDataDefs::GUI_ShowMiniToolBar);
1142 const bool fEnabled = !( strMiniToolbarEnabled.compare("false", Qt::CaseInsensitive) == 0
1143 || strMiniToolbarEnabled.compare("no", Qt::CaseInsensitive) == 0
1144 || strMiniToolbarEnabled.compare("off", Qt::CaseInsensitive) == 0
1145 || strMiniToolbarEnabled == "0");
1146 if (fEnabled)
1147 {
1148 /* Get mini-toolbar position: */
1149 const QString strMiniToolbarPosition = comMachine.GetExtraData(UIExtraDataDefs::GUI_MiniToolBarAlignment);
1150 {
1151 /* Try to convert loaded data to alignment: */
1152 switch (gpConverter->fromInternalString<MiniToolbarAlignment>(strMiniToolbarPosition))
1153 {
1154 case MiniToolbarAlignment_Top:
1155 table << UITextTableLine(QApplication::translate("UIDetails", "Mini-toolbar Position", "details (user interface)"),
1156 QString("<a href=#%1,%2>%3</a>")
1157 .arg(strAnchorType)
1158 .arg((int)MiniToolbarAlignment_Top)
1159 .arg(QApplication::translate("UIDetails", "Top", "details (user interface/mini-toolbar position)")));
1160 break;
1161 case MiniToolbarAlignment_Bottom:
1162 table << UITextTableLine(QApplication::translate("UIDetails", "Mini-toolbar Position", "details (user interface)"),
1163 QString("<a href=#%1,%2>%3</a>")
1164 .arg(strAnchorType)
1165 .arg((int)MiniToolbarAlignment_Bottom)
1166 .arg(QApplication::translate("UIDetails", "Bottom", "details (user interface/mini-toolbar position)")));
1167 break;
1168 default:
1169 break;
1170 }
1171 }
1172 }
1173 else
1174 table << UITextTableLine(QApplication::translate("UIDetails", "Mini-toolbar", "details (user interface)"),
1175 QString("<a href=#%1,%2>%3</a>")
1176 .arg(strAnchorType)
1177 .arg((int)MiniToolbarAlignment_Disabled)
1178 .arg(QApplication::translate("UIDetails", "Disabled", "details (user interface/mini-toolbar)")));
1179 }
1180#endif /* !VBOX_WS_MAC */
1181
1182 return table;
1183}
1184
1185UITextTable UIDetailsGenerator::generateMachineInformationDescription(CMachine &comMachine,
1186 const UIExtraDataMetaDefs::DetailsElementOptionTypeDescription &fOptions)
1187{
1188 Q_UNUSED(fOptions);
1189
1190 UITextTable table;
1191
1192 if (comMachine.isNull())
1193 return table;
1194
1195 if (!comMachine.GetAccessible())
1196 {
1197 table << UITextTableLine(QApplication::translate("UIDetails", "Information Inaccessible", "details"), QString());
1198 return table;
1199 }
1200
1201 /* Summary: */
1202 const QString strDescription = comMachine.GetDescription();
1203 if (!strDescription.isEmpty())
1204 table << UITextTableLine(strDescription, QString());
1205 else
1206 table << UITextTableLine(QApplication::translate("UIDetails", "None", "details (description)"), QString());
1207
1208 return table;
1209}
1210
1211void UIDetailsGenerator::acquireHardDiskStatusInfo(CMachine &comMachine, QString &strInfo,
1212 bool &fAttachmentsPresent)
1213{
1214 /* Enumerate all the controllers: */
1215 foreach (const CStorageController &comController, comMachine.GetStorageControllers())
1216 {
1217 /* Enumerate all the attachments: */
1218 QString strAttData;
1219 foreach (const CMediumAttachment &comAttachment, comMachine.GetMediumAttachmentsOfController(comController.GetName()))
1220 {
1221 /* Skip unrelated attachments: */
1222 if (comAttachment.GetType() != KDeviceType_HardDisk)
1223 continue;
1224 /* Append attachment data: */
1225 strAttData += e_strTableRow3
1226 .arg(gpConverter->toString(StorageSlot(comController.GetBus(), comAttachment.GetPort(), comAttachment.GetDevice())))
1227 .arg(UIMedium(comAttachment.GetMedium(), UIMediumDeviceType_HardDisk).location());
1228 fAttachmentsPresent = true;
1229 }
1230 /* Append controller data: */
1231 if (!strAttData.isNull())
1232 strInfo += e_strTableRow1.arg(comController.GetName()) + strAttData;
1233 }
1234}
1235
1236void UIDetailsGenerator::acquireOpticalDiskStatusInfo(CMachine &comMachine, QString &strInfo,
1237 bool &fAttachmentsPresent, bool &fAttachmentsMounted)
1238{
1239 /* Enumerate all the controllers: */
1240 foreach (const CStorageController &comController, comMachine.GetStorageControllers())
1241 {
1242 QString strAttData;
1243 /* Enumerate all the attachments: */
1244 foreach (const CMediumAttachment &comAttachment, comMachine.GetMediumAttachmentsOfController(comController.GetName()))
1245 {
1246 /* Skip unrelated attachments: */
1247 if (comAttachment.GetType() != KDeviceType_DVD)
1248 continue;
1249 /* Append attachment data: */
1250 UIMedium vboxMedium(comAttachment.GetMedium(), UIMediumDeviceType_DVD);
1251 strAttData += e_strTableRow3
1252 .arg(gpConverter->toString(StorageSlot(comController.GetBus(), comAttachment.GetPort(), comAttachment.GetDevice())))
1253 .arg(vboxMedium.isNull() || vboxMedium.isHostDrive() ? vboxMedium.name() : vboxMedium.location());
1254 fAttachmentsPresent = true;
1255 if (!vboxMedium.isNull())
1256 fAttachmentsMounted = true;
1257 }
1258 /* Append controller data: */
1259 if (!strAttData.isNull())
1260 strInfo += e_strTableRow1.arg(comController.GetName()) + strAttData;
1261 }
1262}
1263
1264void UIDetailsGenerator::acquireFloppyDiskStatusInfo(CMachine &comMachine, QString &strInfo,
1265 bool &fAttachmentsPresent, bool &fAttachmentsMounted)
1266{
1267 /* Enumerate all the controllers: */
1268 foreach (const CStorageController &comController, comMachine.GetStorageControllers())
1269 {
1270 QString strAttData;
1271 /* Enumerate all the attachments: */
1272 foreach (const CMediumAttachment &comAttachment, comMachine.GetMediumAttachmentsOfController(comController.GetName()))
1273 {
1274 /* Skip unrelated attachments: */
1275 if (comAttachment.GetType() != KDeviceType_Floppy)
1276 continue;
1277 /* Append attachment data: */
1278 UIMedium vboxMedium(comAttachment.GetMedium(), UIMediumDeviceType_Floppy);
1279 strAttData += e_strTableRow3
1280 .arg(gpConverter->toString(StorageSlot(comController.GetBus(), comAttachment.GetPort(), comAttachment.GetDevice())))
1281 .arg(vboxMedium.isNull() || vboxMedium.isHostDrive() ? vboxMedium.name() : vboxMedium.location());
1282 fAttachmentsPresent = true;
1283 if (!vboxMedium.isNull())
1284 fAttachmentsMounted = true;
1285 }
1286 /* Append controller data: */
1287 if (!strAttData.isNull())
1288 strInfo += e_strTableRow1.arg(comController.GetName()) + strAttData;
1289 }
1290}
1291
1292void UIDetailsGenerator::acquireAudioStatusInfo(CMachine &comMachine, QString &strInfo,
1293 bool &fAudioEnabled, bool &fEnabledOutput, bool &fEnabledInput)
1294{
1295 /* Get audio settings & adapter: */
1296 const CAudioSettings comAudioSettings = comMachine.GetAudioSettings();
1297 const CAudioAdapter comAdapter = comAudioSettings.GetAdapter();
1298 fAudioEnabled = comAdapter.GetEnabled();
1299 if (fAudioEnabled)
1300 {
1301 fEnabledOutput = comAdapter.GetEnabledOut();
1302 fEnabledInput = comAdapter.GetEnabledIn();
1303 strInfo = QString(e_strTableRow2).arg(QApplication::translate("UIDetails", "Audio Output", "details (audio)"),
1304 fEnabledOutput ?
1305 QApplication::translate("UIDetails", "Enabled", "details (audio/output)") :
1306 QApplication::translate("UIDetails", "Disabled", "details (audio/output)"))
1307 + QString(e_strTableRow2).arg(QApplication::translate("UIDetails", "Audio Input", "details (audio)"),
1308 fEnabledInput ?
1309 QApplication::translate("UIDetails", "Enabled", "details (audio/input)") :
1310 QApplication::translate("UIDetails", "Disabled", "details (audio/input)"));
1311 }
1312}
1313
1314void UIDetailsGenerator::acquireNetworkStatusInfo(CMachine &comMachine, QString &strInfo,
1315 bool &fAdaptersPresent, bool &fCablesDisconnected)
1316{
1317 /* Determine max amount of network adapters: */
1318 CVirtualBox comVBox = uiCommon().virtualBox();
1319 CPlatform comPlatform = comMachine.GetPlatform();
1320 const KChipsetType enmChipsetType = comPlatform.GetChipsetType();
1321 CPlatformProperties comPlatformProperties = comVBox.GetPlatformProperties(KPlatformArchitecture_x86);
1322 const ulong cMaxNetworkAdapters = comPlatformProperties.GetMaxNetworkAdapters(enmChipsetType);
1323
1324 /* Gather adapter properties: */
1325 RTTIMESPEC time;
1326 uint64_t u64Now = RTTimeSpecGetNano(RTTimeNow(&time));
1327 QString strFlags, strCount;
1328 LONG64 iTimestamp;
1329 comMachine.GetGuestProperty("/VirtualBox/GuestInfo/Net/Count", strCount, iTimestamp, strFlags);
1330 bool fPropsValid = (u64Now - iTimestamp < UINT64_C(60000000000)); /* timeout beacon */
1331 QStringList ipList, macList;
1332 if (fPropsValid)
1333 {
1334 const ulong cAdapters = qMin(strCount.toULong(), cMaxNetworkAdapters);
1335 for (ulong i = 0; i < cAdapters; ++i)
1336 {
1337 ipList << comMachine.GetGuestPropertyValue(QString("/VirtualBox/GuestInfo/Net/%1/V4/IP").arg(i));
1338 macList << comMachine.GetGuestPropertyValue(QString("/VirtualBox/GuestInfo/Net/%1/MAC").arg(i));
1339 }
1340 }
1341
1342 /* Enumerate up to cMaxNetworkAdapters adapters: */
1343 for (ulong uSlot = 0; uSlot < cMaxNetworkAdapters; ++uSlot)
1344 {
1345 const CNetworkAdapter &comAdapter = comMachine.GetNetworkAdapter(uSlot);
1346 if (comMachine.isOk() && !comAdapter.isNull() && comAdapter.GetEnabled())
1347 {
1348 fAdaptersPresent = true;
1349 QString strGuestIp;
1350 if (fPropsValid)
1351 {
1352 const QString strGuestMac = comAdapter.GetMACAddress();
1353 const int iIp = macList.indexOf(strGuestMac);
1354 if (iIp >= 0)
1355 strGuestIp = ipList.at(iIp);
1356 }
1357 /* Check if the adapter's cable is connected: */
1358 const bool fCableConnected = comAdapter.GetCableConnected();
1359 if (fCablesDisconnected && fCableConnected)
1360 fCablesDisconnected = false;
1361 /* Append adapter data: */
1362 strInfo += e_strTableRow1
1363 .arg(QApplication::translate("UIIndicatorsPool", "Adapter %1 (%2)", "Network tooltip")
1364 .arg(uSlot + 1).arg(gpConverter->toString(comAdapter.GetAttachmentType())));
1365 if (!strGuestIp.isEmpty())
1366 strInfo += e_strTableRow3
1367 .arg(QApplication::translate("UIIndicatorsPool", "IP", "Network tooltip"), strGuestIp);
1368 strInfo += e_strTableRow3
1369 .arg(QApplication::translate("UIIndicatorsPool", "Cable", "Network tooltip"))
1370 .arg(fCableConnected ?
1371 QApplication::translate("UIIndicatorsPool", "Connected", "cable (Network tooltip)") :
1372 QApplication::translate("UIIndicatorsPool", "Disconnected", "cable (Network tooltip)"));
1373 }
1374 }
1375}
1376
1377void UIDetailsGenerator::acquireUsbStatusInfo(CMachine &comMachine, CConsole &comConsole,
1378 QString &strInfo, bool &fUsbEnabled)
1379{
1380 /* Check whether there is at least one USB controller with an available proxy: */
1381 fUsbEnabled = !comMachine.GetUSBDeviceFilters().isNull()
1382 && !comMachine.GetUSBControllers().isEmpty()
1383 && comMachine.GetUSBProxyAvailable();
1384 if (fUsbEnabled)
1385 {
1386 /* Enumerate all the USB devices: */
1387 foreach (const CUSBDevice &comUsbDevice, comConsole.GetUSBDevices())
1388 strInfo += e_strTableRow1.arg(uiCommon().usbDetails(comUsbDevice));
1389 /* Handle 'no-usb-devices' case: */
1390 if (strInfo.isNull())
1391 strInfo = e_strTableRow1
1392 .arg(QApplication::translate("UIIndicatorsPool", "No USB devices attached", "USB tooltip"));
1393 }
1394}
1395
1396void UIDetailsGenerator::acquireSharedFoldersStatusInfo(CMachine &comMachine, CConsole &comConsole, CGuest &comGuest,
1397 QString &strInfo, bool &fFoldersPresent)
1398{
1399 /* Enumerate all the folders: */
1400 QMap<QString, QString> folders;
1401 foreach (const CSharedFolder &comPermanentFolder, comMachine.GetSharedFolders())
1402 folders.insert(comPermanentFolder.GetName(), comPermanentFolder.GetHostPath());
1403 foreach (const CSharedFolder &comTemporaryFolder, comConsole.GetSharedFolders())
1404 folders.insert(comTemporaryFolder.GetName(), comTemporaryFolder.GetHostPath());
1405 fFoldersPresent = !folders.isEmpty();
1406
1407 /* Append attachment data: */
1408 for (QMap<QString, QString>::const_iterator it = folders.constBegin(); it != folders.constEnd(); ++it)
1409 {
1410 /* Select slashes depending on the OS type: */
1411 if (UICommon::isDOSType(comGuest.GetOSTypeId()))
1412 strInfo += e_strTableRow2.arg(QString("<b>\\\\vboxsvr\\%1</b>").arg(it.key()), it.value());
1413 else
1414 strInfo += e_strTableRow2.arg(QString("<b>%1</b>").arg(it.key()), it.value());
1415 }
1416
1417 /* Handle 'no-folders' case: */
1418 if (!fFoldersPresent)
1419 strInfo = e_strTableRow1
1420 .arg(QApplication::translate("UIIndicatorsPool", "No shared folders", "Shared folders tooltip"));
1421}
1422
1423void UIDetailsGenerator::acquireDisplayStatusInfo(CMachine &comMachine, QString &strInfo,
1424 bool &fAcceleration3D)
1425{
1426 /* Get graphics adapter: */
1427 CGraphicsAdapter comGraphics = comMachine.GetGraphicsAdapter();
1428
1429 /* Video Memory: */
1430 const ULONG uVRAMSize = comGraphics.GetVRAMSize();
1431 const QString strVRAMSize = UICommon::tr("<nobr>%1 MB</nobr>", "details report").arg(uVRAMSize);
1432 strInfo += e_strTableRow2
1433 .arg(QApplication::translate("UIIndicatorsPool", "Video memory", "Display tooltip"), strVRAMSize);
1434
1435 /* Monitor Count: */
1436 const ULONG uMonitorCount = comGraphics.GetMonitorCount();
1437 if (uMonitorCount > 1)
1438 {
1439 const QString strMonitorCount = QString::number(uMonitorCount);
1440 strInfo += e_strTableRow2
1441 .arg(QApplication::translate("UIIndicatorsPool", "Screens", "Display tooltip"), strMonitorCount);
1442 }
1443
1444 /* 3D acceleration: */
1445 fAcceleration3D = comGraphics.GetAccelerate3DEnabled();
1446 if (fAcceleration3D)
1447 {
1448 const QString strAcceleration3D = fAcceleration3D
1449 ? UICommon::tr("Enabled", "details report (3D Acceleration)")
1450 : UICommon::tr("Disabled", "details report (3D Acceleration)");
1451 strInfo += e_strTableRow2
1452 .arg(QApplication::translate("UIIndicatorsPool", "3D acceleration", "Display tooltip"), strAcceleration3D);
1453 }
1454}
1455
1456void UIDetailsGenerator::acquireRecordingStatusInfo(CMachine &comMachine, QString &strInfo,
1457 bool &fRecordingEnabled)
1458{
1459 /* Get recording settings: */
1460 CRecordingSettings comRecordingSettings = comMachine.GetRecordingSettings();
1461 fRecordingEnabled = comRecordingSettings.GetEnabled();
1462 if (fRecordingEnabled)
1463 {
1464 /* For now all screens have the same config: */
1465 CRecordingScreenSettings comRecordingScreen0Settings = comRecordingSettings.GetScreenSettings(0);
1466 const bool fVideoEnabled = comRecordingScreen0Settings.IsFeatureEnabled(KRecordingFeature_Video);
1467 const bool fAudioEnabled = comRecordingScreen0Settings.IsFeatureEnabled(KRecordingFeature_Audio);
1468
1469 /* Compose tool-tip: */
1470 QString strToolTip;
1471 if (fVideoEnabled && fAudioEnabled)
1472 strToolTip = QApplication::translate("UIIndicatorsPool", "Video/audio recording file", "Recording tooltip");
1473 else if (fAudioEnabled)
1474 strToolTip = QApplication::translate("UIIndicatorsPool", "Audio recording file", "Recording tooltip");
1475 else if (fVideoEnabled)
1476 strToolTip = QApplication::translate("UIIndicatorsPool", "Video recording file", "Recording tooltip");
1477 strInfo += e_strTableRow2
1478 .arg(strToolTip)
1479 .arg(comRecordingScreen0Settings.GetFilename());
1480 }
1481 /* Handle 'no-recording' case: */
1482 else
1483 {
1484 strInfo += e_strTableRow1
1485 .arg(QApplication::translate("UIIndicatorsPool", "Recording disabled", "Recording tooltip"));
1486 }
1487}
1488
1489void UIDetailsGenerator::acquireFeaturesStatusInfo(CMachine &comMachine, QString &strInfo,
1490 KVMExecutionEngine &enmEngine,
1491 bool fNestedPagingEnabled, bool fUxEnabled,
1492 KParavirtProvider enmProvider)
1493{
1494 /* VT-x/AMD-V feature: */
1495 QString strExecutionEngine;
1496 switch (enmEngine)
1497 {
1498 case KVMExecutionEngine_Emulated:
1499 strExecutionEngine = "IEM"; /* no translation */
1500 break;
1501 case KVMExecutionEngine_HwVirt:
1502 strExecutionEngine = "VT-x/AMD-V"; /* no translation */
1503 break;
1504 case KVMExecutionEngine_NativeApi:
1505 strExecutionEngine = "native API"; /* no translation */
1506 break;
1507 default:
1508 AssertFailed();
1509 enmEngine = KVMExecutionEngine_NotSet;
1510 RT_FALL_THRU();
1511 case KVMExecutionEngine_NotSet:
1512 strExecutionEngine = UICommon::tr("not set", "details report (execution engine)");
1513 break;
1514 }
1515
1516 /* Nested Paging feature: */
1517 const QString strNestedPaging = fNestedPagingEnabled
1518 ? UICommon::tr("Active", "details report (Nested Paging)")
1519 : UICommon::tr("Inactive", "details report (Nested Paging)");
1520
1521 /* Unrestricted Execution feature: */
1522 const QString strUnrestrictExec = fUxEnabled
1523 ? UICommon::tr("Active", "details report (Unrestricted Execution)")
1524 : UICommon::tr("Inactive", "details report (Unrestricted Execution)");
1525
1526 /* CPU Execution Cap feature: */
1527 const QString strCPUExecCap = QString::number(comMachine.GetCPUExecutionCap());
1528
1529 /* Paravirtualization feature: */
1530 const QString strParavirt = gpConverter->toString(enmProvider);
1531
1532 /* Compose tool-tip: */
1533 strInfo += e_strTableRow2.arg(UICommon::tr("Execution engine", "details report"), strExecutionEngine);
1534 strInfo += e_strTableRow2.arg(UICommon::tr("Nested Paging"), strNestedPaging);
1535 strInfo += e_strTableRow2.arg(UICommon::tr("Unrestricted Execution"), strUnrestrictExec);
1536 strInfo += e_strTableRow2.arg(UICommon::tr("Execution Cap", "details report"), strCPUExecCap);
1537 strInfo += e_strTableRow2.arg(UICommon::tr("Paravirtualization Interface", "details report"), strParavirt);
1538
1539 /* Add CPU count optional info: */
1540 const int cCpuCount = comMachine.GetCPUCount();
1541 if (cCpuCount > 1)
1542 strInfo += e_strTableRow2.arg(UICommon::tr("Processors", "details report"), QString::number(cCpuCount));
1543}
Note: See TracBrowser for help on using the repository browser.

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