Changeset 84861 in vbox
- Timestamp:
- Jun 17, 2020 10:30:14 AM (5 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 4 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk
r84790 r84861 681 681 src/wizards/newcloudvm/UIWizardNewCloudVMPageExpert.h \ 682 682 src/wizards/newvm/UIWizardNewVM.h \ 683 src/wizards/newvm/UIWizardNewVMPageBasic0.h \ 683 684 src/wizards/newvm/UIWizardNewVMPageBasic1.h \ 684 685 src/wizards/newvm/UIWizardNewVMPageBasic2.h \ … … 1139 1140 src/wizards/newcloudvm/UIWizardNewCloudVMPageExpert.cpp \ 1140 1141 src/wizards/newvm/UIWizardNewVM.cpp \ 1142 src/wizards/newvm/UIWizardNewVMPageBasic0.cpp \ 1141 1143 src/wizards/newvm/UIWizardNewVMPageBasic1.cpp \ 1142 1144 src/wizards/newvm/UIWizardNewVMPageBasic2.cpp \ -
trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManager.cpp
r84595 r84861 598 598 /* Execute wizard: */ 599 599 pWizard->exec(); 600 601 600 602 delete pWizard; 601 603 } -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVM.cpp
r82968 r84861 19 19 #include "UICommon.h" 20 20 #include "UIWizardNewVM.h" 21 #include "UIWizardNewVMPageBasic0.h" 21 22 #include "UIWizardNewVMPageBasic1.h" 22 23 #include "UIWizardNewVMPageBasic2.h" … … 68 69 case WizardMode_Basic: 69 70 { 70 setPage(Page1, new UIWizardNewVMPageBasic1(m_strGroup)); 71 setPage(Page2, new UIWizardNewVMPageBasic2); 72 setPage(Page3, new UIWizardNewVMPageBasic3); 71 setPage(Page1, new UIWizardNewVMPageBasic0); 72 setPage(Page2, new UIWizardNewVMPageBasic1(m_strGroup)); 73 setPage(Page3, new UIWizardNewVMPageBasic2); 74 setPage(Page4, new UIWizardNewVMPageBasic3); 73 75 break; 74 76 } … … 456 458 return strControllerName; 457 459 } 460 461 QString UIWizardNewVM::unattendedISOFilePath() const 462 { 463 QVariant fieldValue = field("ISOFilePath"); 464 if (fieldValue.isNull() || !fieldValue.isValid() || !fieldValue.canConvert(QMetaType::QString)) 465 return QString(); 466 return fieldValue.toString(); 467 } 468 469 bool UIWizardNewVM::isUnattendedInstallEnabled() const 470 { 471 QVariant fieldValue = field("isUnattendedEnabled"); 472 if (fieldValue.isNull() || !fieldValue.isValid() || !fieldValue.canConvert(QMetaType::Bool)) 473 return false; 474 return fieldValue.toBool(); 475 } 476 477 bool UIWizardNewVM::startHeadless() const 478 { 479 QVariant fieldValue = field("startHeadless"); 480 if (fieldValue.isNull() || !fieldValue.isValid() || !fieldValue.canConvert(QMetaType::Bool)) 481 return false; 482 return fieldValue.toBool(); 483 } -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVM.h
r82968 r84861 41 41 Page1, 42 42 Page2, 43 Page3 43 Page3, 44 Page4 44 45 }; 45 46 … … 72 73 friend class UIWizardNewVMPageExpert; 73 74 75 QString unattendedISOFilePath() const; 76 bool isUnattendedInstallEnabled() const; 77 bool startHeadless() const; 78 79 74 80 private slots: 75 81 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageBasic0.cpp
r84828 r84861 1 1 /* $Id$ */ 2 2 /** @file 3 * VBox Qt GUI - UIWizardNewVMPageBasic 1class implementation.3 * VBox Qt GUI - UIWizardNewVMPageBasic0 class implementation. 4 4 */ 5 5 … … 17 17 18 18 /* Qt includes: */ 19 #include <QDir> 19 #include <QCheckBox> 20 #include <QFileInfo> 21 #include <QLabel> 20 22 #include <QLineEdit> 21 23 #include <QHBoxLayout> 22 #include <Q VBoxLayout>24 #include <QGridLayout> 23 25 24 26 /* GUI includes: */ 25 27 #include "QIRichTextLabel.h" 26 28 #include "UICommon.h" 29 #include "UIFilePathSelector.h" 27 30 #include "UIMessageCenter.h" 28 31 #include "UINameAndSystemEditor.h" 29 #include "UIWizardNewVMPageBasic 1.h"32 #include "UIWizardNewVMPageBasic0.h" 30 33 #include "UIWizardNewVM.h" 31 34 … … 35 38 36 39 37 /* Defines some patterns to guess the right OS type. Should be in sync with 38 * VirtualBox-settings-common.xsd in Main. The list is sorted by priority. The39 * first matching string found, will be used. */40 struct osTypePattern 40 UIWizardNewVMPage0::UIWizardNewVMPage0() 41 : m_pUnattendedCheckBox(0) 42 , m_pStartHeadlessCheckBox(0) 43 , m_pISOFilePathSelector(0) 41 44 { 42 QRegExp pattern;43 const char *pcstId;44 };45 46 static const osTypePattern gs_OSTypePattern[] =47 {48 /* DOS: */49 { QRegExp("DOS", Qt::CaseInsensitive), "DOS" },50 51 /* Windows: */52 { QRegExp( "Wi.*98", Qt::CaseInsensitive), "Windows98" },53 { QRegExp( "Wi.*95", Qt::CaseInsensitive), "Windows95" },54 { QRegExp( "Wi.*Me", Qt::CaseInsensitive), "WindowsMe" },55 { QRegExp( "(Wi.*NT)|(NT[-._v]*4)", Qt::CaseInsensitive), "WindowsNT4" },56 { QRegExp( "NT[-._v]*3[.,]*[51x]", Qt::CaseInsensitive), "WindowsNT3x" },57 /* Note: Do not automatically set WindowsXP_64 on 64-bit hosts, as Windows XP 64-bit58 * is extremely rare -- most users never heard of it even. So always default to 32-bit. */59 { QRegExp("((Wi.*XP)|(XP)).*", Qt::CaseInsensitive), "WindowsXP" },60 { QRegExp("((Wi.*2003)|(W2K3)|(Win2K3)).*64", Qt::CaseInsensitive), "Windows2003_64" },61 { QRegExp("((Wi.*2003)|(W2K3)|(Win2K3)).*32", Qt::CaseInsensitive), "Windows2003" },62 { QRegExp("((Wi.*Vis)|(Vista)).*64", Qt::CaseInsensitive), "WindowsVista_64" },63 { QRegExp("((Wi.*Vis)|(Vista)).*32", Qt::CaseInsensitive), "WindowsVista" },64 { QRegExp( "(Wi.*2016)|(W2K16)|(Win2K16)", Qt::CaseInsensitive), "Windows2016_64" },65 { QRegExp( "(Wi.*2012)|(W2K12)|(Win2K12)", Qt::CaseInsensitive), "Windows2012_64" },66 { QRegExp("((Wi.*2008)|(W2K8)|(Win2k8)).*64", Qt::CaseInsensitive), "Windows2008_64" },67 { QRegExp("((Wi.*2008)|(W2K8)|(Win2K8)).*32", Qt::CaseInsensitive), "Windows2008" },68 { QRegExp( "(Wi.*2000)|(W2K)|(Win2K)", Qt::CaseInsensitive), "Windows2000" },69 { QRegExp( "(Wi.*7.*64)|(W7.*64)", Qt::CaseInsensitive), "Windows7_64" },70 { QRegExp( "(Wi.*7.*32)|(W7.*32)", Qt::CaseInsensitive), "Windows7" },71 { QRegExp( "(Wi.*8.*1.*64)|(W8.*64)", Qt::CaseInsensitive), "Windows81_64" },72 { QRegExp( "(Wi.*8.*1.*32)|(W8.*32)", Qt::CaseInsensitive), "Windows81" },73 { QRegExp( "(Wi.*8.*64)|(W8.*64)", Qt::CaseInsensitive), "Windows8_64" },74 { QRegExp( "(Wi.*8.*32)|(W8.*32)", Qt::CaseInsensitive), "Windows8" },75 { QRegExp( "(Wi.*10.*64)|(W10.*64)", Qt::CaseInsensitive), "Windows10_64" },76 { QRegExp( "(Wi.*10.*32)|(W10.*32)", Qt::CaseInsensitive), "Windows10" },77 { QRegExp( "Wi.*3.*1", Qt::CaseInsensitive), "Windows31" },78 /* Set Windows 7 as default for "Windows". */79 { QRegExp( "Wi.*64", Qt::CaseInsensitive), "Windows7_64" },80 { QRegExp( "Wi.*32", Qt::CaseInsensitive), "Windows7" },81 /* ReactOS wants to be considered as Windows 2003 */82 { QRegExp( "Reac.*", Qt::CaseInsensitive), "Windows2003" },83 84 /* Solaris: */85 { QRegExp("Sol.*11", Qt::CaseInsensitive), "Solaris11_64" },86 { QRegExp("((Op.*Sol)|(os20[01][0-9])|(Sol.*10)|(India)|(Neva)).*64", Qt::CaseInsensitive), "OpenSolaris_64" },87 { QRegExp("((Op.*Sol)|(os20[01][0-9])|(Sol.*10)|(India)|(Neva)).*32", Qt::CaseInsensitive), "OpenSolaris" },88 { QRegExp("Sol.*64", Qt::CaseInsensitive), "Solaris_64" },89 { QRegExp("Sol.*32", Qt::CaseInsensitive), "Solaris" },90 91 /* OS/2: */92 { QRegExp( "OS[/|!-]{,1}2.*W.*4.?5", Qt::CaseInsensitive), "OS2Warp45" },93 { QRegExp( "OS[/|!-]{,1}2.*W.*4", Qt::CaseInsensitive), "OS2Warp4" },94 { QRegExp( "OS[/|!-]{,1}2.*W", Qt::CaseInsensitive), "OS2Warp3" },95 { QRegExp("(OS[/|!-]{,1}2.*e)|(eCS.*)", Qt::CaseInsensitive), "OS2eCS" },96 { QRegExp( "OS[/|!-]{,1}2", Qt::CaseInsensitive), "OS2" },97 { QRegExp( "eComS.*", Qt::CaseInsensitive), "OS2eCS" },98 99 /* Other: Must come before Ubuntu/Maverick and before Linux??? */100 { QRegExp("QN", Qt::CaseInsensitive), "QNX" },101 102 /* Mac OS X: Must come before Ubuntu/Maverick and before Linux: */103 { QRegExp("((mac.*10[.,]{0,1}4)|(os.*x.*10[.,]{0,1}4)|(mac.*ti)|(os.*x.*ti)|(Tig)).64", Qt::CaseInsensitive), "MacOS_64" },104 { QRegExp("((mac.*10[.,]{0,1}4)|(os.*x.*10[.,]{0,1}4)|(mac.*ti)|(os.*x.*ti)|(Tig)).32", Qt::CaseInsensitive), "MacOS" },105 { QRegExp("((mac.*10[.,]{0,1}5)|(os.*x.*10[.,]{0,1}5)|(mac.*leo)|(os.*x.*leo)|(Leop)).*64", Qt::CaseInsensitive), "MacOS_64" },106 { QRegExp("((mac.*10[.,]{0,1}5)|(os.*x.*10[.,]{0,1}5)|(mac.*leo)|(os.*x.*leo)|(Leop)).*32", Qt::CaseInsensitive), "MacOS" },107 { QRegExp("((mac.*10[.,]{0,1}6)|(os.*x.*10[.,]{0,1}6)|(mac.*SL)|(os.*x.*SL)|(Snow L)).*64", Qt::CaseInsensitive), "MacOS106_64" },108 { QRegExp("((mac.*10[.,]{0,1}6)|(os.*x.*10[.,]{0,1}6)|(mac.*SL)|(os.*x.*SL)|(Snow L)).*32", Qt::CaseInsensitive), "MacOS106" },109 { QRegExp( "(mac.*10[.,]{0,1}7)|(os.*x.*10[.,]{0,1}7)|(mac.*ML)|(os.*x.*ML)|(Mount)", Qt::CaseInsensitive), "MacOS108_64" },110 { QRegExp( "(mac.*10[.,]{0,1}8)|(os.*x.*10[.,]{0,1}8)|(Lion)", Qt::CaseInsensitive), "MacOS107_64" },111 { QRegExp( "(mac.*10[.,]{0,1}9)|(os.*x.*10[.,]{0,1}9)|(mac.*mav)|(os.*x.*mav)|(Mavericks)", Qt::CaseInsensitive), "MacOS109_64" },112 { QRegExp( "(mac.*yos)|(os.*x.*yos)|(Yosemite)", Qt::CaseInsensitive), "MacOS1010_64" },113 { QRegExp( "(mac.*cap)|(os.*x.*capit)|(Capitan)", Qt::CaseInsensitive), "MacOS1011_64" },114 { QRegExp( "(mac.*hig)|(os.*x.*high.*sierr)|(High Sierra)", Qt::CaseInsensitive), "MacOS1013_64" },115 { QRegExp( "(mac.*sie)|(os.*x.*sierr)|(Sierra)", Qt::CaseInsensitive), "MacOS1012_64" },116 { QRegExp("((Mac)|(Tig)|(Leop)|(Yose)|(os[ ]*x)).*64", Qt::CaseInsensitive), "MacOS_64" },117 { QRegExp("((Mac)|(Tig)|(Leop)|(Yose)|(os[ ]*x)).*32", Qt::CaseInsensitive), "MacOS" },118 119 /* Code names for Linux distributions: */120 { QRegExp("((bianca)|(cassandra)|(celena)|(daryna)|(elyssa)|(felicia)|(gloria)|(helena)|(isadora)|(julia)|(katya)|(lisa)|(maya)|(nadia)|(olivia)|(petra)|(qiana)|(rebecca)|(rafaela)|(rosa)).*64", Qt::CaseInsensitive), "Ubuntu_64" },121 { QRegExp("((bianca)|(cassandra)|(celena)|(daryna)|(elyssa)|(felicia)|(gloria)|(helena)|(isadora)|(julia)|(katya)|(lisa)|(maya)|(nadia)|(olivia)|(petra)|(qiana)|(rebecca)|(rafaela)|(rosa)).*32", Qt::CaseInsensitive), "Ubuntu" },122 { QRegExp("((edgy)|(feisty)|(gutsy)|(hardy)|(intrepid)|(jaunty)|(karmic)|(lucid)|(maverick)|(natty)|(oneiric)|(precise)|(quantal)|(raring)|(saucy)|(trusty)|(utopic)|(vivid)|(wily)|(xenial)|(yakkety)|(zesty)).*64", Qt::CaseInsensitive), "Ubuntu_64" },123 { QRegExp("((edgy)|(feisty)|(gutsy)|(hardy)|(intrepid)|(jaunty)|(karmic)|(lucid)|(maverick)|(natty)|(oneiric)|(precise)|(quantal)|(raring)|(saucy)|(trusty)|(utopic)|(vivid)|(wily)|(xenial)|(yakkety)|(zesty)).*32", Qt::CaseInsensitive), "Ubuntu" },124 { QRegExp("((sarge)|(etch)|(lenny)|(squeeze)|(wheezy)|(jessie)|(stretch)|(buster)|(sid)).*64", Qt::CaseInsensitive), "Debian_64" },125 { QRegExp("((sarge)|(etch)|(lenny)|(squeeze)|(wheezy)|(jessie)|(stretch)|(buster)|(sid)).*32", Qt::CaseInsensitive), "Debian" },126 { QRegExp("((moonshine)|(werewolf)|(sulphur)|(cambridge)|(leonidas)|(constantine)|(goddard)|(laughlin)|(lovelock)|(verne)|(beefy)|(spherical)).*64", Qt::CaseInsensitive), "Fedora_64" },127 { QRegExp("((moonshine)|(werewolf)|(sulphur)|(cambridge)|(leonidas)|(constantine)|(goddard)|(laughlin)|(lovelock)|(verne)|(beefy)|(spherical)).*32", Qt::CaseInsensitive), "Fedora" },128 129 /* Regular names of Linux distributions: */130 { QRegExp("Arc.*64", Qt::CaseInsensitive), "ArchLinux_64" },131 { QRegExp("Arc.*32", Qt::CaseInsensitive), "ArchLinux" },132 { QRegExp("Deb.*64", Qt::CaseInsensitive), "Debian_64" },133 { QRegExp("Deb.*32", Qt::CaseInsensitive), "Debian" },134 { QRegExp("((SU)|(Nov)|(SLE)).*64", Qt::CaseInsensitive), "OpenSUSE_64" },135 { QRegExp("((SU)|(Nov)|(SLE)).*32", Qt::CaseInsensitive), "OpenSUSE" },136 { QRegExp("Fe.*64", Qt::CaseInsensitive), "Fedora_64" },137 { QRegExp("Fe.*32", Qt::CaseInsensitive), "Fedora" },138 { QRegExp("((Gen)|(Sab)).*64", Qt::CaseInsensitive), "Gentoo_64" },139 { QRegExp("((Gen)|(Sab)).*32", Qt::CaseInsensitive), "Gentoo" },140 { QRegExp("((Man)|(Mag)).*64", Qt::CaseInsensitive), "Mandriva_64" },141 { QRegExp("((Man)|(Mag)).*32", Qt::CaseInsensitive), "Mandriva" },142 { QRegExp("((Red)|(rhel)|(cen)).*64", Qt::CaseInsensitive), "RedHat_64" },143 { QRegExp("((Red)|(rhel)|(cen)).*32", Qt::CaseInsensitive), "RedHat" },144 { QRegExp("Tur.*64", Qt::CaseInsensitive), "Turbolinux_64" },145 { QRegExp("Tur.*32", Qt::CaseInsensitive), "Turbolinux" },146 { QRegExp("(Ub)|(Min).*64", Qt::CaseInsensitive), "Ubuntu_64" },147 { QRegExp("(Ub)|(Min).*32", Qt::CaseInsensitive), "Ubuntu" },148 { QRegExp("Xa.*64", Qt::CaseInsensitive), "Xandros_64" },149 { QRegExp("Xa.*32", Qt::CaseInsensitive), "Xandros" },150 { QRegExp("((Or)|(oel)|(ol)).*64", Qt::CaseInsensitive), "Oracle_64" },151 { QRegExp("((Or)|(oel)|(ol)).*32", Qt::CaseInsensitive), "Oracle" },152 { QRegExp("Knoppix", Qt::CaseInsensitive), "Linux26" },153 { QRegExp("Dsl", Qt::CaseInsensitive), "Linux24" },154 { QRegExp("((Lin)|(lnx)).*2.?2", Qt::CaseInsensitive), "Linux22" },155 { QRegExp("((Lin)|(lnx)).*2.?4.*64", Qt::CaseInsensitive), "Linux24_64" },156 { QRegExp("((Lin)|(lnx)).*2.?4.*32", Qt::CaseInsensitive), "Linux24" },157 { QRegExp("((((Lin)|(lnx)).*2.?6)|(LFS)).*64", Qt::CaseInsensitive), "Linux26_64" },158 { QRegExp("((((Lin)|(lnx)).*2.?6)|(LFS)).*32", Qt::CaseInsensitive), "Linux26" },159 { QRegExp("((Lin)|(lnx)).*64", Qt::CaseInsensitive), "Linux26_64" },160 { QRegExp("((Lin)|(lnx)).*32", Qt::CaseInsensitive), "Linux26" },161 162 /* Other: */163 { QRegExp("L4", Qt::CaseInsensitive), "L4" },164 { QRegExp("((Fr.*B)|(fbsd)).*64", Qt::CaseInsensitive), "FreeBSD_64" },165 { QRegExp("((Fr.*B)|(fbsd)).*32", Qt::CaseInsensitive), "FreeBSD" },166 { QRegExp("Op.*B.*64", Qt::CaseInsensitive), "OpenBSD_64" },167 { QRegExp("Op.*B.*32", Qt::CaseInsensitive), "OpenBSD" },168 { QRegExp("Ne.*B.*64", Qt::CaseInsensitive), "NetBSD_64" },169 { QRegExp("Ne.*B.*32", Qt::CaseInsensitive), "NetBSD" },170 { QRegExp("Net", Qt::CaseInsensitive), "Netware" },171 { QRegExp("Rocki", Qt::CaseInsensitive), "JRockitVE" },172 { QRegExp("bs[23]{0,1}-", Qt::CaseInsensitive), "VBoxBS_64" }, /* bootsector tests */173 { QRegExp("Ot", Qt::CaseInsensitive), "Other" },174 };175 176 UIWizardNewVMPage1::UIWizardNewVMPage1(const QString &strGroup)177 : m_pNameAndSystemEditor(0)178 , m_strGroup(strGroup)179 180 {181 CHost host = uiCommon().host();182 m_fSupportsHWVirtEx = host.GetProcessorFeature(KProcessorFeature_HWVirtEx);183 m_fSupportsLongMode = host.GetProcessorFeature(KProcessorFeature_LongMode);184 45 } 185 46 186 void UIWizardNewVMPage1::onNameChanged(QString strNewName) 47 QString UIWizardNewVMPage0::ISOFilePath() const 187 48 { 188 /* Do not forget about achitecture bits, if not yet specified: */ 189 if (!strNewName.contains("32") && !strNewName.contains("64")) 190 strNewName += ARCH_BITS == 64 && m_fSupportsHWVirtEx && m_fSupportsLongMode ? "64" : "32"; 191 192 /* Search for a matching OS type based on the string the user typed already. */ 193 for (size_t i = 0; i < RT_ELEMENTS(gs_OSTypePattern); ++i) 194 if (strNewName.contains(gs_OSTypePattern[i].pattern)) 195 { 196 if (m_pNameAndSystemEditor) 197 { 198 m_pNameAndSystemEditor->blockSignals(true); 199 m_pNameAndSystemEditor->setType(uiCommon().vmGuestOSType(gs_OSTypePattern[i].pcstId)); 200 m_pNameAndSystemEditor->blockSignals(false); 201 } 202 break; 203 } 49 if (!m_pISOFilePathSelector) 50 return QString(); 51 return m_pISOFilePathSelector->path(); 204 52 } 205 53 206 void UIWizardNewVMPage1::onOsTypeChanged() 54 bool UIWizardNewVMPage0::isUnattendedEnabled() const 207 55 { 208 /* If the user manually edited the OS type, we didn't want our automatic OS type guessing anymore. 209 * So simply disconnect the text-edit signal. */ 210 if (m_pNameAndSystemEditor) 211 m_pNameAndSystemEditor->disconnect(SIGNAL(sigNameChanged(const QString &)), thisImp(), SLOT(sltNameChanged(const QString &))); 56 if (!m_pUnattendedCheckBox) 57 return false; 58 return m_pUnattendedCheckBox->isChecked(); 212 59 } 213 60 214 void UIWizardNewVMPage1::composeMachineFilePath() 61 bool UIWizardNewVMPage0::startHeadless() const 215 62 { 216 if (!m_pNameAndSystemEditor) 217 return; 218 if (m_pNameAndSystemEditor->name().isEmpty() || m_pNameAndSystemEditor->path().isEmpty()) 219 return; 220 /* Get VBox: */ 221 CVirtualBox vbox = uiCommon().virtualBox(); 222 223 /* Compose machine filename: */ 224 m_strMachineFilePath = vbox.ComposeMachineFilename(m_pNameAndSystemEditor->name(), 225 m_strGroup, 226 QString(), 227 m_pNameAndSystemEditor->path()); 228 /* Compose machine folder/basename: */ 229 const QFileInfo fileInfo(m_strMachineFilePath); 230 m_strMachineFolder = fileInfo.absolutePath(); 231 m_strMachineBaseName = fileInfo.completeBaseName(); 63 if (!m_pStartHeadlessCheckBox) 64 return false; 65 return m_pStartHeadlessCheckBox->isChecked(); 232 66 } 233 67 234 bool UIWizardNewVMPage1::createMachineFolder() 235 { 236 if (!m_pNameAndSystemEditor) 237 return false; 238 /* Cleanup previosly created folder if any: */ 239 if (!cleanupMachineFolder()) 240 { 241 msgCenter().cannotRemoveMachineFolder(m_strMachineFolder, thisImp()); 242 return false; 243 } 244 245 composeMachineFilePath(); 246 247 /* Check if the folder already exists and check if it has been created by this wizard */ 248 if (QDir(m_strMachineFolder).exists()) 249 { 250 /* Looks like we have already created this folder for this run of the wizard. Just return */ 251 if (m_strCreatedFolder == m_strMachineFolder) 252 return true; 253 /* The folder is there but not because of this wizard. Avoid overwriting a existing machine's folder */ 254 else 255 { 256 msgCenter().cannotRewriteMachineFolder(m_strMachineFolder, thisImp()); 257 return false; 258 } 259 } 260 261 /* Try to create new folder (and it's predecessors): */ 262 bool fMachineFolderCreated = QDir().mkpath(m_strMachineFolder); 263 if (!fMachineFolderCreated) 264 { 265 msgCenter().cannotCreateMachineFolder(m_strMachineFolder, thisImp()); 266 return false; 267 } 268 m_strCreatedFolder = m_strMachineFolder; 269 return true; 270 } 271 272 bool UIWizardNewVMPage1::cleanupMachineFolder(bool fWizardCancel /* = false */) 273 { 274 /* Make sure folder was previosly created: */ 275 if (m_strCreatedFolder.isEmpty()) 276 return true; 277 /* Clean this folder if the machine folder has been changed by the user or we are cancelling the wizard: */ 278 if (m_strCreatedFolder != m_strMachineFolder || fWizardCancel) 279 { 280 /* Try to cleanup folder (and it's predecessors): */ 281 bool fMachineFolderRemoved = QDir().rmpath(m_strCreatedFolder); 282 /* Reset machine folder value: */ 283 if (fMachineFolderRemoved) 284 m_strCreatedFolder = QString(); 285 /* Return cleanup result: */ 286 return fMachineFolderRemoved; 287 } 288 return true; 289 } 290 291 QString UIWizardNewVMPage1::machineFilePath() const 292 { 293 return m_strMachineFilePath; 294 } 295 296 void UIWizardNewVMPage1::setMachineFilePath(const QString &strMachineFilePath) 297 { 298 m_strMachineFilePath = strMachineFilePath; 299 } 300 301 QString UIWizardNewVMPage1::machineFolder() const 302 { 303 return m_strMachineFolder; 304 } 305 306 void UIWizardNewVMPage1::setMachineFolder(const QString &strMachineFolder) 307 { 308 m_strMachineFolder = strMachineFolder; 309 } 310 311 QString UIWizardNewVMPage1::machineBaseName() const 312 { 313 return m_strMachineBaseName; 314 } 315 316 void UIWizardNewVMPage1::setMachineBaseName(const QString &strMachineBaseName) 317 { 318 m_strMachineBaseName = strMachineBaseName; 319 } 320 321 UIWizardNewVMPageBasic1::UIWizardNewVMPageBasic1(const QString &strGroup) 322 : UIWizardNewVMPage1(strGroup) 68 UIWizardNewVMPageBasic0::UIWizardNewVMPageBasic0() 69 : UIWizardNewVMPage0() 323 70 { 324 71 /* Create widgets: */ … … 326 73 { 327 74 m_pLabel = new QIRichTextLabel(this); 328 m_pNameAndSystemEditor = new UINameAndSystemEditor(this, true, true, true); 75 m_pUnattendedCheckBox = new QCheckBox; 76 connect(m_pUnattendedCheckBox, &QCheckBox::toggled, this, &UIWizardNewVMPageBasic0::sltUnattendedCheckBoxToggle); 77 m_pISOSelectorLabel = new QLabel; 78 { 79 m_pISOSelectorLabel->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum); 80 m_pISOSelectorLabel->setEnabled(false); 81 } 82 m_pISOFilePathSelector = new UIFilePathSelector; 83 { 84 m_pISOFilePathSelector->setResetEnabled(false); 85 m_pISOFilePathSelector->setMode(UIFilePathSelector::Mode_File_Open); 86 m_pISOFilePathSelector->setFileDialogFilters("*.iso *.ISO"); 87 m_pISOFilePathSelector->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum); 88 m_pISOFilePathSelector->setEnabled(false); 89 connect(m_pISOFilePathSelector, &UIFilePathSelector::pathChanged, this, &UIWizardNewVMPageBasic0::sltPathChanged); 90 } 91 m_pStartHeadlessCheckBox = new QCheckBox; 92 { 93 m_pStartHeadlessCheckBox->setEnabled(false); 94 } 329 95 pMainLayout->addWidget(m_pLabel); 330 pMainLayout->addWidget(m_pNameAndSystemEditor); 96 97 QGridLayout *pISOSelectorLayout = new QGridLayout; 98 pISOSelectorLayout->addWidget(m_pUnattendedCheckBox, 0, 0, 1, 5); 99 pISOSelectorLayout->addWidget(m_pISOSelectorLabel, 1, 1, 1, 1); 100 pISOSelectorLayout->addWidget(m_pISOFilePathSelector, 1, 2, 1, 4); 101 pISOSelectorLayout->addWidget(m_pStartHeadlessCheckBox, 2, 2, 1, 5); 102 103 pMainLayout->addLayout(pISOSelectorLayout); 331 104 pMainLayout->addStretch(); 332 105 } 333 106 334 /* Setup connections: */335 connect(m_pNameAndSystemEditor, &UINameAndSystemEditor::sigNameChanged, this, &UIWizardNewVMPageBasic1::sltNameChanged);336 connect(m_pNameAndSystemEditor, &UINameAndSystemEditor::sigPathChanged, this, &UIWizardNewVMPageBasic1::sltPathChanged);337 connect(m_pNameAndSystemEditor, &UINameAndSystemEditor::sigOsTypeChanged, this, &UIWizardNewVMPageBasic1::sltOsTypeChanged);338 107 339 108 /* Register fields: */ 340 registerField("name*", m_pNameAndSystemEditor, "name", SIGNAL(sigNameChanged(const QString &))); 341 registerField("type", m_pNameAndSystemEditor, "type", SIGNAL(sigOsTypeChanged())); 342 registerField("machineFilePath", this, "machineFilePath"); 343 registerField("machineFolder", this, "machineFolder"); 344 registerField("machineBaseName", this, "machineBaseName"); 109 registerField("ISOFilePath", this, "ISOFilePath"); 110 registerField("isUnattendedEnabled", this, "isUnattendedEnabled"); 111 registerField("startHeadless", this, "startHeadless"); 345 112 } 346 113 347 void UIWizardNewVMPageBasic1::sltNameChanged(const QString &strNewName) 114 bool UIWizardNewVMPageBasic0::isComplete() const 348 115 { 349 /* Call to base-class: */350 onNameChanged(strNewName);351 composeMachineFilePath();116 bool fISOFileOK = checkISOFile(); 117 //emit completeChanged(); 118 return fISOFileOK; 352 119 } 353 120 354 void UIWizardNewVMPageBasic 1::sltPathChanged(const QString &strNewPath)121 void UIWizardNewVMPageBasic0::sltUnattendedCheckBoxToggle(bool fEnabled) 355 122 { 356 Q_UNUSED(strNewPath); 357 composeMachineFilePath(); 123 if (m_pISOSelectorLabel) 124 m_pISOSelectorLabel->setEnabled(fEnabled); 125 if (m_pISOFilePathSelector) 126 m_pISOFilePathSelector->setEnabled(fEnabled); 127 if (m_pStartHeadlessCheckBox) 128 m_pStartHeadlessCheckBox->setEnabled(fEnabled); 129 emit completeChanged(); 358 130 } 359 131 360 void UIWizardNewVMPageBasic 1::sltOsTypeChanged()132 void UIWizardNewVMPageBasic0::sltPathChanged(const QString &strPath) 361 133 { 362 /* Call to base-class: */363 onOsTypeChanged();134 Q_UNUSED(strPath); 135 emit completeChanged(); 364 136 } 365 137 366 void UIWizardNewVMPageBasic 1::retranslateUi()138 void UIWizardNewVMPageBasic0::retranslateUi() 367 139 { 368 140 /* Translate page: */ 369 setTitle(UIWizardNewVM::tr(" Name and operating system"));141 setTitle(UIWizardNewVM::tr("Unattended Guest OS Install")); 370 142 371 143 /* Translate widgets: */ 372 m_pLabel->setText(UIWizardNewVM::tr("Please choose a descriptive name and destination folder for the new virtual machine " 373 "and select the type of operating system you intend to install on it. " 374 "The name you choose will be used throughout VirtualBox " 375 "to identify this machine.")); 144 m_pLabel->setText(UIWizardNewVM::tr("You can enable the unattended (automated) guest OS install " 145 "and select an installation medium. The guest OS will be " 146 "installed after this window is closed. ")); 147 m_pUnattendedCheckBox->setText(UIWizardNewVM::tr("Enable unattended guest OS Install")); 148 m_pISOSelectorLabel->setText(UIWizardNewVM::tr("ISO:")); 149 if (m_pStartHeadlessCheckBox) 150 { 151 m_pStartHeadlessCheckBox->setText(UIWizardNewVM::tr("Start VM Headless")); 152 m_pStartHeadlessCheckBox->setToolTip(UIWizardNewVM::tr("When checked the unattended will start the virtual machine headless")); 153 } 376 154 } 377 155 378 void UIWizardNewVMPageBasic1::initializePage() 156 bool UIWizardNewVMPageBasic0::checkISOFile() const 157 { 158 if (m_pUnattendedCheckBox && m_pUnattendedCheckBox->isChecked()) 159 { 160 QString strISOFilePath = m_pISOFilePathSelector ? m_pISOFilePathSelector->path() : QString(); 161 if (!QFileInfo(strISOFilePath).exists()) 162 return false; 163 } 164 return true; 165 } 166 167 void UIWizardNewVMPageBasic0::initializePage() 379 168 { 380 169 /* Translate page: */ 381 170 retranslateUi(); 382 if (m_p NameAndSystemEditor)383 m_p NameAndSystemEditor->setFocus();171 if (m_pUnattendedCheckBox) 172 m_pUnattendedCheckBox->setFocus(); 384 173 } 385 174 386 void UIWizardNewVMPageBasic 1::cleanupPage()175 void UIWizardNewVMPageBasic0::cleanupPage() 387 176 { 388 /* Cleanup: */389 cleanupMachineFolder();390 /* Call to base-class: */391 177 UIWizardPage::cleanupPage(); 392 178 } 393 179 394 bool UIWizardNewVMPageBasic 1::validatePage()180 bool UIWizardNewVMPageBasic0::validatePage() 395 181 { 396 /* Try to create machine folder: */ 397 return createMachineFolder(); 182 return checkISOFile(); 398 183 } -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageBasic0.h
r84828 r84861 1 1 /* $Id$ */ 2 2 /** @file 3 * VBox Qt GUI - UIWizardNewVMPageBasic 1class declaration.3 * VBox Qt GUI - UIWizardNewVMPageBasic0 class declaration. 4 4 */ 5 5 … … 16 16 */ 17 17 18 #ifndef FEQT_INCLUDED_SRC_wizards_newvm_UIWizardNewVMPageBasic 1_h19 #define FEQT_INCLUDED_SRC_wizards_newvm_UIWizardNewVMPageBasic 1_h18 #ifndef FEQT_INCLUDED_SRC_wizards_newvm_UIWizardNewVMPageBasic0_h 19 #define FEQT_INCLUDED_SRC_wizards_newvm_UIWizardNewVMPageBasic0_h 20 20 #ifndef RT_WITHOUT_PRAGMA_ONCE 21 21 # pragma once … … 28 28 class UINameAndSystemEditor; 29 29 class QIRichTextLabel; 30 class QCheckBox; 31 class QLabel; 32 class UIFilePathSelector; 30 33 31 34 /* 1st page of the New Virtual Machine wizard (base part): */ 32 class UIWizardNewVMPage 1: public UIWizardPageBase35 class UIWizardNewVMPage0 : public UIWizardPageBase 33 36 { 34 37 protected: 35 38 36 39 /* Constructor: */ 37 UIWizardNewVMPage 1(const QString &strGroup);40 UIWizardNewVMPage0(); 38 41 39 /* Handlers: */40 void onNameChanged(QString strNewName);41 void onOsTypeChanged();42 QString ISOFilePath() const; 43 bool isUnattendedEnabled() const; 44 bool startHeadless() const; 42 45 43 bool createMachineFolder(); 44 /** Removes a previously created folder (if exists) before creating a new one. 45 * used during page cleanup and new folder creation. Called upon page Next/Back and 46 * wizard cancel */ 47 bool cleanupMachineFolder(bool fWizardCancel = false); 48 49 QString machineFilePath() const; 50 void setMachineFilePath(const QString &strMachineFilePath); 51 52 QString machineFolder() const; 53 void setMachineFolder(const QString &strMachineFolder); 54 55 QString machineBaseName() const; 56 void setMachineBaseName(const QString &strMachineBaseName); 57 58 /** calls CVirtualBox::ComposeMachineFilename(...) and sets related member variables */ 59 void composeMachineFilePath(); 60 61 /** Provides a path selector and a line edit field for path and name entry. */ 62 UINameAndSystemEditor *m_pNameAndSystemEditor; 46 QCheckBox *m_pUnattendedCheckBox; 47 QCheckBox *m_pStartHeadlessCheckBox; 48 QLabel *m_pISOSelectorLabel; 49 UIFilePathSelector *m_pISOFilePathSelector; 63 50 64 51 private: 65 52 66 /** Full path (including the file name) of the machine's configuration file. */67 QString m_strMachineFilePath;68 /** Path of the folder hosting the machine's configuration file. Generated from m_strMachineFilePath. */69 QString m_strMachineFolder;70 /** Path of the folder created by this wizard page. Used to remove previously created71 * folder. see cleanupMachineFolder();*/72 QString m_strCreatedFolder;73 /** Base name of the machine is generated from the m_strMachineFilePath. */74 QString m_strMachineBaseName;75 76 77 QString m_strGroup;78 bool m_fSupportsHWVirtEx;79 bool m_fSupportsLongMode;80 53 friend class UIWizardNewVM; 81 54 }; 82 55 83 56 /* 1st page of the New Virtual Machine wizard (basic extension): */ 84 class UIWizardNewVMPageBasic 1 : public UIWizardPage, public UIWizardNewVMPage157 class UIWizardNewVMPageBasic0 : public UIWizardPage, public UIWizardNewVMPage0 85 58 { 86 59 Q_OBJECT; 87 Q_PROPERTY(QString machineFilePath READ machineFilePath WRITE setMachineFilePath);88 Q_PROPERTY( QString machineFolder READ machineFolder WRITE setMachineFolder);89 Q_PROPERTY( QString machineBaseName READ machineBaseName WRITE setMachineBaseName);60 Q_PROPERTY(QString ISOFilePath READ ISOFilePath); 61 Q_PROPERTY(bool isUnattendedEnabled READ isUnattendedEnabled); 62 Q_PROPERTY(bool startHeadless READ startHeadless); 90 63 91 64 public: 92 65 93 66 /* Constructor: */ 94 UIWizardNewVMPageBasic1(const QString &strGroup); 67 UIWizardNewVMPageBasic0(); 68 virtual bool isComplete() const; /* override */ 95 69 96 70 protected: … … 101 75 private slots: 102 76 103 /* Handlers: */ 104 void sltNameChanged(const QString &strNewText); 105 void sltPathChanged(const QString &strNewPath); 106 void sltOsTypeChanged(); 77 void sltUnattendedCheckBoxToggle(bool fEnabled); 78 void sltPathChanged(const QString &strPath); 107 79 108 80 private: 81 82 /** Returns false if user selects unattended install and does not provide a valid ISO file path. Else returns true. */ 83 bool checkISOFile() const; 109 84 110 85 /* Translation stuff: */ … … 122 97 }; 123 98 124 #endif /* !FEQT_INCLUDED_SRC_wizards_newvm_UIWizardNewVMPageBasic 1_h */99 #endif /* !FEQT_INCLUDED_SRC_wizards_newvm_UIWizardNewVMPageBasic0_h */
Note:
See TracChangeset
for help on using the changeset viewer.