VirtualBox

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

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

FE/Qt: bugref:9653: Implementing possibility to edit separate cloud VM settings directly from Details pane.

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

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