Changeset 29942 in vbox
- Timestamp:
- Jun 1, 2010 12:07:18 PM (15 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/wizards/firstrun
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/wizards/firstrun/UIFirstRunWzd.cpp
r29730 r29942 62 62 } 63 63 64 bool UIFirstRunWzd::isDefaultHardDiskAttached(const CMachine &machine) 65 { 66 LONG iPort = 0; 67 LONG iDevice = 0; 64 bool UIFirstRunWzd::isBootHardDiskAttached(const CMachine &machine) 65 { 66 /* Result is 'false' initially: */ 67 bool fIsBootHardDiskAttached = false; 68 /* Get 'vbox' global object: */ 68 69 CVirtualBox vbox = vboxGlobal().virtualBox(); 69 CGuestOSType type = vbox.GetGuestOSType(machine.GetOSTypeId()); 70 KStorageBus ctrDvdBus = type.GetRecommendedDvdStorageBus(); 71 KStorageBus ctrHdBus = type.GetRecommendedHdStorageBus(); 72 KStorageControllerType dvdStorageControllerType = type.GetRecommendedDvdStorageController(); 73 KStorageControllerType hdStorageControllerType = type.GetRecommendedHdStorageController(); 74 CMediumAttachment hda = ctrHdBus != ctrDvdBus || hdStorageControllerType != dvdStorageControllerType ? 75 machine.GetMediumAttachment(VBoxVMSettingsHD::tr("Storage Controller 1"), iPort, iDevice) : 76 machine.GetMediumAttachment(VBoxVMSettingsHD::tr("Storage Controller"), iPort, iDevice); 77 return !hda.isNull() && hda.GetType() == KDeviceType_HardDisk; 70 /* Determine machine 'OS type': */ 71 const CGuestOSType &osType = vbox.GetGuestOSType(machine.GetOSTypeId()); 72 /* Determine recommended controller's 'bus' & 'type': */ 73 KStorageBus hdCtrBus = osType.GetRecommendedHdStorageBus(); 74 KStorageControllerType hdCtrType = osType.GetRecommendedHdStorageController(); 75 /* Enumerate attachments vector: */ 76 const CMediumAttachmentVector &attachments = machine.GetMediumAttachments(); 77 for (int i = 0; i < attachments.size(); ++i) 78 { 79 /* Get current attachment: */ 80 const CMediumAttachment &attachment = attachments[i]; 81 /* Determine attachment's controller: */ 82 const CStorageController &controller = machine.GetStorageControllerByName(attachment.GetController()); 83 /* If controller's 'bus' & 'type' are recommended and attachment's 'type' is 'hard disk': */ 84 if (controller.GetBus() == hdCtrBus && 85 controller.GetControllerType() == hdCtrType && 86 attachment.GetType() == KDeviceType_HardDisk) 87 { 88 /* Set the result to 'true': */ 89 fIsBootHardDiskAttached = true; 90 break; 91 } 92 } 93 /* Return result: */ 94 return fIsBootHardDiskAttached; 78 95 } 79 96 … … 97 114 98 115 /* Hide unnecessary text labels */ 99 bool fIs DefaultHDAttached = UIFirstRunWzd::isDefaultHardDiskAttached(machine);100 m_pPage1Text1Var1->setHidden(!fIs DefaultHDAttached);101 m_pPage1Text1Var2->setHidden(fIs DefaultHDAttached);116 bool fIsBootHDAttached = UIFirstRunWzd::isBootHardDiskAttached(machine); 117 m_pPage1Text1Var1->setHidden(!fIsBootHDAttached); 118 m_pPage1Text1Var2->setHidden(fIsBootHDAttached); 102 119 } 103 120 … … 160 177 161 178 /* Hide unnecessary text labels */ 162 bool fIs DefaultHDAttached = UIFirstRunWzd::isDefaultHardDiskAttached(machine);163 m_pPage2Text1Var1->setHidden(!fIs DefaultHDAttached);164 m_pPage2Text1Var2->setHidden(fIs DefaultHDAttached);179 bool fIsBootHDAttached = UIFirstRunWzd::isBootHardDiskAttached(machine); 180 m_pPage2Text1Var1->setHidden(!fIsBootHDAttached); 181 m_pPage2Text1Var2->setHidden(fIsBootHDAttached); 165 182 166 183 /* Assign media selector attributes */ … … 237 254 238 255 /* Hide unnecessary text labels */ 239 bool fIs DefaultHDAttached = UIFirstRunWzd::isDefaultHardDiskAttached(machine);240 m_pPage3Text1Var1->setHidden(!fIs DefaultHDAttached);241 m_pPage3Text1Var2->setHidden(fIs DefaultHDAttached);242 m_pPage3Text2Var1->setHidden(!fIs DefaultHDAttached);243 m_pPage3Text2Var2->setHidden(fIs DefaultHDAttached);256 bool fIsBootHDAttached = UIFirstRunWzd::isBootHardDiskAttached(machine); 257 m_pPage3Text1Var1->setHidden(!fIsBootHDAttached); 258 m_pPage3Text1Var2->setHidden(fIsBootHDAttached); 259 m_pPage3Text2Var1->setHidden(!fIsBootHDAttached); 260 m_pPage3Text2Var2->setHidden(fIsBootHDAttached); 244 261 } 245 262 … … 293 310 bool UIFirstRunWzdPage3::insertDevice() 294 311 { 295 /* Composing default controller name */ 312 /* Get 'vbox' global object: */ 313 CVirtualBox vbox = vboxGlobal().virtualBox(); 314 /* Determine machine 'OS type': */ 315 const CGuestOSType &osType = vbox.GetGuestOSType(m_Machine.GetOSTypeId()); 316 /* Determine recommended controller's 'bus' & 'type': */ 317 KStorageBus dvdCtrBus = osType.GetRecommendedDvdStorageBus(); 318 KStorageControllerType dvdCtrType = osType.GetRecommendedDvdStorageController(); 319 /* Declare null 'dvd' attachment: */ 320 CMediumAttachment cda; 321 /* Enumerate attachments vector: */ 322 const CMediumAttachmentVector &attachments = m_Machine.GetMediumAttachments(); 323 for (int i = 0; i < attachments.size(); ++i) 324 { 325 /* Get current attachment: */ 326 const CMediumAttachment &attachment = attachments[i]; 327 /* Determine attachment's controller: */ 328 const CStorageController &controller = m_Machine.GetStorageControllerByName(attachment.GetController()); 329 /* If controller's 'bus' & 'type' are recommended and attachment's 'type' is 'dvd': */ 330 if (controller.GetBus() == dvdCtrBus && 331 controller.GetControllerType() == dvdCtrType && 332 attachment.GetType() == KDeviceType_DVD) 333 { 334 /* Remember attachment: */ 335 cda = attachment; 336 break; 337 } 338 } 339 AssertMsg(!cda.isNull(), ("Storage Controller is NOT properly configured!\n")); 340 /* Get chosen 'dvd' medium to mount: */ 296 341 QString mediumId = field("id").toString(); 297 LONG iPort = 1; 298 LONG iDevice = 0; 299 QString strCtnName = VBoxVMSettingsHD::tr("Storage Controller"); 300 CMediumAttachment cda = m_Machine.GetMediumAttachment(strCtnName, iPort, iDevice); 301 AssertMsg(!cda.isNull() && cda.GetType() == KDeviceType_DVD, 302 ("Storage Controller is NOT properly configured!\n")); 303 /* Mount medium to the predefined port/device */ 304 m_Machine.MountMedium(strCtnName, iPort, iDevice, mediumId, false /* force */); 342 /* Mount medium to the predefined port/device: */ 343 m_Machine.MountMedium(cda.GetController(), cda.GetPort(), cda.GetDevice(), mediumId, false /* force */); 305 344 if (m_Machine.isOk()) 306 345 return true; -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/firstrun/UIFirstRunWzd.h
r28933 r29942 37 37 UIFirstRunWzd(QWidget *pParent, const CMachine &machine); 38 38 39 static bool is DefaultHardDiskAttached(const CMachine &machine);39 static bool isBootHardDiskAttached(const CMachine &machine); 40 40 41 41 protected:
Note:
See TracChangeset
for help on using the changeset viewer.