Changeset 83855 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Apr 20, 2020 1:36:50 PM (5 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/manager
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManager.cpp
r83854 r83855 292 292 uiCommon().launchMachine(comMachine); 293 293 else 294 sltOpenAddMachineDialog(strFile);294 openAddMachineDialog(strFile); 295 295 } 296 296 /* And has allowed VBox OVF file extension: */ … … 465 465 UIQObjectPropertySetter guardBlock(actionPool()->action(UIActionIndexST_M_File_S_ImportAppliance), "opened", true); 466 466 connect(&guardBlock, &UIQObjectPropertySetter::sigAboutToBeDestroyed, 467 this, &UIVirtualBoxManager::sltHandleUpdateActionAppearanceRequest);467 this, &UIVirtualBoxManager::sltHandleUpdateActionAppearanceRequest); 468 468 updateActionsAppearance(); 469 469 … … 557 557 } 558 558 559 void UIVirtualBoxManager::sltOpenAddMachineDialog(const QString &strFileName /* = QString() */) 560 { 561 /* Initialize variables: */ 562 #ifdef VBOX_WS_MAC 563 QString strTmpFile = ::darwinResolveAlias(strFileName); 564 #else 565 QString strTmpFile = strFileName; 566 #endif 567 CVirtualBox comVBox = uiCommon().virtualBox(); 568 559 void UIVirtualBoxManager::sltOpenAddMachineDialog() 560 { 569 561 /* Lock the actions preventing cascade calls: */ 570 562 UIQObjectPropertySetter guardBlock(QList<QObject*>() << actionPool()->action(UIActionIndexST_M_Welcome_S_Add) … … 576 568 updateActionsAppearance(); 577 569 578 /* No file specified: */ 579 if (strTmpFile.isEmpty()) 580 { 581 QString strBaseFolder = comVBox.GetSystemProperties().GetDefaultMachineFolder(); 582 QString strTitle = tr("Select a virtual machine file"); 583 QStringList extensions; 584 for (int i = 0; i < VBoxFileExts.size(); ++i) 585 extensions << QString("*.%1").arg(VBoxFileExts[i]); 586 QString strFilter = tr("Virtual machine files (%1)").arg(extensions.join(" ")); 587 /* Create open file dialog: */ 588 QStringList fileNames = QIFileDialog::getOpenFileNames(strBaseFolder, strFilter, this, strTitle, 0, true, true); 589 if (!fileNames.isEmpty()) 590 strTmpFile = fileNames.at(0); 591 } 592 593 /* Nothing was chosen? */ 594 if (strTmpFile.isEmpty()) 595 return; 596 597 /* Make sure this machine can be opened: */ 598 CMachine comMachineNew = comVBox.OpenMachine(strTmpFile); 599 if (!comVBox.isOk()) 600 { 601 msgCenter().cannotOpenMachine(comVBox, strTmpFile); 602 return; 603 } 604 605 /* Make sure this machine was NOT registered already: */ 606 CMachine comMachineOld = comVBox.FindMachine(comMachineNew.GetId().toString()); 607 if (!comMachineOld.isNull()) 608 { 609 msgCenter().cannotReregisterExistingMachine(strTmpFile, comMachineOld.GetName()); 610 return; 611 } 612 613 /* Register that machine: */ 614 comVBox.RegisterMachine(comMachineNew); 570 /* Open add machine dialog: */ 571 openAddMachineDialog(); 615 572 } 616 573 … … 1436 1393 /* 'Welcome' menu connections: */ 1437 1394 connect(actionPool()->action(UIActionIndexST_M_Welcome_S_Add), &UIAction::triggered, 1438 this, &UIVirtualBoxManager::sltOpenAddMachineDialog Default);1395 this, &UIVirtualBoxManager::sltOpenAddMachineDialog); 1439 1396 1440 1397 /* 'Group' menu connections: */ 1441 1398 connect(actionPool()->action(UIActionIndexST_M_Group_S_Add), &UIAction::triggered, 1442 this, &UIVirtualBoxManager::sltOpenAddMachineDialog Default);1399 this, &UIVirtualBoxManager::sltOpenAddMachineDialog); 1443 1400 connect(actionPool()->action(UIActionIndexST_M_Group_M_StartOrShow), &UIAction::triggered, 1444 1401 this, &UIVirtualBoxManager::sltPerformStartOrShowMachine); … … 1458 1415 /* 'Machine' menu connections: */ 1459 1416 connect(actionPool()->action(UIActionIndexST_M_Machine_S_Add), &UIAction::triggered, 1460 this, &UIVirtualBoxManager::sltOpenAddMachineDialog Default);1417 this, &UIVirtualBoxManager::sltOpenAddMachineDialog); 1461 1418 connect(actionPool()->action(UIActionIndexST_M_Machine_S_Settings), &UIAction::triggered, 1462 1419 this, &UIVirtualBoxManager::sltOpenMachineSettingsDialogDefault); … … 1632 1589 } 1633 1590 1591 void UIVirtualBoxManager::openAddMachineDialog(const QString &strFileName /* = QString() */) 1592 { 1593 /* Initialize variables: */ 1594 #ifdef VBOX_WS_MAC 1595 QString strTmpFile = ::darwinResolveAlias(strFileName); 1596 #else 1597 QString strTmpFile = strFileName; 1598 #endif 1599 CVirtualBox comVBox = uiCommon().virtualBox(); 1600 1601 /* No file specified: */ 1602 if (strTmpFile.isEmpty()) 1603 { 1604 QString strBaseFolder = comVBox.GetSystemProperties().GetDefaultMachineFolder(); 1605 QString strTitle = tr("Select a virtual machine file"); 1606 QStringList extensions; 1607 for (int i = 0; i < VBoxFileExts.size(); ++i) 1608 extensions << QString("*.%1").arg(VBoxFileExts[i]); 1609 QString strFilter = tr("Virtual machine files (%1)").arg(extensions.join(" ")); 1610 /* Create open file dialog: */ 1611 QStringList fileNames = QIFileDialog::getOpenFileNames(strBaseFolder, strFilter, this, strTitle, 0, true, true); 1612 if (!fileNames.isEmpty()) 1613 strTmpFile = fileNames.at(0); 1614 } 1615 1616 /* Nothing was chosen? */ 1617 if (strTmpFile.isEmpty()) 1618 return; 1619 1620 /* Make sure this machine can be opened: */ 1621 CMachine comMachineNew = comVBox.OpenMachine(strTmpFile); 1622 if (!comVBox.isOk()) 1623 { 1624 msgCenter().cannotOpenMachine(comVBox, strTmpFile); 1625 return; 1626 } 1627 1628 /* Make sure this machine was NOT registered already: */ 1629 CMachine comMachineOld = comVBox.FindMachine(comMachineNew.GetId().toString()); 1630 if (!comMachineOld.isNull()) 1631 { 1632 msgCenter().cannotReregisterExistingMachine(strTmpFile, comMachineOld.GetName()); 1633 return; 1634 } 1635 1636 /* Register that machine: */ 1637 comVBox.RegisterMachine(comMachineNew); 1638 } 1639 1634 1640 void UIVirtualBoxManager::performStartOrShowVirtualMachines(const QList<UIVirtualMachineItem*> &items, UICommon::LaunchMode enmLaunchMode) 1635 1641 { -
trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManager.h
r83854 r83855 185 185 /** @name Machine menu stuff. 186 186 * @{ */ 187 /** Handles call to open Add Machine dialog. 188 * @param strFileName can bring the name of file to add machine from. */ 189 void sltOpenAddMachineDialog(const QString &strFileName = QString()); 190 /** Handles call to open Add Machine dialog the default way. */ 191 void sltOpenAddMachineDialogDefault() { sltOpenAddMachineDialog(); } 187 /** Handles call to open add machine dialog. */ 188 void sltOpenAddMachineDialog(); 192 189 193 190 /** Handles call to open Machine Settings dialog. … … 304 301 /** Returns whether single cloud profile group is selected. */ 305 302 bool isSingleCloudProfileGroupSelected() const; 303 /** @} */ 304 305 /** @name VM add stuff. 306 * @{ */ 307 /** Opens add machine dialog specifying initial name with @a strFileName. */ 308 void openAddMachineDialog(const QString &strFileName = QString()); 306 309 /** @} */ 307 310
Note:
See TracChangeset
for help on using the changeset viewer.