Changeset 78121 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Apr 15, 2019 8:35:13 AM (6 years ago)
- svn:sync-xref-src-repo-rev:
- 130016
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvd
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvd/UIWizardNewVDPageBasic3.cpp
r76606 r78121 128 128 129 129 /* static */ 130 QString UIWizardNewVDPage3::absoluteFilePath(const QString &strFileName, const QString &str DefaultPath)130 QString UIWizardNewVDPage3::absoluteFilePath(const QString &strFileName, const QString &strPath) 131 131 { 132 132 /* Wrap file-info around received file name: */ … … 135 135 if (fileInfo.fileName() == strFileName || fileInfo.isRelative()) 136 136 { 137 /* Resolve path on the basis of defaultpath we have: */138 fileInfo = QFileInfo(str DefaultPath, strFileName);137 /* Resolve path on the basis of path we have: */ 138 fileInfo = QFileInfo(strPath, strFileName); 139 139 } 140 140 /* Return full absolute hard disk file path: */ 141 141 return QDir::toNativeSeparators(fileInfo.absoluteFilePath()); 142 } 143 144 /*static */ 145 QString UIWizardNewVDPage3::absoluteFilePath(const QString &strFileName, const QString &strPath, const QString &strExtension) 146 { 147 QString strFilePath = absoluteFilePath(strFileName, strPath); 148 if (QFileInfo(strFilePath).suffix().isEmpty()) 149 strFilePath += QString(".%1").arg(strExtension); 150 return strFilePath; 142 151 } 143 152 … … 267 276 m_strDefaultExtension = defaultExtension(field("mediumFormat").value<CMediumFormat>()); 268 277 /* Set default name as text for location editor: */ 269 m_pLocationEditor->setText( m_strDefaultName);278 m_pLocationEditor->setText(absoluteFilePath(m_strDefaultName, m_strDefaultPath, m_strDefaultExtension)); 270 279 } 271 280 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvd/UIWizardNewVDPageBasic3.h
r76581 r78121 46 46 /* Location-editors stuff: */ 47 47 static QString toFileName(const QString &strName, const QString &strExtension); 48 static QString absoluteFilePath(const QString &strFileName, const QString &strDefaultPath); 48 /* Returns the full image file path except the extension. */ 49 static QString absoluteFilePath(const QString &strFileName, const QString &strPath); 50 /* Returns the full image file path including the extension. */ 51 static QString absoluteFilePath(const QString &strFileName, const QString &strPath, const QString &strExtension); 49 52 static QString defaultExtension(const CMediumFormat &mediumFormatRef); 50 53 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvd/UIWizardNewVDPageExpert.cpp
r76606 r78121 17 17 18 18 /* Qt includes: */ 19 #include <QDir> 19 20 #include <QGridLayout> 20 21 #include <QVBoxLayout> … … 47 48 : UIWizardNewVDPage3(strDefaultName, strDefaultPath) 48 49 { 50 /* Get default extension for new virtual-disk: */ 49 51 /* Create widgets: */ 50 52 QGridLayout *pMainLayout = new QGridLayout(this); … … 56 58 { 57 59 m_pLocationEditor = new QLineEdit(m_pLocationCnt); 58 {59 m_pLocationEditor->setText(m_strDefaultName);60 }61 60 m_pLocationOpenButton = new QIToolButton(m_pLocationCnt); 62 61 { … … 174 173 registerField("mediumPath", this, "mediumPath"); 175 174 registerField("mediumSize", this, "mediumSize"); 175 176 /* Initialization of m_strDefaultExtension is done here 177 since first m_formats should be populated and fields should be registered: */ 178 m_strDefaultExtension = defaultExtension(mediumFormat()); 179 if (m_pLocationEditor) 180 m_pLocationEditor->setText(absoluteFilePath(m_strDefaultName, m_strDefaultPath, m_strDefaultExtension)); 176 181 } 177 182 … … 202 207 /* Compose virtual-disk extension: */ 203 208 m_strDefaultExtension = defaultExtension(mf); 209 /* Update m_pLocationEditor's text if necessary: */ 210 if (!m_pLocationEditor->text().isEmpty() && !m_strDefaultExtension.isEmpty()) 211 { 212 QFileInfo fileInfo(m_pLocationEditor->text()); 213 if (fileInfo.completeSuffix() != m_strDefaultExtension) 214 { 215 QString strNewFilePath = QString("%1/%2.%3").arg(fileInfo.absoluteDir().absolutePath()).arg(fileInfo.baseName()).arg(m_strDefaultExtension); 216 m_pLocationEditor->setText(strNewFilePath); 217 } 218 } 204 219 205 220 /* Broadcast complete-change: */
Note:
See TracChangeset
for help on using the changeset viewer.