Changeset 79982 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Jul 25, 2019 4:09:39 PM (6 years ago)
- svn:sync-xref-src-repo-rev:
- 132416
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIDetailsGenerator.cpp
r79959 r79982 21 21 22 22 /* GUI includes: */ 23 #include "UIBootOrderEditor.h" 23 24 #include "UIConverter.h" 24 25 #include "UIDetailsGenerator.h" … … 162 163 if (fOptions & UIExtraDataMetaDefs::DetailsElementOptionTypeSystem_BootOrder) 163 164 { 164 QStringList bootOrder; 165 for (ulong i = 1; i <= uiCommon().virtualBox().GetSystemProperties().GetMaxBootPosition(); ++i) 166 { 167 const KDeviceType enmDeviceType = comMachine.GetBootOrder(i); 168 if (enmDeviceType == KDeviceType_Null) 169 continue; 170 bootOrder << gpConverter->toString(enmDeviceType); 171 } 172 if (bootOrder.isEmpty()) 173 bootOrder << gpConverter->toString(KDeviceType_Null); 174 table << UITextTableLine(QApplication::translate("UIDetails", "Boot Order", "details (system)"), bootOrder.join(", ")); 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))); 175 173 } 176 174 -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMachineAttributeSetter.cpp
r79959 r79982 20 20 21 21 /* GUI includes: */ 22 #include "UIBootOrderEditor.h" 22 23 #include "UICommon.h" 23 24 #include "UIMachineAttributeSetter.h" … … 99 100 break; 100 101 } 102 case MachineAttribute_BootOrder: 103 { 104 /* Change machine boot order: */ 105 saveBootItems(guiAttribute.value<UIBootItemDataList>(), comMachine); 106 if (!comMachine.isOk()) 107 { 108 msgCenter().cannotChangeMachineAttribute(comMachine); 109 fErrorHappened = true; 110 } 111 break; 112 } 101 113 default: 102 114 break; -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMachineAttributeSetter.h
r79959 r79982 34 34 MachineAttribute_Location, 35 35 MachineAttribute_BaseMemory, 36 MachineAttribute_BootOrder, 36 37 }; 37 38 -
trunk/src/VBox/Frontends/VirtualBox/src/manager/details/UIDetailsElement.cpp
r79960 r79982 28 28 #include "UIActionPool.h" 29 29 #include "UIBaseMemoryEditor.h" 30 #include "UIBootOrderEditor.h" 30 31 #include "UICommon.h" 31 32 #include "UIConverter.h" … … 50 51 AnchorRole_OSType, 51 52 AnchorRole_BaseMemory, 53 AnchorRole_BootOrder, 52 54 AnchorRole_Storage, 53 55 }; … … 153 155 m_pTextPane->setAnchorRoleRestricted("#os_type", cal != ConfigurationAccessLevel_Full); 154 156 m_pTextPane->setAnchorRoleRestricted("#base_memory", cal != ConfigurationAccessLevel_Full); 157 m_pTextPane->setAnchorRoleRestricted("#boot_order", cal != ConfigurationAccessLevel_Full); 155 158 m_pTextPane->setAnchorRoleRestricted("#mount", cal == ConfigurationAccessLevel_Null); 156 159 m_pTextPane->setAnchorRoleRestricted("#attach", cal != ConfigurationAccessLevel_Full); … … 436 439 roles["#os_type"] = AnchorRole_OSType; 437 440 roles["#base_memory"] = AnchorRole_BaseMemory; 441 roles["#boot_order"] = AnchorRole_BootOrder; 438 442 roles["#mount"] = AnchorRole_Storage; 439 443 roles["#attach"] = AnchorRole_Storage; … … 535 539 break; 536 540 } 541 case AnchorRole_BootOrder: 542 { 543 /* Prepare popup: */ 544 QPointer<QIDialogContainer> pPopup = new QIDialogContainer(0, Qt::Tool); 545 if (pPopup) 546 { 547 /* Prepare editor: */ 548 UIBootOrderEditor *pEditor = new UIBootOrderEditor(pPopup, true /* with label */); 549 if (pEditor) 550 { 551 pEditor->setValue(bootItemsFromSerializedString(strData.section(',', 0, 0))); 552 pPopup->setWidget(pEditor); 553 } 554 555 /* Adjust popup geometry: */ 556 pPopup->move(QCursor::pos()); 557 pPopup->adjustSize(); 558 559 // WORKAROUND: 560 // On Windows, Tool dialogs aren't activated by default by some reason. 561 // So we have created sltActivateWindow wrapping actual activateWindow 562 // to fix that annoying issue. 563 QMetaObject::invokeMethod(pPopup, "sltActivateWindow", Qt::QueuedConnection); 564 /* Execute popup, change machine name if confirmed: */ 565 if (pPopup->exec() == QDialog::Accepted) 566 setMachineAttribute(machine(), MachineAttribute_BootOrder, QVariant::fromValue(pEditor->value())); 567 568 /* Delete popup: */ 569 delete pPopup; 570 } 571 break; 572 } 537 573 case AnchorRole_Storage: 538 574 { -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIBootOrderEditor.cpp
r79981 r79982 367 367 } 368 368 369 QString UIBootDataTools::bootItemsToReadableString(const UIBootItemDataList &bootItems) 370 { 371 /* Prepare list: */ 372 QStringList list; 373 /* We are reflecting only enabled items: */ 374 foreach (const UIBootItemData &bootItem, bootItems) 375 if (bootItem.m_fEnabled) 376 list << gpConverter->toString(bootItem.m_enmType); 377 /* But if list is empty we are adding Null item at least: */ 378 if (list.isEmpty()) 379 list << gpConverter->toString(KDeviceType_Null); 380 /* Join list to string: */ 381 return list.join(", "); 382 } 383 384 QString UIBootDataTools::bootItemsToSerializedString(const UIBootItemDataList &bootItems) 385 { 386 /* Prepare list: */ 387 QStringList list; 388 /* This is simple, we are adding '+' before enabled types and '-' before disabled: */ 389 foreach (const UIBootItemData &bootItem, bootItems) 390 list << (bootItem.m_fEnabled ? QString("+%1").arg(bootItem.m_enmType) : QString("-%1").arg(bootItem.m_enmType)); 391 /* Join list to string: */ 392 return list.join(';'); 393 } 394 395 UIBootItemDataList UIBootDataTools::bootItemsFromSerializedString(const QString &strBootItems) 396 { 397 /* Prepare list: */ 398 UIBootItemDataList list; 399 /* First of all, split passed string to arguments: */ 400 const QStringList arguments = strBootItems.split(';'); 401 /* Now parse in backward direction, we have added '+' before enabled types and '-' before disabled: */ 402 foreach (QString strArgument, arguments) 403 { 404 UIBootItemData data; 405 data.m_fEnabled = strArgument.startsWith('+'); 406 strArgument.remove(QRegExp("[+-]")); 407 data.m_enmType = static_cast<KDeviceType>(strArgument.toInt()); 408 list << data; 409 } 410 /* Return list: */ 411 return list; 412 } 413 369 414 370 415 /********************************************************************************************************************************* -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIBootOrderEditor.h
r79981 r79982 63 63 }; 64 64 typedef QList<UIBootItemData> UIBootItemDataList; 65 Q_DECLARE_METATYPE(UIBootItemDataList); 65 66 66 67 … … 72 73 /** Saves @a bootItems list to passed @a comMachine. */ 73 74 SHARED_LIBRARY_STUFF void saveBootItems(const UIBootItemDataList &bootItems, CMachine &comMachine); 75 76 /** Converts passed @a bootItems list into human readable string. */ 77 SHARED_LIBRARY_STUFF QString bootItemsToReadableString(const UIBootItemDataList &bootItems); 78 79 /** Performs serialization for passed @a bootItems list. */ 80 SHARED_LIBRARY_STUFF QString bootItemsToSerializedString(const UIBootItemDataList &bootItems); 81 /** Performs deserialization for passed @a strBootItems string. */ 82 SHARED_LIBRARY_STUFF UIBootItemDataList bootItemsFromSerializedString(const QString &strBootItems); 74 83 } 75 84 using namespace UIBootDataTools;
Note:
See TracChangeset
for help on using the changeset viewer.