VirtualBox

Ignore:
Timestamp:
Apr 13, 2022 5:33:39 PM (3 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
150954
Message:

FE/Qt: bugref:10215. Making necessary changes so that new vm wizard is kicked off when VirtualBox binary is started with an iso as command line argument.

Location:
trunk/src/VBox/Frontends/VirtualBox/src
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManager.cpp

    r94168 r94593  
    654654        const QString strFile = list.at(i).toLocalFile();
    655655#endif
     656        const QStringList isoExtensionList = QStringList() << "iso";
    656657        /* If there is such file exists: */
    657658        if (!strFile.isEmpty() && QFile::exists(strFile))
     
    689690#endif
    690691            }
     692            else if (UICommon::hasAllowedExtension(strFile, isoExtensionList))
     693            {
     694                openNewMachineWizard(strFile);
     695            }
    691696        }
    692697    }
     
    957962void UIVirtualBoxManager::sltOpenNewMachineWizard()
    958963{
    959     /* Lock the actions preventing cascade calls: */
    960     UIQObjectPropertySetter guardBlock(QList<QObject*>() << actionPool()->action(UIActionIndexMN_M_Welcome_S_New)
    961                                                          << actionPool()->action(UIActionIndexMN_M_Machine_S_New)
    962                                                          << actionPool()->action(UIActionIndexMN_M_Group_S_New),
    963                                        "opened", true);
    964     connect(&guardBlock, &UIQObjectPropertySetter::sigAboutToBeDestroyed,
    965             this, &UIVirtualBoxManager::sltHandleUpdateActionAppearanceRequest);
    966     updateActionsAppearance();
    967 
    968     /* Get first selected item: */
    969     UIVirtualMachineItem *pItem = currentItem();
    970 
    971     /* For global item or local machine: */
    972     if (   !pItem
    973         || pItem->itemType() == UIVirtualMachineItemType_Local)
    974     {
    975         CUnattended comUnattendedInstaller = uiCommon().virtualBox().CreateUnattendedInstaller();
    976         AssertMsg(!comUnattendedInstaller.isNull(), ("Could not create unattended installer!\n"));
    977 
    978         /* Use the "safe way" to open stack of Mac OS X Sheets: */
    979         QWidget *pWizardParent = windowManager().realParentWindow(this);
    980         UISafePointerWizardNewVM pWizard = new UIWizardNewVM(pWizardParent, actionPool(),
    981                                                              m_pWidget->fullGroupName(), "gui-createvm", comUnattendedInstaller);
    982         windowManager().registerNewParent(pWizard, pWizardParent);
    983 
    984         /* Execute wizard: */
    985         pWizard->exec();
    986 
    987         bool fStartHeadless = pWizard->startHeadless();
    988         bool fUnattendedEnabled = pWizard->isUnattendedEnabled();
    989         QString strMachineId = pWizard->createdMachineId().toString();
    990         delete pWizard;
    991         /* Handle unattended install stuff: */
    992         if (fUnattendedEnabled)
    993             startUnattendedInstall(comUnattendedInstaller, fStartHeadless, strMachineId);
    994     }
    995     /* For cloud machine: */
    996     else
    997     {
    998         /* Use the "safe way" to open stack of Mac OS X Sheets: */
    999         QWidget *pWizardParent = windowManager().realParentWindow(this);
    1000         UISafePointerWizardNewCloudVM pWizard = new UIWizardNewCloudVM(pWizardParent, m_pWidget->fullGroupName());
    1001         windowManager().registerNewParent(pWizard, pWizardParent);
    1002 
    1003         /* Execute wizard: */
    1004         pWizard->exec();
    1005         delete pWizard;
    1006     }
     964    openNewMachineWizard();
    1007965}
    1008966
     
    25292487}
    25302488
     2489void UIVirtualBoxManager::openNewMachineWizard(const QString &strISOFilePath /* = QString() */)
     2490{
     2491    /* Lock the actions preventing cascade calls: */
     2492    UIQObjectPropertySetter guardBlock(QList<QObject*>() << actionPool()->action(UIActionIndexMN_M_Welcome_S_New)
     2493                                                         << actionPool()->action(UIActionIndexMN_M_Machine_S_New)
     2494                                                         << actionPool()->action(UIActionIndexMN_M_Group_S_New),
     2495                                       "opened", true);
     2496    connect(&guardBlock, &UIQObjectPropertySetter::sigAboutToBeDestroyed,
     2497            this, &UIVirtualBoxManager::sltHandleUpdateActionAppearanceRequest);
     2498    updateActionsAppearance();
     2499
     2500    /* Get first selected item: */
     2501    UIVirtualMachineItem *pItem = currentItem();
     2502
     2503    /* For global item or local machine: */
     2504    if (   !pItem
     2505        || pItem->itemType() == UIVirtualMachineItemType_Local)
     2506    {
     2507        CUnattended comUnattendedInstaller = uiCommon().virtualBox().CreateUnattendedInstaller();
     2508        AssertMsg(!comUnattendedInstaller.isNull(), ("Could not create unattended installer!\n"));
     2509
     2510        /* Use the "safe way" to open stack of Mac OS X Sheets: */
     2511        QWidget *pWizardParent = windowManager().realParentWindow(this);
     2512        UISafePointerWizardNewVM pWizard = new UIWizardNewVM(pWizardParent, actionPool(),
     2513                                                             m_pWidget->fullGroupName(), "gui-createvm",
     2514                                                             comUnattendedInstaller, strISOFilePath);
     2515        windowManager().registerNewParent(pWizard, pWizardParent);
     2516
     2517        /* Execute wizard: */
     2518        pWizard->exec();
     2519
     2520        bool fStartHeadless = pWizard->startHeadless();
     2521        bool fUnattendedEnabled = pWizard->isUnattendedEnabled();
     2522        QString strMachineId = pWizard->createdMachineId().toString();
     2523        delete pWizard;
     2524        /* Handle unattended install stuff: */
     2525        if (fUnattendedEnabled)
     2526            startUnattendedInstall(comUnattendedInstaller, fStartHeadless, strMachineId);
     2527    }
     2528    /* For cloud machine: */
     2529    else
     2530    {
     2531        /* Use the "safe way" to open stack of Mac OS X Sheets: */
     2532        QWidget *pWizardParent = windowManager().realParentWindow(this);
     2533        UISafePointerWizardNewCloudVM pWizard = new UIWizardNewCloudVM(pWizardParent, m_pWidget->fullGroupName());
     2534        windowManager().registerNewParent(pWizard, pWizardParent);
     2535
     2536        /* Execute wizard: */
     2537        pWizard->exec();
     2538        delete pWizard;
     2539    }
     2540}
     2541
    25312542/* static */
    25322543void UIVirtualBoxManager::launchMachine(CMachine &comMachine,
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManager.h

    r94089 r94593  
    368368        /** Opens add machine dialog specifying initial name with @a strFileName. */
    369369        void openAddMachineDialog(const QString &strFileName = QString());
    370 
     370        /** Opens new machine dialog specifying initial name with @a strFileName. */
     371        void openNewMachineWizard(const QString &strISOFilePath = QString());
    371372        /** Launches certain @a comMachine in specified @a enmLaunchMode. */
    372373        static void launchMachine(CMachine &comMachine, UICommon::LaunchMode enmLaunchMode = UICommon::LaunchMode_Default);
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/editors/UINameAndSystemEditor.cpp

    r94445 r94593  
    136136}
    137137
     138void UINameAndSystemEditor::setISOImagePath(const QString &strPath)
     139{
     140    if (m_pSelectorImage)
     141        m_pSelectorImage->setPath(strPath);
     142    emit sigImageChanged(strPath);
     143}
    138144QString UINameAndSystemEditor::ISOImagePath() const
    139145{
     
    543549                m_pLabelEdition->setAlignment(Qt::AlignRight);
    544550                m_pLabelEdition->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
    545 
    546551                m_pLayout->addWidget(m_pLabelEdition, iRow, 0);
    547552            }
     
    550555            if (m_pComboEdition)
    551556            {
    552                 m_pLabelEdition->setBuddy(m_pComboEdition->focusProxy());
     557                m_pLabelEdition->setBuddy(m_pComboEdition);
    553558                m_pLayout->addWidget(m_pComboEdition, iRow, 1, 1, 2);
    554559            }
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/editors/UINameAndSystemEditor.h

    r94445 r94593  
    111111    /** Returns image string selected by the user. */
    112112    QString ISOImagePath() const;
     113    /** Sets image path. */
     114    void setISOImagePath(const QString &strPath);
    113115
    114116    /** Defines the VM OS @a strTypeId and @a strFamilyId if passed. */
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVM.cpp

    r94078 r94593  
    4949UIWizardNewVM::UIWizardNewVM(QWidget *pParent, UIActionPool *pActionPool,
    5050                             const QString &strMachineGroup, const QString &strHelpHashtag,
    51                              CUnattended &comUnattended)
     51                             CUnattended &comUnattended, const QString &strISOFilePath /* = QString() */)
    5252    : UINativeWizard(pParent, WizardType_NewVM, WizardMode_Auto, strHelpHashtag)
    5353    , m_strMachineGroup(strMachineGroup)
     
    7171    , m_comUnattended(comUnattended)
    7272    , m_fStartHeadless(false)
     73    , m_strInitialISOFilePath(strISOFilePath)
    7374{
    7475#ifndef VBOX_WS_MAC
     
    9192        case WizardMode_Basic:
    9293        {
    93             addPage(new UIWizardNewVMNameOSTypePage);
     94            UIWizardNewVMNameOSTypePage *pNamePage = new UIWizardNewVMNameOSTypePage;
     95            addPage(pNamePage);
     96            if (!m_strInitialISOFilePath.isEmpty())
     97                pNamePage->setISOFilePath(m_strInitialISOFilePath);
    9498            m_iUnattendedInstallPageIndex = addPage(new UIWizardNewVMUnattendedPage);
    9599            setUnattendedPageVisible(false);
     
    101105        case WizardMode_Expert:
    102106        {
    103             addPage(new UIWizardNewVMExpertPage(m_pActionPool));
     107            UIWizardNewVMExpertPage *pExpertPage = new UIWizardNewVMExpertPage(m_pActionPool);
     108            addPage(pExpertPage);
     109            if (!m_strInitialISOFilePath.isEmpty())
     110                pExpertPage->setISOFilePath(m_strInitialISOFilePath);
    104111            break;
    105112        }
     
    708715void UIWizardNewVM::setISOFilePath(const QString &strISOFilePath)
    709716{
    710     /* am I being a paranoid?: */
    711717    QFileInfo isoFileInfo(strISOFilePath);
    712718    if (!isoFileInfo.exists())
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVM.h

    r94078 r94593  
    5151
    5252    UIWizardNewVM(QWidget *pParent, UIActionPool *pActionPool,
    53                   const QString &strMachineGroup, const QString &strHelpHashtag, CUnattended &comUnattended);
     53                  const QString &strMachineGroup, const QString &strHelpHashtag,
     54                  CUnattended &comUnattended, const QString &strISOFilePath = QString());
     55
    5456    bool isUnattendedEnabled() const;
    5557    bool isUnattendedInstallSupported() const;
     
    225227       CUnattended &m_comUnattended;
    226228       bool m_fStartHeadless;
     229       QString m_strInitialISOFilePath;
    227230    /** @} */
    228231};
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMExpertPage.cpp

    r94078 r94593  
    8484}
    8585
     86void UIWizardNewVMExpertPage::setISOFilePath(const QString &strISOFilePath)
     87{
     88    QFileInfo isoFileInfo(strISOFilePath);
     89    if (isoFileInfo.exists() && m_pNameAndSystemEditor)
     90        m_pNameAndSystemEditor->setISOImagePath(strISOFilePath);
     91}
     92
    8693void UIWizardNewVMExpertPage::sltNameChanged(const QString &strNewName)
    8794{
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMExpertPage.h

    r94078 r94593  
    5555
    5656    UIWizardNewVMExpertPage(UIActionPool *pActionPool);
     57    void setISOFilePath(const QString &strISOFilePath);
    5758
    5859private slots:
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMNameOSTypePage.cpp

    r94478 r94593  
    407407}
    408408
     409void UIWizardNewVMNameOSTypePage::setISOFilePath(const QString &strISOFilePath)
     410{
     411    QFileInfo isoFileInfo(strISOFilePath);
     412    if (isoFileInfo.exists() && m_pNameAndSystemEditor)
     413        m_pNameAndSystemEditor->setISOImagePath(strISOFilePath);
     414}
     415
    409416void UIWizardNewVMNameOSTypePage::prepare()
    410417{
     
    511518        {
    512519            m_pNameAndSystemEditor->setFocus();
    513             m_pNameAndSystemEditor->setEditionSelectorEnabled(false);
     520            setEditionSelectorEnabled();
    514521        }
    515522        setSkipCheckBoxEnable();
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMNameOSTypePage.h

    r94078 r94593  
    5656    /** Constructor. */
    5757    UIWizardNewVMNameOSTypePage();
    58 
     58    void setISOFilePath(const QString &strISOFilePath);
    5959
    6060protected:
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette