- Timestamp:
- Nov 2, 2010 9:50:33 PM (14 years ago)
- svn:sync-xref-src-repo-rev:
- 67338
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp
r33702 r33712 30 30 #include "UIIconPool.h" 31 31 #include "UIExtraDataEventHandler.h" 32 #include "QIFileDialog.h" 32 33 33 34 #include "UIMachine.h" … … 2560 2561 } 2561 2562 2563 /* Open some external medium using file open dialog 2564 * and temporary cache (enumerate) it in GUI inner mediums cache: */ 2565 QString VBoxGlobal::openMediumWithFileOpenDialog(VBoxDefs::MediumType mediumType, QWidget *pParent) const 2566 { 2567 /* Initialize variables: */ 2568 CVirtualBox vbox = vboxGlobal().virtualBox(); 2569 QString strHomeFolder = vbox.GetHomeFolder(); 2570 QList < QPair <QString, QString> > filters; 2571 QStringList backends; 2572 QStringList prefixes; 2573 QString strFilter; 2574 QString strTitle; 2575 QString allType; 2576 KDeviceType type; 2577 switch (mediumType) 2578 { 2579 case VBoxDefs::MediumType_HardDisk: 2580 { 2581 filters = vboxGlobal().HDDBackends(); 2582 strTitle = tr ("Select a hard disk image file"); 2583 allType = tr ("hard disk"); 2584 type = KDeviceType_HardDisk; 2585 break; 2586 } 2587 case VBoxDefs::MediumType_DVD: 2588 { 2589 filters = vboxGlobal().DVDBackends(); 2590 strTitle = tr ("Select a CD/DVD-ROM disk image file"); 2591 allType = tr ("CD/DVD-ROM disk"); 2592 type = KDeviceType_DVD; 2593 break; 2594 } 2595 case VBoxDefs::MediumType_Floppy: 2596 { 2597 filters = vboxGlobal().FloppyBackends(); 2598 strTitle = tr ("Select a floppy disk image file"); 2599 allType = tr ("floppy disk"); 2600 type = KDeviceType_Floppy; 2601 break; 2602 } 2603 default: 2604 break; 2605 } 2606 2607 /* Prepare filters and backends: */ 2608 for (int i = 0; i < filters.count(); ++i) 2609 { 2610 /* Get iterated filter: */ 2611 QPair <QString, QString> item = filters.at(i); 2612 /* Create one backend filter string: */ 2613 backends << QString("%1 (%2)").arg(item.first).arg(item.second); 2614 /* Save the suffix's for the "All" entry: */ 2615 prefixes << item.second; 2616 } 2617 if (!prefixes.isEmpty()) 2618 backends.insert(0, tr("All %1 images (%2)").arg(allType).arg(prefixes.join(" ").trimmed())); 2619 backends << tr("All files (*)"); 2620 strFilter = backends.join(";;").trimmed(); 2621 2622 /* Create open file dialog: */ 2623 QStringList files = QIFileDialog::getOpenFileNames(strHomeFolder, strFilter, pParent, strTitle, 0, true, true); 2624 if (!files.empty() && !files[0].isEmpty()) 2625 { 2626 /* Get location: */ 2627 QString strLocation = files[0]; 2628 2629 /* Open corresponding medium: */ 2630 CMedium comMedium = vbox.OpenMedium(strLocation, type, KAccessMode_ReadWrite); 2631 2632 if (vbox.isOk()) 2633 { 2634 /* Prepare vbox medium wrapper: */ 2635 VBoxMedium vboxMedium; 2636 2637 /* First of all we should test if that medium already opened: */ 2638 if (!vboxGlobal().findMedium(comMedium, vboxMedium)) 2639 { 2640 /* And create new otherwise: */ 2641 vboxMedium = VBoxMedium(CMedium(comMedium), mediumType, KMediumState_Created); 2642 vboxGlobal().addMedium(vboxMedium); 2643 } 2644 2645 /* Return vboxMedium id: */ 2646 return vboxMedium.id(); 2647 } 2648 else 2649 vboxProblem().cannotOpenMedium(pParent, vbox, mediumType, strLocation); 2650 } 2651 2652 return QString(); 2653 } 2654 2562 2655 #ifdef VBOX_GUI_WITH_SYSTRAY 2563 2656 /** … … 3416 3509 } 3417 3510 strList += " " + tr("and") + " " + list.at(list.size() - 1); 3418 } else3511 } 3419 3512 return strList; 3420 3513 } -
trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.h
r33702 r33712 579 579 } 580 580 581 QString openMediumWithFileOpenDialog(VBoxDefs::MediumType mediumType, QWidget *pParent = 0) const; 582 581 583 /* Returns the number of current running Fe/Qt4 main windows. */ 582 584 int mainWindowCount(); -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp
r33636 r33712 34 34 #include "UIMachineWindow.h" 35 35 #include "UISession.h" 36 #include "VBox MediaManagerDlg.h"36 #include "VBoxGlobal.h" 37 37 #include "VBoxProblemReporter.h" 38 38 #include "VBoxTakeSnapshotDlg.h" … … 1293 1293 } 1294 1294 /* Open VMM Dialog: */ 1295 VBoxMediaManagerDlg dlg(defaultMachineWindow()->machineWindow()); 1296 dlg.setup(target.type, true /* select? */, true /* refresh? */, machine, currentId, true, usedImages); 1297 if (dlg.exec() == QDialog::Accepted) 1298 newId = dlg.selectedId(); 1295 QString strMediumId = vboxGlobal().openMediumWithFileOpenDialog(target.type, defaultMachineWindow()->machineWindow()); 1296 if (!strMediumId.isNull()) 1297 newId = strMediumId; 1299 1298 else return; 1300 1299 } -
trunk/src/VBox/Frontends/VirtualBox/src/settings/vm/VBoxVMSettingsHD.cpp
r33686 r33712 2410 2410 void VBoxVMSettingsHD::sltOpenMedium() 2411 2411 { 2412 QString id = getWithOpenFileDialog(mCbVdi->type());2412 QString id = vboxGlobal().openMediumWithFileOpenDialog(mCbVdi->type(), this); 2413 2413 if (!id.isNull()) 2414 mCbVdi->setCurrentItem 2414 mCbVdi->setCurrentItem(id); 2415 2415 } 2416 2416 … … 2477 2477 int askResult = vboxProblem().confirmRunNewHDWzdOrOFD (deviceType); 2478 2478 QString mediumId = askResult == QIMessageBox::Yes ? getWithNewHDWizard() : 2479 askResult == QIMessageBox::No ? getWithOpenFileDialog(typeToLocal (deviceType)) : QString();2479 askResult == QIMessageBox::No ? vboxGlobal().openMediumWithFileOpenDialog(typeToLocal (deviceType), this) : QString(); 2480 2480 if (mediumId.isNull()) 2481 2481 mediumId = firstAvailableId; … … 2759 2759 } 2760 2760 2761 QString VBoxVMSettingsHD::getWithOpenFileDialog (VBoxDefs::MediumType aMediumType)2762 {2763 /* Initialize variables: */2764 CVirtualBox vbox = vboxGlobal().virtualBox();2765 QString strHomeFolder = vbox.GetHomeFolder();2766 QList < QPair <QString, QString> > filters;2767 QStringList backends;2768 QStringList prefixes;2769 QString strFilter;2770 QString strTitle;2771 QString allType;2772 KDeviceType type;2773 switch (aMediumType)2774 {2775 case VBoxDefs::MediumType_HardDisk:2776 {2777 filters = vboxGlobal().HDDBackends();2778 strTitle = tr ("Select a hard disk image file");2779 allType = tr ("hard disk");2780 type = KDeviceType_HardDisk;2781 break;2782 }2783 case VBoxDefs::MediumType_DVD:2784 {2785 filters = vboxGlobal().DVDBackends();2786 strTitle = tr ("Select a CD/DVD-ROM disk image file");2787 allType = tr ("CD/DVD-ROM disk");2788 type = KDeviceType_DVD;2789 break;2790 }2791 case VBoxDefs::MediumType_Floppy:2792 {2793 filters = vboxGlobal().FloppyBackends();2794 strTitle = tr ("Select a floppy disk image file");2795 allType = tr ("floppy disk");2796 type = KDeviceType_Floppy;2797 break;2798 }2799 default:2800 break;2801 }2802 2803 /* Prepare filters and backends: */2804 for (int i = 0; i < filters.count(); ++i)2805 {2806 /* Get iterated filter: */2807 QPair <QString, QString> item = filters.at(i);2808 /* Create one backend filter string: */2809 backends << QString("%1 (%2)").arg(item.first).arg(item.second);2810 /* Save the suffix's for the "All" entry: */2811 prefixes << item.second;2812 }2813 if (!prefixes.isEmpty())2814 backends.insert(0, tr("All %1 images (%2)").arg(allType).arg(prefixes.join(" ").trimmed()));2815 backends << tr("All files (*)");2816 strFilter = backends.join(";;").trimmed();2817 2818 /* Create open file dialog: */2819 QStringList files = QIFileDialog::getOpenFileNames(strHomeFolder, strFilter, this, strTitle, 0, true, true);2820 if (!files.empty() && !files[0].isEmpty())2821 {2822 /* Get location: */2823 QString strLocation = files[0];2824 2825 /* Open corresponding medium: */2826 CMedium comMedium = vbox.OpenMedium(strLocation, type, KAccessMode_ReadWrite);2827 2828 if (vbox.isOk())2829 {2830 /* Prepare vbox medium wrapper: */2831 VBoxMedium vboxMedium;2832 2833 /* First of all we should test if that medium already opened: */2834 if (!vboxGlobal().findMedium(comMedium, vboxMedium))2835 {2836 /* And create new otherwise: */2837 vboxMedium = VBoxMedium(CMedium(comMedium), aMediumType, KMediumState_Created);2838 vboxGlobal().addMedium(vboxMedium);2839 }2840 2841 /* Return vboxMedium id: */2842 return vboxMedium.id();2843 }2844 else2845 vboxProblem().cannotOpenMedium(this, vbox, aMediumType, strLocation);2846 }2847 2848 /* Return null string: */2849 return QString();2850 }2851 2852 2761 QString VBoxVMSettingsHD::getWithNewHDWizard() 2853 2762 { -
trunk/src/VBox/Frontends/VirtualBox/src/settings/vm/VBoxVMSettingsHD.h
r33686 r33712 638 638 void addAttachmentWrapper (KDeviceType aDevice); 639 639 640 QString getWithOpenFileDialog (VBoxDefs::MediumType aMediumType);641 640 QString getWithNewHDWizard(); 642 641 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/firstrun/UIFirstRunWzd.cpp
r33140 r33712 21 21 #include "UIFirstRunWzd.h" 22 22 #include "UIIconPool.h" 23 #include "VBox MediaManagerDlg.h"23 #include "VBoxGlobal.h" 24 24 #include "VBoxProblemReporter.h" 25 25 #include "VBoxVMSettingsHD.h" … … 224 224 void UIFirstRunWzdPage2::sltOpenVirtualMediaManager() 225 225 { 226 /* Create & open VMM*/227 VBoxMediaManagerDlg dlg(this);228 dlg.setup(m_pMediaSelector->type(), true /* propose to choose? */);229 if ( dlg.exec() == QDialog::Accepted)230 m_pMediaSelector->setCurrentItem( dlg.selectedId());226 /* Get opened vboxMedium id: */ 227 QString strMediumId = vboxGlobal().openMediumWithFileOpenDialog(m_pMediaSelector->type(), this); 228 /* Update medium-combo if necessary: */ 229 if (!strMediumId.isNull()) 230 m_pMediaSelector->setCurrentItem(strMediumId); 231 231 } 232 232 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UINewVMWzd.cpp
r33676 r33712 534 534 void UINewVMWzdPage4::getWithFileOpenDialog() 535 535 { 536 /* Initialize variables: */ 537 CVirtualBox vbox = vboxGlobal().virtualBox(); 538 QString strHomeFolder = vbox.GetHomeFolder(); 539 QString title = m_pVMMButton->toolTip(); 540 QList < QPair <QString, QString> > filters = vboxGlobal().HDDBackends(); 541 QString allType = tr("hard disk"); 542 QString strFilter; 543 QStringList backends; 544 QStringList prefixes; 545 546 /* Prepare filters and backends: */ 547 for (int i = 0; i < filters.count(); ++i) 548 { 549 /* Get iterated filter: */ 550 QPair <QString, QString> item = filters.at(i); 551 /* Create one backend filter string: */ 552 backends << QString("%1 (%2)").arg(item.first).arg(item.second); 553 /* Save the suffix's for the "All" entry: */ 554 prefixes << item.second; 555 } 556 if (!prefixes.isEmpty()) 557 backends.insert(0, tr("All %1 images (%2)").arg(allType).arg(prefixes.join(" ").trimmed())); 558 backends << tr("All files (*)"); 559 strFilter = backends.join(";;").trimmed(); 560 561 /* Create open file dialog: */ 562 QStringList files = QIFileDialog::getOpenFileNames(strHomeFolder, strFilter, this, title, 0, true, true); 563 if (!files.empty() && !files[0].isEmpty()) 564 { 565 /* Get location: */ 566 QString strLocation = files[0]; 567 568 /* Open corresponding medium: */ 569 CMedium comMedium = vbox.OpenMedium(strLocation, KDeviceType_HardDisk, KAccessMode_ReadWrite); 570 571 if (vbox.isOk()) 572 { 573 /* Prepare vbox medium wrapper: */ 574 VBoxMedium vboxMedium; 575 576 /* First of all we should test if that medium already opened: */ 577 if (!vboxGlobal().findMedium(comMedium, vboxMedium)) 578 { 579 /* And create new otherwise: */ 580 vboxMedium = VBoxMedium(CMedium(comMedium), VBoxDefs::MediumType_HardDisk, KMediumState_Created); 581 vboxGlobal().addMedium(vboxMedium); 582 } 583 584 /* Ask medium combobox to select newly added medium: */ 585 m_pDiskSelector->setCurrentItem(vboxMedium.id()); 586 587 /* Update hard disk source: */ 588 hardDiskSourceChanged(); 589 590 m_pDiskSelector->setFocus(); 591 } 592 else 593 vboxProblem().cannotOpenMedium(this, vbox, VBoxDefs::MediumType_HardDisk, strLocation); 536 /* Get opened vboxMedium id: */ 537 QString strMediumId = vboxGlobal().openMediumWithFileOpenDialog(VBoxDefs::MediumType_HardDisk, this); 538 if (!strMediumId.isNull()) 539 { 540 /* Update medium-combo if necessary: */ 541 m_pDiskSelector->setCurrentItem(strMediumId); 542 /* Update hard disk source: */ 543 hardDiskSourceChanged(); 544 /* Focus on hard disk combo: */ 545 m_pDiskSelector->setFocus(); 594 546 } 595 547 }
Note:
See TracChangeset
for help on using the changeset viewer.