VirtualBox

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

Last change on this file since 98490 was 98490, checked in by vboxsync, 2 years ago

FE/Qt: bugref:10322: Runtime UI: Reworking UIIndicatorsPool virtualization features indicator to move COM related logic to UISession.

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

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