VirtualBox

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

Last change on this file since 83151 was 83151, checked in by vboxsync, 5 years ago

FE/Qt: bugref:9653: VirtualBox Manager: Details pane: Generate General and System details elements, most of options are dummy for now, will be added later.

  • 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: 48.0 KB
Line 
1/* $Id: UIDetailsGenerator.cpp 83151 2020-02-25 13:06:21Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - UIDetailsGenerator implementation.
4 */
5
6/*
7 * Copyright (C) 2012-2020 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18/* Qt includes: */
19#include <QApplication>
20#include <QDir>
21
22/* GUI includes: */
23#include "UIBootOrderEditor.h"
24#include "UICloudMachine.h"
25#include "UIConverter.h"
26#include "UIDetailsGenerator.h"
27#include "UIErrorString.h"
28#include "UICommon.h"
29
30/* COM includes: */
31#include "COMEnums.h"
32#include "CAudioAdapter.h"
33#include "CGraphicsAdapter.h"
34#include "CMachine.h"
35#include "CMediumAttachment.h"
36#include "CNetworkAdapter.h"
37#include "CRecordingScreenSettings.h"
38#include "CRecordingSettings.h"
39#include "CSerialPort.h"
40#include "CSharedFolder.h"
41#include "CStorageController.h"
42#include "CSystemProperties.h"
43#include "CUSBController.h"
44#include "CUSBDeviceFilter.h"
45#include "CUSBDeviceFilters.h"
46#include "CVRDEServer.h"
47
48UITextTable UIDetailsGenerator::generateMachineInformationGeneral(CMachine &comMachine,
49 const UIExtraDataMetaDefs::DetailsElementOptionTypeGeneral &fOptions)
50{
51 UITextTable table;
52
53 if (comMachine.isNull())
54 return table;
55
56 if (!comMachine.GetAccessible())
57 {
58 table << UITextTableLine(QApplication::translate("UIDetails", "Information Inaccessible", "details"), QString());
59 return table;
60 }
61
62 /* Name: */
63 if (fOptions & UIExtraDataMetaDefs::DetailsElementOptionTypeGeneral_Name)
64 {
65 /* Configure hovering anchor: */
66 const QString strAnchorType = QString("machine_name");
67 const QString strName = comMachine.GetName();
68 table << UITextTableLine(QApplication::translate("UIDetails", "Name", "details (general)"),
69 QString("<a href=#%1,%2>%2</a>")
70 .arg(strAnchorType,
71 strName));
72 }
73
74 /* Operating system: */
75 if (fOptions & UIExtraDataMetaDefs::DetailsElementOptionTypeGeneral_OS)
76 {
77 /* Configure hovering anchor: */
78 const QString strAnchorType = QString("os_type");
79 const QString strOsTypeId = comMachine.GetOSTypeId();
80 table << UITextTableLine(QApplication::translate("UIDetails", "Operating System", "details (general)"),
81 QString("<a href=#%1,%2>%3</a>")
82 .arg(strAnchorType,
83 strOsTypeId,
84 uiCommon().vmGuestOSTypeDescription(strOsTypeId)));
85 }
86
87 /* Settings file location: */
88 if (fOptions & UIExtraDataMetaDefs::DetailsElementOptionTypeGeneral_Location)
89 {
90 /* Configure hovering anchor: */
91 const QString strAnchorType = QString("machine_location");
92 const QString strMachineLocation = comMachine.GetSettingsFilePath();
93 table << UITextTableLine(QApplication::translate("UIDetails", "Settings File Location", "details (general)"),
94 QString("<a href=#%1,%2>%3</a>")
95 .arg(strAnchorType,
96 strMachineLocation,
97 QDir::toNativeSeparators(QFileInfo(strMachineLocation).absolutePath())));
98 }
99
100 /* Groups: */
101 if (fOptions & UIExtraDataMetaDefs::DetailsElementOptionTypeGeneral_Groups)
102 {
103 QStringList groups = comMachine.GetGroups().toList();
104 /* Do not show groups for machine which is in root group only: */
105 if (groups.size() == 1)
106 groups.removeAll("/");
107 /* If group list still not empty: */
108 if (!groups.isEmpty())
109 {
110 /* For every group: */
111 for (int i = 0; i < groups.size(); ++i)
112 {
113 /* Trim first '/' symbol: */
114 QString &strGroup = groups[i];
115 if (strGroup.startsWith("/") && strGroup != "/")
116 strGroup.remove(0, 1);
117 }
118 table << UITextTableLine(QApplication::translate("UIDetails", "Groups", "details (general)"), groups.join(", "));
119 }
120 }
121
122 return table;
123}
124
125UITextTable UIDetailsGenerator::generateMachineInformationGeneral(UICloudMachine &guiCloudMachine,
126 const UIExtraDataMetaDefs::DetailsElementOptionTypeGeneral &fOptions)
127{
128 UITextTable table;
129
130 if (guiCloudMachine.isNull())
131 return table;
132
133 if (!guiCloudMachine.isAccessible())
134 {
135 table << UITextTableLine(QApplication::translate("UIDetails", "Information Inaccessible", "details"), QString());
136 return table;
137 }
138
139 /* Name: */
140 if (fOptions & UIExtraDataMetaDefs::DetailsElementOptionTypeGeneral_Name)
141 table << UITextTableLine(QApplication::translate("UIDetails", "Name", "details (general)"),
142 guiCloudMachine.name());
143
144 /* Operating system: */
145 if (fOptions & UIExtraDataMetaDefs::DetailsElementOptionTypeGeneral_OS)
146 table << UITextTableLine(QApplication::translate("UIDetails", "Operating System", "details (general)"),
147 uiCommon().vmGuestOSTypeDescription(guiCloudMachine.osType()));
148
149 return table;
150}
151
152UITextTable UIDetailsGenerator::generateMachineInformationSystem(CMachine &comMachine,
153 const UIExtraDataMetaDefs::DetailsElementOptionTypeSystem &fOptions)
154{
155 UITextTable table;
156
157 if (comMachine.isNull())
158 return table;
159
160 if (!comMachine.GetAccessible())
161 {
162 table << UITextTableLine(QApplication::translate("UIDetails", "Information Inaccessible", "details"), QString());
163 return table;
164 }
165
166 /* Base memory: */
167 if (fOptions & UIExtraDataMetaDefs::DetailsElementOptionTypeSystem_RAM)
168 {
169 /* Configure hovering anchor: */
170 const QString strAnchorType = QString("base_memory");
171 const int iBaseMemory = comMachine.GetMemorySize();
172 table << UITextTableLine(QApplication::translate("UIDetails", "Base Memory", "details (system)"),
173 QString("<a href=#%1,%2>%3</a>")
174 .arg(strAnchorType)
175 .arg(iBaseMemory)
176 .arg(QApplication::translate("UIDetails", "%1 MB").arg(iBaseMemory)));
177 }
178
179 /* Processors: */
180 if (fOptions & UIExtraDataMetaDefs::DetailsElementOptionTypeSystem_CPUCount)
181 {
182 const int cCPU = comMachine.GetCPUCount();
183 if (cCPU > 1)
184 table << UITextTableLine(QApplication::translate("UIDetails", "Processors", "details (system)"),
185 QString::number(cCPU));
186 }
187
188 /* Execution cap: */
189 if (fOptions & UIExtraDataMetaDefs::DetailsElementOptionTypeSystem_CPUExecutionCap)
190 {
191 const int iCPUExecutionCap = comMachine.GetCPUExecutionCap();
192 if (iCPUExecutionCap < 100)
193 table << UITextTableLine(QApplication::translate("UIDetails", "Execution Cap", "details (system)"),
194 QApplication::translate("UIDetails", "%1%", "details").arg(iCPUExecutionCap));
195 }
196
197 /* Boot order: */
198 if (fOptions & UIExtraDataMetaDefs::DetailsElementOptionTypeSystem_BootOrder)
199 {
200 /* Configure hovering anchor: */
201 const QString strAnchorType = QString("boot_order");
202 const UIBootItemDataList bootItems = loadBootItems(comMachine);
203 table << UITextTableLine(QApplication::translate("UIDetails", "Boot Order", "details (system)"),
204 QString("<a href=#%1,%2>%3</a>")
205 .arg(strAnchorType,
206 bootItemsToSerializedString(bootItems),
207 bootItemsToReadableString(bootItems)));
208 }
209
210 /* Chipset type: */
211 if (fOptions & UIExtraDataMetaDefs::DetailsElementOptionTypeSystem_ChipsetType)
212 {
213 const KChipsetType enmChipsetType = comMachine.GetChipsetType();
214 if (enmChipsetType == KChipsetType_ICH9)
215 table << UITextTableLine(QApplication::translate("UIDetails", "Chipset Type", "details (system)"),
216 gpConverter->toString(enmChipsetType));
217 }
218
219 /* EFI: */
220 if (fOptions & UIExtraDataMetaDefs::DetailsElementOptionTypeSystem_Firmware)
221 {
222 switch (comMachine.GetFirmwareType())
223 {
224 case KFirmwareType_EFI:
225 case KFirmwareType_EFI32:
226 case KFirmwareType_EFI64:
227 case KFirmwareType_EFIDUAL:
228 {
229 table << UITextTableLine(QApplication::translate("UIDetails", "EFI", "details (system)"),
230 QApplication::translate("UIDetails", "Enabled", "details (system/EFI)"));
231 break;
232 }
233 default:
234 {
235 // For NLS purpose:
236 QApplication::translate("UIDetails", "Disabled", "details (system/EFI)");
237 break;
238 }
239 }
240 }
241
242 /* Acceleration: */
243 if (fOptions & UIExtraDataMetaDefs::DetailsElementOptionTypeSystem_Acceleration)
244 {
245 QStringList acceleration;
246 if (uiCommon().virtualBox().GetHost().GetProcessorFeature(KProcessorFeature_HWVirtEx))
247 {
248 /* VT-x/AMD-V: */
249 if (comMachine.GetHWVirtExProperty(KHWVirtExPropertyType_Enabled))
250 {
251 acceleration << QApplication::translate("UIDetails", "VT-x/AMD-V", "details (system)");
252 /* Nested Paging (only when hw virt is enabled): */
253 if (comMachine.GetHWVirtExProperty(KHWVirtExPropertyType_NestedPaging))
254 acceleration << QApplication::translate("UIDetails", "Nested Paging", "details (system)");
255 }
256 }
257 /* PAE/NX: */
258 if (comMachine.GetCPUProperty(KCPUPropertyType_PAE))
259 acceleration << QApplication::translate("UIDetails", "PAE/NX", "details (system)");
260 /* Paravirtualization provider: */
261 switch (comMachine.GetEffectiveParavirtProvider())
262 {
263 case KParavirtProvider_Minimal: acceleration << QApplication::translate("UIDetails", "Minimal Paravirtualization", "details (system)"); break;
264 case KParavirtProvider_HyperV: acceleration << QApplication::translate("UIDetails", "Hyper-V Paravirtualization", "details (system)"); break;
265 case KParavirtProvider_KVM: acceleration << QApplication::translate("UIDetails", "KVM Paravirtualization", "details (system)"); break;
266 default: break;
267 }
268 if (!acceleration.isEmpty())
269 table << UITextTableLine(QApplication::translate("UIDetails", "Acceleration", "details (system)"),
270 acceleration.join(", "));
271 }
272
273 return table;
274}
275
276UITextTable UIDetailsGenerator::generateMachineInformationSystem(UICloudMachine &guiCloudMachine,
277 const UIExtraDataMetaDefs::DetailsElementOptionTypeSystem &fOptions)
278{
279 UITextTable table;
280
281 if (guiCloudMachine.isNull())
282 return table;
283
284 if (!guiCloudMachine.isAccessible())
285 {
286 table << UITextTableLine(QApplication::translate("UIDetails", "Information Inaccessible", "details"), QString());
287 return table;
288 }
289
290 /* Base memory: */
291 if (fOptions & UIExtraDataMetaDefs::DetailsElementOptionTypeSystem_RAM)
292 table << UITextTableLine(QApplication::translate("UIDetails", "Base Memory", "details (system)"),
293 QApplication::translate("UIDetails", "%1 MB").arg(guiCloudMachine.memorySize()));
294
295 /* Processors: */
296 if (fOptions & UIExtraDataMetaDefs::DetailsElementOptionTypeSystem_CPUCount)
297 table << UITextTableLine(QApplication::translate("UIDetails", "Processors", "details (system)"),
298 QString::number(guiCloudMachine.cpuCount()));
299
300 return table;
301}
302
303UITextTable UIDetailsGenerator::generateMachineInformationDisplay(CMachine &comMachine,
304 const UIExtraDataMetaDefs::DetailsElementOptionTypeDisplay &fOptions)
305{
306 UITextTable table;
307
308 if (comMachine.isNull())
309 return table;
310
311 if (!comMachine.GetAccessible())
312 {
313 table << UITextTableLine(QApplication::translate("UIDetails", "Information Inaccessible", "details"), QString());
314 return table;
315 }
316
317 const CGraphicsAdapter comGraphics = comMachine.GetGraphicsAdapter();
318
319 /* Video memory: */
320 if (fOptions & UIExtraDataMetaDefs::DetailsElementOptionTypeDisplay_VRAM)
321 {
322 /* Configure hovering anchor: */
323 const QString strAnchorType = QString("video_memory");
324 const int iVideoMemory = comGraphics.GetVRAMSize();
325 table << UITextTableLine(QApplication::translate("UIDetails", "Video Memory", "details (display)"),
326 QString("<a href=#%1,%2>%3</a>")
327 .arg(strAnchorType)
328 .arg(iVideoMemory)
329 .arg(QApplication::translate("UIDetails", "%1 MB").arg(iVideoMemory)));
330 }
331
332 /* Screens: */
333 if (fOptions & UIExtraDataMetaDefs::DetailsElementOptionTypeDisplay_ScreenCount)
334 {
335 const int cGuestScreens = comGraphics.GetMonitorCount();
336 if (cGuestScreens > 1)
337 table << UITextTableLine(QApplication::translate("UIDetails", "Screens", "details (display)"),
338 QString::number(cGuestScreens));
339 }
340
341 /* Scale-factor: */
342 if (fOptions & UIExtraDataMetaDefs::DetailsElementOptionTypeDisplay_ScaleFactor)
343 {
344 const QString strScaleFactor = comMachine.GetExtraData(UIExtraDataDefs::GUI_ScaleFactor);
345 {
346 /* Try to convert loaded data to double: */
347 bool fOk = false;
348 double dValue = strScaleFactor.toDouble(&fOk);
349 /* Invent the default value: */
350 if (!fOk || !dValue)
351 dValue = 1.0;
352 /* Append information: */
353 if (dValue != 1.0)
354 table << UITextTableLine(QApplication::translate("UIDetails", "Scale-factor", "details (display)"),
355 QString::number(dValue, 'f', 2));
356 }
357 }
358
359 /* Graphics Controller: */
360 if (fOptions & UIExtraDataMetaDefs::DetailsElementOptionTypeDisplay_GraphicsController)
361 {
362 const QString strAnchorType = QString("graphics_controller_type");
363 const KGraphicsControllerType enmType = comGraphics.GetGraphicsControllerType();
364 table << UITextTableLine(QApplication::translate("UIDetails", "Graphics Controller", "details (display)"),
365 QString("<a href=#%1,%2>%3</a>")
366 .arg(strAnchorType)
367 .arg((int)enmType)
368 .arg(gpConverter->toString(enmType)));
369 }
370
371 /* Acceleration: */
372 if (fOptions & UIExtraDataMetaDefs::DetailsElementOptionTypeDisplay_Acceleration)
373 {
374 QStringList acceleration;
375#ifdef VBOX_WITH_VIDEOHWACCEL
376 /* 2D acceleration: */
377 if (comGraphics.GetAccelerate2DVideoEnabled())
378 acceleration << QApplication::translate("UIDetails", "2D Video", "details (display)");
379#endif
380 /* 3D acceleration: */
381 if (comGraphics.GetAccelerate3DEnabled())
382 acceleration << QApplication::translate("UIDetails", "3D", "details (display)");
383 if (!acceleration.isEmpty())
384 table << UITextTableLine(QApplication::translate("UIDetails", "Acceleration", "details (display)"),
385 acceleration.join(", "));
386 }
387
388 /* Remote desktop server: */
389 if (fOptions & UIExtraDataMetaDefs::DetailsElementOptionTypeDisplay_VRDE)
390 {
391 const CVRDEServer comServer = comMachine.GetVRDEServer();
392 if (!comServer.isNull())
393 {
394 if (comServer.GetEnabled())
395 table << UITextTableLine(QApplication::translate("UIDetails", "Remote Desktop Server Port", "details (display/vrde)"),
396 comServer.GetVRDEProperty("TCP/Ports"));
397 else
398 table << UITextTableLine(QApplication::translate("UIDetails", "Remote Desktop Server", "details (display/vrde)"),
399 QApplication::translate("UIDetails", "Disabled", "details (display/vrde/VRDE server)"));
400 }
401 }
402
403 /* Recording: */
404 if (fOptions & UIExtraDataMetaDefs::DetailsElementOptionTypeDisplay_Recording)
405 {
406 CRecordingSettings comRecordingSettings = comMachine.GetRecordingSettings();
407 if (comRecordingSettings.GetEnabled())
408 {
409 /* For now all screens have the same config: */
410 const CRecordingScreenSettings comRecordingScreen0Settings = comRecordingSettings.GetScreenSettings(0);
411
412 /** @todo r=andy Refine these texts (wrt audio and/or video). */
413 table << UITextTableLine(QApplication::translate("UIDetails", "Recording File", "details (display/recording)"),
414 comRecordingScreen0Settings.GetFilename());
415 table << UITextTableLine(QApplication::translate("UIDetails", "Recording Attributes", "details (display/recording)"),
416 QApplication::translate("UIDetails", "Frame Size: %1x%2, Frame Rate: %3fps, Bit Rate: %4kbps")
417 .arg(comRecordingScreen0Settings.GetVideoWidth()).arg(comRecordingScreen0Settings.GetVideoHeight())
418 .arg(comRecordingScreen0Settings.GetVideoFPS()).arg(comRecordingScreen0Settings.GetVideoRate()));
419 }
420 else
421 {
422 table << UITextTableLine(QApplication::translate("UIDetails", "Recording", "details (display/recording)"),
423 QApplication::translate("UIDetails", "Disabled", "details (display/recording)"));
424 }
425 }
426
427 return table;
428}
429
430UITextTable UIDetailsGenerator::generateMachineInformationStorage(CMachine &comMachine,
431 const UIExtraDataMetaDefs::DetailsElementOptionTypeStorage &fOptions,
432 bool fLink /* = true */)
433{
434 UITextTable table;
435
436 if (comMachine.isNull())
437 return table;
438
439 if (!comMachine.GetAccessible())
440 {
441 table << UITextTableLine(QApplication::translate("UIDetails", "Information Inaccessible", "details"), QString());
442 return table;
443 }
444
445 /* Iterate over all the machine controllers: */
446 foreach (const CStorageController &comController, comMachine.GetStorageControllers())
447 {
448 /* Add controller information: */
449 const QString strControllerName = QApplication::translate("UIMachineSettingsStorage", "Controller: %1");
450 table << UITextTableLine(strControllerName.arg(comController.GetName()), QString());
451 /* Populate map (its sorted!): */
452 QMap<StorageSlot, QString> attachmentsMap;
453 foreach (const CMediumAttachment &attachment, comMachine.GetMediumAttachmentsOfController(comController.GetName()))
454 {
455 /* Acquire device type first of all: */
456 const KDeviceType enmDeviceType = attachment.GetType();
457
458 /* Ignore restricted device types: */
459 if ( ( !(fOptions & UIExtraDataMetaDefs::DetailsElementOptionTypeStorage_HardDisks)
460 && enmDeviceType == KDeviceType_HardDisk)
461 || ( !(fOptions & UIExtraDataMetaDefs::DetailsElementOptionTypeStorage_OpticalDevices)
462 && enmDeviceType == KDeviceType_DVD)
463 || ( !(fOptions & UIExtraDataMetaDefs::DetailsElementOptionTypeStorage_FloppyDevices)
464 && enmDeviceType == KDeviceType_Floppy))
465 continue;
466
467 /* Prepare current storage slot: */
468 const StorageSlot attachmentSlot(comController.GetBus(), attachment.GetPort(), attachment.GetDevice());
469 AssertMsg(comController.isOk(),
470 ("Unable to acquire controller data: %s\n",
471 UIErrorString::formatRC(comController.lastRC()).toUtf8().constData()));
472 if (!comController.isOk())
473 continue;
474
475 /* Prepare attachment information: */
476 QString strAttachmentInfo = uiCommon().details(attachment.GetMedium(), false, false);
477 /* That hack makes sure 'Inaccessible' word is always bold: */
478 { // hack
479 const QString strInaccessibleString(UICommon::tr("Inaccessible", "medium"));
480 const QString strBoldInaccessibleString(QString("<b>%1</b>").arg(strInaccessibleString));
481 strAttachmentInfo.replace(strInaccessibleString, strBoldInaccessibleString);
482 } // hack
483
484 /* Append 'device slot name' with 'device type name' for optical devices only: */
485 QString strDeviceType = enmDeviceType == KDeviceType_DVD
486 ? QApplication::translate("UIDetails", "[Optical Drive]", "details (storage)")
487 : QString();
488 if (!strDeviceType.isNull())
489 strDeviceType.append(' ');
490
491 /* Insert that attachment information into the map: */
492 if (!strAttachmentInfo.isNull())
493 {
494 /* Configure hovering anchors: */
495 const QString strAnchorType = enmDeviceType == KDeviceType_DVD || enmDeviceType == KDeviceType_Floppy ? QString("mount") :
496 enmDeviceType == KDeviceType_HardDisk ? QString("attach") : QString();
497 const CMedium medium = attachment.GetMedium();
498 const QString strMediumLocation = medium.isNull() ? QString() : medium.GetLocation();
499 if (fLink)
500 attachmentsMap.insert(attachmentSlot,
501 QString("<a href=#%1,%2,%3,%4>%5</a>")
502 .arg(strAnchorType,
503 comController.GetName(),
504 gpConverter->toString(attachmentSlot),
505 strMediumLocation,
506 strDeviceType + strAttachmentInfo));
507 else
508 attachmentsMap.insert(attachmentSlot,
509 QString("%1")
510 .arg(strDeviceType + strAttachmentInfo));
511 }
512 }
513
514 /* Iterate over the sorted map: */
515 const QList<StorageSlot> storageSlots = attachmentsMap.keys();
516 const QList<QString> storageInfo = attachmentsMap.values();
517 for (int i = 0; i < storageSlots.size(); ++i)
518 table << UITextTableLine(QString(" ") + gpConverter->toString(storageSlots[i]), storageInfo[i]);
519 }
520 if (table.isEmpty())
521 table << UITextTableLine(QApplication::translate("UIDetails", "Not Attached", "details (storage)"), QString());
522
523 return table;
524}
525
526UITextTable UIDetailsGenerator::generateMachineInformationAudio(CMachine &comMachine,
527 const UIExtraDataMetaDefs::DetailsElementOptionTypeAudio &fOptions)
528{
529 UITextTable table;
530
531 if (comMachine.isNull())
532 return table;
533
534 if (!comMachine.GetAccessible())
535 {
536 table << UITextTableLine(QApplication::translate("UIDetails", "Information Inaccessible", "details"), QString());
537 return table;
538 }
539
540 const CAudioAdapter comAudio = comMachine.GetAudioAdapter();
541 if (comAudio.GetEnabled())
542 {
543 /* Host driver: */
544 if (fOptions & UIExtraDataMetaDefs::DetailsElementOptionTypeAudio_Driver)
545 {
546 const QString strAnchorType = QString("audio_host_driver_type");
547 const KAudioDriverType enmType = comAudio.GetAudioDriver();
548 table << UITextTableLine(QApplication::translate("UIDetails", "Host Driver", "details (audio)"),
549 QString("<a href=#%1,%2>%3</a>")
550 .arg(strAnchorType)
551 .arg((int)enmType)
552 .arg(gpConverter->toString(enmType)));
553 }
554
555 /* Controller: */
556 if (fOptions & UIExtraDataMetaDefs::DetailsElementOptionTypeAudio_Controller)
557 {
558 const QString strAnchorType = QString("audio_controller_type");
559 const KAudioControllerType enmType = comAudio.GetAudioController();
560 table << UITextTableLine(QApplication::translate("UIDetails", "Controller", "details (audio)"),
561 QString("<a href=#%1,%2>%3</a>")
562 .arg(strAnchorType)
563 .arg((int)enmType)
564 .arg(gpConverter->toString(enmType)));
565 }
566
567#ifdef VBOX_WITH_AUDIO_INOUT_INFO
568 /* Audio I/O: */
569 if (fOptions & UIExtraDataMetaDefs::DetailsElementOptionTypeAudio_IO)
570 {
571 table << UITextTableLine(QApplication::translate("UIDetails", "Audio Input", "details (audio)"),
572 comAudio.GetEnabledIn() ?
573 QApplication::translate("UIDetails", "Enabled", "details (audio/input)") :
574 QApplication::translate("UIDetails", "Disabled", "details (audio/input)"));
575 table << UITextTableLine(QApplication::translate("UIDetails", "Audio Output", "details (audio)"),
576 comAudio.GetEnabledOut() ?
577 QApplication::translate("UIDetails", "Enabled", "details (audio/output)") :
578 QApplication::translate("UIDetails", "Disabled", "details (audio/output)"));
579 }
580#endif /* VBOX_WITH_AUDIO_INOUT_INFO */
581 }
582 else
583 table << UITextTableLine(QApplication::translate("UIDetails", "Disabled", "details (audio)"),
584 QString());
585
586 return table;
587}
588
589QString summarizeGenericProperties(const CNetworkAdapter &comAdapter)
590{
591 QVector<QString> names;
592 QVector<QString> props;
593 props = comAdapter.GetProperties(QString(), names);
594 QString strResult;
595 for (int i = 0; i < names.size(); ++i)
596 {
597 strResult += names[i] + "=" + props[i];
598 if (i < names.size() - 1)
599 strResult += ", ";
600 }
601 return strResult;
602}
603
604UITextTable UIDetailsGenerator::generateMachineInformationNetwork(CMachine &comMachine,
605 const UIExtraDataMetaDefs::DetailsElementOptionTypeNetwork &fOptions)
606{
607 UITextTable table;
608
609 if (comMachine.isNull())
610 return table;
611
612 if (!comMachine.GetAccessible())
613 {
614 table << UITextTableLine(QApplication::translate("UIDetails", "Information Inaccessible", "details"), QString());
615 return table;
616 }
617
618 /* Iterate over all the adapters: */
619 const ulong uCount = uiCommon().virtualBox().GetSystemProperties().GetMaxNetworkAdapters(comMachine.GetChipsetType());
620 for (ulong uSlot = 0; uSlot < uCount; ++uSlot)
621 {
622 const QString strAnchorType = QString("network_attachment_type");
623 const CNetworkAdapter comAdapter = comMachine.GetNetworkAdapter(uSlot);
624
625 /* Skip disabled adapters: */
626 if (!comAdapter.GetEnabled())
627 continue;
628
629 /* Gather adapter information: */
630 const KNetworkAttachmentType enmAttachmentType = comAdapter.GetAttachmentType();
631 const QString strAttachmentTemplate = gpConverter->toString(comAdapter.GetAdapterType()).replace(QRegExp("\\s\\(.+\\)"), " (<a href=#%1,%2;%3;%4>%5</a>)");
632 QString strAttachmentType;
633 switch (enmAttachmentType)
634 {
635 case KNetworkAttachmentType_NAT:
636 {
637 if (fOptions & UIExtraDataMetaDefs::DetailsElementOptionTypeNetwork_NAT)
638 strAttachmentType = strAttachmentTemplate
639 .arg(strAnchorType)
640 .arg(uSlot)
641 .arg((int)KNetworkAttachmentType_NAT)
642 .arg(QString())
643 .arg(gpConverter->toString(KNetworkAttachmentType_NAT));
644 break;
645 }
646 case KNetworkAttachmentType_Bridged:
647 {
648 if (fOptions & UIExtraDataMetaDefs::DetailsElementOptionTypeNetwork_BridgetAdapter)
649 {
650 const QString strName = comAdapter.GetBridgedInterface();
651 strAttachmentType = strAttachmentTemplate
652 .arg(strAnchorType)
653 .arg(uSlot)
654 .arg((int)KNetworkAttachmentType_Bridged)
655 .arg(strName)
656 .arg(QApplication::translate("UIDetails", "Bridged Adapter, %1", "details (network)")
657 .arg(strName));
658 }
659 break;
660 }
661 case KNetworkAttachmentType_Internal:
662 {
663 if (fOptions & UIExtraDataMetaDefs::DetailsElementOptionTypeNetwork_InternalNetwork)
664 {
665 const QString strName = comAdapter.GetInternalNetwork();
666 strAttachmentType = strAttachmentTemplate
667 .arg(strAnchorType)
668 .arg(uSlot)
669 .arg((int)KNetworkAttachmentType_Internal)
670 .arg(strName)
671 .arg(QApplication::translate("UIDetails", "Internal Network, '%1'", "details (network)")
672 .arg(strName));
673 }
674 break;
675 }
676 case KNetworkAttachmentType_HostOnly:
677 {
678 if (fOptions & UIExtraDataMetaDefs::DetailsElementOptionTypeNetwork_HostOnlyAdapter)
679 {
680 const QString strName = comAdapter.GetHostOnlyInterface();
681 strAttachmentType = strAttachmentTemplate
682 .arg(strAnchorType)
683 .arg(uSlot)
684 .arg((int)KNetworkAttachmentType_HostOnly)
685 .arg(strName)
686 .arg(QApplication::translate("UIDetails", "Host-only Adapter, '%1'", "details (network)")
687 .arg(strName));
688 }
689 break;
690 }
691 case KNetworkAttachmentType_Generic:
692 {
693 if (fOptions & UIExtraDataMetaDefs::DetailsElementOptionTypeNetwork_GenericDriver)
694 {
695 const QString strName = comAdapter.GetGenericDriver();
696 const QString strGenericDriverProperties(summarizeGenericProperties(comAdapter));
697 strAttachmentType = strGenericDriverProperties.isNull()
698 ? strAttachmentTemplate
699 .arg(strAnchorType)
700 .arg(uSlot)
701 .arg((int)KNetworkAttachmentType_Generic)
702 .arg(strName)
703 .arg(QApplication::translate("UIDetails", "Generic Driver, '%1'", "details (network)")
704 .arg(strName))
705 : strAttachmentTemplate
706 .arg(strAnchorType)
707 .arg(uSlot)
708 .arg((int)KNetworkAttachmentType_Generic)
709 .arg(strName)
710 .arg(QApplication::translate("UIDetails", "Generic Driver, '%1' { %2 }", "details (network)")
711 .arg(strName, strGenericDriverProperties));
712 }
713 break;
714 }
715 case KNetworkAttachmentType_NATNetwork:
716 {
717 if (fOptions & UIExtraDataMetaDefs::DetailsElementOptionTypeNetwork_NATNetwork)
718 {
719 const QString strName = comAdapter.GetNATNetwork();
720 strAttachmentType = strAttachmentTemplate
721 .arg(strAnchorType)
722 .arg(uSlot)
723 .arg((int)KNetworkAttachmentType_NATNetwork)
724 .arg(strName)
725 .arg(QApplication::translate("UIDetails", "NAT Network, '%1'", "details (network)")
726 .arg(strName));
727 }
728 break;
729 }
730 default:
731 {
732 if (fOptions & UIExtraDataMetaDefs::DetailsElementOptionTypeNetwork_NotAttached)
733 strAttachmentType = strAttachmentTemplate
734 .arg(strAnchorType)
735 .arg(uSlot)
736 .arg((int)enmAttachmentType)
737 .arg(QString())
738 .arg(gpConverter->toString(enmAttachmentType));
739 break;
740 }
741 }
742 if (!strAttachmentType.isNull())
743 table << UITextTableLine(QApplication::translate("UIDetails", "Adapter %1", "details (network)").arg(comAdapter.GetSlot() + 1), strAttachmentType);
744 }
745 if (table.isEmpty())
746 table << UITextTableLine(QApplication::translate("UIDetails", "Disabled", "details (network/adapter)"), QString());
747
748 return table;
749}
750
751UITextTable UIDetailsGenerator::generateMachineInformationSerial(CMachine &comMachine,
752 const UIExtraDataMetaDefs::DetailsElementOptionTypeSerial &fOptions)
753{
754 UITextTable table;
755
756 if (comMachine.isNull())
757 return table;
758
759 if (!comMachine.GetAccessible())
760 {
761 table << UITextTableLine(QApplication::translate("UIDetails", "Information Inaccessible", "details"), QString());
762 return table;
763 }
764
765 /* Iterate over all the ports: */
766 const ulong uCount = uiCommon().virtualBox().GetSystemProperties().GetSerialPortCount();
767 for (ulong uSlot = 0; uSlot < uCount; ++uSlot)
768 {
769 const CSerialPort comPort = comMachine.GetSerialPort(uSlot);
770
771 /* Skip disabled adapters: */
772 if (!comPort.GetEnabled())
773 continue;
774
775 /* Gather port information: */
776 const KPortMode enmMode = comPort.GetHostMode();
777 const QString strModeTemplate = uiCommon().toCOMPortName(comPort.GetIRQ(), comPort.GetIOBase()) + ", ";
778 QString strModeType;
779 switch (enmMode)
780 {
781 case KPortMode_HostPipe:
782 {
783 if (fOptions & UIExtraDataMetaDefs::DetailsElementOptionTypeSerial_HostPipe)
784 strModeType = strModeTemplate + QString("%1 (%2)").arg(gpConverter->toString(enmMode)).arg(QDir::toNativeSeparators(comPort.GetPath()));
785 break;
786 }
787 case KPortMode_HostDevice:
788 {
789 if (fOptions & UIExtraDataMetaDefs::DetailsElementOptionTypeSerial_HostDevice)
790 strModeType = strModeTemplate + QString("%1 (%2)").arg(gpConverter->toString(enmMode)).arg(QDir::toNativeSeparators(comPort.GetPath()));
791 break;
792 }
793 case KPortMode_RawFile:
794 {
795 if (fOptions & UIExtraDataMetaDefs::DetailsElementOptionTypeSerial_RawFile)
796 strModeType = strModeTemplate + QString("%1 (%2)").arg(gpConverter->toString(enmMode)).arg(QDir::toNativeSeparators(comPort.GetPath()));
797 break;
798 }
799 case KPortMode_TCP:
800 {
801 if (fOptions & UIExtraDataMetaDefs::DetailsElementOptionTypeSerial_TCP)
802 strModeType = strModeTemplate + QString("%1 (%2)").arg(gpConverter->toString(enmMode)).arg(QDir::toNativeSeparators(comPort.GetPath()));
803 break;
804 }
805 default:
806 {
807 if (fOptions & UIExtraDataMetaDefs::DetailsElementOptionTypeSerial_Disconnected)
808 strModeType = strModeTemplate + gpConverter->toString(enmMode);
809 break;
810 }
811 }
812 if (!strModeType.isNull())
813 table << UITextTableLine(QApplication::translate("UIDetails", "Port %1", "details (serial)").arg(comPort.GetSlot() + 1), strModeType);
814 }
815 if (table.isEmpty())
816 table << UITextTableLine(QApplication::translate("UIDetails", "Disabled", "details (serial)"), QString());
817
818 return table;
819}
820
821UITextTable UIDetailsGenerator::generateMachineInformationUSB(CMachine &comMachine,
822 const UIExtraDataMetaDefs::DetailsElementOptionTypeUsb &fOptions)
823{
824 UITextTable table;
825
826 if (comMachine.isNull())
827 return table;
828
829 if (!comMachine.GetAccessible())
830 {
831 table << UITextTableLine(QApplication::translate("UIDetails", "Information Inaccessible", "details"), QString());
832 return table;
833 }
834
835 /* Iterate over all the USB filters: */
836 const CUSBDeviceFilters comFilterObject = comMachine.GetUSBDeviceFilters();
837 if (!comFilterObject.isNull() && comMachine.GetUSBProxyAvailable())
838 {
839 const QString strAnchorType = QString("usb_controller_type");
840 const CUSBControllerVector controllers = comMachine.GetUSBControllers();
841 if (!controllers.isEmpty())
842 {
843 /* USB controllers: */
844 if (fOptions & UIExtraDataMetaDefs::DetailsElementOptionTypeUsb_Controller)
845 {
846 QStringList controllerInternal;
847 QStringList controllersReadable;
848 foreach (const CUSBController &comController, controllers)
849 {
850 const KUSBControllerType enmType = comController.GetType();
851 controllerInternal << QString::number((int)enmType);
852 controllersReadable << gpConverter->toString(enmType);
853 }
854 table << UITextTableLine(QApplication::translate("UIDetails", "USB Controller", "details (usb)"),
855 QString("<a href=#%1,%2>%3</a>")
856 .arg(strAnchorType)
857 .arg(controllerInternal.join(';'))
858 .arg(controllersReadable.join(", ")));
859 }
860
861 /* Device filters: */
862 if (fOptions & UIExtraDataMetaDefs::DetailsElementOptionTypeUsb_DeviceFilters)
863 {
864 const CUSBDeviceFilterVector filters = comFilterObject.GetDeviceFilters();
865 uint uActive = 0;
866 for (int i = 0; i < filters.size(); ++i)
867 if (filters.at(i).GetActive())
868 ++uActive;
869 table << UITextTableLine(QApplication::translate("UIDetails", "Device Filters", "details (usb)"),
870 QApplication::translate("UIDetails", "%1 (%2 active)", "details (usb)").arg(filters.size()).arg(uActive));
871 }
872 }
873 else
874 table << UITextTableLine(QString("<a href=#%1,%2>%3</a>")
875 .arg(strAnchorType)
876 .arg(QString::number((int)KUSBControllerType_Null))
877 .arg(QApplication::translate("UIDetails", "Disabled", "details (usb)")),
878 QString());
879 }
880 else
881 table << UITextTableLine(QApplication::translate("UIDetails", "USB Controller Inaccessible", "details (usb)"), QString());
882
883 return table;
884}
885
886UITextTable UIDetailsGenerator::generateMachineInformationSharedFolders(CMachine &comMachine,
887 const UIExtraDataMetaDefs::DetailsElementOptionTypeSharedFolders &fOptions)
888{
889 Q_UNUSED(fOptions);
890
891 UITextTable table;
892
893 if (comMachine.isNull())
894 return table;
895
896 if (!comMachine.GetAccessible())
897 {
898 table << UITextTableLine(QApplication::translate("UIDetails", "Information Inaccessible", "details"), QString());
899 return table;
900 }
901
902 /* Summary: */
903 const ulong uCount = comMachine.GetSharedFolders().size();
904 if (uCount > 0)
905 table << UITextTableLine(QApplication::translate("UIDetails", "Shared Folders", "details (shared folders)"), QString::number(uCount));
906 else
907 table << UITextTableLine(QApplication::translate("UIDetails", "None", "details (shared folders)"), QString());
908
909 return table;
910}
911
912UITextTable UIDetailsGenerator::generateMachineInformationUI(CMachine &comMachine,
913 const UIExtraDataMetaDefs::DetailsElementOptionTypeUserInterface &fOptions)
914{
915 UITextTable table;
916
917 if (comMachine.isNull())
918 return table;
919
920 if (!comMachine.GetAccessible())
921 {
922 table << UITextTableLine(QApplication::translate("UIDetails", "Information Inaccessible", "details"), QString());
923 return table;
924 }
925
926#ifndef VBOX_WS_MAC
927 /* Menu-bar: */
928 if (fOptions & UIExtraDataMetaDefs::DetailsElementOptionTypeUserInterface_MenuBar)
929 {
930 const QString strAnchorType = QString("menu_bar");
931 const QString strMenubarEnabled = comMachine.GetExtraData(UIExtraDataDefs::GUI_MenuBar_Enabled);
932 const bool fEnabled = !( strMenubarEnabled.compare("false", Qt::CaseInsensitive) == 0
933 || strMenubarEnabled.compare("no", Qt::CaseInsensitive) == 0
934 || strMenubarEnabled.compare("off", Qt::CaseInsensitive) == 0
935 || strMenubarEnabled == "0");
936 table << UITextTableLine(QApplication::translate("UIDetails", "Menu-bar", "details (user interface)"),
937 QString("<a href=#%1,%2>%3</a>")
938 .arg(strAnchorType)
939 .arg((int)fEnabled)
940 .arg(fEnabled ? QApplication::translate("UIDetails", "Enabled", "details (user interface/menu-bar)")
941 : QApplication::translate("UIDetails", "Disabled", "details (user interface/menu-bar)")));
942 }
943#endif /* !VBOX_WS_MAC */
944
945 /* Status-bar: */
946 if (fOptions & UIExtraDataMetaDefs::DetailsElementOptionTypeUserInterface_StatusBar)
947 {
948 const QString strAnchorType = QString("status_bar");
949 const QString strStatusbarEnabled = comMachine.GetExtraData(UIExtraDataDefs::GUI_StatusBar_Enabled);
950 const bool fEnabled = !( strStatusbarEnabled.compare("false", Qt::CaseInsensitive) == 0
951 || strStatusbarEnabled.compare("no", Qt::CaseInsensitive) == 0
952 || strStatusbarEnabled.compare("off", Qt::CaseInsensitive) == 0
953 || strStatusbarEnabled == "0");
954 table << UITextTableLine(QApplication::translate("UIDetails", "Status-bar", "details (user interface)"),
955 QString("<a href=#%1,%2>%3</a>")
956 .arg(strAnchorType)
957 .arg((int)fEnabled)
958 .arg(fEnabled ? QApplication::translate("UIDetails", "Enabled", "details (user interface/status-bar)")
959 : QApplication::translate("UIDetails", "Disabled", "details (user interface/status-bar)")));
960 }
961
962#ifndef VBOX_WS_MAC
963 /* Mini-toolbar: */
964 if (fOptions & UIExtraDataMetaDefs::DetailsElementOptionTypeUserInterface_MiniToolbar)
965 {
966 const QString strAnchorType = QString("mini_toolbar");
967 const QString strMiniToolbarEnabled = comMachine.GetExtraData(UIExtraDataDefs::GUI_ShowMiniToolBar);
968 const bool fEnabled = !( strMiniToolbarEnabled.compare("false", Qt::CaseInsensitive) == 0
969 || strMiniToolbarEnabled.compare("no", Qt::CaseInsensitive) == 0
970 || strMiniToolbarEnabled.compare("off", Qt::CaseInsensitive) == 0
971 || strMiniToolbarEnabled == "0");
972 if (fEnabled)
973 {
974 /* Get mini-toolbar position: */
975 const QString strMiniToolbarPosition = comMachine.GetExtraData(UIExtraDataDefs::GUI_MiniToolBarAlignment);
976 {
977 /* Try to convert loaded data to alignment: */
978 switch (gpConverter->fromInternalString<MiniToolbarAlignment>(strMiniToolbarPosition))
979 {
980 case MiniToolbarAlignment_Top:
981 table << UITextTableLine(QApplication::translate("UIDetails", "Mini-toolbar Position", "details (user interface)"),
982 QString("<a href=#%1,%2>%3</a>")
983 .arg(strAnchorType)
984 .arg((int)MiniToolbarAlignment_Top)
985 .arg(QApplication::translate("UIDetails", "Top", "details (user interface/mini-toolbar position)")));
986 break;
987 case MiniToolbarAlignment_Bottom:
988 table << UITextTableLine(QApplication::translate("UIDetails", "Mini-toolbar Position", "details (user interface)"),
989 QString("<a href=#%1,%2>%3</a>")
990 .arg(strAnchorType)
991 .arg((int)MiniToolbarAlignment_Bottom)
992 .arg(QApplication::translate("UIDetails", "Bottom", "details (user interface/mini-toolbar position)")));
993 break;
994 default:
995 break;
996 }
997 }
998 }
999 else
1000 table << UITextTableLine(QApplication::translate("UIDetails", "Mini-toolbar", "details (user interface)"),
1001 QString("<a href=#%1,%2>%3</a>")
1002 .arg(strAnchorType)
1003 .arg((int)MiniToolbarAlignment_Disabled)
1004 .arg(QApplication::translate("UIDetails", "Disabled", "details (user interface/mini-toolbar)")));
1005 }
1006#endif /* !VBOX_WS_MAC */
1007
1008 return table;
1009}
1010
1011UITextTable UIDetailsGenerator::generateMachineInformationDescription(CMachine &comMachine,
1012 const UIExtraDataMetaDefs::DetailsElementOptionTypeDescription &fOptions)
1013{
1014 Q_UNUSED(fOptions);
1015
1016 UITextTable table;
1017
1018 if (comMachine.isNull())
1019 return table;
1020
1021 if (!comMachine.GetAccessible())
1022 {
1023 table << UITextTableLine(QApplication::translate("UIDetails", "Information Inaccessible", "details"), QString());
1024 return table;
1025 }
1026
1027 /* Summary: */
1028 const QString strDescription = comMachine.GetDescription();
1029 if (!strDescription.isEmpty())
1030 table << UITextTableLine(strDescription, QString());
1031 else
1032 table << UITextTableLine(QApplication::translate("UIDetails", "None", "details (description)"), QString());
1033
1034 return table;
1035}
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