VirtualBox

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

Last change on this file since 80073 was 80073, checked in by vboxsync, 6 years ago

FE/Qt: bugref:7720: VirtualBox Manager: Details pane: Possibility to edit VM graphics controller type on-the-fly.

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