Changeset 70111 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Dec 13, 2017 2:34:56 PM (7 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp
r70110 r70111 113 113 /* Other VBox includes: */ 114 114 # include <iprt/asm.h> 115 # include <iprt/env.h> 116 # include <iprt/getopt.h> 117 # include <iprt/ldr.h> 115 118 # include <iprt/param.h> 116 119 # include <iprt/path.h> 117 # include <iprt/env.h>118 # include <iprt/ldr.h>119 120 # include <iprt/system.h> 120 121 # include <iprt/stream.h> … … 1033 1034 } 1034 1035 1036 1037 /** 1038 * Create a VISO using the file open dialog. 1039 * 1040 * Temporarily caches (enumerate) it in GUI inner mediums cache. 1041 * 1042 * @returns Medium ID string, empty on abort. 1043 */ 1044 QString VBoxGlobal::createVisoMediumWithFileOpenDialog(QWidget *pParent, const QString &strMachineFolder, bool fUseLastFolder) 1045 { 1046 AssertReturn(!strMachineFolder.isEmpty(), QString()); 1047 1048 /* Where to start browsing for content. */ 1049 QString strLastFolder = gEDataManager->recentFolderForOpticalDisks(); 1050 if (strLastFolder.isEmpty()) 1051 strLastFolder = gEDataManager->recentFolderForFloppyDisks(); 1052 if (strLastFolder.isEmpty()) 1053 strLastFolder = gEDataManager->recentFolderForHardDrives(); 1054 QString strHomeFolder = fUseLastFolder && !strLastFolder.isEmpty() ? strLastFolder : strMachineFolder; 1055 1056 /* Execute the open file dialog: */ 1057 /** @todo make it possible to select directories... */ 1058 QStringList files = QIFileDialog::getOpenFileNames(strHomeFolder, tr("All files (*)"), pParent, 1059 /// @todo tr("Please select files and directories to be on the VISO"), 1060 tr("Please select files to be on the VISO"), 1061 0, true /*aResolveSymlinks*/, false /*aSingleFile*/); 1062 1063 /* Return if no result. */ 1064 if (files.empty() || files[0].isEmpty()) 1065 return QString(); 1066 1067 /* Produce the VISO. */ 1068 char szVisoPath[RTPATH_MAX]; 1069 int vrc = RTPathJoin(szVisoPath, sizeof(szVisoPath), strMachineFolder.toUtf8().constData(), "ad-hoc.viso"); 1070 if (RT_SUCCESS(vrc)) 1071 { 1072 PRTSTREAM pStrmViso; 1073 vrc = RTStrmOpen(szVisoPath, "w", &pStrmViso); 1074 if (RT_SUCCESS(vrc)) 1075 { 1076 RTUUID Uuid; 1077 vrc = RTUuidCreate(&Uuid); 1078 if (RT_SUCCESS(vrc)) 1079 { 1080 RTStrmPrintf(pStrmViso, "--iprt-iso-maker-file-marker-bourne-sh %RTuuid\n", &Uuid); 1081 1082 for (int iFile = 0; iFile < files.size(); iFile++) 1083 { 1084 QByteArray const utf8Name = files[iFile].toUtf8(); 1085 const char *apszArgv[2] = { utf8Name.constData(), NULL }; 1086 char *pszQuoted; 1087 vrc = RTGetOptArgvToString(&pszQuoted, apszArgv, RTGETOPTARGV_CNV_QUOTE_BOURNE_SH); 1088 if (RT_SUCCESS(vrc)) 1089 { 1090 RTStrmPrintf(pStrmViso, "%s\n", pszQuoted); 1091 RTStrFree(pszQuoted); 1092 } 1093 else 1094 break; 1095 } 1096 1097 RTStrmFlush(pStrmViso); 1098 if (RT_SUCCESS(vrc)) 1099 vrc = RTStrmError(pStrmViso); 1100 } 1101 1102 RTStrmClose(pStrmViso); 1103 } 1104 } 1105 1106 /* Done. */ 1107 if (RT_SUCCESS(vrc)) 1108 return openMedium(UIMediumType_DVD, QString(szVisoPath), pParent); 1109 1110 /** @todo error message. */ 1111 return QString(); 1112 } 1113 1035 1114 /* Open some external medium using file open dialog 1036 1115 * and temporary cache (enumerate) it in GUI inner mediums cache: */ … … 1269 1348 pActionOpenExistingMedium->setText(QApplication::translate("UIMachineSettingsStorage", "Choose disk image...", "This is used for hard disks, optical media and floppies")); 1270 1349 1350 /* Prepare ad-hoc-viso action for DVD-ROMs: */ 1351 if (mediumType == UIMediumType_DVD) 1352 { 1353 QAction *pActionAdHocViso = menu.addAction(UIIconPool::iconSet(":/select_file_16px.png"), QString(), 1354 pListener, pszSlotName); 1355 pActionAdHocViso->setData(QVariant::fromValue(UIMediumTarget(strControllerName, currentAttachment.GetPort(), 1356 currentAttachment.GetDevice(), mediumType, 1357 UIMediumTarget::UIMediumTargetType_CreateAdHocVISO))); 1358 pActionAdHocViso->setText(QApplication::translate("UIMachineSettingsStorage", "Create ad hoc VISO...", "This is used for optical media")); 1359 } 1271 1360 1272 1361 /* Insert separator: */ … … 1399 1488 switch (target.type) 1400 1489 { 1401 /* Do we have an exact ID ? */1490 /* Do we have an exact ID or do we let the user open a medium? */ 1402 1491 case UIMediumTarget::UIMediumTargetType_WithID: 1492 case UIMediumTarget::UIMediumTargetType_CreateAdHocVISO: 1403 1493 { 1404 1494 /* New mount-target attributes: */ … … 1419 1509 /* Call for file-open dialog: */ 1420 1510 const QString strMachineFolder(QFileInfo(constMachine.GetSettingsFilePath()).absolutePath()); 1421 const QString strMediumID = vboxGlobal().openMediumWithFileOpenDialog(target.mediumType, windowManager().mainWindowShown(), 1422 strMachineFolder); 1511 const QString strMediumID = target.type != UIMediumTarget::UIMediumTargetType_CreateAdHocVISO 1512 ? vboxGlobal().openMediumWithFileOpenDialog(target.mediumType, 1513 windowManager().mainWindowShown(), 1514 strMachineFolder) 1515 : vboxGlobal().createVisoMediumWithFileOpenDialog(windowManager().mainWindowShown(), 1516 strMachineFolder, true /*fUseLastFolder*/); 1423 1517 /* Return focus back: */ 1424 1518 if (pLastFocusedWidget) -
trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.h
r69615 r70111 313 313 void createMedium(const UIMedium &medium); 314 314 void deleteMedium(const QString &strMediumID); 315 QString createVisoMediumWithFileOpenDialog(QWidget *pParent, const QString &strMachineFolder, bool fUseLastFolder); 315 316 QString openMediumWithFileOpenDialog(UIMediumType mediumType, QWidget *pParent = 0, 316 317 const QString &strDefaultFolder = QString(), bool fUseLastFolder = true); -
trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumDefs.h
r69500 r70111 55 55 { 56 56 /** Medium-target types. */ 57 enum UIMediumTargetType { UIMediumTargetType_WithID, UIMediumTargetType_WithLocation };57 enum UIMediumTargetType { UIMediumTargetType_WithID, UIMediumTargetType_WithLocation, UIMediumTargetType_CreateAdHocVISO }; 58 58 59 59 /** Medium-target constructor. */
Note:
See TracChangeset
for help on using the changeset viewer.