Changeset 34961 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Dec 10, 2010 3:36:39 PM (14 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxDefs.cpp
r34519 r34961 77 77 const char* VBoxDefs::GUI_Export_Bucket = "GUI/Export/Bucket"; 78 78 const char* VBoxDefs::GUI_PreventBetaWarning = "GUI/PreventBetaWarning"; 79 const char* VBoxDefs::GUI_RecentListHD = "GUI/RecentListHD"; 80 const char* VBoxDefs::GUI_RecentListCD = "GUI/RecentListCD"; 81 const char* VBoxDefs::GUI_RecentListFD = "GUI/RecentListFD"; 79 82 #ifdef VBOX_WITH_VIDEOHWACCEL 80 83 const char* VBoxDefs::GUI_Accelerate2D_StretchLinear = "GUI/Accelerate2D/StretchLinear"; -
trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxDefs.h
r34743 r34961 153 153 static const char* GUI_PreventBetaWarning; 154 154 155 static const char* GUI_RecentListHD; 156 static const char* GUI_RecentListCD; 157 static const char* GUI_RecentListFD; 158 155 159 #ifdef VBOX_WITH_VIDEOHWACCEL 156 160 static const char* GUI_Accelerate2D_StretchLinear; -
trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp
r34959 r34961 2597 2597 QString VBoxGlobal::openMediumWithFileOpenDialog(VBoxDefs::MediumType mediumType, QWidget *pParent, 2598 2598 const QString &strDefaultFolder /* = QString() */, 2599 bool fUseLastFolder /* = false */) const2599 bool fUseLastFolder /* = false */) 2600 2600 { 2601 2601 /* Initialize variables: */ 2602 CVirtualBox vbox = vboxGlobal().virtualBox();2603 2602 QString strHomeFolder = fUseLastFolder && !m_strLastFolder.isEmpty() ? m_strLastFolder : 2604 strDefaultFolder.isEmpty() ? vbox .GetHomeFolder() : strDefaultFolder;2603 strDefaultFolder.isEmpty() ? vboxGlobal().virtualBox().GetHomeFolder() : strDefaultFolder; 2605 2604 QList < QPair <QString, QString> > filters; 2606 2605 QStringList backends; … … 2609 2608 QString strTitle; 2610 2609 QString allType; 2611 KDeviceType type;2612 2610 switch (mediumType) 2613 2611 { … … 2617 2615 strTitle = tr ("Choose a virtual hard disk file"); 2618 2616 allType = tr ("hard disk"); 2619 type = KDeviceType_HardDisk;2620 2617 break; 2621 2618 } … … 2625 2622 strTitle = tr ("Choose a virtual CD/DVD disk file"); 2626 2623 allType = tr ("CD/DVD-ROM disk"); 2627 type = KDeviceType_DVD;2628 2624 break; 2629 2625 } … … 2633 2629 strTitle = tr ("Choose a virtual floppy disk file"); 2634 2630 allType = tr ("floppy disk"); 2635 type = KDeviceType_Floppy;2636 2631 break; 2637 2632 } … … 2657 2652 /* Create open file dialog: */ 2658 2653 QStringList files = QIFileDialog::getOpenFileNames(strHomeFolder, strFilter, pParent, strTitle, 0, true, true); 2654 2655 /* If dialog has some result: */ 2659 2656 if (!files.empty() && !files[0].isEmpty()) 2660 { 2661 /* Get location: */ 2662 QString strLocation = files[0]; 2663 2664 /* Remember absolute path: */ 2665 m_strLastFolder = QFileInfo(strLocation).absolutePath(); 2666 2667 /* Open corresponding medium: */ 2668 CMedium comMedium = vbox.OpenMedium(strLocation, type, KAccessMode_ReadWrite); 2669 2670 if (vbox.isOk()) 2671 { 2672 /* Prepare vbox medium wrapper: */ 2673 VBoxMedium vboxMedium; 2674 2675 /* First of all we should test if that medium already opened: */ 2676 if (!vboxGlobal().findMedium(comMedium, vboxMedium)) 2677 { 2678 /* And create new otherwise: */ 2679 vboxMedium = VBoxMedium(CMedium(comMedium), mediumType, KMediumState_Created); 2680 vboxGlobal().addMedium(vboxMedium); 2681 } 2682 2683 /* Return vboxMedium id: */ 2684 return vboxMedium.id(); 2685 } 2686 else 2687 vboxProblem().cannotOpenMedium(pParent, vbox, mediumType, strLocation); 2688 } 2657 return openMedium(mediumType, files[0]); 2658 2659 return QString(); 2660 } 2661 2662 QString VBoxGlobal::openMedium(VBoxDefs::MediumType mediumType, QString strMediumLocation) 2663 { 2664 /* Convert to native separators: */ 2665 strMediumLocation = QDir::toNativeSeparators(strMediumLocation); 2666 2667 /* Initialize variables: */ 2668 CVirtualBox vbox = vboxGlobal().virtualBox(); 2669 2670 /* Remember the path of the last chosen medium: */ 2671 m_strLastFolder = QFileInfo(strMediumLocation).absolutePath(); 2672 2673 /* Update recently used list: */ 2674 QString strRecentAddress = mediumType == VBoxDefs::MediumType_HardDisk ? VBoxDefs::GUI_RecentListHD : 2675 mediumType == VBoxDefs::MediumType_DVD ? VBoxDefs::GUI_RecentListCD : 2676 mediumType == VBoxDefs::MediumType_Floppy ? VBoxDefs::GUI_RecentListFD : 2677 QString(); 2678 QStringList recentMediumList = virtualBox().GetExtraData(strRecentAddress).split(';'); 2679 if (recentMediumList.contains(strMediumLocation)) 2680 recentMediumList.removeAll(strMediumLocation); 2681 recentMediumList.prepend(strMediumLocation); 2682 while(recentMediumList.size() > 5) recentMediumList.removeLast(); 2683 virtualBox().SetExtraData(strRecentAddress, recentMediumList.join(";")); 2684 2685 /* Open corresponding medium: */ 2686 CMedium comMedium = vbox.OpenMedium(strMediumLocation, mediumTypeToGlobal(mediumType), KAccessMode_ReadWrite); 2687 2688 if (vbox.isOk()) 2689 { 2690 /* Prepare vbox medium wrapper: */ 2691 VBoxMedium vboxMedium; 2692 2693 /* First of all we should test if that medium already opened: */ 2694 if (!vboxGlobal().findMedium(comMedium, vboxMedium)) 2695 { 2696 /* And create new otherwise: */ 2697 vboxMedium = VBoxMedium(CMedium(comMedium), mediumType, KMediumState_Created); 2698 vboxGlobal().addMedium(vboxMedium); 2699 } 2700 2701 /* Return vboxMedium id: */ 2702 return vboxMedium.id(); 2703 } 2704 else 2705 vboxProblem().cannotOpenMedium(0, vbox, mediumType, strMediumLocation); 2689 2706 2690 2707 return QString(); -
trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.h
r34947 r34961 594 594 595 595 QString openMediumWithFileOpenDialog(VBoxDefs::MediumType mediumType, QWidget *pParent = 0, 596 const QString &strDefaultFolder = QString(), bool fUseLastFolder = false) const; 596 const QString &strDefaultFolder = QString(), bool fUseLastFolder = false); 597 QString openMedium(VBoxDefs::MediumType mediumType, QString strMediumLocation); 597 598 598 599 /* Returns the number of current running Fe/Qt4 main windows. */ -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp
r34947 r34961 80 80 Q_DECLARE_METATYPE(MediumTarget); 81 81 82 struct RecentMediumTarget 83 { 84 RecentMediumTarget() : name(QString("")), port(0), device(0), location(QString()), type(VBoxDefs::MediumType_Invalid) {} 85 RecentMediumTarget(const QString &strName, LONG iPort, LONG iDevice, const QString &strLocation, VBoxDefs::MediumType eType) 86 : name(strName), port(iPort), device(iDevice), location(strLocation), type(eType) {} 87 QString name; 88 LONG port; 89 LONG device; 90 QString location; 91 VBoxDefs::MediumType type; 92 }; 93 Q_DECLARE_METATYPE(RecentMediumTarget); 94 82 95 struct USBTarget 83 96 { … … 1097 1110 1098 1111 /* Fill attachments menu: */ 1099 CMachinemachine = session().GetMachine();1112 const CMachine &machine = session().GetMachine(); 1100 1113 const CMediumAttachmentVector &attachments = machine.GetMediumAttachments(); 1101 foreach (const CMediumAttachment &attachment, attachments) 1102 { 1103 CStorageController controller = machine.GetStorageControllerByName(attachment.GetController()); 1114 for (int iAttachmentIndex = 0; iAttachmentIndex < attachments.size(); ++iAttachmentIndex) 1115 { 1116 /* Current attachment: */ 1117 const CMediumAttachment &attachment = attachments[iAttachmentIndex]; 1118 /* Current controller: */ 1119 const CStorageController &controller = machine.GetStorageControllerByName(attachment.GetController()); 1120 /* If controller present and device type correct: */ 1104 1121 if (!controller.isNull() && (attachment.GetType() == deviceType)) 1105 1122 { 1123 /* Current attachment attributes: */ 1124 const CMedium ¤tMedium = attachment.GetMedium(); 1125 QString strCurrentId = currentMedium.isNull() ? QString::null : currentMedium.GetId(); 1126 QString strCurrentLocation = currentMedium.isNull() ? QString::null : currentMedium.GetLocation(); 1127 1106 1128 /* Attachment menu item: */ 1107 1129 QMenu *pAttachmentMenu = 0; … … 1110 1132 pAttachmentMenu = new QMenu(pMenu); 1111 1133 pAttachmentMenu->setTitle(QString("%1 (%2)").arg(controller.GetName()) 1112 .arg 1113 1114 1134 .arg(vboxGlobal().toString(StorageSlot(controller.GetBus(), 1135 attachment.GetPort(), 1136 attachment.GetDevice())))); 1115 1137 switch (controller.GetBus()) 1116 1138 { … … 1130 1152 else pAttachmentMenu = pMenu; 1131 1153 1132 /* Mount Medium actions: */ 1154 /* Prepare choose-existing-medium action: */ 1155 QAction *pChooseExistingMediumAction = pAttachmentMenu->addAction(QIcon(":/select_file_16px.png"), QString(), 1156 this, SLOT(sltMountStorageMedium())); 1157 pChooseExistingMediumAction->setData(QVariant::fromValue(MediumTarget(controller.GetName(), attachment.GetPort(), 1158 attachment.GetDevice(), mediumType))); 1159 1160 /* Prepare choose-particular-medium actions: */ 1133 1161 CMediumVector mediums; 1162 QString strRecentMediumAddress; 1134 1163 switch (mediumType) 1135 1164 { 1136 1165 case VBoxDefs::MediumType_DVD: 1137 mediums += vboxGlobal().virtualBox().GetHost().GetDVDDrives();1138 mediums += vboxGlobal().virtualBox().GetDVDImages();1166 mediums = vboxGlobal().virtualBox().GetHost().GetDVDDrives(); 1167 strRecentMediumAddress = VBoxDefs::GUI_RecentListCD; 1139 1168 break; 1140 1169 case VBoxDefs::MediumType_Floppy: 1141 mediums += vboxGlobal().virtualBox().GetHost().GetFloppyDrives();1142 mediums += vboxGlobal().virtualBox().GetFloppyImages();1170 mediums = vboxGlobal().virtualBox().GetHost().GetFloppyDrives(); 1171 strRecentMediumAddress = VBoxDefs::GUI_RecentListFD; 1143 1172 break; 1144 1173 default: … … 1146 1175 } 1147 1176 1148 /* Mediums to be shown: */ 1149 int mediumsToBeShown = 0; 1150 const int maxMediumsToBeShown = 5; 1151 CMedium currentMedium = attachment.GetMedium(); 1152 QString currentId = currentMedium.isNull() ? QString::null : currentMedium.GetId(); 1153 bool fCurrentUsed = false; 1154 foreach (CMedium medium, mediums) 1177 /* Prepare choose-host-drive actions: */ 1178 for (int iHostDriveIndex = 0; iHostDriveIndex < mediums.size(); ++iHostDriveIndex) 1155 1179 { 1156 bool isMediumUsed = false; 1157 foreach (const CMediumAttachment &otherAttachment, attachments) 1180 const CMedium &medium = mediums[iHostDriveIndex]; 1181 bool fIsHostDriveUsed = false; 1182 for (int iOtherAttachmentIndex = 0; iOtherAttachmentIndex < attachments.size(); ++iOtherAttachmentIndex) 1158 1183 { 1184 const CMediumAttachment &otherAttachment = attachments[iOtherAttachmentIndex]; 1159 1185 if (otherAttachment != attachment) 1160 1186 { 1161 CMediumotherMedium = otherAttachment.GetMedium();1187 const CMedium &otherMedium = otherAttachment.GetMedium(); 1162 1188 if (!otherMedium.isNull() && otherMedium.GetId() == medium.GetId()) 1163 1189 { 1164 isMediumUsed = true;1190 fIsHostDriveUsed = true; 1165 1191 break; 1166 1192 } 1167 1193 } 1168 1194 } 1169 if (! isMediumUsed)1195 if (!fIsHostDriveUsed) 1170 1196 { 1171 if (!fCurrentUsed && !currentMedium.isNull() && mediumsToBeShown == maxMediumsToBeShown - 1) 1172 medium = currentMedium; 1173 1174 if (medium.GetId() == currentId) 1175 fCurrentUsed = true; 1176 1177 QAction *mountMediumAction = new QAction(VBoxMedium(medium, mediumType).name(), pAttachmentMenu); 1178 mountMediumAction->setCheckable(true); 1179 mountMediumAction->setChecked(!currentMedium.isNull() && medium.GetId() == currentId); 1180 mountMediumAction->setData(QVariant::fromValue(MediumTarget(controller.GetName(), 1181 attachment.GetPort(), 1182 attachment.GetDevice(), 1183 medium.GetId()))); 1184 connect(mountMediumAction, SIGNAL(triggered(bool)), this, SLOT(sltMountStorageMedium())); 1185 pAttachmentMenu->addAction(mountMediumAction); 1186 ++ mediumsToBeShown; 1187 if (mediumsToBeShown == maxMediumsToBeShown) 1188 break; 1197 QAction *pChooseHostDriveAction = pAttachmentMenu->addAction(VBoxMedium(medium, mediumType).name(), 1198 this, SLOT(sltMountStorageMedium())); 1199 pChooseHostDriveAction->setCheckable(true); 1200 pChooseHostDriveAction->setChecked(!currentMedium.isNull() && medium.GetId() == strCurrentId); 1201 pChooseHostDriveAction->setData(QVariant::fromValue(MediumTarget(controller.GetName(), attachment.GetPort(), 1202 attachment.GetDevice(), medium.GetId()))); 1189 1203 } 1190 1204 } 1191 1205 1192 /* Virtual Media Manager action: */ 1193 QAction *callVMMAction = new QAction(pAttachmentMenu); 1194 callVMMAction->setIcon(QIcon(":/diskimage_16px.png")); 1195 callVMMAction->setData(QVariant::fromValue(MediumTarget(controller.GetName(), 1196 attachment.GetPort(), 1197 attachment.GetDevice(), 1198 mediumType))); 1199 connect(callVMMAction, SIGNAL(triggered(bool)), this, SLOT(sltMountStorageMedium())); 1200 pAttachmentMenu->addAction(callVMMAction); 1206 /* Prepare choose-recent-medium actions: */ 1207 QStringList recentMediumList = vboxGlobal().virtualBox().GetExtraData(strRecentMediumAddress).split(';'); 1208 /* For every list-item: */ 1209 for (int i = 0; i < recentMediumList.size(); ++i) 1210 { 1211 QString strRecentMediumLocation = QDir::toNativeSeparators(recentMediumList[i]); 1212 if (QFile::exists(strRecentMediumLocation)) 1213 { 1214 bool fIsRecentMediumUsed = false; 1215 for (int iOtherAttachmentIndex = 0; iOtherAttachmentIndex < attachments.size(); ++iOtherAttachmentIndex) 1216 { 1217 const CMediumAttachment &otherAttachment = attachments[iOtherAttachmentIndex]; 1218 if (otherAttachment != attachment) 1219 { 1220 const CMedium &otherMedium = otherAttachment.GetMedium(); 1221 if (!otherMedium.isNull() && otherMedium.GetLocation() == strRecentMediumLocation) 1222 { 1223 fIsRecentMediumUsed = true; 1224 break; 1225 } 1226 } 1227 } 1228 if (!fIsRecentMediumUsed) 1229 { 1230 QAction *pChooseRecentMediumAction = pAttachmentMenu->addAction(QFileInfo(strRecentMediumLocation).fileName(), 1231 this, SLOT(sltMountRecentStorageMedium())); 1232 pChooseRecentMediumAction->setCheckable(true); 1233 pChooseRecentMediumAction->setChecked(!currentMedium.isNull() && strRecentMediumLocation == strCurrentLocation); 1234 pChooseRecentMediumAction->setData(QVariant::fromValue(RecentMediumTarget(controller.GetName(), attachment.GetPort(), 1235 attachment.GetDevice(), strRecentMediumLocation, mediumType))); 1236 } 1237 } 1238 } 1201 1239 1202 1240 /* Insert separator: */ … … 1216 1254 { 1217 1255 case VBoxDefs::MediumType_DVD: 1218 callVMMAction->setText(QApplication::translate("UIMachineLogic", "More CD/DVD Images..."));1219 unmountMediumAction->setText(QApplication::translate("UIMachine Logic", "Unmount CD/DVD Device"));1256 pChooseExistingMediumAction->setText(QApplication::translate("UIMachineSettingsStorage", "Choose a virtual CD/DVD disk file...")); 1257 unmountMediumAction->setText(QApplication::translate("UIMachineSettingsStorage", "Remove disk from virtual drive")); 1220 1258 unmountMediumAction->setIcon(UIIconPool::iconSet(":/cd_unmount_16px.png", 1221 1259 ":/cd_unmount_dis_16px.png")); 1222 1260 break; 1223 1261 case VBoxDefs::MediumType_Floppy: 1224 callVMMAction->setText(QApplication::translate("UIMachineLogic", "More Floppy Images..."));1225 unmountMediumAction->setText(QApplication::translate("UIMachine Logic", "Unmount Floppy Device"));1262 pChooseExistingMediumAction->setText(QApplication::translate("UIMachineSettingsStorage", "Choose a virtual floppy disk file...")); 1263 unmountMediumAction->setText(QApplication::translate("UIMachineSettingsStorage", "Remove disk from virtual drive")); 1226 1264 unmountMediumAction->setIcon(UIIconPool::iconSet(":/fd_unmount_16px.png", 1227 1265 ":/fd_unmount_dis_16px.png")); … … 1332 1370 if (!machine.isOk()) 1333 1371 vboxProblem().cannotSaveMachineSettings(machine); 1372 } 1373 } 1374 1375 void UIMachineLogic::sltMountRecentStorageMedium() 1376 { 1377 /* Get sender action: */ 1378 QAction *pSender = qobject_cast<QAction*>(sender()); 1379 AssertMsg(pSender, ("This slot should only be called on selecting storage menu item!\n")); 1380 1381 /* Get mount-target: */ 1382 RecentMediumTarget target = pSender->data().value<RecentMediumTarget>(); 1383 1384 /* Get new medium id: */ 1385 QString strNewId = vboxGlobal().openMedium(target.type, target.location); 1386 1387 if (!strNewId.isEmpty()) 1388 { 1389 /* Get current machine: */ 1390 CMachine machine = session().GetMachine(); 1391 1392 /* Get current medium id: */ 1393 const CMediumAttachment ¤tAttachment = machine.GetMediumAttachment(target.name, target.port, target.device); 1394 CMedium currentMedium = currentAttachment.GetMedium(); 1395 QString strCurrentId = currentMedium.isNull() ? QString("") : currentMedium.GetId(); 1396 1397 /* Should we mount or unmount? */ 1398 bool fMount = strNewId != strCurrentId; 1399 1400 /* Prepare target medium: */ 1401 const VBoxMedium &vboxMedium = fMount ? vboxGlobal().findMedium(strNewId) : VBoxMedium(); 1402 const CMedium &comMedium = fMount ? vboxMedium.medium() : CMedium(); 1403 1404 /* 'Mounted' flag: */ 1405 bool fWasMounted = false; 1406 1407 /* Try to mount medium to the predefined port/device: */ 1408 machine.MountMedium(target.name, target.port, target.device, comMedium, false /* force? */); 1409 if (machine.isOk()) 1410 fWasMounted = true; 1411 else 1412 { 1413 /* Ask for force remounting: */ 1414 if (vboxProblem().cannotRemountMedium(0, machine, vboxGlobal().findMedium(fMount ? strNewId : strCurrentId), fMount, true /* retry? */) == QIMessageBox::Ok) 1415 { 1416 /* Force remount medium to the predefined port/device: */ 1417 machine.MountMedium(target.name, target.port, target.device, comMedium, true /* force? */); 1418 if (machine.isOk()) 1419 fWasMounted = true; 1420 else 1421 vboxProblem().cannotRemountMedium(0, machine, vboxGlobal().findMedium(fMount ? strNewId : strCurrentId), fMount, false /* retry? */); 1422 } 1423 } 1424 1425 /* Save medium mounted at runtime if necessary: */ 1426 if (fWasMounted && !uisession()->isIgnoreRuntimeMediumsChanging()) 1427 { 1428 machine.SaveSettings(); 1429 if (!machine.isOk()) 1430 vboxProblem().cannotSaveMachineSettings(machine); 1431 } 1334 1432 } 1335 1433 } -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.h
r33540 r34961 171 171 void sltPrepareStorageMenu(); 172 172 void sltMountStorageMedium(); 173 void sltMountRecentStorageMedium(); 173 174 void sltPrepareUSBMenu(); 174 175 void sltAttachUSBDevice(); -
trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsStorage.cpp
r34947 r34961 2404 2404 /* Add "Choose a virtual hard disk file" action: */ 2405 2405 addChooseExistingMediumAction(pOpenMediumMenu, tr("Choose a virtual hard disk file...")); 2406 /* Add recent mediums list: */ 2407 addRecentMediumActions(pOpenMediumMenu, m_pMediumIdHolder->type()); 2406 2408 break; 2407 2409 } … … 2412 2414 /* Add "Choose a physical drive" actions: */ 2413 2415 addChooseHostDriveActions(pOpenMediumMenu); 2416 /* Add recent mediums list: */ 2417 addRecentMediumActions(pOpenMediumMenu, m_pMediumIdHolder->type()); 2414 2418 /* Add "Eject current medium" action: */ 2415 2419 pOpenMediumMenu->addSeparator(); … … 2427 2431 /* Add "Choose a physical drive" actions: */ 2428 2432 addChooseHostDriveActions(pOpenMediumMenu); 2433 /* Add recent mediums list: */ 2434 addRecentMediumActions(pOpenMediumMenu, m_pMediumIdHolder->type()); 2429 2435 /* Add "Eject current medium" action: */ 2430 2436 pOpenMediumMenu->addSeparator(); … … 2469 2475 if (pChooseHostDriveAction) 2470 2476 m_pMediumIdHolder->setId(pChooseHostDriveAction->data().toString()); 2477 } 2478 2479 void UIMachineSettingsStorage::sltChooseRecentMedium() 2480 { 2481 /* This slot should be called ONLY by choose-recent-medium action: */ 2482 QAction *pChooseRecentMediumAction = qobject_cast<QAction*>(sender()); 2483 AssertMsg(pChooseRecentMediumAction, ("Can't access choose-recent-medium action!\n")); 2484 if (pChooseRecentMediumAction) 2485 { 2486 /* Get recent medium type & name: */ 2487 QStringList mediumInfoList = pChooseRecentMediumAction->data().toString().split(','); 2488 VBoxDefs::MediumType mediumType = (VBoxDefs::MediumType)mediumInfoList[0].toUInt(); 2489 QString strMediumLocation = mediumInfoList[1]; 2490 QString strMediumId = vboxGlobal().openMedium(mediumType, strMediumLocation); 2491 if (!strMediumId.isNull()) 2492 m_pMediumIdHolder->setId(strMediumId); 2493 } 2471 2494 } 2472 2495 … … 2927 2950 } 2928 2951 2952 void UIMachineSettingsStorage::addRecentMediumActions(QMenu *pOpenMediumMenu, VBoxDefs::MediumType recentMediumType) 2953 { 2954 /* Compose recent-medium list address: */ 2955 QString strRecentMediumAddress; 2956 switch (recentMediumType) 2957 { 2958 case VBoxDefs::MediumType_HardDisk: 2959 strRecentMediumAddress = VBoxDefs::GUI_RecentListHD; 2960 break; 2961 case VBoxDefs::MediumType_DVD: 2962 strRecentMediumAddress = VBoxDefs::GUI_RecentListCD; 2963 break; 2964 case VBoxDefs::MediumType_Floppy: 2965 strRecentMediumAddress = VBoxDefs::GUI_RecentListFD; 2966 break; 2967 default: 2968 break; 2969 } 2970 /* Get recent-medium list: */ 2971 QStringList recentMediumList = vboxGlobal().virtualBox().GetExtraData(strRecentMediumAddress).split(';'); 2972 /* For every list-item: */ 2973 for (int index = 0; index < recentMediumList.size(); ++index) 2974 { 2975 /* Prepare corresponding action: */ 2976 QString strRecentMediumLocation = recentMediumList[index]; 2977 if (QFile::exists(strRecentMediumLocation)) 2978 { 2979 QAction *pChooseRecentMediumAction = pOpenMediumMenu->addAction(QFileInfo(strRecentMediumLocation).fileName(), 2980 this, SLOT(sltChooseRecentMedium())); 2981 pChooseRecentMediumAction->setData(QString("%1,%2").arg(recentMediumType).arg(strRecentMediumLocation)); 2982 } 2983 } 2984 } 2985 2929 2986 #include "UIMachineSettingsStorage.moc" 2930 2987 -
trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsStorage.h
r34329 r34961 637 637 void sltChooseExistingMedium(); 638 638 void sltChooseHostDrive(); 639 void sltChooseRecentMedium(); 639 640 640 641 void updateActionsState(); … … 667 668 void addChooseExistingMediumAction(QMenu *pOpenMediumMenu, const QString &strActionName); 668 669 void addChooseHostDriveActions(QMenu *pOpenMediumMenu); 670 void addRecentMediumActions(QMenu *pOpenMediumMenu, VBoxDefs::MediumType recentMediumType); 669 671 670 672 QIWidgetValidator *mValidator;
Note:
See TracChangeset
for help on using the changeset viewer.