VirtualBox

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

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

FE/Qt: bugref:9389: Coding-style fixes for r129028.

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