VirtualBox

Changeset 90763 in vbox


Ignore:
Timestamp:
Aug 20, 2021 3:34:22 PM (3 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9996. Some refactoring on disk file selection functions.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/wizards
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvd/UIWizardNewVDPageExpert.cpp

    r90761 r90763  
    121121    UIWizardNewVD *pWizard = qobject_cast<UIWizardNewVD*>(wizard());
    122122    AssertReturnVoid(pWizard);
    123     QString strSelectedPath = UIWizardNewVDSizeLocation::selectNewMediumLocation(pWizard);
     123    CMediumFormat comMediumFormat(pWizard->mediumFormat());
     124    QString strSelectedPath =
     125        UIDiskEditorGroupBox::openFileDialogForDiskFile(pWizard->mediumPath(), comMediumFormat,
     126                                                        KDeviceType_HardDisk, pWizard);
    124127    if (strSelectedPath.isEmpty())
    125128        return;
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvd/UIWizardNewVDPageSizeLocation.cpp

    r90761 r90763  
    3030/* COM includes: */
    3131#include "CSystemProperties.h"
    32 
    33 QString UIWizardNewVDSizeLocation::selectNewMediumLocation(UIWizardNewVD *pWizard)
    34 {
    35     AssertReturn(pWizard, QString());
    36     QString strChosenFilePath;
    37     /* Get current folder and filename: */
    38     QFileInfo fullFilePath(pWizard->mediumPath());
    39     QDir folder = fullFilePath.path();
    40     QString strFileName = fullFilePath.fileName();
    41 
    42     /* Set the first parent folder that exists as the current: */
    43     while (!folder.exists() && !folder.isRoot())
    44     {
    45         QFileInfo folderInfo(folder.absolutePath());
    46         if (folder == QDir(folderInfo.absolutePath()))
    47             break;
    48         folder = folderInfo.absolutePath();
    49     }
    50     AssertReturn(folder.exists() && !folder.isRoot(), strChosenFilePath);
    51 
    52     QVector<QString> fileExtensions;
    53     QVector<KDeviceType> deviceTypes;
    54     CMediumFormat mediumFormat = pWizard->mediumFormat();
    55     mediumFormat.DescribeFileExtensions(fileExtensions, deviceTypes);
    56     QStringList validExtensionList;
    57     for (int i = 0; i < fileExtensions.size(); ++i)
    58         if (deviceTypes[i] == KDeviceType_HardDisk)
    59             validExtensionList << QString("*.%1").arg(fileExtensions[i]);
    60     /* Compose full filter list: */
    61     QString strBackendsList = QString("%1 (%2)").arg(mediumFormat.GetName()).arg(validExtensionList.join(" "));
    62 
    63     strChosenFilePath = QIFileDialog::getSaveFileName(folder.absoluteFilePath(strFileName),
    64                                                               strBackendsList, pWizard,
    65                                                               UICommon::tr("Please choose a location for new virtual hard disk file"));
    66     return strChosenFilePath;
    67 }
    68 
    6932
    7033UIWizardNewVDPageSizeLocation::UIWizardNewVDPageSizeLocation(const QString &strDefaultName,
     
    10164    UIWizardNewVD *pWizard = qobject_cast<UIWizardNewVD*>(wizard());
    10265    AssertReturnVoid(pWizard);
    103     QString strSelectedPath = UIWizardNewVDSizeLocation::selectNewMediumLocation(pWizard);
     66    CMediumFormat comMediumFormat(pWizard->mediumFormat());
     67    QString strSelectedPath =
     68        UIDiskEditorGroupBox::openFileDialogForDiskFile(pWizard->mediumPath(), comMediumFormat,
     69                                                                KDeviceType_HardDisk, pWizard);
     70
    10471    if (strSelectedPath.isEmpty())
    10572        return;
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvd/UIWizardNewVDPageSizeLocation.h

    r90427 r90763  
    2929class UIMediumSizeAndPathGroupBox;
    3030class UIWizardNewVD;
    31 
    32 namespace UIWizardNewVDSizeLocation
    33 {
    34     QString selectNewMediumLocation(UIWizardNewVD *pWizard);
    35 }
    3631
    3732class SHARED_LIBRARY_STUFF UIWizardNewVDPageSizeLocation : public UINativeWizardPage
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMDiskPageBasic.cpp

    r90748 r90763  
    5656        return QUuid();
    5757    return uMediumId;
    58 }
    59 
    60 QString UIWizardNewVMDiskPage::selectNewMediumLocation(UIWizardNewVM *pWizard)
    61 {
    62     AssertReturn(pWizard, QString());
    63     QString strChosenFilePath;
    64     /* Get current folder and filename: */
    65     QFileInfo fullFilePath(pWizard->mediumPath());
    66     QDir folder = fullFilePath.path();
    67     QString strFileName = fullFilePath.fileName();
    68 
    69     /* Set the first parent folder that exists as the current: */
    70     while (!folder.exists() && !folder.isRoot())
    71     {
    72         QFileInfo folderInfo(folder.absolutePath());
    73         if (folder == QDir(folderInfo.absolutePath()))
    74             break;
    75         folder = folderInfo.absolutePath();
    76     }
    77     AssertReturn(folder.exists() && !folder.isRoot(), strChosenFilePath);
    78 
    79     QVector<QString> fileExtensions;
    80     QVector<KDeviceType> deviceTypes;
    81     CMediumFormat mediumFormat = pWizard->mediumFormat();
    82     mediumFormat.DescribeFileExtensions(fileExtensions, deviceTypes);
    83     QStringList validExtensionList;
    84     for (int i = 0; i < fileExtensions.size(); ++i)
    85         if (deviceTypes[i] == KDeviceType_HardDisk)
    86             validExtensionList << QString("*.%1").arg(fileExtensions[i]);
    87     /* Compose full filter list: */
    88     QString strBackendsList = QString("%1 (%2)").arg(mediumFormat.GetName()).arg(validExtensionList.join(" "));
    89 
    90     strChosenFilePath = QIFileDialog::getSaveFileName(folder.absoluteFilePath(strFileName),
    91                                                               strBackendsList, pWizard,
    92                                                               UICommon::tr("Please choose a location for new virtual hard disk file"));
    93     return strChosenFilePath;
    9458}
    9559
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMDiskPageBasic.h

    r90413 r90763  
    5959                                const QString &strMachineBaseName,
    6060                                QWidget *pCaller);
    61     QString selectNewMediumLocation(UIWizardNewVM *pWizard);
    6261}
    6362
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageExpert.cpp

    r90761 r90763  
    692692    UIWizardNewVM *pWizard = qobject_cast<UIWizardNewVM*>(wizard());
    693693    AssertReturnVoid(pWizard);
    694     QString strSelectedPath = UIWizardNewVMDiskPage::selectNewMediumLocation(pWizard);
     694    CMediumFormat comMediumFormat(pWizard->mediumFormat());
     695    QString strSelectedPath =
     696        UIDiskEditorGroupBox::openFileDialogForDiskFile(pWizard->mediumPath(), comMediumFormat, KDeviceType_HardDisk, pWizard);
    695697    if (strSelectedPath.isEmpty())
    696698        return;
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