VirtualBox

Changeset 100640 in vbox for trunk


Ignore:
Timestamp:
Jul 19, 2023 6:59:39 AM (19 months ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
158477
Message:

FE/Qt: bugref:9080:

  • Save As now really can save VISO file,
  • VISO creation does not return QUuid any more,
  • Settings dialog can be dismissed with escape.
Location:
trunk/src/VBox/Frontends/VirtualBox/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UICommon.cpp

    r100349 r100640  
    16751675            break;
    16761676        case UIMediumDeviceType_DVD:
    1677             uMediumId = UIVisoCreatorDialog::createViso(pActionPool, pParent, strDefaultFolder, strMachineName);
     1677            UIVisoCreatorDialog::createViso(pActionPool, pParent, strDefaultFolder, strMachineName);
    16781678            break;
    16791679        case UIMediumDeviceType_Floppy:
     
    16861686        return QUuid();
    16871687
    1688     /* Update the recent medium list only if the medium type is DVD or floppy: */
    1689     if (enmMediumType == UIMediumDeviceType_DVD || enmMediumType == UIMediumDeviceType_Floppy)
     1688    /* Update the recent medium list only if the medium type is floppy since updating when a VISO is created is not optimal: */
     1689    if (enmMediumType == UIMediumDeviceType_Floppy)
    16901690        updateRecentlyUsedMediumListAndFolder(enmMediumType, medium(uMediumId).location());
    16911691    return uMediumId;
     
    19081908                }
    19091909                else if(target.type == UIMediumTarget::UIMediumTargetType_CreateAdHocVISO)
    1910                     uMediumID = UIVisoCreatorDialog::createViso(pActionPool, windowManager().mainWindowShown(),
    1911                                                                 strMachineFolder, comConstMachine.GetName());
     1910                    UIVisoCreatorDialog::createViso(pActionPool, windowManager().mainWindowShown(),
     1911                                                    strMachineFolder, comConstMachine.GetName());
    19121912
    19131913                else if(target.type == UIMediumTarget::UIMediumTargetType_CreateFloppyDisk)
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/viso/UIVisoCreator.cpp

    r100630 r100640  
    184184    m_pButtonBox->setDoNotPickDefaultButton(true);
    185185    m_pButtonBox->setStandardButtons(QDialogButtonBox::Cancel | QDialogButtonBox::Ok);
     186    m_pButtonBox->button(QDialogButtonBox::Cancel)->setShortcut(QKeySequence(Qt::Key_Escape));
    186187    pMainLayout->addWidget(m_pButtonBox);
    187188
     
    225226    emit sigClosed(false);
    226227}
    227 
    228228
    229229void UIVisoSettingWidget::setSettings(const UIVisoCreatorWidget::Settings &settings)
     
    445445        setVisoName(fileInfo.completeBaseName());
    446446    }
     447    emit sigSave();
    447448}
    448449
     
    810811        connect(m_pVisoCreatorWidget, &UIVisoCreatorWidget::sigSettingDialogToggle,
    811812                this, &UIVisoCreatorDialog::sltSettingDialogToggle);
     813        connect(m_pVisoCreatorWidget, &UIVisoCreatorWidget::sigSave,
     814                this, &UIVisoCreatorDialog::sltSave);
    812815    }
    813816
     
    891894}
    892895
     896void UIVisoCreatorDialog::sltSave()
     897{
     898    saveVISOFile();
     899}
     900
    893901void UIVisoCreatorDialog::loadSettings()
    894902{
     
    928936
    929937/* static */
    930 QUuid UIVisoCreatorDialog::createViso(UIActionPool *pActionPool, QWidget *pParent,
    931                                       const QString &strDefaultFolder /* = QString() */,
    932                                       const QString &strMachineName /* = QString() */)
     938void UIVisoCreatorDialog::createViso(UIActionPool *pActionPool, QWidget *pParent,
     939                                     const QString &strDefaultFolder /* = QString() */,
     940                                     const QString &strMachineName /* = QString() */)
    933941{
    934942    QString strVisoSaveFolder(strDefaultFolder);
     
    939947    UIVisoCreatorDialog *pVisoCreator = new UIVisoCreatorDialog(pActionPool, pDialogParent,
    940948                                                                strVisoSaveFolder, strMachineName);
    941     AssertPtrReturn(pVisoCreator, QUuid());
     949    AssertPtrReturnVoid(pVisoCreator);
    942950
    943951    windowManager().registerNewParent(pVisoCreator, pDialogParent);
     
    946954    if (pVisoCreator->exec(false /* not application modal */))
    947955    {
    948         QStringList VisoEntryList = pVisoCreator->entryList();
    949         QString strImportedISOPath = pVisoCreator->importedISOPath();
    950         if ((VisoEntryList.empty() || VisoEntryList[0].isEmpty()) && strImportedISOPath.isEmpty())
     956        if (pVisoCreator->saveVISOFile())
     957            gEDataManager->setVISOCreatorRecentFolder(pVisoCreator->currentPath());
     958    }
     959
     960    delete pVisoCreator;
     961    return;
     962}
     963
     964bool UIVisoCreatorDialog::saveVISOFile()
     965{
     966    QStringList VisoEntryList = entryList();
     967    QString strImportedISOPath = importedISOPath();
     968    if ((VisoEntryList.empty() || VisoEntryList[0].isEmpty()) && strImportedISOPath.isEmpty())
     969        return false;
     970
     971    QFile file(visoFileFullPath());
     972    if (file.open(QFile::WriteOnly | QFile::Truncate))
     973    {
     974        QString strVisoName = visoName();
     975
     976        QTextStream stream(&file);
     977        stream << QString("%1 %2").arg("--iprt-iso-maker-file-marker-bourne-sh").arg(QUuid::createUuid().toString()) << "\n";
     978        stream<< "--volume-id=" << strVisoName << "\n";
     979        if (!strImportedISOPath.isEmpty())
     980            stream << "--import-iso=" << strImportedISOPath << "\n";
     981        stream << VisoEntryList.join("\n");
     982        if (!customOptions().isEmpty())
    951983        {
    952             delete pVisoCreator;
    953             return QUuid();
     984            stream << "\n";
     985            stream << customOptions().join("\n");
    954986        }
    955 
    956         QFile file(pVisoCreator->visoFileFullPath());
    957         if (file.open(QFile::WriteOnly | QFile::Truncate))
    958         {
    959             QString strVisoName = pVisoCreator->visoName();
    960             if (strVisoName.isEmpty())
    961                 strVisoName = strMachineName;
    962 
    963             QTextStream stream(&file);
    964             stream << QString("%1 %2").arg("--iprt-iso-maker-file-marker-bourne-sh").arg(QUuid::createUuid().toString()) << "\n";
    965             stream<< "--volume-id=" << strVisoName << "\n";
    966             if (!strImportedISOPath.isEmpty())
    967                 stream << "--import-iso=" << strImportedISOPath << "\n";
    968             stream << VisoEntryList.join("\n");
    969             if (!pVisoCreator->customOptions().isEmpty())
    970             {
    971                 stream << "\n";
    972                 stream << pVisoCreator->customOptions().join("\n");
    973             }
    974             file.close();
    975         }
    976     } // if (pVisoCreator->exec(false /* not application modal */))
    977     gEDataManager->setVISOCreatorRecentFolder(pVisoCreator->currentPath());
    978 
    979     delete pVisoCreator;
    980     return QUuid();
    981 }
    982 
     987        file.close();
     988    }
     989    return true;
     990}
    983991
    984992#include "UIVisoCreator.moc"
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/viso/UIVisoCreator.h

    r100500 r100640  
    7070    void sigVisoFilePathChanged(const QString &strPath);
    7171    void sigSettingDialogToggle(bool fDialogShown);
     72    void sigSave();
    7273
    7374public:
     
    192193      * @param  pParent           Passes the dialog parent.
    193194      * @param  strDefaultFolder  Passes the folder to save the VISO file.
    194       * @param  strMachineName    Passes the name of the machine,
    195       * returns the UUID of the created medium or a null QUuid. */
    196     static QUuid createViso(UIActionPool *pActionPool, QWidget *pParent,
    197                             const QString &strDefaultFolder = QString(),
    198                             const QString &strMachineName  = QString());
     195      * @param  strMachineName    Passes the name of the machine. */
     196    static void createViso(UIActionPool *pActionPool, QWidget *pParent,
     197                           const QString &strDefaultFolder = QString(),
     198                           const QString &strMachineName  = QString());
    199199
    200200protected:
     
    208208    void sltVisoFilePathChanged(const QString &strPath);
    209209    void sltSettingDialogToggle(bool fIsShown);
     210    void sltSave();
    210211
    211212private:
     213
     214    bool saveVISOFile();
    212215    void prepareWidgets(const QString& strVisoSavePath, const QString &strMachineName);
    213216    virtual void retranslateUi() final override;
Note: See TracChangeset for help on using the changeset viewer.

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