VirtualBox

Ignore:
Timestamp:
Feb 17, 2021 11:42:01 AM (4 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
142831
Message:

FE/Qt: Keeping the part of the disk file name even if it includes a dot.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvd
Files:
5 edited

Legend:

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

    r82968 r87775  
    2424#include "UIConverter.h"
    2525#include "UIWizardNewVDPageBasic1.h"
     26#include "UIWizardNewVDPageBasic3.h"
    2627#include "UIWizardNewVD.h"
    2728#include "UICommon.h"
     
    7172        m_formatNames << medFormat.GetName();
    7273        m_pFormatButtonGroup->addButton(pFormatButton, m_formatNames.size() - 1);
     74        m_formatExtensions << UIWizardNewVDPage3::defaultExtension(medFormat);
    7375    }
    7476}
     
    204206    return UIWizardNewVD::Page3;
    205207}
    206 
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvd/UIWizardNewVDPageBasic1.h

    r82968 r87775  
    5555    QList<CMediumFormat> m_formats;
    5656    QStringList m_formatNames;
     57    QStringList m_formatExtensions;
    5758};
    5859
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvd/UIWizardNewVDPageBasic3.h

    r82968 r87775  
    3636class SHARED_LIBRARY_STUFF UIWizardNewVDPage3 : public UIWizardPageBase
    3737{
     38
     39public:
     40
     41    static QString defaultExtension(const CMediumFormat &mediumFormatRef);
     42
    3843protected:
    3944
     
    5055    /* Returns the full image file path including the extension. */
    5156    static QString absoluteFilePath(const QString &strFileName, const QString &strPath, const QString &strExtension);
    52     static QString defaultExtension(const CMediumFormat &mediumFormatRef);
    5357
    5458    /* Checks if the medium file is bigger than what is allowed in FAT file systems. */
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvd/UIWizardNewVDPageExpert.cpp

    r85466 r87775  
    213213        if (fileInfo.suffix() != m_strDefaultExtension)
    214214        {
    215             QFileInfo newFileInfo(fileInfo.absolutePath(), QString("%1.%2").arg(fileInfo.completeBaseName()).arg(m_strDefaultExtension));
     215            QFileInfo newFileInfo(fileInfo.absolutePath(),
     216                                  QString("%1.%2").arg(stripFormatExtension(fileInfo.fileName())).arg(m_strDefaultExtension));
    216217            m_pLocationEditor->setText(newFileInfo.absoluteFilePath());
    217218        }
     
    296297    return fResult;
    297298}
     299
     300QString UIWizardNewVDPageExpert::stripFormatExtension(const QString &strFileName)
     301{
     302    QString result(strFileName);
     303    foreach (const QString &strExtension, m_formatExtensions)
     304    {
     305        if (strFileName.endsWith(strExtension, Qt::CaseInsensitive))
     306        {
     307            /* Add the dot to extenstion: */
     308            QString strExtensionWithDot(strExtension);
     309            strExtensionWithDot.prepend('.');
     310            int iIndex = strFileName.lastIndexOf(strExtensionWithDot, -1, Qt::CaseInsensitive);
     311            result.remove(iIndex, strExtensionWithDot.length());
     312        }
     313    }
     314    return result;
     315}
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvd/UIWizardNewVDPageExpert.h

    r82968 r87775  
    7373    bool isComplete() const;
    7474    bool validatePage();
     75    /** Strips the format extension from the @p strFileName. foo.dd.vdi becomes foo.dd. any extension which is not
     76      * a format extension is left alone. */
     77    QString stripFormatExtension(const QString &strFileName);
    7578
    7679    /* Widgets: */
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